File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,9 @@ final class ClassReflection
141141 /** @var array<string, true> */
142142 private static array $ resolvingTypeAliasImports = [];
143143
144+ /** @var array<string, bool> */
145+ private array $ hasMethodCache = [];
146+
144147 /**
145148 * @param PropertiesClassReflectionExtension[] $propertiesClassReflectionExtensions
146149 * @param MethodsClassReflectionExtension[] $methodsClassReflectionExtensions
@@ -473,16 +476,26 @@ public function hasProperty(string $propertyName): bool
473476
474477 public function hasMethod (string $ methodName ): bool
475478 {
479+ if (array_key_exists ($ methodName , $ this ->hasMethodCache )) {
480+ return $ this ->hasMethodCache [$ methodName ];
481+ }
482+
476483 foreach ($ this ->methodsClassReflectionExtensions as $ extension ) {
477484 if ($ extension ->hasMethod ($ this , $ methodName )) {
485+ $ this ->hasMethodCache [$ methodName ] = true ;
486+
478487 return true ;
479488 }
480489 }
481490
482491 if ($ this ->requireExtendsMethodsClassReflectionExtension ->hasMethod ($ this , $ methodName )) {
492+ $ this ->hasMethodCache [$ methodName ] = true ;
493+
483494 return true ;
484495 }
485496
497+ $ this ->hasMethodCache [$ methodName ] = false ;
498+
486499 return false ;
487500 }
488501
You can’t perform that action at this time.
0 commit comments