@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! function_exists('for_all')) { |
|
2 | +if (!function_exists('for_all')) { |
|
3 | 3 | /** |
4 | 4 | * Применение callback функции к каждому элементу массива, который является строкой или просто строке |
5 | 5 | * Всем переменным не являющимися массивом или строкой, будет присвоено значение null |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | -if (! function_exists('get_key')) { |
|
30 | +if (!function_exists('get_key')) { |
|
31 | 31 | /** |
32 | 32 | * Получение значения по ключу из массива, либо возврат значения по умолчанию |
33 | 33 | * |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | if (is_array($data) && (is_int($key) || is_string($key)) && $key !== '' && array_key_exists($key, $data)) { |
44 | 44 | $out = $data[$key]; |
45 | 45 | } |
46 | - if (! empty($validate) && is_callable($validate)) { |
|
46 | + if (!empty($validate) && is_callable($validate)) { |
|
47 | 47 | $out = (($validate($out) === true) ? $out : $default); |
48 | 48 | } |
49 | 49 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | -if (! function_exists('rename_key_array')) { |
|
54 | +if (!function_exists('rename_key_array')) { |
|
55 | 55 | /** |
56 | 56 | * Переменовывание элементов массива |
57 | 57 | * |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | $out = []; |
68 | 68 | if (is_array($data)) { |
69 | - if (! is_scalar($addPS)) { |
|
69 | + if (!is_scalar($addPS)) { |
|
70 | 70 | $addPS = ''; |
71 | 71 | } |
72 | 72 | $InsertPrefix = (is_scalar($prefix) && $prefix !== '') ? ($prefix . $addPS) : ''; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | -if (! function_exists('make_array')) { |
|
96 | +if (!function_exists('make_array')) { |
|
97 | 97 | /** |
98 | 98 | * Создание многомерного массива из двухмерного, в имени которого содержится разделитель |
99 | 99 | * |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $keys = explode($sep, $key); |
111 | 111 | $workArray = &$out; |
112 | 112 | foreach ($keys as $i => $subKey) { |
113 | - if (! array_key_exists($subKey, $workArray)) { |
|
113 | + if (!array_key_exists($subKey, $workArray)) { |
|
114 | 114 | $workArray[$subKey] = ($i + 1 == count($keys)) ? $val : []; |
115 | 115 | } |
116 | 116 | $workArray = &$workArray[$subKey]; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | -if (! function_exists('array_sort')) { |
|
128 | +if (!function_exists('array_sort')) { |
|
129 | 129 | /** |
130 | 130 | * Сортировка массива |
131 | 131 | * |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | function array_sort(array $arr, $sort_field, $desc = false) |
138 | 138 | { |
139 | 139 | $first = reset($arr); |
140 | - if (! isset($first[$sort_field])) { |
|
140 | + if (!isset($first[$sort_field])) { |
|
141 | 141 | return $arr; |
142 | 142 | } |
143 | 143 | $sort = []; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | -if (! function_exists('array_unset')) { |
|
153 | +if (!function_exists('array_unset')) { |
|
154 | 154 | /** |
155 | 155 | * Удаление списка ключей из массива |
156 | 156 | * |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | -if (! function_exists('array_filter')) { |
|
178 | +if (!function_exists('array_filter')) { |
|
179 | 179 | /** |
180 | 180 | * Фильтрация массива |
181 | 181 | * |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | -if (! function_exists('array_path')) { |
|
199 | +if (!function_exists('array_path')) { |
|
200 | 200 | /** |
201 | 201 | * Получение значения многомерного массива |
202 | 202 | * |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | { |
211 | 211 | $path = explode($separator, $path); |
212 | 212 | while ($key = array_shift($path)) { |
213 | - if (! isset($array[$key])) { |
|
213 | + if (!isset($array[$key])) { |
|
214 | 214 | return $default; |
215 | 215 | } |
216 | 216 | $array = $array[$key]; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | -if (! function_exists('array_path_unset')) { |
|
223 | +if (!function_exists('array_path_unset')) { |
|
224 | 224 | /** |
225 | 225 | * Удаление ключа многомерного массива |
226 | 226 | * |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $path = explode($separator, $path); |
236 | 236 | while (count($path) > 1) { |
237 | 237 | $key = array_shift($path); |
238 | - if (! isset($tmp[$key])) { |
|
238 | + if (!isset($tmp[$key])) { |
|
239 | 239 | return; |
240 | 240 | } |
241 | 241 | $tmp = &$tmp[$key]; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | -if (! function_exists('array_path_replace')) { |
|
247 | +if (!function_exists('array_path_replace')) { |
|
248 | 248 | /** |
249 | 249 | * Заменить значение многомерного массива |
250 | 250 | * |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $path = explode($separator, $path); |
261 | 261 | while (count($path) > 1) { |
262 | 262 | $key = array_shift($path); |
263 | - if (! isset($tmp[$key])) { |
|
263 | + if (!isset($tmp[$key])) { |
|
264 | 264 | $tmp[$key] = []; |
265 | 265 | } |
266 | 266 | $tmp = &$tmp[$key]; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
272 | -if (! function_exists('array_clean')) { |
|
272 | +if (!function_exists('array_clean')) { |
|
273 | 273 | /** |
274 | 274 | * Удалить пустые элементы из массива |
275 | 275 | * |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | -if (! function_exists('array_shuffle')) { |
|
286 | +if (!function_exists('array_shuffle')) { |
|
287 | 287 | /** |
288 | 288 | * Перемешать массив в случайном порядке с сохранением ключей |
289 | 289 | * |
@@ -292,13 +292,13 @@ discard block |
||
292 | 292 | */ |
293 | 293 | function array_shuffle(array &$data = []) |
294 | 294 | { |
295 | - return uksort($data, function () { |
|
295 | + return uksort($data, function() { |
|
296 | 296 | return rand() > rand(); |
297 | 297 | }); |
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
301 | -if (! function_exists('array_random')) { |
|
301 | +if (!function_exists('array_random')) { |
|
302 | 302 | /** |
303 | 303 | * Получить несколько случайных записей из массива с сохранением ключей |
304 | 304 | * |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | { |
311 | 311 | $flag = array_shuffle($data); |
312 | 312 | if ($flag) { |
313 | - if ((int)$count > 0) { |
|
314 | - $data = current(array_chunk($data, (int)$count, true)); |
|
313 | + if ((int) $count > 0) { |
|
314 | + $data = current(array_chunk($data, (int) $count, true)); |
|
315 | 315 | } |
316 | 316 | } else { |
317 | 317 | $data = []; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
324 | -if (! function_exists('is_assoc')) { |
|
324 | +if (!function_exists('is_assoc')) { |
|
325 | 325 | /** |
326 | 326 | * Является ли массив ассоциативным |
327 | 327 | * |
@@ -330,11 +330,11 @@ discard block |
||
330 | 330 | */ |
331 | 331 | function is_assoc($array) |
332 | 332 | { |
333 | - return is_array($array) ? (bool)count(array_filter(array_keys($array), 'is_string')) : false; |
|
333 | + return is_array($array) ? (bool) count(array_filter(array_keys($array), 'is_string')) : false; |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | -if (! function_exists('array_copy_key')) { |
|
337 | +if (!function_exists('array_copy_key')) { |
|
338 | 338 | /** |
339 | 339 | * Определить ключи массива равыне значениям |
340 | 340 | * |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | function array_copy_key(array $data = []) |
345 | 345 | { |
346 | - $data = array_filter($data, function ($val) { |
|
346 | + $data = array_filter($data, function($val) { |
|
347 | 347 | return is_scalar($val); |
348 | 348 | }); |
349 | 349 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | -if (! function_exists('make_tree')) { |
|
354 | +if (!function_exists('make_tree')) { |
|
355 | 355 | /** |
356 | 356 | * Helper function |
357 | 357 | * @see http://gostash.it/ru/users/3191 |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | { |
368 | 368 | $result = []; |
369 | 369 | |
370 | - if (! empty($tree)) { |
|
370 | + if (!empty($tree)) { |
|
371 | 371 | $m = []; |
372 | 372 | |
373 | 373 | foreach ($tree as $e) { |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
387 | -if (! function_exists('array_chunk_vcolumn')) { |
|
387 | +if (!function_exists('array_chunk_vcolumn')) { |
|
388 | 388 | /** |
389 | 389 | * Разбиение массива на несколько частей с сохранением ключей, чтобы в каждой из этих частей было равное кол-во элементов |
390 | 390 | * Массив наполняется последовательно. Т.е. сначала наполняется данными первая часть, потом вторая и так, пока не закончатся данные. |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | } |
412 | 412 | } |
413 | 413 | |
414 | -if (! function_exists('array_chunk_hcolumn')) { |
|
414 | +if (!function_exists('array_chunk_hcolumn')) { |
|
415 | 415 | /** |
416 | 416 | * Разбиение массива на несколько частей с сохранением ключей, чтобы в каждой из этих частей было равное кол-во элементов |
417 | 417 | * Массив наполняется равномерно. Т.е. в первую строку каждой части складывается по одному элементу из массива. Затем аналогичным образом во вторую и так, пока не закончатся данные. |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | } |
435 | 435 | } |
436 | 436 | |
437 | -if (! function_exists('array_filter_keys')) { |
|
437 | +if (!function_exists('array_filter_keys')) { |
|
438 | 438 | /** |
439 | 439 | * Фильтрация массива по ключу |
440 | 440 | * |
@@ -443,14 +443,14 @@ discard block |
||
443 | 443 | */ |
444 | 444 | function array_filter_keys($array, $needle) |
445 | 445 | { |
446 | - $matchedKeys = array_filter(array_keys($array), function ($key) use ($needle) { |
|
446 | + $matchedKeys = array_filter(array_keys($array), function($key) use ($needle) { |
|
447 | 447 | return preg_match($needle, $key); |
448 | 448 | }); |
449 | 449 | |
450 | 450 | return array_intersect_key($array, array_flip($matchedKeys)); |
451 | 451 | } |
452 | 452 | } |
453 | -if (! function_exists('choose_chance')) { |
|
453 | +if (!function_exists('choose_chance')) { |
|
454 | 454 | /*** |
455 | 455 | * Выбор ключа массива со определенной вероятность |
456 | 456 | * choose_chance(array("a" => 10, "b" => 25, "c" => 25, "d" => 40)); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! function_exists('supports_ansi_colors')) { |
|
2 | +if (!function_exists('supports_ansi_colors')) { |
|
3 | 3 | /** |
4 | 4 | * Функция позволяет узнать, поддерживает ли консоль цвета и другое форматирование. |
5 | 5 | * @see: https://gostash.it/ru/stashes/1601-podderzivaet-li-konsol-cveta |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | } |
19 | 19 | } |
20 | 20 | |
21 | -if (! function_exists('check_email')) { |
|
21 | +if (!function_exists('check_email')) { |
|
22 | 22 | /** |
23 | 23 | * Проверка строки с email на наличие ошибок |
24 | 24 | * Если e-mail валидный, то в ответ будет получено false |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | if (filter_var($email, FILTER_VALIDATE_EMAIL)) { |
36 | 36 | list(, $domain) = explode("@", $email, 2); |
37 | - if (! $dns || ($dns && checkdnsrr($domain, "MX") && checkdnsrr($domain, "A"))) { |
|
37 | + if (!$dns || ($dns && checkdnsrr($domain, "MX") && checkdnsrr($domain, "A"))) { |
|
38 | 38 | $error = false; |
39 | 39 | } else { |
40 | 40 | $error = 'dns'; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | -if (! function_exists('generate_password')) { |
|
50 | +if (!function_exists('generate_password')) { |
|
51 | 51 | /** |
52 | 52 | * Генерация пароля |
53 | 53 | * |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | -if (! function_exists('get_gravatar')) { |
|
102 | +if (!function_exists('get_gravatar')) { |
|
103 | 103 | /** |
104 | 104 | * Получение ссылки на аватарку с gravatar |
105 | 105 | * |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | */ |
110 | 110 | function get_gravatar($email, $size = 32) |
111 | 111 | { |
112 | - $url = '//www.gravatar.com/avatar/' . md5(is_scalar($email) ? $email : '') . '?s=' . (int)abs($size); |
|
112 | + $url = '//www.gravatar.com/avatar/' . md5(is_scalar($email) ? $email : '') . '?s=' . (int) abs($size); |
|
113 | 113 | |
114 | 114 | return $url; |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | -if (! function_exists('share_vk')) { |
|
118 | +if (!function_exists('share_vk')) { |
|
119 | 119 | /** |
120 | 120 | * Получение ссылки поделиться для "Вконтакте" |
121 | 121 | * |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | -if (! function_exists('share_ok')) { |
|
132 | +if (!function_exists('share_ok')) { |
|
133 | 133 | /** |
134 | 134 | * Получение ссылки поделиться для "Одноклассников" |
135 | 135 | * |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | -if (! function_exists('share_google')) { |
|
148 | +if (!function_exists('share_google')) { |
|
149 | 149 | /** |
150 | 150 | * Получение ссылки поделиться для "Google+" |
151 | 151 | * |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | -if (! function_exists('share_facebook')) { |
|
161 | +if (!function_exists('share_facebook')) { |
|
162 | 162 | /** |
163 | 163 | * Получение ссылки поделиться для "Facebook" |
164 | 164 | * |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | -if (! function_exists('share_twitter')) { |
|
177 | +if (!function_exists('share_twitter')) { |
|
178 | 178 | /** |
179 | 179 | * Получение ссылки поделиться для "Twitter" |
180 | 180 | * |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | -if (! function_exists('share_mail')) { |
|
191 | +if (!function_exists('share_mail')) { |
|
192 | 192 | /** |
193 | 193 | * Получение ссылки поделиться для "Mail.ru" |
194 | 194 | * |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | -if (! function_exists('share_linkedin')) { |
|
205 | +if (!function_exists('share_linkedin')) { |
|
206 | 206 | /** |
207 | 207 | * Получение ссылки поделиться для "LinkedIN" |
208 | 208 | * |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
219 | -if (! function_exists('qr_code')) { |
|
219 | +if (!function_exists('qr_code')) { |
|
220 | 220 | /** |
221 | 221 | * Генерация QR-кода для строки |
222 | 222 | * |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function qr_code($str, $size = 230) |
228 | 228 | { |
229 | - $size = (int)$size; |
|
229 | + $size = (int) $size; |
|
230 | 230 | $size = implode("x", [$size, $size]); |
231 | 231 | |
232 | 232 | return '//chart.apis.google.com/chart?cht=qr&chs=' . $size . '&chl=' . (is_scalar($str) ? urlencode($str) : ''); |
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | -if (! function_exists('get_user_ip')) { |
|
236 | +if (!function_exists('get_user_ip')) { |
|
237 | 237 | /** |
238 | 238 | * Получение реального ip текущего пользователя |
239 | 239 | * |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | function get_user_ip($out = '127.0.0.1') |
246 | 246 | { |
247 | - $_getEnv = function ($data) { |
|
247 | + $_getEnv = function($data) { |
|
248 | 248 | switch (true) { |
249 | 249 | case (isset($_SERVER[$data])): |
250 | 250 | $out = $_SERVER[$data]; |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | case ($tmp = $_getEnv('HTTP_X_FORWARDED_FOR')): |
290 | 290 | $out = $tmp; |
291 | 291 | break; |
292 | - case (! empty($_SERVER['REMOTE_ADDR'])): |
|
292 | + case (!empty($_SERVER['REMOTE_ADDR'])): |
|
293 | 293 | $out = $_SERVER['REMOTE_ADDR']; |
294 | 294 | break; |
295 | 295 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
302 | -if (! function_exists('whois_query')) { |
|
302 | +if (!function_exists('whois_query')) { |
|
303 | 303 | /** |
304 | 304 | * Получение whois информации о домене |
305 | 305 | * @see http://www.jonasjohn.de/snippets/php/whois-query.htm |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | "nl" => "whois.domain-registry.nl" |
370 | 370 | ]; |
371 | 371 | |
372 | - if (! isset($servers[$ext])) { |
|
372 | + if (!isset($servers[$ext])) { |
|
373 | 373 | throw new ErrorException('No matching nic server found!'); |
374 | 374 | } |
375 | 375 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | // connect to whois server: |
381 | 381 | if ($conn = fsockopen($nic_server, 43)) { |
382 | 382 | fputs($conn, $domain . "\r\n"); |
383 | - while (! feof($conn)) { |
|
383 | + while (!feof($conn)) { |
|
384 | 384 | $output .= fgets($conn, 128); |
385 | 385 | } |
386 | 386 | fclose($conn); |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | } |
393 | 393 | } |
394 | 394 | |
395 | -if (! function_exists('copyright')) { |
|
395 | +if (!function_exists('copyright')) { |
|
396 | 396 | /** |
397 | 397 | * Геренатор года для подстановки в копирайты |
398 | 398 | * |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | -if (! function_exists('mime_file')) { |
|
411 | +if (!function_exists('mime_file')) { |
|
412 | 412 | /** |
413 | 413 | * Получение MIME типа файла |
414 | 414 | * |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | -if (! function_exists('image_size')) { |
|
459 | +if (!function_exists('image_size')) { |
|
460 | 460 | /** |
461 | 461 | * Определение размеров картинки |
462 | 462 | * |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | -if (! function_exists('plural')) { |
|
492 | +if (!function_exists('plural')) { |
|
493 | 493 | /** |
494 | 494 | * Определение падежа слова в зависимости от числового значения |
495 | 495 | * |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | function plural($number, array $titles = []) |
501 | 501 | { |
502 | 502 | $cases = [2, 0, 1, 1, 1, 2]; |
503 | - $number = (int)$number; |
|
503 | + $number = (int) $number; |
|
504 | 504 | $position = ($number % 100 > 4 && $number % 100 < 20) ? 2 : $cases[($number % 10 < 5) ? $number % 10 : 5]; |
505 | 505 | $out = isset($titles[$position]) ? $titles[$position] : ''; |
506 | 506 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | } |
509 | 509 | } |
510 | 510 | |
511 | -if (! function_exists('validate_date')) { |
|
511 | +if (!function_exists('validate_date')) { |
|
512 | 512 | /** |
513 | 513 | * Проверка валидности даты |
514 | 514 | * |
@@ -533,14 +533,14 @@ discard block |
||
533 | 533 | $datetime2 = \DateTime::createFromFormat($fromFormat, $date); |
534 | 534 | if ($datetime2 instanceof \DateTime) { |
535 | 535 | $interval = $datetime1->diff($datetime2); |
536 | - $validTime = is_callable($validator) ? (bool)$validator($datetime2, $interval) : true; |
|
536 | + $validTime = is_callable($validator) ? (bool) $validator($datetime2, $interval) : true; |
|
537 | 537 | } |
538 | 538 | } |
539 | 539 | |
540 | 540 | return $validTime ? $datetime2->format($toFormat) : null; |
541 | 541 | } |
542 | 542 | } |
543 | -if (! function_exists('format_bytes')) { |
|
543 | +if (!function_exists('format_bytes')) { |
|
544 | 544 | /** |
545 | 545 | * Преобразование из байт в другие порядки (кило, мега, гига) с добавлением префикса |
546 | 546 | * |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | */ |
552 | 552 | function format_bytes($bytes, $precision = 2, $suffixes = ['Байт', 'Кбайт', 'Мбайт', 'Гбайт', 'Тбайт']) |
553 | 553 | { |
554 | - $bytes = (float)$bytes; |
|
554 | + $bytes = (float) $bytes; |
|
555 | 555 | if (empty($bytes)) { |
556 | 556 | return 0; |
557 | 557 | } |
@@ -560,12 +560,12 @@ discard block |
||
560 | 560 | return trim( |
561 | 561 | round(pow(1024, $base - floor($base)), $precision) . |
562 | 562 | ' ' . |
563 | - get_key($suffixes, (int)$base, '', 'is_scalar') |
|
563 | + get_key($suffixes, (int) $base, '', 'is_scalar') |
|
564 | 564 | ); |
565 | 565 | } |
566 | 566 | } |
567 | 567 | |
568 | -if (! function_exists('format_microtime')) { |
|
568 | +if (!function_exists('format_microtime')) { |
|
569 | 569 | /** |
570 | 570 | * Форматирование microtime времени |
571 | 571 | * @param string $time microtime время |
@@ -573,10 +573,10 @@ discard block |
||
573 | 573 | */ |
574 | 574 | function format_microtime($time, $len = 4) |
575 | 575 | { |
576 | - return sprintf("%." . (int)$len . "f", $time); |
|
576 | + return sprintf("%." . (int) $len . "f", $time); |
|
577 | 577 | } |
578 | 578 | } |
579 | -if (! function_exists('ip_in_range')) { |
|
579 | +if (!function_exists('ip_in_range')) { |
|
580 | 580 | /** |
581 | 581 | * Входит ли указанный IP в заданный диапазон |
582 | 582 | * |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | } |
592 | 592 | } |
593 | 593 | |
594 | -if (! function_exists('make_csv')) { |
|
594 | +if (!function_exists('make_csv')) { |
|
595 | 595 | /** |
596 | 596 | * Формирование правильной CSV строки |
597 | 597 | * |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! function_exists('value')) { |
|
2 | +if (!function_exists('value')) { |
|
3 | 3 | /** |
4 | 4 | * Если аргумент это замыкание, то вычисляется его значение и отдается в виде результата |
5 | 5 | * В противном случае возвращается сам аргумент |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
16 | -if (! function_exists('is_serialized')) { |
|
16 | +if (!function_exists('is_serialized')) { |
|
17 | 17 | /** |
18 | 18 | * Проверка переменной на предмет наличия в ней сериализованных данных |
19 | 19 | * |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function is_serialized($data) |
24 | 24 | { |
25 | - if (! is_string($data)) { |
|
25 | + if (!is_string($data)) { |
|
26 | 26 | return false; |
27 | 27 | } |
28 | 28 | $data = trim($data); |
@@ -46,18 +46,18 @@ discard block |
||
46 | 46 | return ('"' === $data[$length - 2]); |
47 | 47 | case 'a': |
48 | 48 | case 'O': |
49 | - return (bool)preg_match("/^{$token}:[0-9]+:/s", $data); |
|
49 | + return (bool) preg_match("/^{$token}:[0-9]+:/s", $data); |
|
50 | 50 | case 'b': |
51 | 51 | case 'i': |
52 | 52 | case 'd': |
53 | - return (bool)preg_match("/^{$token}:[0-9.E-]+;\$/", $data); |
|
53 | + return (bool) preg_match("/^{$token}:[0-9.E-]+;\$/", $data); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | return false; |
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | -if (! function_exists('var_switch')) { |
|
60 | +if (!function_exists('var_switch')) { |
|
61 | 61 | /** |
62 | 62 | * Поменять местами значения двух переменных |
63 | 63 | * |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | -if (! function_exists('arity')) { |
|
74 | +if (!function_exists('arity')) { |
|
75 | 75 | /** |
76 | 76 | * Сколько параметров принимает данное замыкание |
77 | 77 | * |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! function_exists('mb_lcfirst') && extension_loaded('mbstring')) { |
|
2 | +if (!function_exists('mb_lcfirst') && extension_loaded('mbstring')) { |
|
3 | 3 | /** |
4 | 4 | * Преобразует первый символ в нижний регистр |
5 | 5 | * |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | function mb_lcfirst($data, $charset = 'UTF-8') |
11 | 11 | { |
12 | - return for_all($data, function ($el) use ($charset) { |
|
12 | + return for_all($data, function($el) use ($charset) { |
|
13 | 13 | $str = one_space($el); |
14 | 14 | |
15 | 15 | return mb_strtolower(mb_substr($str, 0, 1, $charset), $charset) . |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | } |
19 | 19 | } |
20 | 20 | |
21 | -if (! function_exists('mb_ucfirst') && extension_loaded('mbstring')) { |
|
21 | +if (!function_exists('mb_ucfirst') && extension_loaded('mbstring')) { |
|
22 | 22 | /** |
23 | 23 | * Преобразует первый символ в верхний регистр |
24 | 24 | * |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function mb_ucfirst($data, $charset = 'UTF-8') |
30 | 30 | { |
31 | - return for_all($data, function ($el) use ($charset) { |
|
31 | + return for_all($data, function($el) use ($charset) { |
|
32 | 32 | $str = one_space($el); |
33 | 33 | |
34 | 34 | return mb_strtoupper(mb_substr($str, 0, 1, $charset), $charset) . |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | -if (! function_exists('one_space')) { |
|
40 | +if (!function_exists('one_space')) { |
|
41 | 41 | /** |
42 | 42 | * Заменить множественную последовательность пробелов и табуляций на 1 пробел |
43 | 43 | * |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function one_space($data) |
48 | 48 | { |
49 | - return for_all($data, function ($el) { |
|
49 | + return for_all($data, function($el) { |
|
50 | 50 | return preg_replace('/[ \t]+/', ' ', $el); |
51 | 51 | }); |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | -if (! function_exists('one_new_line')) { |
|
55 | +if (!function_exists('one_new_line')) { |
|
56 | 56 | /** |
57 | 57 | * Заменить множественную последовательность перевода строки на 1 перевод |
58 | 58 | * |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | */ |
62 | 62 | function one_new_line($data) |
63 | 63 | { |
64 | - return for_all($data, function ($el) { |
|
64 | + return for_all($data, function($el) { |
|
65 | 65 | return preg_replace('/(\R)+/', '$1', $el); |
66 | 66 | }); |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | -if (! function_exists('full_one_space')) { |
|
70 | +if (!function_exists('full_one_space')) { |
|
71 | 71 | /** |
72 | 72 | * Заменить множественную последовательность пробелов, табуляций и переводов строк на 1 пробел |
73 | 73 | * |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | */ |
77 | 77 | function full_one_space($data) |
78 | 78 | { |
79 | - return for_all($data, function ($el) { |
|
79 | + return for_all($data, function($el) { |
|
80 | 80 | return preg_replace('/\s+/', ' ', $el); |
81 | 81 | }); |
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | -if (! function_exists('e_decode')) { |
|
85 | +if (!function_exists('e_decode')) { |
|
86 | 86 | /** |
87 | 87 | * Декодирование HTML сущностей в строке |
88 | 88 | * |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | */ |
93 | 93 | function e_decode($data, $charset = 'UTF-8') |
94 | 94 | { |
95 | - return for_all($data, function ($el) use ($charset) { |
|
95 | + return for_all($data, function($el) use ($charset) { |
|
96 | 96 | return one_space(str_replace("\xC2\xA0", ' ', html_entity_decode($el, ENT_COMPAT, $charset))); |
97 | 97 | }); |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | -if (! function_exists('e')) { |
|
101 | +if (!function_exists('e')) { |
|
102 | 102 | /** |
103 | 103 | * Преобразование всех символов строки в HTML сущности |
104 | 104 | * |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | */ |
109 | 109 | function e($data, $charset = 'UTF-8') |
110 | 110 | { |
111 | - return for_all($data, function ($el) use ($charset) { |
|
111 | + return for_all($data, function($el) use ($charset) { |
|
112 | 112 | return one_space(htmlentities($el, ENT_COMPAT | ENT_SUBSTITUTE, $charset, false)); |
113 | 113 | }); |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | -if (! function_exists('camel_case')) { |
|
117 | +if (!function_exists('camel_case')) { |
|
118 | 118 | /** |
119 | 119 | * Преобразовывание строки в CamelCase формат |
120 | 120 | * |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | function camel_case($str, $first = false) |
126 | 126 | { |
127 | - return for_all($str, function ($str) use ($first) { |
|
127 | + return for_all($str, function($str) use ($first) { |
|
128 | 128 | $str = preg_replace('/[^-_\w\s]/', '', $str); |
129 | 129 | $parts = preg_split('/[-_\s]/', $str); |
130 | 130 | $out = strtolower(array_shift($parts)); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | -if (! function_exists('underscore')) { |
|
143 | +if (!function_exists('underscore')) { |
|
144 | 144 | /** |
145 | 145 | * Преобразовывание строки в underscore формат |
146 | 146 | * |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | function underscore($str) |
151 | 151 | { |
152 | - return for_all($str, function ($str) { |
|
152 | + return for_all($str, function($str) { |
|
153 | 153 | $str = preg_replace('/[^-_\w\s]/', '', $str); |
154 | 154 | $str = preg_replace('/([a-z])([A-Z])/', '$1 $2', $str); |
155 | 155 | $str = preg_replace('/[-\s]/', '_', $str); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | -if (! function_exists('normalize_name')) { |
|
162 | +if (!function_exists('normalize_name')) { |
|
163 | 163 | /** |
164 | 164 | * Нормализация имен |
165 | 165 | * Иванов-петров => Иванов-Петров |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | function normalize_name($name) |
171 | 171 | { |
172 | - return for_all($name, function ($name) { |
|
172 | + return for_all($name, function($name) { |
|
173 | 173 | $name = ucwords(strtolower($name)); |
174 | 174 | foreach (['-', "'"] as $delimiter) { |
175 | 175 | if (strpos($name, $delimiter) !== false) { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | -if (! function_exists('mb_str_replace')) { |
|
185 | +if (!function_exists('mb_str_replace')) { |
|
186 | 186 | /** |
187 | 187 | * Replace all occurrences of the search string with the replacement string. |
188 | 188 | * |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | function mb_str_replace($search, $replace, $subject, &$count = 0) |
202 | 202 | { |
203 | 203 | mb_regex_encoding('utf-8'); |
204 | - if (! is_array($subject)) { |
|
204 | + if (!is_array($subject)) { |
|
205 | 205 | // Normalize $search and $replace so they are both arrays of the same length |
206 | 206 | $searches = is_array($search) ? array_values($search) : [$search]; |
207 | 207 | $replacements = is_array($replace) ? array_values($replace) : [$replace]; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | -if (! function_exists('mb_trim_word')) { |
|
226 | +if (!function_exists('mb_trim_word')) { |
|
227 | 227 | /** |
228 | 228 | * Обрезание текста по длине с поиском последнего полностью вмещающегося слова и удалением лишних крайних знаков пунктуации. |
229 | 229 | * |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | -if (! function_exists('strip_tags_smart')) { |
|
249 | +if (!function_exists('strip_tags_smart')) { |
|
250 | 250 | /** |
251 | 251 | * Более продвинутый аналог strip_tags() для корректного вырезания тагов из html кода. |
252 | 252 | * Функция strip_tags(), в зависимости от контекста, может работать не корректно. |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | if (is_array($s)) { |
316 | 316 | if ($_callback_type === 'strip_tags') { |
317 | 317 | $tag = strtolower($s[1]); |
318 | - if (! empty($_allowable_tags)) { |
|
318 | + if (!empty($_allowable_tags)) { |
|
319 | 319 | #tag with attributes |
320 | 320 | if (array_key_exists($tag, $_allowable_tags)) { |
321 | 321 | return $s[0]; |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | if ($tag === 'br') { |
337 | 337 | return "\r\n"; |
338 | 338 | } |
339 | - if (! empty($_para_tags) && array_key_exists($tag, $_para_tags)) { |
|
339 | + if (!empty($_para_tags) && array_key_exists($tag, $_para_tags)) { |
|
340 | 340 | return "\r\n\r\n"; |
341 | 341 | } |
342 | 342 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | > |
385 | 385 | /sxSX', |
386 | 386 | ]; |
387 | - if (! empty($pair_tags)) { |
|
387 | + if (!empty($pair_tags)) { |
|
388 | 388 | #парные таги вместе с содержимым: |
389 | 389 | foreach ($pair_tags as $k => $v) { |
390 | 390 | $pair_tags[$k] = preg_quote($v, '/'); |
@@ -434,12 +434,12 @@ discard block |
||
434 | 434 | } |
435 | 435 | |
436 | 436 | #массив тагов, которые не будут вырезаны |
437 | - if (! empty($allowable_tags)) { |
|
437 | + if (!empty($allowable_tags)) { |
|
438 | 438 | $_allowable_tags = array_flip($allowable_tags); |
439 | 439 | } |
440 | 440 | |
441 | 441 | #парные таги, которые будут восприниматься как параграфы |
442 | - if (! empty($para_tags)) { |
|
442 | + if (!empty($para_tags)) { |
|
443 | 443 | $_para_tags = array_flip($para_tags); |
444 | 444 | } |
445 | 445 | } |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
483 | -if (! function_exists('last_implode')) { |
|
483 | +if (!function_exists('last_implode')) { |
|
484 | 484 | /** |
485 | 485 | * Склеивание всех элементов массива по разделителю. Для последнего элемента используется специфичный разделитель |
486 | 486 | * |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | } |
502 | 502 | } |
503 | 503 | |
504 | -if (! function_exists('is_nop')) { |
|
504 | +if (!function_exists('is_nop')) { |
|
505 | 505 | /** |
506 | 506 | * Является ли строка пустой |
507 | 507 | * |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | } |
515 | 515 | } |
516 | 516 | |
517 | -if (! function_exists('first_word')) { |
|
517 | +if (!function_exists('first_word')) { |
|
518 | 518 | /** |
519 | 519 | * Получение первого слова из строки |
520 | 520 | * |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | } |
528 | 528 | } |
529 | 529 | |
530 | -if (! function_exists('is_real_int')) { |
|
530 | +if (!function_exists('is_real_int')) { |
|
531 | 531 | /** |
532 | 532 | * Проверяет содержит ли переменная тип integer. |
533 | 533 | * Функция успешно определяет целые числа даже если они хранятся в переменной с типом string |
@@ -537,11 +537,11 @@ discard block |
||
537 | 537 | */ |
538 | 538 | function is_real_int($value) |
539 | 539 | { |
540 | - return is_numeric($value) && ! is_float(1 * $value); |
|
540 | + return is_numeric($value) && !is_float(1 * $value); |
|
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
544 | -if (! function_exists('is_real_float')) { |
|
544 | +if (!function_exists('is_real_float')) { |
|
545 | 545 | /** |
546 | 546 | * Проверяет содержит ли переменная тип float. |
547 | 547 | * Функция успешно определяет числа с плавающей точкой даже если они хранятся в переменной с типом string |
@@ -551,6 +551,6 @@ discard block |
||
551 | 551 | */ |
552 | 552 | function is_real_float($value) |
553 | 553 | { |
554 | - return is_numeric($value) && is_float(1*$value); |
|
554 | + return is_numeric($value) && is_float(1 * $value); |
|
555 | 555 | } |
556 | 556 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! function_exists('html_implode')) { |
|
2 | +if (!function_exists('html_implode')) { |
|
3 | 3 | /** |
4 | 4 | * Каждый элемент массива обернуть в html тег |
5 | 5 | * |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
16 | -if (! function_exists('html_table')) { |
|
16 | +if (!function_exists('html_table')) { |
|
17 | 17 | /** |
18 | 18 | * Создать таблицу из массива |
19 | 19 | * |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | } else { |
32 | 32 | $thead = $table; |
33 | 33 | } |
34 | - if (! empty($thead)) { |
|
34 | + if (!empty($thead)) { |
|
35 | 35 | $thead = html_wrap('thead', html_wrap('tr', $thead)); |
36 | 36 | } |
37 | 37 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | -if (! function_exists('html_wrap')) { |
|
46 | +if (!function_exists('html_wrap')) { |
|
47 | 47 | /** |
48 | 48 | * Обернуть некий текст в html тег |
49 | 49 | * |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -if (! function_exists('empty_tag')) { |
|
63 | +if (!function_exists('empty_tag')) { |
|
64 | 64 | /** |
65 | 65 | * Создать пустой html тег |
66 | 66 | * |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | -if (! function_exists('html_attrs')) { |
|
79 | +if (!function_exists('html_attrs')) { |
|
80 | 80 | /** |
81 | 81 | * Создать список аттрибутов для html тега |
82 | 82 | * |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -if (! function_exists('make_options')) { |
|
107 | +if (!function_exists('make_options')) { |
|
108 | 108 | /** |
109 | 109 | * Создать html список select для формы |
110 | 110 | * |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $options = []; |
122 | 122 | $selected = false; |
123 | 123 | foreach ($data as $title => $value) { |
124 | - if (! is_array($value)) { |
|
124 | + if (!is_array($value)) { |
|
125 | 125 | $value = [ |
126 | 126 | 'value' => $value |
127 | 127 | ]; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | if (is_int($title)) { |
131 | 131 | $title = get_key($value, 'value', $title); |
132 | 132 | } |
133 | - if ((string)$val === (string)$current) { |
|
133 | + if ((string) $val === (string) $current) { |
|
134 | 134 | $value['selected'] = true; |
135 | 135 | $selected = true; |
136 | 136 | } else { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $options[$title] = $value; |
141 | 141 | } |
142 | 142 | foreach ($options as $title => $attr) { |
143 | - if (! $selected && get_key($attr, 'value', '') == $default) { |
|
143 | + if (!$selected && get_key($attr, 'value', '') == $default) { |
|
144 | 144 | $attr['selected'] = true; |
145 | 145 | } |
146 | 146 | $out .= html_wrap('option', $title, $attr); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | -if (! function_exists('img_tag')) { |
|
154 | +if (!function_exists('img_tag')) { |
|
155 | 155 | /** |
156 | 156 | * Создать html тег img |
157 | 157 | * |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | -if (! function_exists('a_tag')) { |
|
170 | +if (!function_exists('a_tag')) { |
|
171 | 171 | /** |
172 | 172 | * Создать html тег a |
173 | 173 | * |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | -if (! function_exists('input_tag')) { |
|
188 | +if (!function_exists('input_tag')) { |
|
189 | 189 | /** |
190 | 190 | * Создать html тег input |
191 | 191 | * |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | -if (! function_exists('stylesheet_link_tag')) { |
|
208 | +if (!function_exists('stylesheet_link_tag')) { |
|
209 | 209 | /** |
210 | 210 | * Создать html тег для подключения файла с CSS стилями |
211 | 211 | * |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | -if (! function_exists('javascript_include_tag')) { |
|
226 | +if (!function_exists('javascript_include_tag')) { |
|
227 | 227 | /** |
228 | 228 | * Создать html тег для подключения файла с JavaScript |
229 | 229 | * |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
243 | -if (! function_exists('between_tag')) { |
|
243 | +if (!function_exists('between_tag')) { |
|
244 | 244 | /** |
245 | 245 | * Вырезание текста между HTML тэгов |
246 | 246 | * |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | if (isset($m[1], $m[2])) { |
261 | 261 | //Начинаем поиски закрывающих тегов (всех до конца документа) |
262 | 262 | preg_match_all('%</' . $tag . '[^>]*>%is', $m[2], $tmp, PREG_OFFSET_CAPTURE); |
263 | - if (! empty($tmp[0])) { |
|
263 | + if (!empty($tmp[0])) { |
|
264 | 264 | foreach ($tmp[0] as $j => $subTmp) { |
265 | 265 | $closeTag = $subTmp[0]; //закрывающий тэг |
266 | 266 | $subText = substr($m[2], 0, $subTmp[1]); //Тексту внутри тэгов |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | } |
276 | 276 | $html = substr($m[2], $tmp[0][$j][1] + strlen($tmp[0][$j][0])); |
277 | 277 | } |
278 | - if (! $new) { |
|
278 | + if (!$new) { |
|
279 | 279 | if (isset($tmp[0][$j]) && $j < $count[0]) { |
280 | 280 | $subTmp = $tmp[0][$j]; |
281 | 281 | $closeTag = $subTmp[0]; |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | } else { |
292 | 292 | $html = ''; |
293 | 293 | } |
294 | - } while (! empty($html)); |
|
294 | + } while (!empty($html)); |
|
295 | 295 | |
296 | 296 | return $replace; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | -if (! function_exists('clear_html')) { |
|
300 | +if (!function_exists('clear_html')) { |
|
301 | 301 | /** |
302 | 302 | * Удаление комментариев, переносов и лишних пробелов из html строки |
303 | 303 | * |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! function_exists('is_even')) { |
|
2 | +if (!function_exists('is_even')) { |
|
3 | 3 | /** |
4 | 4 | * Четное ли число хранится внутри переменной |
5 | 5 | * |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | } |
13 | 13 | } |
14 | 14 | |
15 | -if (! function_exists('plus_minus')) { |
|
15 | +if (!function_exists('plus_minus')) { |
|
16 | 16 | /** |
17 | 17 | * Подстановка +/- перед значением переменной |
18 | 18 | * |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function plus_minus($num, $plus = '+', $minus = '-') |
25 | 25 | { |
26 | - if (! is_scalar($num)) { |
|
26 | + if (!is_scalar($num)) { |
|
27 | 27 | $num = 0; |
28 | 28 | } |
29 | 29 | if ($num < 0) { |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
41 | -if (! function_exists('strip_non_numeric')) { |
|
41 | +if (!function_exists('strip_non_numeric')) { |
|
42 | 42 | /** |
43 | 43 | * Удаление из переменной всех не числовых символов |
44 | 44 | * |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | */ |
48 | 48 | function strip_non_numeric($string) |
49 | 49 | { |
50 | - return is_scalar($string) ? (int)preg_replace('/[^0-9]+/', '', $string) : null; |
|
50 | + return is_scalar($string) ? (int) preg_replace('/[^0-9]+/', '', $string) : null; |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | -if (! function_exists('clean_ids')) { |
|
54 | +if (!function_exists('clean_ids')) { |
|
55 | 55 | /** |
56 | 56 | * Удаление из массива значений меньше нуля, а так же значений из массива запрещенных значений |
57 | 57 | * |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | function clean_ids($IDs, $sep = ',', $ignore = []) |
64 | 64 | { |
65 | 65 | $out = []; |
66 | - if (! is_array($IDs)) { |
|
66 | + if (!is_array($IDs)) { |
|
67 | 67 | $IDs = is_scalar($IDs) ? explode($sep, $IDs) : []; |
68 | 68 | } |
69 | 69 | foreach ($IDs as $item) { |
70 | 70 | $item = trim($item); |
71 | - if ((is_scalar($item) && (int)$item >= 0) && (empty($ignore) || ! in_array((int)$item, $ignore, true))) { |
|
72 | - $out[] = (int)$item; |
|
71 | + if ((is_scalar($item) && (int) $item >= 0) && (empty($ignore) || !in_array((int) $item, $ignore, true))) { |
|
72 | + $out[] = (int) $item; |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | $out = array_unique($out); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | -if (! function_exists('is_number')) { |
|
81 | +if (!function_exists('is_number')) { |
|
82 | 82 | /** |
83 | 83 | * Является ли переменная истинным числом |
84 | 84 | * |
@@ -87,6 +87,6 @@ discard block |
||
87 | 87 | */ |
88 | 88 | function is_number($var) |
89 | 89 | { |
90 | - return (is_numeric($var) && ! is_string($var)); |
|
90 | + return (is_numeric($var) && !is_string($var)); |
|
91 | 91 | } |
92 | 92 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! function_exists('get_max_upload_size')) { |
|
2 | +if (!function_exists('get_max_upload_size')) { |
|
3 | 3 | /** |
4 | 4 | * Максимальный размер закачиваемого файла |
5 | 5 | * |
@@ -8,16 +8,16 @@ discard block |
||
8 | 8 | |
9 | 9 | function get_max_upload_size() |
10 | 10 | { |
11 | - $max_upload = (int)(ini_get('upload_max_filesize')); |
|
12 | - $max_post = (int)(ini_get('post_max_size')); |
|
13 | - $memory_limit = (int)(ini_get('memory_limit')); |
|
11 | + $max_upload = (int) (ini_get('upload_max_filesize')); |
|
12 | + $max_post = (int) (ini_get('post_max_size')); |
|
13 | + $memory_limit = (int) (ini_get('memory_limit')); |
|
14 | 14 | $upload_mb = min($max_upload, $max_post, $memory_limit); |
15 | 15 | |
16 | 16 | return $upload_mb; |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | -if (! function_exists('get_extension')) { |
|
20 | +if (!function_exists('get_extension')) { |
|
21 | 21 | /** |
22 | 22 | * Расширение имени файла |
23 | 23 | * |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | -if (! function_exists('dir_list_files')) { |
|
33 | +if (!function_exists('dir_list_files')) { |
|
34 | 34 | /** |
35 | 35 | * Получить список файлов в директории |
36 | 36 | * |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | $dir = opendir($path); |
43 | 43 | $files = []; |
44 | - if (! empty($dir)) { |
|
44 | + if (!empty($dir)) { |
|
45 | 45 | while (false !== ($file = readdir($dir))) { |
46 | 46 | if ($file != '.' && $file != '..') { |
47 | 47 | $files[] = $file; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -if (! function_exists('sanitize_path')) { |
|
57 | +if (!function_exists('sanitize_path')) { |
|
58 | 58 | /** |
59 | 59 | * Удаление из строки символов, определяющих перемещение вверх по дереву каталогов |
60 | 60 | * @see https://github.com/modxcms/revolution/commit/10248d06ebb7c933d33129272623d0a64d528a82#diff-9ec30f895e27297f4307c80efb483bb8 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! function_exists('request_method')) { |
|
2 | +if (!function_exists('request_method')) { |
|
3 | 3 | /** |
4 | 4 | * Тип запроса REQUEST_METHOD в нижнем регистре |
5 | 5 | * |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | } |
12 | 12 | } |
13 | 13 | |
14 | -if (! function_exists('is_post')) { |
|
14 | +if (!function_exists('is_post')) { |
|
15 | 15 | /** |
16 | 16 | * Запрошена ли страница методом POST |
17 | 17 | * |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | -if (! function_exists('is_get')) { |
|
26 | +if (!function_exists('is_get')) { |
|
27 | 27 | /** |
28 | 28 | * Запрошена ли страница методом GET |
29 | 29 | * |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | -if (! function_exists('is_ajax')) { |
|
38 | +if (!function_exists('is_ajax')) { |
|
39 | 39 | /** |
40 | 40 | * Проверяет AJAX запрос или нет |
41 | 41 | * |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | -if (! function_exists('is_cli')) { |
|
50 | +if (!function_exists('is_cli')) { |
|
51 | 51 | /** |
52 | 52 | * Проверяет запущен ли скрипт в CLI режиме |
53 | 53 | * |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | function is_cli() |
57 | 57 | { |
58 | 58 | return defined('STDIN') || |
59 | - (empty($_SERVER['REMOTE_ADDR']) && ! isset($_SERVER['HTTP_USER_AGENT']) && count($_SERVER['argv']) > 0); |
|
59 | + (empty($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['HTTP_USER_AGENT']) && count($_SERVER['argv']) > 0); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -if (! function_exists('is_https')) { |
|
63 | +if (!function_exists('is_https')) { |
|
64 | 64 | /** |
65 | 65 | * Проверка протокола HTTPS |
66 | 66 | * |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | { |
71 | 71 | $type = strtolower(get_key($_SERVER, 'HTTPS', null)); |
72 | 72 | |
73 | - return (! empty($type) && $type !== 'off'); |
|
73 | + return (!empty($type) && $type !== 'off'); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | -if (! function_exists('build_query')) { |
|
77 | +if (!function_exists('build_query')) { |
|
78 | 78 | /** |
79 | 79 | * Создание URL-кодированной строки запроса с пропуском пустых значений |
80 | 80 | * |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! function_exists('hide_errors')) { |
|
2 | +if (!function_exists('hide_errors')) { |
|
3 | 3 | /** |
4 | 4 | * Не отображать и не логировать ошибки скриптов |
5 | 5 | * |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | } |
13 | 13 | } |
14 | 14 | |
15 | -if (! function_exists('show_errors')) { |
|
15 | +if (!function_exists('show_errors')) { |
|
16 | 16 | /** |
17 | 17 | * Показать все ошибки скриптов |
18 | 18 | * |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
28 | -if (! function_exists('dd')) { |
|
28 | +if (!function_exists('dd')) { |
|
29 | 29 | /** |
30 | 30 | * Удалить буфер вывода, сделать дамп параметров функции и прервать выполнение скрипта |
31 | 31 | * |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | function dd() |
36 | 36 | { |
37 | 37 | ob_clean(); |
38 | - array_map(function ($x) { |
|
38 | + array_map(function($x) { |
|
39 | 39 | var_dump($x); |
40 | 40 | }, func_get_args()); |
41 | 41 | die; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | -if (! function_exists('array_code')) { |
|
45 | +if (!function_exists('array_code')) { |
|
46 | 46 | /** |
47 | 47 | * Печать массива в том виде, в котором его понимает php |
48 | 48 | * |
@@ -63,8 +63,7 @@ discard block |
||
63 | 63 | $vals = []; |
64 | 64 | foreach ($arr as $key => $val) { |
65 | 65 | $vals[] = is_array($val) ? |
66 | - "'" . $key . "'=>" . array_code($val, $level + 1) : |
|
67 | - "'" . $key . "'=>'" . $val . "'"; |
|
66 | + "'" . $key . "'=>" . array_code($val, $level + 1) : "'" . $key . "'=>'" . $val . "'"; |
|
68 | 67 | } |
69 | 68 | $php = "array(\r" . $tabs . implode(",\r" . $tabs, $vals) . "\r" . $breaks . ")"; |
70 | 69 | } |
@@ -73,7 +72,7 @@ discard block |
||
73 | 72 | } |
74 | 73 | } |
75 | 74 | |
76 | -if (! function_exists('show_var')) { |
|
75 | +if (!function_exists('show_var')) { |
|
77 | 76 | /** |
78 | 77 | * Показать содержимое переменной |
79 | 78 | * @param mixed $html |
@@ -84,7 +83,7 @@ discard block |
||
84 | 83 | return html_wrap('pre', e(print_r($html, 1))); |
85 | 84 | } |
86 | 85 | } |
87 | -if (! function_exists('point_info')) { |
|
86 | +if (!function_exists('point_info')) { |
|
88 | 87 | /** |
89 | 88 | * Информация о ресурсах потребляемых на каком-то участке кода |
90 | 89 | * @param string $key Имя метки |
@@ -96,7 +95,7 @@ discard block |
||
96 | 95 | static $marks = []; |
97 | 96 | $out = []; |
98 | 97 | |
99 | - if (is_scalar($key) && ! empty($key)) { |
|
98 | + if (is_scalar($key) && !empty($key)) { |
|
100 | 99 | if ($store) { |
101 | 100 | $marks[$key] = [ |
102 | 101 | 'time' => microtime(true), |
@@ -124,7 +123,7 @@ discard block |
||
124 | 123 | } |
125 | 124 | } |
126 | 125 | |
127 | -if (! function_exists('call_private_method')) { |
|
126 | +if (!function_exists('call_private_method')) { |
|
128 | 127 | /** |
129 | 128 | * Возможность вызвать любой метод (даже приватный) |
130 | 129 | * call_private_method($myObject, 'myMethod', array('myValue1', 'myValue2')); |
@@ -146,7 +145,7 @@ discard block |
||
146 | 145 | } |
147 | 146 | } |
148 | 147 | |
149 | -if (! function_exists('format_exception')) { |
|
148 | +if (!function_exists('format_exception')) { |
|
150 | 149 | /** |
151 | 150 | * Форматировавние исключений для логирования или удобоваримого отображения |
152 | 151 | * |
@@ -163,13 +162,13 @@ discard block |
||
163 | 162 | $msg = get_class($exception); |
164 | 163 | |
165 | 164 | $code = $exception->getCode(); |
166 | - if (! empty($code)) { |
|
165 | + if (!empty($code)) { |
|
167 | 166 | $msg .= ':' . $exception->getCode(); |
168 | 167 | } |
169 | 168 | $msg .= PHP_EOL; |
170 | 169 | |
171 | 170 | $tmp = $exception->getMessage(); |
172 | - if (! empty($tmp)) { |
|
171 | + if (!empty($tmp)) { |
|
173 | 172 | $msg .= $exception->getMessage(); |
174 | 173 | $msg .= PHP_EOL; |
175 | 174 | } |