cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions FunctionCallSignatureSniff.php
/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Sniffs/Methods FunctionCallSignatureSniff.php /PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Tests/Functions
FunctionCallSignatureUnitTest.inc FunctionCallSignatureUnitTest.php /PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Tests/Methods
FunctionCallSignatureUnitTest.inc FunctionCallSignatureUnitTest.php

From: Date: Wed, 27 Dec 2006 23:49:09 +0000
Subject: cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions FunctionCallSignatureSniff.php
/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Sniffs/Methods FunctionCallSignatureSniff.php /PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Tests/Functions
FunctionCallSignatureUnitTest.inc FunctionCallSignatureUnitTest.php /PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Tests/Methods
FunctionCallSignatureUnitTest.inc FunctionCallSignatureUnitTest.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-43855@lists.php.net to get a copy of this message
squiz Wed Dec 27 23:49:09 2006 UTC Added files: /pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions FunctionCallSignatureSniff.php /pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Tests/Functions FunctionCallSignatureUnitTest.inc FunctionCallSignatureUnitTest.php Removed files: /pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Sniffs/Methods FunctionCallSignatureSniff.php /pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Tests/Methods FunctionCallSignatureUnitTest.inc FunctionCallSignatureUnitTest.php Modified files: /pear/PHP_CodeSniffer package.xml Log: Moved sniff from Methods dir to Functions dir

http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/package.xml?r1=1.17&r2=1.18&diff_format=u Index: pear/PHP_CodeSniffer/package.xml diff -u pear/PHP_CodeSniffer/package.xml:1.17 pear/PHP_CodeSniffer/package.xml:1.18 --- pear/PHP_CodeSniffer/package.xml:1.17 Wed Dec 27 23:43:23 2006 +++ pear/PHP_CodeSniffer/package.xml Wed Dec 27 23:49:08 2006 @@ -20,7 +20,7 @@ </maintainers> <release> <version>0.3.0</version> - <date>2006-12-22</date> + <date>2006-12-28</date> <license>BSD License</license> <state>alpha</state> <notes> @@ -35,6 +35,8 @@ - Added ClassCommentSniff to PEAR standard - Added FunctionCommentSniff to PEAR standard - Change MultipleStatementSniff to MultipleStatementAlignmentSniff in PEAR standard + - Replaced Methods directory with Functions directory in Generic and PEAR standards + - also renamed some of the sniffs in those directories - Updated file, class and method comments for all files - Fixed bug #9274 : nested_parenthesis element not set for open and close parenthesis tokens - Fixed bug #9411 : too few pattern characters cause incorrect error report @@ -276,15 +278,13 @@ <file name="FunctionCallArgumentSpacingSniff.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> - <file name="OpeningFunctionBraceSniff.php"> + <file name="FunctionCallSignatureSniff.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> - <file name="ValidDefaultValueSniff.php"> + <file name="OpeningFunctionBraceSniff.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> - </dir> - <dir name="Methods"> - <file name="FunctionCallSignatureSniff.php"> + <file name="ValidDefaultValueSniff.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> </dir> @@ -352,16 +352,14 @@ <file name="FunctionCallArgumentSpacingUnitTest.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> - <file name="ValidDefaultValueUnitTest.inc"/> - <file name="ValidDefaultValueUnitTest.php"> - <replace type="package-info" from="@package_version@" to="version"/> - </file> - </dir> - <dir name="Methods"> <file name="FunctionCallSignatureUnitTest.inc"/> <file name="FunctionCallSignatureUnitTest.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> + <file name="ValidDefaultValueUnitTest.inc"/> + <file name="ValidDefaultValueUnitTest.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> </dir> <dir name="NamingConventions"> <file name="ValidClassNameUnitTest.inc"/> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php <?php /** * PEAR_Sniffs_Functions_FunctionCallSignatureSniff. * * 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: FunctionCallSignatureSniff.php,v 1.1 2006/12/27 23:49:09 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ require_once 'PHP/CodeSniffer/Standards/AbstractPatternSniff.php'; /** * PEAR_Sniffs_Functions_FunctionCallSignatureSniff. * * @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 PEAR_Sniffs_Functions_FunctionCallSignatureSniff implements PHP_CodeSniffer_Sniff { /** * Returns an array of tokens this test wants to listen for. * * @return array */ public function register() { return array(T_STRING); }//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(); // Find the next non-empty token. $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true); if ($tokens[$next]['code'] !== T_OPEN_PARENTHESIS) { // Not a function call. return; } if (isset($tokens[$next]['parenthesis_closer']) === false) { // Not a function call. return; } // Find the previous non-empty token. $previous = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr - 1, null, true); if ($tokens[$previous]['code'] === T_FUNCTION) { // It's a function definition, not a function call. return; } if (($stackPtr + 1) !== $next) { // Checking this: $value = my_function[*](...). $error = 'Space before opening parenthesis of function call prohibited'; $phpcsFile->addError($error, $stackPtr); } if ($tokens[$next + 1]['code'] === T_WHITESPACE) { // Checking this: $value = my_function([*]...). $error = 'Space after opening parenthesis of function call prohibited'; $phpcsFile->addError($error, $stackPtr); } $closer = $tokens[$next]['parenthesis_closer']; if ($tokens[$closer - 1]['code'] === T_WHITESPACE) { // Checking this: $value = my_function(...[*]). $between = $phpcsFile->findNext(T_WHITESPACE, $next + 1, null, true); // Only throw an error if there is some content between the parenthesis. // IE. Checking for this: $value = my_function(). // If there is no content, then we would have thrown an error in the // previous IF statement because it would look like this: // $value = my_function( ). if ($between !== $closer) { $error = 'Space before closing parenthesis of function call prohibited'; $phpcsFile->addError($error, $closer); } } $next = $phpcsFile->findNext(T_WHITESPACE, $closer + 1, null, true); if ($tokens[$next]['code'] === T_SEMICOLON) { if (in_array($tokens[$closer + 1]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true) { $error = 'Space after closing parenthesis of function call prohibited'; $phpcsFile->addError($error, $closer); } } }//end process() }//end class ?> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc <?php test(); test($arg, $arg2); test (); test( ); test() ; test( $arg); test( $arg ); test ( $arg ); if (is_array($arg) === true) { } $something = get($arg1, $arg2); $something = get($arg1, $arg2) ; $something = get($arg1, $arg2) ; // No errors as this test only checks for function calls. public function test () { } make_foo($string/*the string*/, true/*test*/); make_foo($string/*the string*/, true/*test*/ ); make_foo($string /*the string*/, true /*test*/); make_foo(/*the string*/$string, /*test*/true); make_foo( /*the string*/$string, /*test*/true); ?> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php <?php /** * Unit test class for the FunctionCallSignature 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: FunctionCallSignatureUnitTest.php,v 1.1 2006/12/27 23:49:09 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ /** * Unit test class for the FunctionCallSignature 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 PEAR_Tests_Functions_FunctionCallSignatureUnitTest 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, 6 => 1, 7 => 1, 8 => 1, 9 => 2, 10 => 3, 17 => 1, 18 => 1, 27 => 1, 30 => 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 ?>
« previous php.pear.cvs (#43855) next »