Conditions | 16 |
Paths | 17 |
Total Lines | 45 |
Code Lines | 25 |
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 |
||
110 | private function resolveParameters(array $refParameters, array $arguments): array |
||
111 | { |
||
112 | $parameters = []; |
||
113 | |||
114 | foreach ($refParameters as $index => $parameter) { |
||
115 | $typeHint = $parameter->getType(); |
||
116 | |||
117 | if ($typeHint instanceof \ReflectionUnionType) { |
||
118 | foreach ($typeHint->getTypes() as $unionType) { |
||
119 | if (isset($arguments[$unionType->getName()])) { |
||
120 | $parameters[$index] = $arguments[$unionType->getName()]; |
||
121 | |||
122 | continue 2; |
||
123 | } |
||
124 | |||
125 | if (null !== $this->container && $this->container->has($unionType->getName())) { |
||
126 | $parameter[$index] = $this->container->get($unionType->getName()); |
||
127 | |||
128 | continue 2; |
||
129 | } |
||
130 | } |
||
131 | } elseif ($typeHint instanceof \ReflectionNamedType) { |
||
132 | if (isset($arguments[$typeHint->getName()])) { |
||
133 | $parameters[$index] = $arguments[$typeHint->getName()]; |
||
134 | |||
135 | continue; |
||
136 | } |
||
137 | |||
138 | if (null !== $this->container && $this->container->has($typeHint->getName())) { |
||
139 | $parameter[$index] = $this->container->get($typeHint->getName()); |
||
140 | |||
141 | continue; |
||
142 | } |
||
143 | } |
||
144 | |||
145 | if (isset($arguments[$parameter->getName()])) { |
||
146 | $parameters[$index] = $arguments[$parameter->getName()]; |
||
147 | } elseif (null !== $this->container && $this->container->has($parameter->getName())) { |
||
148 | $parameters[$index] = $this->container->get($typeHint->getName()); |
||
149 | } elseif ($parameter->allowsNull() && !$parameter->isDefaultValueAvailable()) { |
||
150 | $parameters[$index] = null; |
||
151 | } |
||
152 | } |
||
153 | |||
154 | return $parameters; |
||
155 | } |
||
157 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.