CodeIgniter4 icon indicating copy to clipboard operation
CodeIgniter4 copied to clipboard

refactor: upgrade to PHP 8.1 with rector

Open kenjis opened this issue 2 years ago • 7 comments

Description Supersedes #7964

All refactoring will be performed just prior to the release of v4.5.0.

Checklist:

  • [x] Securely signed commits
  • [ ] Component(s) with PHPDoc blocks, only if necessary or adds value
  • [ ] Unit testing, with >80% coverage
  • [ ] User guide updated
  • [ ] Conforms to style guide

kenjis avatar Dec 21 '23 02:12 kenjis

@kenjis I suggest rules ChangeSwitchToMatchRector by Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector

ddevsr avatar Dec 21 '23 04:12 ddevsr

Doesn't it included in LevelSetList::UP_TO_PHP_81?

kenjis avatar Dec 21 '23 06:12 kenjis

Doesn't it included in LevelSetList::UP_TO_PHP_81?

Sorry i didnt read it

ddevsr avatar Dec 21 '23 06:12 ddevsr

@samsonasik When rector is executed on this branch, rector enters an infinite loop, because of the following files:

            __DIR__ . '/system/Common.php',
            __DIR__ . '/system/Helpers/filesystem_helper.php',
            __DIR__ . '/system/Helpers/text_helper.php',
            __DIR__ . '/system/Helpers/form_helper.php',
            __DIR__ . '/system/Helpers/html_helper.php',
            __DIR__ . '/system/Helpers/number_helper.php',

Rector adds too many declare(strict_types=1); lines to them. Is this a bug?

kenjis avatar Dec 21 '23 08:12 kenjis

@kenjis probably, could you create a reproducible at https://getrector.com/demo and report at https://github.com/rectorphp/rector/ ? Thank you.

samsonasik avatar Dec 21 '23 08:12 samsonasik

:wave: Hi, @kenjis!

We detected conflicts in your PR against the base branch :speak_no_evil:
You may want to sync :arrows_counterclockwise: your branch with upstream!

Ref: Syncing Your Branch

github-actions[bot] avatar Dec 22 '23 02:12 github-actions[bot]

:wave: Hi, @kenjis!

We detected conflicts in your PR against the base branch :speak_no_evil:
You may want to sync :arrows_counterclockwise: your branch with upstream!

Ref: Syncing Your Branch

github-actions[bot] avatar Feb 08 '24 21:02 github-actions[bot]

@samsonasik These files with too many declare(strict_types=1) are all functions, not class files. But I cannot make a simple reproducible sample code.

kenjis avatar Feb 25 '24 03:02 kenjis

@kenjis the DeclareStrictTypesRector can be skipped if it make too many changes, and create separate PR to enable that?

samsonasik avatar Feb 25 '24 03:02 samsonasik

Actually, the DeclareStrictTypesRector is not part of any set list now, so should not apply the changes except registered, I can't see any addition of declare(strict_types=1) now in github diff

samsonasik avatar Feb 25 '24 03:02 samsonasik

:wave: Hi, @kenjis!

We detected conflicts in your PR against the base branch :speak_no_evil:
You may want to sync :arrows_counterclockwise: your branch with upstream!

Ref: Syncing Your Branch

github-actions[bot] avatar Feb 26 '24 00:02 github-actions[bot]

:wave: Hi, @kenjis!

We detected conflicts in your PR against the base branch :speak_no_evil:
You may want to sync :arrows_counterclockwise: your branch with upstream!

Ref: Syncing Your Branch

github-actions[bot] avatar Mar 09 '24 23:03 github-actions[bot]

@kenjis could you rebase and retry add DeclareStrictTypesRector, run composer update, and verify if no longer infinite loop on latest rector 1.0.3? Thank you.

samsonasik avatar Mar 15 '24 05:03 samsonasik

@samsonasik Thank you! It worked fine.

[OK] 148 files have been changed by Rector  

Dropped https://github.com/codeigniter4/CodeIgniter4/pull/8354/commits/1ecb0491baf78f5c7fa16034f47a0174d05d9a8f

kenjis avatar Mar 16 '24 01:03 kenjis