- Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Describe the bug
phpcs in PSR12 mode reports that a line is indented incorrectly when it is correctly indented according to my understanding.
Code sample
<?php namespace foo; class Foo { public static function foo(array $foo): array { return \array_map(static function ($foo) { return [ match ($foo) { 0 => 1, 1 => 0, }, $foo, ]; }, $foo); } }
Custom ruleset
--standard=PSR12
To reproduce
Steps to reproduce the behavior:
- Create a file called
test.php
with the code sample above... - Run
phpcs --standard=PSR12 -s test.php
- See error message displayed
FILE: /pwd/test.php -------------------------------------------------------------------------------------------------------------------------- FOUND 2 ERRORS AFFECTING 2 LINES -------------------------------------------------------------------------------------------------------------------------- 11 | ERROR | [x] Line indented incorrectly; expected 12 spaces, found 16 | | (Generic.WhiteSpace.ScopeIndent.IncorrectExact) 14 | ERROR | [x] Line indented incorrectly; expected 12 spaces, found 16 | | (Generic.WhiteSpace.ScopeIndent.IncorrectExact) -------------------------------------------------------------------------------------------------------------------------- PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY -------------------------------------------------------------------------------------------------------------------------- Time: 73ms; Memory: 8MB
When reformatting with phpcbf
the file will look like this afterwards:
<?php namespace foo; class Foo { public static function foo(array $foo): array { return \array_map(static function ($foo) { return [ match ($foo) { 0 => 1, 1 => 0, }, $foo, ]; }, $foo); } }
Expected behavior
I did not expect any errors in the given file.
I expected phpcbf not to change the file.
Versions (please complete the following information):
- OS: Ubuntu 20.04, Docker.
- PHP: 8.1
- PHPCS: PHP_CodeSniffer version 3.7.1 (stable) by Squiz (http://www.squiz.net)
- Standard: PSR12
Additional context
n/a