I have run into occasions where Generic.Files.EndFileNewline or PSR2.Files.EndFileNewline will throw an error on a file that does end with a new line.
Fixing the files with phpcbf will add another new line and will still error when checked again. this is what a post fixer error looks like
13 | ERROR | [x] File must end with a newline character (Generic.Files.EndFileNewline.NotFound)
13 | ERROR | [x] Additional blank lines found at end of doc comment (Generic.Commenting.DocComment.SpacingAfter)
Example files that have such an issue are included (one PHP, one CSS).
If there is an empty new line at the end of the file there should be no PSR2.Files.EndFileNewline.NoneFound or Generic.Files.EndFileNewline.NoneFound error Expected 1 newline at end of file; 0 found regardless of the code that is before that last newline in the file.
This is because the last token is a doc comment, and is tokenized as T_DOC_COMMENT_WHITESPACE. Should hopefully be an easy fix.
Note that your second file doesn't produce any errors.
I should note that the first file is a snippet from a larger file that would error out. https://raw.githubusercontent.com/Kunena/Kunena-Forum/K5.1/src/libraries/kunena/bbcode/bbcode.php
As for the second file, it was erroring on 2.6.0 so maybe it's no longer an issue in 2.7.0.
Just confirming this is fixed now. Had a few unit test problems given the comment was not closed. Especially with HHVM, which just removed that entire comment from the file content while parsing.
Forgot to say: thanks for the bug report :)
You are welcome, Thank you.
Most helpful comment
Just confirming this is fixed now. Had a few unit test problems given the comment was not closed. Especially with HHVM, which just removed that entire comment from the file content while parsing.