Passed
Pull Request — lib (#368)
by Alexey
01:58
created
Michelf/MarkdownExtra.php 1 patch
Braces   +42 added lines, -36 removed lines patch added patch discarded remove patch
@@ -170,8 +170,9 @@  discard block
 block discarded – undo
170 170
 		$this->footnotes_assembled = null;
171 171
 
172 172
 		foreach ($this->predef_abbr as $abbr_word => $abbr_desc) {
173
-			if ($this->abbr_word_re)
174
-				$this->abbr_word_re .= '|';
173
+			if ($this->abbr_word_re) {
174
+							$this->abbr_word_re .= '|';
175
+			}
175 176
 			$this->abbr_word_re .= preg_quote($abbr_word);
176 177
 			$this->abbr_desciptions[$abbr_word] = trim($abbr_desc);
177 178
 		}
@@ -188,8 +189,9 @@  discard block
 block discarded – undo
188 189
 		$this->abbr_desciptions = array();
189 190
 		$this->abbr_word_re = '';
190 191
 
191
-		if ( ! $this->omit_footnotes )
192
-			$this->footnotes_assembled = null;
192
+		if ( ! $this->omit_footnotes ) {
193
+					$this->footnotes_assembled = null;
194
+		}
193 195
 
194 196
 		parent::teardown();
195 197
 	}
@@ -239,7 +241,9 @@  discard block
 block discarded – undo
239 241
 			if ($element[0] === '.') {
240 242
 				$classes[] = substr($element, 1);
241 243
 			} else if ($element[0] === '#') {
242
-				if ($id === false) $id = substr($element, 1);
244
+				if ($id === false) {
245
+					$id = substr($element, 1);
246
+				}
243 247
 			} else if (strpos($element, '=') > 0) {
244 248
 				$parts = explode('=', $element, 2);
245 249
 				$attributes[] = $parts[0] . '="' . $parts[1] . '"';
@@ -409,7 +413,9 @@  discard block
 block discarded – undo
409 413
 										$enclosing_tag_re = '', $span = false)
410 414
 	{
411 415
 
412
-		if ($text === '') return array('', '');
416
+		if ($text === '') {
417
+			return array('', '');
418
+		}
413 419
 
414 420
 		// Regex to check for the presense of newlines around a block tag.
415 421
 		$newline_before_re = '/(?:^\n?|\n\n)*$/';
@@ -520,8 +526,7 @@  discard block
 block discarded – undo
520 526
 					// End marker found: pass text unchanged until marker.
521 527
 					$parsed .= $tag . $matches[0];
522 528
 					$text = substr($text, strlen($matches[0]));
523
-				}
524
-				else {
529
+				} else {
525 530
 					// No end marker: just skip it.
526 531
 					$parsed .= $tag;
527 532
 				}
@@ -543,8 +548,7 @@  discard block
 block discarded – undo
543 548
 					// End marker found: pass text unchanged until marker.
544 549
 					$parsed .= $tag . $matches[0];
545 550
 					$text = substr($text, strlen($matches[0]));
546
-				}
547
-				else {
551
+				} else {
548 552
 					// Unmatched marker: just skip it.
549 553
 					$parsed .= $tag;
550 554
 				}
@@ -597,8 +601,7 @@  discard block
 block discarded – undo
597 601
 				}
598 602
 
599 603
 				$parsed .= $tag;
600
-			}
601
-			else {
604
+			} else {
602 605
 				$parsed .= $tag;
603 606
 			}
604 607
 			// @phpstan-ignore-next-line
@@ -622,7 +625,9 @@  discard block
 block discarded – undo
622 625
 	 * @return array
623 626
 	 */
624 627
 	protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
625
-		if ($text === '') return array('', '');
628
+		if ($text === '') {
629
+			return array('', '');
630
+		}
626 631
 
627 632
 		// Regex to match `markdown` attribute inside of a tag.
628 633
 		$markdown_attr_re = '
@@ -672,8 +677,9 @@  discard block
 block discarded – undo
672 677
 
673 678
 		// Get the name of the starting tag.
674 679
 		// (This pattern makes $base_tag_name_re safe without quoting.)
675
-		if (preg_match('/^<([\w:$]*)\b/', $text, $matches))
676
-			$base_tag_name_re = $matches[1];
680
+		if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) {
681
+					$base_tag_name_re = $matches[1];
682
+		}
677 683
 
