Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotation - improve on recognising types with reference and splat operator #6242

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -495,6 +495,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 @@ -577,6 +584,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