-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Added AbstractPrefixRequiredForAbstractClass, InterfaceSuffixRequired… #3055
Added AbstractPrefixRequiredForAbstractClass, InterfaceSuffixRequired… #3055
Conversation
…ForInterface, TraitSuffixRequiredForTrait sniffs to Generic.NamingConventions
Related to this issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @annechko, Thanks for these sniffs. Looking good!
I've left some suggestions and comments in-line for you to consider. Most apply to all three sniffs, but I've only left a comment where I encountered something the first time.
src/Standards/Generic/Sniffs/NamingConventions/AbstractPrefixRequiredForAbstractClassSniff.php
Outdated
Show resolved
Hide resolved
src/Standards/Generic/Sniffs/NamingConventions/AbstractPrefixRequiredForAbstractClassSniff.php
Outdated
Show resolved
Hide resolved
src/Standards/Generic/Sniffs/NamingConventions/AbstractPrefixRequiredForAbstractClassSniff.php
Outdated
Show resolved
Hide resolved
src/Standards/Generic/Sniffs/NamingConventions/InterfaceSuffixRequiredForInterfaceSniff.php
Outdated
Show resolved
Hide resolved
src/Standards/Generic/Sniffs/NamingConventions/AbstractPrefixRequiredForAbstractClassSniff.php
Outdated
Show resolved
Hide resolved
… to Missing, add Found info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed that I overlooked the docs files, so two more small remarks there.
Only other thing I could imagine, would be to make the desired prefix/suffix configurable as well as making it configurable whether it should be a prefix or a suffix, but that's probably functionality which would be used by only a small % of users of the sniffs.
src/Standards/Generic/Docs/NamingConventions/AbstractPrefixRequiredForAbstractClassStandard.xml
Outdated
Show resolved
Hide resolved
src/Standards/Generic/Docs/NamingConventions/AbstractPrefixRequiredForAbstractClassStandard.xml
Outdated
Show resolved
Hide resolved
… Interface name, changed docs
@jrfnl Thanks for your feedback! I've tried to fix all places.
I changed And I'm not sure about other sniffs, whether to wait for an issue for Abstract Classes and Traits sniffs |
Sorry, have only just gotten to this. Great work by the way.
I actually think the sniff would be better reverted to before this change was made, especially given that it's only been made in the interface naming sniff. We could add complexity to it if there is a strong desire for it by a larger number of users, but I like the idea of committing 3 sniffs that just implement those PSR naming conventions for anyone who wants to use them. We could do the other way and implement the same options in the other 2 sniffs, but I think this would require a rethink of how the error messages are created as the interface one is getting a bit complex. Thoughts? Either way, I've marked this for inclusion in the 3.6.0 release. I'm sure we'll get to a good place before then. |
@gsherwood I think that maybe it would be better to cover only those rules from PSR naming first, and then wait if there will be a request from users to extend the behavior, at least these sniffs are better then nothing, as it was before them :) Also all these 3 sniffs are very similar, except for error messages and register() method (different tokens), so if we ever want to expand behavior in all 3 sniffs it'd be better to use some common base class and inheret all sniffs from it, and it takes time, and maybe this behavior is not really needed for now. So - revert code and wait for an issue - is ok? |
I'd be happy with that. I think the sniffs provide real value even without these config options. |
…checking Interface name, changed docs"
I've merged in these new sniffs, although I did decide to rename them so they fit a bit better with the other sniffs in that category. So PHPCS now has Thanks again. |
Added 3 new sniffs to Generic standard to be able to check these rules:
PSR Naming Conventions https://www.php-fig.org/bylaws/psr-naming-conventions/