Skip to content

3.10.0 added a bug with line identation #505

@momala454

Description

@momala454

Describe the bug

Doesn't properly detect the correct number of space in some cases.

Code sample

<?php declare(strict_types=1); namespace a; class Hello { /** @param mixed[] $items */ public static function world(array $items, bool $nice): void { } public function hi(): void { \a\Hello::world( items: [ 'a' => [1, 2, 3] ], nice: false ); } }

If I add a comma after "nice: false", no error is reported

Custom ruleset

<?xml version="1.0"?> <ruleset name="My Custom Standard"> <description>If you are using a custom ruleset, please enter the relevant part here.</description> </ruleset>

To reproduce

Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcs test.php ...
  3. See error message displayed
 21 | ERROR | [x] Line indented incorrectly; expected at least 12 spaces, found 8 (Generic.WhiteSpace.ScopeIndent.Incorrect) 

Expected behavior

No error

Versions (please complete the following information)

Operating System Windows 10
PHP version 8.1
PHP_CodeSniffer version 3.10.0
Standard psr12
Install type [composer

Additional context

Add any other context about the problem here.

Please confirm

  • I have searched the issue list and am not opening a duplicate issue.
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions