Conditions | 11 |
Paths | 8 |
Total Lines | 101 |
Code Lines | 42 |
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 |
||
43 | function template_find_members() |
||
44 | { |
||
45 | global $context, $settings, $scripturl, $modSettings, $txt; |
||
46 | |||
47 | echo '<!DOCTYPE html> |
||
48 | <html', $context['right_to_left'] ? ' dir="rtl"' : '', '> |
||
49 | <head> |
||
50 | <title>', $txt['find_members'], '</title> |
||
51 | <meta charset="', $context['character_set'], '"> |
||
52 | <meta name="robots" content="noindex"> |
||
53 | ', template_css(), ' |
||
54 | <script src="', $settings['default_theme_url'], '/scripts/script.js', $context['browser_cache'], '"></script> |
||
55 | <script> |
||
56 | var membersAdded = []; |
||
57 | function addMember(name) |
||
58 | { |
||
59 | var theTextBox = window.opener.document.getElementById("', $context['input_box_name'], '"); |
||
60 | |||
61 | if (name in membersAdded) |
||
62 | return; |
||
63 | |||
64 | // If we only accept one name don\'t remember what is there. |
||
65 | if (', JavaScriptEscape($context['delimiter']), ' != \'null\') |
||
66 | membersAdded[name] = true; |
||
67 | |||
68 | if (theTextBox.value.length < 1 || ', JavaScriptEscape($context['delimiter']), ' == \'null\') |
||
69 | theTextBox.value = ', $context['quote_results'] ? '"\"" + name + "\""' : 'name', '; |
||
70 | else |
||
71 | theTextBox.value += ', JavaScriptEscape($context['delimiter']), ' + ', $context['quote_results'] ? '"\"" + name + "\""' : 'name', '; |
||
72 | |||
73 | window.focus(); |
||
74 | } |
||
75 | </script> |
||
76 | </head> |
||
77 | <body id="help_popup"> |
||
78 | <form action="', $scripturl, '?action=findmember;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '" class="padding description"> |
||
79 | <div class="roundframe"> |
||
80 | <div class="cat_bar"> |
||
81 | <h3 class="catbg">', $txt['find_members'], '</h3> |
||
82 | </div> |
||
83 | <div class="padding"> |
||
84 | <strong>', $txt['find_username'], ':</strong><br> |
||
85 | <input type="text" name="search" id="search" value="', isset($context['last_search']) ? $context['last_search'] : '', '" style="margin-top: 4px; width: 96%;"><br> |
||
86 | <span class="smalltext"><em>', $txt['find_wildcards'], '</em></span><br>'; |
||
87 | |||
88 | // Only offer to search for buddies if we have some! |
||
89 | if (!empty($context['show_buddies'])) |
||
90 | echo ' |
||
91 | <span class="smalltext"> |
||
92 | <label for="buddies"><input type="checkbox" name="buddies" id="buddies"', !empty($context['buddy_search']) ? ' checked' : '', '> ', $txt['find_buddies'], '</label> |
||
93 | </span><br>'; |
||
94 | |||
95 | echo ' |
||
96 | <div class="padding righttext"> |
||
97 | <input type="submit" value="', $txt['search'], '" class="button"> |
||
98 | <input type="button" value="', $txt['find_close'], '" onclick="window.close();" class="button"> |
||
99 | </div> |
||
100 | </div><!-- .padding --> |
||
101 | </div><!-- .roundframe --> |
||
102 | <br> |
||
103 | <div class="roundframe"> |
||
104 | <div class="cat_bar"> |
||
105 | <h3 class="catbg">', $txt['find_results'], '</h3> |
||
106 | </div>'; |
||
107 | |||
108 | if (empty($context['results'])) |
||
109 | echo ' |
||
110 | <p class="error">', $txt['find_no_results'], '</p>'; |
||
111 | else |
||
112 | { |
||
113 | echo ' |
||
114 | <ul class="padding">'; |
||
115 | |||
116 | foreach ($context['results'] as $result) |
||
117 | echo ' |
||
118 | <li class="windowbg"> |
||
119 | <a href="', $result['href'], '" target="_blank" rel="noopener"> <span class="main_icons profile_sm"></span> |
||
120 | <a href="javascript:void(0);" onclick="addMember(this.innerHTML); return false;">', $result['name'], '</a> |
||
121 | </li>'; |
||
122 | |||
123 | echo ' |
||
124 | </ul> |
||
125 | <div class="pagesection"> |
||
126 | <div class="pagelinks">', $context['page_index'], '</div> |
||
127 | </div>'; |
||
128 | } |
||
129 | |||
130 | echo ' |
||
131 | </div><!-- .roundframe --> |
||
132 | <input type="hidden" name="input" value="', $context['input_box_name'], '"> |
||
133 | <input type="hidden" name="delim" value="', $context['delimiter'], '"> |
||
134 | <input type="hidden" name="quote" value="', $context['quote_results'] ? '1' : '0', '"> |
||
135 | </form>'; |
||
136 | |||
137 | if (empty($context['results'])) |
||
138 | echo ' |
||
139 | <script> |
||
140 | document.getElementById("search").focus(); |
||
141 | </script>'; |
||
142 | |||
143 | echo ' |
||
144 | </body> |
||
176 | ?> |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.