You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a series of 4 assignment statements. The first 3 statements are assigned using the null coalesce assignment (??=), while the 4th statement is assigned using normal assignment (=). When checking the file with wpcs, it generates a warning message. I believe this warning is not correct.
The "maybe" part of this issue is that I might have the wrong idea of what should be correct here.
<?xml version="1.0"?>
<rulesetname="My Custom Standard">
<description>If you are using a custom ruleset, please enter it here.</description>
<ruleref="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
FILE: /path/to/test.php
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
6 | WARNING | [x] Equals sign not aligned with surrounding assignments; expected 5 spaces but found 3 spaces (Generic.Formatting.MultipleStatementAlignment.NotSameWarning)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expected behavior
I expected that this series of statements should not trigger a warning.
Versions (please complete the following information)
Operating System
MacOS 14.3.1
PHP version
8.1
PHP_CodeSniffer version
3.7.2
Standard
custom
Install type
Composer 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.
The text was updated successfully, but these errors were encountered:
@fredden@jrfnl Thanks for the responses. I hadn't personally encountered this situation before so I wasn't sure that it was correct. Good to know it's working as intended.
Describe the bug
I have a series of 4 assignment statements. The first 3 statements are assigned using the null coalesce assignment (
??=
), while the 4th statement is assigned using normal assignment (=
). When checking the file with wpcs, it generates a warning message. I believe this warning is not correct.The "maybe" part of this issue is that I might have the wrong idea of what should be correct here.
Code sample
Custom ruleset
To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above...phpcs test.php ...
Expected behavior
I expected that this series of statements should not trigger a warning.
Versions (please complete the following information)
3.7.2
Please confirm:
master
branch of PHP_CodeSniffer.The text was updated successfully, but these errors were encountered: