FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=19928&edit=1

ID: 19928
Updated by: boonedox@gmail.com
Reported By: boonedox@gmail.com
-Summary: bug in newline stana
+Summary: bug in newline standard
Status: Open
Type: Bug
Package: PHP_CodeSniffer
Operating System: Gentoo
Package Version: 1.4.5
PHP Version: 5.4.6
Roadmap Versions:
New Comment:

-Summary: bug in newline stana
+Summary: bug in newline standard



Previous Comments:
------------------------------------------------------------------------

[2013-05-02 00:03:36] boonedox

Description:
------------
PSR2_Sniffs_Files_EndFileNewlineSniff::process is incorrectly
checking blank lines at the end of the file. It is reporting an
error
when $blankLines > 0, which is incorrect, because $blankLines
should be 1. This is also a check that is done by
PSR2_Sniffs_Files_EndFileWhitespaceSniff. I believe the
blankLines check is supposed to be in
PSR2_Sniffs_Files_EndFileWhitespaceSniff while
PSR2_Sniffs_Files_EndFileNewlineSniff should just be checking
that the file ends w/ a
unix line ending.

old code in PSR2_Sniffs_Files_EndFileNewlineSniff::process
if ($blankLines === 0) {
$error = 'Expected 1 blank line at end of file; 0
found';
$data = array($blankLines);
$phpcsFile->addError($error, $stackPtr, 'NotFound',
$data);
} else if ($blankLines > 1) {
$error = 'Expected 1 blank line at end of file; "%s"
found';
$data = array($blankLines);
$phpcsFile->addError($error, $stackPtr, 'TooMany',
$data);
}

new code in 1.4.5 for
PSR2_Sniffs_Files_EndFileNewlineSniff::process
if ($blankLines > 0) {
$error = 'Expected 1 blank line at end of file; %s
found';
$data = array($blankLines + 1);
$phpcsFile->addError($error, $stackPtr, 'TooMany',
$data);
}


Test script:
---------------
phpcs --standard=PSR2 world.php

Expected result:
----------------
Time: 0 seconds, Memory: 4.75Mb

Actual result:
--------------
FILE: /world.php
------------------------------------------------------------------------
--------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
------------------------------------------------------------------------
--------
11 | ERROR | Expected 1 blank line at end of file; 2 found
------------------------------------------------------------------------
--------

Time: 0 seconds, Memory: 4.75Mb

------------------------------------------------------------------------

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
grouppear-bugs @
categoriesphp
postedMay 1, '13 at 10:03p
activeMay 1, '13 at 10:48p
posts2
users2
websitepear.php.net

2 users in discussion

Boonedox: 1 post Gsherwood: 1 post

People

Translate

site design / logo © 2022 Grokbase