-
-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Labels
Description
Describe the bug
In a specific snippet where a property is assigned an array value, and an element of that array is a chained call, the sniff will require incorrect indentation.
I did not debug this and I don't know what exactly triggers it, but the property assignment seems necessary (e.g., assigning to a normal variable does not reproduce the bug).
Code sample
<?php
$bar->prop = [
$foo->first()
->second(),
];
Custom ruleset
<?xml version="1.0"?>
<ruleset name="My Custom Standard">
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent" />
</ruleset>
To reproduce
Steps to reproduce the behavior:
- Create a file called
test.php
with the code sample above - Run
phpcs test.php
- See error message displayed
---------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------
5 | ERROR | [x] Object operator not indented correctly; expected 4 spaces but found 8
---------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------
Expected behavior
No issue should be emitted.
Versions (please complete the following information)
Operating System | Ubuntu |
PHP version | 8.4.8 |
PHP_CodeSniffer version | master |
Standard | custom |
Install type | composer (local) |
Please confirm
- I have searched the issue list and am not opening a duplicate issue.
- I have read the Contribution Guidelines and this is not a support question.
- I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
- I have verified the issue still exists in the
master
branch of PHP_CodeSniffer.