Skip to content

Commit

Permalink
Fix default trait method parameter mentioning constant from the using…
Browse files Browse the repository at this point in the history
… class
  • Loading branch information
ondrejmirtes committed Mar 17, 2021
1 parent a41da9f commit 4fafef2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Reflection/ReflectionParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private function parseDefaultValueNode() : void

$this->defaultValue = (new CompileNodeToValue())->__invoke(
$defaultValueNode,
new CompilerContext($this->reflector, $this->function->getFileName(), $this->getDeclaringClass(), $namespace, $this->function->getName())
new CompilerContext($this->reflector, $this->function->getFileName(), $this->getImplementingClass(), $namespace, $this->function->getName())
);
}

Expand All @@ -235,7 +235,7 @@ private function findParentClassDeclaringConstant(string $constantName) : string
{
$method = $this->function;
assert($method instanceof ReflectionMethod);
$class = $method->getDeclaringClass();
$class = $method->getImplementingClass();

do {
if ($class->hasConstant($constantName)) {
Expand Down Expand Up @@ -282,6 +282,15 @@ public function getDeclaringClass() : ?ReflectionClass
return null;
}

public function getImplementingClass() : ?ReflectionClass
{
if ($this->function instanceof ReflectionMethod) {
return $this->function->getImplementingClass();
}

return null;
}

/**
* Is the parameter optional?
*
Expand Down

0 comments on commit 4fafef2

Please sign in to comment.