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

Bug #17243 Alternate Switch Syntax causes endless loop of Notices in SwitchDeclaration
Submitted: 2010-03-18 23:06 UTC
From: ashnazg Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.2.2)
PHP Version: 5.2.4 OS: RHEL4
Roadmaps: (Not assigned)    
Subscription  


 [2010-03-18 23:06 UTC] ashnazg (Chuck Burgess)
Description: ------------ A switch statement that uses the "alternative" syntax that ends with the "endswitch;" line triggers an endless loop of PHP Notices from the Squiz.ControlsStructures.SwitchDeclaration sniff. Test script: --------------- (Example of alternative switch syntax php.net manual) <?php switch (i): case 0: echo "i equals 0"; break; case 1: echo "i equals 1"; break; default: echo "none of the above"; endswitch; ?> You can remove any particular section of the contents (e.g. the case 0 section, case 1 section, etc) and get the same results. You can even comment out the *entire* guts of it, so that only the switch and endswitch lines remain, with the same result. Expected result: ---------------- Run to completion Actual result: -------------- Endless loop of: PHP Notice: Undefined index: in PHP/CodeSniffer/File.php on line 2224 PHP Stack trace: PHP 1. {main}() phpcs:0 PHP 2. PHP_CodeSniffer_CLI->process() phpcs:30 PHP 3. PHP_CodeSniffer->process() PHP/CodeSniffer/CLI.php:429 PHP 4. PHP_CodeSniffer->processFile() PHP/CodeSniffer.php:376 PHP 5. PHP_CodeSniffer->_processFile() PHP/CodeSniffer.php:836 PHP 6. PHP_CodeSniffer_File->start() PHP/CodeSniffer.php:921 PHP 7. Squiz_Sniffs_ControlStructures_SwitchDeclarationSniff->process() PHP/CodeSniffer/File.php:431 PHP 8. PHP_CodeSniffer_File->findPrevious() PHP/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php:206 Notice: Undefined index: in PHP/CodeSniffer/File.php on line 2224 Call Stack: 0.0006 50464 1. {main}() phpcs:0 0.0357 1018772 2. PHP_CodeSniffer_CLI->process() phpcs:30 0.0370 1023908 3. PHP_CodeSniffer->process() PHP/CodeSniffer/CLI.php:429 0.2301 4471652 4. PHP_CodeSniffer->processFile() PHP/CodeSniffer.php:376 0.2303 4471732 5. PHP_CodeSniffer->_processFile() PHP/CodeSniffer.php:836 0.2307 4472580 6. PHP_CodeSniffer_File->start() PHP/CodeSniffer.php:921 0.2898 4595384 7. Squiz_Sniffs_ControlStructures_SwitchDeclarationSniff->process() PHP/CodeSniffer/File.php:431 0.3526 4597796 8. PHP_CodeSniffer_File->findPrevious() PHP/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php:206

Comments

 [2010-03-19 05:17 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2010-03-19 05:19 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!