cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators ComparisonOperatorUsageSniff.php
IncrementDecrementUsageSniff.php ValidLogicalOperatorsSniff.php /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators
ComparisonOperatorUsageUnitTest.inc ComparisonOperatorUsageUnitTest.php IncrementDecrementUsageUnitTest.inc IncrementDecrementUsageUnitTest.php
ValidLogicalOperatorsUnitTest.inc ValidLogicalOperatorsUnitTest.php

From: Date: Tue, 02 Jan 2007 01:16:15 +0000
Subject: cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators ComparisonOperatorUsageSniff.php
IncrementDecrementUsageSniff.php ValidLogicalOperatorsSniff.php /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators
ComparisonOperatorUsageUnitTest.inc ComparisonOperatorUsageUnitTest.php IncrementDecrementUsageUnitTest.inc IncrementDecrementUsageUnitTest.php
ValidLogicalOperatorsUnitTest.inc ValidLogicalOperatorsUnitTest.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-43917@lists.php.net to get a copy of this message
squiz Tue Jan 2 01:16:15 2007 UTC Added files: /pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators ComparisonOperatorUsageSniff.php IncrementDecrementUsageSniff.php ValidLogicalOperatorsSniff.php /pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators ComparisonOperatorUsageUnitTest.inc ComparisonOperatorUsageUnitTest.php IncrementDecrementUsageUnitTest.inc IncrementDecrementUsageUnitTest.php ValidLogicalOperatorsUnitTest.inc ValidLogicalOperatorsUnitTest.php Modified files: /pear/PHP_CodeSniffer package.xml Log: Sniff added to Squiz coding standard

