Skip to content

Commit c6fad15

Browse files
authored
Merge pull request #18 from KentarouTakeda/fix-generics-and-closures-return-type
Fixed incorrect parsing of return types for generics and closures
2 parents bba116b + 836d531 commit c6fad15

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/Barryvdh/Reflection/DocBlock/Tag/MethodTag.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ public function setContent($content)
8080
(?:[\w\|_\\\\]*\$this[\w\|_\\\\]*)
8181
|
8282
(?:
83-
(?:[\w\|_\\\\]+)
83+
(?:[\w\|_\\\\]+(?:<[\s\S]*>)?)
8484
# array notation
8585
(?:\[\])*
8686
)*
87+
|
88+
(?:\([\s\S]*\))?
8789
)
8890
\s+
8991
)?

tests/Barryvdh/Reflection/DocBlock/Tag/MethodTagTest.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,25 @@ public function getTestSignatures()
142142
array(
143143
'static static foo()',
144144
true, 'foo', 'static', true, 0, ''
145-
)
145+
),
146+
147+
// generic array
148+
array(
149+
'array<int, string> foo()',
150+
true, 'foo', 'array<int, string>', false, 0, ''
151+
),
152+
153+
// nested generics
154+
array(
155+
'array<int, array<string, mixed>> foo()',
156+
true, 'foo', 'array<int, array<string, mixed>>', false, 0, ''
157+
),
158+
159+
// closure
160+
array(
161+
'(\Closure(int, string): bool) foo()',
162+
true, 'foo', '(\Closure(int, string): bool)', false, 0, ''
163+
),
146164
);
147165
}
148166
}

0 commit comments

Comments
 (0)