| Conditions | 14 |
| Paths | 8 |
| Total Lines | 49 |
| Code Lines | 29 |
| 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 |
||
| 68 | public function buildLitteral(NodeList &$list):string |
||
| 69 | { |
||
| 70 | $result = ''; |
||
| 71 | if ($this instanceof NodeLit) { |
||
| 72 | return self::buildLitt($list); |
||
|
|
|||
| 73 | } |
||
| 74 | if ($this instanceof NodeRaw) { |
||
| 75 | return self::buildRaw($list); |
||
| 76 | } |
||
| 77 | if ($list->count()) { |
||
| 78 | if ($this->modifier !== '+') { |
||
| 79 | self::litteralStripLeading($list); |
||
| 80 | self::litteralStripTrailing($list); |
||
| 81 | } |
||
| 82 | $first = $list->shift(); |
||
| 83 | $refIndent = $first->indent ?? 0; |
||
| 84 | // $refSeparator = [ Y::RAW => '', Y::LITT => "\n", Y::LITT_FOLDED => ' '][$type]; |
||
| 85 | $refSeparator = ' '; |
||
| 86 | $result = substr($first->raw, $first->indent); |
||
| 87 | foreach ($list as $child) { |
||
| 88 | if ($this instanceof NodeLitFolded) { |
||
| 89 | if($child->indent > $refIndent || ($child instanceof NodeBlank)) { |
||
| 90 | $separator = "\n"; |
||
| 91 | } else { |
||
| 92 | $separator = !empty($result) && $result[-1] === "\n" ? '' : $refSeparator; |
||
| 93 | } |
||
| 94 | } else { |
||
| 95 | $separator = $refSeparator; |
||
| 96 | } |
||
| 97 | $val = ''; |
||
| 98 | if ($child->value instanceof NodeList) { |
||
| 99 | $val = "\n".self::buildLitteral($child->value); |
||
| 100 | } else { |
||
| 101 | if ($child instanceof NodeScalar) { |
||
| 102 | $val = $child->value; |
||
| 103 | } /*else { |
||
| 104 | $cursor = $child; |
||
| 105 | $val = substr($child->raw, $child->indent); |
||
| 106 | // while ($cursor->value instanceof Node) { |
||
| 107 | // $val .= substr($cursor->raw, $cursor->indent); |
||
| 108 | // $cursor = $cursor->value; |
||
| 109 | // } |
||
| 110 | // $val .= $cursor->value; |
||
| 111 | }*/ |
||
| 112 | } |
||
| 113 | $result .= $separator .$val; |
||
| 114 | } |
||
| 115 | } |
||
| 116 | return $result.($this->modifier === '-' ? "" : "\n"); |
||
| 117 | } |
||
| 121 | } |
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.