Skip to content

Commit 9121f4d

Browse files
committed
minor #18021 Don't use reflections when possible (Ener-Getick)
This PR was merged into the 2.3 branch. Discussion ---------- Don't use reflections when possible | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Use php functions instead of reflection when possible (to improve a bit the performance). Commits ------- a46270a Don't use reflections when possible
2 parents 6a03b55 + 1f7b401 commit 9121f4d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Mapping/PropertyMetadata.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ public function getPropertyValue($object)
4545
*/
4646
protected function newReflectionMember($objectOrClassName)
4747
{
48-
$class = new \ReflectionClass($objectOrClassName);
49-
while (!$class->hasProperty($this->getName())) {
50-
$class = $class->getParentClass();
48+
while (!property_exists($objectOrClassName, $this->getName())) {
49+
$objectOrClassName = get_parent_class($objectOrClassName);
5150
}
5251

53-
$member = new \ReflectionProperty($class->getName(), $this->getName());
52+
$member = new \ReflectionProperty($objectOrClassName, $this->getName());
5453
$member->setAccessible(true);
5554

5655
return $member;

0 commit comments

Comments
 (0)