Closed jrfnl closed 9 months ago
Note: this does cause some overlap with the PSR12.Classes.AnonClassDeclaration
sniff in the PSR12 standard. Not sure what to do about this, though it shouldn't be a cause for fixer conflicts (as the sniffs expect the same thing).
Rebased without any real changes to solve the merge conflicts.
Closing as replaced by https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/47
The function call spacing for anonymous class instantiations was so far not checked by these
or any other PHPCS nativesniffs.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 thePSR2.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 theTokens::$functionNameTokens
array.Notes:
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#3200Tokens::$functionNameTokens
array within PHPCS.Generic.WhiteSpace.ArbitraryParenthesesSpacing
sniff is not affected by the change and already contains a test to verify this.Squiz.Operators.ComparisonOperatorUsage
sniff also is not affected by the change. I have added tests to confirm this in a separate commit.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 thePSR2.Methods.FunctionCallSignature
sniffs .