@@ -64,6 +64,7 @@ public function forReflectionMethod(\ReflectionMethod $method): array
64
64
$ parser = new DocBlock ($ method );
65
65
$ texts = $ parser ->texts ();
66
66
$ title = \array_shift ($ texts );
67
+ $ throws = $ parser ->first ('throws ' );
67
68
68
69
$ metadata = [
69
70
'name ' => $ method ->name ,
@@ -73,33 +74,34 @@ public function forReflectionMethod(\ReflectionMethod $method): array
73
74
'isPublic ' => $ method ->isPublic (),
74
75
'isAbstract ' => $ method ->isAbstract (),
75
76
'maybeMagic ' => \substr ($ method ->name , 0 , 2 ) === '__ ' ,
77
+ 'throws ' => $ throws ? \explode (' ' , \trim ($ throws ->getValue ()), 2 ) : [],
76
78
'title ' => $ title ,
77
79
'texts ' => $ texts ,
78
80
];
79
81
80
82
$ params = [];
81
83
foreach ($ parser ->find ('param ' ) as $ param ) {
82
- if (\preg_match ('/(.*)\$(\w+)/ ' , $ param ->getValue (), $ match )) {
83
- $ params [$ match [2 ]] = \trim ($ match [1 ]);
84
+ if (\preg_match ('/(.*)\$(\w+)(.*) / ' , $ param ->getValue (), $ match )) {
85
+ $ params [$ match [2 ]] = [ \trim ($ match [1 ]), \trim ( $ match [ 3 ])] ;
84
86
}
85
87
}
86
88
87
89
if (null !== $ return = $ parser ->first ('return ' )) {
88
- $ return = \preg_replace ( ' /(\S+)(.*)/ ' , ' $1 ' , $ return ->getValue ());
90
+ $ return = \explode ( ' ' , \trim ( $ return ->getValue ()), 2 );
89
91
}
90
92
91
- return $ metadata + $ this ->getMethodParameters ($ method , $ params , $ return ?? '' );
93
+ return $ metadata + $ this ->getMethodParameters ($ method , $ params , $ return ?? [] );
92
94
}
93
95
94
- protected function getMethodParameters (\ReflectionMethod $ method , array $ docParams , string $ return )
96
+ protected function getMethodParameters (\ReflectionMethod $ method , array $ docParams , array $ return )
95
97
{
96
98
$ params = [];
97
99
$ parser = new DocBlock ($ method );
98
100
99
101
foreach ($ method ->getParameters () as $ param ) {
100
102
$ name = $ param ->name ;
101
103
if (!$ param ->hasType ()) {
102
- $ params [] = \trim (($ docParams [$ name ] ?? '' ) . " \$$ name " );
104
+ $ params [] = [ \trim (($ docParams [$ name ][ 0 ] ?? '' ) . " \$$ name " ), $ docParams [ $ name ][ 1 ] ?? '' ] ;
103
105
104
106
continue ;
105
107
}
@@ -108,7 +110,7 @@ protected function getMethodParameters(\ReflectionMethod $method, array $docPara
108
110
}
109
111
110
112
if ($ returnType = $ method ->getReturnType ()) {
111
- $ return = $ this ->getRealType ($ returnType );
113
+ $ return[ 0 ] = $ this ->getRealType ($ returnType );
112
114
}
113
115
114
116
return \compact ('params ' , 'return ' );
0 commit comments