| Conditions | 12 |
| Paths | 28 |
| Total Lines | 40 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 31 | protected function getAliases(object $attribute, \ReflectionMethod $method): array |
||
| 32 | { |
||
| 33 | $alias = $attribute->alias ?? null; |
||
| 34 | |||
| 35 | $aliases = []; |
||
| 36 | if ($alias !== null) { |
||
| 37 | $aliases[] = $alias; |
||
| 38 | } |
||
| 39 | |||
| 40 | $attrs = $method->getAttributes(name: BindAlias::class); |
||
| 41 | foreach ($attrs as $attr) { |
||
| 42 | $aliases = [...$aliases, ...$attr->newInstance()->aliases]; |
||
| 43 | } |
||
| 44 | |||
| 45 | // If no aliases are provided, we will use the return type as the alias. |
||
| 46 | if (\count($aliases) > 0 && !$attribute->aliasesFromReturnType) { |
||
| 47 | return \array_unique(\array_filter($aliases)); |
||
| 48 | } |
||
| 49 | |||
| 50 | $type = $method->getReturnType(); |
||
| 51 | |||
| 52 | if ($type instanceof \ReflectionUnionType || $type instanceof \ReflectionIntersectionType) { |
||
| 53 | foreach ($type->getTypes() as $type) { |
||
| 54 | if ($type->isBuiltin()) { |
||
| 55 | continue; |
||
| 56 | } |
||
| 57 | |||
| 58 | $aliases[] = $type->getName(); |
||
| 59 | } |
||
| 60 | } elseif ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) { |
||
| 61 | $aliases[] = $type->getName(); |
||
| 62 | } |
||
| 63 | |||
| 64 | if ($aliases === []) { |
||
| 65 | throw new \LogicException( |
||
| 66 | "No alias provided for binding {$method->getDeclaringClass()->getName()}::{$method->getName()}", |
||
| 67 | ); |
||
| 68 | } |
||
| 69 | |||
| 70 | return \array_unique(\array_filter($aliases)); |
||
| 71 | } |
||
| 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