Skip to content

Commit

Permalink
Replace default value of first parameter in getWarningList() with ''
Browse files Browse the repository at this point in the history
Replacing the default value with an empty string. Per Juliette's comment
(PHPCSStandards#163 (comment))
there are three reasons why we want to do that:

- The default value has no value in practice. It is an optional argument which is not enforced via the abstract functions, but is passed in all cases, so the default is never used in practice.
- Setting the default value as file 1 also has an assumption implied, while IMO assumptions have no place in a test suite.
- Maintainability - one less thing to have to keep in sync and to guard against typos
  • Loading branch information
rodrigoprimo authored and dingo-d committed Dec 23, 2023
1 parent d7049db commit efda300
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getErrorList()
*
* @return array<int, int>
*/
public function getWarningList($testFile='MultipleStatementAlignmentUnitTest.inc')
public function getWarningList($testFile='')
{
switch ($testFile) {
case 'MultipleStatementAlignmentUnitTest.inc':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getErrorList($testFile='FileCommentUnitTest.inc')
*
* @return array<int, int>
*/
public function getWarningList($testFile='FileCommentUnitTest.inc')
public function getWarningList($testFile='')
{
switch ($testFile) {
case 'FileCommentUnitTest.1.inc':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function getErrorList($testFile='ForLoopDeclarationUnitTest.inc')
*
* @return array<int, int>
*/
public function getWarningList($testFile='ForLoopDeclarationUnitTest.inc')
public function getWarningList($testFile='')
{
switch ($testFile) {
case 'ForLoopDeclarationUnitTest.inc':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function getErrorList($testFile='SwitchDeclarationUnitTest.inc')
*
* @return array<int, int>
*/
public function getWarningList($testFile='SwitchDeclarationUnitTest.inc')
public function getWarningList($testFile='')
{
if ($testFile === 'SwitchDeclarationUnitTest.js') {
return [273 => 1];
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getErrorList()
*
* @return array<int, int>
*/
public function getWarningList($testFile='CommentedOutCodeUnitTest.inc')
public function getWarningList($testFile='')
{
switch ($testFile) {
case 'CommentedOutCodeUnitTest.inc':
Expand Down

0 comments on commit efda300

Please sign in to comment.