| Conditions | 8 |
| Paths | 17 |
| Total Lines | 51 |
| 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 |
||
| 120 | protected function getRevisions(&$first, &$hasNext) |
||
| 121 | { |
||
| 122 | global $INFO, $conf; |
||
| 123 | |||
| 124 | if ($this->id != $INFO['id']) { |
||
| 125 | return parent::getRevisions($first, $hasNext); |
||
| 126 | } |
||
| 127 | |||
| 128 | $changelog =& $this->changelog; |
||
| 129 | |||
| 130 | $revisions = []; |
||
| 131 | |||
| 132 | /* we need to get one additional log entry to be able to |
||
| 133 | * decide if this is the last page or is there another one. |
||
| 134 | * see also Ui\Recent::getRecents() |
||
| 135 | */ |
||
| 136 | $revlist = $changelog->getRevisions($first, $conf['recent'] +1); |
||
| 137 | if (count($revlist) == 0 && $first != 0) { |
||
| 138 | $first = 0; |
||
| 139 | $revlist = $changelog->getRevisions($first, $conf['recent'] +1); |
||
| 140 | } |
||
| 141 | $exists = $INFO['exists']; |
||
| 142 | if ($first == 0 && $exists) { |
||
| 143 | // add current page as revision[0] |
||
| 144 | $revisions[] = array( |
||
| 145 | 'date' => $INFO['lastmod'], |
||
| 146 | 'ip' => null, |
||
| 147 | 'type' => $INFO['meta']['last_change']['type'], |
||
| 148 | 'id' => $INFO['id'], |
||
| 149 | 'user' => $INFO['editor'], |
||
| 150 | 'sum' => $INFO['sum'], |
||
| 151 | 'extra' => null, |
||
| 152 | 'sizechange' => $INFO['meta']['last_change']['sizechange'], |
||
| 153 | 'item' => $this->item, |
||
| 154 | 'current' => true, |
||
| 155 | ); |
||
| 156 | } |
||
| 157 | |||
| 158 | // decide if this is the last page or is there another one |
||
| 159 | $hasNext = false; |
||
| 160 | if (count($revlist) > $conf['recent']) { |
||
| 161 | $hasNext = true; |
||
| 162 | array_pop($revlist); // remove one additional log entry |
||
| 163 | } |
||
| 164 | |||
| 165 | // append each revison info array to the revisions |
||
| 166 | foreach ($revlist as $rev) { |
||
| 167 | $revisions[] = $changelog->getRevisionInfo($rev) + array('item' => $this->item); |
||
| 168 | } |
||
| 169 | return $revisions; |
||
| 170 | } |
||
| 171 | |||
| 173 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..