Skip to content
Closed
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 @@ -156,10 +156,13 @@ public function checkSpacing(File $phpcsFile, $stackPtr, $openBracket)
}//end if

if ($tokens[($nextSeparator + 1)]['code'] !== T_WHITESPACE) {
$error = 'No space found after comma in argument list';
$fix = $phpcsFile->addFixableError($error, $nextSeparator, 'NoSpaceAfterComma');
if ($fix === true) {
$phpcsFile->fixer->addContent($nextSeparator, ' ');
// Ignore trailing comma's after last argument as that's outside the scope of this sniff.
if (($nextSeparator + 1) !== $closeBracket) {
$error = 'No space found after comma in argument list';
$fix = $phpcsFile->addFixableError($error, $nextSeparator, 'NoSpaceAfterComma');
if ($fix === true) {
$phpcsFile->fixer->addContent($nextSeparator, ' ');
}
}
} else {
// If there is a newline in the space, then they must be formatting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,13 @@ class Testing extends Bar
$a = new parent($foo ,$bar);
}
}

// Ignore spacing after PHP 7.3+ trailing comma in single-line function calls to prevent fixer conflicts.
// This is something which should be decided by a sniff dealing with the function call parentheses.
$foo = new MyClass($obj, 'getMethod',);
$foo = new MyClass($obj, 'getMethod', );
$foo = new MyClass($obj, 'getMethod', );
$foo = new MyClass(
$obj,
'getMethod',
);
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,13 @@ class Testing extends Bar
$a = new parent($foo, $bar);
}
}

// Ignore spacing after PHP 7.3+ trailing comma in single-line function calls to prevent fixer conflicts.
// This is something which should be decided by a sniff dealing with the function call parentheses.
$foo = new MyClass($obj, 'getMethod',);
$foo = new MyClass($obj, 'getMethod', );
$foo = new MyClass($obj, 'getMethod', );
$foo = new MyClass(
$obj,
'getMethod',
);
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function getErrorList()
154 => 2,
155 => 1,
162 => 2,
170 => 1,
];

}//end getErrorList()
Expand Down