Skip to content

Commit bad2a2c

Browse files
tvandervormfabpot
authored andcommitted
[Config] Fix for signatures of typed properties
1 parent 0825ea7 commit bad2a2c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Symfony/Component/Config/Resource/ReflectionClassResource.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private function generateSignature(\ReflectionClass $class)
140140

141141
foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) {
142142
yield $p->getDocComment().$p;
143-
yield print_r($defaults[$p->name], true);
143+
yield print_r($defaults[$p->name] ?? null, true);
144144
}
145145
}
146146

src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ public function provideHashedSignature()
137137
yield [1, 13, 'protected function prot($a = [123]) {}'];
138138
yield [0, 14, '/** priv docblock */'];
139139
yield [0, 15, ''];
140+
141+
if (\PHP_VERSION_ID >= 70400) {
142+
// PHP7.4 typed properties without default value are
143+
// undefined, make sure this doesn't throw an error
144+
yield [1, 5, 'public array $pub;'];
145+
yield [0, 7, 'protected int $prot;'];
146+
yield [0, 9, 'private string $priv;'];
147+
}
140148
}
141149

142150
public function testEventSubscriber()

0 commit comments

Comments
 (0)