| Conditions | 10 |
| Paths | 8 |
| Total Lines | 44 |
| Code Lines | 26 |
| 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 |
||
| 46 | public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
|
|
|||
| 47 | { |
||
| 48 | if ($this->supportsBelow('5.3') === false) { |
||
| 49 | return; |
||
| 50 | } |
||
| 51 | |||
| 52 | $tokens = $phpcsFile->getTokens(); |
||
| 53 | |||
| 54 | // Next non-empty token should be the open parenthesis. |
||
| 55 | $openParenthesis = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true); |
||
| 56 | if ($openParenthesis === false || $tokens[$openParenthesis]['code'] !== T_OPEN_PARENTHESIS) { |
||
| 57 | return; |
||
| 58 | } |
||
| 59 | |||
| 60 | // Don't throw errors during live coding. |
||
| 61 | if (isset($tokens[$openParenthesis]['parenthesis_closer']) === false) { |
||
| 62 | return; |
||
| 63 | } |
||
| 64 | |||
| 65 | // Is this T_STRING really a function or method call ? |
||
| 66 | $prevToken = $phpcsFile->findPrevious(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); |
||
| 67 | if ($prevToken !== false && in_array($tokens[$prevToken]['code'], array(T_DOUBLE_COLON, T_OBJECT_OPERATOR), true) === false) { |
||
| 68 | $ignore = array( |
||
| 69 | T_FUNCTION, |
||
| 70 | T_CONST, |
||
| 71 | T_USE, |
||
| 72 | T_NEW, |
||
| 73 | T_CLASS, |
||
| 74 | T_INTERFACE, |
||
| 75 | ); |
||
| 76 | |||
| 77 | if (in_array($tokens[$prevToken]['code'], $ignore, true) === true) { |
||
| 78 | // Not a call to a PHP function or method. |
||
| 79 | return; |
||
| 80 | } |
||
| 81 | } |
||
| 82 | |||
| 83 | $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer']; |
||
| 84 | $nextNonEmpty = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($closeParenthesis + 1), null, true, null, true); |
||
| 85 | if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['type'] === 'T_OPEN_SQUARE_BRACKET') { |
||
| 86 | $phpcsFile->addError( |
||
| 87 | 'Function array dereferencing is not present in PHP version 5.3 or earlier', |
||
| 88 | $nextNonEmpty, |
||
| 89 | 'Found' |
||
| 90 | ); |
||
| 95 |
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