| Conditions | 6 |
| Paths | 14 |
| 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 |
||
| 46 | public function show($first = 0) |
||
| 47 | { |
||
| 48 | global $lang; |
||
| 49 | |||
| 50 | // get revisions, and set correct pagenation parameters (first, hasNext) |
||
| 51 | if ($first === null) $first = 0; |
||
| 52 | $hasNext = false; |
||
| 53 | $revisions = $this->getRevisions($first, $hasNext); |
||
| 54 | |||
| 55 | // create the form |
||
| 56 | $form = new Form([ |
||
| 57 | 'id' => 'page__revisions', // must not be "media__revisions" |
||
| 58 | 'action' => media_managerURL(['image' => $this->id], '&'), |
||
| 59 | 'class' => 'changes', |
||
| 60 | ]); |
||
| 61 | $form->setHiddenField('mediado', 'diff'); // required for media revisions |
||
| 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 (file_exists(mediaFN($this->id, $rev))) { |
||
| 75 | $form->addCheckbox('rev2[]')->val($rev); |
||
| 76 | } else { |
||
| 77 | $form->addCheckbox('')->val($rev)->attr('disabled','disabled'); |
||
| 78 | } |
||
| 79 | $form->addHTML(' '); |
||
| 80 | |||
| 81 | $objRevInfo = $this->getObjRevInfo($info); |
||
| 82 | $html = implode(' ', [ |
||
| 83 | $objRevInfo->editDate(), // edit date and time |
||
| 84 | $objRevInfo->difflink(), // link to diffview icon |
||
| 85 | $objRevInfo->itemName(), // name of page or media |
||
| 86 | '<div>', |
||
| 87 | $objRevInfo->editSummary(), // edit summary |
||
| 88 | $objRevInfo->editor(), // editor info |
||
| 89 | $objRevInfo->sizechange(), // size change indicator |
||
| 90 | $objRevInfo->currentIndicator(), // current indicator (only when k=1) |
||
| 91 | '</div>', |
||
| 92 | ]); |
||
| 93 | $form->addHTML($html); |
||
| 94 | |||
| 95 | $form->addTagClose('div'); |
||
| 96 | $form->addTagClose('li'); |
||
| 97 | } |
||
| 98 | $form->addTagClose('ul'); // end of revision list |
||
| 99 | |||
| 100 | // show button for diff view |
||
| 101 | $form->addButton('do[diff]', $lang['diff2'])->attr('type', 'submit'); |
||
| 102 | |||
| 103 | $form->addTagClose('div'); // close div class=no |
||
| 104 | |||
| 105 | print $form->toHTML('Revisions'); |
||
| 106 | |||
| 107 | // provide navigation for pagenated revision list (of pages and/or media files) |
||
| 108 | print $this->navigation($first, $hasNext, function ($n) { |
||
| 109 | return media_managerURL(['first' => $n], '&', false, true); |
||
| 110 | }); |
||
| 111 | } |
||
| 112 | |||
| 114 |
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..