class ValidFunctionNameSniff
Same name in this branch
- 11.1.x vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidFunctionNameSniff.php \Drupal\Sniffs\NamingConventions\ValidFunctionNameSniff
- 11.1.x vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php \PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidFunctionNameSniff
Hierarchy
- class \PHP_CodeSniffer\Sniffs\AbstractScopeSniff implements \PHP_CodeSniffer\Sniffs\Sniff
- class \PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidFunctionNameSniff extends \PHP_CodeSniffer\Sniffs\AbstractScopeSniff
- class \PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions\ValidFunctionNameSniff extends \PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidFunctionNameSniff
- class \PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidFunctionNameSniff extends \PHP_CodeSniffer\Sniffs\AbstractScopeSniff
Expanded class hierarchy of ValidFunctionNameSniff
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ Squiz/ Sniffs/ NamingConventions/ ValidFunctionNameSniff.php, line 16
Namespace
PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventionsView source
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
* found.
*
* @return void
*/
protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) {
$functionName = $phpcsFile->getDeclarationName($stackPtr);
if ($functionName === null) {
return;
}
$errorData = [
$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);
$functionName = ltrim($functionName, '_');
}
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()
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
AbstractScopeSniff::$listenOutside | private | property | True if this test should fire on tokens outside of the scope. | |
AbstractScopeSniff::$scopeTokens | private | property | The type of scope opener tokens that this test wishes to listen to. | |
AbstractScopeSniff::$tokens | private | property | The token types that this test wishes to listen to within the scope. | |
AbstractScopeSniff::process | final public | function | Processes the tokens that this test is listening for. | Overrides Sniff::process |
AbstractScopeSniff::register | final public | function | The method that is called to register the tokens this test wishes to listen to. |
Overrides Sniff::register |
ValidFunctionNameSniff::$magicFunctions | protected | property | A list of all PHP magic functions. | |
ValidFunctionNameSniff::$magicMethods | protected | property | A list of all PHP magic methods. | |
ValidFunctionNameSniff::processTokenOutsideScope | protected | function | Processes the tokens outside the scope. | Overrides ValidFunctionNameSniff::processTokenOutsideScope |
ValidFunctionNameSniff::processTokenWithinScope | protected | function | Processes the tokens within the scope. | Overrides AbstractScopeSniff::processTokenWithinScope |
ValidFunctionNameSniff::__construct | public | function | Constructs a PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff. | Overrides AbstractScopeSniff::__construct |