Skip to content

Commit 79a87cb

Browse files
bug #41767 [Config] fix tracking default values that reference the parent class (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [Config] fix tracking default values that reference the parent class | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #41133 | License | MIT | Doc PR | - Commits ------- 978747e [Config] fix tracking default values that reference the parent class
2 parents 08b1682 + 978747e commit 79a87cb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ private function generateSignature(\ReflectionClass $class): iterable
161161
}
162162
}
163163

164+
$defined = \Closure::bind(static function ($c) { return \defined($c); }, null, $class->name);
165+
164166
foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $m) {
165167
if (\PHP_VERSION_ID >= 80000) {
166168
foreach ($m->getAttributes() as $a) {
@@ -187,7 +189,7 @@ private function generateSignature(\ReflectionClass $class): iterable
187189
continue;
188190
}
189191

190-
if (!$p->isDefaultValueConstant() || \defined($p->getDefaultValueConstantName())) {
192+
if (!$p->isDefaultValueConstant() || $defined($p->getDefaultValueConstantName())) {
191193
$defaults[$p->name] = $p->getDefaultValue();
192194

193195
continue;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public function provideHashedSignature(): iterable
164164

165165
yield [true, 17, 'public function ccc($bar = 187) {}'];
166166
yield [true, 17, 'public function ccc($bar = ANOTHER_ONE_THAT_WILL_NEVER_BE_DEFINED_CCCCCCCCC) {}'];
167+
yield [true, 17, 'public function ccc($bar = parent::BOOM) {}'];
167168
yield [true, 17, null, static function () { \define('A_CONSTANT_THAT_FOR_SURE_WILL_NEVER_BE_DEFINED_CCCCCC', 'foo'); }];
168169
}
169170

0 commit comments

Comments
 (0)