Skip to content

Commit

Permalink
Factory: parameters 'int $foo = null' are parsed as '?int'
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 8, 2024
1 parent 08ab9bf commit c02c065
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/PhpGenerator/Factory.php
Expand Up @@ -218,8 +218,6 @@ public function fromParameterReflection(\ReflectionParameter $from): Parameter
} else {
$param->setDefaultValue($from->getDefaultValue());
}

$param->setNullable($param->isNullable() && $param->getDefaultValue() !== null);
}

$param->setAttributes($this->getAttributes($from));
Expand Down
2 changes: 1 addition & 1 deletion tests/PhpGenerator/expected/ClassType.from.bodies.expect
Expand Up @@ -38,7 +38,7 @@ abstract class Class7
}


public function resolving($a = Abc\a\FOO, self $b = null, $c = self::FOO)
public function resolving($a = Abc\a\FOO, ?self $b = null, $c = self::FOO)
{
// constants
echo FOO;
Expand Down
4 changes: 2 additions & 2 deletions tests/PhpGenerator/expected/ClassType.from.expect
Expand Up @@ -55,7 +55,7 @@ class Class2 extends Class1 implements Interface2
}


private function func4(array $a = [], Class2 $b = null, $c = Unknown::ABC)
private function func4(array $a = [], ?Class2 $b = null, $c = Unknown::ABC)
{
}

Expand All @@ -77,7 +77,7 @@ class Class4

class Class5
{
public function func1(\A $a, ?\B $b, \C $c = null, \D $d = null, ?int $i = 1, ?array $arr = [])
public function func1(\A $a, ?\B $b, ?\C $c = null, ?\D $d = null, ?int $i = 1, ?array $arr = [])
{
}

Expand Down

0 comments on commit c02c065

Please sign in to comment.