| Conditions | 2 |
| Paths | 2 |
| Total Lines | 76 |
| Code Lines | 49 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 21 | protected function createContent(ManialinkInterface $manialink) |
||
| 22 | { |
||
| 23 | parent::createContent($manialink); |
||
| 24 | |||
| 25 | $tooltip = new uiTooltip(); |
||
| 26 | $manialink->addChild($tooltip); |
||
| 27 | |||
| 28 | |||
| 29 | $label = new uiLabel("Test", uiLabel::TYPE_NORMAL); |
||
| 30 | $tooltip->addTooltip($label, "tooltip test"); |
||
| 31 | |||
| 32 | $manialink->addChild($label); |
||
| 33 | |||
| 34 | $checkbox = new uiCheckbox("test checkbox 1", "checkbox1"); |
||
| 35 | $tooltip->addTooltip($checkbox, "testing 123"); |
||
| 36 | |||
| 37 | $checkbox2 = new uiCheckbox("test checkbox 2", "checkbox2"); |
||
| 38 | $tooltip->addTooltip($checkbox2, "testing"); |
||
| 39 | $line1 = new layoutRow(0, 0, [$checkbox, $checkbox2], 0); |
||
|
|
|||
| 40 | |||
| 41 | $ok = new uiButton("Apply", uiButton::TYPE_DECORATED); |
||
| 42 | $tooltip->addTooltip($ok, "ridicolously long description text is here!"); |
||
| 43 | $ok->setAction($this->actionFactory->createManialinkAction($manialink, [$this, 'ok'], ["ok" => "ok"])); |
||
| 44 | |||
| 45 | $cancel = new uiButton("Cancel"); |
||
| 46 | $cancel->setAction($this->actionFactory->createManialinkAction($manialink, [$this, 'ok'], ["ok" => "cancel"])); |
||
| 47 | |||
| 48 | $line2 = new layoutLine(0, 0, [$ok, $cancel], 1); |
||
| 49 | |||
| 50 | |||
| 51 | $line3 = new layoutRow(55, 0, [], 1); |
||
| 52 | |||
| 53 | for ($x = 0; $x < 10; $x++) { |
||
| 54 | $btn = new uiCheckbox('box'.$x, 'cb_'.$x); |
||
| 55 | $line3->addChild($btn); |
||
| 56 | } |
||
| 57 | |||
| 58 | $manialink->addChild($line3); |
||
| 59 | |||
| 60 | $row = new layoutRow(0, -10, [$line1, $line2], 0); |
||
| 61 | $manialink->addChild($row); |
||
| 62 | |||
| 63 | |||
| 64 | $dropdown = new uiDropdown("dropdown", ["option1" => 1, "option2" => 2]); |
||
| 65 | $dropdown->setPosition(0, -30); |
||
| 66 | $manialink->addChild($dropdown); |
||
| 67 | |||
| 68 | $dropdown = new uiDropdown("style", ["tech" => "tech", "fullspeed" => "fullspeed", "speedtech" => "speedtech"]); |
||
| 69 | $dropdown->setPosition(40, -30); |
||
| 70 | $manialink->addChild($dropdown); |
||
| 71 | |||
| 72 | |||
| 73 | $quad = new Quad(); |
||
| 74 | $quad->setPosition(20, -40) |
||
| 75 | ->setAlign("center", "center") |
||
| 76 | ->setSize(2,2) |
||
| 77 | ->setBackgroundColor("0f0"); |
||
| 78 | $manialink->addChild($quad); |
||
| 79 | |||
| 80 | $quad = new Quad(); |
||
| 81 | $quad->setPosition(40, -20) |
||
| 82 | ->setAlign("center", "center") |
||
| 83 | ->setSize(2,2) |
||
| 84 | ->setBackgroundColor("0ff"); |
||
| 85 | $manialink->addChild($quad); |
||
| 86 | |||
| 87 | $line = new uiLine(20.1, -40); |
||
| 88 | $line->to(20.1, 0); |
||
| 89 | $manialink->addChild($line); |
||
| 90 | |||
| 91 | $line = new uiLine(20, -40); |
||
| 92 | $line->to(40, -20); |
||
| 93 | |||
| 94 | $manialink->addChild($line); |
||
| 95 | |||
| 96 | } |
||
| 97 | |||
| 110 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: