Skip to content

chore: add Rector and modernize code#1528

Merged
gennadigennadigennadi merged 3 commits into
4.xfrom
add-rector-php81-rule
Jan 5, 2026
Merged

chore: add Rector and modernize code#1528
gennadigennadigennadi merged 3 commits into
4.xfrom
add-rector-php81-rule

Conversation

@gennadigennadigennadi

@gennadigennadigennadi gennadigennadigennadi commented Jan 3, 2026

Copy link
Copy Markdown
Collaborator
  • Add Rector tool to Makefile with rector and rector-check targets
  • Enable PHP 8.1 prepared set in rector.php
  • Update tests to use ::class constants instead of FQCN strings
  • Prefer arrow functions and first-class callables (e.g. strval(...), Path::normalize(...)) for array_map and callbacks
  • Remove redundant parent::setUp/tearDown calls in tests
  • Add explicit (string) casts where needed and tweak JUnit formatter tests to use correct implode glue

This aligns the project with PHP 8.1, improves readability, and prepares codebase for automated refactoring with Rector.

- Add Rector tool to Makefile with rector and rector-check targets
- Enable PHP 8.1 prepared set in rector.php; drop deprecated withPhpLevel
- Update tests to use ::class constants instead of FQCN strings
- Prefer arrow functions and first-class callables (e.g. strval(...),
  Path::normalize(...)) for array_map and callbacks
- Remove redundant parent::setUp/tearDown calls in tests
- Add explicit (string) casts where needed and tweak JUnit formatter
  tests to use correct implode glue

This aligns the project with PHP 8.1, improves readability, and
prepares codebase for automated refactoring with Rector.

@patrickkusebauch patrickkusebauch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far looks fine.

@gennadigennadigennadi gennadigennadigennadi changed the title chore: add Rector and modernize tests chore: add Rector and modernize code Jan 3, 2026

@patrickkusebauch patrickkusebauch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far so good.

@gennadigennadigennadi gennadigennadigennadi marked this pull request as ready for review January 5, 2026 19:21
@gennadigennadigennadi gennadigennadigennadi merged commit 761c96a into 4.x Jan 5, 2026
16 checks passed
@gennadigennadigennadi gennadigennadigennadi deleted the add-rector-php81-rule branch January 5, 2026 19:23

foreach ($refs as $ref) {
$name = preg_replace('/^.*\\\\(\w+(\(\))?)$/', '$1', $ref->getToken()->toString());
$name = preg_replace('/^.*\\\\(\w+(\(\))?)$/', '$1', (string) $ref->getToken()->toString());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the string type not be enforced on the toString() method instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went down the rabbit hole :-).
The problem is that we don't enforce array-shapes (see refsByName signature), therefore rector does not know what $ref is and adds the cast.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks for digging. :)

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.

3 participants