| Conditions | 10 |
| Paths | 10 |
| Total Lines | 43 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 49 | public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
|
|
|||
| 50 | { |
||
| 51 | if ($this->supportsBelow('5.6') !== true) { |
||
| 52 | return; |
||
| 53 | } |
||
| 54 | |||
| 55 | $tokens = $phpcsFile->getTokens(); |
||
| 56 | |||
| 57 | $ignore = array( |
||
| 58 | T_DOUBLE_COLON, |
||
| 59 | T_OBJECT_OPERATOR, |
||
| 60 | T_FUNCTION, |
||
| 61 | T_CONST, |
||
| 62 | ); |
||
| 63 | |||
| 64 | $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); |
||
| 65 | if (in_array($tokens[$prevToken]['code'], $ignore) === true) { |
||
| 66 | // Not a call to a PHP function. |
||
| 67 | return; |
||
| 68 | } |
||
| 69 | |||
| 70 | $functionLc = strtolower($tokens[$stackPtr]['content']); |
||
| 71 | if ($functionLc !== 'define') { |
||
| 72 | return; |
||
| 73 | } |
||
| 74 | |||
| 75 | $secondParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 2); |
||
| 76 | if (isset($secondParam['start'], $secondParam['end']) === false) { |
||
| 77 | return; |
||
| 78 | } |
||
| 79 | |||
| 80 | $targetNestingLevel = 0; |
||
| 81 | if (isset($tokens[$secondParam['start']]['nested_parenthesis'])) { |
||
| 82 | $targetNestingLevel = count($tokens[$secondParam['start']]['nested_parenthesis']); |
||
| 83 | } |
||
| 84 | |||
| 85 | $array = $phpcsFile->findNext(array(T_ARRAY, T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1)); |
||
| 86 | if ($array !== false) { |
||
| 87 | if ((isset($tokens[$array]['nested_parenthesis']) === false && $targetNestingLevel === 0) || count($tokens[$array]['nested_parenthesis']) === $targetNestingLevel) { |
||
| 88 | $phpcsFile->addError( |
||
| 89 | 'Constant arrays using define are not allowed in PHP 5.6 or earlier', |
||
| 90 | $array, |
||
| 91 | 'Found' |
||
| 92 | ); |
||
| 97 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths