Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSR12.Files.FileHeader.SpacingAfterBlock: false positive when use is used for class and function #3935

Closed
3 tasks done
VladyslavSikailo opened this issue Dec 6, 2023 · 1 comment

Comments

@VladyslavSikailo
Copy link

Describe the bug

PSR12.Files.FileHeader.SpacingAfterBlock check is false positive when use is used for class and function.

Code sample

<?php

namespace Foo;

use Countable;
use function str_replace;

class Test
{
}

To reproduce

Steps to reproduce the behavior:

  1. Create a file called Test.php with the code sample above
  2. Run phpcs -s --standard=PSR12 --no-cache Test.php
  3. See the error message displayed
-------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------
 5 | ERROR | [x] Header blocks must be separated by a single blank line
   |       |     (PSR12.Files.FileHeader.SpacingAfterBlock)
-------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------

Expected behavior

Checking should be passed

Versions (please complete the following information)

Operating System MacOS 14.0
PHP version 8.2.6
PHP_CodeSniffer version master
Standard PSR12
Install type Composer (local)

Please confirm:

  • I have searched the issue list and am not opening a duplicate issue.
  • I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
  • I have verified the issue still exists in the master branch of PHP_CodeSniffer.
@jrfnl
Copy link
Contributor

jrfnl commented Dec 6, 2023

@VladyslavSikailo Not a false positive. PSR12 demands a blank line between different type of use statements, so there should be a blank line between the last class use statement and the first function use statement.

P.S.: for the future, please open new issues in https://github.com/PHPCSStandards/PHP_CodeSniffer - also see #3932

@jrfnl jrfnl closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants