Skip to content

Commit

Permalink
Merge pull request #9458 from pvandommelen/type_round_brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Mar 6, 2023
2 parents dc4516b + c72edef commit 3a0adab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Expand Up @@ -1906,8 +1906,8 @@ private static function getTypeAliasesFromCommentLines(

$type_string = str_replace("\n", '', implode('', $var_line_parts));

$type_string = preg_replace('/>[^>^\}]*$/', '>', $type_string, 1);
$type_string = preg_replace('/\}[^>^\}]*$/', '}', $type_string, 1);
// Strip any remaining characters after the last grouping character >, } or )
$type_string = preg_replace('/(?<=[>})])[^>})]*$/', '', $type_string, 1);

try {
$type_tokens = TypeTokenizer::getFullyQualifiedTokens(
Expand Down
8 changes: 8 additions & 0 deletions tests/TypeAnnotationTest.php
Expand Up @@ -653,6 +653,14 @@ public function doStuff(): array {
'$output===' => 'list<1|2>',
],
],
'handlesTypeWhichEndsWithRoundBracket' => [
'code' => '<?php
/**
* @psalm-type Foo=(iterable<mixed>)
*/
class A {}
',
],
];
}

Expand Down

0 comments on commit 3a0adab

Please sign in to comment.