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

Bug #16641 Notice output
Submitted: 2009-09-24 20:34 UTC
From: jsf_imento Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.2.0)
PHP Version: 5.3.0 OS: OSX
Roadmaps: (Not assigned)    
Subscription  


 [2009-09-24 20:34 UTC] jsf_imento (Johannes Frandsen)
Description: ------------ When running phpcs on a standard osx macports php/pear installation I get a Notice error in my output. I fixed it by adding to lines, but maybe its a deeper problem. public function addWarning($warning, $stackPtr) { // Work out which sniff generated the warning. $parts = explode('_', $this->_activeListener); isset($parts[2]) ? $parts[2] : $parts[2] = ''; //Added by jsf_imento isset($parts[3]) ? $parts[3] : $parts[3] = ''; //Added by jsf_imento $sniff = $parts[0].'.'.$parts[2].'.'.$parts[3]; Test script: --------------- phpcs --report=checkstyle --standard=PEAR --extensions=php ./ Actual result: -------------- Notice: Undefined offset: 2 in /opt/local/lib/php/PHP/CodeSniffer/File.php on line 629 Stack trace: 1. {main}() /opt/local/bin/phpcs:0 2. PHP_CodeSniffer_CLI->process() /opt/local/bin/phpcs:30 3. PHP_CodeSniffer->process() /opt/local/lib/php/PHP/CodeSniffer/CLI.php:389 4. PHP_CodeSniffer->processFiles() /opt/local/lib/php/PHP/CodeSniffer.php:341 5. PHP_CodeSniffer->processFile() /opt/local/lib/php/PHP/CodeSniffer.php:690 6. PHP_CodeSniffer_File->start() /opt/local/lib/php/PHP/CodeSniffer.php:762 7. PHP_CodeSniffer_File->addWarning() /opt/local/lib/php/PHP/CodeSniffer/File.php:449 Notice: Undefined offset: 3 in /opt/local/lib/php/PHP/CodeSniffer/File.php on line 629 Stack trace: 1. {main}() /opt/local/bin/phpcs:0 2. PHP_CodeSniffer_CLI->process() /opt/local/bin/phpcs:30 3. PHP_CodeSniffer->process() /opt/local/lib/php/PHP/CodeSniffer/CLI.php:389 4. PHP_CodeSniffer->processFiles() /opt/local/lib/php/PHP/CodeSniffer.php:341 5. PHP_CodeSniffer->processFile() /opt/local/lib/php/PHP/CodeSniffer.php:690 6. PHP_CodeSniffer_File->start() /opt/local/lib/php/PHP/CodeSniffer.php:762 7. PHP_CodeSniffer_File->addWarning() /opt/local/lib/php/PHP/CodeSniffer/File.php:449

Comments

 [2009-09-28 10:46 UTC] squiz (Greg Sherwood)
-Assigned To: +Assigned To: squiz
Are you able to tell me what the value of $this->_activeListener was when you got this problem? All PEAR sniffs should be named correctly and not have any problems.
 [2009-09-28 10:46 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Feedback
 [2009-09-30 16:26 UTC] jsf_imento (Johannes Frandsen)
Adding this code in addWarning() in File.php: if(!isset($parts[2])){ echo '$this->_activeListener = '.$this->_activeListener; } result in this outout: $this->_activeListener =
 [2009-09-30 17:10 UTC] squiz (Greg Sherwood)
Well that is pretty strange. Any chance you can share the code that you are checking? It sounds like there is more of a core problem checking it and suppressing the NOTICE might just be hiding another problem.
 [2009-09-30 17:48 UTC] jsf_imento (Johannes Frandsen)
Well its occurs as part of my CI build so a lot of code goes through, but Ill see if I can dig out the offending code..... it may take a few days thou.
 [2009-10-07 18:25 UTC] kukulich (Jaroslav HanslĂ­k)
It's strange that function addError contains a little different piece of code. public function addError($error, $stackPtr) { // Work out which sniff generated the error. $parts = explode('_', $this->_activeListener); if (isset($parts[3]) === true) { $sniff = $parts[0].'.'.$parts[2].'.'.$parts[3]; } else { $sniff = 'unknownSniff'; } ... } public function addWarning($warning, $stackPtr) { // Work out which sniff generated the warning. $parts = explode('_', $this->_activeListener); $sniff = $parts[0].'.'.$parts[2].'.'.$parts[3]; ... }
 [2009-10-12 04:06 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Closed
This bug has been fixed in SVN. 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. I've added the same error checking code from addError into addWarning so you shouldn't get the error any more. If you do happen to find the code causing the problem, I'd love to see it if possible because something is obviously not working 100% somewhere.
 [2009-10-30 00:43 UTC] ashnazg (Chuck Burgess)
Greg, Today I noticed the notices when running phpcs 1.2.0 against some PHP4 code that uses short tags. When I run phpcs while php.ini is *not* allowing short tags, I get the notices from that File.php file... when I enable short tags, no notices. Hope that helps... CRB