Describe the bug
The rule PEAR.WhiteSpace.ObjectOperatorIndent always shows an error for indentation space for object operator when on a array that has a embedded array before it.
If i move the key brand from the code sample to the end of the array the error is not reported anymore.
Code sample
<?php
namespace Example;
class Bug
{
public function toJson(array $list): array
{
return [
'brand' => [
'id' => $item->product()->brand()->id(),
'title' => $item->product()->brand()->name(),
],
'charges' => $item->charges()
->toArray(), // Object operator not indented correctly; expected 20 spaces but found 16
];
}
}
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
FILE: src/Example/Bug.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
----------------------------------------------------------------------
15 | ERROR | [x] Object operator not indented correctly; expected 20
| | spaces but found 16
15 | ERROR | [x] Object operator not indented correctly; expected 20
| | spaces but found 16
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Time: 267ms; Memory: 8MB
Expected behavior
PHPCS and PHPCPF should be able to "select" the right indentation when on a array, even if a "embedded array" before it.
Versions (please complete the following information):
- OS: Linux
- PHP: 7.4
- PHPCS: 3.5.0, 3.7.1
- Standard: see "Custom ruleset"
Additional context
NONE
Describe the bug
The rule
PEAR.WhiteSpace.ObjectOperatorIndentalways shows an error for indentation space for object operator when on a array that has a embedded array before it.If i move the key
brandfrom the code sample to the end of the array the error is not reported anymore.Code sample
Custom ruleset
To reproduce
Steps to reproduce the behavior:
test.phpwith the code sample above...phpcs test.php ...Expected behavior
PHPCS and PHPCPF should be able to "select" the right indentation when on a array, even if a "embedded array" before it.
Versions (please complete the following information):
Additional context
NONE