-
-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EarlyExitSniff: New option "ignoreOneLineTrailingIf"
- Loading branch information
Showing
6 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/Sniffs/ControlStructures/data/earlyExitIgnoredOneLineTrailingIfErrors.fixed.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
function ($values) { | ||
foreach ($values as $value) { | ||
if ($value === null) { | ||
return; | ||
} | ||
|
||
if ($value) { | ||
doSomething(); | ||
} | ||
} | ||
}; | ||
|
||
function ($values) { | ||
foreach ($values as $value) { | ||
if ($value === null) { | ||
return; | ||
} | ||
|
||
if (!$value) { | ||
continue; | ||
} | ||
|
||
doSomething(); | ||
doMore(); | ||
} | ||
}; |
22 changes: 22 additions & 0 deletions
22
tests/Sniffs/ControlStructures/data/earlyExitIgnoredOneLineTrailingIfErrors.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
function ($values) { | ||
foreach ($values as $value) { | ||
if ($value === null) { | ||
return; | ||
} elseif ($value) { | ||
doSomething(); | ||
} | ||
} | ||
}; | ||
|
||
function ($values) { | ||
foreach ($values as $value) { | ||
if ($value === null) { | ||
return; | ||
} elseif ($value) { | ||
doSomething(); | ||
doMore(); | ||
} | ||
} | ||
}; |
19 changes: 19 additions & 0 deletions
19
tests/Sniffs/ControlStructures/data/earlyExitIgnoredOneLineTrailingIfNoErrors.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
function ($values) { | ||
foreach ($values as $value) { | ||
if ($value) { | ||
doSomething(); | ||
} | ||
} | ||
}; | ||
|
||
function ($values) { | ||
foreach ($values as $value) { | ||
$value .= 'whatever'; | ||
|
||
if ($value) { | ||
doSomething(); | ||
} | ||
} | ||
}; |
055af01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for implementing this! I'm looking forward to using this in the next release :)