Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ReturnTypeFromStrictBoolReturnExprRector support for if/else retu…
…rns (#5384) * Add fixture * Add ReturnTypeFromStrictBoolReturnExprRector support for if/else returns
- Loading branch information
1 parent
16f8d19
commit 620321b
Showing
16 changed files
with
194 additions
and
70 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
35 changes: 35 additions & 0 deletions
35
...Rector/ClassMethod/ReturnTypeFromStrictBoolReturnExprRector/Fixture/If_else_bools.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,35 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictBoolReturnExprRector\Fixture; | ||
|
||
final class IfElseBools | ||
{ | ||
public function run($value) | ||
{ | ||
if ($value) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictBoolReturnExprRector\Fixture; | ||
|
||
final class IfElseBools | ||
{ | ||
public function run($value): bool | ||
{ | ||
if ($value) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
?> |
39 changes: 39 additions & 0 deletions
39
...sMethod/ReturnTypeFromStrictBoolReturnExprRector/Fixture/precontent_If_else_bools.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\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictBoolReturnExprRector\Fixture; | ||
|
||
final class PreContentIfElseBools | ||
{ | ||
public function run($value) | ||
{ | ||
$value += 100; | ||
|
||
if ($value) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictBoolReturnExprRector\Fixture; | ||
|
||
final class PreContentIfElseBools | ||
{ | ||
public function run($value): bool | ||
{ | ||
$value += 100; | ||
|
||
if ($value) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
?> |
35 changes: 35 additions & 0 deletions
35
...ctor/ClassMethod/ReturnTypeFromStrictScalarReturnExprRector/Fixture/if_else_bools.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,35 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector\Fixture; | ||
|
||
final class IfElseBools | ||
{ | ||
public function run($value) | ||
{ | ||
if ($value) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector\Fixture; | ||
|
||
final class IfElseBools | ||
{ | ||
public function run($value): bool | ||
{ | ||
if ($value) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
?> |
18 changes: 0 additions & 18 deletions
18
...assMethod/ReturnTypeFromStrictTypedCallRector/Fixture/return_self_different_namespace.php
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...ration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/twice_same_type.php
This file was deleted.
Oops, something went wrong.
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
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
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
Oops, something went wrong.