-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Generic.Arrays.ArrayIndent can request close brace indent to be less than the statement indent level #2882
Comments
The core issue with this one appears to be that the open bracket of the array needs to be indented to at least the level of the start of the statement. In the code sample, it's indented 3 spaces instead of 4, which causes the conflicts. I'm going to look at changing the ArrayIndent sniff to enforce this base indent, but not a specific indent level. Note that the Squiz standard works fine because it has additional rules that force the array open brace to be on the same line as the start of the statement, so the indent is always calculated correctly. |
…indent to be less than the statement indent level
The change described above has fixed this issue without impacting any existing tests. Thanks for reporting this issue. |
It works well on
diff --git a/test.php b/test.php
index 126663e5a..5cdf6591d 100644
--- a/test.php
+++ b/test.php
@@ -3,6 +3,6 @@
$foo =
[
'bar' =>
- [
+ [
],
]; Thanks, @gsherwood! |
…indent to be less than the statement indent level
Originally, this issue was found when using the Doctrine Coding Standard but as it turned out in slevomat/coding-standard#913, it’s reproducible with PHP_CodeSniffer as well.
Consider the following code example and standard configuration:
The following violations are reported:
An attempt to auto-fix the file fails:
And introduces another violation (both lines 6 and 7 are now indented using 3 spaces instead of 4):
An attempt to fix the modified file also fails. Note that fixing the file using
--standard=Squiz
(as per the reported violations) succeeds:The text was updated successfully, but these errors were encountered: