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 @@ -45,6 +45,11 @@ public function process(File $phpcsFile, $stackPtr)
// Ignore default value assignments in function definitions.
$function = $phpcsFile->findPrevious([T_FUNCTION, T_CLOSURE, T_FN], ($stackPtr - 1), null, false, null, true);
if ($function !== false) {
if (isset($tokens[$function]['parenthesis_closer']) === false) {
// Live coding/parse error. Bow out.
return;
}

$opener = $tokens[$function]['parenthesis_opener'];
$closer = $tokens[$function]['parenthesis_closer'];
if ($opener < $stackPtr && $closer > $stackPtr) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// Intentional parse error (missing closing parenthesis).
// This should be the only test in this file.
// Testing that the sniff is *not* triggered.

function missingClosingParenthesis($a =
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,29 @@ final class DisallowMultipleAssignmentsUnitTest extends AbstractSniffUnitTest
* The key of the array should represent the line number and the value
* should represent the number of errors that should occur on that line.
*
* @param string $testFile The name of the test file to process.
*
* @return array<int, int>
*/
public function getErrorList()
public function getErrorList($testFile='')
{
return [
4 => 1,
5 => 2,
7 => 1,
9 => 1,
12 => 1,
14 => 1,
15 => 1,
79 => 1,
85 => 1,
];
switch ($testFile) {
case 'DisallowMultipleAssignmentsUnitTest.1.inc':
return [
4 => 1,
5 => 2,
7 => 1,
9 => 1,
12 => 1,
14 => 1,
15 => 1,
79 => 1,
85 => 1,
];

default:
return [];
}

}//end getErrorList()

Expand Down