Skip to content

Commit cd1d618

Browse files
committed
Printer: fixed combination nullable + mixed [Closes #74]
1 parent e772208 commit cd1d618

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/PhpGenerator/Printer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public function printType(?string $type, bool $nullable = false, PhpNamespace $n
293293
if ($this->resolveTypes && $namespace) {
294294
$type = $namespace->unresolveUnionType($type);
295295
}
296-
if ($nullable) {
296+
if ($nullable && strcasecmp($type, 'mixed')) {
297297
$type = strpos('|', $type) === false
298298
? '?' . $type
299299
: $type . '|null';

tests/PhpGenerator/expected/ClassType.from.80.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Class10
3939
public string|int $prop;
4040

4141

42-
public function test(string|int $param): string|int
42+
public function test(mixed $param): string|int
4343
{
4444
}
4545
}

tests/PhpGenerator/fixtures/classes.php80

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Class10
4444
{
4545
public string|int $prop;
4646

47-
function test(string|int $param): string|int
47+
function test(mixed $param): string|int
4848
{
4949
}
5050
}

0 commit comments

Comments
 (0)