Completed
Push — master ( c74a72...239795 )
by Olivier
04:51
created
lib/Hooks.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,6 @@
 block discarded – undo
12 12
 namespace Patron;
13 13
 
14 14
 use Brickrouge\Pager;
15
-
16 15
 use ICanBoogie\Core;
17 16
 use ICanBoogie\Render\TemplateName;
18 17
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	{
44 44
 		$count = null;
45 45
 		$limit = null;
46
-		$page =  null;
46
+		$page = null;
47 47
 		$range = null;
48 48
 		$noarrows = null;
49 49
 		$with = null;
@@ -166,10 +166,8 @@  discard block
 block discarded – undo
166 166
 
167 167
 		if (!is_array($entries) && !is_object($entries))
168 168
 		{
169
-			$patron->error
170
-			(
171
-				'Invalid source for %param. Source must either be an array or a traversable object. Given: !entries', array
172
-				(
169
+			$patron->error(
170
+				'Invalid source for %param. Source must either be an array or a traversable object. Given: !entries', array(
173 171
 					'%param' => 'in', '!entries' => $entries
174 172
 				)
175 173
 			);
@@ -330,7 +328,7 @@  discard block
 block discarded – undo
330 328
 
331 329
 			if ($name != 'when')
332 330
 			{
333
-				$patron->error('Unexpected child: :node', [ ':node' => $node ]);
331
+				$patron->error('Unexpected child: :node', [':node' => $node]);
334 332
 
335 333
 				return null;
336 334
 			}
@@ -716,16 +714,16 @@  discard block
 block discarded – undo
716 714
 	{
717 715
 		$app->events->attach(function(MarkupCollection\AlterEvent $event, MarkupCollection $markups) use ($app) {
718 716
 
719
-			foreach((array) $app->configs['patron.markups'] as $name => $definition)
717
+			foreach ((array) $app->configs['patron.markups'] as $name => $definition)
720 718
 			{
721
-				$markups[$name] = $definition + [ 1 => [ ] ];
719
+				$markups[$name] = $definition + [1 => []];
722 720
 			}
723 721
 
724 722
 		});
725 723
 
726 724
 		$app->events->attach(function(FunctionCollection\AlterEvent $event, FunctionCollection $markups) use ($app) {
727 725
 
728
-			foreach((array) $app->configs['patron.functions'] as $name => $definition)
726
+			foreach ((array) $app->configs['patron.functions'] as $name => $definition)
729 727
 			{
730 728
 				$markups[$name] = $definition;
731 729
 			}
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -260,8 +260,7 @@  discard block
 block discarded – undo
260 260
 		if ($args['equals'] !== null)
261 261
 		{
262 262
 			$true = $args['select'] == $args['equals'];
263
-		}
264
-		else
263
+		} else
265 264
 		{
266 265
 			$true = !empty($args['test']);
267 266
 		}
@@ -407,12 +406,10 @@  discard block
 block discarded – undo
407 406
 			$patron->error('Ambiguous selection');
408 407
 
409 408
 			return null;
410
-		}
411
-		else if ($select)
409
+		} else if ($select)
412 410
 		{
413 411
 			$value = $select;
414
-		}
415
-		else
412
+		} else
416 413
 		{
417 414
 			$value = $patron($template);
418 415
 		}
Please login to merge, or discard this patch.
lib/markdown/markdown.php 4 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -1044,6 +1044,10 @@  discard block
 block discarded – undo
1044 1044
 
1045 1045
 	var $list_level = 0;
1046 1046
 
1047
+	/**
1048
+	 * @param string $list_str
1049
+	 * @param string $marker_any_re
1050
+	 */
1047 1051
 	function processListItems($list_str, $marker_any_re) {
1048 1052
 	#
1049 1053
 	#	Process the contents of a single ordered or unordered list, splitting it
@@ -1644,6 +1648,9 @@  discard block
 block discarded – undo
1644 1648
 	# hanlde UTF-8 if the default function does not exist.
1645 1649
 	var $utf8_strlen = 'mb_strlen';
1646 1650
 
1651
+	/**
1652
+	 * @param string $text
1653
+	 */
1647 1654
 	function detab($text) {
1648 1655
 	#
1649 1656
 	# Replace tabs with the appropriate amount of space.
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,10 +87,10 @@
 block discarded – undo
87 87
 	# - Add paragraph tag around the excerpt, but remove it for the excerpt rss.
88 88
 	if (MARKDOWN_WP_POSTS) {
89 89
 		remove_filter('the_content',     'wpautop');
90
-        remove_filter('the_content_rss', 'wpautop');
90
+		remove_filter('the_content_rss', 'wpautop');
91 91
 		remove_filter('the_excerpt',     'wpautop');
92 92
 		add_filter('the_content',     'mdwp_MarkdownPost', 6);
93
-        add_filter('the_content_rss', 'mdwp_MarkdownPost', 6);
93
+		add_filter('the_content_rss', 'mdwp_MarkdownPost', 6);
94 94
 		add_filter('get_the_excerpt', 'mdwp_MarkdownPost', 6);
95 95
 		add_filter('get_the_excerpt', 'trim', 7);
96 96
 		add_filter('the_excerpt',     'mdwp_add_p');
Please login to merge, or discard this patch.
Braces   +30 added lines, -23 removed lines patch added patch discarded remove patch
@@ -194,8 +194,12 @@  discard block
 block discarded – undo
194 194
 	# Fake Textile class. It calls Markdown instead.
195 195
 	class Textile {
196 196
 		function TextileThis($text, $lite='', $encode='') {
197
-			if ($lite == '' && $encode == '')    $text = Markdown($text);
198
-			if (function_exists('SmartyPants'))  $text = SmartyPants($text);
197
+			if ($lite == '' && $encode == '') {
198
+				$text = Markdown($text);
199
+			}
200
+			if (function_exists('SmartyPants')) {
201
+				$text = SmartyPants($text);
202
+			}
199 203
 			return $text;
200 204
 		}
201 205
 		# Fake restricted version: restrictions are not supported for now.
@@ -413,7 +417,9 @@  discard block
 block discarded – undo
413 417
 
414 418
 
415 419
 	function hashHTMLBlocks($text) {
416
-		if ($this->no_markup)  return $text;
420
+		if ($this->no_markup) {
421
+			return $text;
422
+		}
417 423
 
418 424
 		$less_than_tab = $this->tab_width - 1;
419 425
 
@@ -689,7 +695,9 @@  discard block
 block discarded – undo
689 695
 	#
690 696
 	# Turn Markdown link shortcuts into XHTML <a> tags.
691 697
 	#
692
-		if ($this->in_anchor) return $text;
698
+		if ($this->in_anchor) {
699
+			return $text;
700
+		}
693 701
 		$this->in_anchor = true;
694 702
 
695 703
 		#
@@ -783,8 +791,7 @@  discard block
 block discarded – undo
783 791
 			$link_text = $this->runSpanGamut($link_text);
784 792
 			$result .= ">$link_text</a>";
785 793
 			$result = $this->hashPart($result);
786
-		}
787
-		else {
794
+		} else {
788 795
 			$result = $whole_match;
789 796
 		}
790 797
 		return $result;
@@ -885,8 +892,7 @@  discard block
 block discarded – undo
885 892
 			}
886 893
 			$result .= $this->empty_element_suffix;
887 894
 			$result = $this->hashPart($result);
888
-		}
889
-		else {
895
+		} else {
890 896
 			# If there's no such link ID, leave intact:
891 897
 			$result = $whole_match;
892 898
 		}
@@ -944,8 +950,9 @@  discard block
 block discarded – undo
944 950
 	}
945 951
 	function _doHeaders_callback_setext($matches) {
946 952
 		# Terrible hack to check we haven't found an empty list item.
947
-		if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1]))
948
-			return $matches[0];
953
+		if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1])) {
954
+					return $matches[0];
955
+		}
949 956
 
950 957
 		$level = $matches[2]{0} == '=' ? 1 : 2;
951 958
 		$block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>";
@@ -1012,8 +1019,7 @@  discard block
 block discarded – undo
1012 1019
 						'.$whole_list_re.'
1013 1020
 					}mx',
1014 1021
 					array(&$this, '_doLists_callback'), $text);
1015
-			}
1016
-			else {
1022
+			} else {
1017 1023
 				$text = preg_replace_callback('{
1018 1024
 						(?:(?<=\n)\n|\A\n?) # Must eat the newline
1019 1025
 						'.$whole_list_re.'
@@ -1103,8 +1109,7 @@  discard block
 block discarded – undo
1103 1109
 			# Replace marker with the appropriate whitespace indentation
1104 1110
 			$item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item;
1105 1111
 			$item = $this->runBlockGamut($this->outdent($item)."\n");
1106
-		}
1107
-		else {
1112
+		} else {
1108 1113
 			# Recursion for sub-lists:
1109 1114
 			$item = $this->doLists($this->outdent($item));
1110 1115
 			$item = preg_replace('/\n+$/', '', $item);
@@ -1149,8 +1154,7 @@  discard block
 block discarded – undo
1149 1154
 			$class = $format_match[1];
1150 1155
 			$codeblock = substr($codeblock, strlen($format_match[0]));
1151 1156
 			$codeblock = $this->format_codeblock($codeblock, $class);
1152
-		}
1153
-		else
1157
+		} else
1154 1158
 		{
1155 1159
 			$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
1156 1160
 		}
@@ -1389,8 +1393,7 @@  discard block
 block discarded – undo
1389 1393
 				$value = preg_replace('/^([ ]*)/', "<p>", $value);
1390 1394
 				$value .= "</p>";
1391 1395
 				$grafs[$key] = $this->unhash($value);
1392
-			}
1393
-			else {
1396
+			} else {
1394 1397
 				# Is a block.
1395 1398
 				# Modify elements of @grafs in-place...
1396 1399
 				$graf = $value;
@@ -1538,8 +1541,11 @@  discard block
 block discarded – undo
1538 1541
 				# roughly 10% raw, 45% hex, 45% dec
1539 1542
 				# '@' *must* be encoded. I insist.
1540 1543
 				if ($r > 90 && $char != '@') /* do nothing */;
1541
-				else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';';
1542
-				else              $chars[$key] = '&#'.$ord.';';
1544
+				else if ($r < 45) {
1545
+					$chars[$key] = '&#x'.dechex($ord).';';
1546
+				} else {
1547
+					$chars[$key] = '&#'.$ord.';';
1548
+				}
1543 1549
 			}
1544 1550
 		}
1545 1551
 
@@ -1597,8 +1603,7 @@  discard block
 block discarded – undo
1597 1603
 			if (isset($parts[1])) {
1598 1604
 				$output .= $this->handleSpanToken($parts[1], $parts[2]);
1599 1605
 				$str = $parts[2];
1600
-			}
1601
-			else {
1606
+			} else {
1602 1607
 				break;
1603 1608
 			}
1604 1609
 		}
@@ -1681,7 +1686,9 @@  discard block
 block discarded – undo
1681 1686
 	# function that will loosely count the number of UTF-8 characters with a
1682 1687
 	# regular expression.
1683 1688
 	#
1684
-		if (function_exists($this->utf8_strlen)) return;
1689
+		if (function_exists($this->utf8_strlen)) {
1690
+			return;
1691
+		}
1685 1692
 		$this->utf8_strlen = create_function('$text', 'return preg_match_all(
1686 1693
 			"/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/",
1687 1694
 			$text, $m);');
Please login to merge, or discard this patch.
Spacing   +67 added lines, -70 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 # <http://daringfireball.net/projects/markdown/>
12 12
 #
13 13
 
14
-define( 'MARKDOWN_VERSION',  "1.0.1o" ); # Sun 8 Jan 2012
14
+define('MARKDOWN_VERSION', "1.0.1o"); # Sun 8 Jan 2012
15 15
 
16 16
 
17 17
 #
@@ -19,18 +19,18 @@  discard block
 block discarded – undo
19 19
 #
20 20
 
21 21
 # Change to ">" for HTML output
22
-@define( 'MARKDOWN_EMPTY_ELEMENT_SUFFIX',  " />");
22
+@define('MARKDOWN_EMPTY_ELEMENT_SUFFIX', " />");
23 23
 
24 24
 # Define the width of a tab for code blocks.
25
-@define( 'MARKDOWN_TAB_WIDTH',     4 );
25
+@define('MARKDOWN_TAB_WIDTH', 4);
26 26
 
27 27
 # Optional title attribute for footnote links and backlinks.
28
-@define( 'MARKDOWN_FN_LINK_TITLE',         "" );
29
-@define( 'MARKDOWN_FN_BACKLINK_TITLE',     "" );
28
+@define('MARKDOWN_FN_LINK_TITLE', "");
29
+@define('MARKDOWN_FN_BACKLINK_TITLE', "");
30 30
 
31 31
 # Optional class attribute for footnote links and backlinks.
32
-@define( 'MARKDOWN_FN_LINK_CLASS',         "" );
33
-@define( 'MARKDOWN_FN_BACKLINK_CLASS',     "" );
32
+@define('MARKDOWN_FN_LINK_CLASS', "");
33
+@define('MARKDOWN_FN_BACKLINK_CLASS', "");
34 34
 
35 35
 
36 36
 #
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 #
39 39
 
40 40
 # Change to false to remove Markdown from posts and/or comments.
41
-@define( 'MARKDOWN_WP_POSTS',      true );
42
-@define( 'MARKDOWN_WP_COMMENTS',   true );
41
+@define('MARKDOWN_WP_POSTS', true);
42
+@define('MARKDOWN_WP_COMMENTS', true);
43 43
 
44 44
 
45 45
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 if (!defined('MARKDOWN_PARSER_CLASS'))
49 49
 {
50
-	define( 'MARKDOWN_PARSER_CLASS',  'MarkdownExtra_Parser' );
50
+	define('MARKDOWN_PARSER_CLASS', 'MarkdownExtra_Parser');
51 51
 }
52 52
 
