Blame | Letzte Änderung | Log anzeigen | RSS feed
<?php/*** Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff.** 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: ValidFunctionNameSniff.php 240383 2007-07-27 05:38:59Z squiz $* @link http://pear.php.net/package/PHP_CodeSniffer*/if (class_exists('PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff', true) === false) {throw new PHP_CodeSniffer_Exception('Class PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff not found');}/*** Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff.** Ensures method names are correct depending on whether they are public* or private, and that functions are named correctly.** @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: 1.2.1* @link http://pear.php.net/package/PHP_CodeSniffer*/class Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff extends PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff{/*** Processes the tokens outside the scope.** @param PHP_CodeSniffer_File $phpcsFile The file being processed.* @param int $stackPtr The position where this token was* found.** @return void*/protected function processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr){$functionName = $phpcsFile->getDeclarationName($stackPtr);// Does this function claim to be magical?if (preg_match('|^__|', $functionName) !== 0) {$magicPart = substr($functionName, 2);$error = "Function name \"$functionName\" is invalid; only PHP magic methods should be prefixed with a double underscore.";$phpcsFile->addError($error, $stackPtr);return;}if (PHP_CodeSniffer::isCamelCaps($functionName, false, true, false) === false) {$error = "Function name \"$functionName\" is not in camel caps format";$phpcsFile->addError($error, $stackPtr);}}//end processTokenOutsideScope()}//end class?>