Skip to content

Extra: Encourage the best practice of only declaring one class/interface/trait per file #1111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2017

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Aug 29, 2017

PHPCS 3.1.0 will introduce a new Generic.Files.OneObjectStructurePerFile sniff will which check for all three in one go, but cannot be used yet. See: squizlabs/PHP_CodeSniffer#1627 and squizlabs/PHP_CodeSniffer#1630

The current sniffs in this proposal will not catch one file containing a class + an interface + a trait, but will catch any file containing two or more of the same type of object structure.

I've chosen to downgrade the message to a warning and to soften the error message a little.
Once these sniffs have been in for a while and we have not received negative feedback about them, we could chose to defer to the upstream sniffs and let them error with a sterner message.

…ace/trait per file

PHPCS 3.1.0 will introduce a new `Generic.Files.OneObjectStructurePerFile` sniff will which check for all three in one go, but cannot be used yet.

The current sniffs in this proposal will not catch one file containing a class + an interface + a trait, but will catch any file containing two or more of the same type of object structure.

I've chosen to downgrade the message to a warning and to soften the error message a little.
Once these sniffs have been in for a while and we have not received negative feedback about them, we could chose to defer to the upstream sniffs and let them `error` with a sterner message.
@GaryJones GaryJones merged commit 7f208f3 into develop Aug 30, 2017
@GaryJones GaryJones deleted the feature/extra-one-structure-per-file branch August 30, 2017 06:57
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.

3 participants