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

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

Closed
iammattcoleman opened this issue Feb 9, 2018 · 5 comments
Milestone

Comments

@iammattcoleman
Copy link
Contributor

iammattcoleman commented Feb 9, 2018

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
@iammattcoleman iammattcoleman changed the title Ignoring Generic.Files.LineLength.TooLong on the last USE statement causes a false positive for PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse Comments on the last USE statement cause a false positive for PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse Feb 10, 2018
@gsherwood gsherwood added this to the 3.2.3 milestone Feb 11, 2018
@gsherwood gsherwood changed the title Comments on the last USE statement cause a false positive for PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse Comment on last USE statement causes false positive for PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse Feb 11, 2018
gsherwood added a commit that referenced this issue Feb 11, 2018
@iammattcoleman
Copy link
Contributor Author

@gsherwood Do you have an ETA for the 3.2.3 release?

@gsherwood
Copy link
Member

Do you have an ETA for the 3.2.3 release?

Should have been 3 weeks ago but I got very ill, so it's very late. Hopefully this week though.

@jrfnl
Copy link
Contributor

jrfnl commented Feb 12, 2018

@gsherwood Sorry to hear you were ill. Hope you're all better now.
FYI: AFAICS there are four more sniffs with pertinent problems with the new PHPCS annotations. I will try and get to these this week.

@gsherwood
Copy link
Member

FYI: AFAICS there are four more sniffs with pertinent problems with the new PHPCS annotations. I will try and get to these this week.

Thanks for letting me know, and thanks for all your help with those annotations.

@iammattcoleman
Copy link
Contributor Author

iammattcoleman commented Feb 13, 2018

@gsherwood Thanks for the estimate. Hope you're feeling better!

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

3 participants