-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
4.0 | PEAR/PSR2/FunctionCallSignature: support anonymous classes #47
base: 4.0
Are you sure you want to change the base?
4.0 | PEAR/PSR2/FunctionCallSignature: support anonymous classes #47
Conversation
hi, thanks for head-up, didn't know squizlabs is abandoned tried with this branch and have some issues with loading rules on branch 4, getting a lot of:
need to check more what has changed to find out what's the problem, as release 3.7.2 from this repo works well with couple changes - just pushed branch: https://github.com/webimpress/coding-standard/tree/feat/phpcsstandards if you have a sec to advise what I need to change to prepare compatibility with v4 and verify changes from this branch. Thanks 🙏 |
@michalbundyra Expect an official announcement over the next few days. For now, I'm still scrambling to get this repo up & running properly. (The news is very fresh)
The 4.0 branch has a I originally had this PR against the 3.x branch, but when recreating it now, I decided to err on the side of caution as the PR changes one of the I'm hoping to release 3.8.0, including nearly all of my previously open PRs (with the exception of the 4.x specific ones) over the next few weeks. |
@jrfnl thanks, just tested with PS. Do you think would be ok for me to release new minor (1.4.0) with switch to this library (and probably pin v3.8 when released)? Or I would need a new major? Thanks :) |
Thanks for testing!
That should be fine as far as I can see, though I suggest only doing so after I've tagged |
Cool, thanks again, I'll subscribe on the repo to be up to date. Once it's stabilised I might be bringing couple of mine old PRs from squizlabs as well :) |
Sounds like a plan ;-) |
d17d642
to
7bbac11
Compare
7bbac11
to
1505104
Compare
.. to document that the sniff also handles comparisons passed in the instantiation of an anonymous class.
The function call spacing for anonymous class instantiations was so far not checked by these or any other PHPCS native sniffs. In my opinion, object instantiations of anonymous classes should be treated the same an object instantiations of non-anonymous classes. The `PEAR.Functions.FunctionCallSignature` and the `PSR2.Methods.FunctionCallSignature` sniffs check the object instantiation spacing for non-anonymous classes, so seem like the logical place to also check the spacing for anonymous class object instantiations. To add this support, the `T_ANON_CLASS` token has been added to the `Tokens::$functionNameTokens` array. Notes: * As PSR12 does not specify the spacing between the `class` keyword and the open parenthesis (or rather is unclear about it), I am explicitly excluding anonymous classes from the "space before open parenthesis" check. Related: squizlabs/PHP_CodeSniffer 3200 * I have verified all other uses of the `Tokens::$functionNameTokens` array within PHPCS. - The `Generic.WhiteSpace.ArbitraryParenthesesSpacing` sniff is not affected by the change and already contains a test to verify this. - The `Squiz.Operators.ComparisonOperatorUsage` sniff also is not affected by the change. I have added tests to confirm this in a separate commit. * Obviously external standards using the token array _may_ be affected by the change, but a scan of the most popular external standards showed me that the token array is rarely used and when it is used, is mostly used incorrectly. The only sniff using the array, which looks to be using it correctly and which may be affected, is the `WebImpressCodingStandard.WhiteSpace.ScopeIndent` sniff. Whether this is positive or negative is up to michalbundyra to determine. Includes unit tests for both the `PEAR.Functions.FunctionCallSignature` and the `PSR2.Methods.FunctionCallSignature` sniffs .
1505104
to
e0ff181
Compare
Description
Recreation of upstream PR squizlabs/PHP_CodeSniffer#3636 + rebase for the 4.0 branch:
Other notes from the original PR:
Suggested changelog entry
Tokens::$functionNameTokens
array now includes theT_ANON_CLASS
token.