-
-
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.
[TypeDeclaration] Skip Type modified between Assign and Return_ on Re…
…turnTypeFromReturnNewRector (#2650)
- Loading branch information
1 parent
f5896ac
commit 7e1c2bb
Showing
5 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...peFromReturnNewRector/Fixture/skip_type_modified_between_assign_and_return_by_ref.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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture; | ||
|
||
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Source\SomeResponse; | ||
|
||
final class SkipTypeModifiedBetweenAssignAndReturnByRef | ||
{ | ||
public function action() | ||
{ | ||
$response = new SomeResponse(); | ||
|
||
$this->verify($response); | ||
|
||
return $response; | ||
} | ||
|
||
private function verify(SomeResponse &$someResponse): void | ||
{ | ||
if (is_cli()) { | ||
$someResponse = new CLIResponse(); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...eFromReturnNewRector/Fixture/skip_type_modified_between_assign_and_return_with_if.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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture; | ||
|
||
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Source\SomeResponse; | ||
|
||
final class SkipTypeModifiedBetweenAssignAndReturnWithIf | ||
{ | ||
public function action() | ||
{ | ||
$response = new SomeResponse(); | ||
|
||
if (is_cli()) { | ||
$response = new CLIResponse(); | ||
} | ||
|
||
return $response; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ReturnTypeFromReturnNewRector/Fixture/type_not_changed_after_assigned_to_variable.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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture; | ||
|
||
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Source\SomeResponse; | ||
|
||
final class TypeNotChangedAfterAssignedToVariable | ||
{ | ||
public function action() | ||
{ | ||
$response = new SomeResponse(); | ||
$response->setBody('some message'); | ||
|
||
return $response; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture; | ||
|
||
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Source\SomeResponse; | ||
|
||
final class TypeNotChangedAfterAssignedToVariable | ||
{ | ||
public function action(): \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Source\SomeResponse | ||
{ | ||
$response = new SomeResponse(); | ||
$response->setBody('some message'); | ||
|
||
return $response; | ||
} | ||
} | ||
|
||
?> |
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