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

Bug #18933 Alternative namespace declaration syntax confuses scope sniffs
Submitted: 2011-10-26 14:17 UTC
From: sebastian Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.0)
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2011-10-26 14:17 UTC] sebastian (Sebastian Bergmann)
Description: ------------ When using the alternative namespace declaration syntax, PHP_CodeSniffer wrongly complains about the indentation of switch/case statements. The expected and actual output shown below were generated with PHP_CodeSniffer 1.3.0 + http://svn.php.net/viewvc/pear/packages/PHP_CodeSniffer/trunk/CodeSniffer/Tokenizers/PHP.php?r1=307870&r2=310221 This is not a duplicate of http://pear.php.net/bugs/18930 or pear.php.net/bugs/bug.php?id=18043. Test script: --------------- <?php namespace A { class B { function c() { switch (true) { case true: ; break; } } } } Expected result: ---------------- FILE: /home/sb/test.php -------------------------------------------------------------------------------- FOUND 5 ERROR(S) AFFECTING 5 LINE(S) -------------------------------------------------------------------------------- 2 | ERROR | Missing file doc comment (PEAR.Commenting.FileComment.Missing) 4 | ERROR | Missing class doc comment (PEAR.Commenting.ClassComment.Missing) 6 | ERROR | Missing function doc comment | | (PEAR.Commenting.FunctionComment.Missing) -------------------------------------------------------------------------------- Actual result: -------------- FILE: /home/sb/test.php -------------------------------------------------------------------------------- FOUND 5 ERROR(S) AFFECTING 5 LINE(S) -------------------------------------------------------------------------------- 2 | ERROR | Missing file doc comment (PEAR.Commenting.FileComment.Missing) 4 | ERROR | Missing class doc comment (PEAR.Commenting.ClassComment.Missing) 5 | ERROR | Expected 0 spaces before opening brace; 4 found | | (PEAR.Classes.ClassDeclaration.SpaceBeforeBrace) 6 | ERROR | Missing function doc comment | | (PEAR.Commenting.FunctionComment.Missing) 9 | ERROR | Line indented incorrectly; expected 12 spaces, found 16 | | (PEAR.WhiteSpace.ScopeIndent.Incorrect) --------------------------------------------------------------------------------

Comments

 [2011-11-02 03:39 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fixed in SVN, although there was only one error and not two. That ScopeIndent one at the end is correct because the PEAR standard says that CASE statements should not be indented 4 spaces from the SWITCH. They are supposed to align. The ClassDeclaration one was a bug though. It didn't support class definitions inside a namespace.