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

Bug #13158 Strange behaviour in AbstractPatternSniff
Submitted: 2008-02-20 14:44 UTC
From: jotango Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.0.1)
PHP Version: Irrelevant OS:
Roadmaps: 1.1.0    
Subscription  


 [2008-02-20 14:44 UTC] jotango (Jan Miczaika)
Description: ------------ Hello, I wanted to modify the PEAR_Sniffs_ControlStructures_ControlSignatureSniff to match our coding guidelines. We like our braces to be on the next line, e.g. if (cond) { etc. When I run the pattern as is: 'if (...) {EOL', I get: Expected "if (...) {\n"; found "...) \n{\n" Which looks right. If I modify the pattern row to: 'if (...) EOL{EOL', I get: Expected "if (...) \n{\n"; found "...) \n\n" So the found result actually changes depending on the filter I gave it! Both patterns produce an error for my test pattern, which is quite simple (see above). Is this errant behaviour or am I doing something wrong?

Comments

 [2008-02-20 22:45 UTC] squiz (Greg Sherwood)
The error you are getting is due to the additional whitespace in the pattern. Instead of "if (...) EOL{EOL" use "if (...)EOL{EOL". The abstract pattern is confused because of the fact that the space and newline become one token in PHP.
 [2008-02-20 22:47 UTC] squiz (Greg Sherwood)
Still need to sort out that "found" pattern though.
 [2008-02-21 01:11 UTC] squiz (Greg Sherwood)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Found string now shows curly brace as expected.