Closed
Description
Describe the bug
Minus -
used as negation of brackets result is okay in function
but not in fn
Code sample
This is reported
static fn(DateTime $a, DateTime $b): int => -($a->getTimestamp() <=> $b->getTimestamp())
This is not reported
static function (DateTime $a, DateTime $b): int {
return -($a->getTimestamp() <=> $b->getTimestamp());
}
Custom ruleset
<ruleset>
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
</ruleset>
To reproduce
- Create a file called
test.php
with the code sample above - Create a file called
ruleset.xml
with custom ruleset above - Run
phpcs test.php --standard=ruleset.xml
- See error message displayed
Expected 1 space after "-"; 0 found (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
Expected behavior
Code is not reported as invalid or at least have same behavior for both contexts (function
and fn
)