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
141
141
/** @var array<string, true> */
142
142
private static array $ resolvingTypeAliasImports = [];
143
143
144
+ /** @var array<string, bool> */
145
+ private array $ hasMethodCache = [];
146
+
144
147
/**
145
148
* @param PropertiesClassReflectionExtension[] $propertiesClassReflectionExtensions
146
149
* @param MethodsClassReflectionExtension[] $methodsClassReflectionExtensions
@@ -473,16 +476,28 @@ public function hasProperty(string $propertyName): bool
473
476
474
477
public function hasMethod (string $ methodName ): bool
475
478
{
479
+ $ key = sprintf ('%s-%s ' , $ methodName , $ this ->getCacheKey ());
480
+
481
+ if (array_key_exists ($ key , $ this ->hasMethodCache )) {
482
+ return $ this ->hasMethodCache [$ key ];
483
+ }
484
+
476
485
foreach ($ this ->methodsClassReflectionExtensions as $ extension ) {
477
486
if ($ extension ->hasMethod ($ this , $ methodName )) {
487
+ $ this ->hasMethodCache [$ key ] = true ;
488
+
478
489
return true ;
479
490
}
480
491
}
481
492
482
493
if ($ this ->requireExtendsMethodsClassReflectionExtension ->hasMethod ($ this , $ methodName )) {
494
+ $ this ->hasMethodCache [$ key ] = true ;
495
+
483
496
return true ;
484
497
}
485
498
499
+ $ this ->hasMethodCache [$ key ] = false ;
500
+
486
501
return false ;
487
502
}
488
503
You can’t perform that action at this time.
0 commit comments