Source for file ValidFunctionNameSniff.php
Documentation is available at ValidFunctionNameSniff.php
* Ensures method names are correct.
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions;
use PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidFunctionNameSniff as PEARValidFunctionNameSniff;
use PHP_CodeSniffer\Util\Common;
use PHP_CodeSniffer\Files\File;
class ValidFunctionNameSniff extends PEARValidFunctionNameSniff
* Processes the tokens outside the scope.
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being processed.
* @param int $stackPtr The position where this token was
protected function processTokenOutsideScope (File $phpcsFile, $stackPtr)
$functionName = $phpcsFile->getDeclarationName ($stackPtr);
if ($functionName === null ) {
$errorData = array ($functionName);
// Does this function claim to be magical?
if (preg_match('|^__[^_]|', $functionName) !== 0 ) {
$error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
$phpcsFile->addError ($error, $stackPtr, 'DoubleUnderscore', $errorData);
if (Common ::isCamelCaps ($functionName, false , true , false ) === false ) {
$error = 'Function name "%s" is not in camel caps format';
$phpcsFile->addError ($error, $stackPtr, 'NotCamelCaps', $errorData);
}//end processTokenOutsideScope()
Documentation generated on Mon, 11 Mar 2019 15:27:51 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|