678 684
 		// Loop through every tag until we find the corresponding closing tag.
679 685
 		do {
@@ -702,8 +708,7 @@  discard block
 block discarded – undo
702 708
 			{
703 709
 				// Just add the tag to the block as if it was text.
704 710
 				$block_text .= $tag;
705
-			}
706
-			else {
711
+			} else {
707 712
 				// Increase/decrease nested tag count. Only do so if
708 713
 				// the tag's name match base tag's.
709 714
 				if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) {
@@ -764,8 +769,9 @@  discard block
 block discarded – undo
764 769
 
765 770
 					// Start over with a new block.
766 771
 					$block_text = "";
772
+				} else {
773
+					$block_text .= $tag;
767 774
 				}
768
-				else $block_text .= $tag;
769 775
 			}
770 776
 
771 777
 		} while ($depth > 0);
@@ -886,14 +892,14 @@  discard block
 block discarded – undo
886 892
 				$title = $this->encodeAttribute($title);
887 893
 				$result .=  " title=\"$title\"";
888 894
 			}
889
-			if (isset($this->ref_attr[$link_id]))
890
-				$result .= $this->ref_attr[$link_id];
895
+			if (isset($this->ref_attr[$link_id])) {
896
+							$result .= $this->ref_attr[$link_id];
897
+			}
891 898
 
892 899
 			$link_text = $this->runSpanGamut($link_text);
893 900
 			$result .= ">$link_text</a>";
894 901
 			$result = $this->hashPart($result);
895
-		}
896
-		else {
902
+		} else {
897 903
 			$result = $whole_match;
898 904
 		}
899 905
 		return $result;
@@ -914,8 +920,9 @@  discard block
 block discarded – undo
914 920
 		// if the URL was of the form <s p a c e s> it got caught by the HTML
915 921
 		// tag parser and hashed. Need to reverse the process before using the URL.
916 922
 		$unhashed = $this->unhash($url);
917
-		if ($unhashed !== $url)
918
-			$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
923
+		if ($unhashed !== $url) {
924
+					$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
925
+		}
919 926
 
920 927
 		$url = $this->encodeURLAttribute($url);
921 928
 
@@ -1015,8 +1022,7 @@  discard block
 block discarded – undo
1015 1022
 			}
1016 1023
 			$result .= $this->empty_element_suffix;
1017 1024
 			$result = $this->hashPart($result);
1018
-		}
1019
-		else {
1025
+		} else {
1020 1026
 			// If there's no such link ID, leave intact:
1021 1027
 			$result = $whole_match;
1022 1028
 		}
@@ -1233,14 +1239,15 @@  discard block
 block discarded – undo
1233 1239
 		// Reading alignement from header underline.
1234 1240
 		$separators	= preg_split('/ *[|] */', $underline);
1235 1241
 		foreach ($separators as $n => $s) {
1236
-			if (preg_match('/^ *-+: *$/', $s))
1237
-				$attr[$n] = $this->_doTable_makeAlignAttr('right');
1238
-			else if (preg_match('/^ *:-+: *$/', $s))
1239
-				$attr[$n] = $this->_doTable_makeAlignAttr('center');
1240
-			else if (preg_match('/^ *:-+ *$/', $s))
1241
-				$attr[$n] = $this->_doTable_makeAlignAttr('left');
1242
-			else
1243
-				$attr[$n] = '';
1242
+			if (preg_match('/^ *-+: *$/', $s)) {
1243
+							$attr[$n] = $this->_doTable_makeAlignAttr('right');
1244
+			} else if (preg_match('/^ *:-+: *$/', $s)) {
1245
+							$attr[$n] = $this->_doTable_makeAlignAttr('center');
1246
+			} else if (preg_match('/^ *:-+ *$/', $s)) {
1247
+							$attr[$n] = $this->_doTable_makeAlignAttr('left');
1248
+			} else {
1249
+							$attr[$n] = '';
1250
+			}
1244 1251
 		}
1245 1252
 
1246 1253
 		// Parsing span elements, including code spans, character escapes,
@@ -1423,8 +1430,7 @@  discard block
 block discarded – undo
1423 1430
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1424 1431
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1425 1432
 			$def = "\n". $def ."\n";
1426
-		}
1427
-		else {
1433
+		} else {
1428 1434
 			$def = rtrim($def);
1429 1435
 			$def = $this->runSpanGamut($this->outdent($def));
1430 1436
 		}
Please login to merge, or discard this patch.