Fix issues with parsing invokable macros (#1124)

* Fix issues with parsing invokable macros

* Add macro test

# Conflicts:
#	tests/MacroTest.php
This commit is contained in:
Stan Daniëls
2021-01-09 13:24:28 +01:00
committed by GitHub
parent 4f13ba85bd
commit fd30d1190d
4 changed files with 65 additions and 2 deletions
+5 -1
View File
@@ -65,7 +65,11 @@ class Macro extends Method
protected function addLocationToPhpDoc()
{
$enclosingClass = $this->method->getClosureScopeClass();
if ($this->method->name === '__invoke') {
$enclosingClass = $this->method->getDeclaringClass();
} else {
$enclosingClass = $this->method->getClosureScopeClass();
}
/** @var \ReflectionMethod $enclosingMethod */
$enclosingMethod = Collection::make($enclosingClass->getMethods())
+1 -1
View File
@@ -55,7 +55,7 @@ class Method
$this->initClassDefinedProperties($method, $class);
//Reference the 'real' function in the declaring class
$this->root = '\\' . ltrim($class->getName(), '\\');
$this->root = '\\' . ltrim($method->name === '__invoke' ? $method->getDeclaringClass()->getName() : $class->getName(), '\\');
//Create a DocBlock and serializer instance
$this->initPhpDoc($method);