| Conditions | 18 |
| Paths | 432 |
| Total Lines | 49 |
| Code Lines | 27 |
| 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 |
||
| 130 | private static function doPreload(string $class, array &$preloaded): void |
||
| 131 | { |
||
| 132 | if (isset($preloaded[$class]) || \in_array($class, ['self', 'static', 'parent'], true)) { |
||
| 133 | return; |
||
| 134 | } |
||
| 135 | |||
| 136 | $preloaded[$class] = true; |
||
| 137 | |||
| 138 | try { |
||
| 139 | $r = new ReflectionClass($class); |
||
| 140 | |||
| 141 | if ($r->isInternal()) { |
||
| 142 | return; |
||
| 143 | } |
||
| 144 | |||
| 145 | $r->getConstants(); |
||
| 146 | $r->getDefaultProperties(); |
||
| 147 | |||
| 148 | if (\PHP_VERSION_ID >= 70400) { |
||
| 149 | foreach ($r->getProperties(ReflectionProperty::IS_PUBLIC) as $p) { |
||
| 150 | if (null !== ($t = $p->getType()) && !$t->isBuiltin()) { |
||
|
|
|||
| 151 | \assert($t instanceof ReflectionNamedType); |
||
| 152 | self::doPreload($t->getName(), $preloaded); |
||
| 153 | } |
||
| 154 | } |
||
| 155 | } |
||
| 156 | |||
| 157 | foreach ($r->getMethods(ReflectionMethod::IS_PUBLIC) as $m) { |
||
| 158 | foreach ($m->getParameters() as $p) { |
||
| 159 | if ($p->isDefaultValueAvailable() && $p->isDefaultValueConstant()) { |
||
| 160 | $c = (string) $p->getDefaultValueConstantName(); |
||
| 161 | |||
| 162 | if ($i = \strpos($c, '::')) { |
||
| 163 | self::doPreload(\substr($c, 0, $i), $preloaded); |
||
| 164 | } |
||
| 165 | } |
||
| 166 | |||
| 167 | if (null !== ($t = $p->getType()) && !$t->isBuiltin()) { |
||
| 168 | \assert($t instanceof ReflectionNamedType); |
||
| 169 | self::doPreload($t->getName(), $preloaded); |
||
| 170 | } |
||
| 171 | } |
||
| 172 | |||
| 173 | if (null !== ($t = $m->getReturnType()) && !$t->isBuiltin()) { |
||
| 174 | \assert($t instanceof ReflectionNamedType); |
||
| 175 | self::doPreload($t->getName(), $preloaded); |
||
| 176 | } |
||
| 177 | } |
||
| 178 | } catch (ReflectionException $e) { |
||
| 179 | // ignore missing classes |
||
| 196 |
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.