refactor: upgrade to PHP 8.0 with rector#6923
refactor: upgrade to PHP 8.0 with rector#6923kenjis wants to merge 8 commits intocodeigniter4:4.3from
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.
@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.
Possibly bug on TokenGetAllToObjectRector
There was a problem hiding this comment.
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.
|
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.
Is this a breaking change?
There was a problem hiding this comment.
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: