Conditions | 31 |
Paths | 325 |
Total Lines | 135 |
Code Lines | 58 |
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 |
||
61 | function template_error_log() |
||
62 | { |
||
63 | global $scripturl, $context, $txt; |
||
64 | |||
65 | echo ' |
||
66 | <form action="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';start=', $context['start'], $context['has_filter'] ? $context['filter']['href'] : '', '" method="post" accept-charset="', $context['character_set'], '"> |
||
67 | <div class="cat_bar"> |
||
68 | <h3 class="catbg"> |
||
69 | <a href="', $scripturl, '?action=helpadmin;help=error_log" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a> ', $txt['errorlog'], ' |
||
70 | </h3> |
||
71 | </div> |
||
72 | <div class="information flow_hidden"> |
||
73 | <div class="additional_row">'; |
||
74 | |||
75 | // No errors, so just show a message and be done with it. |
||
76 | if (empty($context['errors'])) |
||
77 | { |
||
78 | echo ' |
||
79 | ', $txt['errorlog_no_entries'], ' |
||
80 | </div> |
||
81 | </div> |
||
82 | </form>'; |
||
83 | return; |
||
84 | } |
||
85 | |||
86 | if ($context['has_filter']) |
||
87 | echo ' |
||
88 | <div class="infobox"> |
||
89 | <strong>', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], ' |
||
90 | </div>'; |
||
91 | |||
92 | echo ' |
||
93 | <div class="floatright"> |
||
94 | <input type="submit" name="removeSelection" value="', $txt['remove_selection'], '" data-confirm="', $txt['remove_selection_confirm'], '" class="button you_sure"> |
||
95 | <input type="submit" name="delall" value="', ($context['has_filter'] ? $txt['remove_filtered_results'] : $txt['remove_all']), '" data-confirm="', ($context['has_filter'] ? $txt['remove_filtered_results_confirm'] : $txt['sure_about_errorlog_remove']), '" class="button you_sure"> |
||
96 | ', ($context['has_filter'] ? '<a href="' . $scripturl . '?action=admin;area=logs;sa=errorlog' . ($context['sort_direction'] == 'down' ? ';desc' : '') . '" class="button">' . $txt['clear_filter'] . '</a>' : ''), ' |
||
97 | </div> |
||
98 | ', $txt['apply_filter_of_type'], ':'; |
||
99 | |||
100 | $error_types = array(); |
||
101 | |||
102 | foreach ($context['error_types'] as $type => $details) |
||
103 | $error_types[] = ($details['is_selected'] ? '<span class="main_icons right_arrow"></span> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : 'style="font-weight: normal;"') . ' title="' . $details['description'] . '">' . ($details['error_type'] === 'critical' ? '<span class="error">' . $details['label'] . '</span>' : $details['label']) . '</a>'; |
||
104 | |||
105 | echo ' |
||
106 | ', implode(' | ', $error_types), ' |
||
107 | </div> |
||
108 | </div> |
||
109 | <div class="pagesection"> |
||
110 | <div class="pagelinks"> |
||
111 | ', $context['page_index'], ' |
||
112 | </div> |
||
113 | <div class="floatright" style="padding: 0 12px"> |
||
114 | <label for="check_all"><strong>', $txt['check_all'], '</strong></label> |
||
115 | <input type="checkbox" id="check_all" onclick="invertAll(this, this.form, \'delete[]\');"> |
||
116 | </div> |
||
117 | </div>'; |
||
118 | |||
119 | // We have some errors, must be some mods installed :P |
||
120 | foreach ($context['errors'] as $error) |
||
121 | { |
||
122 | echo ' |
||
123 | <div class="windowbg word_break"> |
||
124 | <div class="counter" style="padding: 0 10px 10px 0">', $error['id'], '</div> |
||
125 | <div class="topic_details"> |
||
126 | <span class="floatright"> |
||
127 | <input type="checkbox" name="delete[]" value="', $error['id'], '"> |
||
128 | </span> |
||
129 | <h5> |
||
130 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? '' : ';desc', $context['has_filter'] ? $context['filter']['href'] : '', '" title="', $txt['reverse_direction'], '"><span class="main_icons sort_' . $context['sort_direction'] . '"></span></a> ', $error['time'], ' |
||
131 | </h5> |
||
132 | <hr class="clear"> |
||
133 | </div> |
||
134 | <div> |
||
135 | <div class="half_content"> |
||
136 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=id_member;value=', $error['member']['id'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_member'], '"><span class="main_icons filter"></span></a> |
||
137 | <strong>', $error['member']['link'], '</strong>'; |
||
138 | |||
139 | if (!empty($error['member']['ip'])) |
||
140 | echo ' |
||
141 | <br> |
||
142 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=ip;value=', $error['member']['ip'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_ip'], '"><span class="main_icons filter"></span></a> |
||
143 | <strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong>'; |
||
144 | |||
145 | if (!empty($error['member']['session'])) |
||
146 | echo ' |
||
147 | <br> |
||
148 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=session;value=', $error['member']['session'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '"><span class="main_icons filter"></span></a> <a class="bbc_link" href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=session;value=', $error['member']['session'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '">', $error['member']['session'], '</a>'; |
||
149 | |||
150 | echo ' |
||
151 | <br> |
||
152 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=url;value=', $error['url']['href'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_url'], '"><span class="main_icons filter"></span></a> |
||
153 | <a href="', $error['url']['html'], '" class="bbc_link word_break">', $error['url']['html'], '</a>'; |
||
154 | |||
155 | if (!empty($error['file'])) |
||
156 | echo ' |
||
157 | <br> |
||
158 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=file;value=', $error['file']['search'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_file'], '"><span class="main_icons filter"></span></a> <a class="bbc_link" href="', $error['file']['href'], '" onclick="return reqWin(this.href, 600, 480, false);">', $error['file']['file'], '</a> (', $txt['line'], ' ', $error['file']['line'], ')'; |
||
159 | |||
160 | echo ' |
||
161 | </div> |
||
162 | <div class="half_content"> |
||
163 | <strong class="floatright"> |
||
164 | <span class="main_icons details"></span> <a class="bbc_link" href="', $scripturl, '?action=admin;area=logs;sa=errorlog;backtrace=', $error['id'], '" onclick="return reqWin(this.href, 600, 480, false);">', $txt['backtrace_title'], '</a> |
||
165 | </strong> |
||
166 | </div> |
||
167 | </div> |
||
168 | <div class="post"> |
||
169 | <br class="clear"> |
||
170 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=error_type;value=', $error['error_type']['type'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_type'], '"><span class="main_icons filter"></span></a>', $txt['error_type'], ': ', $error['error_type']['type'] === 'critical' ? '<span class="error">' . $error['error_type']['name'] . '</span>' : $error['error_type']['name'], '<br> |
||
171 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=message;value=', $error['message']['href'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_message'], '"><span class="main_icons filter floatleft"></span></a> |
||
172 | <div class="codeheader"><span class="code floatleft">' . $txt['error_message'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a> <a class="codeoperation smf_expand_code hidden" data-shrink-txt="' . $txt['code_shrink'] . '" data-expand-txt="' . $txt['code_expand'] . '">' . $txt['code_expand'] . '</a> |
||
173 | </div><code class="bbc_code" style="white-space: pre-line; overflow-y: auto">', $error['message']['html'], '</code> |
||
174 | </div> |
||
175 | </div>'; |
||
176 | } |
||
177 | |||
178 | echo ' |
||
179 | <div class="pagesection"> |
||
180 | <div class="pagelinks"> |
||
181 | ', $context['page_index'], ' |
||
182 | </div> |
||
183 | <div class="floatright"> |
||
184 | <input type="submit" name="removeSelection" value="', $txt['remove_selection'], '" data-confirm="', $txt['remove_selection_confirm'], '" class="button you_sure"> |
||
185 | <input type="submit" name="delall" value="', ($context['has_filter'] ? $txt['remove_filtered_results'] : $txt['remove_all']), '" data-confirm="', ($context['has_filter'] ? $txt['remove_filtered_results_confirm'] : $txt['sure_about_errorlog_remove']), '" class="button you_sure"> |
||
186 | </div> |
||
187 | </div>'; |
||
188 | |||
189 | if ($context['sort_direction'] == 'down') |
||
190 | echo ' |
||
191 | <input type="hidden" name="desc" value="1">'; |
||
192 | |||
193 | echo ' |
||
194 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||
195 | <input type="hidden" name="', $context['admin-el_token_var'], '" value="', $context['admin-el_token'], '"> |
||
196 | </form>'; |
||
380 | ?> |
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.