From 119f01a7bd590469cb01b538f20a125a28853626 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 24 Feb 2021 19:40:21 +0100 Subject: [PATCH] re-fixed [Closes #72] --- src/PhpGenerator/Printer.php | 2 +- tests/PhpGenerator/expected/ClassType.expect | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpGenerator/Printer.php b/src/PhpGenerator/Printer.php index d89da4b5..e96cd13c 100644 --- a/src/PhpGenerator/Printer.php +++ b/src/PhpGenerator/Printer.php @@ -300,7 +300,7 @@ public function printType(?string $type, bool $nullable = false, PhpNamespace $n $type = $namespace->unresolveUnionType($type); } if ($nullable && strcasecmp($type, 'mixed')) { - $type = strpos('|', $type) === false + $type = strpos($type, '|') === false ? '?' . $type : $type . '|null'; } diff --git a/tests/PhpGenerator/expected/ClassType.expect b/tests/PhpGenerator/expected/ClassType.expect index dc9797fd..5f837efa 100644 --- a/tests/PhpGenerator/expected/ClassType.expect +++ b/tests/PhpGenerator/expected/ClassType.expect @@ -43,5 +43,5 @@ abstract class Example extends ParentClass implements IExample, IOne } - abstract public function show($item, array|null &$res = null, ?stdClass|string $bar = null); + abstract public function show($item, array|null &$res = null, stdClass|string|null $bar = null); }