8000 bug #49292 [VarDumper] Fix error when reflected class has default Enu… · fancyweb/symfony@2a633cf · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a633cf

Browse files
bug symfony#49292 [VarDumper] Fix error when reflected class has default Enum parameter in constructor (kapiwko)
This PR was submitted for the 6.3 branch but it was squashed and merged into the 5.4 branch instead. Discussion ---------- [VarDumper] Fix error when reflected class has default Enum parameter in constructor | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | no | License | MIT | Doc PR | no Have classes: ``` enum GeometryType: string { case Geometry = 'GEOMETRY'; } ``` ``` fin E2FD al class Geometry { public function __construct(GeometryType $type = GeometryType::Geometry) { } } ``` Try to dump reflection of class Geometry: ``` $reflection = new \ReflectionClass(Geometry::class); dump($reflection); ``` Have error: `Symfony\Component\VarDumper\Caster\ConstStub::__construct(): Argument #2 ($value) must be of type string|int|float|null, App\Infrastructure\Geometry\GeometryType given, called in [...]/vendor/symfony/var-dumper/Caster/ReflectionCaster.php on line 296` Commits ------- d6a7730 [VarDumper] Fix error when reflected class has default Enum parameter in constructor
2 parents 111af45 + d6a7730 commit 2a633cf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
292292
if ($c->isOptional()) {
293293
try {
294294
$a[$prefix.'default'] = $v = $c->getDefaultValue();
295-
if ($c->isDefaultValueConstant()) {
295+
if ($c->isDefaultValueConstant() && !\is_object($v)) {
296296
$a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v);
297297
}
298298
if (null === $v) {

0 commit comments

Comments
 (0)
0