-
Notifications
You must be signed in to change notification settings - Fork 2k
refactor: upgrade to PHP 8.0 with rector #6923
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
system/Autoloader/FileLocator.php
Outdated
| } | ||
|
|
||
| if ((isset($tokens[$i - 2][1]) && ($tokens[$i - 2][1] === 'phpnamespace' || $tokens[$i - 2][1] === 'namespace')) || ($dlm && $tokens[$i - 1][0] === T_NS_SEPARATOR && $token[0] === T_STRING)) { | ||
| if ((isset($tokens[$i - 2][1]) && ($tokens[$i - 2][1] === 'phpnamespace' || $tokens[$i - 2][1] === 'namespace')) || ($dlm && $tokens[$i - 1][0] === T_NS_SEPARATOR && $token->is(T_STRING))) { |
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.
@samsonasik
This code causes an error.
Running PHPStan...
Note: Using configuration file .../CodeIgniter4/phpstan.neon.dist.
Error thrown in .../CodeIgniter4/system/Autoloader/FileLocator.php on line 128 while loading bootstrap file .../CodeIgniter4/phpstan-bootstrap.php: Cannot use object of type PhpToken as array
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.
Possibly bug on TokenGetAllToObjectRector
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.
Yes, this is a bug on TokenGetAllToObjectRector.
The $tokens in the original code is just an array of array, and used as $tokens[$i - 2][1].
But $tokens in the refactored code is an array of PhpToken object.
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.
Skipped the rule.
|
Cherry-picking rule by rule per-PR from config can be a way to make easier to catch breaking changes, so smallest PR will be easy to merge |
Applied rules: * StrEndsWithRector (https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions) * StrStartsWithRector (https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions) * StrContainsRector (https://externals.io/message/108562 php/php-src#5179)
c4487b6 to
6c5297e
Compare
| * {@inheritDoc} | ||
| */ | ||
| public function __toString() | ||
| public function __toString(): string |
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.
Is this a breaking change?
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.
No, __toString is special, it keep working even child doesn't has return type
|
It seems difficult to apply ClasPropertyAssignToConstructorPromotionRector. E.g.,
|
|
That can posibly due to autoload overlapped, the tweak may be needed https://github.com/rectorphp/rector/blob/main/docs/static_reflection_and_autoload.md |
|
Probably due to property type mismatch between parent class and child class. |
|
I think the small approach is good. I will also note that I've found CS Fixer to be a great companion tool for Rector during the upgrades to make sure the results are still compliant with our style guide. |
Needs #6922
Description
See #6921
Applied rules:
Checklist: