Skip to content

Generic MultipleStatementAlignment sniff reports incorrect errors for multiple assignments on a single line #564

@meijerm15

Description

@meijerm15

PHPCBF is currently aborting all changes to a file when encountering an unfix-able violation, like demonstrated below. Which is an A = B = C assignment.

This will cause it to not fix any violations anywhere else in this specific file, which makes it rather impossible to find this aborting violation in a huge class.

Could we get a line number/range of where this error/aborting violation is found or maybe if possible, this violation being fixed?

Example

<?php namespace test\test; class Test { public function foo() { $test = "test"; $foo = $moo = $test; } public function moo() { $test = "test"; $foo = $test; } }

PHPCS log

 9 | ERROR | [x] Equals sign not aligned with surrounding assignments; | | expected 7 spaces but found 1 space | | (Generic.Formatting.MultipleStatementAlignment.NotSame) 10 | ERROR | [x] Equals sign not aligned with surrounding assignments; | | expected 8 spaces but found 1 space | | (Generic.Formatting.MultipleStatementAlignment.NotSame) 16 | ERROR | [x] Equals sign not aligned with surrounding assignments; | | expected 2 spaces but found 1 space | | (Generic.Formatting.MultipleStatementAlignment.NotSame)

PHPCBF log

Processing Test.php [PHP => 85 tokens in 18 lines]... DONE in 4ms (3 fixable violations) => Fixing file: 2/3 violations remaining [made 50 passes]... ERROR in 505ms No fixable errors were found Time: 533ms; Memory: 5.75Mb

Version

PHP_CodeSniffer version 2.3.0 (stable) by Squiz (http://www.squiz.net)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions