From 2b3c9a244956c98b413bf418d835be96787f1abb Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 12 Mar 2019 06:38:49 -0400 Subject: [PATCH] Fix BC introduced in #765 (#778) See my comment https://github.com/barryvdh/laravel-ide-helper/pull/765#issuecomment-471014271: The change in #765 made anonymous functions get reflected with `ReflectionMethod` instead of `ReflectionFunction`, which makes it lose the doc comment. This means that the generated helpers are missing their return types. This is because Closure is also an object and callable. To fix it, Closure should be excluded from that new condition. --- src/Alias.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Alias.php b/src/Alias.php index 522ff61..8f1c570 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -10,6 +10,7 @@ namespace Barryvdh\LaravelIdeHelper; +use Closure; use ReflectionClass; use Barryvdh\Reflection\DocBlock; use Barryvdh\Reflection\DocBlock\Context; @@ -395,7 +396,7 @@ class Alias return new \ReflectionMethod($macro_func[0], $macro_func[1]); } - if (is_object($macro_func) && is_callable($macro_func)) { + if (is_object($macro_func) && is_callable($macro_func) && !$macro_func instanceof Closure) { return new \ReflectionMethod($macro_func, '__invoke'); }