Skip to content

Commit 5b3060c

Browse files
committed
Don't add value of (default/static) objects to the signature
1 parent 623fd6b commit 5b3060c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Resource/ReflectionClassResource.php

Lines changed: 1 addition & 1 deletion
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(isset($defaults[$p->name]) ? $defaults[$p->name] : null, true);
143+
yield print_r(isset($defaults[$p->name]) && !\is_object($defaults[$p->name]) ? $defaults[$p->name] : null, true);
144144
}
145145
}
146146

Tests/Resource/ReflectionClassResourceTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@ public function testServiceSubscriber()
170170
$res = new ReflectionClassResource(new \ReflectionClass(TestServiceSubscriber::class));
171171
$this->assertTrue($res->isFresh(0));
172172
}
173+
174+
public function testIgnoresObjectsInSignature()
175+
{
176+
$res = new ReflectionClassResource(new \ReflectionClass(TestServiceWithStaticProperty::class));
177+
$this->assertTrue($res->isFresh(0));
178+
179+
TestServiceWithStaticProperty::$initializedObject = new TestServiceWithStaticProperty();
180+
$this->assertTrue($res->isFresh(0));
181+
}
173182
}
174183

175184
interface DummyInterface
@@ -195,3 +204,8 @@ public static function getSubscribedServices()
195204
return self::$subscribedServices;
196205
}
197206
}
207+
208+
class TestServiceWithStaticProperty
209+
{
210+
public static $initializedObject;
211+
}

0 commit comments

Comments
 (0)