| Conditions | 37 | 
| Paths | > 20000 | 
| Total Lines | 220 | 
| Code Lines | 150 | 
| 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  | 
            ||
| 55 | public function index($executeActions = true): bool  | 
            ||
| 56 |     { | 
            ||
| 57 | global $conf;  | 
            ||
| 58 | global $db;  | 
            ||
| 59 | global $user;  | 
            ||
| 60 | global $hookmanager;  | 
            ||
| 61 | global $user;  | 
            ||
| 62 | global $menumanager;  | 
            ||
| 63 | global $langs;  | 
            ||
| 64 | global $mysoc;  | 
            ||
| 65 | |||
| 66 | // Load translation files required by the page  | 
            ||
| 67 |         $this->langs->load("members"); | 
            ||
| 68 | |||
| 69 |         $rowid = GETPOSTINT('rowid'); | 
            ||
| 70 |         $action = GETPOST('action', 'aZ09'); | 
            ||
| 71 |         $massaction = GETPOST('massaction', 'alpha'); | 
            ||
| 72 |         $cancel = GETPOST('cancel', 'alpha'); | 
            ||
| 73 |         $toselect = GETPOST('toselect', 'array'); | 
            ||
| 74 |         $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)) . basename(__FILE__, '.php')); // To manage different context of search | 
            ||
| 75 |         $backtopage = GETPOST('backtopage', 'alpha'); | 
            ||
| 76 |         $mode = GETPOST('mode', 'alpha'); | 
            ||
| 77 | |||
| 78 |         $sall = GETPOST("sall", "alpha"); | 
            ||
| 79 |         $filter = GETPOST("filter", 'alpha'); | 
            ||
| 80 |         $search_ref = GETPOST('search_ref', 'alpha'); | 
            ||
| 81 |         $search_lastname = GETPOST('search_lastname', 'alpha'); | 
            ||
| 82 |         $search_login = GETPOST('search_login', 'alpha'); | 
            ||
| 83 |         $search_email = GETPOST('search_email', 'alpha'); | 
            ||
| 84 |         $type = GETPOST('type', 'intcomma'); | 
            ||
| 85 |         $status = GETPOST('status', 'alpha'); | 
            ||
| 86 |         $optioncss = GETPOST('optioncss', 'alpha'); | 
            ||
| 87 | |||
| 88 | // Load variable for pagination  | 
            ||
| 89 |         $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; | 
            ||
| 90 |         $sortfield = GETPOST('sortfield', 'aZ09comma'); | 
            ||
| 91 |         $sortorder = GETPOST('sortorder', 'aZ09comma'); | 
            ||
| 92 |         $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); | 
            ||
| 93 |         if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { | 
            ||
| 94 | // If $page is not defined, or '' or -1 or if we click on clear filters  | 
            ||
| 95 | $page = 0;  | 
            ||
| 96 | }  | 
            ||
| 97 | $offset = $limit * $page;  | 
            ||
| 98 | $pageprev = $page - 1;  | 
            ||
| 99 | $pagenext = $page + 1;  | 
            ||
| 100 |         if (!$sortorder) { | 
            ||
| 101 | $sortorder = "DESC";  | 
            ||
| 102 | }  | 
            ||
| 103 |         if (!$sortfield) { | 
            ||
| 104 | $sortfield = "d.lastname";  | 
            ||
| 105 | }  | 
            ||
| 106 | |||
| 107 |         $label = GETPOST("label", "alpha"); | 
            ||
| 108 |         $morphy = GETPOST("morphy", "alpha"); | 
            ||
| 109 |         $status = GETPOSTINT("status"); | 
            ||
| 110 |         $subscription = GETPOSTINT("subscription"); | 
            ||
| 111 |         $amount = GETPOST('amount', 'alpha'); | 
            ||
| 112 |         $duration_value = GETPOSTINT('duration_value'); | 
            ||
| 113 |         $duration_unit = GETPOST('duration_unit', 'alpha'); | 
            ||
| 114 |         $vote = GETPOSTINT("vote"); | 
            ||
| 115 |         $comment = GETPOST("comment", 'restricthtml'); | 
            ||
| 116 |         $mail_valid = GETPOST("mail_valid", 'restricthtml'); | 
            ||
| 117 |         $caneditamount = GETPOSTINT("caneditamount"); | 
            ||
| 118 | |||
| 119 | // Initialize technical objects  | 
            ||
| 120 | $object = new AdherentType($db);  | 
            ||
| 121 | $extrafields = new ExtraFields($db);  | 
            ||
| 122 | $this->hookmanager->initHooks(['membertypecard', 'globalcard']);  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 123 | |||
| 124 | // Fetch optionals attributes and labels  | 
            ||
| 125 | $extrafields->fetch_name_optionals_label($object->table_element);  | 
            ||
| 126 | |||
| 127 | // Security check  | 
            ||
| 128 | $result = restrictedArea($user, 'adherent', $rowid, 'adherent_type');  | 
            ||
| 129 | |||
| 130 | |||
| 131 | /*  | 
            ||
| 132 | * Actions  | 
            ||
| 133 | */  | 
            ||
| 134 | |||
| 135 |         if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers | 
            ||
| 136 | $search_ref = "";  | 
            ||
| 137 | $search_lastname = "";  | 
            ||
| 138 | $search_login = "";  | 
            ||
| 139 | $search_email = "";  | 
            ||
| 140 | $type = "";  | 
            ||
| 141 | $sall = "";  | 
            ||
| 142 | }  | 
            ||
| 143 | |||
| 144 |         if (GETPOST('cancel', 'alpha')) { | 
            ||
| 145 | $action = 'list';  | 
            ||
| 146 | $massaction = '';  | 
            ||
| 147 | }  | 
            ||
| 148 |         if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { | 
            ||
| 149 | $massaction = '';  | 
            ||
| 150 | }  | 
            ||
| 151 | |||
| 152 |         if ($cancel) { | 
            ||
| 153 | $action = '';  | 
            ||
| 154 | |||
| 155 |             if (!empty($backtopage)) { | 
            ||
| 156 |                 header("Location: " . $backtopage); | 
            ||
| 157 | exit;  | 
            ||
| 158 | }  | 
            ||
| 159 | }  | 
            ||
| 160 | |||
| 161 |         if ($action == 'add' && $user->hasRight('adherent', 'configurer')) { | 
            ||
| 162 | $object->label = trim($label);  | 
            ||
| 163 | $object->morphy = trim($morphy);  | 
            ||
| 164 | $object->status = (int) $status;  | 
            ||
| 165 | $object->subscription = (int) $subscription;  | 
            ||
| 166 | $object->amount = ($amount == '' ? '' : price2num($amount, 'MT'));  | 
            ||
| 167 | $object->caneditamount = $caneditamount;  | 
            ||
| 168 | $object->duration_value = $duration_value;  | 
            ||
| 169 | $object->duration_unit = $duration_unit;  | 
            ||
| 170 | $object->note_public = trim($comment);  | 
            ||
| 171 | $object->note_private = '';  | 
            ||
| 172 | $object->mail_valid = trim($mail_valid);  | 
            ||
| 173 | $object->vote = (int) $vote;  | 
            ||
| 174 | |||
| 175 | // Fill array 'array_options' with data from add form  | 
            ||
| 176 | $ret = $extrafields->setOptionalsFromPost(null, $object);  | 
            ||
| 177 |             if ($ret < 0) { | 
            ||
| 178 | $error++;  | 
            ||
| 179 | }  | 
            ||
| 180 | |||
| 181 |             if (empty($object->label)) { | 
            ||
| 182 | $error++;  | 
            ||
| 183 |                 setEventMessages($this->langs->trans("ErrorFieldRequired", $this->langs->transnoentities("Label")), null, 'errors'); | 
            ||
| 184 |             } else { | 
            ||
| 185 | $sql = "SELECT libelle FROM " . MAIN_DB_PREFIX . "adherent_type WHERE libelle = '" . $this->db->escape($object->label) . "'";  | 
            ||
| 186 |                 $sql .= " WHERE entity IN (" . getEntity('member_type') . ")"; | 
            ||
| 187 | $result = $this->db->query($sql);  | 
            ||
| 188 | $num = null;  | 
            ||
| 189 |                 if ($result) { | 
            ||
| 190 | $num = $this->db->num_rows($result);  | 
            ||
| 191 | }  | 
            ||
| 192 |                 if ($num) { | 
            ||
| 193 | $error++;  | 
            ||
| 194 |                     $this->langs->load("errors"); | 
            ||
| 195 |                     setEventMessages($this->langs->trans("ErrorLabelAlreadyExists", $login), null, 'errors'); | 
            ||
| 196 | }  | 
            ||
| 197 | }  | 
            ||
| 198 | |||
| 199 |             if (!$error) { | 
            ||
| 200 | $id = $object->create($user);  | 
            ||
| 201 |                 if ($id > 0) { | 
            ||
| 202 |                     header("Location: " . $_SERVER['PHP_SELF']); | 
            ||
| 203 | exit;  | 
            ||
| 204 |                 } else { | 
            ||
| 205 | setEventMessages($object->error, $object->errors, 'errors');  | 
            ||
| 206 | $action = 'create';  | 
            ||
| 207 | }  | 
            ||
| 208 |             } else { | 
            ||
| 209 | $action = 'create';  | 
            ||
| 210 | }  | 
            ||
| 211 | }  | 
            ||
| 212 | |||
| 213 |         if ($action == 'update' && $user->hasRight('adherent', 'configurer')) { | 
            ||
| 214 | $object->fetch($rowid);  | 
            ||
| 215 | |||
| 216 | $object->oldcopy = dol_clone($object, 2);  | 
            ||
| 217 | |||
| 218 | $object->label = trim($label);  | 
            ||
| 219 | $object->morphy = trim($morphy);  | 
            ||
| 220 | $object->status = (int) $status;  | 
            ||
| 221 | $object->subscription = (int) $subscription;  | 
            ||
| 222 | $object->amount = ($amount == '' ? '' : price2num($amount, 'MT'));  | 
            ||
| 223 | $object->caneditamount = $caneditamount;  | 
            ||
| 224 | $object->duration_value = $duration_value;  | 
            ||
| 225 | $object->duration_unit = $duration_unit;  | 
            ||
| 226 | $object->note_public = trim($comment);  | 
            ||
| 227 | $object->note_private = '';  | 
            ||
| 228 | $object->mail_valid = trim($mail_valid);  | 
            ||
| 229 | $object->vote = (bool) trim($vote);  | 
            ||
| 230 | |||
| 231 | // Fill array 'array_options' with data from add form  | 
            ||
| 232 | $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');  | 
            ||
| 233 |             if ($ret < 0) { | 
            ||
| 234 | $error++;  | 
            ||
| 235 | }  | 
            ||
| 236 | |||
| 237 | $ret = $object->update($user);  | 
            ||
| 238 | |||
| 239 |             if ($ret >= 0 && !count($object->errors)) { | 
            ||
| 240 |                 setEventMessages($this->langs->trans("MemberTypeModified"), null, 'mesgs'); | 
            ||
| 241 |             } else { | 
            ||
| 242 | setEventMessages($object->error, $object->errors, 'errors');  | 
            ||
| 243 | }  | 
            ||
| 244 | |||
| 245 |             header("Location: " . $_SERVER['PHP_SELF'] . "?rowid=" . $object->id); | 
            ||
| 246 | exit;  | 
            ||
| 247 | }  | 
            ||
| 248 | |||
| 249 |         if ($action == 'confirm_delete' && $user->hasRight('adherent', 'configurer')) { | 
            ||
| 250 | $object->fetch($rowid);  | 
            ||
| 251 | $res = $object->delete($user);  | 
            ||
| 252 | |||
| 253 |             if ($res > 0) { | 
            ||
| 254 |                 setEventMessages($this->langs->trans("MemberTypeDeleted"), null, 'mesgs'); | 
            ||
| 255 |                 header("Location: " . $_SERVER['PHP_SELF']); | 
            ||
| 256 | exit;  | 
            ||
| 257 |             } else { | 
            ||
| 258 |                 setEventMessages($this->langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors'); | 
            ||
| 259 | $action = '';  | 
            ||
| 260 | }  | 
            ||
| 261 | }  | 
            ||
| 262 | |||
| 263 | |||
| 264 | /*  | 
            ||
| 265 | * View  | 
            ||
| 266 | */  | 
            ||
| 267 | |||
| 268 | // require_once realpath(BASE_PATH . '/../Dolibarr/Modules/Adherent/Views/type.php');  | 
            ||
| 269 | |||
| 270 | $this->db->close();  | 
            ||
| 271 | |||
| 272 | $this->template = '/page/adherent/type_list';  | 
            ||
| 273 | |||
| 274 | return true;  | 
            ||
| 275 | }  | 
            ||
| 277 | 
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.