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