-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Describe the bug
The sniff doesn't recognize unary minus applied to a number used with theexit language construct.
Code sample
<?php
function test()
{
exit -1;
}Custom ruleset
None.
To reproduce
Steps to reproduce the behavior:
- Run
phpcs -s --standard=PSR12 --sniffs=PSR12.Operators.OperatorSpacing test.php
FILE: /home/morozov/Projects/phpcs-playground/test.php
------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------
5 | ERROR | [x] Expected at least 1 space after "-"; 0 found
| | (PSR12.Operators.OperatorSpacing.NoSpaceAfter)
------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------
Time: 33ms; Memory: 6MB
- Run
phpcbf --standard=PSR12 --sniffs=PSR12.Operators.OperatorSpacing test.php
PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE FIXED REMAINING
----------------------------------------------------------------------
/home/morozov/Projects/phpcs-playground/test.php 1 0
----------------------------------------------------------------------
A TOTAL OF 1 ERROR WERE FIXED IN 1 FILE
----------------------------------------------------------------------
Time: 37ms; Memory: 6MB
The resulting file contents are:
<?php
function test()
{
exit - 1;
}Expected behavior
No error is reported.
Versions (please complete the following information):
- OS: Linux
- PHP: 7.4.9
- PHPCS: 3.5.6
- Standard: PSR-12
Reactions are currently unavailable