Conditions | 17 |
Paths | 514 |
Total Lines | 44 |
Code Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Changes | 6 | ||
Bugs | 1 | Features | 3 |
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 |
||
158 | public function render($params = []) |
||
159 | { |
||
160 | $this->params = $params; |
||
161 | $className = $this->className ? $this->className : $this->formClassName(); |
||
162 | if (!$className) { |
||
163 | throw new \Exception('The class name was not set, update $className parameter or implement formClassName()'); |
||
164 | } |
||
165 | $class = $this->getPhpClass($className); |
||
166 | if ($extends = ($this->extends ? $this->extends : $this->formExtends())) { |
||
167 | $this->phpClass->setExtends($extends); |
||
168 | } |
||
169 | $reflection = new \ReflectionClass($this); |
||
170 | foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { |
||
171 | if (!in_array($method->name, $this->exceptRenderMethods)) { |
||
172 | $result = call_user_func([$this, $method->name], $class->addMethod($method->name)); |
||
173 | if ($result === false) { |
||
174 | $methods = $class->getMethods(); |
||
175 | unset($methods[$method->name]); |
||
176 | $class->setMethods($methods); |
||
177 | } |
||
178 | } |
||
179 | } |
||
180 | $this->applyClassProperties($class); |
||
181 | foreach (array_filter($this->classUses()) as $alias => $namespace) { |
||
182 | $this->phpNamespace->addUse($namespace, is_numeric($alias) ? null : $alias); |
||
183 | } |
||
184 | foreach ($this->phpDocComments() as $comment) { |
||
185 | $this->phpClass->addComment($comment); |
||
186 | } |
||
187 | |||
188 | foreach (array_filter($this->classConstants()) as $constant => $value) { |
||
189 | $this->phpClass->addConstant($constant, $value); |
||
190 | } |
||
191 | foreach (array_filter($this->classTraits()) as $trait => $resolutions) { |
||
192 | $this->phpClass->addTrait(is_numeric($trait) ? $resolutions : $trait, is_numeric($trait) ? [] : $resolutions); |
||
193 | } |
||
194 | foreach (array_filter($this->classImplements()) as $implement) { |
||
195 | $this->phpClass->addImplement($implement); |
||
196 | } |
||
197 | $this->classAfterRender(); |
||
198 | $generatedBy = $this->classGeneratedBy(); |
||
199 | $this->phpFile->addComment(is_array($generatedBy) ? join("\n", $generatedBy) : $generatedBy); |
||
200 | $this->output = $this->formOutputPath(); |
||
201 | return (string)$this->phpFile; |
||
202 | } |
||
262 | } |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.