Skip to content
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

Squiz.Arrays.ArrayDeclaration false positive for static functions #3060

Closed
morozov opened this issue Aug 29, 2020 · 0 comments · Fixed by #3061
Closed

Squiz.Arrays.ArrayDeclaration false positive for static functions #3060

morozov opened this issue Aug 29, 2020 · 0 comments · Fixed by #3061
Milestone

Comments

@morozov
Copy link
Contributor

morozov commented Aug 29, 2020

Describe the bug
A false-positive rule violation is detected that prevents auto-fixing.

Code sample

<?php

function test()
{
    yield [
        static function (): void {
        },
    ];
}

Custom ruleset
None.

To reproduce
Steps to reproduce the behavior:

  1. Run phpcs -s --standard=Squiz --sniffs=Squiz.Arrays.ArrayDeclaration,Squiz.WhiteSpace.ScopeKeywordSpacing test.php
FILE: /home/morozov/Projects/phpcs-playground/test.php
------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------
 6 | ERROR | [x] The first value in a multi-value array must be on a new line
   |       |     (Squiz.Arrays.ArrayDeclaration.ValueNoNewline)
------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------

Time: 44ms; Memory: 8MB
  1. Run phpcbf --standard=Squiz --sniffs=Squiz.Arrays.ArrayDeclaration,Squiz.WhiteSpace.ScopeKeywordSpacing test.php
PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
/home/morozov/Projects/phpcs-playground/test.php      FAILED TO FIX
----------------------------------------------------------------------
A TOTAL OF 0 ERRORS WERE FIXED IN 1 FILE
----------------------------------------------------------------------
PHPCBF FAILED TO FIX 1 FILE
----------------------------------------------------------------------

Time: 95ms; Memory: 8MB

Expected behavior
No error is reported.

Versions (please complete the following information):

  • OS: Linux
  • PHP: 7.4.9
  • PHPCS: 3.5.6
  • Standard: Squiz
@gsherwood gsherwood added this to the 3.5.7 milestone Sep 21, 2020
@gsherwood gsherwood changed the title Squiz.Arrays.ArrayDeclaration false positive Squiz.Arrays.ArrayDeclaration false positive for static functions Sep 21, 2020
gsherwood added a commit that referenced this issue Sep 24, 2020
Sniff wasn't ignore static arrow functions, or fixing the indent correctly when it actually was incorrect
gsherwood added a commit that referenced this issue Sep 24, 2020
Sniff wasn't ignore static arrow functions, or fixing the indent correctly when it actually was incorrect
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants