Completed
Push — master ( 7b69e0...e6649e )
by Agel_Nash
02:21
created
src/string.functions.php 1 patch
Braces   +35 added lines, -12 removed lines patch added patch discarded remove patch
@@ -299,26 +299,38 @@  discard block
 block discarded – undo
299 299
 				$tag = strtolower($s[1]);
300 300
 				if (!empty($_allowable_tags)) {
301 301
 					#tag with attributes
302
-					if (array_key_exists($tag, $_allowable_tags)) return $s[0];
302
+					if (array_key_exists($tag, $_allowable_tags)) {
303
+						return $s[0];
304
+					}
303 305
 
304 306
 					#tag without attributes
305 307
 					if (array_key_exists('<' . $tag . '>', $_allowable_tags)) {
306
-						if (substr($s[0], 0, 2) === '</') return '</' . $tag . '>';
307
-						if (substr($s[0], -2) === '/>') return '<' . $tag . ' />';
308
+						if (substr($s[0], 0, 2) === '</') {
309
+							return '</' . $tag . '>';
310
+						}
311
+						if (substr($s[0], -2) === '/>') {
312
+							return '<' . $tag . ' />';
313
+						}
308 314
 						return '<' . $tag . '>';
309 315
 					}
310 316
 				}
311
-				if ($tag === 'br') return "\r\n";
312
-				if (!empty($_para_tags) && array_key_exists($tag, $_para_tags)) return "\r\n\r\n";
317
+				if ($tag === 'br') {
318
+					return "\r\n";
319
+				}
320
+				if (!empty($_para_tags) && array_key_exists($tag, $_para_tags)) {
321
+					return "\r\n\r\n";
322
+				}
313 323
 				return '';
314 324
 			}
315 325
 			trigger_error('Unknown callback type "' . $_callback_type . '"!', E_USER_ERROR);
316 326
 		}
317 327
 
318
-		if (($pos = strpos($s, '<')) === false || strpos($s, '>', $pos) === false)  #speed improve
328
+		if (($pos = strpos($s, '<')) === false || strpos($s, '>', $pos) === false) {
329
+			#speed improve
319 330
 		{
320 331
 			#tags are not found
321
-			return $s;
332
+			return $s;
333
+		}
322 334
 		}
323 335
 
324 336
 		$length = strlen($s);
@@ -354,7 +366,9 @@  discard block
 block discarded – undo
354 366
 		);
355 367
 		if (!empty($pair_tags)) {
356 368
 			#парные таги вместе с содержимым:
357
-			foreach ($pair_tags as $k => $v) $pair_tags[$k] = preg_quote($v, '/');
369
+			foreach ($pair_tags as $k => $v) {
370
+				$pair_tags[$k] = preg_quote($v, '/');
371
+			}
358 372
 			$patterns[] = '/ <((?i:' . implode('|', $pair_tags) . '))' . $re_attrs_fast_safe . '(?<!\/)>
359 373
                          .*?
360 374
                          <\/(?i:\\1)' . $re_attrs_fast_safe . '>
@@ -400,10 +414,14 @@  discard block
 block discarded – undo
400 414
 					}
401 415
 
402 416
 					#массив тагов, которые не будут вырезаны
403
-					if (!empty($allowable_tags)) $_allowable_tags = array_flip($allowable_tags);
417
+					if (!empty($allowable_tags)) {
418
+						$_allowable_tags = array_flip($allowable_tags);
419
+					}
404 420
 
405 421
 					#парные таги, которые будут восприниматься как параграфы
406
-					if (!empty($para_tags)) $_para_tags = array_flip($para_tags);
422
+					if (!empty($para_tags)) {
423
+						$_para_tags = array_flip($para_tags);
424
+					}
407 425
 				}
408 426
 			}#if
409 427
 
@@ -418,11 +436,16 @@  discard block
 block discarded – undo
418 436
 				}
419 437
 			}
420 438
 
421
-			if ($s === $s2) break;
439
+			if ($s === $s2) {
440
+				break;
441
+			}
422 442
 			$s = $s2;
423 443
 			$i++;
424 444
 		}#while
425
-		if ($i >= $max) $s = strip_tags($s); #too many cycles for replace...
445
+		if ($i >= $max) {
446
+			$s = strip_tags($s);
447
+		}
448
+		#too many cycles for replace...
426 449
 
427 450
 		if ($is_format_spaces && strlen($s) !== $length) {
428 451
 			#remove a duplicate spaces
Please login to merge, or discard this patch.