Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Add Else and ElseIf on CompleteMissingIfElseBracketRect…
…or (#5124) * [CodeQuality] Add Else and ElseIf on CompleteMissingIfElseBracketRector * fix * fix end statement * clean up * clean up
- Loading branch information
1 parent
1966194
commit 96a1476
Showing
4 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...ity/Rector/If_/CompleteMissingIfElseBracketRector/Fixture/missing_bracket_on_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,34 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector\Fixture; | ||
|
||
class MissingBracketOnElse | ||
{ | ||
public function run($value, $value2) | ||
{ | ||
if ($value) { | ||
return 1; | ||
} else | ||
return 2; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector\Fixture; | ||
|
||
class MissingBracketOnElse | ||
{ | ||
public function run($value, $value2) | ||
{ | ||
if ($value) { | ||
return 1; | ||
} else { | ||
return 2; | ||
} | ||
} | ||
} | ||
|
||
?> |
34 changes: 34 additions & 0 deletions
34
...y/Rector/If_/CompleteMissingIfElseBracketRector/Fixture/missing_bracket_on_elseif.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,34 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector\Fixture; | ||
|
||
class MissingBracketOnElseIf | ||
{ | ||
public function run($value, $value2) | ||
{ | ||
if ($value) { | ||
return 1; | ||
} elseif ($value2) | ||
return 2; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector\Fixture; | ||
|
||
class MissingBracketOnElseIf | ||
{ | ||
public function run($value, $value2) | ||
{ | ||
if ($value) { | ||
return 1; | ||
} elseif ($value2) { | ||
return 2; | ||
} | ||
} | ||
} | ||
|
||
?> |
17 changes: 17 additions & 0 deletions
17
...lity/Rector/If_/CompleteMissingIfElseBracketRector/Fixture/skip_spaced_else_stmts.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,17 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector\Fixture; | ||
|
||
class SkipSpacedElseStmts | ||
{ | ||
public function run($value, $value2) | ||
{ | ||
if ($value) { | ||
return 1; | ||
} else { | ||
$a = 1; | ||
|
||
return $a; | ||
} | ||
} | ||
} |
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