Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Reflection/ClassReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ class ClassReflection
/** @var array<string, true> */
private static array $resolvingTypeAliasImports = [];

/** @var array<string, bool> */
private array $hasMethodCache = [];

/**
* @param PropertiesClassReflectionExtension[] $propertiesClassReflectionExtensions
* @param MethodsClassReflectionExtension[] $methodsClassReflectionExtensions
Expand Down Expand Up @@ -482,16 +485,26 @@ public function hasProperty(string $propertyName): bool

public function hasMethod(string $methodName): bool
{
if (array_key_exists($methodName, $this->hasMethodCache)) {
return $this->hasMethodCache[$methodName];
}

foreach ($this->methodsClassReflectionExtensions as $extension) {
if ($extension->hasMethod($this, $methodName)) {
$this->hasMethodCache[$methodName] = true;

return true;
}
}

if ($this->requireExtendsMethodsClassReflectionExtension->hasMethod($this, $methodName)) {
$this->hasMethodCache[$methodName] = true;

return true;
}

$this->hasMethodCache[$methodName] = false;

return false;
}

Expand Down
Loading