Open
Description
Describe the bug
Generic.Formatting.MultipleStatementAlignment
doesn't work correctly with match()
.
Code sample
<?php declare(strict_types = 1);
namespace Bug;
class A {
public function bug(bool $b): void {
$a = match ($b) {
true => 1,
default => false,
};
$var = 123;
echo $a.$var;
}
}
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:
- Create a file called
test.php
with the code sample above... - Run
phpcs test.php ...
- See error message displayed
------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------
7 | WARNING | [x] Equals sign not aligned correctly; expected 1 space but found 3 spaces
------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------
Expected behavior
No error.
Versions (please complete the following information)
Operating System | Win 10 |
PHP version | 8.2 |
PHP_CodeSniffer version | 3.7.2 |
Standard | custom |
Install type | Composer (global/local) |
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.