Open simPod opened 3 months ago
Confirmed. Thanks for reporting this @simPod.
This looks like a similar issue to #368 which was fixed by #369 and #379, which were included in the 3.9.1
release.
I've checked and the fixes in the 3.9.1
release are not directly related to this issue. This issue can be reproduced both with PHPCS 3.9.0
as well as master
.
The Squiz.Arrays.ArrayDeclaration
sniff is known to be problematic and has been for years.
The problem is largely that as soon as something is excluded from that sniff, the sniff is broken. This is a design flaw in the sniff.
I've been building up a (highly configurable) NormalizedArrays
standard in PHPCSExtra to replace it, but that's not complete yet. Would be lovely if I could find some time to finish that at some point.
With that in mind, I will not be working on this issue. If someone would submit a PR with a small/simple fix for this issue, I will accept it, but other than that, this sniff is out of bounds for large fixes/rewrites as it is just not worth the time.
Seems also related to this issue?
<?php declare(strict_types = 1);
class Bug {
public static function bug(): mixed {
return [
'paginator' => [
new class() {
public function toArray(): mixed {
return [];
}
},
],
];
}
}
9 | ERROR | [x] The first value in a multi-value array must be on a new line
9 | ERROR | [x] Each value in a multi-line array must be on a new line
@LastDragon-ru To be honest, that looks like a completely different issue to me.
Describe the bug
Squiz.Arrays.ArrayDeclaration.ValueNoNewline
triggers false positive atstatic fn
.Code sample
To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above...phpcs test.php ...
Expected behavior
No error
Versions (please complete the following information)
Additional context
Add any other context about the problem here.
Please confirm
master
branch of PHP_CodeSniffer.