You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix fatal 'class already declared' errors when using external standards
I've seen similar issues now in several external standards, where people are receiving a `Cannot declare class Standard\Sniffs\Category\SomethingSniff, because the name is already in use` error.
I've not been able to reproduce the issues, but noticed that - at least in some of the cases - this involved external sniffs which extend other external sniffs and use a `use` statement for the parent sniff.
I suspect that the fact that I cannot reproduce this, may be due to sniffs not loading in a predefined order, but depending on when the directive to include the sniff/standard is encountered in the ruleset.
I imagine that if a child sniff is included first and a parent sniff second, this causes the fatal error.
Using `include_once` instead of `include` for typical class based files should solve this problem.
To that end, I've reviewed all uses of `include/require` in PHPCS and the three addressed in this PR are the result of that review.
0 commit comments