Skip to content

Adopt the PHP 8.1 syntax Rector proposes and remove its skips #601

Closed

Description

@armanist

Summary

Apply the PHP 8.1 syntax that Rector's 8.1 level set proposes (readonly properties and first-class callable syntax), and remove the three skips that keep composer rector:check green until then. Part of the PHP 8.1 update (#595).

Why

#595 moves Rector to the 8.1 level set. Three of its rules would change 52 files, so they are skipped for now:

  • ReadOnlyPropertyRector: 84 properties in 48 files become readonly.
  • FunctionFirstClassCallableRector: 5 places ('strlen' becomes strlen(...)).
  • ArrayToFirstClassCallableRector: 2 places ([$this, 'method'] becomes $this->method(...)).

Applying all three at once passes composer cs:check and composer phpstan, but breaks 4 tests, so each rule needs a decision.

Findings from a trial run

  • MigrationManagerTest (2 tests) replaces the db property by reflection. A readonly property cannot be changed after the constructor.
  • ErrorHandlerTest (2 tests) checks that ErrorHandler::setup() registers [$handler, 'handleError'] and [$handler, 'handleException']. After the rewrite PHP holds a Closure instead of an array, which is a visible change in what the registered handler is.
  • readonly also changes how the classes behave: a property can no longer be reassigned, which matters to anyone who subclasses them.

Proposed change

Take the rules one at a time, one commit each:

  • FunctionFirstClassCallableRector: apply the 5 edits.
  • ArrayToFirstClassCallableRector: apply in Transformer; decide for ErrorHandler whether to keep the array callable (and skip that line) or change the tests.
  • ReadOnlyPropertyRector: apply, change the tests that set those properties by reflection, and list in the changelog the classes whose properties became readonly.
  • Remove each skip from rector.php when its rule is applied.

Out of scope

  • Turning AppType and LoggerType into enums.
  • Anything that needs PHP 8.2 or newer.

Breaking changes

  • Subclasses that reassign a property that became readonly. To be listed in the changelog.

Acceptance criteria

  • rector.php has no skip for these three rules, or a comment for each one that stays
  • composer test, composer cs:check, composer phpstan and composer rector:check pass on every PHP version in the CI matrix

Notes

Relevant code: rector.php, src/Tracer/ErrorHandler.php, tests/Unit/Migration/MigrationManagerTest.php, tests/Unit/Tracer/ErrorHandlerTest.php.

Activity

  1. added this to the 3.1.0 milestone on Oct 23, 2026
  2. self-assigned this
    on Oct 23, 2026
  3. added a commit that references this issue on Oct 23, 2026
  4. added 2 commits that reference this issue on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions