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

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 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

@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 fro RestrictedClasses. This way this PR is now about namespaced names tests for sniffs that extend AbstractClassRestrictionsSniff.

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.

1 participant