squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.66k stars 1.48k forks source link

False Positive: Squiz.Arrays.ArrayDeclaration.ValueNoNewline #3952

Closed simPod closed 3 months ago

simPod commented 3 months ago

Describe the bug

Squiz.Arrays.ArrayDeclaration.ValueNoNewline gives false positives

Code sample

$x = [
    static fn (  // false positive here
        A $a,
    ) => B::create(
        $a,
    ),
    false,
];

$y = [
    ...[ // false positive here
        new A(),
    ],
];

To reproduce

Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcs test.php ...
  3. See error message displayed
    PHPCS output here

Expected behavior

No rrror

Versions (please complete the following information)

Operating System [MacOS]
PHP version [8.3]
PHP_CodeSniffer version [3.7.2]
Standard [Squiz]
Install type [composer local]

Please confirm:

jrfnl commented 3 months ago

Please don't open issues in this repo anymore. This repo is abandoned and https://github.com/PHPCSStandards/PHP_CodeSniffer is its successor. See: #3932

Also, please start by updating your PHPCS install to the latest release (3.10.1) and only report in the new repo if the issue still exists.

simPod commented 3 months ago

Ah sorry, got confused