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

Bug #19666 PSR1.Files.SideEffects throws a notice "Undefined index: scope_closer ..."
Submitted: 2012-10-22 19:57 UTC
From: andygrunwald Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version SVN)
PHP Version: 5.3.17 OS: MacOSX
Roadmaps: (Not assigned)    
Subscription  


 [2012-10-22 19:57 UTC] andygrunwald (Andy Grunwald)
Description: ------------ The sniff "PSR1.Files.SideEffects" throws a notice: "Notice: Undefined index: scope_closer in .../CodeSniffer/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php on line 149" You will find the backtrace in "Actual result". In this backtrace i removed my local pathes Test script: --------------- 1. Get the PHP file "ContentContentObject.php" from https://github.com/typo3/TYPO3v4-Core/blob/master/typo3/sysext/frontend/Classes/ContentObject/ContentContentObject.php 2. Execute the following command: php PHP_CodeSniffer-Fork/scripts/phpcs --standard=PSR1 --sniffs=PSR1.Files.SideEffects ContentContentObject.php -v --extensions=php,inc Expected result: ---------------- No results / notices Actual result: -------------- Registering sniffs in PSR1 standard... DONE (1 sniffs registered) Creating file list... DONE (1 files in queue) Changing into directory /Users/andygrunwald/Development/TYPO3/typo3_src- git/typo3/sysext/frontend/Classes/ContentObject Processing ContentContentObject.php [1657 tokens in 159 lines]... PHP Notice: Undefined index: scope_closer in CodeSniffer/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php on line 149 PHP Stack trace: PHP 1. {main}() scripts/phpcs:0 PHP 2. PHP_CodeSniffer_CLI->process() scripts/phpcs:37 PHP 3. PHP_CodeSniffer->process() CodeSniffer/CLI.php:561 PHP 4. PHP_CodeSniffer->processFile() CodeSniffer.php:504 PHP 5. PHP_CodeSniffer->_processFile() CodeSniffer.php:1302 PHP 6. PHP_CodeSniffer_File->start() CodeSniffer.php:1424 PHP 7. PSR1_Sniffs_Files_SideEffectsSniff->process() CodeSniffer/File.php:492 PHP 8. PSR1_Sniffs_Files_SideEffectsSniff- >_searchForConflict() CodeSniffer/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php:63 Notice: Undefined index: scope_closer in CodeSniffer/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php on line 149 Call Stack: 0.0129 635152 1. {main}() scripts/phpcs:0 0.0253 2372376 2. PHP_CodeSniffer_CLI->process() scripts/phpcs:37 0.0259 2381448 3. PHP_CodeSniffer->process() CodeSniffer/CLI.php:561 0.0623 2698816 4. PHP_CodeSniffer->processFile() CodeSniffer.php:504 0.0624 2699224 5. PHP_CodeSniffer->_processFile() CodeSniffer.php:1302 0.0625 2702080 6. PHP_CodeSniffer_File->start() CodeSniffer.php:1424 0.1303 5241416 7. PSR1_Sniffs_Files_SideEffectsSniff- >process() CodeSniffer/File.php:492 0.1303 5241512 8. PSR1_Sniffs_Files_SideEffectsSniff- >_searchForConflict() CodeSniffer/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php:63

Comments

 [2012-10-26 08:39 UTC] squiz (Greg Sherwood)
-Assigned To: +Assigned To: squiz
Smallest bit of code I can replicate with: function render() { do { } while (true); $wrap = isset($var) ? true : false; } Caused by tokenizer seeing that WHILE as being opened by the INLINE ELSE, which is being tokenized as simply a COLON, another token that can open a while loop.
 [2012-10-26 09:13 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
Fixed in github repo. Actually needed a change to the tokenizer rather than the sniff: https://github.com/squizlabs/PHP_CodeSniffer/commit/5ea94def4cb705abcc51f1adf9 d116021715f935
 [2012-10-26 12:45 UTC] andygrunwald (Andy Grunwald)
Works perfect. Thanks for fixing this issue so fast! You doing a great work!