| Conditions | 14 |
| Paths | 25 |
| Total Lines | 50 |
| 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 |
||
| 218 | private function generateSignature() |
||
| 219 | { |
||
| 220 | if ($this->canBeGenerated()) { |
||
| 221 | $hasBody = $this->getGeneratorProperty('has_body', true); |
||
| 222 | $isAbstract = $this->getGeneratorProperty('abstract', false); |
||
| 223 | $isFinal = $this->getGeneratorProperty('final', false); |
||
| 224 | $isStatic = $this->getGeneratorProperty('static', false); |
||
| 225 | $name = $this->getGeneratorProperty('name'); |
||
| 226 | $parameters = $this->getGeneratorProperty('parameters', []); |
||
| 227 | $visibility = $this->getGeneratorProperty('visibility'); |
||
| 228 | |||
| 229 | //@todo refactor the wired usage for line and block generator |
||
| 230 | $line = $this->getLineGenerator(); |
||
| 231 | |||
| 232 | if ($isAbstract) { |
||
| 233 | $line->add('abstract'); |
||
| 234 | } else if ($isFinal) { |
||
| 235 | $line->add('final'); |
||
| 236 | } |
||
| 237 | |||
| 238 | if (!is_null($visibility)) { |
||
| 239 | $line->add($visibility); |
||
| 240 | } |
||
| 241 | |||
| 242 | if ($isStatic) { |
||
| 243 | $line->add('static'); |
||
| 244 | } |
||
| 245 | |||
| 246 | $parametersLine = $this->getLineGenerator(); |
||
| 247 | $parametersLine->setSeparator(', '); |
||
| 248 | if (is_array($parameters)) { |
||
| 249 | foreach ($parameters as $parameter) { |
||
| 250 | $parameterLine = $this->getLineGenerator(); |
||
| 251 | if ((strlen($parameter['type_hint']) > 0) |
||
| 252 | && (!in_array($parameter['type_hint'], $this->getNotPrintableTypeHints()))) { |
||
| 253 | $parameterLine->add($parameter['type_hint']); |
||
| 254 | } |
||
| 255 | $parameterLine->add(($parameter['is_reference'] ? '&' : '') . '$' . $parameter['name']); |
||
| 256 | if (strlen((string) $parameter['default_value']) > 0) { |
||
| 257 | $parameterLine->add('= ' . (string) $parameter['default_value']); |
||
| 258 | } |
||
| 259 | $parametersLine->add($parameterLine); |
||
| 260 | } |
||
| 261 | } |
||
| 262 | |||
| 263 | $line->add('function ' . $name . '(' . $parametersLine->generate() . ')' . ((($isAbstract) || (!$hasBody)) ? ';' : '')); |
||
| 264 | $block = $this->getBlockGenerator($line); |
||
| 265 | $this->addContent($block); |
||
| 266 | } |
||
| 267 | } |
||
| 268 | } |
||
| 269 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: