File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
8
8
### Added
9
9
- Fix phpdoc generate for custom cast with parameter [ \# 986 / artelkr] ( https://github.com/barryvdh/laravel-ide-helper/pull/986 )
10
10
- Created a possibility to add custom relation type [ \# 987 / efinder2] ( https://github.com/barryvdh/laravel-ide-helper/pull/987 )
11
+ - Added ` @see ` with macro/mixin definition location to PhpDoc [ \# 1054 / riesjart] ( https://github.com/barryvdh/laravel-ide-helper/pull/1054 )
11
12
12
13
### Changed
13
14
- Implement DeferrableProvider [ \# 914 / kon-shou] ( https://github.com/barryvdh/laravel-ide-helper/pull/914 )
Original file line number Diff line number Diff line change 4
4
5
5
use Barryvdh \Reflection \DocBlock ;
6
6
use Barryvdh \Reflection \DocBlock \Tag ;
7
+ use Illuminate \Support \Collection ;
7
8
8
9
class Macro extends Method
9
10
{
@@ -33,6 +34,8 @@ protected function initPhpDoc($method)
33
34
{
34
35
$ this ->phpdoc = new DocBlock ('/** */ ' );
35
36
37
+ $ this ->addLocationToPhpDoc ();
38
+
36
39
// Add macro parameters
37
40
foreach ($ method ->getParameters () as $ parameter ) {
38
41
$ type = $ parameter ->hasType () ? $ parameter ->getType ()->getName () : 'mixed ' ;
@@ -53,6 +56,24 @@ protected function initPhpDoc($method)
53
56
}
54
57
}
55
58
59
+ protected function addLocationToPhpDoc ()
60
+ {
61
+ $ enclosingClass = $ this ->method ->getClosureScopeClass ();
62
+
63
+ /** @var \ReflectionMethod $enclosingMethod */
64
+ $ enclosingMethod = Collection::make ($ enclosingClass ->getMethods ())
65
+ ->first (function (\ReflectionMethod $ method ) {
66
+ return $ method ->getStartLine () <= $ this ->method ->getStartLine ()
67
+ && $ method ->getEndLine () >= $ this ->method ->getEndLine ();
68
+ });
69
+
70
+ if ($ enclosingMethod ) {
71
+ $ this ->phpdoc ->appendTag (Tag::createInstance (
72
+ '@see \\' . $ enclosingClass ->getName () . ':: ' . $ enclosingMethod ->getName () . '() '
73
+ ));
74
+ }
75
+ }
76
+
56
77
/**
57
78
* @param \ReflectionFunctionAbstract $method
58
79
* @param \ReflectionClass $class
You can’t perform that action at this time.
0 commit comments