-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
False Positive: Squiz.Arrays.ArrayDeclaration.ValueNoNewline: The first value in a multi-value array must be on a new line #2937
Comments
Same bug here with similar code: $server = new Server([
static function (ServerRequestInterface $request, callable $next) {
return $next($request);
},
]); |
Also nested arrays are affected by this, I don't know if you want this in a separate issue? <?php
// 1)
$foo = [[1,
2,
3,
]];
// 2)
$foo = [[
1,
2,
3,
]];
// 3)
$foo = [[1 => 1,
2 => 2,
3 => 3,
]];
// 4)
$foo = [[
1 => 1,
2 => 2,
3 => 3,
]];
// 5)
$foo = [lorem(
1,
2,
3
)]; Cases 1) and 3) report errors as before I think this is consistent with 5) which was ok both before and now.
So this affects also |
[
12345,
[0],
(object) [
'type' => 'int',
],
], This is also a false positive, object is in the right place |
I left the false positives unfixed: squizlabs/PHP_CodeSniffer#2937 (comment) Signed-off-by: William Desportes <williamdes@wdes.fr>
Related #582. |
same with yield 'testActiveOnly' => [
static function () {
return ['inactive' => '2'];
},
]; |
Hi, I'm using phpcs version 3.5.8 and still have this problem.
Result:
But, if I try to use PHPCBF:
2 errors became -3... 🤔 |
I've just double-checked, but the original issue as reported by @bendavies and confirmed by @ondrejmirtes and @fezfez was fixed in PHPCS 3.5.7 per ticket #3060. The issue reported by @VasekPurchart is unrelated and is more about the interpretation of what the sniff expects and not necessarily a bug. The issue reported by @williamdes was fixed in PHPCS 3.5.7 per ticket #3059. The issue reported by @dianaarnos is unrelated and not reproducable with the given code sample on any PHPCS version between version 3.5.5 and current |
Given
if
static
is removed from the function, there is no violation.The text was updated successfully, but these errors were encountered: