| Conditions | 17 |
| Paths | 6561 |
| Total Lines | 47 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 declare(strict_types=1); |
||
| 86 | public function updateTable($table) |
||
| 87 | { |
||
| 88 | global $xoopsDB; |
||
| 89 | |||
| 90 | $ret = true; |
||
| 91 | |||
| 92 | // If table has a structure, create the table |
||
| 93 | if ($table->getStructure()) { |
||
| 94 | $ret = $table->createTable() && $ret; |
||
| 95 | } |
||
| 96 | |||
| 97 | // If table is flag for drop, drop it |
||
| 98 | if ($table->getFlagForDrop()) { |
||
| 99 | $ret = $table->dropTable() && $ret; |
||
| 100 | } |
||
| 101 | |||
| 102 | // If table has data, insert it |
||
| 103 | if ($table->getData()) { |
||
| 104 | $ret = $table->addData() && $ret; |
||
| 105 | } |
||
| 106 | |||
| 107 | // If table has new fields to be added, add them |
||
| 108 | if ($table->getNewFields()) { |
||
| 109 | $ret = $table->addNewFields() && $ret; |
||
| 110 | } |
||
| 111 | |||
| 112 | // If table has altered field, alter the table |
||
| 113 | if ($table->getAlteredFields()) { |
||
| 114 | $ret = $table->alterTable() && $ret; |
||
| 115 | } |
||
| 116 | |||
| 117 | // If table has updated field values, update the table |
||
| 118 | if ($table->getUpdatedFields()) { |
||
| 119 | $ret = $table->updateFieldsValues($table) && $ret; |
||
|
|
|||
| 120 | } |
||
| 121 | |||
| 122 | // If table has dropped field, alter the table |
||
| 123 | if ($table->getDroppedFields()) { |
||
| 124 | $ret = $table->dropFields($table) && $ret; |
||
| 125 | } |
||
| 126 | //felix |
||
| 127 | // If table has updated field values, update the table |
||
| 128 | if ($table->getUpdatedWhere()) { |
||
| 129 | $ret = $table->updateWhereValues($table) && $ret; |
||
| 130 | } |
||
| 131 | |||
| 132 | return $ret; |
||
| 133 | } |
||
| 135 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.