File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,9 @@ class ClassReflection
142142 /** @var array<string, true> */
143143 private static array $ resolvingTypeAliasImports = [];
144144
145+ /** @var array<string, bool> */
146+ private array $ hasMethodCache = [];
147+
145148 /**
146149 * @param PropertiesClassReflectionExtension[] $propertiesClassReflectionExtensions
147150 * @param MethodsClassReflectionExtension[] $methodsClassReflectionExtensions
@@ -482,16 +485,28 @@ public function hasProperty(string $propertyName): bool
482485
483486 public function hasMethod (string $ methodName ): bool
484487 {
488+ $ key = sprintf ('%s-%s ' , $ methodName , $ this ->getCacheKey ());
489+
490+ if (array_key_exists ($ key , $ this ->hasMethodCache )) {
491+ return $ this ->hasMethodCache [$ key ];
492+ }
493+
485494 foreach ($ this ->methodsClassReflectionExtensions as $ extension ) {
486495 if ($ extension ->hasMethod ($ this , $ methodName )) {
496+ $ this ->hasMethodCache [$ key ] = true ;
497+
487498 return true ;
488499 }
489500 }
490501
491502 if ($ this ->requireExtendsMethodsClassReflectionExtension ->hasMethod ($ this , $ methodName )) {
503+ $ this ->hasMethodCache [$ key ] = true ;
504+
492505 return true ;
493506 }
494507
508+ $ this ->hasMethodCache [$ key ] = false ;
509+
495510 return false ;
496511 }
497512
You can’t perform that action at this time.
0 commit comments