You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a closure/anonymous function is used as a callback in a function call, then indentations doesn't get fixed with Generic.WhiteSpace.ScopeIndent sniff property exact set to true. The conditional statement blocks will get fixed, but the code inside them won't. Both space and tab indentation doesn't get fixed. I am aware there is multiple closed issues relating to indentation but they're slightly different issues I believe (none of the solutions fixed the issue).
<?xml version="1.0"?>
<rulesetname="yCodeTech">
<description>yCodeTech's Coding Standards</description>
<!-- Scan all files in directory -->
<file>.</file>
<!-- Scan only PHP files -->
<argname="extensions"value="php"/>
<!-- Ignore WordPress and Composer dependencies -->
<exclude-pattern>web/wp</exclude-pattern>
<exclude-pattern>web/app/plugins</exclude-pattern>
<exclude-pattern>web/app/mu-plugins</exclude-pattern>
<exclude-pattern>vendor/</exclude-pattern>
<exclude-pattern>web/app/uploads/</exclude-pattern>
<!-- Show colors in console -->
<argvalue="-colors"/>
<!-- Show sniff codes in all reports -->
<argvalue="ns"/>
<!-- Allow multiple classes in a single file ONLY for facades.php files, ie. exclude the file from the sniff. -->
<ruleref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<exclude-pattern>*facades.php</exclude-pattern>
</rule>
<!-- Use PSR-2 as a base -->
<ruleref="PSR2">
<!-- Allow tab indent -->
<excludename="Generic.WhiteSpace.DisallowTabIndent"/>
<!-- Allow php files to end without blank line -->
<excludename="PSR2.Files.EndFileNewline"/>
<!-- Allow braces on the same line as the function declaration. -->
<excludename="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
<!-- Allow inline if statements without braces -->
<excludename="Generic.ControlStructures.InlineControlStructure" />
<excludename="PSR2.Classes.ClassDeclaration.OpenBraceNewLine" />
<excludename="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace" />
<excludename="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<excludename="PEAR.Functions.ValidDefaultValue.NotAtEnd" />
<!-- Allow same-line function call arguments, ie. prevent 1 argument per line. -->
<excludename="PEAR.Functions.FunctionCallSignature.MultipleArguments" />
<!-- Allow content after a function opening bracket, ie. allow arguments on same line as the opening bracket. -->
<excludename="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" />
<!-- Prevent function closing bracket from being on it's own line. -->
<excludename="PEAR.Functions.FunctionCallSignature.CloseBracketLine" />
</rule>
<!-- Allow same line starting brackets for classes -->
<ruleref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
<!-- Disallow space indent --><!--<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/> --><!-- Allow tab indents -->
<ruleref="Generic.WhiteSpace.ScopeIndent">
<properties>
<propertyname="indent"value="4"/>
<propertyname="tabIndent"value="false"/>
<propertyname="exact"value="true"/>
</properties>
</rule>
<!-- Disallow spaces after opening and closing braces -->
<ruleref="PEAR.Functions.FunctionCallSignature">
<properties>
<propertyname="requiredSpacesAfterOpen"value="0" />
<propertyname="requiredSpacesBeforeClose"value="0" />
<propertyname="allowMultipleArguments"value="false"/>
</properties>
</rule>
</ruleset>
To reproduce
Steps to reproduce the behavior:
Create a file called test.php with the code sample above...
Run phpcs test.php ...
No error message outputted.
Expected behavior
The indentation should be fixed no matter its type. So above code should be fixed to:
yCodeTech
changed the title
Generic.WhiteSpace.ScopeIndent
Generic.WhiteSpace.ScopeIndent: Indentation doesn't get fixed inside closures as a callback arg in a function call
Sep 10, 2023
Describe the bug
If a closure/anonymous function is used as a callback in a function call, then indentations doesn't get fixed with
Generic.WhiteSpace.ScopeIndent
sniff propertyexact
set totrue
. The conditional statement blocks will get fixed, but the code inside them won't. Both space and tab indentation doesn't get fixed. I am aware there is multiple closed issues relating to indentation but they're slightly different issues I believe (none of the solutions fixed the issue).Code sample
Custom ruleset
To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above...phpcs test.php ...
Expected behavior
The indentation should be fixed no matter its type. So above code should be fixed to:
Versions (please complete the following information)
Please confirm:
master
branch of PHP_CodeSniffer.The text was updated successfully, but these errors were encountered: