| Conditions | 7 |
| Paths | 18 |
| Total Lines | 66 |
| 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 |
||
| 45 | public function show($first = 0) |
||
| 46 | { |
||
| 47 | global $lang, $REV; |
||
| 48 | |||
| 49 | // get revisions, and set correct pagenation parameters (first, hasNext) |
||
| 50 | if ($first === null) $first = 0; |
||
| 51 | $hasNext = false; |
||
| 52 | $revisions = $this->getRevisions($first, $hasNext); |
||
| 53 | |||
| 54 | // print intro |
||
| 55 | print p_locale_xhtml('revisions'); |
||
| 56 | |||
| 57 | // create the form |
||
| 58 | $form = new Form([ |
||
| 59 | 'id' => 'page__revisions', |
||
| 60 | 'class' => 'changes', |
||
| 61 | ]); |
||
| 62 | $form->addTagOpen('div')->addClass('no'); |
||
| 63 | |||
| 64 | // start listing |
||
| 65 | $form->addTagOpen('ul'); |
||
| 66 | foreach ($revisions as $info) { |
||
| 67 | $rev = $info['date']; |
||
| 68 | $class = ($info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) ? 'minor' : ''; |
||
| 69 | $form->addTagOpen('li')->addClass($class); |
||
| 70 | $form->addTagOpen('div')->addClass('li'); |
||
| 71 | |||
| 72 | if (isset($info['current'])) { |
||
| 73 | $form->addCheckbox('rev2[]')->val('current'); |
||
| 74 | } elseif ($rev == $REV) { |
||
| 75 | $form->addCheckbox('rev2[]')->val($rev)->attr('checked','checked'); |
||
| 76 | } elseif (page_exists($this->id, $rev)) { |
||
| 77 | $form->addCheckbox('rev2[]')->val($rev); |
||
| 78 | } else { |
||
| 79 | $form->addCheckbox('')->val($rev)->attr('disabled','disabled'); |
||
| 80 | } |
||
| 81 | $form->addHTML(' '); |
||
| 82 | |||
| 83 | $objRevInfo = $this->getObjRevInfo($info); |
||
| 84 | $html = implode(' ', [ |
||
| 85 | $objRevInfo->editDate(), // edit date and time |
||
| 86 | $objRevInfo->difflink(), // link to diffview icon |
||
| 87 | $objRevInfo->itemName(), // name of page or media |
||
| 88 | $objRevInfo->editSummary(), // edit summary |
||
| 89 | $objRevInfo->editor(), // editor info |
||
| 90 | $objRevInfo->sizechange(), // size change indicator |
||
| 91 | $objRevInfo->currentIndicator(), // current indicator (only when k=1) |
||
| 92 | ]); |
||
| 93 | $form->addHTML($html); |
||
| 94 | $form->addTagClose('div'); |
||
| 95 | $form->addTagClose('li'); |
||
| 96 | } |
||
| 97 | $form->addTagClose('ul'); // end of revision list |
||
| 98 | |||
| 99 | // show button for diff view |
||
| 100 | $form->addButton('do[diff]', $lang['diff2'])->attr('type', 'submit'); |
||
| 101 | |||
| 102 | $form->addTagClose('div'); // close div class=no |
||
| 103 | |||
| 104 | print $form->toHTML('Revisions'); |
||
| 105 | |||
| 106 | // provide navigation for pagenated revision list (of pages and/or media files) |
||
| 107 | print $this->navigation($first, $hasNext, function ($n) { |
||
| 108 | return array('do' => 'revisions', 'first' => $n); |
||
| 109 | }); |
||
| 110 | } |
||
| 111 | |||
| 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..