-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
ReturnUnionTypeRector now skips nullable types, to prepare space for new nullable rule as off PHP 7.1+ #6105
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
39 changes: 0 additions & 39 deletions
39
...s/TypeDeclaration/Rector/ClassMethod/ReturnUnionTypeRector/Fixture/nullable_union.php.inc
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
...Rector/ClassMethod/ReturnUnionTypeRector/FixturePhp81/false_null_to_nullable_bool.php.inc
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
...ssMethod/ReturnUnionTypeRector/FixturePhp81/skip_nullable_handled_by_another_rule.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,15 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnUnionTypeRector\FixturePhp81; | ||
|
||
final class SkipNullableHandledByAnotherRule | ||
{ | ||
public function run($value) | ||
{ | ||
if ($value) { | ||
return null; | ||
} | ||
|
||
return false; | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
...or/ClassMethod/ReturnUnionTypeRector/FixtureTrueInUnion/nullable_false_is_allowed.php.inc
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
...od/ReturnUnionTypeRector/FixtureTrueInUnion/skip_nullable_handled_by_another_rule.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,16 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnUnionTypeRector\FixtureTrueInUnion; | ||
|
||
final class SkipNullableHandledByAnotherRule | ||
{ | ||
public function run($value) | ||
{ | ||
|
||
if (rand(0, 1)) { | ||
return false; | ||
} | ||
|
||
return null; | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
...Declaration/Rector/Closure/AddClosureUnionReturnTypeRector/Fixture/nullable_array.php.inc
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
...ration/Rector/Closure/AddClosureUnionReturnTypeRector/Fixture/skip_nullable_array.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\TypeDeclaration\Rector\Closure\AddClosureUnionReturnTypeRector\Fixture; | ||
|
||
final class SkipNullableArray | ||
{ | ||
public function run() | ||
{ | ||
function () { | ||
if (rand(0, 1)) { | ||
return []; | ||
} | ||
|
||
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
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.
new rule to update sub type by docblock seems needed, to ensure not introduce phpstan notice
https://phpstan.org/r/49cbf30f-03e8-4b82-b47e-b649cadc7a34
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.
Docblock changes are out of our scope since Rector 0.15. This will have to be dealt manualy.
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.
That will ok for 1 or 2 files, but for many files, imo, that's worth it, I think
coding-style
orcode-quality
set will match thatThere 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.
That's beyond our scope. I'd leave that for manual review or custom set 👍
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.
Also, this seems rather rare case.