Skip to content

Commit

Permalink
Fixed ReferencedNameHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Aug 25, 2017
1 parent 2b1568e commit ae42c30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion SlevomatCodingStandard/Helpers/ReferencedNameHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ private static function createAllReferencedNames(\PHP_CodeSniffer\Files\File $ph
if ($tokens[$previousTokenBeforeStartPointer]['code'] !== T_NEW) {
$type = ReferencedName::TYPE_FUNCTION;
}
} elseif ($tokens[$nextTokenAfterEndPointer]['code'] !== T_VARIABLE) {
} elseif (!in_array($tokens[$nextTokenAfterEndPointer]['code'], [
T_VARIABLE,
T_ELLIPSIS, // variadic parameter
T_BITWISE_AND, // parameter by reference
], true)
) {
if (
!in_array($tokens[$previousTokenBeforeStartPointer]['code'], [
T_EXTENDS,
Expand Down
2 changes: 2 additions & 0 deletions tests/Helpers/ReferencedNameHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function testGetAllReferencedNames()
['BAR_CONSTANT', false, true],
['Integer', false, false],
['Boolean', false, false],
['Bobobo', false, false],
['Dododo', false, false],
['\ExtendedInterface', false, false],
['\SecondExtendedInterface', false, false],
['\ThirdExtendedInterface', false, false],
Expand Down
8 changes: 8 additions & 0 deletions tests/Helpers/data/lotsOfReferencedNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public function fooMethod(TypeHintedName $foo, array $bar)

new Integer();
new Boolean();

function (Bobobo ...$bobobo) : array {
return $bobobo;
};

function (Dododo &$dododo) : array {
return $dododo;
};
}

}
Expand Down

0 comments on commit ae42c30

Please sign in to comment.