Skip to content

Commit

Permalink
Merge c7d50f7 into 333f15e
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Jan 14, 2022
2 parents 333f15e + c7d50f7 commit d5ab46d
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php
Expand Up @@ -416,7 +416,7 @@ private function parseTypeHint(Tokens $tokens, int $index): array
private function annotationIsSuperfluous(Annotation $annotation, array $info, array $symbolShortNames): bool
{
if ('param' === $annotation->getTag()->getName()) {
$regex = '/@param\s+(?:\S|\s(?!\$))++\s\$\S+\s+\S/';
$regex = '/@param\s+[^\$]+\s(?:\&\s*)?(?:\.{3}\s*)?\$\S+\s+\S/';
} elseif ('var' === $annotation->getTag()->getName()) {
$regex = '/@var\s+\S+(\s+\$\S+)?(\s+)(?!\*+\/)([^$\s]+)/';
} else {
Expand Down
98 changes: 98 additions & 0 deletions tests/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixerTest.php
Expand Up @@ -1496,6 +1496,104 @@ final class Bar{}
*/
class Foo {
}', ],
'remove when used with reference' => [
'<?php class Foo {
/**
*/
function f1(string &$x) {}
/**
*/
function f2(string &$x) {}
/**
*/
function f3(string &$x) {}
}',
'<?php class Foo {
/**
* @param string $x
*/
function f1(string &$x) {}
/**
* @param string &$x
*/
function f2(string &$x) {}
/**
* @param string $y Description
*/
function f3(string &$x) {}
}',
],
'dont remove when used with reference' => [
'<?php class Foo {
/**
* @param string ...$x Description
*/
function f(string ...$x) {}
}',
],
'remove when used with splat operator' => [
'<?php class Foo {
/**
*/
function f1(string ...$x) {}
/**
*/
function f2(string ...$x) {}
}',
'<?php class Foo {
/**
* @param string ...$x
*/
function f1(string ...$x) {}
/**
* @param string ...$y Description
*/
function f2(string ...$x) {}
}',
],
'dont remove when used with splat operator' => [
'<?php class Foo {
/**
* @param string ...$x Description
*/
function f(string ...$x) {}
}',
],
'remove when used with reference and splat operator' => [
'<?php class Foo {
/**
*/
function f1(string &...$x) {}
/**
*/
function f2(string &...$x) {}
/**
*/
function f3(string &...$x) {}
}',
'<?php class Foo {
/**
* @param string ...$x
*/
function f1(string &...$x) {}
/**
* @param string &...$x
*/
function f2(string &...$x) {}
/**
* @param string ...$y Description
*/
function f3(string &...$x) {}
}',
],
'dont remove when used with reference and splat operator' => [
'<?php class Foo {
/**
* @param string &...$x Description
*/
function f(string &...$x) {}
}',
],
];
}

Expand Down

0 comments on commit d5ab46d

Please sign in to comment.