Class VariablesSniff
Ensure that the variables are responds to the following requirements:
- If variables are local and used only in a module scope, they should be located in the module file, in the beginning of the general comment.
- All variable names must be lowercase
http://devdocs.magento.com/guides/v2.0/coding-standards/code-standard-less.html#naming
Definition at line 23 of file VariablesSniff.php.
◆ process()
process |
( |
File |
$phpcsFile, |
|
|
|
$stackPtr |
|
) |
| |
{}
Definition at line 43 of file VariablesSniff.php.
45 $tokens = $phpcsFile->getTokens();
46 $currentToken =
$tokens[$stackPtr];
48 $nextColon = $phpcsFile->findNext(T_COLON, $stackPtr);
49 $nextSemicolon = $phpcsFile->findNext(T_SEMICOLON, $stackPtr);
50 if ((
false === $nextColon) || (
false === $nextSemicolon)) {
54 $isVariableDeclaration = ($currentToken[
'line'] ===
$tokens[$nextColon][
'line'])
55 && ($currentToken[
'line'] ===
$tokens[$nextSemicolon][
'line'])
56 && (T_STRING ===
$tokens[$stackPtr + 1][
'code'])
57 && (T_COLON ===
$tokens[$stackPtr + 2][
'code']);
59 if (!$isVariableDeclaration) {
63 $classBefore = $phpcsFile->findPrevious(T_STYLE, $stackPtr);
64 if (
false !== $classBefore) {
66 'Variable declaration located not in the beginning of general comments',
72 $variableName =
$tokens[$stackPtr + 1][
'content'];
73 if (preg_match(
'/[A-Z]/', $variableName)) {
75 'Variable declaration contains uppercase symbols',
◆ register()
◆ $supportedTokenizers
The documentation for this class was generated from the following file:
- vendor/magento/magento2-base/dev/tests/static/framework/Magento/Sniffs/Less/VariablesSniff.php