| Conditions | 6 |
| Paths | 4 |
| Total Lines | 55 |
| Code Lines | 18 |
| 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 |
||
| 29 | function protector_onuninstall_base($module, $mydirname) |
||
| 30 | { |
||
| 31 | // transations on module uninstall |
||
| 32 | |||
| 33 | global $ret; // TODO :-D |
||
| 34 | |||
| 35 | // for Cube 2.1 |
||
| 36 | // if (defined('XOOPS_CUBE_LEGACY')) { |
||
| 37 | // $root =& XCube_Root::getSingleton(); |
||
| 38 | // $root->mDelegateManager->add('Legacy.Admin.Event.ModuleUninstall.' . ucfirst($mydirname) . '.Success', 'protector_message_append_onuninstall'); |
||
| 39 | // $ret = array(); |
||
| 40 | // } else { |
||
| 41 | if (!is_array($ret)) { |
||
| 42 | $ret = array(); |
||
| 43 | } |
||
| 44 | // } |
||
| 45 | |||
| 46 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 47 | $mid = $module->getVar('mid'); |
||
| 48 | |||
| 49 | // TABLES (loading mysql.sql) |
||
| 50 | $sql_file_path = __DIR__ . '/sql/mysql.sql'; |
||
| 51 | $prefix_mod = $db->prefix() . '_' . $mydirname; |
||
| 52 | if (file_exists($sql_file_path)) { |
||
| 53 | $ret[] = 'SQL file found at <b>' . htmlspecialchars($sql_file_path) . '</b>.<br /> Deleting tables...<br>'; |
||
| 54 | $sql_lines = file($sql_file_path); |
||
| 55 | foreach ($sql_lines as $sql_line) { |
||
| 56 | if (preg_match('/^CREATE TABLE \`?([a-zA-Z0-9_-]+)\`? /i', $sql_line, $regs)) { |
||
| 57 | $sql = 'DROP TABLE ' . addslashes($prefix_mod . '_' . $regs[1]); |
||
| 58 | if (!$db->query($sql)) { |
||
| 59 | $ret[] = '<span style="color:#ff0000;">ERROR: Could not drop table <b>' . htmlspecialchars($prefix_mod . '_' . $regs[1]) . '<b>.</span><br>'; |
||
| 60 | } else { |
||
| 61 | $ret[] = 'Table <b>' . htmlspecialchars($prefix_mod . '_' . $regs[1]) . '</b> dropped.<br>'; |
||
| 62 | } |
||
| 63 | } |
||
| 64 | } |
||
| 65 | } |
||
| 66 | |||
| 67 | // TEMPLATES (Not necessary because modulesadmin removes all templates) |
||
| 68 | /* $tplfile_handler = xoops_getHandler( 'tplfile' ) ; |
||
| 69 | $templates =& $tplfile_handler->find( null , 'module' , $mid ) ; |
||
| 70 | $tcount = count( $templates ) ; |
||
| 71 | if ($tcount > 0) { |
||
| 72 | $ret[] = 'Deleting templates...' ; |
||
| 73 | for ($i = 0 ; $i < $tcount ; ++$i) { |
||
| 74 | if ( ! $tplfile_handler->delete( $templates[$i] ) ) { |
||
| 75 | $ret[] = '<span style="color:#ff0000;">ERROR: Could not delete template '.$templates[$i]->getVar('tpl_file','s').' from the database. Template ID: <b>'.$templates[$i]->getVar('tpl_id','s').'</b></span><br>'; |
||
| 76 | } else { |
||
| 77 | $ret[] = 'Template <b>'.$templates[$i]->getVar('tpl_file','s').'</b> deleted from the database. Template ID: <b>'.$templates[$i]->getVar('tpl_id','s').'</b><br>'; |
||
| 78 | } |
||
| 79 | } |
||
| 80 | } |
||
| 81 | unset($templates); */ |
||
| 82 | |||
| 83 | return true; |
||
| 84 | } |
||
| 101 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.