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

Bug #19374 HEREDOC/NOWDOC Indentation problems
Submitted: 2012-04-05 23:04 UTC
From: echosa Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.3)
PHP Version: 5.3.8 OS: Mac OS X 10.7.3
Roadmaps: (Not assigned)    
Subscription  


 [2012-04-05 23:04 UTC] echosa (Brian Zwahr)
Description: ------------ HEREDOC/NOWDOC strings are incorrectly reported as having no indentation and needing to be indented 4 spaces. This includes the the opening tag (if on its own line) and the closing tag (which should never be indented). Specifically, this is happening to me when using a NOWDOC as a protected class property array default value. Test script: --------------- <?php class Whatever { protected $_protectedArray = array( 'normalString' => 'That email address is already in use!', 'offendingString' => <<<'STRING' Each line of this string is always said to be at column 0, no matter how many spaces are placed at the beginning of each line and the ending STRING on the next line is reported as having to be indented. STRING ); } Expected result: ---------------- I would expect the script to pass cleanly, with the exception of the missing file and class doc comments. Actual result: -------------- test.php|2 col 1 error| Missing file doc comment test.php|2 col 1 error| Missing class doc comment test.php|7 col 1 error| Line indented incorrectly; expected at least 4 spaces, found 0 test.php|8 col 1 error| Line indented incorrectly; expected at least 4 spaces, found 0 test.php|9 col 1 error| Line indented incorrectly; expected at least 4 spaces, found 0 test.php|10 col 1 error| Line indented incorrectly; expected at least 4 spaces, found 0 test.php|11 col 1 error| Line indented incorrectly; expected at least 4 spaces, found 0

Comments

 [2012-04-11 10:01 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
The sniff reporting this issue already skipped heredocs, but didn't get nowdoc support. I've added that now and it should fix this issue. Commit is here: https://github.com/squizlabs/PHP_CodeSniffer/commit/f19c5365800772d4ebcdb175c 6c6ac5852e5d870