@@ -144,6 +144,9 @@ final class ClassReflection
144
144
/** @var array<string, bool> */
145
145
private array $ hasMethodCache = [];
146
146
147
+ /** @var array<string, bool> */
148
+ private array $ hasPropertyCache = [];
149
+
147
150
/**
148
151
* @param PropertiesClassReflectionExtension[] $propertiesClassReflectionExtensions
149
152
* @param MethodsClassReflectionExtension[] $methodsClassReflectionExtensions
@@ -454,24 +457,28 @@ private function allowsDynamicPropertiesExtensions(): bool
454
457
455
458
public function hasProperty (string $ propertyName ): bool
456
459
{
460
+ if (array_key_exists ($ propertyName , $ this ->hasPropertyCache )) {
461
+ return $ this ->hasPropertyCache [$ propertyName ];
462
+ }
463
+
457
464
if ($ this ->isEnum ()) {
458
- return $ this ->hasNativeProperty ($ propertyName );
465
+ return $ this ->hasPropertyCache [ $ propertyName ] = $ this -> hasNativeProperty ($ propertyName );
459
466
}
460
467
461
468
foreach ($ this ->propertiesClassReflectionExtensions as $ i => $ extension ) {
462
469
if ($ i > 0 && !$ this ->allowsDynamicPropertiesExtensions ()) {
463
470
break ;
464
471
}
465
472
if ($ extension ->hasProperty ($ this , $ propertyName )) {
466
- return true ;
473
+ return $ this -> hasPropertyCache [ $ propertyName ] = true ;
467
474
}
468
475
}
469
476
470
477
if ($ this ->requireExtendsPropertiesClassReflectionExtension ->hasProperty ($ this , $ propertyName )) {
471
- return true ;
478
+ return $ this -> hasPropertyCache [ $ propertyName ] = true ;
472
479
}
473
480
474
- return false ;
481
+ return $ this -> hasPropertyCache [ $ propertyName ] = false ;
475
482
}
476
483
477
484
public function hasMethod (string $ methodName ): bool
0 commit comments