Fix php 7.4 regression on strtolower to false on ClassLikeNameClassNameImportSkipVoter#7436
Fix php 7.4 regression on strtolower to false on ClassLikeNameClassNameImportSkipVoter#7436samsonasik merged 2 commits intomainfrom
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.
Can you add a note about PHP 7.4? So we don't accidentally remove it :)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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.
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.
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.
Might be also good candidate for a downgrade rule
|
@TomasVotruba I need to create immediate release 2.2.1 for it :) |
|
This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work. |
Fixes rectorphp/rector#9405
Ref #7235 (comment)