Skip to content

Conversation

@carlos-granados
Copy link
Contributor

Now that we have a full coding standard configuration we are ready to add the Rector tool and start using it.

We need to be careful when using it as some of the changes introduced by Rector can create BC issues so we need to evaluate all of its rules and only apply those which are safe.

This PR introduces the initial setup to use this tool and adds a couple of things:

  • The initial level of the Code Quality rules which applies a couple of rules
  • Import handling, which makes sure that we are using import statements instead of FQN and removes unused imports

I have separated this in two commits (tool setup and code changes) so that the code changes can be added to the blame ignore file once this PR is approved

Closes #1506

@carlos-granados carlos-granados marked this pull request as draft May 16, 2025 06:56
// Class names are intentionally fully qualified here to maximise clarity - particularly because a future
// PHPUnit version may reuse a class name in a different namespace.

if (class_exists(\PHPUnit\Util\ThrowableToStringMapper::class)) {
if (class_exists(ThrowableToStringMapper::class)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably OK to lose the fully-qualified names here - particularly now we know that people won't be able to use just the assertions from future PHPUnit versions anyway?

If so we should just remove the comment above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had not realised about the comment, agree with you, removed

@carlos-granados
Copy link
Contributor Author

@acoulton do you think this is now OK? I would like to merge it so that we can continue adding more Rector rules

@carlos-granados carlos-granados requested a review from acoulton June 5, 2025 08:03
Copy link
Contributor

@acoulton acoulton left a comment

Choose a reason for hiding this comment

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

Great, thanks @carlos-granados

@carlos-granados carlos-granados marked this pull request as ready for review June 5, 2025 11:17
@carlos-granados carlos-granados merged commit 0c129f2 into Behat:master Jun 5, 2025
19 checks passed
@carlos-granados carlos-granados deleted the add-rector branch June 20, 2025 10:39
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.

Add Rector to our code base

2 participants