-
-
Notifications
You must be signed in to change notification settings - Fork 417
Fix php 7.4 regression on strtolower to false on ClassLikeNameClassNameImportSkipVoter #7436
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
Conversation
β¦meImportSkipVoter
β¦meImportSkipVoter
| $shortNameLowered = $fullyQualifiedObjectType->getShortNameLowered(); | ||
| $fullyQualifiedObjectTypeNamespace = strtolower( | ||
| substr($fullyQualifiedObjectType->getClassName(), 0, -strlen($fullyQualifiedObjectType->getShortName()) - 1) | ||
| substr($fullyQualifiedObjectType->getClassName(), 0, -strlen($fullyQualifiedObjectType->getShortName()) - 1) ?: '' |
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.
Can you add a note about PHP 7.4? So we don't accidentally remove it :)
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.
sure, I created new PR to add note for it
the RecastingRemovalRector needs also improvement for it, currently skipped
Lines 57 to 60 in 21b6091
| // todo: properly handle, substr() can return false on php 7.x | |
| RecastingRemovalRector::class => [ | |
| __DIR__ . '/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/ClassLikeNameClassNameImportSkipVoter.php', | |
| ], |
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.
I wonder why this problem is not patched by PHPStan. is it reproducible on the phpstan playground, that we are missing a error here?
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 on phpstan.org, it shows
on php 8.0+, show empy string
on php 7.2+, show false
see https://phpstan.org/r/6c0960c9-23d9-4387-8f95-f13f2f50f33b
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.
ohh I just see rector-src does not run PHPStan on PHP7.x.. you are only using a single PHP 8.2 job and therefore miss PHPStan errors on all other PHP versions
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.
I created PR to skip remove (string) case on substr() on RecastingRemovalRector on getNativeType() method:
| $shortNameLowered = $fullyQualifiedObjectType->getShortNameLowered(); | ||
| $fullyQualifiedObjectTypeNamespace = strtolower( | ||
| substr($fullyQualifiedObjectType->getClassName(), 0, -strlen($fullyQualifiedObjectType->getShortName()) - 1) | ||
| substr($fullyQualifiedObjectType->getClassName(), 0, -strlen($fullyQualifiedObjectType->getShortName()) - 1) ?: '' |
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.
Might be also good candidate for a downgrade rule
|
@TomasVotruba I need to create immediate release 2.2.1 for it :) |
Fixes rectorphp/rector#9405
Ref #7235 (comment)