@@ -144,6 +144,9 @@ final class ClassReflection
144144 /** @var array<string, bool> */
145145 private array $ hasMethodCache = [];
146146
147+ /** @var array<string, bool> */
148+ private array $ hasPropertyCache = [];
149+
147150 /**
148151 * @param PropertiesClassReflectionExtension[] $propertiesClassReflectionExtensions
149152 * @param MethodsClassReflectionExtension[] $methodsClassReflectionExtensions
@@ -454,24 +457,28 @@ private function allowsDynamicPropertiesExtensions(): bool
454457
455458 public function hasProperty (string $ propertyName ): bool
456459 {
460+ if (array_key_exists ($ propertyName , $ this ->hasPropertyCache )) {
461+ return $ this ->hasPropertyCache [$ propertyName ];
462+ }
463+
457464 if ($ this ->isEnum ()) {
458- return $ this ->hasNativeProperty ($ propertyName );
465+ return $ this ->hasPropertyCache [ $ propertyName ] = $ this -> hasNativeProperty ($ propertyName );
459466 }
460467
461468 foreach ($ this ->propertiesClassReflectionExtensions as $ i => $ extension ) {
462469 if ($ i > 0 && !$ this ->allowsDynamicPropertiesExtensions ()) {
463470 break ;
464471 }
465472 if ($ extension ->hasProperty ($ this , $ propertyName )) {
466- return true ;
473+ return $ this -> hasPropertyCache [ $ propertyName ] = true ;
467474 }
468475 }
469476
470477 if ($ this ->requireExtendsPropertiesClassReflectionExtension ->hasProperty ($ this , $ propertyName )) {
471- return true ;
478+ return $ this -> hasPropertyCache [ $ propertyName ] = true ;
472479 }
473480
474- return false ;
481+ return $ this -> hasPropertyCache [ $ propertyName ] = false ;
475482 }
476483
477484 public function hasMethod (string $ methodName ): bool
0 commit comments