Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CodeSniffer/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -3121,6 +3121,11 @@ public function isReference($stackPtr)
return true;
}

if ($this->_tokens[$tokenBefore]['code'] === T_OPEN_SHORT_ARRAY) {
// Inside an array declaration, this is a reference.
return true;
}

if (isset(PHP_CodeSniffer_Tokens::$assignmentTokens[$this->_tokens[$tokenBefore]['code']]) === true) {
// This is directly after an assignment. It's a reference. Even if
// it is part of an operation, the other tests will handle it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,6 @@ if (true || -1 == $b) {
$var = array(-1);
$var = [-1];
$var = [0, -1, -2];

$y = array(&$x);
$y = [&$x];
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,6 @@ if (true || -1 == $b) {
$var = array(-1);
$var = [-1];
$var = [0, -1, -2];

$y = array(&$x);
$y = [&$x];