[prev in list] [next in list] [prev in thread] [next in thread]
List: pear-cvs
Subject: [PEAR-CVS] cvs: pear /PHP_CodeSniffer CodeSniffer.php /PHP_CodeSniffer/CodeSniffer File.php Sniff.p
From: "Greg Sherwood" <squiz () php ! net>
Date: 2007-11-30 1:18:41
Message-ID: cvssquiz1196385521 () cvsserver
[Download RAW message or body]
squiz Fri Nov 30 01:18:41 2007 UTC
Modified files:
/pear/PHP_CodeSniffer CodeSniffer.php
/pear/PHP_CodeSniffer/CodeSniffer File.php Sniff.php
/pear/PHP_CodeSniffer/CodeSniffer/CommentParser
AbstractDocElement.php
AbstractParser.php
ClassCommentParser.php
CommentElement.php
FunctionCommentParser.php
MemberCommentParser.php
PairElement.php
ParameterElement.php
SingleElement.php
/pear/PHP_CodeSniffer/CodeSniffer/Standards
AbstractPatternSniff.php
AbstractScopeSniff.php
AbstractVariableSniff.php
/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures
\
SwitchDeclarationSniff.php Log:
Coding standard fixes
["squiz-20071130011841.txt" (text/plain)]
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer.php?r1=1.58&r2=1.59&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer.php
diff -u pear/PHP_CodeSniffer/CodeSniffer.php:1.58 \
pear/PHP_CodeSniffer/CodeSniffer.php:1.59
--- pear/PHP_CodeSniffer/CodeSniffer.php:1.58 Mon Nov 26 01:00:40 2007
+++ pear/PHP_CodeSniffer/CodeSniffer.php Fri Nov 30 01:18:40 2007
@@ -11,7 +11,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: CodeSniffer.php,v 1.58 2007/11/26 01:00:40 squiz Exp $
+ * @version CVS: $Id: CodeSniffer.php,v 1.59 2007/11/30 01:18:40 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
@@ -1227,7 +1227,11 @@
// The character is a number, so it cant be a captial.
$isCaps = false;
} else {
- $isCaps = (strtoupper($string{$i}) === $string{$i}) ? true : \
false; + if (strtoupper($string{$i}) === $string{$i}) {
+ $isCaps = true;
+ } else {
+ $isCaps = false;
+ }
}
if ($isCaps === true && $lastCharWasCaps === true) {
@@ -1310,9 +1314,11 @@
}//end switch
if (strpos($lowerVarType, 'array(') !== false) {
- // Valid array declaration: array, array(type), array(type1 => \
type2). + // Valid array declaration:
+ // array, array(type), array(type1 => type2).
$matches = array();
- if (preg_match('/^array\(\s*([^\s^=^>]*)(\s*=>\s*(.*))?\s*\)/i', \
$varType, $matches) !== 0) { + $pattern = \
'/^array\(\s*([^\s^=^>]*)(\s*=>\s*(.*))?\s*\)/i'; + if \
(preg_match($pattern, $varType, $matches) !== 0) {
$type1 = (isset($matches[1]) === true) ? $matches[1] : '';
$type2 = (isset($matches[3]) === true) ? $matches[3] : '';
$type1 = self::suggestType($type1);
@@ -1374,7 +1380,8 @@
}
// Valid coding standard dirs include a standard class.
- if (is_file($file->getPathname()."/{$filename}CodingStandard.php") \
=== true) { + $csFile = \
$file->getPathname()."/{$filename}CodingStandard.php"; + if \
(is_file($csFile) === true) { // We found a coding standard directory.
$installedStandards[] = $filename;
}
@@ -1459,7 +1466,8 @@
}
if (is_file($configFile) === true && is_writable($configFile) === false) {
- throw new PHP_CodeSniffer_Exception("Config file $configFile is not \
writable"); + $error = "Config file $configFile is not writable";
+ throw new PHP_CodeSniffer_Exception($error);
}
$phpCodeSnifferConfig = self::getAllConfigData();
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/File.php?r1=1.50&r2=1.51&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/File.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/File.php:1.50 \
pear/PHP_CodeSniffer/CodeSniffer/File.php:1.51
--- pear/PHP_CodeSniffer/CodeSniffer/File.php:1.50 Mon Nov 26 01:00:40 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/File.php Fri Nov 30 01:18:40 2007
@@ -11,7 +11,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: File.php,v 1.50 2007/11/26 01:00:40 squiz Exp $
+ * @version CVS: $Id: File.php,v 1.51 2007/11/30 01:18:40 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
@@ -526,7 +526,8 @@
// Will be either \r, \r\n or \n.
$handle = fopen($file, 'r');
if ($handle === false) {
- throw new PHP_CodeSniffer_Exception('File could not be opened; could not \
auto-detect line endings'); + $error = 'File could not be opened; could \
not auto-detect line endings'; + throw new \
PHP_CodeSniffer_Exception($error); }
$firstLine = fgets($handle);
@@ -1295,9 +1296,9 @@
if (in_array($tokens[$x]['code'], \
PHP_CodeSniffer_Tokens::$emptyTokens) === true) { continue;
} else {
- // If the first non-whitespace/comment token is a \
variable
- // then this is an opener for a string offset and not
- // a scope.
+ // If the first non-whitespace/comment token is a
+ // variable then this is an opener for a string offset
+ // and not a scope.
if ($tokens[$x]['code'] === T_VARIABLE) {
if (PHP_CODESNIFFER_VERBOSITY > 1) {
echo str_repeat("\t", $depth);
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Sniff.php?r1=1.3&r2=1.4&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Sniff.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/Sniff.php:1.3 \
pear/PHP_CodeSniffer/CodeSniffer/Sniff.php:1.4
--- pear/PHP_CodeSniffer/CodeSniffer/Sniff.php:1.3 Mon Jul 23 01:47:51 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/Sniff.php Fri Nov 30 01:18:40 2007
@@ -10,17 +10,17 @@
* @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: Sniff.php,v 1.3 2007/07/23 01:47:51 squiz Exp $
+ * @version CVS: $Id: Sniff.php,v 1.4 2007/11/30 01:18:40 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
/**
* Represents a PHP_CodeSniffer sniff for sniffing coding standards.
*
- * A sniff registers what token types it wishes to listen for, then, when \
PHP_CodeSniffer
- * encounters that token, the sniff is invoked and passed information about where
- * the token was found in the stack, and the PHP_CodeSniffer file in which the token \
was
- * found.
+ * A sniff registers what token types it wishes to listen for, then, when
+ * PHP_CodeSniffer encounters that token, the sniff is invoked and passed
+ * information about where the token was found in the stack, and the
+ * PHP_CodeSniffer file in which the token was found.
*
* @category PHP
* @package PHP_CodeSniffer
@@ -78,9 +78,11 @@
* $phpcsFile->addError('Encountered an error', $stackPtr);
* </code>
*
- * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the \
token was found.
- * @param int $stackPtr The position in the PHP_CodeSniffer \
file's token
- * stack where the token was found.
+ * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the
+ * token was found.
+ * @param int $stackPtr The position in the PHP_CodeSniffer
+ * file's token stack where the token
+ * was found.
*
* @return void
*/
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/CommentParser/AbstractDocElement.php?r1=1.9&r2=1.10&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/CommentParser/AbstractDocElement.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/CommentParser/AbstractDocElement.php:1.9 \
pear/PHP_CodeSniffer/CodeSniffer/CommentParser/AbstractDocElement.php:1.10
--- pear/PHP_CodeSniffer/CodeSniffer/CommentParser/AbstractDocElement.php:1.9 Fri Jul \
27 05:38:36 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/CommentParser/AbstractDocElement.php Fri Nov 30 \
01:18:41 2007 @@ -10,12 +10,13 @@
* @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: AbstractDocElement.php,v 1.9 2007/07/27 05:38:36 squiz Exp $
+ * @version CVS: $Id: AbstractDocElement.php,v 1.10 2007/11/30 01:18:41 squiz Exp \
$
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
if (interface_exists('PHP_CodeSniffer_CommentParser_DocElement', true) === false) {
- throw new PHP_CodeSniffer_Exception('Interface \
PHP_CodeSniffer_CommentParser_DocElement not found'); + $error = 'Interface \
PHP_CodeSniffer_CommentParser_DocElement not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
/**
@@ -110,11 +111,18 @@
/**
* Constructs a Doc Element.
*
- * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element \
that ocurred before this.
- * @param array $tokens The tokens \
of this element.
- * @param string $tag The doc \
element tag this element + * @param PHP_CodeSniffer_CommentParser_DocElement \
$previousElement The element + * \
that ocurred + * \
before this. + * @param array $tokens \
The tokens of + * \
this element. + * @param string $tag \
The doc + * \
element tag + * \
this element
* represents.
- * @param PHP_CodeSniffer_File $phpcsFile The file \
that this element is in. + * @param PHP_CodeSniffer_File \
$phpcsFile The file that + * \
this element + * \
is in.
*
* @throws Exception If $previousElement in not a DocElement or if
* getSubElements() does not return an array.
@@ -122,7 +130,8 @@
public function __construct($previousElement, array $tokens, $tag, \
PHP_CodeSniffer_File $phpcsFile) {
if ($previousElement !== null && ($previousElement instanceof \
PHP_CodeSniffer_CommentParser_DocElement) === false) {
- throw new Exception('$previousElement must be an instance of \
DocElement'); + $error = '$previousElement must be an instance of \
DocElement'; + throw new Exception($error);
}
$this->phpcsFile = $phpcsFile;
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/CommentParser/AbstractParser.php?r1=1.17&r2=1.18&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/CommentParser/AbstractParser.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/CommentParser/AbstractParser.php:1.17 \
pear/PHP_CodeSniffer/CodeSniffer/CommentParser/AbstractParser.php:1.18
--- pear/PHP_CodeSniffer/CodeSniffer/CommentParser/AbstractParser.php:1.17 Fri Jul 27 \
05:38:37 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/CommentParser/AbstractParser.php Fri Nov 30 \
01:18:41 2007 @@ -10,20 +10,23 @@
* @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: AbstractParser.php,v 1.17 2007/07/27 05:38:37 squiz Exp $
+ * @version CVS: $Id: AbstractParser.php,v 1.18 2007/11/30 01:18:41 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
if (class_exists('PHP_CodeSniffer_CommentParser_SingleElement', true) === false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_SingleElement not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_SingleElement not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
if (class_exists('PHP_CodeSniffer_CommentParser_CommentElement', true) === false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_CommentElement not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_CommentElement not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
if (class_exists('PHP_CodeSniffer_CommentParser_ParserException', true) === false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_ParserException not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_ParserException not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
/**
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ClassCommentParser.php?r1=1.10&r2=1.11&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ClassCommentParser.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ClassCommentParser.php:1.10 \
pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ClassCommentParser.php:1.11
--- pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ClassCommentParser.php:1.10 Fri \
Oct 26 02:13:18 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ClassCommentParser.php Fri Nov 30 \
01:18:41 2007 @@ -10,12 +10,13 @@
* @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: ClassCommentParser.php,v 1.10 2007/10/26 02:13:18 squiz Exp \
$ + * @version CVS: $Id: ClassCommentParser.php,v 1.11 2007/11/30 01:18:41 squiz \
Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
if (class_exists('PHP_CodeSniffer_CommentParser_AbstractParser', true) === false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_AbstractParser not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_AbstractParser not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
/**
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/CommentParser/CommentElement.php?r1=1.12&r2=1.13&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/CommentParser/CommentElement.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/CommentParser/CommentElement.php:1.12 \
pear/PHP_CodeSniffer/CodeSniffer/CommentParser/CommentElement.php:1.13
--- pear/PHP_CodeSniffer/CodeSniffer/CommentParser/CommentElement.php:1.12 Sun Nov 25 \
02:59:28 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/CommentParser/CommentElement.php Fri Nov 30 \
01:18:41 2007 @@ -10,12 +10,13 @@
* @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: CommentElement.php,v 1.12 2007/11/25 02:59:28 squiz Exp $
+ * @version CVS: $Id: CommentElement.php,v 1.13 2007/11/30 01:18:41 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
if (class_exists('PHP_CodeSniffer_CommentParser_SingleElement', true) === false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_SingleElement not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_SingleElement not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
/**
@@ -51,12 +52,19 @@
/**
* Constructs a PHP_CodeSniffer_CommentParser_CommentElement.
*
- * @param PHP_CodeSniffer_CommentParser_DocElemement $previousElement The \
element that
- * appears \
before this + * @param PHP_CodeSniffer_CommentParser_DocElemement \
$previousElement The element + * \
that + * \
appears + * \
before this
* element.
- * @param array $tokens The tokens \
that
- * make up \
this element.
- * @param PHP_CodeSniffer_File $phpcsFile The file \
that this element is in. + * @param array \
$tokens The tokens + * \
that make + * \
up this + * \
element. + * @param PHP_CodeSniffer_File $phpcsFile \
The file + * \
that this + * \
element is + * \
in.
*/
public function __construct($previousElement, $tokens, PHP_CodeSniffer_File \
$phpcsFile) {
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/CommentParser/FunctionCommentParser.php?r1=1.7&r2=1.8&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/CommentParser/FunctionCommentParser.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/CommentParser/FunctionCommentParser.php:1.7 \
pear/PHP_CodeSniffer/CodeSniffer/CommentParser/FunctionCommentParser.php:1.8
--- pear/PHP_CodeSniffer/CodeSniffer/CommentParser/FunctionCommentParser.php:1.7 Fri \
Jul 27 05:38:37 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/CommentParser/FunctionCommentParser.php Fri Nov \
30 01:18:41 2007 @@ -10,24 +10,28 @@
* @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: FunctionCommentParser.php,v 1.7 2007/07/27 05:38:37 squiz \
Exp $ + * @version CVS: $Id: FunctionCommentParser.php,v 1.8 2007/11/30 01:18:41 \
squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
if (class_exists('PHP_CodeSniffer_CommentParser_AbstractParser', true) === false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_AbstractParser not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_AbstractParser not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
if (class_exists('PHP_CodeSniffer_CommentParser_ParameterElement', true) === false) \
{
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_ParameterElement not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_ParameterElement not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
if (class_exists('PHP_CodeSniffer_CommentParser_PairElement', true) === false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_PairElement not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_PairElement not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
if (class_exists('PHP_CodeSniffer_CommentParser_SingleElement', true) === false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_SingleElement not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_SingleElement not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
/**
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/CommentParser/MemberCommentParser.php?r1=1.7&r2=1.8&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/CommentParser/MemberCommentParser.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/CommentParser/MemberCommentParser.php:1.7 \
pear/PHP_CodeSniffer/CodeSniffer/CommentParser/MemberCommentParser.php:1.8
--- pear/PHP_CodeSniffer/CodeSniffer/CommentParser/MemberCommentParser.php:1.7 Fri \
Jul 27 05:38:37 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/CommentParser/MemberCommentParser.php Fri Nov 30 \
01:18:41 2007 @@ -10,12 +10,13 @@
* @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: MemberCommentParser.php,v 1.7 2007/07/27 05:38:37 squiz Exp \
$ + * @version CVS: $Id: MemberCommentParser.php,v 1.8 2007/11/30 01:18:41 squiz \
Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === \
false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_ClassCommentParser not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_ClassCommentParser not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
/**
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/CommentParser/PairElement.php?r1=1.7&r2=1.8&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/CommentParser/PairElement.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/CommentParser/PairElement.php:1.7 \
pear/PHP_CodeSniffer/CodeSniffer/CommentParser/PairElement.php:1.8
--- pear/PHP_CodeSniffer/CodeSniffer/CommentParser/PairElement.php:1.7 Fri Jul 27 \
05:38:37 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/CommentParser/PairElement.php Fri Nov 30 \
01:18:41 2007 @@ -10,12 +10,13 @@
* @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: PairElement.php,v 1.7 2007/07/27 05:38:37 squiz Exp $
+ * @version CVS: $Id: PairElement.php,v 1.8 2007/11/30 01:18:41 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
if (class_exists('PHP_CodeSniffer_CommentParser_AbstractDocElement', true) === \
false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_AbstractDocElement not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_AbstractDocElement not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
/**
@@ -68,10 +69,18 @@
/**
* Constructs a PHP_CodeSniffer_CommentParser_PairElement doc tag.
*
- * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element \
before this one.
- * @param array $tokens The tokens \
that comprise this element.
- * @param string $tag The tag that \
this element represents.
- * @param PHP_CodeSniffer_File $phpcsFile The file \
that this element is in. + * @param PHP_CodeSniffer_CommentParser_DocElement \
$previousElement The element + * \
before this + * \
one. + * @param array $tokens The \
tokens + * that \
comprise + * \
this element. + * @param string $tag \
The tag that + * \
this element + * \
represents. + * @param PHP_CodeSniffer_File $phpcsFile \
The file that + * \
this element + * \
is in.
*/
public function __construct($previousElement, $tokens, $tag, \
PHP_CodeSniffer_File $phpcsFile) {
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ParameterElement.php?r1=1.11&r2=1.12&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ParameterElement.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ParameterElement.php:1.11 \
pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ParameterElement.php:1.12
--- pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ParameterElement.php:1.11 Wed Oct \
24 02:06:22 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ParameterElement.php Fri Nov 30 \
01:18:41 2007 @@ -10,12 +10,13 @@
* @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: ParameterElement.php,v 1.11 2007/10/24 02:06:22 squiz Exp $
+ * @version CVS: $Id: ParameterElement.php,v 1.12 2007/11/30 01:18:41 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
if (class_exists('PHP_CodeSniffer_CommentParser_AbstractDocElement', true) === \
false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_AbstractDocElement not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_AbstractDocElement not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
/**
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/CommentParser/SingleElement.php?r1=1.10&r2=1.11&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/CommentParser/SingleElement.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/CommentParser/SingleElement.php:1.10 \
pear/PHP_CodeSniffer/CodeSniffer/CommentParser/SingleElement.php:1.11
--- pear/PHP_CodeSniffer/CodeSniffer/CommentParser/SingleElement.php:1.10 Fri Jul 27 \
05:38:37 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/CommentParser/SingleElement.php Fri Nov 30 \
01:18:41 2007 @@ -10,12 +10,13 @@
* @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: SingleElement.php,v 1.10 2007/07/27 05:38:37 squiz Exp $
+ * @version CVS: $Id: SingleElement.php,v 1.11 2007/11/30 01:18:41 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
if (class_exists('PHP_CodeSniffer_CommentParser_AbstractDocElement', true) === \
false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_CommentParser_AbstractDocElement not found'); + $error = 'Class \
PHP_CodeSniffer_CommentParser_AbstractDocElement not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
/**
@@ -56,10 +57,18 @@
/**
* Constructs a SingleElement doc tag.
*
- * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element \
before this one.
- * @param array $tokens The tokens \
that comprise this element.
- * @param string $tag The tag that \
this element represents.
- * @param PHP_CodeSniffer_File $phpcsFile The file \
that this element is in. + * @param PHP_CodeSniffer_CommentParser_DocElement \
$previousElement The element + * \
before this + * \
one. + * @param array $tokens The \
tokens + * that \
comprise + * \
this element. + * @param string $tag \
The tag that + * \
this element + * \
represents. + * @param PHP_CodeSniffer_File $phpcsFile \
The file that + * \
this element + * \
is in.
*/
public function __construct($previousElement, $tokens, $tag, \
PHP_CodeSniffer_File $phpcsFile) {
@@ -131,8 +140,10 @@
* Processes a content check for single doc element.
*
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
- * @param int $commentStart The line number where the error \
occurs.
- * @param string $docBlock Whether this is a file or class \
comment doc + * @param int $commentStart The line number where
+ * the error occurs.
+ * @param string $docBlock Whether this is a file or
+ * class comment doc.
*
* @return void
*/
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractPatternSniff.php?r1=1.17&r2=1.18&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractPatternSniff.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractPatternSniff.php:1.17 \
pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractPatternSniff.php:1.18
--- pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractPatternSniff.php:1.17 Fri Nov \
16 03:09:20 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractPatternSniff.php Fri Nov 30 \
01:18:41 2007 @@ -10,12 +10,13 @@
* @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: AbstractPatternSniff.php,v 1.17 2007/11/16 03:09:20 squiz \
Exp $ + * @version CVS: $Id: AbstractPatternSniff.php,v 1.18 2007/11/30 01:18:41 \
squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
if (class_exists('PHP_CodeSniffer_Standards_IncorrectPatternException', true) === \
false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_Standards_IncorrectPatternException not found'); + $error = 'Class \
PHP_CodeSniffer_Standards_IncorrectPatternException not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
/**
@@ -173,7 +174,8 @@
// If we could not get a token.
if ($token === false) {
- throw new PHP_CodeSniffer_Exception('Could not determine a token to \
listen for'); + $error = 'Could not determine a token to listen for';
+ throw new PHP_CodeSniffer_Exception($error);
}
return $tokenTypes[$token];
@@ -244,9 +246,10 @@
/**
* Processes the pattern and varifies the code at $stackPtr.
*
- * @param array $patternInfo Information about the pattern used \
for
- * checking, which includes are parsed
- * otken representation of the pattern.
+ * @param array $patternInfo Information about the pattern used
+ * for checking, which includes are
+ * parsed token representation of the
+ * pattern.
* @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the
* token occured.
* @param int $stackPtr The postion in the tokens stack \
where @@ -298,8 +301,8 @@
} else {
// Check to see if this important token is the same as the
- // previous important token in the pattern. If it is not, \
then
- // the pattern cannot be for this piece of code.
+ // previous important token in the pattern. If it is not,
+ // then the pattern cannot be for this piece of code.
$prev = $phpcsFile->findPrevious($ignoreTokens, $stackPtr, \
null, true);
if ($prev === false || $tokens[$prev]['code'] !== \
$pattern[$i]['token']) { return false;
@@ -441,8 +444,8 @@
}
// Even when ignoring comments, we are not allowed to \
include
- // newlines without the pattern specifying them, so \
everything
- // should be on the same line.
+ // newlines without the pattern specifying them, so
+ // everything should be on the same line.
if ($tokens[$next]['line'] !== $tokens[$stackPtr]['line']) {
$hasError = true;
}
@@ -509,8 +512,8 @@
if ($newline === $stackPtr) {
$next = ($stackPtr + 1);
} else {
- // Check that there were no significant tokens that we \
skipped
- // over to find our newline character.
+ // Check that there were no significant tokens that we
+ // skipped over to find our newline character.
$next = $phpcsFile->findNext($ignoreTokens, $stackPtr, null, \
true); if ($next < $newline) {
// We skipped a non-ignored token.
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractScopeSniff.php?r1=1.5&r2=1.6&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractScopeSniff.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractScopeSniff.php:1.5 \
pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractScopeSniff.php:1.6
--- pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractScopeSniff.php:1.5 Mon Jul 23 \
01:47:52 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractScopeSniff.php Fri Nov 30 \
01:18:41 2007 @@ -11,7 +11,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: AbstractScopeSniff.php,v 1.5 2007/07/23 01:47:52 squiz Exp $
+ * @version CVS: $Id: AbstractScopeSniff.php,v 1.6 2007/11/30 01:18:41 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
@@ -21,19 +21,19 @@
*
* Below is a test that listens to methods that exist only within classes:
* <code>
- * class ClassScopeTest extends PHP_CodeSniffer_Standards_AbstractScopeSniff
- * {
- * public function __construct()
- * {
- * parent::__construct(array(T_CLASS), array(T_FUNCTION));
- * }
+ * class ClassScopeTest extends PHP_CodeSniffer_Standards_AbstractScopeSniff
+ * {
+ * public function __construct()
+ * {
+ * parent::__construct(array(T_CLASS), array(T_FUNCTION));
+ * }
*
- * protected function processTokenWithinScope(PHP_CodeSniffer_File \
$phpcsFile, $)
- * {
- * $className = $phpcsFile->getDeclarationName($currScope);
- * echo 'encountered a method within class '.$className;
- * }
- * }
+ * protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, \
$) + * {
+ * $className = $phpcsFile->getDeclarationName($currScope);
+ * echo 'encountered a method within class '.$className;
+ * }
+ * }
* </code>
*
* @category PHP
@@ -86,7 +86,8 @@
* within the scope.
* @param boolean $listenOutside If true this test will also alert the
* extending class when a token is found outside
- * the scope, by calling the \
processTokenOutideScope. + * the scope, by calling \
the + * processTokenOutideScope method.
*
* @see PHP_CodeSniffer.getValidScopeTokeners()
* @throws PHP_CodeSniffer_Test_Exception If the specified tokens array is \
empty. @@ -94,23 +95,27 @@
public function __construct(array $scopeTokens, array $tokens, \
$listenOutside=false) {
if (empty($scopeTokens) === true) {
- throw new PHP_CodeSniffer_Test_Exception('The scope tokens list cannot \
be empty'); + $error = 'The scope tokens list cannot be empty';
+ throw new PHP_CodeSniffer_Test_Exception($error);
}
if (empty($tokens) === true) {
- throw new PHP_CodeSniffer_Test_Exception('The tokens list cannot be \
empty'); + $error ='The tokens list cannot be empty';
+ throw new PHP_CodeSniffer_Test_Exception($error);
}
$invalidScopeTokens = array_diff($scopeTokens, \
PHP_CodeSniffer_File::getValidScopeOpeners()); if (empty($invalidScopeTokens) === \
false) { $invalid = implode(', ', $invalidScopeTokens);
- throw new PHP_CodeSniffer_Test_Exception("Supplied scope tokens \
[$invalid] are not valid scope opener"); + $error = "Scope tokens \
[$invalid] are not valid scope opener"; + throw new \
PHP_CodeSniffer_Test_Exception($error); }
$invalidScopeTokens = array_intersect($scopeTokens, $tokens);
if (empty($invalidScopeTokens) === false) {
$invalid = implode(', ', $invalidScopeTokens);
- throw new PHP_CodeSniffer_Test_Exception("Supplied scope tokens \
[$invalid] cannot be in the tokens array"); + $error = "Scope tokens \
[$invalid] cant be in the tokens array"; + throw new \
PHP_CodeSniffer_Test_Exception($error); }
$this->_listenOutside = $listenOutside;
@@ -145,8 +150,8 @@
* Processes the tokens that this test is listening for.
*
* @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
- * @param int $stackPtr The position in the stack where this \
token
- * was found.
+ * @param int $stackPtr The position in the stack where this
+ * token was found.
*
* @return void
* @see processTokenWithinScope()
@@ -183,8 +188,8 @@
* listening to.
*
* @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
- * @param int $stackPtr The position in the stack where this \
token
- * was found.
+ * @param int $stackPtr The position in the stack where this
+ * token was found.
* @param int $currScope The position in the tokens array that
* opened the scope that this test is
* listening for.
@@ -199,8 +204,8 @@
* listening to.
*
* @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
- * @param int $stackPtr The position in the stack where this \
token
- * was found.
+ * @param int $stackPtr The position in the stack where this
+ * token was found.
*
* @return void
*/
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractVariableSniff.php?r1=1.9&r2=1.10&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractVariableSniff.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractVariableSniff.php:1.9 \
pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractVariableSniff.php:1.10
--- pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractVariableSniff.php:1.9 Fri Jul \
27 05:36:21 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/Standards/AbstractVariableSniff.php Fri Nov 30 \
01:18:41 2007 @@ -10,12 +10,13 @@
* @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: AbstractVariableSniff.php,v 1.9 2007/07/27 05:36:21 squiz \
Exp $ + * @version CVS: $Id: AbstractVariableSniff.php,v 1.10 2007/11/30 01:18:41 \
squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) {
- throw new PHP_CodeSniffer_Exception('Class \
PHP_CodeSniffer_Standards_AbstractScopeSniff not found'); + $error = 'Class \
PHP_CodeSniffer_Standards_AbstractScopeSniff not found'; + throw new \
PHP_CodeSniffer_Exception($error); }
/**
@@ -66,7 +67,9 @@
*/
public function __construct()
{
- parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION, \
T_VARIABLE, T_DOUBLE_QUOTED_STRING), true); + $listen = array(T_CLASS, \
T_INTERFACE); + $scopes = array(T_FUNCTION, T_VARIABLE, \
T_DOUBLE_QUOTED_STRING); + parent::__construct($listen, $scopes, true);
}//end __construct()
@@ -74,7 +77,8 @@
/**
* Processes the token in the specified PHP_CodeSniffer_File.
*
- * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this \
token was found. + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer \
file where this + * token was found.
* @param int $stackPtr The position where the token was \
found.
* @param array $currScope The current scope opener token.
*
@@ -114,7 +118,8 @@
$this->processVariable($phpcsFile, $stackPtr);
} else if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING) {
// Check to see if this string has a variable in it.
- if (preg_match('|[^\\\]\$[a-zA-Z0-9_]+|', \
$tokens[$stackPtr]['content']) !== 0) { + $pattern = \
'|[^\\\]\$[a-zA-Z0-9_]+|'; + if (preg_match($pattern, \
$tokens[$stackPtr]['content']) !== 0) {
$this->processVariableInString($phpcsFile, $stackPtr);
}
}
@@ -132,7 +137,8 @@
/**
* Processes the token outside the scope in the file.
*
- * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this \
token was found. + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer \
file where this + * token was found.
* @param int $stackPtr The position where the token was \
found.
*
* @return void
@@ -153,7 +159,8 @@
/**
* Called to process class member vars.
*
- * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this \
token was found. + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer \
file where this + * token was found.
* @param int $stackPtr The position where the token was \
found.
*
* @return void
@@ -164,7 +171,8 @@
/**
* Called to process normal member vars.
*
- * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this \
token was found. + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer \
file where this + * token was found.
* @param int $stackPtr The position where the token was \
found.
*
* @return void
@@ -178,7 +186,8 @@
* Note that there may be more than one variable in the string, which will
* result only in one call for the string.
*
- * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this \
token was found. + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer \
file where this + * token was found.
* @param int $stackPtr The position where the double quoted
* string was found.
*
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php?r1=1.16&r2=1.17&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php
diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php:1.16 \
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php:1.17
--- pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php:1.16 Thu \
Nov 15 04:45:28 2007
+++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php Fri \
Nov 30 01:18:41 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: SwitchDeclarationSniff.php,v 1.16 2007/11/15 04:45:28 squiz \
Exp $ + * @version CVS: $Id: SwitchDeclarationSniff.php,v 1.17 2007/11/30 01:18:41 \
squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
@@ -195,7 +195,7 @@
// Make sure this default belongs to us.
if ($default !== false) {
$conditions = array_keys($tokens[$default]['conditions']);
- $owner = array_pop($conditions);
+ $owner = array_pop($conditions);
if ($owner !== $stackPtr) {
$default = false;
}
--
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic