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