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

Bug #19897 Indenting warnings in templates not consistent
Submitted: 2013-04-13 00:43 UTC
From: tchaffee Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.5)
PHP Version: 5.3.10 OS: Linux
Roadmaps: (Not assigned)    

 [2013-04-13 00:43 UTC] tchaffee (Todd Chaffee)
Description: ------------ For most constructs in a template file (HTML with PHP) the indenting warnings are generated, but for 'echo' there is no warning. Test script: --------------- This won't generate an indenting warning: <div> <div> <?php echo myfunc( somelongparams, another param, ); ?> <div> <div> But this will: <div> <div> <?php for ($i = 0; $i < 3; $i++) { echo 'something ' . $i; ); ?> <div> <div> Expected result: ---------------- No warning for either construct. Would like the indenting to take into consideration that the <?php opening is indented itself. It seems to work when using 'echo' but not for other statements. Actual result: -------------- For the 'for' statement: ## | ERROR | Line indented incorrectly; expected 0 spaces, found 8


 [2013-04-15 04:10 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz
I don't get any errors or warnings for any of the sample code you provided. The way the indentation sniffs works is that the first time an indenting scope is found, it sets that as the start column. Any code inside there must be indented at least COLUMN + INDENT spaces. So in the case of your sample code, the first structure is the FOR and so it can't produce any errors itself because it isn't sitting inside anything else. Is there actually more to you file than this sample code? Does the FOR exist inside another indenting scope? Can you provide a file that I am able to test on (or even just part of a file that will produce the error)?
 [2013-04-15 15:32 UTC] tchaffee (Todd Chaffee)
Sorry, I should have tested that code. Try this and it should repo the problem. Couldn't find a way to upload the file, so here it is: <div> <div> <?php echo myfunc( $somelongparams, $anotherparam, ); ?> <div> <div> <div> <div> <?php if ($myvar == 'test') { echo 'something'; } ?> <div> <div>
 [2013-04-17 10:48 UTC] squiz (Greg Sherwood)
That's perfect, thanks. I understand the problem now.
 [2013-06-25 06:25 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Open
 [2013-06-25 07:14 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
Fix committed to github repo: 4cfd507d6ec925