Skip to content

Comment on last USE statement causes false positive for PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse #1891

Closed
@iammattcoleman

Description

@iammattcoleman

Overview

If the last USE statement has a comment, an incorrect PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse error is reported.

Steps to reproduce

Run phpcs --standard=PSR2 on a file with the following contents:

<?php
use Foo\Bar; //comment

// This should pass.

Expected output

None. This should validate correctly.

Actual output

FILE: /Users/matt/Projects/PHP_CodeSniffer/tests/TestCommentAfterLastUse.php
-------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------
 2 | ERROR | [x] There must be one blank line after the last USE statement; 0 found;
-------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------

Time: 114ms; Memory: 6Mb

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions