-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Handle do { } while maybe returned on ExplicitReturnNul…
…lRector (#5766) * [CodeQuality] Handle do {} while maybe returned on ExplicitReturnNullRector * handle possibly returned * debug * debug
- Loading branch information
1 parent
aac889b
commit 879feb8
Showing
3 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...ality/Rector/ClassMethod/ExplicitReturnNullRector/Fixture/do_while_maybe_returned.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,40 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector\Fixture; | ||
|
||
final class DoWhileMaybeReturned | ||
{ | ||
public function run(int $i) | ||
{ | ||
do { | ||
if (rand(0, 1)) { | ||
continue; | ||
} | ||
|
||
return 2; | ||
} while (++$i < 1); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector\Fixture; | ||
|
||
final class DoWhileMaybeReturned | ||
{ | ||
public function run(int $i) | ||
{ | ||
do { | ||
if (rand(0, 1)) { | ||
continue; | ||
} | ||
|
||
return 2; | ||
} while (++$i < 1); | ||
return null; | ||
} | ||
} | ||
|
||
?> |
40 changes: 40 additions & 0 deletions
40
...lity/Rector/ClassMethod/ExplicitReturnNullRector/Fixture/do_while_maybe_returned2.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,40 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector\Fixture; | ||
|
||
final class DoWhileMaybeReturned2 | ||
{ | ||
public function run(int $i) | ||
{ | ||
do { | ||
if (rand(0,1)) { | ||
break; | ||
} | ||
|
||
return 2; | ||
} while (++$i < 1); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector\Fixture; | ||
|
||
final class DoWhileMaybeReturned2 | ||
{ | ||
public function run(int $i) | ||
{ | ||
do { | ||
if (rand(0,1)) { | ||
break; | ||
} | ||
|
||
return 2; | ||
} while (++$i < 1); | ||
return null; | ||
} | ||
} | ||
|
||
?> |
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