cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes ClassDeclarationSniff.php
/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes ClassDeclarationUnitTest.inc ClassDeclarationUnitTest.php
| From: | Greg Sherwood | Date: | Mon, 10 Dec 2007 03:30:14 +0000 |
| Subject: | cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes ClassDeclarationSniff.php /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes ClassDeclarationUnitTest.inc ClassDeclarationUnitTest.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-49699@lists.php.net to get a copy of this message | ||
squiz Mon Dec 10 03:30:14 2007 UTC
Modified files:
/pear/PHP_CodeSniffer package.xml
/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes
ClassDeclarationSniff.php
/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes
ClassDeclarationUnitTest.inc
ClassDeclarationUnitTest.php
Log:
Squiz ClassDeclarationSniff now throws errors for a missing end PHP tag after the end class tag
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/package.xml?r1=1.187&r2=1.188&diff_format=u
Index: pear/PHP_CodeSniffer/package.xml
diff -u pear/PHP_CodeSniffer/package.xml:1.187 pear/PHP_CodeSniffer/package.xml:1.188
--- pear/PHP_CodeSniffer/package.xml:1.187 Wed Dec 5 22:09:59 2007
+++ pear/PHP_CodeSniffer/package.xml Mon Dec 10 03:30:14 2007
@@ -39,6 +39,7 @@
-- Thanks to Carsten Wiedmann for the patch
- PEAR ClassDeclarationSniff no longer throws errors for multi-line class declarations
- Squiz ClassDeclarationSniff now ensures there is one blank line after a class closing brace
+ - Squiz ClassDeclarationSniff now throws errors for a missing end PHP tag after the end class tag
- Fixed bug #12621 : "space after AS" check is wrong
-- Thanks to Satoshi Oikawa for the patch
</notes>
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php?r1=1.13&r2=1.14&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php
diff -u
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php:1.13
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php:1.14
---
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php:1.13 Wed
Dec 5 03:32:26 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php Mon
Dec 10 03:30:14 2007
@@ -10,7 +10,7 @@
* @author Marc McIntyre <mmcintyre@squiz.net>
* @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: ClassDeclarationSniff.php,v 1.13 2007/12/05 03:32:26 squiz Exp $
+ * @version CVS: $Id: ClassDeclarationSniff.php,v 1.14 2007/12/10 03:30:14 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
@@ -122,20 +122,29 @@
// Check that the closing brace has one blank line after it.
$nextContent = $phpcsFile->findNext(array(T_WHITESPACE, T_COMMENT), ($closeBrace + 1),
null, true);
- $nextLine = $tokens[$nextContent]['line'];
- $braceLine = $tokens[$closeBrace]['line'];
- if ($braceLine === $nextLine) {
+ if ($nextContent === false) {
+ // No content found, so we reached the end of the file.
+ // That means there was no closing tag either.
$error = 'Closing brace of a ';
$error .= $tokens[$stackPtr]['content'];
- $error .= ' must be followed by a single blank line';
+ $error .= ' must be followed by a blank line and then a closing PHP tag';
$phpcsFile->addError($error, $closeBrace);
- } else if ($nextLine !== ($braceLine + 2)) {
- $difference = ($nextLine - $braceLine - 1).' lines';
- $error = 'Closing brace of a ';
- $error .= $tokens[$stackPtr]['content'];
- $error .= ' must be followed by a single blank line; found
'.$difference;
- $phpcsFile->addError($error, $closeBrace);
- }
+ } else {
+ $nextLine = $tokens[$nextContent]['line'];
+ $braceLine = $tokens[$closeBrace]['line'];
+ if ($braceLine === $nextLine) {
+ $error = 'Closing brace of a ';
+ $error .= $tokens[$stackPtr]['content'];
+ $error .= ' must be followed by a single blank line';
+ $phpcsFile->addError($error, $closeBrace);
+ } else if ($nextLine !== ($braceLine + 2)) {
+ $difference = ($nextLine - $braceLine - 1).' lines';
+ $error = 'Closing brace of a ';
+ $error .= $tokens[$stackPtr]['content'];
+ $error .= ' must be followed by a single blank line; found
'.$difference;
+ $phpcsFile->addError($error, $closeBrace);
+ }
+ }//end if
// Check the closing brace is on it's own line, but allow
// for comments like "//end class".
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc?r1=1.7&r2=1.8&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc
diff -u
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc:1.7
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc:1.8
---
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc:1.7 Tue
Jun 26 01:36:33 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc Mon
Dec 10 03:30:14 2007
@@ -86,4 +86,11 @@
{
}
-?>
\ No newline at end of file
+?>
+
+<?php
+
+class CorrectClassDeclaration
+{
+
+}//end class
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php?r1=1.9&r2=1.10&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php
diff -u
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php:1.9
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php:1.10
---
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php:1.9 Wed
Dec 5 03:32:27 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php Mon
Dec 10 03:30:14 2007
@@ -10,7 +10,7 @@
* @author Marc McIntyre <mmcintyre@squiz.net>
* @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: ClassDeclarationUnitTest.php,v 1.9 2007/12/05 03:32:27 squiz Exp $
+ * @version CVS: $Id: ClassDeclarationUnitTest.php,v 1.10 2007/12/10 03:30:14 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
@@ -70,6 +70,8 @@
80 => 1,
85 => 1,
88 => 1,
+ 93 => 1,
+ 96 => 1,
);
}//end getErrorList()