cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures ForLoopDeclarationSniff.php

[email protected] ("Greg Sherwood") Thu, 08 May 2008 03:38:48 -0000
Newsgroups php.pear.cvs
Message-ID <cvssquiz1210217928@cvsserver>
squiz		Thu May  8 03:38:48 2008 UTC

  Modified files:              
    /pear/PHP_CodeSniffer	package.xml 
    /pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures	
                                                                              	ForLoopDeclarationSniff.php 
  Log:
  Fixed bug #13849 : infinite loop in PHP_CodeSniffer_File::findNext(). Occured when FOR keyword had no brackets, which phpcs now throws a warning for (possible parse error).
  
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/package.xml?r1=1.268&r2=1.269&diff_format=u
Index: pear/PHP_CodeSniffer/package.xml
diff -u pear/PHP_CodeSniffer/package.xml:1.268 pear/PHP_CodeSniffer/package.xml:1.269
--- pear/PHP_CodeSniffer/package.xml:1.268	Thu May  8 01:16:27 2008
+++ pear/PHP_CodeSniffer/package.xml	Thu May  8 03:38:48 2008
@@ -41,6 +41,7 @@
   - Generic UpperCaseConstantSniff no longer throws errors for delcare(ticks = ...)
     - Thanks to Josh Snyder for the patch
   - Fixed bug #13846 : Bug in Squiz.NonExecutableCodeSniff
+  - Fixed bug #13849 : infinite loop in PHP_CodeSniffer_File::findNext()
  </notes>
  <contents>
   <dir name="/">
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php?r1=1.7&r2=1.8&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php:1.7 pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php:1.8
--- pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php:1.7	Mon Mar 17 04:55:17 2008
+++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php	Thu May  8 03:38:48 2008
@@ -10,7 +10,7 @@
  * @author    Marc McIntyre <[email protected]>
  * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
  * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version   CVS: $Id: ForLoopDeclarationSniff.php,v 1.7 2008/03/17 04:55:17 squiz Exp $
+ * @version   CVS: $Id: ForLoopDeclarationSniff.php,v 1.8 2008/05/08 03:38:48 squiz Exp $
  * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
@@ -69,6 +69,12 @@
         $errors = array();
 
         $openingBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr);
+        if ($openingBracket === false) {
+            $error = 'Possible parse error: no opening parenthesis for FOR keyword';
+            $phpcsFile->addWarning($error, $stackPtr);
+            return;
+        }
+
         $closingBracket = $tokens[$openingBracket]['parenthesis_closer'];
 
         if ($tokens[($openingBracket + 1)]['code'] === T_WHITESPACE) {