| Conditions | 14 |
| Paths | 520 |
| Total Lines | 74 |
| Code Lines | 47 |
| Lines | 8 |
| Ratio | 10.81 % |
| 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 |
||
| 33 | protected function render() { |
||
| 34 | /** @var Trait_ $trait */ |
||
| 35 | $trait = $this->element; |
||
| 36 | |||
| 37 | $docBlock = $trait->getDocBlock(); |
||
| 38 | |||
| 39 | $this->addH1(self::escape($trait->getFqsen())); |
||
| 40 | |||
| 41 | $namespace = str_replace('\\' . $trait->getName(), '', $trait->getFqsen()); |
||
| 42 | if($namespace !== '') { |
||
| 43 | $this->beginPhpDomain('namespace', substr($namespace, 1), false); |
||
| 44 | } |
||
| 45 | |||
| 46 | $this->beginPhpDomain('trait', $trait->getName(), false); |
||
| 47 | |||
| 48 | $this->indent(); |
||
| 49 | if ($docBlock) { |
||
| 50 | $this |
||
| 51 | ->addLine($docBlock->getDescription()) |
||
| 52 | ->addLine(); |
||
| 53 | } |
||
| 54 | |||
| 55 | $usedTraits = ''; |
||
| 56 | foreach ($trait->getUsedTraits() as $trait) { |
||
| 57 | $usedTraits .= $this->getLink('trait', $trait) . ' '; |
||
| 58 | } |
||
| 59 | $this->addFieldList('Traits', $usedTraits); |
||
| 60 | |||
| 61 | $this->unindent(); |
||
| 62 | $this->addLine(); |
||
| 63 | $this->addLine(); |
||
| 64 | |||
| 65 | $this->addProperties($trait->getProperties()); |
||
|
|
|||
| 66 | |||
| 67 | $this->addH2('Methods'); |
||
| 68 | /* Render methods of a trait */ |
||
| 69 | foreach ($trait->getMethods() as $method) { |
||
| 70 | $docBlock = $method->getDocBlock(); |
||
| 71 | $params = []; |
||
| 72 | if($docBlock !== null) { |
||
| 73 | /** @var Param $param */ |
||
| 74 | foreach ($docBlock->getTagsByName('param') as $param) { |
||
| 75 | $params[$param->getVariableName()] = $param; |
||
|
1 ignored issue
–
show
|
|||
| 76 | } |
||
| 77 | } |
||
| 78 | $args = ''; |
||
| 79 | /** @var Argument $argument */ |
||
| 80 | foreach ($method->getArguments() as $argument) { |
||
| 81 | // TODO: defaults, types |
||
| 82 | $args .= ' $' . $argument->getName() . ', '; |
||
| 83 | } |
||
| 84 | $args = substr($args, 0, -2); |
||
| 85 | |||
| 86 | $modifiers = $method->getVisibility(); |
||
| 87 | $modifiers .= $method->isAbstract() ? ' abstract' : ''; |
||
| 88 | $modifiers .= $method->isFinal() ? ' final' : ''; |
||
| 89 | $modifiers .= $method->isStatic() ? ' static' : ''; |
||
| 90 | $this->addLine('.. rst-class:: ' . $modifiers)->addLine(); |
||
| 91 | $this->indent(); |
||
| 92 | $this->beginPhpDomain('method', $method->getName().'('.$args.')'); |
||
| 93 | $this->addDocBlockDescription($docBlock); |
||
| 94 | View Code Duplication | if (!empty($params)) { |
|
| 95 | foreach ($method->getArguments() as $argument) { |
||
| 96 | /** @var Param $param */ |
||
| 97 | $param = $params[$argument->getName()]; |
||
| 98 | if ($param !== null) |
||
| 99 | $this->addMultiline(':param ' . $param->getType() . ' $' . $argument->getName() . ': ' . $param->getDescription(), true); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | $this->endPhpDomain('method'); |
||
| 103 | $this->unindent(); |
||
| 104 | |||
| 105 | } |
||
| 106 | $this->endPhpDomain(); //trait |
||
| 107 | } |
||
| 109 | } |
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.