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 @@ -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,28 @@ public function hasProperty(string $propertyName): bool
473476
474477 public function hasMethod (string $ methodName ): bool
475478 {
479+ $ key = sprintf ('%s-%s ' , $ methodName , $ this ->getCacheKey ());
480+
481+ if (array_key_exists ($ key , $ this ->hasMethodCache )) {
482+ return $ this ->hasMethodCache [$ key ];
483+ }
484+
476485 foreach ($ this ->methodsClassReflectionExtensions as $ extension ) {
477486 if ($ extension ->hasMethod ($ this , $ methodName )) {
487+ $ this ->hasMethodCache [$ key ] = true ;
488+
478489 return true ;
479490 }
480491 }
481492
482493 if ($ this ->requireExtendsMethodsClassReflectionExtension ->hasMethod ($ this , $ methodName )) {
494+ $ this ->hasMethodCache [$ key ] = true ;
495+
483496 return true ;
484497 }
485498
499+ $ this ->hasMethodCache [$ key ] = false ;
500+
486501 return false ;
487502 }
488503
You can’t perform that action at this time.
0 commit comments