| Conditions | 10 |
| Paths | 129 |
| Total Lines | 56 |
| Code Lines | 37 |
| 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 |
||
| 33 | public function getUserbar() |
||
| 34 | { |
||
| 35 | global $xoopsModuleConfig, $xoopsUser, $isadmin; |
||
| 36 | if (empty($GLOBALS['xoopsModuleConfig']['userbar_enabled'])) { |
||
| 37 | return null; |
||
| 38 | } |
||
| 39 | $user = $this->user; |
||
| 40 | $userbar = []; |
||
| 41 | $userbar[] = [ |
||
| 42 | 'link' => $GLOBALS['xoops']->url('userinfo.php?uid=' . $user->getVar('uid')), |
||
| 43 | 'name' => PROFILE, |
||
| 44 | ]; |
||
| 45 | if (\is_object($xoopsUser)) { |
||
| 46 | $userbar[] = [ |
||
| 47 | 'link' => "javascript:void openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $user->getVar('uid') . "','pmlite', 450, 380);", |
||
| 48 | 'name' => _MD_PM, |
||
| 49 | ]; |
||
| 50 | } |
||
| 51 | if ($isadmin || $user->getVar('user_viewemail')) { |
||
| 52 | $userbar[] = [ |
||
| 53 | 'link' => "javascript:void window.open('mailto:" . $user->getVar('email') . "','new');", |
||
| 54 | 'name' => _MD_EMAIL, |
||
| 55 | ]; |
||
| 56 | } |
||
| 57 | if ($user->getVar('url')) { |
||
| 58 | $userbar[] = [ |
||
| 59 | 'link' => "javascript:void window.open('" . $user->getVar('url') . "','new');", |
||
| 60 | 'name' => _MD_WWW, |
||
| 61 | ]; |
||
| 62 | } |
||
| 63 | if ($user->getVar('user_icq')) { |
||
| 64 | $userbar[] = [ |
||
| 65 | 'link' => "javascript:void window.open('http://wwp.icq.com/scripts/search.dll?to=" . $user->getVar('user_icq') . "','new');", |
||
| 66 | 'name' => _MD_ICQ, |
||
| 67 | ]; |
||
| 68 | } |
||
| 69 | if ($user->getVar('user_aim')) { |
||
| 70 | $userbar[] = [ |
||
| 71 | 'link' => "javascript:void window.open('aim:goim?screenname=" . $user->getVar('user_aim') . '&message=Hi+' . $user->getVar('user_aim') . '+Are+you+there?' . "','new');", |
||
| 72 | 'name' => _MD_AIM, |
||
| 73 | ]; |
||
| 74 | } |
||
| 75 | if ($user->getVar('user_yim')) { |
||
| 76 | $userbar[] = [ |
||
| 77 | 'link' => "javascript:void window.open('http://edit.yahoo.com/config/send_webmesg?.target=" . $user->getVar('user_yim') . '&.src=pg' . "','new');", |
||
| 78 | 'name' => _MD_YIM, |
||
| 79 | ]; |
||
| 80 | } |
||
| 81 | if ($user->getVar('user_msnm')) { |
||
| 82 | $userbar[] = [ |
||
| 83 | 'link' => "javascript:void window.open('http://members.msn.com?mem=" . $user->getVar('user_msnm') . "','new');", |
||
| 84 | 'name' => _MD_MSNM, |
||
| 85 | ]; |
||
| 86 | } |
||
| 87 | |||
| 88 | return $userbar; |
||
| 89 | } |
||
| 91 |
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.