Closed jrfnl closed 1 year ago
Note: this PR will conflict with the already open PRs #3739 and #3661 and depending on the merge order, rebasing and conflict resolution will be needed....
FYI: this fix is included in today's PHP_CodeSniffer 3.8.0 release.
As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo).
Since PHP 8.1,
new ClassName()
expressions can be used as the default value of a parameter in a function declaration.new ClassName()
expressions should be treated as function calls, which have their own indentation rules, so thePEAR.Functions.FunctionDeclaration
and theSquiz.Functions.MultiLineFunctionDeclaration
sniffs should skip over these and not attempt to change the indentation of parameters in those function calls.This commit implements this change.
Includes unit tests.
Refs:
Fixes #3786
Note:
File::getMethodParameters()
method handles "new in initializers" correctly.Squiz.Functions.FunctionDeclaration
, theSquiz.Functions.FunctionDeclarationArgumentSpacing
and thePSR2.Methods.MethodDeclaration
sniffs, I don't foresee that those need changes for "new in initializers".