Skip to content

Commit

Permalink
minor #6242 Annotation - improve on recognising types with reference …
Browse files Browse the repository at this point in the history
…and splat operator (kubawerlos)

This PR was squashed before being merged into the master branch (closes #6242).

Discussion
----------

Annotation - improve on recognising types with reference and splat operator

Commits
-------

f6093dd Annotation - improve on recognising types with reference and splat operator
  • Loading branch information
SpacePossum committed Feb 4, 2022
2 parents 6ba7795 + f6093dd commit b61622c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DocBlock/Annotation.php
Expand Up @@ -285,7 +285,7 @@ private function getTypesContent(): string
}

$matchingResult = Preg::match(
'{^(?:\s*\*|/\*\*)\s*@'.$name.'\s+'.TypeExpression::REGEX_TYPES.'(?:[*\h\v].*)?\r?$}sx',
'{^(?:\s*\*|/\*\*)\s*@'.$name.'\s+'.TypeExpression::REGEX_TYPES.'(?:(?:[*\h\v]|\&[\.\$]).*)?\r?$}sx',
$this->lines[0]->getContent(),
$matches
);
Expand Down
8 changes: 8 additions & 0 deletions tests/DocBlock/AnnotationTest.php
Expand Up @@ -496,6 +496,13 @@ public function provideNormalizedTypesCases(): array
[['null', 'string'], '* @param StRiNg|NuLl $foo'],
[['void'], '* @return Void'],
[['bar', 'baz', 'foo', 'null', 'qux'], '* @return Foo|Bar|Baz|Qux|null'],
[['bool', 'int'], '* @param bool|int $foo'],
[['bool', 'int'], '* @param bool|int ...$foo'],
[['bool', 'int'], '* @param bool|int &$foo'],
[['bool', 'int'], '* @param bool|int &...$foo'],
[['bool', 'int'], '* @param bool|int&$foo'],
[['bool', 'int'], '* @param bool|int&...$foo'],
[['bar', 'baz', 'foo'], '* @param Foo|Bar&Baz&$param'],
];
}

Expand Down Expand Up @@ -578,6 +585,7 @@ public function provideGetVariableCases(): \Generator
yield ['* @param int & $foo', '$foo'];
yield ['* @param int ...$foo', '$foo'];
yield ['* @param int ... $foo', '$foo'];
yield ['* @param int&...$foo', '$foo'];
yield ['* @param int &...$foo', '$foo'];
yield ['* @param int & ...$foo', '$foo'];
yield ['* @param int & ... $foo', '$foo'];
Expand Down

0 comments on commit b61622c

Please sign in to comment.