Source for file CamelCapsMethodNameSniff.php
Documentation is available at CamelCapsMethodNameSniff.php
* Ensures method names are defined using camel case.
* @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\PSR1\Sniffs\Methods;
use PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff as GenericCamelCapsFunctionNameSniff;
use PHP_CodeSniffer\Util\Common;
use PHP_CodeSniffer\Files\File;
class CamelCapsMethodNameSniff extends GenericCamelCapsFunctionNameSniff
* Processes the tokens within the scope.
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being processed.
* @param int $stackPtr The position where this token was
* @param int $currScope The position of the current scope.
protected function processTokenWithinScope (File $phpcsFile, $stackPtr, $currScope)
$methodName = $phpcsFile->getDeclarationName ($stackPtr);
if ($methodName === null ) {
if (isset ($this->magicMethods[$magicPart]) === true
|| isset ($this->methodsDoubleUnderscore[$magicPart]) === true
$testName = ltrim($methodName, '_');
if ($testName !== '' && Common ::isCamelCaps ($testName, false , true , false ) === false ) {
$error = 'Method name "%s" is not in camel caps format';
$className = $phpcsFile->getDeclarationName ($currScope);
$errorData = array ($className. '::'. $methodName);
$phpcsFile->addError ($error, $stackPtr, 'NotCamelCaps', $errorData);
$phpcsFile->recordMetric ($stackPtr, 'CamelCase method name', 'no');
$phpcsFile->recordMetric ($stackPtr, 'CamelCase method name', 'yes');
}//end processTokenWithinScope()
* 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)
}//end processTokenOutsideScope()
Documentation generated on Mon, 11 Mar 2019 15:27:16 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|