Skip to content

Issue/601 Adopt the PHP 8.1 syntax Rector proposes and remove its skips - #607

Merged
armanist merged 3 commits into
quantum-php:masterfrom
armanist:issue/601-rector-php81-syntax
Oct 23, 2026
Merged

armanist merged 3 commits into
quantum-php:masterfrom
armanist:issue/601-rector-php81-syntax

Conversation

@armanist

Copy link
Copy Markdown
Collaborator

Closes #601. Part of #595. The changelog entry is written in a final pull request, after the sub-issues.

What changed

  • FunctionFirstClassCallableRector: array_map('trim', $x) and the like become array_map(trim(...), $x) in Body, MailTrap, Route, RouteBuilder and UploadPolicy.
  • ArrayToFirstClassCallableRector: Transformer and ErrorHandler use $this->handleError(...) and $transformer->transform(...) instead of array callables. ErrorHandlerTest now checks the registered handlers by reflection: a Closure bound to the ErrorHandler instance, named handleError or handleException.
  • ReadOnlyPropertyRector: 84 private properties in 48 classes that are assigned only in the constructor become private readonly.
  • MigrationManagerTest: two tests replaced the private db property by reflection, which readonly does not allow. They now build MigrationManager in a fresh app context that holds a mocked Database.
  • rector.php has no skip left for these three rules. The constructor promotion rule stays skipped as before.

Why

#595 moved Rector to the PHP 8.1 level set and skipped three of its rules to keep composer rector:check green. This applies them, one commit per rule.

Breaking changes

  • None. All 84 properties are private, so subclasses cannot be affected. The registered error and exception handlers are now closures instead of arrays; nothing in the framework reads them back.

Testing

  • Changed tests: ErrorHandlerTest (the two registration tests) and MigrationManagerTest (the unsupported driver and wrong direction tests).
  • No behavior changed, so no new tests. The full suite on PHP 8.1 gives the same results as before: only the Redis and Memcached tests error locally, and they run in CI.

Notes for reviewers

  • Review commit by commit. The readonly commit is large (50 files) but mechanical, produced by rector process.

@quantum-php quantum-php deleted a comment from coderabbitai Bot Oct 23, 2026
@armanist
armanist merged commit 57623a7 into quantum-php:master Oct 23, 2026
5 of 6 checks passed
@armanist
armanist deleted the issue/601-rector-php81-syntax branch October 23, 2026 17:19
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt the PHP 8.1 syntax Rector proposes and remove its skips

1 participant