Skip to content

Generic.Formatting.MultipleStatementAlignment false positive on closure with parameters #3460

@LastDragon-ru

Description

@LastDragon-ru

Describe the bug

Code sample

<?php declare(strict_types = 1);

namespace Bugs;

use Mockery;

class Bug {
    public function bug(): mixed {
        $a = static function (array $variables = []) {
            return $variables;
        };
        $b = $a;

        return $b;
    }
}

Custom ruleset

<?xml version="1.0"?>
<ruleset name="Bug"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
    <file>./packages</file>
    <rule ref="Generic.Formatting.MultipleStatementAlignment"/>
</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
---------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------
 12 | WARNING | [x] Equals sign not aligned with surrounding assignments; expected 37 spaces but found 1 space
---------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------

Expected behavior

No error.

Versions (please complete the following information):

OS: [e.g., Windows 10, MacOS 10.15]: Ubuntu Latest
PHP: [e.g., 7.2, 7.4]: 8.0
PHPCS: [e.g., 3.5.5, master]: master
Standard: [e.g., PSR2, PSR12, Squiz]: none

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions