-
-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TypeDeclaration] Handle fallback from param same type object on ReturnTypeFromReturnNewRector #5039
Merged
Merged
[TypeDeclaration] Handle fallback from param same type object on ReturnTypeFromReturnNewRector #5039
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
be8b2eb
[TypeDeclaration] Handle fallback from param on ReturnTypeFromReturnN…
samsonasik 7594001
implemented :tada:
samsonasik 2a154c6
[ci-review] Rector Rectify
actions-user e69bc6e
rename fixture
samsonasik f93af9d
rename fixture
samsonasik ed8860f
fix phpstan
samsonasik 11c285c
fix phpstan
samsonasik 402d4ab
realpath() always string after file_exists() on bin/rector.php
samsonasik 3bb67a3
Fix phpstan
samsonasik 8fae378
cheap check early
samsonasik a5c966e
Trigger CI
samsonasik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...tion/Rector/ClassMethod/ReturnTypeFromReturnNewRector/Fixture/fallback_from_param.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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture; | ||
|
||
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Source\SomeResponse; | ||
|
||
final class FallbackFromParam | ||
{ | ||
public function action(SomeResponse $someResponse) | ||
{ | ||
if (rand(0, 1)) { | ||
return new SomeResponse(); | ||
} | ||
|
||
return $someResponse; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture; | ||
|
||
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Source\SomeResponse; | ||
|
||
final class FallbackFromParam | ||
{ | ||
public function action(SomeResponse $someResponse): \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Source\SomeResponse | ||
{ | ||
if (rand(0, 1)) { | ||
return new SomeResponse(); | ||
} | ||
|
||
return $someResponse; | ||
} | ||
} | ||
|
||
?> |
39 changes: 39 additions & 0 deletions
39
...Rector/ClassMethod/ReturnTypeFromReturnNewRector/Fixture/fallback_from_param_self.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 | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture; | ||
|
||
final class FallbackFromParamSelf | ||
{ | ||
public function action(self $obj) | ||
{ | ||
if (rand(0, 1)) { | ||
return new FallbackFromParamSelf(); | ||
} | ||
|
||
return $obj; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture; | ||
|
||
final class FallbackFromParamSelf | ||
{ | ||
public function action(self $obj): \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture\FallbackFromParamSelf | ||
{ | ||
if (rand(0, 1)) { | ||
return new FallbackFromParamSelf(); | ||
} | ||
|
||
return $obj; | ||
} | ||
} | ||
|
||
?> |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need another test for a
static
and/orparent
typed param?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static already error on the first place :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multiple return already skipped at
rector-src/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnNewRector.php
Lines 185 to 186 in c956f86