1 | <?php |
||||
2 | /** |
||||
3 | * Elgg UTF-8 string functions |
||||
4 | * |
||||
5 | * @package Elgg |
||||
6 | * @subpackage Core |
||||
7 | */ |
||||
8 | |||||
9 | /** |
||||
10 | * Parses a string using mb_parse_str() if available. |
||||
11 | * NOTE: This differs from parse_str() by returning the results |
||||
12 | * instead of placing them in the local scope! |
||||
13 | * |
||||
14 | * @param string $str The string |
||||
15 | * |
||||
16 | * @return array |
||||
17 | * @since 1.7.0 |
||||
18 | */ |
||||
19 | function elgg_parse_str($str) { |
||||
20 | 5 | if (is_callable('mb_parse_str')) { |
|||
21 | 5 | mb_parse_str($str, $results); |
|||
22 | } else { |
||||
23 | parse_str($str, $results); |
||||
24 | } |
||||
25 | |||||
26 | 5 | return $results; |
|||
27 | } |
||||
28 | |||||
29 | /** |
||||
30 | * Wrapper function for mb_split(). Falls back to split() if |
||||
31 | * mb_split() isn't available. Parameters are passed to the |
||||
32 | * wrapped function in the same order they are passed to this |
||||
33 | * function. |
||||
34 | * |
||||
35 | * @return string |
||||
36 | * @since 1.7.0 |
||||
37 | */ |
||||
38 | function elgg_split() { |
||||
39 | $args = func_get_args(); |
||||
40 | if (is_callable('mb_split')) { |
||||
41 | return call_user_func_array('mb_split', $args); |
||||
42 | } |
||||
43 | return call_user_func_array('split', $args); |
||||
44 | } |
||||
45 | |||||
46 | /** |
||||
47 | * Wrapper function for mb_stristr(). Falls back to stristr() if |
||||
48 | * mb_stristr() isn't available. Parameters are passed to the |
||||
49 | * wrapped function in the same order they are passed to this |
||||
50 | * function. |
||||
51 | * |
||||
52 | * @return string |
||||
53 | * @since 1.7.0 |
||||
54 | */ |
||||
55 | function elgg_stristr() { |
||||
56 | $args = func_get_args(); |
||||
57 | if (is_callable('mb_stristr')) { |
||||
58 | return call_user_func_array('mb_stristr', $args); |
||||
59 | } |
||||
60 | return call_user_func_array('stristr', $args); |
||||
61 | } |
||||
62 | |||||
63 | /** |
||||
64 | * Wrapper function for mb_strlen(). Falls back to strlen() if |
||||
65 | * mb_strlen() isn't available. Parameters are passed to the |
||||
66 | * wrapped function in the same order they are passed to this |
||||
67 | * function. |
||||
68 | * |
||||
69 | * @return string |
||||
70 | * @since 1.7.0 |
||||
71 | */ |
||||
72 | function elgg_strlen() { |
||||
73 | 303 | $args = func_get_args(); |
|||
74 | 303 | if (is_callable('mb_strlen')) { |
|||
75 | 303 | return call_user_func_array('mb_strlen', $args); |
|||
76 | } |
||||
77 | return call_user_func_array('strlen', $args); |
||||
78 | } |
||||
79 | |||||
80 | /** |
||||
81 | * Wrapper function for mb_strpos(). Falls back to strpos() if |
||||
82 | * mb_strpos() isn't available. Parameters are passed to the |
||||
83 | * wrapped function in the same order they are passed to this |
||||
84 | * function. |
||||
85 | * |
||||
86 | * @return string |
||||
87 | * @since 1.7.0 |
||||
88 | */ |
||||
89 | function elgg_strpos() { |
||||
90 | 1 | $args = func_get_args(); |
|||
91 | 1 | if (is_callable('mb_strpos')) { |
|||
92 | 1 | return call_user_func_array('mb_strpos', $args); |
|||
93 | } |
||||
94 | return call_user_func_array('strpos', $args); |
||||
95 | } |
||||
96 | |||||
97 | /** |
||||
98 | * Wrapper function for mb_strrchr(). Falls back to strrchr() if |
||||
99 | * mb_strrchr() isn't available. Parameters are passed to the |
||||
100 | * wrapped function in the same order they are passed to this |
||||
101 | * function. |
||||
102 | * |
||||
103 | * @return string |
||||
104 | * @since 1.7.0 |
||||
105 | */ |
||||
106 | function elgg_strrchr() { |
||||
107 | $args = func_get_args(); |
||||
108 | if (is_callable('mb_strrchr')) { |
||||
109 | return call_user_func_array('mb_strrchr', $args); |
||||
110 | } |
||||
111 | return call_user_func_array('strrchr', $args); |
||||
112 | } |
||||
113 | |||||
114 | /** |
||||
115 | * Wrapper function for mb_strripos(). Falls back to strripos() if |
||||
116 | * mb_strripos() isn't available. Parameters are passed to the |
||||
117 | * wrapped function in the same order they are passed to this |
||||
118 | * function. |
||||
119 | * |
||||
120 | * @return int |
||||
121 | * @since 1.7.0 |
||||
122 | */ |
||||
123 | function elgg_strripos() { |
||||
124 | $args = func_get_args(); |
||||
125 | if (is_callable('mb_strripos')) { |
||||
126 | return call_user_func_array('mb_strripos', $args); |
||||
127 | } |
||||
128 | return call_user_func_array('strripos', $args); |
||||
129 | } |
||||
130 | |||||
131 | /** |
||||
132 | * Wrapper function for mb_strrpos(). Falls back to strrpos() if |
||||
133 | * mb_strrpos() isn't available. Parameters are passed to the |
||||
134 | * wrapped function in the same order they are passed to this |
||||
135 | * function. |
||||
136 | * |
||||
137 | * @return int |
||||
138 | * @since 1.7.0 |
||||
139 | */ |
||||
140 | function elgg_strrpos() { |
||||
141 | $args = func_get_args(); |
||||
142 | if (is_callable('mb_strrpos')) { |
||||
143 | return call_user_func_array('mb_strrpos', $args); |
||||
144 | } |
||||
145 | return call_user_func_array('strrpos', $args); |
||||
146 | } |
||||
147 | |||||
148 | /** |
||||
149 | * Wrapper function for mb_strstr(). Falls back to strstr() if |
||||
150 | * mb_strstr() isn't available. Parameters are passed to the |
||||
151 | * wrapped function in the same order they are passed to this |
||||
152 | * function. |
||||
153 | * |
||||
154 | * @return bool |
||||
155 | * @since 1.7.0 |
||||
156 | */ |
||||
157 | function elgg_strstr() { |
||||
158 | $args = func_get_args(); |
||||
159 | if (is_callable('mb_strstr')) { |
||||
160 | return call_user_func_array('mb_strstr', $args); |
||||
161 | } |
||||
162 | return call_user_func_array('strstr', $args); |
||||
163 | } |
||||
164 | |||||
165 | /** |
||||
166 | * Wrapper function for mb_strtolower(). Falls back to strtolower() if |
||||
167 | * mb_strtolower() isn't available. Parameters are passed to the |
||||
168 | * wrapped function in the same order they are passed to this |
||||
169 | * function. |
||||
170 | * |
||||
171 | * @return string |
||||
172 | * @since 1.7.0 |
||||
173 | */ |
||||
174 | function elgg_strtolower() { |
||||
175 | 73 | $args = func_get_args(); |
|||
176 | 73 | if (is_callable('mb_strtolower')) { |
|||
177 | 73 | return call_user_func_array('mb_strtolower', $args); |
|||
178 | } |
||||
179 | return call_user_func_array('strtolower', $args); |
||||
180 | } |
||||
181 | |||||
182 | /** |
||||
183 | * Wrapper function for mb_strtoupper(). Falls back to strtoupper() if |
||||
184 | * mb_strtoupper() isn't available. Parameters are passed to the |
||||
185 | * wrapped function in the same order they are passed to this |
||||
186 | * function. |
||||
187 | * |
||||
188 | * @return string |
||||
189 | * @since 1.7.0 |
||||
190 | */ |
||||
191 | function elgg_strtoupper() { |
||||
192 | $args = func_get_args(); |
||||
193 | if (is_callable('mb_strtoupper')) { |
||||
194 | return call_user_func_array('mb_strtoupper', $args); |
||||
195 | } |
||||
196 | return call_user_func_array('strtoupper', $args); |
||||
197 | } |
||||
198 | |||||
199 | /** |
||||
200 | * Wrapper for mb_convert_case($str, MB_CASE_TITLE) |
||||
201 | * |
||||
202 | * @param string $str String |
||||
203 | * @return string |
||||
204 | * @since 2.3 |
||||
205 | */ |
||||
206 | function elgg_ucwords($str) { |
||||
207 | if (is_callable('mb_convert_case')) { |
||||
208 | return mb_convert_case($str, MB_CASE_TITLE, 'UTF-8'); |
||||
209 | } |
||||
210 | return ucwords($str); |
||||
211 | } |
||||
212 | |||||
213 | /** |
||||
214 | * Wrapper function for mb_substr_count(). Falls back to substr_count() if |
||||
215 | * mb_substr_count() isn't available. Parameters are passed to the |
||||
216 | * wrapped function in the same order they are passed to this |
||||
217 | * function. |
||||
218 | * |
||||
219 | * @return int |
||||
220 | * @since 1.7.0 |
||||
221 | */ |
||||
222 | function elgg_substr_count() { |
||||
223 | 1 | $args = func_get_args(); |
|||
224 | 1 | if (is_callable('mb_substr_count')) { |
|||
225 | 1 | return call_user_func_array('mb_substr_count', $args); |
|||
226 | } |
||||
227 | return call_user_func_array('substr_count', $args); |
||||
228 | } |
||||
229 | |||||
230 | /** |
||||
231 | * Wrapper function for mb_substr(). Falls back to substr() if |
||||
232 | * mb_substr() isn't available. Parameters are passed to the |
||||
233 | * wrapped function in the same order they are passed to this |
||||
234 | * function. |
||||
235 | * |
||||
236 | * @return string |
||||
237 | * @since 1.7.0 |
||||
238 | */ |
||||
239 | function elgg_substr() { |
||||
240 | 2 | $args = func_get_args(); |
|||
241 | 2 | if (is_callable('mb_substr')) { |
|||
242 | 2 | return call_user_func_array('mb_substr', $args); |
|||
243 | } |
||||
244 | return call_user_func_array('substr', $args); |
||||
245 | } |
||||
246 | |||||
247 | /** |
||||
248 | * @see \Elgg\Application::loadCore Do not do work here. Just register for events. |
||||
249 | */ |
||||
250 | return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) { |
||||
1 ignored issue
–
show
The parameter
$events is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
|
|||||
251 | // if mb functions are available, set internal encoding to UTF8 |
||||
252 | 18 | if (is_callable('mb_internal_encoding')) { |
|||
253 | 18 | mb_internal_encoding("UTF-8"); |
|||
254 | } |
||||
255 | }; |
||||
256 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.