Skip to content

Commit

Permalink
Fixed bug #897 : Generic.Functions.CallTimePassByReference.NotAllowed…
Browse files Browse the repository at this point in the history
… false positive when short array syntax
  • Loading branch information
gsherwood committed Feb 19, 2016
1 parent 3fb060d commit d91641d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,21 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$closeBracket = $tokens[$openBracket]['parenthesis_closer'];

$nextSeparator = $openBracket;
while (($nextSeparator = $phpcsFile->findNext(T_VARIABLE, ($nextSeparator + 1), $closeBracket)) !== false) {
$find = array(
T_VARIABLE,
T_OPEN_SHORT_ARRAY,
);

while (($nextSeparator = $phpcsFile->findNext($find, ($nextSeparator + 1), $closeBracket)) !== false) {
if (isset($tokens[$nextSeparator]['nested_parenthesis']) === false) {
continue;
}

if ($tokens[$nextSeparator]['code'] === T_OPEN_SHORT_ARRAY) {
$nextSeparator = $tokens[$nextSeparator]['bracket_closer'];
continue;
}

// Make sure the variable belongs directly to this function call
// and is not inside a nested function call or array.
$brackets = $tokens[$nextSeparator]['nested_parenthesis'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ $foo(&$myvar);

if (is_array($foo = &$this->bar())) {
}

Hooks::run( 'SecondaryDataUpdates', [ $title, $old, $recursive, $parserOutput, &$updates ] );
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Fixed bug #887 : Using curly braces for a shared CASE/DEFAULT statement can generate an error in PSR2 SwitchDeclaration
- Fixed bug #889 : Closure inside catch/else/elseif causes indentation error
- Fixed bug #890 : Function call inside returned short array value can cause indentation error inside CASE statements
- Fixed bug #897 : Generic.Functions.CallTimePassByReference.NotAllowed false positive when short array syntax
</notes>
<contents>
<dir name="/">
Expand Down

0 comments on commit d91641d

Please sign in to comment.