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 false positive when file only contains docblock #2616

Closed
dereuromark opened this issue Sep 27, 2019 · 6 comments
Closed
Milestone

Comments

@dereuromark
Copy link
Contributor

FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------
 5 | ERROR | [x] Header blocks must be followed by a single blank line

is unfixable.
It doesn't respect a file that only contains a docblock.

code is:

<?php

/**
 * Here go your local configs
 */
@morrisonlevi
Copy link

morrisonlevi commented Sep 27, 2019

I think Datadog/dd-trace-php is hitting this same issue for a different reason in branch levi/phpcs:

circleci@82b8c67c4988:~/app$ composer lint
> phpcs -s --ignore=src/DDTrace/Integrations/ZendFramework/V1/Ddtrace.php

FILE: /home/circleci/app/tests/Unit/Util/TryCatchFinallyTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 226 | ERROR | [x] Header blocks must be followed by a single blank
     |       |     line
     |       |     (PSR12.Files.FileHeader.SpacingAfterBlock)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 39.58 secs; Memory: 20.25MB

Script phpcs -s --ignore=src/DDTrace/Integrations/ZendFramework/V1/Ddtrace.php handling the lint event returned with error code 2
circleci@82b8c67c4988:~/app$ composer fix-lint
> phpcbf

PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
...cleci/app/tests/Unit/Util/TryCatchFinallyTest.php  FAILED TO FIX
----------------------------------------------------------------------
A TOTAL OF 0 ERRORS WERE FIXED IN 1 FILE
----------------------------------------------------------------------
PHPCBF FAILED TO FIX 1 FILE
----------------------------------------------------------------------

Time: 37.31 secs; Memory: 20.25MB


Script phpcbf handling the fix-lint event returned with error code 2

I've since disabled the lint, so be sure to use the link as it points to a specific commit.

morrisonlevi added a commit to DataDog/dd-trace-php that referenced this issue Sep 27, 2019
morrisonlevi added a commit to DataDog/dd-trace-php that referenced this issue Sep 27, 2019
morrisonlevi added a commit to DataDog/dd-trace-php that referenced this issue Sep 27, 2019
@gsherwood gsherwood added this to the 3.5.1 milestone Sep 30, 2019
@gsherwood gsherwood changed the title Bug in PSR12.Files.FileHeader.SpacingAfterBlock PSR12.Files.FileHeader false positive when file only contains docblock Oct 3, 2019
gsherwood added a commit that referenced this issue Oct 3, 2019
@gsherwood
Copy link
Member

Thanks for the report. I've committed a fix, which will be in 3.5.1.

@hopeseekr
Copy link

It''s bugging out all of my repos...

We've been doing <?php declare(strict_types=1); for years and years. It's by far the best place for it.

@guvra
Copy link

guvra commented Nov 5, 2019

Hi,

Is there an explanation on why it's impossible to do the following?

<?php
declare(strict_types=1);

The blank line is a waste of space imo.

@dereuromark
Copy link
Contributor Author

The already added newline is a big waste of space :)
There is no good reasoning here IMO - just a decision made by them that you can chose to ignore.

@gsherwood
Copy link
Member

Is there an explanation on why it's impossible to do the following?

Those sort of questions are better directed to the authors of PSR-12. I had nothing to do with the writing of the standard so I can't talk to the decisions within it. I've just implemented it in PHPCS as faithfully as I can.

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

5 participants