| Conditions | 15 |
| Paths | 8 |
| Total Lines | 48 |
| Code Lines | 25 |
| 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 declare(strict_types=1); |
||
| 53 | public function processNode(Node $node, Scope $scope): array |
||
| 54 | { |
||
| 55 | if (!$scope->isInClass()) { |
||
| 56 | // skip |
||
| 57 | return []; |
||
| 58 | } |
||
| 59 | |||
| 60 | $class = $scope->getClassReflection(); |
||
| 61 | |||
| 62 | if ($class === null || $class->isInterface() || $this->isTestClass($class)) { |
||
| 63 | return []; |
||
| 64 | } |
||
| 65 | |||
| 66 | if (!($node->isPublic() || $node->isProtected()) || $node->isAbstract() || $node->isMagic()) { |
||
| 67 | return []; |
||
| 68 | } |
||
| 69 | |||
| 70 | $methodContent = $this->getMethodContent($node, $scope, $class); |
||
| 71 | $method = $class->getMethod($node->name->name, $scope); |
||
| 72 | |||
| 73 | $classDeprecation = $class->getDeprecatedDescription(); |
||
| 74 | if ($classDeprecation && !$this->handlesDeprecationCorrectly($classDeprecation, $methodContent)) { |
||
| 75 | return [ |
||
| 76 | \sprintf( |
||
| 77 | 'Class "%s" is marked as deprecated, but method "%s" does not call "Feature::triggerDeprecationOrThrow". All public methods of deprecated classes need to trigger a deprecation warning.', |
||
| 78 | $class->getName(), |
||
| 79 | $method->getName() |
||
| 80 | ), |
||
| 81 | ]; |
||
| 82 | } |
||
| 83 | |||
| 84 | $methodDeprecation = $method->getDeprecatedDescription() ?? ''; |
||
| 85 | |||
| 86 | // by default deprecations from parent methods are also available on all implementing methods |
||
| 87 | // we will copy the deprecation to the implementing method, if they also have an affect there |
||
| 88 | $deprecationOfParentMethod = !str_contains($method->getDocComment() ?? '', $methodDeprecation) && !str_contains($method->getDocComment() ?? '', 'inheritdoc'); |
||
| 89 | |||
| 90 | if (!$deprecationOfParentMethod && $methodDeprecation && !$this->handlesDeprecationCorrectly($methodDeprecation, $methodContent)) { |
||
| 91 | return [ |
||
| 92 | \sprintf( |
||
| 93 | 'Method "%s" of class "%s" is marked as deprecated, but does not call "Feature::triggerDeprecationOrThrow". All deprecated methods need to trigger a deprecation warning.', |
||
| 94 | $method->getName(), |
||
| 95 | $class->getName() |
||
| 96 | ), |
||
| 97 | ]; |
||
| 98 | } |
||
| 99 | |||
| 100 | return []; |
||
| 101 | } |
||
| 157 |
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