-
-
Notifications
You must be signed in to change notification settings - Fork 192
Closed
Labels
Description
When updating some of doctrines repositories with the new coding-standard I ran into the following issue:
<?php
public static function test()
{
return static function () : int {
$a = 1;
$b = 2;
return $a*$b;
};
}
Results in:
vendor/bin/phpcs -v test.php
Registering sniffs in the standard... DONE (143 sniffs registered)
Creating file list... DONE (1 files in queue)
Loading cache... DONE (1 files in cache)
Changing into directory .
Processing test.php [PHP => 61 tokens in 11 lines]... DONE in 24ms (1 errors, 0 warnings)
FILE: test.php
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
5 | ERROR | [x] Expected 1 lines after "return", found 0.
| | (SlevomatCodingStandard.ControlStructures.ControlStructureSpacing.IncorrectLinesCountAfterControlStructure)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Applying the automated fixes would result in:
<?php
public static function test()
{
return static function () : int {
$a = 1;
$b = 2;
return $a*$b;
};
}
Example in the doctrine project
https://github.com/doctrine/collections/pull/178/files#r266245125
To me it seems, this sniff is having a false positive in this scenario
Reactions are currently unavailable