-
Notifications
You must be signed in to change notification settings - Fork 191
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
Use fully qualified names in inline code #100
Conversation
cfb9817
to
31f5601
Compare
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'm not sure this needs to be added to the manual. As of PHP 8.0, using whitespace or comments within the name is a parse error (remember: the Make post was written well before PHP 8.0 was released).
31f5601
to
0f49b18
Compare
I can add it as a note below, would be a good addition IMO 👍🏼 |
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.
While the note about PHP 8.0 does help, I still don't think this section needs to be in the manual.
Code shouldn't cause parse errors on any of the supported PHP versions, Doesn't matter the reason of the parse error.
That's not something which is a coding standard, that's something which is a basic necessity for the code to be able to run.
Oh, you meant we should drop this all together? I just added all the rules we had in the spreadsheet 😂 But your reasoning makes complete sense. I'll close this PR 👍🏼 |
Yes, sorry if my original remark wasn't clear enough. |
Was there any proposal about when to use inline FQCN vs an import? |
There was not. At the time, we decided that as WP isn't using namespaces/import I know of at least one company in the WP sphere where they strictly enforce always importing classes, but forbid importing global functions/constants and instead enforce using FQNs for those. For namespaced functions/constants, the namespace is imported, and the functions/constants use partially qualified names. Both Slevomat as well as PHPCSExtra have various sniffs which could enforce one or the other, so userland has a choice here (and the means to enforce their choice). |
This PR depends on #98. Once that is merged, this PR should be rebased to the master branch.
The PR adds rules about the fully qualified names in the inline code and is the continuation of the additions of 'modern' PHP code in the WordPress PHP Coding Standards handbook based on the make post by Juliette Reinders Folmer.