Skip to content

Conversation

@rodrigoprimo
Copy link
Collaborator

@rodrigoprimo rodrigoprimo commented Nov 6, 2025

Description

In preparation for PHPCS 4.0, which changes the tokenization of namespaced names, this PR adds tests with all forms of namespaced function calls (partially qualified, fully qualified, and namespace-relative using the 'namespace' keyword) as well as fully qualified global function calls to the sniffs that extend the AbstractClassRestrictionsSniff class when necessary. Some test files already contained part or all of the required tests.

For DeprecatedClasses, I opted to add the tests in a separate file as the error lines DeprecatedClassesUnitTest.1.inc are generated dynamically. Since the tests were added to a separate file, I opted to include all possible namespace variations even though a few already exist in DeprecatedClassesUnitTest.1.inc. I didn't want to complicate things by having the namespaced names tests in different files.

Suggested changelog entry

N/A

@rodrigoprimo
Copy link
Collaborator Author

Moved to draft pending the review of #2620

@rodrigoprimo rodrigoprimo force-pushed the more-namespace-tests-2 branch from 187b5c8 to 420def6 Compare November 12, 2025 18:38
@rodrigoprimo rodrigoprimo changed the title Sniffs: add tests for namespaced names [2] AbstractClassRestrictionsSniff sniffs: add tests for namespaced names Nov 12, 2025
@rodrigoprimo rodrigoprimo marked this pull request as ready for review November 12, 2025 18:48
@rodrigoprimo
Copy link
Collaborator Author

rodrigoprimo commented Nov 12, 2025

@jrfnl, this PR is now ready for review. I implemented the changes that we discussed for #2620. I also removed tests for CapitalPDangit and added tests for RestrictedClasses. This way, this PR is now about namespaced names tests for sniffs that extend AbstractClassRestrictionsSniff.

Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

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

Thanks @rodrigoprimo for setting this up! Looking good. Just some small remarks to dot the i's and cross the t's.

More tests will be added in a separate file in a subsequent commit.
I opted to add the tests in a separate file as for DeprecatedClassesUnitTest.1.inc the error lines are generated dynamically.
@rodrigoprimo rodrigoprimo force-pushed the more-namespace-tests-2 branch from 420def6 to f4099e0 Compare December 9, 2025 14:42
@rodrigoprimo
Copy link
Collaborator Author

Thanks for your review, @jrfnl. I addressed the points that you raised and, as we discussed, amended the original commits.

This commit also adds two non-namespaces tests for interfaces as those were missing in the file.
@rodrigoprimo rodrigoprimo force-pushed the more-namespace-tests-2 branch from f4099e0 to a6b8b32 Compare December 9, 2025 14:58
Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

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

Thanks for making those updates @rodrigoprimo ! All good from me now.

@jrfnl jrfnl added this to the 3.3.x milestone Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants