Closed simPod closed 3 years ago
This should be fixed by https://github.com/squizlabs/PHP_CodeSniffer/pull/3061.
Tried with dev-master but the issue seems to still exist.
Tried with master and can confirm there error no longer appears.
Test file:
$ cat temp.php
<?php
$a = [
static function (): void {
},
];
PHPCS 3.5.6:
$ phpcs --version
PHP_CodeSniffer version 3.5.6 (stable) by Squiz (http://www.squiz.net)
$ phpcs temp.php --standard=Squiz
FILE: /Users/gsherwood/Projects/PHP_CodeSniffer/temp.php
------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------
1 | ERROR | [ ] Missing file doc comment
3 | ERROR | [x] The first value in a multi-value array must be on a new line
4 | ERROR | [x] Expected 1 blank line before closing function brace; 0 found
------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------
Time: 61ms; Memory: 8MB
Master branch:
$ php bin/phpcs --version
PHP_CodeSniffer version 3.5.7 (stable) by Squiz (http://www.squiz.net)
$ php bin/phpcs temp.php --standard=Squiz
FILE: /Users/gsherwood/Projects/PHP_CodeSniffer/temp.php
------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------
1 | ERROR | [ ] Missing file doc comment
4 | ERROR | [x] Expected 1 blank line before closing function brace; 0 found
------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------
Time: 142ms; Memory: 8MB
@simPod What are you seeing?
I see, just checked. Try this:
yield [
static fn () : string => '',
];
yield [
static function () : string {
return '';
},
];
arrow function fails
@simPod I've pushed an additional fix for the arrow function support. Are you able to try again?
Wrks, thanks a lot!
Describe the bug Can't satisfy sniff when callable is within multiline array
Code sample
The value is on a new line.
This can't be done either because of Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore
Versions (please complete the following information):