Merge pull request #18 from KentarouTakeda/fix-generics-and-closures-return-type

Fixed incorrect parsing of return types for generics and closures
This commit is contained in:
Barry vd. Heuvel
2024-10-23 13:41:03 +02:00
committed by GitHub
2 changed files with 22 additions and 2 deletions
@@ -80,10 +80,12 @@ class MethodTag extends ReturnTag
(?:[\w\|_\\\\]*\$this[\w\|_\\\\]*) (?:[\w\|_\\\\]*\$this[\w\|_\\\\]*)
| |
(?: (?:
(?:[\w\|_\\\\]+) (?:[\w\|_\\\\]+(?:<[\s\S]*>)?)
# array notation # array notation
(?:\[\])* (?:\[\])*
)* )*
|
(?:\([\s\S]*\))?
) )
\s+ \s+
)? )?
@@ -142,7 +142,25 @@ class MethodTagTest extends TestCase
array( array(
'static static foo()', 'static static foo()',
true, 'foo', 'static', true, 0, '' true, 'foo', 'static', true, 0, ''
) ),
// generic array
array(
'array<int, string> foo()',
true, 'foo', 'array<int, string>', false, 0, ''
),
// nested generics
array(
'array<int, array<string, mixed>> foo()',
true, 'foo', 'array<int, array<string, mixed>>', false, 0, ''
),
// closure
array(
'(\Closure(int, string): bool) foo()',
true, 'foo', '(\Closure(int, string): bool)', false, 0, ''
),
); );
} }
} }