-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
[CodeQuality] Handle crash on yield from on OptionalParametersAfterRequiredRector #6545
Conversation
Fixed 🎉 |
Thank, looks good to me 👍 |
@@ -60,7 +62,7 @@ public function resolve(string $rule): string | |||
throw new RectorRuleNameAmbigiousException($message); | |||
} | |||
|
|||
if (strpos($rule, '\\') === false) { | |||
if (in_array(str_contains($rule, '\\'), [0, false], true)) { |
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.
rectify seems should be only str_contains($rule, '\\') === false
, as str_contains never return 0, only bool
. I will check.
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.
It seems due 2 rules, with union type, that buggy due to usage of:
if ($exprType->isBoolean()->yes()) {
0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0%
PHPStan\Type\UnionType #22767
types: array (2)
| 0 => PHPStan\Type\IntegerRangeType #20331
| | min: 0
| | max: null
| 1 => PHPStan\Type\Constant\ConstantBooleanType #22757
| | value: false
normalized: true
sortedTypes: true
cachedDescriptions: array (1)
| 4 => 'int<0, max>|false'
➜ rector-src git:(main) ✗ bin/rector process src/Configuration/OnlyRuleResolver.php --dry-run
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1 file with changes
===================
1) src/Configuration/OnlyRuleResolver.php:61
---------- begin diff ----------
@@ @@
throw new RectorRuleNameAmbigiousException($message);
}
- if (strpos($rule, '\\') === false) {
+ if (in_array(str_contains($rule, '\\'), [0, false], true)) {
$message = sprintf(
'Rule "%s" was not found.%sThe rule has no namespace. Make sure to escape the backslashes, and add quotes around the rule name: --only="My\\Rector\\Rule"',
$rule,
----------- end diff -----------
Applied rules:
* StrContainsRector
* BooleanInBooleanNotRuleFixerRector
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's seems issue in phpstan side for detecting it as union, I just directly patch it on the code for now:
Ref https://getrector.com/demo/a621ae26-28b5-4936-93e0-d3c13b3f9ad9