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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ public function process(File $phpcsFile, $stackPtr)
}

if ($tokens[$varToken]['code'] === T_VARIABLE) {
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($varToken - 1), null, true);
if ($tokens[$prevNonEmpty]['code'] === T_OBJECT_OPERATOR) {
// Dynamic property access, the real "start" variable still needs to be found.
$varToken = $prevNonEmpty;
continue;
}

// We found our variable.
break;
}
Expand All @@ -119,15 +126,14 @@ public function process(File $phpcsFile, $stackPtr)

$allowed = Tokens::$emptyTokens;

$allowed[T_STRING] = T_STRING;
$allowed[T_NS_SEPARATOR] = T_NS_SEPARATOR;
$allowed[T_DOUBLE_COLON] = T_DOUBLE_COLON;
$allowed[T_OBJECT_OPERATOR] = T_OBJECT_OPERATOR;
$allowed[T_ASPERAND] = T_ASPERAND;
$allowed[T_DOLLAR] = T_DOLLAR;
$allowed[T_SELF] = T_SELF;
$allowed[T_PARENT] = T_PARENT;
$allowed[T_STATIC] = T_STATIC;
$allowed[T_STRING] = T_STRING;
$allowed[T_NS_SEPARATOR] = T_NS_SEPARATOR;
$allowed[T_DOUBLE_COLON] = T_DOUBLE_COLON;
$allowed[T_ASPERAND] = T_ASPERAND;
$allowed[T_DOLLAR] = T_DOLLAR;
$allowed[T_SELF] = T_SELF;
$allowed[T_PARENT] = T_PARENT;
$allowed[T_STATIC] = T_STATIC;

$varToken = $phpcsFile->findPrevious($allowed, ($varToken - 1), null, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,17 @@ list ($c, $d) = explode(',', '1,2');
<?= $a * $b ?>
<?= [$c, $d] = explode(',', '1,2');
?>
<?php

// Issue #598.
$filtered_results->field = $result;
$filtered_results->$field = $result;
$filtered_results->$row->field = $result;
$filtered_results->$row->$field = $result;

$filtered_results[ $i ]->field = $result;
$filtered_results[ $i ]->$field = $result;
$filtered_results[ $i ]->$row->field = $result;
$filtered_results[ $i ]->$row->$field = $result;
$filtered_results[ $i ]->$row[0]->field = $result;
$filtered_results[ $i ]->$row[$j]->$field = $result;