cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards AbstractVariableSniff.php /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting ClosingDeclarationCommentSniff.php /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting ClosingDeclarationCommentUnitTest.inc ClosingDeclarationCommentUnitTest.php

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

  Modified files:              
    /pear/PHP_CodeSniffer	package.xml 
    /pear/PHP_CodeSniffer/CodeSniffer/Standards	
                                               	AbstractVariableSniff.php 
    /pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting	
                                                                       	ClosingDeclarationCommentSniff.php 
    /pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting	
                                                                      	ClosingDeclarationCommentUnitTest.inc 
                                                                      	ClosingDeclarationCommentUnitTest.php 
  Log:
  Squiz ClosingDeclarationCommentSniff and AbstractVariableSniff now throw warnings for possible parse errors when non-abstract methods dont have braces.
  
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/package.xml?r1=1.269&r2=1.270&diff_format=u
Index: pear/PHP_CodeSniffer/package.xml
diff -u pear/PHP_CodeSniffer/package.xml:1.269 pear/PHP_CodeSniffer/package.xml:1.270
--- pear/PHP_CodeSniffer/package.xml:1.269	Thu May  8 03:38:48 2008
+++ pear/PHP_CodeSniffer/package.xml	Thu May  8 03:58:12 2008
@@ -40,6 +40,7 @@
   - Removed "function" from error messages for Generic function brace sniffs (feature request #13820)
   - Generic UpperCaseConstantSniff no longer throws errors for delcare(ticks = ...)
     - Thanks to Josh Snyder for the patch
+  - Squiz ClosingDeclarationCommentSniff and AbstractVariableSniff now throw warnings for possible parse errors
   - Fixed bug #13846 : Bug in Squiz.NonExecutableCodeSniff
   - Fixed bug #13849 : infinite loop in PHP_CodeSniffer_File::findNext()
  </notes>
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractVariableSniff.php?r1=1.13&r2=1.14&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractVariableSniff.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractVariableSniff.php:1.13 pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractVariableSniff.php:1.14
--- pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractVariableSniff.php:1.13	Wed Feb 27 00:05:59 2008
+++ pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractVariableSniff.php	Thu May  8 03:58:12 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: AbstractVariableSniff.php,v 1.13 2008/02/27 00:05:59 squiz Exp $
+ * @version   CVS: $Id: AbstractVariableSniff.php,v 1.14 2008/05/08 03:58:12 squiz Exp $
  * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
@@ -118,6 +118,12 @@
             if ($methodProps['is_abstract'] === true || $tokens[$currScope]['code'] === T_INTERFACE) {
                 $this->_endFunction = $phpcsFile->findNext(array(T_SEMICOLON), $stackPtr);
             } else {
+                if (isset($tokens[$stackPtr]['scope_closer']) === false) {
+                    $error = 'Possible parse error: non-abstract method defined as abstract';
+                    $phpcsFile->addWarning($error, $stackPtr);
+                    return;
+                }
+
                 $this->_endFunction = $tokens[$stackPtr]['scope_closer'];
             }
 
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php?r1=1.3&r2=1.4&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php:1.3 pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php:1.4
--- pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php:1.3	Mon Jul 23 01:47:53 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php	Thu May  8 03:58:12 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: ClosingDeclarationCommentSniff.php,v 1.3 2007/07/23 01:47:53 squiz Exp $
+ * @version   CVS: $Id: ClosingDeclarationCommentSniff.php,v 1.4 2008/05/08 03:58:12 squiz Exp $
  * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
@@ -76,6 +76,12 @@
                 return;
             }
 
+            if (isset($tokens[$stackPtr]['scope_closer']) === false) {
+                $error = 'Possible parse error: non-abstract method defined as abstract';
+                $phpcsFile->addWarning($error, $stackPtr);
+                return;
+            }
+
             $decName = $phpcsFile->getDeclarationName($stackPtr);
             $comment = '//end '.$decName.'()';
         } else if ($tokens[$stackPtr]['code'] === T_CLASS) {
@@ -92,7 +98,7 @@
         }
 
         $error = 'Expected '.$comment;
-        if ($tokens[($closingBracket + 1)]['code'] !== T_COMMENT) {
+        if (isset($tokens[($closingBracket + 1)]) === false || $tokens[($closingBracket + 1)]['code'] !== T_COMMENT) {
             $phpcsFile->addError($error, $closingBracket);
             return;
         }
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc?r1=1.1&r2=1.2&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc
diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc:1.1 pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc:1.2
--- pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc:1.1	Mon Dec 18 23:39:25 2006
+++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc	Thu May  8 03:58:12 2008
@@ -66,4 +66,9 @@
 {
 }
 
+class MyClass
+{
+    public function myFunction();
+}//end class
+
 ?>
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php?r1=1.1&r2=1.2&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php:1.1 pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php:1.2
--- pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php:1.1	Mon Dec 18 23:39:25 2006
+++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php	Thu May  8 03:58:12 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: ClosingDeclarationCommentUnitTest.php,v 1.1 2006/12/18 23:39:25 squiz Exp $
+ * @version   CVS: $Id: ClosingDeclarationCommentUnitTest.php,v 1.2 2008/05/08 03:58:12 squiz Exp $
  * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
@@ -66,7 +66,9 @@
      */
     public function getWarningList()
     {
-        return array();
+        return array(
+                71 => 1,
+               );
 
     }//end getWarningList()