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

Bug #14409 Output of warnings to log file
Submitted: 2008-07-27 10:06 UTC
From: mikebevz Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.1.0)
PHP Version: 5.2.6 OS: Windows/Linux
Roadmaps: (Not assigned)    
Subscription  


 [2008-07-27 10:06 UTC] mikebevz (Mike Bevz)
Description: ------------ In version after 1.0.1 in beginning of log file warning messages appears: Warning: substr_count(): Empty substring in /usr/share/php/PHP/CodeSniffer/File.php on line 673 Call Stack: 0.0003 55736 1. {main}() /usr/bin/phpcs:0 0.0168 1017600 2. PHP_CodeSniffer_CLI->process() /usr/bin/phpcs:30 0.0175 1021860 3. PHP_CodeSniffer->process() /usr/share/php/PHP/CodeSniffer/CLI.php:334 0.0528 2439104 4. PHP_CodeSniffer->processFiles() /usr/share/php/PHP/CodeSniffer.php:289 32.0010 15846420 5. PHP_CodeSniffer->processFile() /usr/share/php/PHP/CodeSniffer.php:566 32.0070 15918392 6. PHP_CodeSniffer_File->start() /usr/share/php/PHP/CodeSniffer.php:624 32.0070 15918392 7. PHP_CodeSniffer_File->_parse() /usr/share/php/PHP/CodeSniffer/File.php:343 32.0072 15919436 8. PHP_CodeSniffer_File::tokenizeString() /usr/share/php/PHP/CodeSniffer/File.php:432 32.0076 15923448 9. PHP_CodeSniffer_File::_createLineMap() /usr/share/php/PHP/CodeSniffer/File.php:636 32.0076 15923916 10. substr_count() /usr/share/php/PHP/CodeSniffer/File.php:673 Version 1.0.1 works correctly.

Comments

 [2008-07-27 11:27 UTC] squiz (Greg Sherwood)
Any chance you can provide the code that you were running phpcs on at the time? This error would be caused by a specific piece of code, so I really need it to be able to debug it.
 [2008-07-27 11:32 UTC] mikebevz (Mike Bevz)
We run CS on every build with ANT. Here is the ant task: <target name="php-codesniffer"> <exec executable="phpcs" dir="${basedir}" output="${basedir}/build/logs/checkstyle.xml" error="/tmp/checkstyle.error.log"> <arg line="--report=checkstyle --ignore=*/library/* --standard=PEAR ${basedir}/source/Tourstart"/> </exec> </target> We've got PHP 5.2.6 and latest PEAR. Here are installed PEAR packages if you need: Archive_Tar 1.3.2 stable Auth_SASL 1.0.2 stable Benchmark 1.2.7 stable Console_Getopt 1.2.3 stable DB 1.7.14RC1 beta Date 1.4.7 stable File 1.3.0 stable File_Find 1.3.0 stable HTML_AJAX 0.5.6 beta Image_GraphViz 1.3.0RC3 beta Log 1.11.0 stable MDB2 2.5.0b1 beta Mail 1.2.0b1 beta Net_GeoIP 1.0.0RC1 beta Net_SMTP 1.3.1 stable Net_Socket 1.0.9 stable PEAR 1.7.2 stable PHP_CodeSniffer 1.1.0 stable PhpDocumentor 1.4.2 stable SCA_SDO 1.2.4 stable Structures_Graph 1.0.2 stable Testing_Selenium 0.4.3 beta XML_Beautifier 1.1 stable XML_Parser 1.2.8 stable XML_RPC 1.5.1 stable XML_Util 1.2.0 stable bcompiler 0.8 beta blenc 1.0alpha alpha json 1.2.1 stable
 [2008-07-27 11:46 UTC] squiz (Greg Sherwood)
Sorry, I meant the code in the file that causes the error. Are you able to
 [2008-07-27 11:50 UTC] squiz (Greg Sherwood)
Sorry, I meant the code in the file that causes the error. I am not able to reproduce this error on my tests files so I will need the code that is causing you a problem to be able to fix this. The error cannot simply be suppressed because it points t an error during tokenizing so it is probably causing other errors or stopping errors from being reported correctly. Can you run phpcs directly on the file and use the -v option. This will print the file being processed and will let you determine which file is causing the problem (the error will be shown directly after the file's name is printed). You can then run phpcs directly on the file to confirm. If you can provide me with the content of that file I can fix the issue. If you can't (commercial in confidence maybe) then at least I can provide you with some more steps to help me fix this.
 [2008-07-27 12:39 UTC] mikebevz (Mike Bevz)
Ok, I've found those files. Here you are error message for the file: Processing functions.js. Warning: substr_count(): Empty substring in /usr/share/php/PHP/CodeSniffer/File.php on line 673 Call Stack: 0.0003 55864 1. {main}() /usr/bin/phpcs:0 0.0735 1017704 2. PHP_CodeSniffer_CLI->process() /usr/bin/phpcs:30 0.1273 1021980 3. PHP_CodeSniffer->process() /usr/share/php/PHP/CodeSniffer/CLI.php:334 0.3017 2439536 4. PHP_CodeSniffer->processFiles() /usr/share/php/PHP/CodeSniffer.php:289 35.1663 15818080 5. PHP_CodeSniffer->processFile() /usr/share/php/PHP/CodeSniffer.php:566 35.1726 15891932 6. PHP_CodeSniffer_File->start() /usr/share/php/PHP/CodeSniffer.php:624 35.1726 15891932 7. PHP_CodeSniffer_File->_parse() /usr/share/php/PHP/CodeSniffer/File.php:343 35.1729 15893312 8. PHP_CodeSniffer_File::tokenizeString() /usr/share/php/PHP/CodeSniffer/File.php:432 35.1733 15895156 9. PHP_CodeSniffer_File::_createLineMap() /usr/share/php/PHP/CodeSniffer/File.php:636 35.1733 15895620 10. substr_count() /usr/share/php/PHP/CodeSniffer/File.php:673 Warning: substr_count(): Empty substring in /usr/share/php/PHP/CodeSniffer/File.php on line 673 Call Stack: 0.0003 55864 1. {main}() /usr/bin/phpcs:0 0.0735 1017704 2. PHP_CodeSniffer_CLI->process() /usr/bin/phpcs:30 0.1273 1021980 3. PHP_CodeSniffer->process() /usr/share/php/PHP/CodeSniffer/CLI.php:334 0.3017 2439536 4. PHP_CodeSniffer->processFiles() /usr/share/php/PHP/CodeSniffer.php:289 35.1663 15818080 5. PHP_CodeSniffer->processFile() /usr/share/php/PHP/CodeSniffer.php:566 35.1726 15891932 6. PHP_CodeSniffer_File->start() /usr/share/php/PHP/CodeSniffer.php:624 35.1726 15891932 7. PHP_CodeSniffer_File->_parse() /usr/share/php/PHP/CodeSniffer/File.php:343 35.1729 15893312 8. PHP_CodeSniffer_File::tokenizeString() /usr/share/php/PHP/CodeSniffer/File.php:432 35.1733 15895156 9. PHP_CodeSniffer_File::_createLineMap() /usr/share/php/PHP/CodeSniffer/File.php:636 35.1736 15895788 10. substr_count() /usr/share/php/PHP/CodeSniffer/File.php:673 [2 tokens in 1 lines]... DONE in < 1 second (0 errors, 0 warnings) ------ And all the files that caused the error were empty (for example, function.js with no code). So I think now it's pretty obvious what is the problem now.
 [2008-07-28 04:23 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. The error was only generated when checking a JS file with absolutely no content (not even a newline character).