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