Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Bug #18193 CodeSniffer doesn't reconize CR (\r) line endings
Submitted: 2011-01-13 18:25 UTC
From: konafets Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.0RC1)
PHP Version: 5.3.5 OS: OSX 10.6
Roadmaps: (Not assigned)    
Subscription  


 [2011-01-13 18:25 UTC] konafets (Stefano Kowalke)
Description: ------------ If the line endings of your file are set to CR (MacOS Classic) the content of the T_WHITESPACE token, where the line break should be, is empty. So phpcs interprets the whole file as one line, because it can't detect the line endings. As result it calculates the properties of the tokens (line, column) wrong

Comments

 [2011-01-13 18:31 UTC] konafets (Stefano Kowalke)
How to test: * Create a file with CR line endings * Put some code inside * save the file * check the file through a sniff and let output some token infos with "print_r($tokens[$stackPtr]);"
 [2011-01-13 23:23 UTC] konafets (Stefano Kowalke)
You can download a test file at http://forge.typo3.org/issues/11598. Search for "class.tx_t3jquery.php".
 [2011-01-14 06:43 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Appears to be caused by PHP not detecting line endings correctly, so fgets does not return the first line properly, stopping PHPCS from detecting the EOL char. You can fix this by setting you auto_detect_line_endings ini var to TRUE, or you can grab the latest PHPCS SVN code where I have enabled this by default during PHPCS runs.