From a628fb34293c84c807a1a561883811067e49ebcb Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 22 Sep 2022 16:00:01 +0200 Subject: [PATCH] ClassReflection - do not execute properties extensions on PHP 8.2 if the class does not allow dynamic properties --- src/Reflection/ClassReflection.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Reflection/ClassReflection.php b/src/Reflection/ClassReflection.php index e7b940b35a..63b371a07a 100644 --- a/src/Reflection/ClassReflection.php +++ b/src/Reflection/ClassReflection.php @@ -365,7 +365,10 @@ public function hasProperty(string $propertyName): bool return $this->hasNativeProperty($propertyName); } - foreach ($this->propertiesClassReflectionExtensions as $extension) { + foreach ($this->propertiesClassReflectionExtensions as $i => $extension) { + if ($i > 0 && !$this->allowsDynamicProperties()) { + continue; + } if ($extension->hasProperty($this, $propertyName)) { return true; } @@ -514,7 +517,10 @@ public function getProperty(string $propertyName, ClassMemberAccessAnswerer $sco $key = sprintf('%s-%s', $key, $scope->getClassReflection()->getCacheKey()); } if (!isset($this->properties[$key])) { - foreach ($this->propertiesClassReflectionExtensions as $extension) { + foreach ($this->propertiesClassReflectionExtensions as $i => $extension) { + if ($i > 0 && !$this->allowsDynamicProperties()) { + continue; + } if (!$extension->hasProperty($this, $propertyName)) { continue; }