-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Handle all if,elseif,else no bracket on CompleteMissing…
…IfElseBracketRector (#5129)
- Loading branch information
1 parent
12184ca
commit 0c9fac5
Showing
4 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
.../CodeQuality/Rector/If_/CompleteMissingIfElseBracketRector/Fixture/all_no_bracket.php.inc
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,38 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector\Fixture; | ||
|
||
class AllNoBracket | ||
{ | ||
public function run($value) | ||
{ | ||
if ($value) | ||
return 1; | ||
elseif (rand(0, 1)) | ||
return 2; | ||
else | ||
return 3; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector\Fixture; | ||
|
||
class AllNoBracket | ||
{ | ||
public function run($value) | ||
{ | ||
if ($value) { | ||
return 1; | ||
} elseif (rand(0, 1)) { | ||
return 2; | ||
} else { | ||
return 3; | ||
} | ||
} | ||
} | ||
|
||
?> |
39 changes: 39 additions & 0 deletions
39
...If_/CompleteMissingIfElseBracketRector/Fixture/missing_bracket_on_elseif_and_else.php.inc
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,39 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector\Fixture; | ||
|
||
class MissingBracketOnElseIfAndElse | ||
{ | ||
public function run($value) | ||
{ | ||
if ($value) { | ||
return 1; | ||
} elseif (rand(0, 1)) | ||
return 2; | ||
else | ||
return 3; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector\Fixture; | ||
|
||
class MissingBracketOnElseIfAndElse | ||
{ | ||
public function run($value) | ||
{ | ||
if ($value) { | ||
return 1; | ||
} elseif (rand(0, 1)) { | ||
return 2; | ||
} | ||
else { | ||
return 3; | ||
} | ||
} | ||
} | ||
|
||
?> |
13 changes: 13 additions & 0 deletions
13
...ality/Rector/If_/CompleteMissingIfElseBracketRector/Fixture/skip_direct_semicolon.php.inc
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,13 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector\Fixture; | ||
|
||
class SkipDirectSemicolon | ||
{ | ||
public function run($value) | ||
{ | ||
if ($value); | ||
|
||
echo 'something'; | ||
} | ||
} |
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