53 53
 function Markdown($text) {
@@ -86,19 +86,19 @@  discard block
 block discarded – undo
86 86
 	# - Run Markdown on excerpt, then remove all tags.
87 87
 	# - Add paragraph tag around the excerpt, but remove it for the excerpt rss.
88 88
 	if (MARKDOWN_WP_POSTS) {
89
-		remove_filter('the_content',     'wpautop');
89
+		remove_filter('the_content', 'wpautop');
90 90
         remove_filter('the_content_rss', 'wpautop');
91
-		remove_filter('the_excerpt',     'wpautop');
92
-		add_filter('the_content',     'mdwp_MarkdownPost', 6);
91
+		remove_filter('the_excerpt', 'wpautop');
92
+		add_filter('the_content', 'mdwp_MarkdownPost', 6);
93 93
         add_filter('the_content_rss', 'mdwp_MarkdownPost', 6);
94 94
 		add_filter('get_the_excerpt', 'mdwp_MarkdownPost', 6);
95 95
 		add_filter('get_the_excerpt', 'trim', 7);
96
-		add_filter('the_excerpt',     'mdwp_add_p');
96
+		add_filter('the_excerpt', 'mdwp_add_p');
97 97
 		add_filter('the_excerpt_rss', 'mdwp_strip_p');
98 98
 
99
-		remove_filter('content_save_pre',  'balanceTags', 50);
100
-		remove_filter('excerpt_save_pre',  'balanceTags', 50);
101
-		add_filter('the_content',  	  'balanceTags', 50);
99
+		remove_filter('content_save_pre', 'balanceTags', 50);
100
+		remove_filter('excerpt_save_pre', 'balanceTags', 50);
101
+		add_filter('the_content', 'balanceTags', 50);
102 102
 		add_filter('get_the_excerpt', 'balanceTags', 9);
103 103
 	}
104 104
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		if (is_single() || is_page() || is_feed()) {
113 113
 			$parser->fn_id_prefix = "";
114 114
 		} else {
115
-			$parser->fn_id_prefix = get_the_ID() . ".";
115
+			$parser->fn_id_prefix = get_the_ID().".";
116 116
 		}
117 117
 		return $parser->transform($text);
118 118
 	}
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		add_filter('pre_comment_content', 'Markdown', 6);
129 129
 		add_filter('pre_comment_content', 'mdwp_hide_tags', 8);
130 130
 		add_filter('pre_comment_content', 'mdwp_show_tags', 12);
131
-		add_filter('get_comment_text',    'Markdown', 6);
131
+		add_filter('get_comment_text', 'Markdown', 6);
132 132
 		add_filter('get_comment_excerpt', 'Markdown', 6);
133 133
 		add_filter('get_comment_excerpt', 'mdwp_strip_p', 7);
134 134
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 	@include_once 'smartypants.php';
194 194
 	# Fake Textile class. It calls Markdown instead.
195 195
 	class Textile {
196
-		function TextileThis($text, $lite='', $encode='') {
196
+		function TextileThis($text, $lite = '', $encode = '') {
197 197
 			if ($lite == '' && $encode == '')    $text = Markdown($text);
198 198
 			if (function_exists('SmartyPants'))  $text = SmartyPants($text);
199 199
 			return $text;
200 200
 		}
201 201
 		# Fake restricted version: restrictions are not supported for now.
202
-		function TextileRestricted($text, $lite='', $noimage='') {
202
+		function TextileRestricted($text, $lite = '', $noimage = '') {
203 203
 			return $this->TextileThis($text, $lite);
204 204
 		}
205 205
 		# Workaround to ensure compatibility with TextPattern 4.0.3.
@@ -339,16 +339,14 @@  discard block
 block discarded – undo
339 339
 
340 340
 		$this->teardown();
341 341
 
342
-		return $text . "\n";
342
+		return $text."\n";
343 343
 	}
344 344
 
345
-	public $early_gamut = array
346
-	(
345
+	public $early_gamut = array(
347 346
 		'doFencedCodeBlocks' => 5
348 347
 	);
349 348
 
350
-	var $document_gamut = array
351
-	(
349
+	var $document_gamut = array(
352 350
 		# Strip link definitions, store in hashes.
353 351
 		"stripLinkDefinitions" => 20,
354 352
 
@@ -359,8 +357,7 @@  discard block
 block discarded – undo
359 357
 	 * @var array These are all the transformations that form block-level tags like paragraphs, headers, and
360 358
 	 * list items.
361 359
 	 */
362
-	public $block_gamut = array
363
-	(
360
+	public $block_gamut = array(
364 361
 		"doHeaders"         => 10,
365 362
 		"doHorizontalRules" => 20,
366 363
 
@@ -407,7 +404,7 @@  discard block
 block discarded – undo
407 404
 		$link_id = strtolower($matches[1]);
408 405
 		$url = $matches[2] == '' ? $matches[3] : $matches[2];
409 406
 		$this->urls[$link_id] = $url;
410
-		$this->titles[$link_id] =& $matches[4];
407
+		$this->titles[$link_id] = & $matches[4];
411 408
 		return ''; # String that will replace the block
412 409
 	}
413 410
 
@@ -460,8 +457,8 @@  discard block
 block discarded – undo
460 457
 					(?>
461 458
 					  />
462 459
 					|
463
-					  >', $nested_tags_level).	# end of opening tag
464
-					  '.*?'.					# last level nested tag content
460
+					  >', $nested_tags_level).# end of opening tag
461
+					  '.*?'.# last level nested tag content
465 462
 			str_repeat('
466 463
 					  </\2\s*>	# closing nested tag
467 464
 					)
@@ -573,7 +570,7 @@  discard block
 block discarded – undo
573 570
 
574 571
 		# Then hash the block.
575 572
 		static $i = 0;
576
-		$key = "$boundary\x1A" . ++$i . $boundary;
573
+		$key = "$boundary\x1A".++$i.$boundary;
577 574
 		$this->html_hashes[$key] = $text;
578 575
 		return $key; # String that will replace the tag.
579 576
 	}
@@ -756,9 +753,9 @@  discard block
 block discarded – undo
756 753
 		return $text;
757 754
 	}
758 755
 	function _doAnchors_reference_callback($matches) {
759
-		$whole_match =  $matches[1];
760
-		$link_text   =  $matches[2];
761
-		$link_id     =& $matches[3];
756
+		$whole_match = $matches[1];
757
+		$link_text   = $matches[2];
758
+		$link_id     = & $matches[3];
762 759
 
763 760
 		if ($link_id == "") {
764 761
 			# for shortcut links like [this][] or [this].
@@ -774,10 +771,10 @@  discard block
 block discarded – undo
774 771
 			$url = $this->encodeAttribute($url);
775 772
 
776 773
 			$result = "<a href=\"$url\"";
777
-			if ( isset( $this->titles[$link_id] ) ) {
774
+			if (isset($this->titles[$link_id])) {
778 775
 				$title = $this->titles[$link_id];
779 776
 				$title = $this->encodeAttribute($title);
780
-				$result .=  " title=\"$title\"";
777
+				$result .= " title=\"$title\"";
781 778
 			}
782 779
 
783 780
 			$link_text = $this->runSpanGamut($link_text);
@@ -790,17 +787,17 @@  discard block
 block discarded – undo
790 787
 		return $result;
791 788
 	}
792 789
 	function _doAnchors_inline_callback($matches) {
793
-		$whole_match	=  $matches[1];
794
-		$link_text		=  $this->runSpanGamut($matches[2]);
795
-		$url			=  $matches[3] == '' ? $matches[4] : $matches[3];
796
-		$title			=& $matches[7];
790
+		$whole_match = $matches[1];
791
+		$link_text = $this->runSpanGamut($matches[2]);
792
+		$url = $matches[3] == '' ? $matches[4] : $matches[3];
793
+		$title = & $matches[7];
797 794
 
798 795
 		$url = $this->encodeAttribute($url);
799 796
 
800 797
 		$result = "<a href=\"$url\"";
801 798
 		if (isset($title)) {
802 799
 			$title = $this->encodeAttribute($title);
803
-			$result .=  " title=\"$title\"";
800
+			$result .= " title=\"$title\"";
804 801
 		}
805 802
 
806 803
 		$link_text = $this->runSpanGamut($link_text);
@@ -881,7 +878,7 @@  discard block
 block discarded – undo
881 878
 			if (isset($this->titles[$link_id])) {
882 879
 				$title = $this->titles[$link_id];
883 880
 				$title = $this->encodeAttribute($title);
884
-				$result .=  " title=\"$title\"";
881
+				$result .= " title=\"$title\"";
885 882
 			}
886 883
 			$result .= $this->empty_element_suffix;
887 884
 			$result = $this->hashPart($result);
@@ -894,17 +891,17 @@  discard block
 block discarded – undo
894 891
 		return $result;
895 892
 	}
896 893
 	function _doImages_inline_callback($matches) {
897
-		$whole_match	= $matches[1];
898
-		$alt_text		= $matches[2];
899
-		$url			= $matches[3] == '' ? $matches[4] : $matches[3];
900
-		$title			=& $matches[7];
894
+		$whole_match = $matches[1];
895
+		$alt_text = $matches[2];
896
+		$url = $matches[3] == '' ? $matches[4] : $matches[3];
897
+		$title = & $matches[7];
901 898
 
902 899
 		$alt_text = $this->encodeAttribute($alt_text);
903 900
 		$url = $this->encodeAttribute($url);
904 901
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
905 902
 		if (isset($title)) {
906 903
 			$title = $this->encodeAttribute($title);
907
-			$result .=  " title=\"$title\""; # $title already quoted
904
+			$result .= " title=\"$title\""; # $title already quoted
908 905
 		}
909 906
 		$result .= $this->empty_element_suffix;
910 907
 
@@ -949,12 +946,12 @@  discard block
 block discarded – undo
949 946
 
950 947
 		$level = $matches[2]{0} == '=' ? 1 : 2;
951 948
 		$block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>";
952
-		return "\n" . $this->hashBlock($block) . "\n\n";
949
+		return "\n".$this->hashBlock($block)."\n\n";
953 950
 	}
954 951
 	function _doHeaders_callback_atx($matches) {
955 952
 		$level = strlen($matches[1]);
956 953
 		$block = "<h$level>".$this->runSpanGamut($matches[2])."</h$level>";
957
-		return "\n" . $this->hashBlock($block) . "\n\n";
954
+		return "\n".$this->hashBlock($block)."\n\n";
958 955
 	}
959 956
 
960 957
 
@@ -1033,13 +1030,13 @@  discard block
 block discarded – undo
1033 1030
 		$list = $matches[1];
1034 1031
 		$list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol";
1035 1032
 
1036
-		$marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re );
1033
+		$marker_any_re = ($list_type == "ul" ? $marker_ul_re : $marker_ol_re);
1037 1034
 
1038 1035
 		$list .= "\n";
1039 1036
 		$result = $this->processListItems($list, $marker_any_re);
1040 1037
 
1041
-		$result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>");
1042
-		return "\n". $result ."\n\n";
1038
+		$result = $this->hashBlock("<$list_type>\n".$result."</$list_type>");
1039
+		return "\n".$result."\n\n";
1043 1040
 	}
1044 1041
 
1045 1042
 	var $list_level = 0;
@@ -1092,16 +1089,16 @@  discard block
 block discarded – undo
1092 1089
 	}
1093 1090
 	function _processListItems_callback($matches) {
1094 1091
 		$item = $matches[4];
1095
-		$leading_line =& $matches[1];
1096
-		$leading_space =& $matches[2];
1092
+		$leading_line = & $matches[1];
1093
+		$leading_space = & $matches[2];
1097 1094
 		$marker_space = $matches[3];
1098
-		$tailing_blank_line =& $matches[5];
1095
+		$tailing_blank_line = & $matches[5];
1099 1096
 
1100 1097
 		if ($leading_line || $tailing_blank_line ||
1101 1098
 			preg_match('/\n{2,}/', $item))
1102 1099
 		{
1103 1100
 			# Replace marker with the appropriate whitespace indentation
1104
-			$item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item;
1101
+			$item = $leading_space.str_repeat(' ', strlen($marker_space)).$item;
1105 1102
 			$item = $this->runBlockGamut($this->outdent($item)."\n");
1106 1103
 		}
1107 1104
 		else {
@@ -1111,7 +1108,7 @@  discard block
 block discarded – undo
1111 1108
 			$item = $this->runSpanGamut($item);
1112 1109
 		}
1113 1110
 
1114
-		return "<li>" . $item . "</li>\n";
1111
+		return "<li>".$item."</li>\n";
1115 1112
 	}
1116 1113
 
1117 1114
 
@@ -1204,7 +1201,7 @@  discard block
 block discarded – undo
1204 1201
 				$token_relist[] = $strong_re;
1205 1202
 
1206 1203
 				# Construct master expression from list.
1207
-				$token_re = '{('. implode('|', $token_relist) .')}';
1204
+				$token_re = '{('.implode('|', $token_relist).')}';
1208 1205
 				$this->em_strong_prepared_relist["$em$strong"] = $token_re;
1209 1206
 			}
1210 1207
 		}
@@ -1230,8 +1227,8 @@  discard block
 block discarded – undo
1230 1227
 			#
1231 1228
 			$parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE);
1232 1229
 			$text_stack[0] .= $parts[0];
1233
-			$token =& $parts[1];
1234
-			$text =& $parts[2];
1230
+			$token = & $parts[1];
1231
+			$text = & $parts[2];
1235 1232
 
1236 1233
 			if (empty($token)) {
1237 1234
 				# Reached end of text span: empty stack without emitting.
@@ -1258,7 +1255,7 @@  discard block
 block discarded – undo
1258 1255
 				} else {
1259 1256
 					# Other closing marker: close one em or strong and
1260 1257
 					# change current token state to match the other
1261
-					$token_stack[0] = str_repeat($token{0}, 3-$token_len);
1258
+					$token_stack[0] = str_repeat($token{0}, 3 - $token_len);
1262 1259
 					$tag = $token_len == 2 ? "strong" : "em";
1263 1260
 					$span = $text_stack[0];
1264 1261
 					$span = $this->runSpanGamut($span);
@@ -1352,7 +1349,7 @@  discard block
 block discarded – undo
1352 1349
 		$bq = $matches[1];
1353 1350
 		# trim one level of quoting - trim whitespace-only lines
1354 1351
 		$bq = preg_replace('/^[ ]*>[ ]?|^[ ]+$/m', '', $bq);
1355
-		$bq = $this->runBlockGamut($bq);		# recurse
1352
+		$bq = $this->runBlockGamut($bq); # recurse
1356 1353
 
1357 1354
 		$bq = preg_replace('/^/m', "  ", $bq);
1358 1355
 		# These leading spaces cause problem with <pre> content,
@@ -1360,7 +1357,7 @@  discard block
 block discarded – undo
1360 1357
 		$bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx',
1361 1358
 			array(&$this, '_doBlockQuotes_callback2'), $bq);
1362 1359
 
1363
-		return "\n". $this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n";
1360
+		return "\n".$this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n";
1364 1361
 	}
1365 1362
 	function _doBlockQuotes_callback2($matches) {
1366 1363
 		$pre = $matches[1];
@@ -1462,7 +1459,7 @@  discard block
 block discarded – undo
1462 1459
 			# Ampersand-encoding based entirely on Nat Irons's Amputator
1463 1460
 			# MT plugin: <http://bumppo.net/projects/amputator/>
1464 1461
 			$text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/',
1465
-								'&amp;', $text);;
1462
+								'&amp;', $text); ;
1466 1463
 		}
1467 1464
 		# Encode remaining <'s
1468 1465
 		$text = str_replace('<', '&lt;', $text);
@@ -1526,9 +1523,9 @@  discard block
 block discarded – undo
1526 1523
 	#	Based by a filter by Matthew Wickline, posted to BBEdit-Talk.
1527 1524
 	#   With some optimizations by Milian Wolff.
1528 1525
 	#
1529
-		$addr = "mailto:" . $addr;
1526
+		$addr = "mailto:".$addr;
1530 1527
 		$chars = preg_split('/(?<!^)(?!$)/', $addr);
1531
-		$seed = (int)abs(crc32($addr) / strlen($addr)); # Deterministic seed.
1528
+		$seed = (int) abs(crc32($addr) / strlen($addr)); # Deterministic seed.
1532 1529
 
1533 1530
 		foreach ($chars as $key => $char) {
1534 1531
 			$ord = ord($char);
@@ -1564,7 +1561,7 @@  discard block
 block discarded – undo
1564 1561
 				|
1565 1562
 					(?<![`\\\\])
1566 1563
 					`+						# code span marker
1567
-			'.( $this->no_markup ? '' : '
1564
+			'.($this->no_markup ? '' : '
1568 1565
 				|
1569 1566
 					<!--    .*?     -->		# comment
1570 1567
 				|
@@ -1615,7 +1612,7 @@  discard block
 block discarded – undo
1615 1612
 	{
1616 1613
 		switch ($token{0}) {
1617 1614
 			case "\\":
1618
-				return $this->hashPart("&#". ord($token{1}). ";");
1615
+				return $this->hashPart("&#".ord($token{1}).";");
1619 1616
 			case "`":
1620 1617
 				# Search for end marker in remaining text.
1621 1618
 				if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm',
@@ -1670,7 +1667,7 @@  discard block
 block discarded – undo
1670 1667
 			# Calculate amount of space, insert spaces, insert block.
1671 1668
 			$amount = $this->tab_width -
1672 1669
 				$strlen($line, 'UTF-8') % $this->tab_width;
1673
-			$line .= str_repeat(" ", $amount) . $block;
1670
+			$line .= str_repeat(" ", $amount).$block;
1674 1671
 		}
1675 1672
 		return $line;
1676 1673
 	}
Please login to merge, or discard this patch.
lib/markdown/markdown_extras.php 3 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -375,6 +375,12 @@  discard block
 block discarded – undo
375 375
 
376 376
 		return array($parsed, $text);
377 377
 	}
378
+
379
+	/**
380
+	 * @param string $text
381
+	 * @param string $hash_method
382
+	 * @param boolean $md_attr
383
+	 */
378 384
 	function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
379 385
 	#
380 386
 	# Parse HTML, calling _HashHTMLBlocks_InMarkdown for block tags.
@@ -804,6 +810,9 @@  discard block
 block discarded – undo
804 810
 	}
805 811
 
806 812
 
813
+	/**
814
+	 * @return string
815
+	 */
807 816
 	function processDefListItems($list_str) {
808 817
 	#
809 818
 	#	Process the contents of a single definition list, splitting it
Please login to merge, or discard this patch.
Braces   +59 added lines, -38 removed lines patch added patch discarded remove patch
@@ -84,8 +84,9 @@  discard block
 block discarded – undo
84 84
 		$this->footnote_counter = 1;
85 85
 
86 86
 		foreach ($this->predef_abbr as $abbr_word => $abbr_desc) {
87
-			if ($this->abbr_word_re)
88
-				$this->abbr_word_re .= '|';
87
+			if ($this->abbr_word_re) {
88
+							$this->abbr_word_re .= '|';
89
+			}
89 90
 			$this->abbr_word_re .= preg_quote($abbr_word);
90 91
 			$this->abbr_desciptions[$abbr_word] = trim($abbr_desc);
91 92
 		}
@@ -174,7 +175,9 @@  discard block
 block discarded – undo
174 175
 	#
175 176
 	# Returns an array of that form: ( processed text , remaining text )
176 177
 	#
177
-		if ($text === '') return array('', '');
178
+		if ($text === '') {
179
+			return array('', '');
180
+		}
178 181
 
179 182
 		# Regex to check for the presense of newlines around a block tag.
180 183
 		$newline_before_re = '/(?:^\n?|\n\n)*$/';
@@ -280,8 +283,7 @@  discard block
 block discarded – undo
280 283
 					# End marker found: pass text unchanged until marker.
281 284
 					$parsed .= $tag . $matches[0];
282 285
 					$text = substr($text, strlen($matches[0]));
283
-				}
284
-				else {
286
+				} else {
285 287
 					# Unmatched marker: just skip it.
286 288
 					$parsed .= $tag;
287 289
 				}
@@ -298,8 +300,7 @@  discard block
 block discarded – undo
298 300
 					# End marker found: pass text unchanged until marker.
299 301
 					$parsed .= $tag . $matches[0];
300 302
 					$text = substr($text, strlen($matches[0]));
301
-				}
302
-				else {
303
+				} else {
303 304
 					# No end marker: just skip it.
304 305
 					$parsed .= $tag;
305 306
 				}
@@ -354,8 +355,11 @@  discard block
 block discarded – undo
354 355
 				#
355 356
 				# Increase/decrease nested tag count.
356 357
 				#
357
-				if ($tag{1} == '/')						$depth--;
358
-				else if ($tag{strlen($tag)-2} != '/')	$depth++;
358
+				if ($tag{1} == '/') {
359
+					$depth--;
360
+				} else if ($tag{strlen($tag)-2} != '/') {
361
+					$depth++;
362
+				}
359 363
 
360 364
 				if ($depth < 0) {
361 365
 					#
@@ -367,8 +371,7 @@  discard block
 block discarded – undo
367 371
 				}
368 372
 
369 373
 				$parsed .= $tag;
370
-			}
371
-			else {
374
+			} else {
372 375
 				$parsed .= $tag;
373 376
 			}
374 377
 		} while ($depth >= 0);
@@ -386,7 +389,9 @@  discard block
 block discarded – undo
386 389
 	#
387 390
 	# Returns an array of that form: ( processed text , remaining text )
388 391
 	#
389
-		if ($text === '') return array('', '');
392
+		if ($text === '') {
393
+			return array('', '');
394
+		}
390 395
 
391 396
 		# Regex to match `markdown` attribute inside of a tag.
392 397
 		$markdown_attr_re = '
@@ -437,8 +442,9 @@  discard block
 block discarded – undo
437 442
 		# Get the name of the starting tag.
438 443
 		# (This pattern makes $base_tag_name_re safe without quoting.)
439 444
 		#
440
-		if (preg_match('/^<([\w:$]*)\b/', $text, $matches))
441
-			$base_tag_name_re = $matches[1];
445
+		if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) {
446
+					$base_tag_name_re = $matches[1];
447
+		}
442 448
 
443 449
 		#
444 450
 		# Loop through every tag until we find the corresponding closing tag.
@@ -475,15 +481,17 @@  discard block
 block discarded – undo
475 481
 			{
476 482
 				# Just add the tag to the block as if it was text.
477 483
 				$block_text .= $tag;
478
-			}
479
-			else {
484
+			} else {
480 485
 				#
481 486
 				# Increase/decrease nested tag count. Only do so if
482 487
 				# the tag's name match base tag's.
483 488
 				#
484 489
 				if (preg_match('{^</?'.$base_tag_name_re.'\b}', $tag)) {
485
-					if ($tag{1} == '/')						$depth--;
486
-					else if ($tag{strlen($tag)-2} != '/')	$depth++;
490
+					if ($tag{1} == '/') {
491
+						$depth--;
492
+					} else if ($tag{strlen($tag)-2} != '/') {
493
+						$depth++;
494
+					}
487 495
 				}
488 496
 
489 497
 				#
@@ -530,13 +538,17 @@  discard block
 block discarded – undo
530 538
 					}
531 539
 
532 540
 					# Append tag content to parsed text.
533
-					if (!$span_mode)	$parsed .= "\n\n$block_text\n\n";
534
-					else				$parsed .= "$block_text";
541
+					if (!$span_mode) {
542
+						$parsed .= "\n\n$block_text\n\n";
543
+					} else {
544
+						$parsed .= "$block_text";
545
+					}
535 546
 
536 547
 					# Start over a new block.
537 548
 					$block_text = "";
549
+				} else {
550
+					$block_text .= $tag;
538 551
 				}
539
-				else $block_text .= $tag;
540 552
 			}
541 553
 
542 554
 		} while ($depth > 0);
@@ -601,12 +613,15 @@  discard block
 block discarded – undo
601 613
 		return $text;
602 614
 	}
603 615
 	function _doHeaders_attr($attr) {
604
-		if (empty($attr))  return "";
616
+		if (empty($attr)) {
617
+			return "";
618
+		}
605 619
 		return " id=\"$attr\"";
606 620
 	}
607 621
 	function _doHeaders_callback_setext($matches) {
608
-		if ($matches[3] == '-' && preg_match('{^- }', $matches[1]))
609
-			return $matches[0];
622
+		if ($matches[3] == '-' && preg_match('{^- }', $matches[1])) {
623
+					return $matches[0];
624
+		}
610 625
 		$level = $matches[3]{0} == '=' ? 1 : 2;
611 626
 		$attr  = $this->_doHeaders_attr($id =& $matches[2]);
612 627
 		$block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>";
@@ -704,10 +719,15 @@  discard block
 block discarded – undo
704 719
 		# Reading alignement from header underline.
705 720
 		$separators	= preg_split('/ *[|] */', $underline);
706 721
 		foreach ($separators as $n => $s) {
707
-			if (preg_match('/^ *-+: *$/', $s))		$attr[$n] = ' align="right"';
708
-			else if (preg_match('/^ *:-+: *$/', $s))$attr[$n] = ' align="center"';
709
-			else if (preg_match('/^ *:-+ *$/', $s))	$attr[$n] = ' align="left"';
710
-			else									$attr[$n] = '';
722
+			if (preg_match('/^ *-+: *$/', $s)) {
723
+				$attr[$n] = ' align="right"';
724
+			} else if (preg_match('/^ *:-+: *$/', $s)) {
725
+				$attr[$n] = ' align="center"';
726
+			} else if (preg_match('/^ *:-+ *$/', $s)) {
727
+				$attr[$n] = ' align="left"';
728
+			} else {
729
+				$attr[$n] = '';
730
+			}
711 731
 		}
712 732
 
713 733
 		# Parsing span elements, including code spans, character escapes,
@@ -720,8 +740,9 @@  discard block
 block discarded – undo
720 740
 		$text = "<table>\n";
721 741
 		$text .= "<thead>\n";
722 742
 		$text .= "<tr>\n";
723
-		foreach ($headers as $n => $header)
724
-			$text .= "  <th$attr[$n]>".$this->runSpanGamut(trim($header))."</th>\n";
743
+		foreach ($headers as $n => $header) {
744
+					$text .= "  <th$attr[$n]>".$this->runSpanGamut(trim($header))."</th>\n";
745
+		}
725 746
 		$text .= "</tr>\n";
726 747
 		$text .= "</thead>\n";
727 748
 
@@ -739,8 +760,9 @@  discard block
 block discarded – undo
739 760
 			$row_cells = array_pad($row_cells, $col_count, '');
740 761
 
741 762
 			$text .= "<tr>\n";
742
-			foreach ($row_cells as $n => $cell)
743
-				$text .= "  <td$attr[$n]>".$this->runSpanGamut(trim($cell))."</td>\n";
763
+			foreach ($row_cells as $n => $cell) {
764
+							$text .= "  <td$attr[$n]>".$this->runSpanGamut(trim($cell))."</td>\n";
765
+			}
744 766
 			$text .= "</tr>\n";
745 767
 		}
746 768
 		$text .= "</tbody>\n";
@@ -866,8 +888,7 @@  discard block
 block discarded – undo
866 888
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
867 889
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
868 890
 			$def = "\n". $def ."\n";
869
-		}
870
-		else {
891
+		} else {
871 892
 			$def = rtrim($def);
872 893
 			$def = $this->runSpanGamut($this->outdent($def));
873 894
 		}
@@ -925,8 +946,7 @@  discard block
 block discarded – undo
925 946
 		{
926 947
 			$codeblock = $this->format_codeblock($codeblock, $class);
927 948
 			$codeblock = $this->unhash($codeblock);
928
-		}
929
-		else
949
+		} else
930 950
 		{
931 951
 			$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
932 952
 			$codeblock = preg_replace_callback('/^\n+/', array($this, '_doFencedCodeBlocks_newlines'), $codeblock);
@@ -1161,8 +1181,9 @@  discard block
 block discarded – undo
1161 1181
 	function _stripAbbreviations_callback($matches) {
1162 1182
 		$abbr_word = $matches[1];
1163 1183
 		$abbr_desc = $matches[2];
1164
-		if ($this->abbr_word_re)
1165
-			$this->abbr_word_re .= '|';
1184
+		if ($this->abbr_word_re) {
1185
+					$this->abbr_word_re .= '|';
1186
+		}
1166 1187
 		$this->abbr_word_re .= preg_quote($abbr_word);
1167 1188
 		$this->abbr_desciptions[$abbr_word] = trim($abbr_desc);
1168 1189
 		return ''; # String that will replace the block
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		#
143 143
 		# Call the HTML-in-Markdown hasher.
144 144
 		#
145
-		list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text);
145
+		list($text,) = $this->_hashHTMLBlocks_inMarkdown($text);
146 146
 
147 147
 		return $text;
148 148
 	}
@@ -214,25 +214,25 @@  discard block
 block discarded – undo
214 214
 				|
215 215
 					# Code span marker
216 216
 					`+
217
-				'. ( !$span ? ' # If not in span.
217
+				'. (!$span ? ' # If not in span.
218 218
 				|
219 219
 					# Indented code block
220 220
 					(?: ^[ ]*\n | ^ | \n[ ]*\n )
221
-					[ ]{'.($indent+4).'}[^\n]* \n
221
+					[ ]{'.($indent + 4).'}[^\n]* \n
222 222
 					(?>
223
-						(?: [ ]{'.($indent+4).'}[^\n]* | [ ]* ) \n
223
+						(?: [ ]{'.($indent + 4).'}[^\n]* | [ ]* ) \n
224 224
 					)*
225 225
 				|
226 226
 					# Fenced code block marker
227 227
 					(?> ^ | \n )
228 228
 					[ ]{0,'.($indent).'}~~~+[ ]*\n
229
-				' : '' ). ' # End (if not is span).
229
+				' : '').' # End (if not is span).
230 230
 				)
231 231
 			}xs';
232 232
 
233 233
 
234
-		$depth = 0;		# Current depth inside the tag tree.
235
-		$parsed = "";	# Parsed text that will be returned.
234
+		$depth = 0; # Current depth inside the tag tree.
235
+		$parsed = ""; # Parsed text that will be returned.
236 236
 
237 237
 		#
238 238
 		# Loop through every tag until we find the closing tag of the parent
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 			if ($span) {
254 254
 				$void = $this->hashPart("", ':');
255 255
 				$newline = "$void\n";
256
-				$parts[0] = $void . str_replace("\n", $newline, $parts[0]) . $void;
256
+				$parts[0] = $void.str_replace("\n", $newline, $parts[0]).$void;
257 257
 			}
258 258
 
259 259
 			$parsed .= $parts[0]; # Text before current tag.
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 					$text, $matches))
279 279
 				{
280 280
 					# End marker found: pass text unchanged until marker.
281
-					$parsed .= $tag . $matches[0];
281
+					$parsed .= $tag.$matches[0];
282 282
 					$text = substr($text, strlen($matches[0]));
283 283
 				}
284 284
 				else {
@@ -289,14 +289,14 @@  discard block
 block discarded – undo
289 289
 			#
290 290
 			# Check for: Fenced code block marker.
291 291
 			#
292
-			else if (preg_match('{^\n?[ ]{0,'.($indent+3).'}~}', $tag)) {
292
+			else if (preg_match('{^\n?[ ]{0,'.($indent + 3).'}~}', $tag)) {
293 293
 				# Fenced code block marker: find matching end marker.
294 294
 				$tag_re = preg_quote(trim($tag));
295 295
 				if (preg_match('{^(?>.*\n)+?[ ]{0,'.($indent).'}'.$tag_re.'[ ]*\n}', $text,
296 296
 					$matches))
297 297
 				{
298 298
 					# End marker found: pass text unchanged until marker.
299
-					$parsed .= $tag . $matches[0];
299
+					$parsed .= $tag.$matches[0];
300 300
 					$text = substr($text, strlen($matches[0]));
301 301
 				}
302 302
 				else {
@@ -318,14 +318,14 @@  discard block
 block discarded – undo
318 318
 			#               used as a block tag (tag is alone on it's line).
319 319
 			#
320 320
 			else if (preg_match('{^<(?:'.$this->block_tags_re.')\b}', $tag) ||
321
-				(	preg_match('{^<(?:'.$this->context_block_tags_re.')\b}', $tag) &&
321
+				(preg_match('{^<(?:'.$this->context_block_tags_re.')\b}', $tag) &&
322 322
 					preg_match($newline_before_re, $parsed) &&
323
-					preg_match($newline_after_re, $text)	)
323
+					preg_match($newline_after_re, $text))
324 324
 				)
325 325
 			{
326 326
 				# Need to parse tag and following text using the HTML parser.
327 327
 				list($block_text, $text) =
328
-					$this->_hashHTMLBlocks_inHTML($tag . $text, "hashBlock", true);
328
+					$this->_hashHTMLBlocks_inHTML($tag.$text, "hashBlock", true);
329 329
 
330 330
 				# Make sure it stays outside of any paragraph by adding newlines.
331 331
 				$parsed .= "\n\n$block_text\n\n";
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 				# Need to parse tag and following text using the HTML parser.
341 341
 				# (don't check for markdown attribute)
342 342
 				list($block_text, $text) =
343
-					$this->_hashHTMLBlocks_inHTML($tag . $text, "hashClean", false);
343
+					$this->_hashHTMLBlocks_inHTML($tag.$text, "hashClean", false);
344 344
 
345 345
 				$parsed .= $block_text;
346 346
 			}
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
 				# Increase/decrease nested tag count.
356 356
 				#
357 357
 				if ($tag{1} == '/')						$depth--;
358
-				else if ($tag{strlen($tag)-2} != '/')	$depth++;
358
+				else if ($tag{strlen($tag) - 2} != '/')	$depth++;
359 359
 
360 360
 				if ($depth < 0) {
361 361
 					#
362 362
 					# Going out of parent element. Clean up and break so we
363 363
 					# return to the calling function.
364 364
 					#
365
-					$text = $tag . $text;
365
+					$text = $tag.$text;
366 366
 					break;
367 367
 				}
368 368
 
@@ -427,11 +427,11 @@  discard block
 block discarded – undo
427 427
 				)
428 428
 			}xs';
429 429
 
430
-		$original_text = $text;		# Save original text in case of faliure.
430
+		$original_text = $text; # Save original text in case of faliure.
431 431
 
432
-		$depth		= 0;	# Current depth inside the tag tree.
433
-		$block_text	= "";	# Temporary text holder for current text.
434
-		$parsed		= "";	# Parsed text that will be returned.
432
+		$depth = 0; # Current depth inside the tag tree.
433
+		$block_text = ""; # Temporary text holder for current text.
434
+		$parsed = ""; # Parsed text that will be returned.
435 435
 
436 436
 		#
437 437
 		# Get the name of the starting tag.
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 				#
484 484
 				if (preg_match('{^</?'.$base_tag_name_re.'\b}', $tag)) {
485 485
 					if ($tag{1} == '/')						$depth--;
486
-					else if ($tag{strlen($tag)-2} != '/')	$depth++;
486
+					else if ($tag{strlen($tag) - 2} != '/')	$depth++;
487 487
 				}
488 488
 
489 489
 				#
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
 				#
492 492
 				if ($md_attr &&
493 493
 					preg_match($markdown_attr_re, $tag, $attr_m) &&
494
-					preg_match('/^1|block|span$/', $attr_m[2] . $attr_m[3]))
494
+					preg_match('/^1|block|span$/', $attr_m[2].$attr_m[3]))
495 495
 				{
496 496
 					# Remove `markdown` attribute from opening tag.
497 497
 					$tag = preg_replace($markdown_attr_re, '', $tag);
498 498
 
499 499
 					# Check if text inside this tag must be parsed in span mode.
500
-					$this->mode = $attr_m[2] . $attr_m[3];
500
+					$this->mode = $attr_m[2].$attr_m[3];
501 501
 					$span_mode = $this->mode == 'span' || $this->mode != 'block' &&
502 502
 						preg_match('{^<(?:'.$this->contain_span_tags_re.')\b}', $tag);
503 503
 
@@ -608,15 +608,15 @@  discard block
 block discarded – undo
608 608
 		if ($matches[3] == '-' && preg_match('{^- }', $matches[1]))
609 609
 			return $matches[0];
610 610
 		$level = $matches[3]{0} == '=' ? 1 : 2;
611
-		$attr  = $this->_doHeaders_attr($id =& $matches[2]);
611
+		$attr  = $this->_doHeaders_attr($id = & $matches[2]);
612 612
 		$block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>";
613
-		return "\n" . $this->hashBlock($block) . "\n\n";
613
+		return "\n".$this->hashBlock($block)."\n\n";
614 614
 	}
615 615
 	function _doHeaders_callback_atx($matches) {
616 616
 		$level = strlen($matches[1]);
617
-		$attr  = $this->_doHeaders_attr($id =& $matches[3]);
617
+		$attr  = $this->_doHeaders_attr($id = & $matches[3]);
618 618
 		$block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>";
619
-		return "\n" . $this->hashBlock($block) . "\n\n";
619
+		return "\n".$this->hashBlock($block)."\n\n";
620 620
 	}
621 621
 
622 622
 
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
 		return $text;
683 683
 	}
684 684
 	function _doTable_leadingPipe_callback($matches) {
685
-		$head		= $matches[1];
686
-		$underline	= $matches[2];
685
+		$head = $matches[1];
686
+		$underline = $matches[2];
687 687
 		$content	= $matches[3];
688 688
 
689 689
 		# Remove leading pipe for each row.
@@ -692,17 +692,17 @@  discard block
 block discarded – undo
692 692
 		return $this->_doTable_callback(array($matches[0], $head, $underline, $content));
693 693
 	}
694 694
 	function _doTable_callback($matches) {
695
-		$head		= $matches[1];
696
-		$underline	= $matches[2];
697
-		$content	= $matches[3];
695
+		$head = $matches[1];
696
+		$underline = $matches[2];
697
+		$content = $matches[3];
698 698
 
699 699
 		# Remove any tailing pipes for each line.
700
-		$head		= preg_replace('/[|] *$/m', '', $head);
701
-		$underline	= preg_replace('/[|] *$/m', '', $underline);
702
-		$content	= preg_replace('/[|] *$/m', '', $content);
700
+		$head = preg_replace('/[|] *$/m', '', $head);
701
+		$underline = preg_replace('/[|] *$/m', '', $underline);
702
+		$content = preg_replace('/[|] *$/m', '', $content);
703 703
 
704 704
 		# Reading alignement from header underline.
705
-		$separators	= preg_split('/ *[|] */', $underline);
705
+		$separators = preg_split('/ *[|] */', $underline);
706 706
 		foreach ($separators as $n => $s) {
707 707
 			if (preg_match('/^ *-+: *$/', $s))		$attr[$n] = ' align="right"';
708 708
 			else if (preg_match('/^ *:-+: *$/', $s))$attr[$n] = ' align="center"';
@@ -712,9 +712,9 @@  discard block
 block discarded – undo
712 712
 
713 713
 		# Parsing span elements, including code spans, character escapes,
714 714
 		# and inline HTML tags, so that pipes inside those gets ignored.
715
-		$head		= $this->parseSpan($head);
716
-		$headers	= preg_split('/ *[|] */', $head);
717
-		$col_count	= count($headers);
715
+		$head = $this->parseSpan($head);
716
+		$headers = preg_split('/ *[|] */', $head);
717
+		$col_count = count($headers);
718 718
 
719 719
 		# Write column headers.
720 720
 		$text = "<table>\n";
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 		$text .= "</tbody>\n";
747 747
 		$text .= "</table>";
748 748
 
749
-		return $this->hashBlock($text) . "\n";
749
+		return $this->hashBlock($text)."\n";
750 750
 	}
751 751
 
752 752
 
@@ -799,8 +799,8 @@  discard block
 block discarded – undo
799 799
 		# Turn double returns into triple returns, so that we can make a
800 800
 		# paragraph for the last item in a list, if necessary:
801 801
 		$result = trim($this->processDefListItems($list));
802
-		$result = "<dl>\n" . $result . "\n</dl>";
803
-		return $this->hashBlock($result) . "\n\n";
802
+		$result = "<dl>\n".$result."\n</dl>";
803
+		return $this->hashBlock($result)."\n\n";
804 804
 	}
805 805
 
806 806
 
@@ -852,27 +852,27 @@  discard block
 block discarded – undo
852 852
 		$text = '';
853 853
 		foreach ($terms as $term) {
854 854
 			$term = $this->runSpanGamut(trim($term));
855
-			$text .= "\n<dt>" . $term . "</dt>";
855
+			$text .= "\n<dt>".$term."</dt>";
856 856
 		}
857
-		return $text . "\n";
857
+		return $text."\n";
858 858
 	}
859 859
 	function _processDefListItems_callback_dd($matches) {
860 860
 		$leading_line	= $matches[1];
861 861
 		$marker_space	= $matches[2];
862
-		$def			= $matches[3];
862
+		$def = $matches[3];
863 863
 
864 864
 		if ($leading_line || preg_match('/\n{2,}/', $def)) {
865 865
 			# Replace marker with the appropriate whitespace indentation
866
-			$def = str_repeat(' ', strlen($marker_space)) . $def;
867
-			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
868
-			$def = "\n". $def ."\n";
866
+			$def = str_repeat(' ', strlen($marker_space)).$def;
867
+			$def = $this->runBlockGamut($this->outdent($def."\n\n"));
868
+			$def = "\n".$def."\n";
869 869
 		}
870 870
 		else {
871 871
 			$def = rtrim($def);
872 872
 			$def = $this->runSpanGamut($this->outdent($def));
873 873
 		}
874 874
 
875
-		return "\n<dd>" . $def . "</dd>\n";
875
+		return "\n<dd>".$def."</dd>\n";
876 876
 	}
877 877
 
878 878
 	/**
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
 			$codeblock = preg_replace_callback('/^\n+/', array($this, '_doFencedCodeBlocks_newlines'), $codeblock);
933 933
 		}
934 934
 
935
-		$codeblock = '<pre' . ($class ? ' class="' . $class . '"' : '') . '><code>' . $codeblock . '</code></pre>';
935
+		$codeblock = '<pre'.($class ? ' class="'.$class.'"' : '').'><code>'.$codeblock.'</code></pre>';
936 936
 
937 937
 		return "\n\n".$this->hashBlock($codeblock)."\n\n";
938 938
 	}
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 		return $text;
1031 1031
 	}
1032 1032
 	function _stripFootnotes_callback($matches) {
1033
-		$note_id = $this->fn_id_prefix . $matches[1];
1033
+		$note_id = $this->fn_id_prefix.$matches[1];
1034 1034
 		$this->footnotes[$note_id] = $this->outdent($matches[2]);
1035 1035
 		return ''; # String that will replace the block
1036 1036
 	}
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 		if (!empty($this->footnotes_ordered)) {
1059 1059
 			$text .= "\n\n";
1060 1060
 			$text .= "<div class=\"footnotes\">\n";
1061
-			$text .= "<hr". $this->empty_element_suffix ."\n";
1061
+			$text .= "<hr".$this->empty_element_suffix."\n";
1062 1062
 			$text .= "<ol>\n\n";
1063 1063
 
1064 1064
 			$attr = " rev=\"footnote\"";
@@ -1090,13 +1090,13 @@  discard block
 block discarded – undo
1090 1090
 				# Add backlink to last paragraph; create new paragraph if needed.
1091 1091
 				$backlink = "<a href=\"#fnref:$note_id\"$attr>&#8617;</a>";
1092 1092
 				if (preg_match('{</p>$}', $footnote)) {
1093
-					$footnote = substr($footnote, 0, -4) . "&#160;$backlink</p>";
1093
+					$footnote = substr($footnote, 0, -4)."&#160;$backlink</p>";
1094 1094
 				} else {
1095 1095
 					$footnote .= "\n\n<p>$backlink</p>";
1096 1096
 				}
1097 1097
 
1098 1098
 				$text .= "<li id=\"fn:$note_id\">\n";
1099
-				$text .= $footnote . "\n";
1099
+				$text .= $footnote."\n";
1100 1100
 				$text .= "</li>\n\n";
1101 1101
 			}
1102 1102
 
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 		return $text;
1107 1107
 	}
1108 1108
 	function _appendFootnotes_callback($matches) {
1109
-		$node_id = $this->fn_id_prefix . $matches[1];
1109
+		$node_id = $this->fn_id_prefix.$matches[1];
1110 1110
 
1111 1111
 		# Create footnote marker only if it has a corresponding footnote *and*
1112 1112
 		# the footnote hasn't been used by another marker.
Please login to merge, or discard this patch.
lib/textmark/textmark.php 4 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -219,6 +219,9 @@  discard block
 block discarded – undo
219 219
 		return $text;
220 220
 	}
221 221
 
222
+	/**
223
+	 * @param string $text
224
+	 */
222 225
 	private function doSourcePublish($text)
223 226
 	{
224 227
 		return Patron($text);
@@ -796,6 +799,9 @@  discard block
 block discarded – undo
796 799
 	 **
797 800
 	 */
798 801
 
802
+	/**
803
+	 * @param string $markup
804
+	 */
799 805
 	function createElement($markup, $attrs, $body=NULL)
800 806
 	{
801 807
 		$rc = array();
@@ -934,6 +940,10 @@  discard block
 block discarded – undo
934 940
 	# PHP source highlighter
935 941
 	#
936 942
 
943
+	/**
944
+	 * @param string $text
945
+	 * @param string $marker
946
+	 */
937 947
 	function doSourceCommentLine($text, $marker)
938 948
 	{
939 949
 		$lines = explode("\n", $text);
@@ -983,6 +993,9 @@  discard block
 block discarded – undo
983 993
 	const QUOTE_DOUBLE = '"';
984 994
 	const ESCAPE = '\\';
985 995
 
996
+	/**
997
+	 * @param string $text
998
+	 */
986 999
 	function doSourceString($text)
987 1000
 	{
988 1001
 		$out = NULL;
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1124,7 +1124,7 @@
 block discarded – undo
1124 1124
 			'break',
1125 1125
 			'class',
1126 1126
 			'const',
1127
-            'endif',
1127
+			'endif',
1128 1128
 			'case',
1129 1129
 			'true',
1130 1130
 			'self',
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -513,8 +513,7 @@  discard block
 block discarded – undo
513 513
 				if ($style)
514 514
 				{
515 515
 					$value = '<p style="' . $style . '">' . $value . '</p>';
516
-				}
517
-				else
516
+				} else
518 517
 				{
519 518
 					$value = "<p>$value</p>";
520 519
 				}
@@ -704,8 +703,7 @@  discard block
 block discarded – undo
704 703
 			)
705 704
 			->fetchAndClose();
706 705
 
707
-		}
708
-		else
706
+		} else
709 707
 		{
710 708
 			$entry = $module->model()->loadRange
711 709
 			(
@@ -953,16 +951,13 @@  discard block
 block discarded – undo
953 951
 				if (($c == $in_quotes) && (($i > 1) && ($line{$i - 1} != '\\')))
954 952
 				{
955 953
 					$in_quotes = NULL;
956
-				}
957
-				else if ($in_quotes)
954
+				} else if ($in_quotes)
958 955
 				{
959 956
 					continue;
960
-				}
961
-				else if (($c == '\'') || ($c == '"'))
957
+				} else if (($c == '\'') || ($c == '"'))
962 958
 				{
963 959
 					$in_quotes = $c;
964
-				}
965
-				else if (substr($line, $i, $marker_len) == $marker)
960
+				} else if (substr($line, $i, $marker_len) == $marker)
966 961
 				{
967 962
 					//					echo l('found marker at \1 (\2)<br />', $i, \ICanBoogie\escape(substr($line, $i, 16)));
968 963
 
@@ -1005,27 +1000,23 @@  discard block
 block discarded – undo
1005 1000
 					$escaped = false;
1006 1001
 
1007 1002
 					continue;
1008
-				}
1009
-				else if ($quote_start !== null && $c == $quote)
1003
+				} else if ($quote_start !== null && $c == $quote)
1010 1004
 				{
1011 1005
 					$out .= $this->hashPart('<span class="string">' . \ICanBoogie\escape($quote . substr($text, $quote_start + 1, $i - $quote_start - 1) . $quote) . '</span>');
1012 1006
 
1013 1007
 					$quote_start = null;
1014 1008
 					$quote = null;
1015
-				}
1016
-				else
1009
+				} else
1017 1010
 				{
1018 1011
 					$quote = $c;
1019 1012
 					$quote_start = $i;
1020 1013
 				}
1021
-			}
1022
-			else
1014
+			} else
1023 1015
 			{
1024 1016
 				if ($c == '\\')
1025 1017
 				{
1026 1018
 					$escaped = !$escaped;
1027
-				}
1028
-				else
1019
+				} else
1029 1020
 				{
1030 1021
 					$escaped = false;
1031 1022
 				}
Please login to merge, or discard this patch.
Spacing   +109 added lines, -135 removed lines patch added patch discarded remove patch
@@ -27,18 +27,18 @@  discard block
 block discarded – undo
27 27
  @define('txt_registered',		  '&reg;');
28 28
  @define('txt_copyright',		  '&copy;');
29 29
  */
30
-@define('txt_apostrophe',		  '\'');
31
-@define('txt_quote_double_open',  '« ');
30
+@define('txt_apostrophe', '\'');
31
+@define('txt_quote_double_open', '« ');
32 32
 @define('txt_quote_double_close', ' »');
33
-@define('txt_prime',			  'ʹ');
34
-@define('txt_prime_double', 	  'ʺ');
35
-@define('txt_ellipsis', 		  '…');
36
-@define('txt_emdash',			  '—');
37
-@define('txt_endash',			  '–');
38
-@define('txt_dimension',		  '×');
39
-@define('txt_trademark',		  '™');
40
-@define('txt_registered',		  '®');
41
-@define('txt_copyright',		  '©');
33
+@define('txt_prime', 'ʹ');
34
+@define('txt_prime_double', 'ʺ');
35
+@define('txt_ellipsis', '…');
36
+@define('txt_emdash', '—');
37
+@define('txt_endash', '–');
38
+@define('txt_dimension', '×');
39
+@define('txt_trademark', '™');
40
+@define('txt_registered', '®');
41
+@define('txt_copyright', '©');
42 42
 
43 43
 class Textmark_Parser extends MarkdownExtra_Parser
44 44
 {
@@ -52,14 +52,12 @@  discard block
 block discarded – undo
52 52
 
53 53
 	function __construct()
54 54
 	{
55
-		$this->early_gamut += array
56
-		(
55
+		$this->early_gamut += array(
57 56
 			'doShell' => 5,
58 57
 			'doURL' => 6
59 58
 		);
60 59
 
61
-		$this->span_gamut += array
62
-		(
60
+		$this->span_gamut += array(
63 61
 			'doGlyphs' => 70,
64 62
 			'doSpan' => 71
65 63
 		);
@@ -69,8 +67,7 @@  discard block
 block discarded – undo
69 67
 
70 68
 	public function doShell($text)
71 69
 	{
72
-		return preg_replace_callback
73
-		(
70
+		return preg_replace_callback(
74 71
 			'{^\$\s+([^\n]+)\n}xm', array($this, 'doShell_callback'), $text
75 72
 		);
76 73
 
@@ -79,7 +76,7 @@  discard block
 block discarded – undo
79 76
 
80 77
 	protected function doShell_callback($matches)
81 78
 	{
82
-		$text = '<pre class="markdown shell">$ ' . $matches[1] . '</pre>' . PHP_EOL;
79
+		$text = '<pre class="markdown shell">$ '.$matches[1].'</pre>'.PHP_EOL;
83 80
 
84 81
 		return $this->hashBlock($text);
85 82
 	}
@@ -210,9 +207,9 @@  discard block
 block discarded – undo
210 207
 
211 208
 		switch ($type)
212 209
 		{
213
-			case 'php': return '<pre class="php"><code>' . $this->doSourcePHP($text) . '</code></pre>';
214
-			case 'html': return '<pre class="html"><code>' . $this->doSourceHTML($text) . '</code></pre>';
215
-			case 'raw': return '<pre><code>' . $this->doSourceRaw($text) . '</code></pre>';
210
+			case 'php': return '<pre class="php"><code>'.$this->doSourcePHP($text).'</code></pre>';
211
+			case 'html': return '<pre class="html"><code>'.$this->doSourceHTML($text).'</code></pre>';
212
+			case 'raw': return '<pre><code>'.$this->doSourceRaw($text).'</code></pre>';
216 213
 			case 'publish': return $this->doSourcePublish($text);
217 214
 		}
218 215
 
@@ -271,8 +268,7 @@  discard block
 block discarded – undo
271 268
 
272 269
 		*/
273 270
 
274
-		$text = preg_replace_callback
275
-		(
271
+		$text = preg_replace_callback(
276 272
 			'{
277 273
 				^h([1-6])\.	# $1 = string of h?
278 274
 				[ ]*
@@ -296,9 +292,9 @@  discard block
 block discarded – undo
296 292
 			case '-': $level = 3; break;
297 293
 		}
298 294
 
299
-		$block = "<h$level>" . $this->runSpanGamut($matches[1]) . "</h$level>";
295
+		$block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>";
300 296
 
301
-		return "\n" . $this->hashBlock($block) . "\n\n";
297
+		return "\n".$this->hashBlock($block)."\n\n";
302 298
 	}
303 299
 
304 300
 	function _doHeaders_callback_tp($matches)
@@ -306,8 +302,8 @@  discard block
 block discarded – undo
306 302
 		//		\ICanBoogie\log('<pre>doHeaders[atx]: \1</pre>', print_r($matches, true));
307 303
 
308 304
 		$level = $matches[1];
309
-		$block = "<h$level>" . $this->runSpanGamut($matches[2]) . "</h$level>";
310
-		return "\n" . $this->hashBlock($block) . "\n\n";
305
+		$block = "<h$level>".$this->runSpanGamut($matches[2])."</h$level>";
306
+		return "\n".$this->hashBlock($block)."\n\n";
311 307
 	}
312 308
 
313 309
 	/*
@@ -327,14 +323,14 @@  discard block
 block discarded – undo
327 323
 
328 324
 		$c = "(?:{$clas}|{$styl}|{$lnge}|{$hlgn})*";
329 325
 
330
-		$qtags = array('\*\*','\*','\?\?','-','__','_','%','\+','~','\^');
326
+		$qtags = array('\*\*', '\*', '\?\?', '-', '__', '_', '%', '\+', '~', '\^');
331 327
 		$pnct = ".,\"'?!;:";
332 328
 
333
-		foreach($qtags as $f) {
329
+		foreach ($qtags as $f) {
334 330
 			$text = preg_replace_callback("/
335 331
 				(^|(?<=[\s>$pnct\(])|[{[])
336 332
 				($f)(?!$f)
337
-				(" . $c . ")
333
+				(".$c.")
338 334
 				(?::(\S+))?
339 335
 				([^\s$f]+|\S.*?[^\s$f\n])
340 336
 				([$pnct]*)
@@ -382,23 +378,22 @@  discard block
 block discarded – undo
382 378
 	{
383 379
 		//		echo l('doGlyphs: "\1"<br />', \ICanBoogie\escape($text));
384 380
 
385
-		$glyph_search = array
386
-		(
381
+		$glyph_search = array(
387 382
 		//		'/(\w)\'(\w)/', 									 // apostrophe's
388
-			'/(\s)\'(\d+\w?)\b(?!\')/u', 						 // back in '88
383
+			'/(\s)\'(\d+\w?)\b(?!\')/u', // back in '88
389 384
 		//		'/(\S)\'(?=\s|[[:punct:]]|<|$)/',						 //  single closing
390 385
 		//		'/\'/', 											 //  single opening
391
-			'/(\S)\"(?=\s|[[:punct:]]|<|$)/u',						 //  double closing
392
-			'/"/',												 //  double opening
393
-			'/\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/u',		 //  3+ uppercase acronym
394
-			'/(?<=\s|^|[>(;-])([A-Z]{3,})([a-z]*)(?=\s|[[:punct:]]|<|$)/u',  //  3+ uppercase
395
-			'/([^.]?)\.{3}/u',									 //  ellipsis
396
-			'/(\s?)--(\s?)/u',									 //  em dash
397
-			'/\s-(?:\s|$)/u',									 //  en dash
398
-			'/(\d+)( ?)x( ?)(?=\d+)/u',							 //  dimension sign
399
-			'/(\b ?|\s|^)[([]TM[])]/iu', 						 //  trademark
400
-			'/(\b ?|\s|^)[([]R[])]/iu',							 //  registered
401
-			'/(\b ?|\s|^)[([]C[])]/iu',							 //  copyright
386
+			'/(\S)\"(?=\s|[[:punct:]]|<|$)/u', //  double closing
387
+			'/"/', //  double opening
388
+			'/\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/u', //  3+ uppercase acronym
389
+			'/(?<=\s|^|[>(;-])([A-Z]{3,})([a-z]*)(?=\s|[[:punct:]]|<|$)/u', //  3+ uppercase
390
+			'/([^.]?)\.{3}/u', //  ellipsis
391
+			'/(\s?)--(\s?)/u', //  em dash
392
+			'/\s-(?:\s|$)/u', //  en dash
393
+			'/(\d+)( ?)x( ?)(?=\d+)/u', //  dimension sign
394
+			'/(\b ?|\s|^)[([]TM[])]/iu', //  trademark
395
+			'/(\b ?|\s|^)[([]R[])]/iu', //  registered
396
+			'/(\b ?|\s|^)[([]C[])]/iu', //  copyright
402 397
 
403 398
 		#
404 399
 		# the following is for french language
@@ -407,29 +402,28 @@  discard block
 block discarded – undo
407 402
 			'#\s(\!|\?|\:|\;|\-)#u',
408 403
 		);
409 404
 
410
-		$glyph_replace = array
411
-		(
405
+		$glyph_replace = array(
412 406
 		//		'$1'.$txt_apostrophe.'$2',			 // apostrophe's
413
-			'$1'.txt_apostrophe.'$2',			 // back in '88
407
+			'$1'.txt_apostrophe.'$2', // back in '88
414 408
 		//		'$1'.$txt_quote_single_close,		 //  single closing
415 409
 		//		$txt_quote_single_open, 			 //  single opening
416
-			'$1'.txt_quote_double_close,		 //  double closing
417
-		txt_quote_double_open, 			 //  double opening
418
-			'<acronym title="$2">$1</acronym>',  //  3+ uppercase acronym
419
-			'<span class="caps">$1</span>$2',	 //  3+ uppercase
420
-			'$1'.txt_ellipsis, 				 //  ellipsis
421
-			'$1'.txt_emdash.'$2',				 //  em dash
422
-			' '.txt_endash.' ',				 //  en dash
423
-			'$1$2'.txt_dimension.'$3', 		 //  dimension sign
424
-			'$1'.txt_trademark,				 //  trademark
425
-			'$1'.txt_registered,				 //  registered
426
-			'$1'.txt_copyright,				 //  copyright
410
+			'$1'.txt_quote_double_close, //  double closing
411
+		txt_quote_double_open, //  double opening
412
+			'<acronym title="$2">$1</acronym>', //  3+ uppercase acronym
413
+			'<span class="caps">$1</span>$2', //  3+ uppercase
414
+			'$1'.txt_ellipsis, //  ellipsis
415
+			'$1'.txt_emdash.'$2', //  em dash
416
+			' '.txt_endash.' ', //  en dash
417
+			'$1$2'.txt_dimension.'$3', //  dimension sign
418
+			'$1'.txt_trademark, //  trademark
419
+			'$1'.txt_registered, //  registered
420
+			'$1'.txt_copyright, //  copyright
427 421
 
428 422
 		#
429 423
 		# the following is for french language
430 424
 		#
431 425
 
432
-		self::NBSP . '$1',
426
+		self::NBSP.'$1',
433 427
 		);
434 428
 
435 429
 		return preg_replace($glyph_search, $glyph_replace, $text);
@@ -467,8 +461,7 @@  discard block
 block discarded – undo
467 461
 
468 462
 			$style = NULL;
469 463
 
470
-			if (preg_match
471
-			(
464
+			if (preg_match(
472 465
 				'{
473 466
 					(						# the whole thing is saved in $1
474 467
 					^p						# start
@@ -514,7 +507,7 @@  discard block
 block discarded – undo
514 507
 			{
515 508
 				if ($style)
516 509
 				{
517
-					$value = '<p style="' . $style . '">' . $value . '</p>';
510
+					$value = '<p style="'.$style.'">'.$value.'</p>';
518 511
 				}
519 512
 				else
520 513
 				{
@@ -583,8 +576,7 @@  discard block
 block discarded – undo
583 576
 		# First, handle reference-style labeled images: ![alt text][id]
584 577
 		#
585 578
 
586
-		$text = preg_replace_callback
587
-		(
579
+		$text = preg_replace_callback(
588 580
 			'{
589 581
 			(										# wrap whole match in $1
590 582
 			  !										# start
@@ -697,10 +689,8 @@  discard block
 block discarded – undo
697 689
 
698 690
 		if (isset($parts[1]))
699 691
 		{
700
-			$entry = $module->model()->loadRange
701
-			(
702
-			0, 1, 'WHERE `' . $module->getConstant('TITLE') . '` = ? AND `' . $module->getConstant('ALBUM') . '` = ?', array
703
-			(
692
+			$entry = $module->model()->loadRange(
693
+			0, 1, 'WHERE `'.$module->getConstant('TITLE').'` = ? AND `'.$module->getConstant('ALBUM').'` = ?', array(
704 694
 			$parts[1], $parts[0]
705 695
 			)
706 696
 			)
@@ -709,10 +699,8 @@  discard block
 block discarded – undo
709 699
 		}
710 700
 		else
711 701
 		{
712
-			$entry = $module->model()->loadRange
713
-			(
714
-			0, 1, 'WHERE `slug` = ? OR `title` = ?', array
715
-			(
702
+			$entry = $module->model()->loadRange(
703
+			0, 1, 'WHERE `slug` = ? OR `title` = ?', array(
716 704
 			$id, $id
717 705
 			)
718 706
 			)
@@ -727,8 +715,7 @@  discard block
 block discarded – undo
727 715
 			return parent::_doImages_reference_callback($matches);
728 716
 		}
729 717
 
730
-		$params = array
731
-		(
718
+		$params = array(
732 719
 			'src' => $entry->path,
733 720
 			'alt' => \ICanBoogie\escape($alt),
734 721
 			'width' => $entry->width,
@@ -757,11 +744,11 @@  discard block
 block discarded – undo
757 744
 	{
758 745
 		//		\ICanBoogie\log('<pre>in \1: \2</pre>', __FUNCTION__, $matches);
759 746
 
760
-		$whole_match	= $matches[1];
747
+		$whole_match = $matches[1];
761 748
 		$align = $matches[2];
762
-		$alt_text		= $matches[3];
749
+		$alt_text = $matches[3];
763 750
 		$url			= $matches[4] == '' ? $matches[5] : $matches[4];
764
-		$title			=& $matches[8];
751
+		$title = & $matches[8];
765 752
 
766 753
 		$alt_text = str_replace('"', '&quot;', $alt_text);
767 754
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
@@ -776,13 +763,13 @@  discard block
 block discarded – undo
776 763
 				case '>': $align = 'right'; break;
777 764
 			}
778 765
 
779
-			$result .= ' align="' . $align . '"';
766
+			$result .= ' align="'.$align.'"';
780 767
 		}
781 768
 
782 769
 		if (isset($title))
783 770
 		{
784 771
 			$title = str_replace('"', '&quot;', $title);
785
-			$result .=  " title=\"$title\""; # $title already quoted
772
+			$result .= " title=\"$title\""; # $title already quoted
786 773
 		}
787 774
 
788 775
 		$result .= $this->empty_element_suffix;
@@ -798,16 +785,16 @@  discard block
 block discarded – undo
798 785
 	 **
799 786
 	 */
800 787
 
801
-	function createElement($markup, $attrs, $body=NULL)
788
+	function createElement($markup, $attrs, $body = NULL)
802 789
 	{
803 790
 		$rc = array();
804 791
 
805 792
 		foreach ($attrs as $name => $value)
806 793
 		{
807
-			$rc[] = $name . '="' . $value . '"';
794
+			$rc[] = $name.'="'.$value.'"';
808 795
 		}
809 796
 
810
-		return "<$markup " . implode(' ', $rc) . ($body ? ">$body</$markup>" : " />");
797
+		return "<$markup ".implode(' ', $rc).($body ? ">$body</$markup>" : " />");
811 798
 	}
812 799
 
813 800
 	protected function format_codeblock($codeblock, $type)
@@ -847,8 +834,7 @@  discard block
 block discarded – undo
847 834
 		# markup
848 835
 		#
849 836
 
850
-		$text = preg_replace_callback
851
-		(
837
+		$text = preg_replace_callback(
852 838
 			'#(\<\!?[^\s^\>]+)(\s+[^\>]+)?(\/?\>)#m', array($this, '_do_html_markup'), $text
853 839
 		);
854 840
 
@@ -860,8 +846,7 @@  discard block
 block discarded – undo
860 846
 
861 847
 		//		\ICanBoogie\log('## \1 ## <pre>\2</pre>', __FUNCTION__, $text);
862 848
 
863
-		$text = preg_replace_callback
864
-		(
849
+		$text = preg_replace_callback(
865 850
 			'#\<\/[a-zA-Z]+\>#m', array($this, '_do_html_markup_close'), $text
866 851
 		);
867 852
 
@@ -882,14 +867,14 @@  discard block
 block discarded – undo
882 867
 	{
883 868
 		//		\ICanBoogie\log('<pre>in \1: \2</pre>', __FUNCTION__, $matches);
884 869
 
885
-		return $this->hashPart('<span class="string">' . \ICanBoogie\escape($matches[0]) . '</span>');
870
+		return $this->hashPart('<span class="string">'.\ICanBoogie\escape($matches[0]).'</span>');
886 871
 	}
887 872
 
888 873
 	function _do_html_attribute($matches)
889 874
 	{
890 875
 		//		\ICanBoogie\log('<pre>in \1: \2</pre>', __FUNCTION__, $matches);
891 876
 
892
-		return $this->hashPart('<span class="attribute">' . \ICanBoogie\escape($matches[0]) . '</span>');
877
+		return $this->hashPart('<span class="attribute">'.\ICanBoogie\escape($matches[0]).'</span>');
893 878
 	}
894 879
 
895 880
 	function _do_html_markup($matches)
@@ -902,8 +887,7 @@  discard block
 block discarded – undo
902 887
 		# strings
903 888
 		#
904 889
 
905
-		$text = preg_replace_callback
906
-		(
890
+		$text = preg_replace_callback(
907 891
 			'#\"[^\"]+\"#', array(&$this, '_do_html_string'), $text
908 892
 		);
909 893
 
@@ -913,14 +897,13 @@  discard block
 block discarded – undo
913 897
 		# attributes
914 898
 		#
915 899
 
916
-		$text = preg_replace_callback
917
-		(
900
+		$text = preg_replace_callback(
918 901
 			'#[^\s\=]+#', array(&$this, '_do_html_attribute'), $text
919 902
 		);
920 903
 
921
-		$rc = $this->hashPart('<span class="markup">' . \ICanBoogie\escape($matches[1]) . '</span>');
904
+		$rc = $this->hashPart('<span class="markup">'.\ICanBoogie\escape($matches[1]).'</span>');
922 905
 		$rc .= $text;
923
-		$rc .= $this->hashpart('<span class="markup">' . \ICanBoogie\escape($matches[3]) . '</span>');
906
+		$rc .= $this->hashpart('<span class="markup">'.\ICanBoogie\escape($matches[3]).'</span>');
924 907
 
925 908
 		return $rc;
926 909
 	}
@@ -929,7 +912,7 @@  discard block
 block discarded – undo
929 912
 	{
930 913
 		//		\ICanBoogie\log('<pre>in \1: \2</pre>', __FUNCTION__, $matches);
931 914
 
932
-		return $this->hashPart('<span class="markup">' . \ICanBoogie\escape($matches[0]) . '</span>');
915
+		return $this->hashPart('<span class="markup">'.\ICanBoogie\escape($matches[0]).'</span>');
933 916
 	}
934 917
 
935 918
 	#
@@ -948,7 +931,7 @@  discard block
 block discarded – undo
948 931
 		{
949 932
 			$in_quotes = NULL;
950 933
 
951
-			for ($i = 0 ; $i < strlen($line) ; $i++)
934
+			for ($i = 0; $i < strlen($line); $i++)
952 935
 			{
953 936
 				$c = $line{$i};
954 937
 
@@ -970,8 +953,8 @@  discard block
 block discarded – undo
970 953
 
971 954
 					$line =
972 955
 
973
-					substr($line, 0, $i) .
974
-					$this->hashPart('<code class="comment">' . \ICanBoogie\escape(substr($line, $i)) . '</code>');
956
+					substr($line, 0, $i).
957
+					$this->hashPart('<code class="comment">'.\ICanBoogie\escape(substr($line, $i)).'</code>');
975 958
 
976 959
 					break;
977 960
 				}
@@ -996,7 +979,7 @@  discard block
 block discarded – undo
996 979
 
997 980
 		$y = strlen($text);
998 981
 
999
-		for ($i = 0 ; $i < $y ; $i++)
982
+		for ($i = 0; $i < $y; $i++)
1000 983
 		{
1001 984
 			$c = $text{$i};
1002 985
 
@@ -1010,7 +993,7 @@  discard block
 block discarded – undo
1010 993
 				}
1011 994
 				else if ($quote_start !== null && $c == $quote)
1012 995
 				{
1013
-					$out .= $this->hashPart('<span class="string">' . \ICanBoogie\escape($quote . substr($text, $quote_start + 1, $i - $quote_start - 1) . $quote) . '</span>');
996
+					$out .= $this->hashPart('<span class="string">'.\ICanBoogie\escape($quote.substr($text, $quote_start + 1, $i - $quote_start - 1).$quote).'</span>');
1014 997
 
1015 998
 					$quote_start = null;
1016 999
 					$quote = null;
@@ -1055,8 +1038,7 @@  discard block
 block discarded – undo
1055 1038
 		# comment block
1056 1039
 		#
1057 1040
 
1058
-		$text = preg_replace_callback
1059
-		(
1041
+		$text = preg_replace_callback(
1060 1042
 			'#/\*.*?\*/#ms', array(&$this, '_do_php_comment'), $text
1061 1043
 		);
1062 1044
 
@@ -1066,8 +1048,7 @@  discard block
 block discarded – undo
1066 1048
 		# functions
1067 1049
 		#
1068 1050
 
1069
-		$text = preg_replace_callback
1070
-		(
1051
+		$text = preg_replace_callback(
1071 1052
 			'#(\$?[a-zA-z0-9_]+)\(#', array(&$this, '_do_php_function'), $text
1072 1053
 		);
1073 1054
 
@@ -1077,8 +1058,7 @@  discard block
 block discarded – undo
1077 1058
 
1078 1059
 		//		\ICanBoogie\log('## \1 ## <pre>\2</pre>', __FUNCTION__, \ICanBoogie\escape($text));
1079 1060
 
1080
-		$text = preg_replace_callback
1081
-		(
1061
+		$text = preg_replace_callback(
1082 1062
 			'#(\$|\-\>)([a-zA-z0-9_]+)(?!\x1A)#', array(&$this, '_do_php_variable'), $text
1083 1063
 		);
1084 1064
 
@@ -1086,13 +1066,11 @@  discard block
 block discarded – undo
1086 1066
 		# numbers
1087 1067
 		#
1088 1068
 
1089
-		$text = preg_replace_callback
1090
-		(
1069
+		$text = preg_replace_callback(
1091 1070
 			'#0x[0-9a-fA-F]{1,8}#u', array(&$this, '_do_php_number'), $text
1092 1071
 		);
1093 1072
 
1094
-		$text = preg_replace_callback
1095
-		(
1073
+		$text = preg_replace_callback(
1096 1074
 			'#(?<!\x1A)\d+(?![\w])#u', array(&$this, '_do_php_number'), $text
1097 1075
 		);
1098 1076
 
@@ -1100,8 +1078,7 @@  discard block
 block discarded – undo
1100 1078
 		# reserved keywords
1101 1079
 		#
1102 1080
 
1103
-		$reserved = array
1104
-		(
1081
+		$reserved = array(
1105 1082
 			'include_once',
1106 1083
 			'require_once',
1107 1084
 			'endswitch',
@@ -1148,9 +1125,8 @@  discard block
 block discarded – undo
1148 1125
 
1149 1126
 		foreach ($reserved as $k)
1150 1127
 		{
1151
-			$text = preg_replace_callback
1152
-			(
1153
-				'#' . $k . '#', array(&$this, '_do_php_reserved'), $text
1128
+			$text = preg_replace_callback(
1129
+				'#'.$k.'#', array(&$this, '_do_php_reserved'), $text
1154 1130
 			);
1155 1131
 		}
1156 1132
 
@@ -1158,8 +1134,7 @@  discard block
 block discarded – undo
1158 1134
 		# symbols
1159 1135
 		#
1160 1136
 
1161
-		$text = preg_replace_callback
1162
-		(
1137
+		$text = preg_replace_callback(
1163 1138
 			'#[\(\)\[\]\{\}\!\@\%\&\*\|\/\<\>\-\+\=]+#', array(&$this, '_do_php_symbol'), $text
1164 1139
 		);
1165 1140
 
@@ -1176,8 +1151,8 @@  discard block
 block discarded – undo
1176 1151
 
1177 1152
 		$text =
1178 1153
 
1179
-			'<span class="delimiter">' .
1180
-			"&lt;?php</span>\n\n" .
1154
+			'<span class="delimiter">'.
1155
+			"&lt;?php</span>\n\n".
1181 1156
 
1182 1157
 		$text;
1183 1158
 
@@ -1221,10 +1196,9 @@  discard block
 block discarded – undo
1221 1196
 
1222 1197
 		//		\ICanBoogie\log('## \1 ## \2', __FUNCTION__, $matches);
1223 1198
 
1224
-		return $this->hashPart
1225
-		(
1226
-			'<span class="comment">' .
1227
-		$this->_do_codeentities($matches[0]) .
1199
+		return $this->hashPart(
1200
+			'<span class="comment">'.
1201
+		$this->_do_codeentities($matches[0]).
1228 1202
 			'</span>'
1229 1203
 		);
1230 1204
 	}
@@ -1235,24 +1209,24 @@  discard block
 block discarded – undo
1235 1209
 
1236 1210
 		if ($matches[1] == '->')
1237 1211
 		{
1238
-			return '->' . $this->hashPart('<span class="variable">' . $matches[2] . '</span>');
1212
+			return '->'.$this->hashPart('<span class="variable">'.$matches[2].'</span>');
1239 1213
 		}
1240 1214
 
1241
-		return $this->hashPart('<span class="variable">' . $matches[0] . '</span>');
1215
+		return $this->hashPart('<span class="variable">'.$matches[0].'</span>');
1242 1216
 	}
1243 1217
 
1244 1218
 	function _do_php_reserved($matches)
1245 1219
 	{
1246 1220
 		//		\ICanBoogie\log('## \1 ## \2', __FUNCTION__, $matches);
1247 1221
 
1248
-		return $this->hashPart('<span class="reserved">' . $matches[0] . '</span>');
1222
+		return $this->hashPart('<span class="reserved">'.$matches[0].'</span>');
1249 1223
 	}
1250 1224
 
1251 1225
 	function _do_php_function_def($matches)
1252 1226
 	{
1253 1227
 		//		\ICanBoogie\log('## \1 ## \2', __FUNCTION__, $matches);
1254 1228
 
1255
-		return $this->hashPart('<span class="function">function</span>' . $matches[1]);
1229
+		return $this->hashPart('<span class="function">function</span>'.$matches[1]);
1256 1230
 		//		return $this->hashPart('<span class="function">' . $matches[1] . '</span>(', 'F');
1257 1231
 	}
1258 1232
 
@@ -1265,19 +1239,19 @@  discard block
 block discarded – undo
1265 1239
 			return $matches[0];
1266 1240
 		}
1267 1241
 
1268
-		return $this->hashPart('<span class="function">' . $matches[1] . '</span>', 'F'). '(';
1242
+		return $this->hashPart('<span class="function">'.$matches[1].'</span>', 'F').'(';
1269 1243
 	}
1270 1244
 
1271 1245
 	function _do_php_symbol($matches)
1272 1246
 	{
1273
-		return $this->hashPart('<span class="symbol">' . \ICanBoogie\escape($matches[0]) . '</span>');
1247
+		return $this->hashPart('<span class="symbol">'.\ICanBoogie\escape($matches[0]).'</span>');
1274 1248
 	}
1275 1249
 
1276 1250
 	function _do_php_number($matches)
1277 1251
 	{
1278 1252
 		//		\ICanBoogie\log('## \1 ## \2', __FUNCTION__, $matches);
1279 1253
 
1280
-		return $this->hashPart('<span class="number">' . $matches[0] . '</span>');
1254
+		return $this->hashPart('<span class="number">'.$matches[0].'</span>');
1281 1255
 	}
1282 1256
 
1283 1257
 	/*
@@ -1291,10 +1265,10 @@  discard block
 block discarded – undo
1291 1265
 
1292 1266
 	function _doAnchors_inline_callback($matches)
1293 1267
 	{
1294
-		$whole_match	=  $matches[1];
1295
-		$link_text		=  $this->runSpanGamut($matches[2]);
1296
-		$url			=  $matches[3] == '' ? $matches[4] : $matches[3];
1297
-		$title			=& $matches[7];
1268
+		$whole_match = $matches[1];
1269
+		$link_text = $this->runSpanGamut($matches[2]);
1270
+		$url = $matches[3] == '' ? $matches[4] : $matches[3];
1271
+		$title = & $matches[7];
1298 1272
 
1299 1273
 		$url = $this->encodeAmpsAndAngles($url);
1300 1274
 
@@ -1302,7 +1276,7 @@  discard block
 block discarded – undo
1302 1276
 		if (isset($title)) {
1303 1277
 			$title = str_replace('"', '&quot;', $title);
1304 1278
 			$title = $this->encodeAmpsAndAngles($title);
1305
-			$result .=  " title=\"$title\"";
1279
+			$result .= " title=\"$title\"";
1306 1280
 		}
1307 1281
 
1308 1282
 		if (substr($url, 0, 7) == 'http://')
Please login to merge, or discard this patch.
lib/Evaluator.php 3 patches
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -113,8 +113,7 @@  discard block
 block discarded – undo
113 113
 					{
114 114
 						continue;
115 115
 					}
116
-				}
117
-				else if (!$quote)
116
+				} else if (!$quote)
118 117
 				{
119 118
 					$quote = $c;
120 119
 
@@ -211,12 +210,10 @@  discard block
 block discarded – undo
211 210
 								if (is_numeric($part))
212 211
 								{
213 212
 									$part = (int) $part;
214
-								}
215
-								else if (is_float($part))
213
+								} else if (is_float($part))
216 214
 								{
217 215
 									$part = (float) $part;
218
-								}
219
-								else
216
+								} else
220 217
 								{
221 218
 									$part = constant($part);
222 219
 								}
@@ -359,19 +356,16 @@  discard block
 block discarded – undo
359 356
 							if (function_exists('str' . $method))
360 357
 							{
361 358
 								$callback = 'str' . $method;
362
-							}
363
-							else if (function_exists('str_' . $method))
359
+							} else if (function_exists('str_' . $method))
364 360
 							{
365 361
 								$callback = 'str_' . $method;
366 362
 							}
367
-						}
368
-						else if (is_array($context) || is_object($context))
363
+						} else if (is_array($context) || is_object($context))
369 364
 						{
370 365
 							if (function_exists('ICanBoogie\array_' . $method))
371 366
 							{
372 367
 								$callback = 'ICanBoogie\array_' . $method;
373
-							}
374
-							else if (function_exists('array_' . $method))
368
+							} else if (function_exists('array_' . $method))
375 369
 							{
376 370
 								$callback = 'array_' . $method;
377 371
 							}
@@ -425,13 +419,11 @@  discard block
 block discarded – undo
425 419
 						if ($callback == 'array_shift')
426 420
 						{
427 421
 							$context = array_shift($context);
428
-						}
429
-						else
422
+						} else
430 423
 						{
431 424
 							$context = call_user_func_array($callback, $args);
432 425
 						}
433
-					}
434
-					else
426
+					} else
435 427
 					{
436 428
 						$context = call_user_func_array($callback, $args);
437 429
 					}
Please login to merge, or discard this patch.
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -264,6 +264,10 @@
 block discarded – undo
264 264
 		return $parts;
265 265
 	}
266 266
 
267
+	/**
268
+	 * @param string $expression
269
+	 * @param boolean $silent
270
+	 */
267 271
 	protected function evaluate($context, $expression, $tokens, $silent)
268 272
 	{
269 273
 		$expression_path = [];
Please login to merge, or discard this patch.
Spacing   +15 added lines, -16 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	{
66 66
 		if ($str{0} == '@')
67 67
 		{
68
-			$str = 'this.' . substr($str, 1);
68
+			$str = 'this.'.substr($str, 1);
69 69
 		}
70 70
 
71 71
 		$str .= '.';
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 		$parts = [];
86 86
 
87
-		for ($i = 0 ; $i < $length ; $i++)
87
+		for ($i = 0; $i < $length; $i++)
88 88
 		{
89 89
 			$c = $str{$i};
90 90
 
@@ -280,8 +280,7 @@  discard block
 block discarded – undo
280 280
 				{
281 281
 					if (!is_array($context) && !is_object($context))
282 282
 					{
283
-						throw new \InvalidArgumentException(\ICanBoogie\format
284
-						(
283
+						throw new \InvalidArgumentException(\ICanBoogie\format(
285 284
 							'Unexpected variable type: %type (%value) for %identifier in expression %expression, should be either an array or an object', [
286 285
 
287 286
 								'%type' => gettype($context),
@@ -325,7 +324,7 @@  discard block
 block discarded – undo
325 324
 
326 325
 					if ($args_evaluate)
327 326
 					{
328
-						$this->engine->error('we should evaluate %eval', [ '%eval' => $args_evaluate ]);
327
+						$this->engine->error('we should evaluate %eval', ['%eval' => $args_evaluate]);
329 328
 					}
330 329
 
331 330
 					#
@@ -334,7 +333,7 @@  discard block
 block discarded – undo
334 333
 
335 334
 					if (is_object($context) && method_exists($context, $method))
336 335
 					{
337
-						$context = call_user_func_array([ $context, $method ], $args);
336
+						$context = call_user_func_array([$context, $method], $args);
338 337
 
339 338
 						break;
340 339
 					}
@@ -355,24 +354,24 @@  discard block
 block discarded – undo
355 354
 					{
356 355
 						if (is_string($context))
357 356
 						{
358
-							if (function_exists('str' . $method))
357
+							if (function_exists('str'.$method))
359 358
 							{
360
-								$callback = 'str' . $method;
359
+								$callback = 'str'.$method;
361 360
 							}
362
-							else if (function_exists('str_' . $method))
361
+							else if (function_exists('str_'.$method))
363 362
 							{
364
-								$callback = 'str_' . $method;
363
+								$callback = 'str_'.$method;
365 364
 							}
366 365
 						}
367 366
 						else if (is_array($context) || is_object($context))
368 367
 						{
369
-							if (function_exists('ICanBoogie\array_' . $method))
368
+							if (function_exists('ICanBoogie\array_'.$method))
370 369
 							{
371
-								$callback = 'ICanBoogie\array_' . $method;
370
+								$callback = 'ICanBoogie\array_'.$method;
372 371
 							}
373
-							else if (function_exists('array_' . $method))
372
+							else if (function_exists('array_'.$method))
374 373
 							{
375
-								$callback = 'array_' . $method;
374
+								$callback = 'array_'.$method;
376 375
 							}
377 376
 						}
378 377
 					}
@@ -393,7 +392,7 @@  discard block
 block discarded – undo
393 392
 					{
394 393
 						if (is_object($context) && method_exists($context, '__call'))
395 394
 						{
396
-							$context = call_user_func_array([ $context, $method ], $args);
395
+							$context = call_user_func_array([$context, $method], $args);
397 396
 
398 397
 							break;
399 398
 						}
@@ -460,7 +459,7 @@  discard block
 block discarded – undo
460 459
 	 *
461 460
 	 * @return mixed The extracted value.
462 461
 	 */
463
-	protected function extract_value($container, $identifier, &$exists=false)
462
+	protected function extract_value($container, $identifier, &$exists = false)
464 463
 	{
465 464
 		$exists = false;
466 465
 
Please login to merge, or discard this patch.
lib/HTMLParser.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -170,8 +170,7 @@  discard block
 block discarded – undo
170 170
 						#
171 171
 
172 172
 						$nodes[] = $this->parseMarkup(substr($value, 0, -1));
173
-					}
174
-					else if ($closing)
173
+					} else if ($closing)
175 174
 					{
176 175
 						#
177 176
 						# closing markup
@@ -185,8 +184,7 @@  discard block
 block discarded – undo
185 184
 						}
186 185
 
187 186
 						return $nodes;
188
-					}
189
-					else
187
+					} else
190 188
 					{
191 189
 						#
192 190
 						# this is an open markup with possible children
Please login to merge, or discard this patch.
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -38,6 +38,9 @@  discard block
 block discarded – undo
38 38
 		$this->error_handler = $tags[self::T_ERROR_HANDLER];
39 39
 	}
40 40
 
41
+	/**
42
+	 * @param string $html
43
+	 */
41 44
 	public function parse($html, $namespace=null, $encoding='utf-8')
42 45
 	{
43 46
 		$this->encoding = $encoding;
@@ -87,6 +90,9 @@  discard block
 block discarded – undo
87 90
 		return $tree;
88 91
 	}
89 92
 
93
+	/**
94
+	 * @return string
95
+	 */
90 96
 	protected function escapeSpecials($html)
91 97
 	{
92 98
 		#
Please login to merge, or discard this patch.
Spacing   +15 added lines, -19 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	protected $error_handler;
24 24
 	protected $namespace;
25 25
 
26
-	public function __construct(array $tags=[])
26
+	public function __construct(array $tags = [])
27 27
 	{
28 28
 		$tags += [
29 29
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		$this->error_handler = $tags[self::T_ERROR_HANDLER];
39 39
 	}
40 40
 
41
-	public function parse($html, $namespace=null, $encoding='utf-8')
41
+	public function parse($html, $namespace = null, $encoding = 'utf-8')
42 42
 	{
43 43
 		$this->encoding = $encoding;
44 44
 		$this->namespace = $namespace;
@@ -63,9 +63,8 @@  discard block
 block discarded – undo
63 63
 		# note that i+2 might end with a '/' indicating an auto-closing markup
64 64
 		#
65 65
 
66
-		$this->matches = preg_split
67
-		(
68
-			'#<(/?)' . $namespace . '([^>]*)>#', $html, -1, PREG_SPLIT_DELIM_CAPTURE
66
+		$this->matches = preg_split(
67
+			'#<(/?)'.$namespace.'([^>]*)>#', $html, -1, PREG_SPLIT_DELIM_CAPTURE
69 68
 		);
70 69
 
71 70
 		#
@@ -93,13 +92,13 @@  discard block
 block discarded – undo
93 92
 		# here we escape comments
94 93
 		#
95 94
 
96
-		$html = preg_replace_callback('#<\!--.+-->#sU', [ $this, 'escapeSpecials_callback' ], $html);
95
+		$html = preg_replace_callback('#<\!--.+-->#sU', [$this, 'escapeSpecials_callback'], $html);
97 96
 
98 97
 		#
99 98
 		# and processing options
100 99
 		#
101 100
 
102
-		$html = preg_replace_callback('#<\?.+\?>#sU', [ $this, 'escapeSpecials_callback' ], $html);
101
+		$html = preg_replace_callback('#<\?.+\?>#sU', [$this, 'escapeSpecials_callback'], $html);
103 102
 
104 103
 		return $html;
105 104
 	}
@@ -110,10 +109,9 @@  discard block
 block discarded – undo
110 109
 
111 110
 		$text = $m[0];
112 111
 
113
-		$text = str_replace
114
-		(
115
-			[ '<', '>' ],
116
-			[ "\x01", "\x02" ],
112
+		$text = str_replace(
113
+			['<', '>'],
114
+			["\x01", "\x02"],
117 115
 			$text
118 116
 		);
119 117
 
@@ -122,10 +120,9 @@  discard block
 block discarded – undo
122 120
 
123 121
 	protected function unescapeSpecials($tree)
124 122
 	{
125
-		return is_array($tree) ? array_map([ $this, 'unescapeSpecials' ], $tree) : str_replace
126
-		(
127
-			[ "\x01", "\x02" ],
128
-			[ '<', '>' ],
123
+		return is_array($tree) ? array_map([$this, 'unescapeSpecials'], $tree) : str_replace(
124
+			["\x01", "\x02"],
125
+			['<', '>'],
129 126
 			$tree
130 127
 		);
131 128
 	}
@@ -246,20 +243,19 @@  discard block
 block discarded – undo
246 243
 			$args[$m[1]] = html_entity_decode($m[2], ENT_QUOTES, $this->encoding);
247 244
 		}
248 245
 
249
-		return [ 'name' => $name, 'args' => $args ];
246
+		return ['name' => $name, 'args' => $args];
250 247
 	}
251 248
 
252 249
 	protected function error($markup, $expected)
253 250
 	{
254 251
 		$this->malformed = true;
255 252
 
256
-		call_user_func
257
-		(
253
+		call_user_func(
258 254
 			$this->error_handler, $expected
259 255
 			? 'unexpected closing markup %markup, should be %expected'
260 256
 			: 'unexpected closing markup %markup, when none was opened', [
261 257
 
262
-				'%markup' => $this->namespace . $markup, '%expected' => $expected
258
+				'%markup' => $this->namespace.$markup, '%expected' => $expected
263 259
 
264 260
 			]
265 261
 		);
Please login to merge, or discard this patch.
lib/Engine.php 3 patches
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -134,12 +134,10 @@  discard block
 block discarded – undo
134 134
 			$this->errors[] = '<div class="alert alert-error alert-danger">' . $alert->getMessage() . '</div>';
135 135
 
136 136
 			return;
137
-		}
138
-		else if ($alert instanceof \Exception)
137
+		} else if ($alert instanceof \Exception)
139 138
 		{
140 139
 			$alert = class_exists('ICanBoogie\Debug') ? Debug::format_alert($alert) : (string) $alert;
141
-		}
142
-		else
140
+		} else
143 141
 		{
144 142
 			$alert = \ICanBoogie\format($alert, $args);
145 143
 		}
@@ -189,8 +187,7 @@  discard block
 block discarded – undo
189 187
 		if ($e instanceof \ICanBoogie\HTTP\Exception)
190 188
 		{
191 189
 			throw $e;
192
-		}
193
-		else if ($e instanceof \ICanBoogie\ActiveRecord\Exception)
190
+		} else if ($e instanceof \ICanBoogie\ActiveRecord\Exception)
194 191
 		{
195 192
 			throw $e;
196 193
 		}
@@ -267,8 +264,7 @@  discard block
 block discarded – undo
267 264
 			if ($template_resolver instanceof Render\BasicTemplateResolver)
268 265
 			{
269 266
 				$basic_template_resolver = $template_resolver;
270
-			}
271
-			else if ($template_resolver instanceof Render\TemplateResolverDecorator)
267
+			} else if ($template_resolver instanceof Render\TemplateResolverDecorator)
272 268
 			{
273 269
 				$basic_template_resolver = $template_resolver->find_renderer(Render\BasicTemplateResolver::class);
274 270
 			}
@@ -470,14 +466,12 @@  discard block
 block discarded – undo
470 466
 			try
471 467
 			{
472 468
 				$rc .= $node($this, $this->context);
473
-			}
474
-			catch (\Exception $e)
469
+			} catch (\Exception $e)
475 470
 			{
476 471
 				if (class_exists('ICanBoogie\Debug'))
477 472
 				{
478 473
 					$rc .= Debug::format_alert($e);
479
-				}
480
-				else
474
+				} else
481 475
 				{
482 476
 					$rc .= $e;
483 477
 				}
Please login to merge, or discard this patch.
Doc Comments   +13 added lines, -1 removed lines patch added patch discarded remove patch
@@ -115,6 +115,9 @@  discard block
 block discarded – undo
115 115
 	protected $trace = [];
116 116
 	protected $errors = [];
117 117
 
118
+	/**
119
+	 * @param string[] $a
120
+	 */
118 121
 	public function trace_enter($a)
119 122
 	{
120 123
 		array_unshift($this->trace, $a);
@@ -205,6 +208,9 @@  discard block
 block discarded – undo
205 208
 		return $rc;
206 209
 	}
207 210
 
211
+	/**
212
+	 * @return string
213
+	 */
208 214
 	public function get_file()
209 215
 	{
210 216
 		foreach ($this->trace as $trace)
@@ -233,6 +239,9 @@  discard block
 block discarded – undo
233 239
 
234 240
 	protected $templates = [];
235 241
 
242
+	/**
243
+	 * @param string $name
244
+	 */
236 245
 	public function addTemplate($name, $template)
237 246
 	{
238 247
 		if (isset($this->templates[$name]))
@@ -317,7 +326,7 @@  discard block
 block discarded – undo
317 326
 	/**
318 327
 	 * Calls a template.
319 328
 	 *
320
-	 * @param $name
329
+	 * @param string $name
321 330
 	 * @param array $args
322 331
 	 *
323 332
 	 * @return string
@@ -376,6 +385,9 @@  discard block
 block discarded – undo
376 385
 	**
377 386
 	*/
378 387
 
388
+	/**
389
+	 * @return Node[]
390
+	 */
379 391
 	protected function get_compiled($template)
380 392
 	{
381 393
 		static $compiler;
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param string $expression
88 88
 	 * @param bool $silent
89 89
 	 */
90
-	public function evaluate($expression, $silent=false, $context=null)
90
+	public function evaluate($expression, $silent = false, $context = null)
91 91
 	{
92 92
 		$evaluator = $this->evaluator;
93 93
 
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 		array_shift($this->trace);
126 126
 	}
127 127
 
128
-	public function error($alert, array $args=[])
128
+	public function error($alert, array $args = [])
129 129
 	{
130 130
 		if ($alert instanceof \ICanBoogie\Exception\Config)
131 131
 		{
132
-			$this->errors[] = '<div class="alert alert-danger">' . $alert->getMessage() . '</div>';
132
+			$this->errors[] = '<div class="alert alert-danger">'.$alert->getMessage().'</div>';
133 133
 
134 134
 			return;
135 135
 		}
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
 					}
167 167
 				}
168 168
 
169
-				$trace_html .= sprintf('#%02d: in %s "%s"', $i--, $which, $message) . '<br />';
169
+				$trace_html .= sprintf('#%02d: in %s "%s"', $i--, $which, $message).'<br />';
170 170
 			}
171 171
 
172 172
 			if ($trace_html)
173 173
 			{
174
-				$trace_html = '<pre>' . $trace_html . '</pre>';
174
+				$trace_html = '<pre>'.$trace_html.'</pre>';
175 175
 			}
176 176
 		}
177 177
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		#
180 180
 		#
181 181
 
182
-		$this->errors[] = '<div class="alert alert-danger">' . $alert . $trace_html . '</div>';
182
+		$this->errors[] = '<div class="alert alert-danger">'.$alert.$trace_html.'</div>';
183 183
 	}
184 184
 
185 185
 	public function handle_exception(\Exception $e)
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		}
279 279
 
280 280
 		$tries = [];
281
-		$template_pathname = $template_resolver->resolve($name, [ '.patron', '.html' ], $tries);
281
+		$template_pathname = $template_resolver->resolve($name, ['.patron', '.html'], $tries);
282 282
 
283 283
 		if ($template_pathname)
284 284
 		{
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		}
287 287
 
288 288
 		$template_name = TemplateName::from($name);
289
-		$template_pathname = $template_resolver->resolve($template_name->as_partial, [ '.patron', '.html' ], $tries);
289
+		$template_pathname = $template_resolver->resolve($template_name->as_partial, ['.patron', '.html'], $tries);
290 290
 
291 291
 		if ($template_pathname)
292 292
 		{
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 		$content = file_get_contents($pathname);
302 302
 		$nodes = $this->get_compiled($content);
303 303
 
304
-		return new Template($nodes, [ 'file' => $pathname ]);
304
+		return new Template($nodes, ['file' => $pathname]);
305 305
 	}
306 306
 
307 307
 	protected function get_template($name)
@@ -322,14 +322,14 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @return string
324 324
 	 */
325
-	public function callTemplate($name, array $args=[])
325
+	public function callTemplate($name, array $args = [])
326 326
 	{
327 327
 		$template = $this->get_template($name);
328 328
 
329 329
 		if (!$template)
330 330
 		{
331 331
 			$er = 'Unknown template %name';
332
-			$params = [ '%name' => $name ];
332
+			$params = ['%name' => $name];
333 333
 
334 334
 			if ($this->templates)
335 335
 			{
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 			return null;
343 343
 		}
344 344
 
345
-		$this->trace_enter([ 'template', $name, $template ]);
345
+		$this->trace_enter(['template', $name, $template]);
346 346
 
347 347
 		$this->context['self']['arguments'] = $args;
348 348
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 
366 366
 	protected function init_context()
367 367
 	{
368
-		$this->context = new \BlueTihi\Context([ 'self' => null, 'this' => null ]);
368
+		$this->context = new \BlueTihi\Context(['self' => null, 'this' => null]);
369 369
 	}
370 370
 
371 371
 	/*
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 		return $compiler($template);
389 389
 	}
390 390
 
391
-	public function __invoke($template, $bind=null, array $options=[])
391
+	public function __invoke($template, $bind = null, array $options = [])
392 392
 	{
393 393
 		if (!$template)
394 394
 		{
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
 				$template = $this->get_compiled($template);
449 449
 			}
450 450
 
451
-			$template = new Template($template, [ 'file' => $file ]);
451
+			$template = new Template($template, ['file' => $file]);
452 452
 		}
453 453
 
454 454
 		if ($template->file)
455 455
 		{
456
-			$this->trace_enter([ 'file', $template->file ]);
456
+			$this->trace_enter(['file', $template->file]);
457 457
 		}
458 458
 
459 459
 		$rc = '';
Please login to merge, or discard this patch.
lib/ControlNode.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -136,11 +136,11 @@
 block discarded – undo
136 136
 		# call hook
137 137
 		#
138 138
 
139
-		$engine->trace_enter([ 'markup', $name ]);
139
+		$engine->trace_enter(['markup', $name]);
140 140
 
141 141
 		if ($binding)
142 142
 		{
143
-			array_push($engine->context_markup, [ $engine->context['self'], $engine->context['this'] ]);
143
+			array_push($engine->context_markup, [$engine->context['self'], $engine->context['this']]);
144 144
 
145 145
 			$engine->context['self'] = [
146 146
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -74,19 +74,16 @@  discard block
 block discarded – undo
74 74
 						if ($value{0} == ':')
75 75
 						{
76 76
 							$args[$param] = substr($value, 1);
77
-						}
78
-						else
77
+						} else
79 78
 						{
80 79
 							$args[$param] = $engine->evaluate($value, $silent, $context);
81 80
 						}
82 81
 					}
83
-				}
84
-				else if (isset($options['required']))
82
+				} else if (isset($options['required']))
85 83
 				{
86 84
 					$missing[$param] = true;
87 85
 				}
88
-			}
89
-			else
86
+			} else
90 87
 			{
91 88
 				if (!array_key_exists($param, $args))
92 89
 				{
@@ -122,8 +119,7 @@  discard block
 block discarded – undo
122 119
 				if (isset($arg->args['select']))
123 120
 				{
124 121
 					$arg = $engine->evaluate($arg->args['select'], false, $context);
125
-				}
126
-				else
122
+				} else
127 123
 				{
128 124
 					$arg = $engine($arg->nodes);
129 125
 				}
@@ -155,8 +151,7 @@  discard block
 block discarded – undo
155 151
 		try
156 152
 		{
157 153
 			$rc = call_user_func($callback, $args, $engine, $this->nodes);
158
-		}
159
-		catch (\Exception $e)
154
+		} catch (\Exception $e)
160 155
 		{
161 156
 			$engine->handle_exception($e);
162 157
 		}
Please login to merge, or discard this patch.
lib/Compiler.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -47,8 +47,7 @@  discard block
 block discarded – undo
47 47
 				}
48 48
 
49 49
 				$nodes[] = new ControlNode($node['name'], $node['args'], $children);
50
-			}
51
-			else
50
+			} else
52 51
 			{
53 52
 				#
54 53
 				# we don't resolve comments, unless they are Internet Explorer comments e.g. <!--[
@@ -61,8 +60,7 @@  discard block
 block discarded – undo
61 60
 					$children = $this->parse_html_node($node);
62 61
 
63 62
 					$nodes = array_merge($nodes, $children);
64
-				}
65
-				else
63
+				} else
66 64
 				{
67 65
 					#
68 66
 					# The comments, which are on odd position, are kept intact. The text, which is
@@ -74,8 +72,7 @@  discard block
 block discarded – undo
74 72
 						if ($i % 2)
75 73
 						{
76 74
 							$nodes[] = new TextNode($part);
77
-						}
78
-						else
75
+						} else
79 76
 						{
80 77
 							$children = $this->parse_html_node($part);
81 78
 
@@ -99,8 +96,7 @@  discard block
 block discarded – undo
99 96
 			if ($i % 2)
100 97
 			{
101 98
 				$nodes[] = $this->parse_expression($part);
102
-			}
103
-			else
99
+			} else
104 100
 			{
105 101
 				$nodes[] = new TextNode($part);
106 102
 			}
Please login to merge, or discard this patch.