http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/package.xml?r1=1.22&r2=1.23&diff_format=u Index: pear/PHP_CodeSniffer/package.xml diff -u pear/PHP_CodeSniffer/package.xml:1.22 pear/PHP_CodeSniffer/package.xml:1.23 --- pear/PHP_CodeSniffer/package.xml:1.22 Tue Jan 2 00:10:14 2007 +++ pear/PHP_CodeSniffer/package.xml Tue Jan 2 01:16:15 2007 @@ -512,6 +512,17 @@ <replace type="package-info" from="@package_version@" to="version"/> </file> </dir> + <dir name="Operators"> + <file name="ComparisonOperatorUsageSniff.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + <file name="IncrementDecrementUsageSniff.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + <file name="ValidLogicalOperatorsSniff.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + </dir> <dir name="PHP"> <file name="DisallowObEndFlushSniff.php"> <replace type="package-info" from="@package_version@" to="version"/> @@ -704,6 +715,20 @@ <replace type="package-info" from="@package_version@" to="version"/> </file> </dir> + <dir name="Operators"> + <file name="ComparisonOperatorUsageUnitTest.inc"/> + <file name="ComparisonOperatorUsageUnitTest.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + <file name="IncrementDecrementUsageUnitTest.inc"/> + <file name="IncrementDecrementUsageUnitTest.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + <file name="ValidLogicalOperatorsUnitTest.inc"/> + <file name="ValidLogicalOperatorsUnitTest.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + </dir> <dir name="PHP"> <file name="DisallowObEndFlushUnitTest.inc"/> <file name="DisallowObEndFlushUnitTest.php"> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php <?php /** * A Sniff to enforce the use of IDENTICAL type operators rather than EQUAL operators. * * PHP version 5 * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @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: ComparisonOperatorUsageSniff.php,v 1.1 2007/01/02 01:16:15 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ require_once 'PHP/CodeSniffer/Sniff.php'; /** * A Sniff to enforce the use of IDENTICAL type operators rather than EQUAL operators. * * The use of === true is enforced over implicit true statements, * for example: * * <code> * if ($a) * { * ... * } * </code> * * should be: * * <code> * if ($a === true) * { * ... * } * </code> * * It also enforces the use of === false over ! operators. * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @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 Release: @package_version@ * @link http://pear.php.net/package/PHP_CodeSniffer */ class Squiz_Sniffs_Operators_ComparisonOperatorUsageSniff implements PHP_CodeSniffer_Sniff { /** * A list of valid comparison operators. * * @var array */ private static $_validOps = array( T_IS_IDENTICAL, T_IS_NOT_IDENTICAL, T_LESS_THAN, T_GREATER_THAN, T_IS_GREATER_OR_EQUAL, T_IS_SMALLER_OR_EQUAL, ); /** * A list of invalid operators with their alternatives. * * @var array(int => string) */ private static $_invalidOps = array( T_IS_EQUAL => '===', T_IS_NOT_EQUAL => '!==', T_BOOLEAN_NOT => '=== FALSE', ); /** * Registers the token types that this sniff wishes to listen to. * * @return array */ public function register() { return array( T_IF, T_INLINE_THEN, ); }//end register() /** * Process the tokens that this sniff is listening for. * * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found. * @param int $stackPtr The position in the stack where the token * was found. * * @return void */ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); if ($tokens[$stackPtr]['code'] === T_INLINE_THEN) { $end = $phpcsFile->findPrevious(T_CLOSE_PARENTHESIS, $stackPtr - 1); $start = $tokens[$end]['parenthesis_opener']; } else { $start = $tokens[$stackPtr]['parenthesis_opener']; $end = $tokens[$stackPtr]['parenthesis_closer']; } $requiredOps = 0; $foundOps = 0; for ($i = $start; $i <= $end; $i++) { $type = $tokens[$i]['code']; if (in_array($type, array_keys(self::$_invalidOps)) === true) { $error = 'Operator '.$tokens[$i]['content'].' prohibited;'; $error .= ' use '.self::$_invalidOps[$type].' instead'; $phpcsFile->addError($error, $stackPtr); $foundOps++; } else if (in_array($type, self::$_validOps) === true) { $foundOps++; } if ($tokens[$i]['code'] === T_BOOLEAN_AND || $tokens[$i]['code'] === T_BOOLEAN_OR) { $requiredOps++; // If we get to here and we have not found the right number of // comparison operators, then we must have had an implicit // true operation ie. if ($a) instead of the preferred // if ($a === true), so let's add an error. if ($requiredOps !== $foundOps) { $error = 'Implicit true comparisons prohibited; use === TRUE instead'; $phpcsFile->addError($error, $stackPtr); $foundOps++; } } }//end for $requiredOps++; if ($requiredOps !== $foundOps) { $error = 'Implicit true comparisons prohibited; use === TRUE instead'; $phpcsFile->addError($error, $stackPtr); } }//end process() }//end class ?> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php <?php /** * Squiz_Sniffs_Operators_IncrementDecrementUsageSniff. * * PHP version 5 * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @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: IncrementDecrementUsageSniff.php,v 1.1 2007/01/02 01:16:15 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ require_once 'PHP/CodeSniffer/Sniff.php'; /** * Squiz_Sniffs_Operators_IncrementDecrementUsageSniff. * * Tests that the ++ operators are used when possible. * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @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 Release: @package_version@ * @link http://pear.php.net/package/PHP_CodeSniffer */ class Squiz_Sniffs_Operators_IncrementDecrementUsageSniff implements PHP_CodeSniffer_Sniff { /** * Returns an array of tokens this test wants to listen for. * * @return array */ public function register() { return array( T_EQUAL, T_PLUS_EQUAL, T_MINUS_EQUAL ); }//end register() /** * Processes this test, when one of its tokens is encountered. * * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. * @param int $stackPtr The position of the current token in the * stack passed in $tokens. * * @return void */ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $assignedVar = $phpcsFile->findPrevious(array(T_VARIABLE), $stackPtr - 1, null, false); // Not an assignment, return. if ($assignedVar === false) { return; } $statementEnd = $phpcsFile->findNext(array(T_SEMICOLON, T_CLOSE_PARENTHESIS, T_CLOSE_SQUARE_BRACKET, T_CLOSE_CURLY_BRACKET), $stackPtr, null, false); // If there is anything other than variables, numbers, spaces or operators we need to return. $noiseTokens = $phpcsFile->findNext(array(T_LNUMBER, T_VARIABLE, T_WHITESPACE, T_PLUS, T_MINUS, T_OPEN_PARENTHESIS), $stackPtr + 1, $statementEnd, true); if ($noiseTokens !== false) { return; } if ($tokens[$stackPtr]['code'] == T_EQUAL) { $nextVar = ($stackPtr + 1); $previousVariable = ($stackPtr + 1); $variableCount = 0; while (($nextVar = $phpcsFile->findNext(array(T_VARIABLE), $nextVar + 1, $statementEnd, false)) !== false) { $previousVariable = $nextVar; $variableCount++; } if ($variableCount !== 1) { return; } $nextVar = $previousVariable; if ($tokens[$nextVar]['content'] !== $tokens[$assignedVar]['content']) { return; } } // We have only one variable, and it's the same as what is being assigned, // so we need to check what is being added or subtracted. $nextNumber = ($stackPtr + 1); $previousNumber = ($stackPtr + 1); $numberCount = 0; while (($nextNumber = $phpcsFile->findNext(array(T_LNUMBER), $nextNumber + 1, $statementEnd, false)) !== false) { $previousNumber = $nextNumber; $numberCount++; } if ($numberCount !== 1) { return; } $nextNumber = $previousNumber; if ($tokens[$nextNumber]['content'] === '1') { if ($tokens[$stackPtr]['code'] == T_EQUAL) { $operator = $tokens[$phpcsFile->findNext(array(T_PLUS, T_MINUS), $stackPtr + 1, $statementEnd, false)]['content']; } else { $operator = substr($tokens[$stackPtr]['content'], 0, 1); } $expected = $tokens[$assignedVar]['content'].$operator.$operator; $found = $phpcsFile->getTokensAsString($assignedVar, ($statementEnd - $assignedVar + 1)); if ($operator === '+') { $error = 'Increment'; } else { $error = 'Decrement'; } $error .= " operators should be used where possible; found \"$found\" but expected \"$expected\""; $phpcsFile->addError($error, $stackPtr); } }//end process() }//end class ?> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php <?php /** * Squiz_Sniffs_Operators_ValidLogicalOperatorsSniff. * * PHP version 5 * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @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: ValidLogicalOperatorsSniff.php,v 1.1 2007/01/02 01:16:15 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ require_once 'PHP/CodeSniffer/Sniff.php'; /** * Squiz_Sniffs_Operators_ValidLogicalOperatorsSniff. * * Checks to ensure that the logical operators 'and' and 'or' are not used. * Use the && and || operators instead. * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @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 Release: @package_version@ * @link http://pear.php.net/package/PHP_CodeSniffer */ class Squiz_Sniffs_Operators_ValidLogicalOperatorsSniff implements PHP_CodeSniffer_Sniff { /** * Returns an array of tokens this test wants to listen for. * * @return array */ public function register() { return array( T_LOGICAL_AND, T_LOGICAL_OR, ); }//end register() /** * Processes this test, when one of its tokens is encountered. * * @param PHP_CodeSniffer_File $phpcsFile The current file being scanned. * @param int $stackPtr The position of the current token in the * stack passed in $tokens. * * @return void */ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $replacements = array( 'and' => '&&', 'or' => '||', ); $operator = $tokens[$stackPtr]['content']; $replacement = $replacements[$operator]; $error = "Logical operator \"$operator\" is prohibited; use \"$replacement\" instead"; $phpcsFile->addError($error, $stackPtr); }//end process() }//end class ?> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc <?php if ($value === TRUE) { } else if ($value === FALSE) { } if ($value == TRUE) { } else if ($value == FALSE) { } if ($value) { } else if (!$value) { } if (is_array($array) === TRUE) { } else if (myFunction($value) === FALSE) { } if (is_array($array) == TRUE) { } else if (myFunction($value) == FALSE) { } if (is_array($array)) { } else if (!myFunction($value)) { } if ($value === TRUE || $other === FALSE) { } if ($value == TRUE || $other == FALSE) { } if ($value || !$other) { } if ($one === TRUE || $two === TRUE || $three === FALSE || $four === TRUE) { } if ($one || $two || !$three || $four) { } ?> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php <?php /** * Unit test class for the ComparionOperatorUsage sniff. * * PHP version 5 * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @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: ComparisonOperatorUsageUnitTest.php,v 1.1 2007/01/02 01:16:15 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ /** * Unit test class for the ComparionOperatorUsage sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @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 Release: @package_version@ * @link http://pear.php.net/package/PHP_CodeSniffer */ class Squiz_Tests_Operators_ComparisonOperatorUsageUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * * @return array(int => int) */ public function getErrorList() { return array( 6 => 1, 7 => 1, 10 => 1, 11 => 1, 18 => 1, 19 => 1, 22 => 1, 23 => 1, 29 => 2, 32 => 2, 38 => 4, ); }//end getErrorList() /** * Returns the lines where warnings should occur. * * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * * @return array(int => int) */ public function getWarningList() { return array(); }//end getWarningList() }//end class ?> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc <?php $var = ($var + 1); $var = ($one + 1); $var = ($var + 2); $var = ($one + $two + 1); $var += 1; $var += 2; $var += $one; $var += (1 + 2) $var = myFunction($var, ($one + 1)); $var = ($var - 1); $var = ($one - 1); $var = ($var - 2); $var = ($one - $two - 1); $var -= 1; $var -= 2; $var -= $one; $var -= (1 + 2) $var = myFunction($var, ($one - 1)); ?> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php <?php /** * Unit test class for the IncrementDecrementUsage sniff. * * PHP version 5 * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @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: IncrementDecrementUsageUnitTest.php,v 1.1 2007/01/02 01:16:15 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ /** * Unit test class for the IncrementDecrementUsage sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @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 Release: @package_version@ * @link http://pear.php.net/package/PHP_CodeSniffer */ class Squiz_Tests_Operators_IncrementDecrementUsageUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * * @return array(int => int) */ public function getErrorList() { return array( 2 => 1, 6 => 1, 12 => 1, 16 => 1, ); }//end getErrorList() /** * Returns the lines where warnings should occur. * * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * * @return array(int => int) */ public function getWarningList() { return array(); }//end getWarningList() }//end class ?> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.inc?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.inc +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.inc <?php if ($value === TRUE || $other === FALSE) { } if ($value === TRUE or $other === FALSE) { } if ($value === TRUE && $other === FALSE) { } if ($value === TRUE and $other === FALSE) { } if ($one === TRUE && ($two === TRUE || $three === TRUE)) { } if ($one === TRUE and ($two === TRUE or $three === TRUE)) { } ?> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php <?php /** * Unit test class for the ValidLogicalOperators sniff. * * PHP version 5 * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @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: ValidLogicalOperatorsUnitTest.php,v 1.1 2007/01/02 01:16:15 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ /** * Unit test class for the ValidLogicalOperators sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @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 Release: @package_version@ * @link http://pear.php.net/package/PHP_CodeSniffer */ class Squiz_Tests_Operators_ValidLogicalOperatorsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * * @return array(int => int) */ public function getErrorList() { return array( 5 => 1, 11 => 1, 17 => 2, ); }//end getErrorList() /** * Returns the lines where warnings should occur. * * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * * @return array(int => int) */ public function getWarningList() { return array(); }//end getWarningList() }//end class ?>
« previous php.pear.cvs (#43917) next »