Completed
Push — master ( cde0c6...d99bf9 )
by Stephen
15:46
created
src/wp-includes/SimplePie/Net/IPv6.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -190,7 +190,7 @@
 block discarded – undo
190 190
 	 *           0:0:0:0:0:FFFF:129.144.52.38
191 191
 	 *
192 192
 	 * @param string $ip An IPv6 address
193
-	 * @return array [0] contains the IPv6 represented part, and [1] the IPv4 represented part
193
+	 * @return string[] [0] contains the IPv6 represented part, and [1] the IPv4 represented part
194 194
 	 */
195 195
 	private static function split_v6_v4($ip)
196 196
 	{
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@
 block discarded – undo
123 123
 			// xxx::xxx
124 124
 			else
125 125
 			{
126
-				$fill = ':' . str_repeat('0:', 6 - $c2 - $c1);
126
+				$fill = ':'.str_repeat('0:', 6 - $c2 - $c1);
127 127
 				$ip = str_replace('::', $fill, $ip);
128 128
 			}
129 129
 		}
Please login to merge, or discard this patch.
Braces   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -86,16 +86,14 @@  discard block
 block discarded – undo
86 86
 			if ($ip1 === '')
87 87
 			{
88 88
 				$c1 = -1;
89
-			}
90
-			else
89
+			} else
91 90
 			{
92 91
 				$c1 = substr_count($ip1, ':');
93 92
 			}
94 93
 			if ($ip2 === '')
95 94
 			{
96 95
 				$c2 = -1;
97
-			}
98
-			else
96
+			} else
99 97
 			{
100 98
 				$c2 = substr_count($ip2, ':');
101 99
 			}
@@ -173,8 +171,7 @@  discard block
 block discarded – undo
173 171
 		if ($ip_parts[1] !== '')
174 172
 		{
175 173
 			return implode(':', $ip_parts);
176
-		}
177
-		else
174
+		} else
178 175
 		{
179 176
 			return $ip_parts[0];
180 177
 		}
@@ -200,8 +197,7 @@  discard block
 block discarded – undo
200 197
 			$ipv6_part = substr($ip, 0, $pos);
201 198
 			$ipv4_part = substr($ip, $pos + 1);
202 199
 			return array($ipv6_part, $ipv4_part);
203
-		}
204
-		else
200
+		} else
205 201
 		{
206 202
 			return array($ip, '');
207 203
 		}
@@ -226,35 +222,39 @@  discard block
 block discarded – undo
226 222
 			foreach ($ipv6 as $ipv6_part)
227 223
 			{
228 224
 				// The section can't be empty
229
-				if ($ipv6_part === '')
230
-					return false;
225
+				if ($ipv6_part === '') {
226
+									return false;
227
+				}
231 228
 
232 229
 				// Nor can it be over four characters
233
-				if (strlen($ipv6_part) > 4)
234
-					return false;
230
+				if (strlen($ipv6_part) > 4) {
231
+									return false;
232
+				}
235 233
 
236 234
 				// Remove leading zeros (this is safe because of the above)
237 235
 				$ipv6_part = ltrim($ipv6_part, '0');
238
-				if ($ipv6_part === '')
239
-					$ipv6_part = '0';
236
+				if ($ipv6_part === '') {
237
+									$ipv6_part = '0';
238
+				}
240 239
 
241 240
 				// Check the value is valid
242 241
 				$value = hexdec($ipv6_part);
243
-				if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF)
244
-					return false;
242
+				if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) {
243
+									return false;
244
+				}
245 245
 			}
246 246
 			if (count($ipv4) === 4)
247 247
 			{
248 248
 				foreach ($ipv4 as $ipv4_part)
249 249
 				{
250 250
 					$value = (int) $ipv4_part;
251
-					if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF)
252
-						return false;
251
+					if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) {
252
+											return false;
253
+					}
253 254
 				}
254 255
 			}
255 256
 			return true;
256
-		}
257
-		else
257
+		} else
258 258
 		{
259 259
 			return false;
260 260
 		}
Please login to merge, or discard this patch.
src/wp-includes/SimplePie/Parse/Date.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -704,7 +704,6 @@
 block discarded – undo
704 704
 	 * Remove RFC822 comments
705 705
 	 *
706 706
 	 * @access protected
707
-	 * @param string $data Data to strip comments from
708 707
 	 * @return string Comment stripped string
709 708
 	 */
710 709
 	public function remove_rfc2822_comments($string)
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -541,11 +541,11 @@  discard block
 block discarded – undo
541 541
 	 */
542 542
 	public function __construct()
543 543
 	{
544
-		$this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')';
545
-		$this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')';
544
+		$this->day_pcre = '('.implode(array_keys($this->day), '|').')';
545
+		$this->month_pcre = '('.implode(array_keys($this->month), '|').')';
546 546
 
547 547
 		static $cache;
548
-		if (!isset($cache[get_class($this)]))
548
+		if ( ! isset($cache[get_class($this)]))
549 549
 		{
550 550
 			$all_methods = get_class_methods($this);
551 551
 
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 	public static function get()
573 573
 	{
574 574
 		static $object;
575
-		if (!$object)
575
+		if ( ! $object)
576 576
 		{
577 577
 			$object = new SimplePie_Parse_Date;
578 578
 		}
@@ -638,13 +638,13 @@  discard block
 block discarded – undo
638 638
 	public function date_w3cdtf($date)
639 639
 	{
640 640
 		static $pcre;
641
-		if (!$pcre)
641
+		if ( ! $pcre)
642 642
 		{
643 643
 			$year = '([0-9]{4})';
644 644
 			$month = $day = $hour = $minute = $second = '([0-9]{2})';
645 645
 			$decimal = '([0-9]*)';
646 646
 			$zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))';
647
-			$pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/';
647
+			$pcre = '/^'.$year.'(?:-?'.$month.'(?:-?'.$day.'(?:[Tt\x09\x20]+'.$hour.'(?::?'.$minute.'(?::?'.$second.'(?:.'.$decimal.')?)?)?'.$zone.')?)?)?$/';
648 648
 		}
649 649
 		if (preg_match($pcre, $date, $match))
650 650
 		{
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
 	public function date_rfc2822($date)
771 771
 	{
772 772
 		static $pcre;
773
-		if (!$pcre)
773
+		if ( ! $pcre)
774 774
 		{
775 775
 			$wsp = '[\x09\x20]';
776
-			$fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp . '+)+)';
777
-			$optional_fws = $fws . '?';
776
+			$fws = '(?:'.$wsp.'+|'.$wsp.'*(?:\x0D\x0A'.$wsp.'+)+)';
777
+			$optional_fws = $fws.'?';
778 778
 			$day_name = $this->day_pcre;
779 779
 			$month = $this->month_pcre;
780 780
 			$day = '([0-9]{1,2})';
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
 			$year = '([0-9]{2,4})';
783 783
 			$num_zone = '([+\-])([0-9]{2})([0-9]{2})';
784 784
 			$character_zone = '([A-Z]{1,5})';
785
-			$zone = '(?:' . $num_zone . '|' . $character_zone . ')';
786
-			$pcre = '/(?:' . $optional_fws . $day_name . $optional_fws . ',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws . ':' . $optional_fws . $minute . '(?:' . $optional_fws . ':' . $optional_fws . $second . ')?' . $fws . $zone . '/i';
785
+			$zone = '(?:'.$num_zone.'|'.$character_zone.')';
786
+			$pcre = '/(?:'.$optional_fws.$day_name.$optional_fws.',)?'.$optional_fws.$day.$fws.$month.$fws.$year.$fws.$hour.$optional_fws.':'.$optional_fws.$minute.'(?:'.$optional_fws.':'.$optional_fws.$second.')?'.$fws.$zone.'/i';
787 787
 		}
788 788
 		if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match))
789 789
 		{
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 	public function date_rfc850($date)
864 864
 	{
865 865
 		static $pcre;
866
-		if (!$pcre)
866
+		if ( ! $pcre)
867 867
 		{
868 868
 			$space = '[\x09\x20]+';
869 869
 			$day_name = $this->day_pcre;
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 			$day = '([0-9]{1,2})';
872 872
 			$year = $hour = $minute = $second = '([0-9]{2})';
873 873
 			$zone = '([A-Z]{1,5})';
874
-			$pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i';
874
+			$pcre = '/^'.$day_name.','.$space.$day.'-'.$month.'-'.$year.$space.$hour.':'.$minute.':'.$second.$space.$zone.'$/i';
875 875
 		}
876 876
 		if (preg_match($pcre, $date, $match))
877 877
 		{
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	public function date_asctime($date)
929 929
 	{
930 930
 		static $pcre;
931
-		if (!$pcre)
931
+		if ( ! $pcre)
932 932
 		{
933 933
 			$space = '[\x09\x20]+';
934 934
 			$wday_name = $this->day_pcre;
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 			$hour = $sec = $min = '([0-9]{2})';
938 938
 			$year = '([0-9]{4})';
939 939
 			$terminator = '\x0A?\x00?';
940
-			$pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i';
940
+			$pcre = '/^'.$wday_name.$space.$mon_name.$space.$day.$space.$hour.':'.$min.':'.$sec.$space.$year.$terminator.'$/i';
941 941
 		}
942 942
 		if (preg_match($pcre, $date, $match))
943 943
 		{
Please login to merge, or discard this patch.
Braces   +13 added lines, -26 removed lines patch added patch discarded remove patch
@@ -620,8 +620,7 @@  discard block
 block discarded – undo
620 620
 		if (is_callable($callback))
621 621
 		{
622 622
 			$this->user[] = $callback;
623
-		}
624
-		else
623
+		} else
625 624
 		{
626 625
 			trigger_error('User-supplied function must be a valid callback', E_USER_WARNING);
627 626
 		}
@@ -683,8 +682,7 @@  discard block
 block discarded – undo
683 682
 				{
684 683
 					$timezone = 0 - $timezone;
685 684
 				}
686
-			}
687
-			else
685
+			} else
688 686
 			{
689 687
 				$timezone = 0;
690 688
 			}
@@ -693,8 +691,7 @@  discard block
 block discarded – undo
693 691
 			$second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
694 692
 
695 693
 			return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone;
696
-		}
697
-		else
694
+		} else
698 695
 		{
699 696
 			return false;
700 697
 		}
@@ -730,8 +727,7 @@  discard block
 block discarded – undo
730 727
 					{
731 728
 						$position++;
732 729
 						continue;
733
-					}
734
-					elseif (isset($string[$position]))
730
+					} elseif (isset($string[$position]))
735 731
 					{
736 732
 						switch ($string[$position])
737 733
 						{
@@ -744,14 +740,12 @@  discard block
 block discarded – undo
744 740
 								break;
745 741
 						}
746 742
 						$position++;
747
-					}
748
-					else
743
+					} else
749 744
 					{
750 745
 						break;
751 746
 					}
752 747
 				}
753
-			}
754
-			else
748
+			} else
755 749
 			{
756 750
 				$output .= '(';
757 751
 			}
@@ -830,8 +824,7 @@  discard block
 block discarded – undo
830 824
 			if ($match[4] < 50)
831 825
 			{
832 826
 				$match[4] += 2000;
833
-			}
834
-			elseif ($match[4] < 1000)
827
+			} elseif ($match[4] < 1000)
835 828
 			{
836 829
 				$match[4] += 1900;
837 830
 			}
@@ -840,15 +833,13 @@  discard block
 block discarded – undo
840 833
 			if ($match[7] !== '')
841 834
 			{
842 835
 				$second = $match[7];
843
-			}
844
-			else
836
+			} else
845 837
 			{
846 838
 				$second = 0;
847 839
 			}
848 840
 
849 841
 			return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone;
850
-		}
851
-		else
842
+		} else
852 843
 		{
853 844
 			return false;
854 845
 		}
@@ -905,15 +896,13 @@  discard block
 block discarded – undo
905 896
 			if ($match[4] < 50)
906 897
 			{
907 898
 				$match[4] += 2000;
908
-			}
909
-			else
899
+			} else
910 900
 			{
911 901
 				$match[4] += 1900;
912 902
 			}
913 903
 
914 904
 			return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone;
915
-		}
916
-		else
905
+		} else
917 906
 		{
918 907
 			return false;
919 908
 		}
@@ -954,8 +943,7 @@  discard block
 block discarded – undo
954 943
 
955 944
 			$month = $this->month[strtolower($match[2])];
956 945
 			return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]);
957
-		}
958
-		else
946
+		} else
959 947
 		{
960 948
 			return false;
961 949
 		}
@@ -973,8 +961,7 @@  discard block
 block discarded – undo
973 961
 		if ($strtotime === -1 || $strtotime === false)
974 962
 		{
975 963
 			return false;
976
-		}
977
-		else
964
+		} else
978 965
 		{
979 966
 			return $strtotime;
980 967
 		}
Please login to merge, or discard this patch.
src/wp-includes/SimplePie/Parser.php 3 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -265,6 +265,9 @@  discard block
 block discarded – undo
265 265
 		return $this->data;
266 266
 	}
267 267
 
268
+	/**
269
+	 * @param string $tag
270
+	 */
268 271
 	public function tag_open($parser, $tag, $attributes)
269 272
 	{
270 273
 		list($this->namespace[], $this->element[]) = $this->split_ns($tag);
@@ -332,6 +335,9 @@  discard block
 block discarded – undo
332 335
 		}
333 336
 	}
334 337
 
338
+	/**
339
+	 * @param string $cdata
340
+	 */
335 341
 	public function cdata($parser, $cdata)
336 342
 	{
337 343
 		if ($this->current_xhtml_construct >= 0)
@@ -344,6 +350,9 @@  discard block
 block discarded – undo
344 350
 		}
345 351
 	}
346 352
 
353
+	/**
354
+	 * @param string $tag
355
+	 */
347 356
 	public function tag_close($parser, $tag)
348 357
 	{
349 358
 		if ($this->current_xhtml_construct >= 0)
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 			if ($declaration->parse())
121 121
 			{
122 122
 				$data = substr($data, $pos + 2);
123
-				$data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data;
123
+				$data = '<?xml version="'.$declaration->version.'" encoding="'.$encoding.'" standalone="'.(($declaration->standalone) ? 'yes' : 'no').'"?>'.$data;
124 124
 			}
125 125
 			else
126 126
 			{
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 			xml_set_element_handler($xml, 'tag_open', 'tag_close');
152 152
 
153 153
 			// Parse!
154
-			if (!xml_parse($xml, $data, true))
154
+			if ( ! xml_parse($xml, $data, true))
155 155
 			{
156 156
 				$this->error_code = xml_get_error_code($xml);
157 157
 				$this->error_string = xml_error_string($this->error_code);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 					case constant('XMLReader::END_ELEMENT'):
177 177
 						if ($xml->namespaceURI !== '')
178 178
 						{
179
-							$tagName = $xml->namespaceURI . $this->separator . $xml->localName;
179
+							$tagName = $xml->namespaceURI.$this->separator.$xml->localName;
180 180
 						}
181 181
 						else
182 182
 						{
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 						$empty = $xml->isEmptyElement;
189 189
 						if ($xml->namespaceURI !== '')
190 190
 						{
191
-							$tagName = $xml->namespaceURI . $this->separator . $xml->localName;
191
+							$tagName = $xml->namespaceURI.$this->separator.$xml->localName;
192 192
 						}
193 193
 						else
194 194
 						{
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 						{
200 200
 							if ($xml->namespaceURI !== '')
201 201
 							{
202
-								$attrName = $xml->namespaceURI . $this->separator . $xml->localName;
202
+								$attrName = $xml->namespaceURI.$this->separator.$xml->localName;
203 203
 							}
204 204
 							else
205 205
 							{
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
 			$this->current_xhtml_construct++;
306 306
 			if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML)
307 307
 			{
308
-				$this->data['data'] .= '<' . end($this->element);
308
+				$this->data['data'] .= '<'.end($this->element);
309 309
 				if (isset($attribs['']))
310 310
 				{
311 311
 					foreach ($attribs[''] as $name => $value)
312 312
 					{
313
-						$this->data['data'] .= ' ' . $name . '="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) . '"';
313
+						$this->data['data'] .= ' '.$name.'="'.htmlspecialchars($value, ENT_COMPAT, $this->encoding).'"';
314 314
 					}
315 315
 				}
316 316
 				$this->data['data'] .= '>';
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 		}
319 319
 		else
320 320
 		{
321
-			$this->datas[] =& $this->data;
322
-			$this->data =& $this->data['child'][end($this->namespace)][end($this->element)][];
321
+			$this->datas[] = & $this->data;
322
+			$this->data = & $this->data['child'][end($this->namespace)][end($this->element)][];
323 323
 			$this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang));
324 324
 			if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml')
325 325
 			|| (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')
@@ -349,14 +349,14 @@  discard block
 block discarded – undo
349 349
 		if ($this->current_xhtml_construct >= 0)
350 350
 		{
351 351
 			$this->current_xhtml_construct--;
352
-			if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param')))
352
+			if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && ! in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param')))
353 353
 			{
354
-				$this->data['data'] .= '</' . end($this->element) . '>';
354
+				$this->data['data'] .= '</'.end($this->element).'>';
355 355
 			}
356 356
 		}
357 357
 		if ($this->current_xhtml_construct === -1)
358 358
 		{
359
-			$this->data =& $this->datas[count($this->datas) - 1];
359
+			$this->data = & $this->datas[count($this->datas) - 1];
360 360
 			array_pop($this->datas);
361 361
 		}
362 362
 
@@ -370,12 +370,12 @@  discard block
 block discarded – undo
370 370
 	public function split_ns($string)
371 371
 	{
372 372
 		static $cache = array();
373
-		if (!isset($cache[$string]))
373
+		if ( ! isset($cache[$string]))
374 374
 		{
375 375
 			if ($pos = strpos($string, $this->separator))
376 376
 			{
377 377
 				static $separator_length;
378
-				if (!$separator_length)
378
+				if ( ! $separator_length)
379 379
 				{
380 380
 					$separator_length = strlen($this->separator);
381 381
 				}
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 					$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG2 ||
392 392
 					$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG3 ||
393 393
 					$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG4 ||
394
-					$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5 )
394
+					$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5)
395 395
 				{
396 396
 					$namespace = SIMPLEPIE_NAMESPACE_MEDIARSS;
397 397
 				}
Please login to merge, or discard this patch.
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 		if (strtoupper($encoding) === 'US-ASCII')
82 82
 		{
83 83
 			$this->encoding = 'UTF-8';
84
-		}
85
-		else
84
+		} else
86 85
 		{
87 86
 			$this->encoding = $encoding;
88 87
 		}
@@ -121,8 +120,7 @@  discard block
 block discarded – undo
121 120
 			{
122 121
 				$data = substr($data, $pos + 2);
123 122
 				$data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data;
124
-			}
125
-			else
123
+			} else
126 124
 			{
127 125
 				$this->error_string = 'SimplePie bug! Please report this!';
128 126
 				return false;
@@ -162,8 +160,7 @@  discard block
 block discarded – undo
162 160
 			$this->current_byte = xml_get_current_byte_index($xml);
163 161
 			xml_parser_free($xml);
164 162
 			return $return;
165
-		}
166
-		else
163
+		} else
167 164
 		{
168 165
 			libxml_clear_errors();
169 166
 			$xml = new XMLReader();
@@ -177,8 +174,7 @@  discard block
 block discarded – undo
177 174
 						if ($xml->namespaceURI !== '')
178 175
 						{
179 176
 							$tagName = $xml->namespaceURI . $this->separator . $xml->localName;
180
-						}
181
-						else
177
+						} else
182 178
 						{
183 179
 							$tagName = $xml->localName;
184 180
 						}
@@ -189,8 +185,7 @@  discard block
 block discarded – undo
189 185
 						if ($xml->namespaceURI !== '')
190 186
 						{
191 187
 							$tagName = $xml->namespaceURI . $this->separator . $xml->localName;
192
-						}
193
-						else
188
+						} else
194 189
 						{
195 190
 							$tagName = $xml->localName;
196 191
 						}
@@ -200,8 +195,7 @@  discard block
 block discarded – undo
200 195
 							if ($xml->namespaceURI !== '')
201 196
 							{
202 197
 								$attrName = $xml->namespaceURI . $this->separator . $xml->localName;
203
-							}
204
-							else
198
+							} else
205 199
 							{
206 200
 								$attrName = $xml->localName;
207 201
 							}
@@ -227,8 +221,7 @@  discard block
 block discarded – undo
227 221
 				$this->current_line = $error->line;
228 222
 				$this->current_column = $error->column;
229 223
 				return false;
230
-			}
231
-			else
224
+			} else
232 225
 			{
233 226
 				return true;
234 227
 			}
@@ -284,8 +277,7 @@  discard block
 block discarded – undo
284 277
 				$this->xml_base[] = $base;
285 278
 				$this->xml_base_explicit[] = true;
286 279
 			}
287
-		}
288
-		else
280
+		} else
289 281
 		{
290 282
 			$this->xml_base[] = end($this->xml_base);
291 283
 			$this->xml_base_explicit[] = end($this->xml_base_explicit);
@@ -294,8 +286,7 @@  discard block
 block discarded – undo
294 286
 		if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang']))
295 287
 		{
296 288
 			$this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang'];
297
-		}
298
-		else
289
+		} else
299 290
 		{
300 291
 			$this->xml_lang[] = end($this->xml_lang);
301 292
 		}
@@ -315,8 +306,7 @@  discard block
 block discarded – undo
315 306
 				}
316 307
 				$this->data['data'] .= '>';
317 308
 			}
318
-		}
319
-		else
309
+		} else
320 310
 		{
321 311
 			$this->datas[] =& $this->data;
322 312
 			$this->data =& $this->data['child'][end($this->namespace)][end($this->element)][];
@@ -337,8 +327,7 @@  discard block
 block discarded – undo
337 327
 		if ($this->current_xhtml_construct >= 0)
338 328
 		{
339 329
 			$this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding);
340
-		}
341
-		else
330
+		} else
342 331
 		{
343 332
 			$this->data['data'] .= $cdata;
344 333
 		}
@@ -396,8 +385,7 @@  discard block
 block discarded – undo
396 385
 					$namespace = SIMPLEPIE_NAMESPACE_MEDIARSS;
397 386
 				}
398 387
 				$cache[$string] = array($namespace, $local_name);
399
-			}
400
-			else
388
+			} else
401 389
 			{
402 390
 				$cache[$string] = array('', $string);
403 391
 			}
Please login to merge, or discard this patch.
src/wp-includes/template.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
  * @since 1.5.0
18 18
  *
19 19
  * @param string $type      Filename without extension.
20
- * @param array  $templates An optional list of template candidates
20
+ * @param string[]  $templates An optional list of template candidates
21 21
  * @return string Full path to template file.
22 22
  */
23 23
 function get_query_template( $type, $templates = array() ) {
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
  * @param array  $templates An optional list of template candidates
21 21
  * @return string Full path to template file.
22 22
  */
23
-function get_query_template( $type, $templates = array() ) {
24
-	$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
23
+function get_query_template($type, $templates = array()) {
24
+	$type = preg_replace('|[^a-z0-9-]+|', '', $type);
25 25
 
26
-	if ( empty( $templates ) )
26
+	if (empty($templates))
27 27
 		$templates = array("{$type}.php");
28 28
 
29 29
 	/**
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param array $templates A list of template candidates, in descending order of priority.
40 40
 	 */
41
-	$templates = apply_filters( "{$type}_template_hierarchy", $templates );
41
+	$templates = apply_filters("{$type}_template_hierarchy", $templates);
42 42
 
43
-	$template = locate_template( $templates );
43
+	$template = locate_template($templates);
44 44
 
45 45
 	/**
46 46
 	 * Filters the path of the queried template by type.
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 *
57 57
 	 * @param string $template Path to the template. See locate_template().
58 58
 	 */
59
-	return apply_filters( "{$type}_template", $template );
59
+	return apply_filters("{$type}_template", $template);
60 60
 }
61 61
 
62 62
 /**
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
  * @return string Full path to archive template file.
105 105
  */
106 106
 function get_archive_template() {
107
-	$post_types = array_filter( (array) get_query_var( 'post_type' ) );
107
+	$post_types = array_filter((array) get_query_var('post_type'));
108 108
 
109 109
 	$templates = array();
110 110
 
111
-	if ( count( $post_types ) == 1 ) {
112
-		$post_type = reset( $post_types );
111
+	if (count($post_types) == 1) {
112
+		$post_type = reset($post_types);
113 113
 		$templates[] = "archive-{$post_type}.php";
114 114
 	}
115 115
 	$templates[] = 'archive.php';
116 116
 
117
-	return get_query_template( 'archive', $templates );
117
+	return get_query_template('archive', $templates);
118 118
 }
119 119
 
120 120
 /**
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
  * @return string Full path to archive template file.
131 131
  */
132 132
 function get_post_type_archive_template() {
133
-	$post_type = get_query_var( 'post_type' );
134
-	if ( is_array( $post_type ) )
135
-		$post_type = reset( $post_type );
133
+	$post_type = get_query_var('post_type');
134
+	if (is_array($post_type))
135
+		$post_type = reset($post_type);
136 136
 
137
-	$obj = get_post_type_object( $post_type );
138
-	if ( ! $obj->has_archive )
137
+	$obj = get_post_type_object($post_type);
138
+	if ( ! $obj->has_archive)
139 139
 		return '';
140 140
 
141 141
 	return get_archive_template();
@@ -170,13 +170,13 @@  discard block
 block discarded – undo
170 170
 
171 171
 	$templates = array();
172 172
 
173
-	if ( $author instanceof WP_User ) {
173
+	if ($author instanceof WP_User) {
174 174
 		$templates[] = "author-{$author->user_nicename}.php";
175 175
 		$templates[] = "author-{$author->ID}.php";
176 176
 	}
177 177
 	$templates[] = 'author.php';
178 178
 
179
-	return get_query_template( 'author', $templates );
179
+	return get_query_template('author', $templates);
180 180
 }
181 181
 
182 182
 /**
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
 
211 211
 	$templates = array();
212 212
 
213
-	if ( ! empty( $category->slug ) ) {
213
+	if ( ! empty($category->slug)) {
214 214
 
215
-		$slug_decoded = urldecode( $category->slug );
216
-		if ( $slug_decoded !== $category->slug ) {
215
+		$slug_decoded = urldecode($category->slug);
216
+		if ($slug_decoded !== $category->slug) {
217 217
 			$templates[] = "category-{$slug_decoded}.php";
218 218
 		}
219 219
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	}
223 223
 	$templates[] = 'category.php';
224 224
 
225
-	return get_query_template( 'category', $templates );
225
+	return get_query_template('category', $templates);
226 226
 }
227 227
 
228 228
 /**
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
 
257 257
 	$templates = array();
258 258
 
259
-	if ( ! empty( $tag->slug ) ) {
259
+	if ( ! empty($tag->slug)) {
260 260
 
261
-		$slug_decoded = urldecode( $tag->slug );
262
-		if ( $slug_decoded !== $tag->slug ) {
261
+		$slug_decoded = urldecode($tag->slug);
262
+		if ($slug_decoded !== $tag->slug) {
263 263
 			$templates[] = "tag-{$slug_decoded}.php";
264 264
 		}
265 265
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	}
269 269
 	$templates[] = 'tag.php';
270 270
 
271
-	return get_query_template( 'tag', $templates );
271
+	return get_query_template('tag', $templates);
272 272
 }
273 273
 
274 274
 /**
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
 
303 303
 	$templates = array();
304 304
 
305
-	if ( ! empty( $term->slug ) ) {
305
+	if ( ! empty($term->slug)) {
306 306
 		$taxonomy = $term->taxonomy;
307 307
 
308
-		$slug_decoded = urldecode( $term->slug );
309
-		if ( $slug_decoded !== $term->slug ) {
308
+		$slug_decoded = urldecode($term->slug);
309
+		if ($slug_decoded !== $term->slug) {
310 310
 			$templates[] = "taxonomy-$taxonomy-{$slug_decoded}.php";
311 311
 		}
312 312
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	}
316 316
 	$templates[] = 'taxonomy.php';
317 317
 
318
-	return get_query_template( 'taxonomy', $templates );
318
+	return get_query_template('taxonomy', $templates);
319 319
 }
320 320
 
321 321
 /**
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
  * @return string Full path to home template file.
348 348
  */
349 349
 function get_home_template() {
350
-	$templates = array( 'home.php', 'index.php' );
350
+	$templates = array('home.php', 'index.php');
351 351
 
352
-	return get_query_template( 'home', $templates );
352
+	return get_query_template('home', $templates);
353 353
 }
354 354
 
355 355
 /**
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 function get_front_page_template() {
368 368
 	$templates = array('front-page.php');
369 369
 
370
-	return get_query_template( 'front_page', $templates );
370
+	return get_query_template('front_page', $templates);
371 371
 }
372 372
 
373 373
 /**
@@ -403,28 +403,28 @@  discard block
 block discarded – undo
403 403
 	$template = get_page_template_slug();
404 404
 	$pagename = get_query_var('pagename');
405 405
 
406
-	if ( ! $pagename && $id ) {
406
+	if ( ! $pagename && $id) {
407 407
 		// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
408 408
 		$post = get_queried_object();
409
-		if ( $post )
409
+		if ($post)
410 410
 			$pagename = $post->post_name;
411 411
 	}
412 412
 
413 413
 	$templates = array();
414
-	if ( $template && 0 === validate_file( $template ) )
414
+	if ($template && 0 === validate_file($template))
415 415
 		$templates[] = $template;
416
-	if ( $pagename ) {
417
-		$pagename_decoded = urldecode( $pagename );
418
-		if ( $pagename_decoded !== $pagename ) {
416
+	if ($pagename) {
417
+		$pagename_decoded = urldecode($pagename);
418
+		if ($pagename_decoded !== $pagename) {
419 419
 			$templates[] = "page-{$pagename_decoded}.php";
420 420
 		}
421 421
 		$templates[] = "page-$pagename.php";
422 422
 	}
423
-	if ( $id )
423
+	if ($id)
424 424
 		$templates[] = "page-$id.php";
425 425
 	$templates[] = 'page.php';
426 426
 
427
-	return get_query_template( 'page', $templates );
427
+	return get_query_template('page', $templates);
428 428
 }
429 429
 
430 430
 /**
@@ -479,14 +479,14 @@  discard block
 block discarded – undo
479 479
 
480 480
 	$templates = array();
481 481
 
482
-	if ( ! empty( $object->post_type ) ) {
483
-		$template = get_page_template_slug( $object );
484
-		if ( $template && 0 === validate_file( $template ) ) {
482
+	if ( ! empty($object->post_type)) {
483
+		$template = get_page_template_slug($object);
484
+		if ($template && 0 === validate_file($template)) {
485 485
 			$templates[] = $template;
486 486
 		}
487 487
 
488
-		$name_decoded = urldecode( $object->post_name );
489
-		if ( $name_decoded !== $object->post_name ) {
488
+		$name_decoded = urldecode($object->post_name);
489
+		if ($name_decoded !== $object->post_name) {
490 490
 			$templates[] = "single-{$object->post_type}-{$name_decoded}.php";
491 491
 		}
492 492
 
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 
497 497
 	$templates[] = "single.php";
498 498
 
499
-	return get_query_template( 'single', $templates );
499
+	return get_query_template('single', $templates);
500 500
 }
501 501
 
502 502
 /**
@@ -528,9 +528,9 @@  discard block
 block discarded – undo
528 528
 
529 529
 	$templates = array();
530 530
 
531
-	if ( ! empty( $object->post_type ) ) {
532
-		$post_format = get_post_format( $object );
533
-		if ( $post_format ) {
531
+	if ( ! empty($object->post_type)) {
532
+		$post_format = get_post_format($object);
533
+		if ($post_format) {
534 534
 			$templates[] = "embed-{$object->post_type}-{$post_format}.php";
535 535
 		}
536 536
 		$templates[] = "embed-{$object->post_type}.php";
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 
539 539
 	$templates[] = "embed.php";
540 540
 
541
-	return get_query_template( 'embed', $templates );
541
+	return get_query_template('embed', $templates);
542 542
 }
543 543
 
544 544
 /**
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
  * @return string Full path to singular template file
555 555
  */
556 556
 function get_singular_template() {
557
-	return get_query_template( 'singular' );
557
+	return get_query_template('singular');
558 558
 }
559 559
 
560 560
 /**
@@ -591,14 +591,14 @@  discard block
 block discarded – undo
591 591
 
592 592
 	$templates = array();
593 593
 
594
-	if ( $attachment ) {
595
-		if ( false !== strpos( $attachment->post_mime_type, '/' ) ) {
596
-			list( $type, $subtype ) = explode( '/', $attachment->post_mime_type );
594
+	if ($attachment) {
595
+		if (false !== strpos($attachment->post_mime_type, '/')) {
596
+			list($type, $subtype) = explode('/', $attachment->post_mime_type);
597 597
 		} else {
598
-			list( $type, $subtype ) = array( $attachment->post_mime_type, '' );
598
+			list($type, $subtype) = array($attachment->post_mime_type, '');
599 599
 		}
600 600
 
601
-		if ( ! empty( $subtype ) ) {
601
+		if ( ! empty($subtype)) {
602 602
 			$templates[] = "{$type}-{$subtype}.php";
603 603
 			$templates[] = "{$subtype}.php";
604 604
 		}
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 	}
607 607
 	$templates[] = 'attachment.php';
608 608
 
609
-	return get_query_template( 'attachment', $templates );
609
+	return get_query_template('attachment', $templates);
610 610
 }
611 611
 
612 612
 /**
@@ -622,25 +622,25 @@  discard block
 block discarded – undo
622 622
  * @param bool         $require_once   Whether to require_once or require. Default true. Has no effect if $load is false.
623 623
  * @return string The template filename if one is located.
624 624
  */
625
-function locate_template($template_names, $load = false, $require_once = true ) {
625
+function locate_template($template_names, $load = false, $require_once = true) {
626 626
 	$located = '';
627
-	foreach ( (array) $template_names as $template_name ) {
628
-		if ( !$template_name )
627
+	foreach ((array) $template_names as $template_name) {
628
+		if ( ! $template_name)
629 629
 			continue;
630
-		if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
631
-			$located = STYLESHEETPATH . '/' . $template_name;
630
+		if (file_exists(STYLESHEETPATH.'/'.$template_name)) {
631
+			$located = STYLESHEETPATH.'/'.$template_name;
632 632
 			break;
633
-		} elseif ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
634
-			$located = TEMPLATEPATH . '/' . $template_name;
633
+		} elseif (file_exists(TEMPLATEPATH.'/'.$template_name)) {
634
+			$located = TEMPLATEPATH.'/'.$template_name;
635 635
 			break;
636
-		} elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) {
637
-			$located = ABSPATH . WPINC . '/theme-compat/' . $template_name;
636
+		} elseif (file_exists(ABSPATH.WPINC.'/theme-compat/'.$template_name)) {
637
+			$located = ABSPATH.WPINC.'/theme-compat/'.$template_name;
638 638
 			break;
639 639
 		}
640 640
 	}
641 641
 
642
-	if ( $load && '' != $located )
643
-		load_template( $located, $require_once );
642
+	if ($load && '' != $located)
643
+		load_template($located, $require_once);
644 644
 
645 645
 	return $located;
646 646
 }
@@ -669,20 +669,20 @@  discard block
 block discarded – undo
669 669
  * @param string $_template_file Path to template file.
670 670
  * @param bool   $require_once   Whether to require_once or require. Default true.
671 671
  */
672
-function load_template( $_template_file, $require_once = true ) {
672
+function load_template($_template_file, $require_once = true) {
673 673
 	global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
674 674
 
675
-	if ( is_array( $wp_query->query_vars ) ) {
676
-		extract( $wp_query->query_vars, EXTR_SKIP );
675
+	if (is_array($wp_query->query_vars)) {
676
+		extract($wp_query->query_vars, EXTR_SKIP);
677 677
 	}
678 678
 
679
-	if ( isset( $s ) ) {
680
-		$s = esc_attr( $s );
679
+	if (isset($s)) {
680
+		$s = esc_attr($s);
681 681
 	}
682 682
 
683
-	if ( $require_once ) {
684
-		require_once( $_template_file );
683
+	if ($require_once) {
684
+		require_once($_template_file);
685 685
 	} else {
686
-		require( $_template_file );
686
+		require($_template_file);
687 687
 	}
688 688
 }
Please login to merge, or discard this patch.
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -23,8 +23,9 @@  discard block
 block discarded – undo
23 23
 function get_query_template( $type, $templates = array() ) {
24 24
 	$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
25 25
 
26
-	if ( empty( $templates ) )
27
-		$templates = array("{$type}.php");
26
+	if ( empty( $templates ) ) {
27
+			$templates = array("{$type}.php");
28
+	}
28 29
 
29 30
 	/**
30 31
 	 * Filters the list of template filenames that are searched for when retrieving a template to use.
@@ -131,12 +132,14 @@  discard block
 block discarded – undo
131 132
  */
132 133
 function get_post_type_archive_template() {
133 134
 	$post_type = get_query_var( 'post_type' );
134
-	if ( is_array( $post_type ) )
135
-		$post_type = reset( $post_type );
135
+	if ( is_array( $post_type ) ) {
136
+			$post_type = reset( $post_type );
137
+	}
136 138
 
137 139
 	$obj = get_post_type_object( $post_type );
138
-	if ( ! $obj->has_archive )
139
-		return '';
140
+	if ( ! $obj->has_archive ) {
141
+			return '';
142
+	}
140 143
 
141 144
 	return get_archive_template();
142 145
 }
@@ -406,13 +409,15 @@  discard block
 block discarded – undo
406 409
 	if ( ! $pagename && $id ) {
407 410
 		// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
408 411
 		$post = get_queried_object();
409
-		if ( $post )
410
-			$pagename = $post->post_name;
412
+		if ( $post ) {
413
+					$pagename = $post->post_name;
414
+		}
411 415
 	}
412 416
 
413 417
 	$templates = array();
414
-	if ( $template && 0 === validate_file( $template ) )
415
-		$templates[] = $template;
418
+	if ( $template && 0 === validate_file( $template ) ) {
419
+			$templates[] = $template;
420
+	}
416 421
 	if ( $pagename ) {
417 422
 		$pagename_decoded = urldecode( $pagename );
418 423
 		if ( $pagename_decoded !== $pagename ) {
@@ -420,8 +425,9 @@  discard block
 block discarded – undo
420 425
 		}
421 426
 		$templates[] = "page-$pagename.php";
422 427
 	}
423
-	if ( $id )
424
-		$templates[] = "page-$id.php";
428
+	if ( $id ) {
429
+			$templates[] = "page-$id.php";
430
+	}
425 431
 	$templates[] = 'page.php';
426 432
 
427 433
 	return get_query_template( 'page', $templates );
@@ -625,8 +631,9 @@  discard block
 block discarded – undo
625 631
 function locate_template($template_names, $load = false, $require_once = true ) {
626 632
 	$located = '';
627 633
 	foreach ( (array) $template_names as $template_name ) {
628
-		if ( !$template_name )
629
-			continue;
634
+		if ( !$template_name ) {
635
+					continue;
636
+		}
630 637
 		if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
631 638
 			$located = STYLESHEETPATH . '/' . $template_name;
632 639
 			break;
@@ -639,8 +646,9 @@  discard block
 block discarded – undo
639 646
 		}
640 647
 	}
641 648
 
642
-	if ( $load && '' != $located )
643
-		load_template( $located, $require_once );
649
+	if ( $load && '' != $located ) {
650
+			load_template( $located, $require_once );
651
+	}
644 652
 
645 653
 	return $located;
646 654
 }
Please login to merge, or discard this patch.
src/wp-includes/Text/Diff/Engine/native.php 3 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -145,6 +145,7 @@  discard block
 block discarded – undo
145 145
      * the two files do not match, and likewise that the last lines do not
146 146
      * match.  The caller must trim matching lines from the beginning and end
147 147
      * of the portions it is going to specify.
148
+     * @param double $nchunks
148 149
      */
149 150
     function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks)
150 151
     {
@@ -265,6 +266,10 @@  discard block
 block discarded – undo
265 266
      *
266 267
      * Note that XLIM, YLIM are exclusive bounds.  All line numbers are
267 268
      * origin-0 and discarded lines are not counted.
269
+     * @param integer $xoff
270
+     * @param integer $xlim
271
+     * @param integer $yoff
272
+     * @param integer $ylim
268 273
      */
269 274
     function _compareseq ($xoff, $xlim, $yoff, $ylim)
270 275
     {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             // Skip matching "snake".
100 100
             $copy = array();
101 101
             while ($xi < $n_from && $yi < $n_to
102
-                   && !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
102
+                   && ! $this->xchanged[$xi] && ! $this->ychanged[$yi]) {
103 103
                 $copy[] = $from_lines[$xi++];
104 104
                 ++$yi;
105 105
             }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      * match.  The caller must trim matching lines from the beginning and end
147 147
      * of the portions it is going to specify.
148 148
      */
149
-    function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks)
149
+    function _diag($xoff, $xlim, $yoff, $ylim, $nchunks)
150 150
     {
151 151
         $flip = false;
152 152
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         }
170 170
 
171 171
         $this->lcs = 0;
172
-        $this->seq[0]= $yoff - 1;
172
+        $this->seq[0] = $yoff - 1;
173 173
         $this->in_seq = array();
174 174
         $ymids[0] = array();
175 175
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                 }
183 183
             }
184 184
 
185
-            $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);
185
+            $x1 = $xoff + (int) (($numer + ($xlim - $xoff) * $chunk) / $nchunks);
186 186
             for (; $x < $x1; $x++) {
187 187
                 $line = $flip ? $this->yv[$x] : $this->xv[$x];
188 188
                 if (empty($ymatches[$line])) {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
         $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff);
219 219
         $ymid = $ymids[$this->lcs];
220 220
         for ($n = 0; $n < $nchunks - 1; $n++) {
221
-            $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks);
221
+            $x1 = $xoff + (int) (($numer + ($xlim - $xoff) * $n) / $nchunks);
222 222
             $y1 = $ymid[$n] + 1;
223 223
             $seps[] = $flip ? array($y1, $x1) : array($x1, $y1);
224 224
         }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
         $beg = 1;
240 240
         while ($beg < $end) {
241
-            $mid = (int)(($beg + $end) / 2);
241
+            $mid = (int) (($beg + $end) / 2);
242 242
             if ($ypos > $this->seq[$mid]) {
243 243
                 $beg = $mid + 1;
244 244
             } else {
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
      * Note that XLIM, YLIM are exclusive bounds.  All line numbers are
267 267
      * origin-0 and discarded lines are not counted.
268 268
      */
269
-    function _compareseq ($xoff, $xlim, $yoff, $ylim)
269
+    function _compareseq($xoff, $xlim, $yoff, $ylim)
270 270
     {
271 271
         /* Slide down the bottom initial diagonal. */
272 272
         while ($xoff < $xlim && $yoff < $ylim
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
             reset($seps);
308 308
             $pt1 = $seps[0];
309 309
             while ($pt2 = next($seps)) {
310
-                $this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]);
310
+                $this->_compareseq($pt1[0], $pt2[0], $pt1[1], $pt2[1]);
311 311
                 $pt1 = $pt2;
312 312
             }
313 313
         }
Please login to merge, or discard this patch.
Indentation   +375 added lines, -375 removed lines patch added patch discarded remove patch
@@ -28,314 +28,314 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class Text_Diff_Engine_native {
30 30
 
31
-    function diff($from_lines, $to_lines)
32
-    {
33
-        array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
34
-        array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
35
-
36
-        $n_from = count($from_lines);
37
-        $n_to = count($to_lines);
38
-
39
-        $this->xchanged = $this->ychanged = array();
40
-        $this->xv = $this->yv = array();
41
-        $this->xind = $this->yind = array();
42
-        unset($this->seq);
43
-        unset($this->in_seq);
44
-        unset($this->lcs);
45
-
46
-        // Skip leading common lines.
47
-        for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) {
48
-            if ($from_lines[$skip] !== $to_lines[$skip]) {
49
-                break;
50
-            }
51
-            $this->xchanged[$skip] = $this->ychanged[$skip] = false;
52
-        }
53
-
54
-        // Skip trailing common lines.
55
-        $xi = $n_from; $yi = $n_to;
56
-        for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) {
57
-            if ($from_lines[$xi] !== $to_lines[$yi]) {
58
-                break;
59
-            }
60
-            $this->xchanged[$xi] = $this->ychanged[$yi] = false;
61
-        }
62
-
63
-        // Ignore lines which do not exist in both files.
64
-        for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
65
-            $xhash[$from_lines[$xi]] = 1;
66
-        }
67
-        for ($yi = $skip; $yi < $n_to - $endskip; $yi++) {
68
-            $line = $to_lines[$yi];
69
-            if (($this->ychanged[$yi] = empty($xhash[$line]))) {
70
-                continue;
71
-            }
72
-            $yhash[$line] = 1;
73
-            $this->yv[] = $line;
74
-            $this->yind[] = $yi;
75
-        }
76
-        for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
77
-            $line = $from_lines[$xi];
78
-            if (($this->xchanged[$xi] = empty($yhash[$line]))) {
79
-                continue;
80
-            }
81
-            $this->xv[] = $line;
82
-            $this->xind[] = $xi;
83
-        }
84
-
85
-        // Find the LCS.
86
-        $this->_compareseq(0, count($this->xv), 0, count($this->yv));
87
-
88
-        // Merge edits when possible.
89
-        $this->_shiftBoundaries($from_lines, $this->xchanged, $this->ychanged);
90
-        $this->_shiftBoundaries($to_lines, $this->ychanged, $this->xchanged);
91
-
92
-        // Compute the edit operations.
93
-        $edits = array();
94
-        $xi = $yi = 0;
95
-        while ($xi < $n_from || $yi < $n_to) {
96
-            assert($yi < $n_to || $this->xchanged[$xi]);
97
-            assert($xi < $n_from || $this->ychanged[$yi]);
98
-
99
-            // Skip matching "snake".
100
-            $copy = array();
101
-            while ($xi < $n_from && $yi < $n_to
102
-                   && !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
103
-                $copy[] = $from_lines[$xi++];
104
-                ++$yi;
105
-            }
106
-            if ($copy) {
107
-                $edits[] = new Text_Diff_Op_copy($copy);
108
-            }
109
-
110
-            // Find deletes & adds.
111
-            $delete = array();
112
-            while ($xi < $n_from && $this->xchanged[$xi]) {
113
-                $delete[] = $from_lines[$xi++];
114
-            }
115
-
116
-            $add = array();
117
-            while ($yi < $n_to && $this->ychanged[$yi]) {
118
-                $add[] = $to_lines[$yi++];
119
-            }
120
-
121
-            if ($delete && $add) {
122
-                $edits[] = new Text_Diff_Op_change($delete, $add);
123
-            } elseif ($delete) {
124
-                $edits[] = new Text_Diff_Op_delete($delete);
125
-            } elseif ($add) {
126
-                $edits[] = new Text_Diff_Op_add($add);
127
-            }
128
-        }
129
-
130
-        return $edits;
131
-    }
132
-
133
-    /**
134
-     * Divides the Largest Common Subsequence (LCS) of the sequences (XOFF,
135
-     * XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized
136
-     * segments.
137
-     *
138
-     * Returns (LCS, PTS).  LCS is the length of the LCS. PTS is an array of
139
-     * NCHUNKS+1 (X, Y) indexes giving the diving points between sub
140
-     * sequences.  The first sub-sequence is contained in (X0, X1), (Y0, Y1),
141
-     * the second in (X1, X2), (Y1, Y2) and so on.  Note that (X0, Y0) ==
142
-     * (XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM).
143
-     *
144
-     * This function assumes that the first lines of the specified portions of
145
-     * the two files do not match, and likewise that the last lines do not
146
-     * match.  The caller must trim matching lines from the beginning and end
147
-     * of the portions it is going to specify.
148
-     */
149
-    function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks)
150
-    {
151
-        $flip = false;
152
-
153
-        if ($xlim - $xoff > $ylim - $yoff) {
154
-            /* Things seems faster (I'm not sure I understand why) when the
31
+	function diff($from_lines, $to_lines)
32
+	{
33
+		array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
34
+		array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
35
+
36
+		$n_from = count($from_lines);
37
+		$n_to = count($to_lines);
38
+
39
+		$this->xchanged = $this->ychanged = array();
40
+		$this->xv = $this->yv = array();
41
+		$this->xind = $this->yind = array();
42
+		unset($this->seq);
43
+		unset($this->in_seq);
44
+		unset($this->lcs);
45
+
46
+		// Skip leading common lines.
47
+		for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) {
48
+			if ($from_lines[$skip] !== $to_lines[$skip]) {
49
+				break;
50
+			}
51
+			$this->xchanged[$skip] = $this->ychanged[$skip] = false;
52
+		}
53
+
54
+		// Skip trailing common lines.
55
+		$xi = $n_from; $yi = $n_to;
56
+		for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) {
57
+			if ($from_lines[$xi] !== $to_lines[$yi]) {
58
+				break;
59
+			}
60
+			$this->xchanged[$xi] = $this->ychanged[$yi] = false;
61
+		}
62
+
63
+		// Ignore lines which do not exist in both files.
64
+		for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
65
+			$xhash[$from_lines[$xi]] = 1;
66
+		}
67
+		for ($yi = $skip; $yi < $n_to - $endskip; $yi++) {
68
+			$line = $to_lines[$yi];
69
+			if (($this->ychanged[$yi] = empty($xhash[$line]))) {
70
+				continue;
71
+			}
72
+			$yhash[$line] = 1;
73
+			$this->yv[] = $line;
74
+			$this->yind[] = $yi;
75
+		}
76
+		for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
77
+			$line = $from_lines[$xi];
78
+			if (($this->xchanged[$xi] = empty($yhash[$line]))) {
79
+				continue;
80
+			}
81
+			$this->xv[] = $line;
82
+			$this->xind[] = $xi;
83
+		}
84
+
85
+		// Find the LCS.
86
+		$this->_compareseq(0, count($this->xv), 0, count($this->yv));
87
+
88
+		// Merge edits when possible.
89
+		$this->_shiftBoundaries($from_lines, $this->xchanged, $this->ychanged);
90
+		$this->_shiftBoundaries($to_lines, $this->ychanged, $this->xchanged);
91
+
92
+		// Compute the edit operations.
93
+		$edits = array();
94
+		$xi = $yi = 0;
95
+		while ($xi < $n_from || $yi < $n_to) {
96
+			assert($yi < $n_to || $this->xchanged[$xi]);
97
+			assert($xi < $n_from || $this->ychanged[$yi]);
98
+
99
+			// Skip matching "snake".
100
+			$copy = array();
101
+			while ($xi < $n_from && $yi < $n_to
102
+				   && !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
103
+				$copy[] = $from_lines[$xi++];
104
+				++$yi;
105
+			}
106
+			if ($copy) {
107
+				$edits[] = new Text_Diff_Op_copy($copy);
108
+			}
109
+
110
+			// Find deletes & adds.
111
+			$delete = array();
112
+			while ($xi < $n_from && $this->xchanged[$xi]) {
113
+				$delete[] = $from_lines[$xi++];
114
+			}
115
+
116
+			$add = array();
117
+			while ($yi < $n_to && $this->ychanged[$yi]) {
118
+				$add[] = $to_lines[$yi++];
119
+			}
120
+
121
+			if ($delete && $add) {
122
+				$edits[] = new Text_Diff_Op_change($delete, $add);
123
+			} elseif ($delete) {
124
+				$edits[] = new Text_Diff_Op_delete($delete);
125
+			} elseif ($add) {
126
+				$edits[] = new Text_Diff_Op_add($add);
127
+			}
128
+		}
129
+
130
+		return $edits;
131
+	}
132
+
133
+	/**
134
+	 * Divides the Largest Common Subsequence (LCS) of the sequences (XOFF,
135
+	 * XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized
136
+	 * segments.
137
+	 *
138
+	 * Returns (LCS, PTS).  LCS is the length of the LCS. PTS is an array of
139
+	 * NCHUNKS+1 (X, Y) indexes giving the diving points between sub
140
+	 * sequences.  The first sub-sequence is contained in (X0, X1), (Y0, Y1),
141
+	 * the second in (X1, X2), (Y1, Y2) and so on.  Note that (X0, Y0) ==
142
+	 * (XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM).
143
+	 *
144
+	 * This function assumes that the first lines of the specified portions of
145
+	 * the two files do not match, and likewise that the last lines do not
146
+	 * match.  The caller must trim matching lines from the beginning and end
147
+	 * of the portions it is going to specify.
148
+	 */
149
+	function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks)
150
+	{
151
+		$flip = false;
152
+
153
+		if ($xlim - $xoff > $ylim - $yoff) {
154
+			/* Things seems faster (I'm not sure I understand why) when the
155 155
              * shortest sequence is in X. */
156
-            $flip = true;
157
-            list ($xoff, $xlim, $yoff, $ylim)
158
-                = array($yoff, $ylim, $xoff, $xlim);
159
-        }
160
-
161
-        if ($flip) {
162
-            for ($i = $ylim - 1; $i >= $yoff; $i--) {
163
-                $ymatches[$this->xv[$i]][] = $i;
164
-            }
165
-        } else {
166
-            for ($i = $ylim - 1; $i >= $yoff; $i--) {
167
-                $ymatches[$this->yv[$i]][] = $i;
168
-            }
169
-        }
170
-
171
-        $this->lcs = 0;
172
-        $this->seq[0]= $yoff - 1;
173
-        $this->in_seq = array();
174
-        $ymids[0] = array();
175
-
176
-        $numer = $xlim - $xoff + $nchunks - 1;
177
-        $x = $xoff;
178
-        for ($chunk = 0; $chunk < $nchunks; $chunk++) {
179
-            if ($chunk > 0) {
180
-                for ($i = 0; $i <= $this->lcs; $i++) {
181
-                    $ymids[$i][$chunk - 1] = $this->seq[$i];
182
-                }
183
-            }
184
-
185
-            $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);
186
-            for (; $x < $x1; $x++) {
187
-                $line = $flip ? $this->yv[$x] : $this->xv[$x];
188
-                if (empty($ymatches[$line])) {
189
-                    continue;
190
-                }
191
-                $matches = $ymatches[$line];
192
-                reset($matches);
193
-                while (list(, $y) = each($matches)) {
194
-                    if (empty($this->in_seq[$y])) {
195
-                        $k = $this->_lcsPos($y);
196
-                        assert($k > 0);
197
-                        $ymids[$k] = $ymids[$k - 1];
198
-                        break;
199
-                    }
200
-                }
201
-                while (list(, $y) = each($matches)) {
202
-                    if ($y > $this->seq[$k - 1]) {
203
-                        assert($y <= $this->seq[$k]);
204
-                        /* Optimization: this is a common case: next match is
156
+			$flip = true;
157
+			list ($xoff, $xlim, $yoff, $ylim)
158
+				= array($yoff, $ylim, $xoff, $xlim);
159
+		}
160
+
161
+		if ($flip) {
162
+			for ($i = $ylim - 1; $i >= $yoff; $i--) {
163
+				$ymatches[$this->xv[$i]][] = $i;
164
+			}
165
+		} else {
166
+			for ($i = $ylim - 1; $i >= $yoff; $i--) {
167
+				$ymatches[$this->yv[$i]][] = $i;
168
+			}
169
+		}
170
+
171
+		$this->lcs = 0;
172
+		$this->seq[0]= $yoff - 1;
173
+		$this->in_seq = array();
174
+		$ymids[0] = array();
175
+
176
+		$numer = $xlim - $xoff + $nchunks - 1;
177
+		$x = $xoff;
178
+		for ($chunk = 0; $chunk < $nchunks; $chunk++) {
179
+			if ($chunk > 0) {
180
+				for ($i = 0; $i <= $this->lcs; $i++) {
181
+					$ymids[$i][$chunk - 1] = $this->seq[$i];
182
+				}
183
+			}
184
+
185
+			$x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);
186
+			for (; $x < $x1; $x++) {
187
+				$line = $flip ? $this->yv[$x] : $this->xv[$x];
188
+				if (empty($ymatches[$line])) {
189
+					continue;
190
+				}
191
+				$matches = $ymatches[$line];
192
+				reset($matches);
193
+				while (list(, $y) = each($matches)) {
194
+					if (empty($this->in_seq[$y])) {
195
+						$k = $this->_lcsPos($y);
196
+						assert($k > 0);
197
+						$ymids[$k] = $ymids[$k - 1];
198
+						break;
199
+					}
200
+				}
201
+				while (list(, $y) = each($matches)) {
202
+					if ($y > $this->seq[$k - 1]) {
203
+						assert($y <= $this->seq[$k]);
204
+						/* Optimization: this is a common case: next match is
205 205
                          * just replacing previous match. */
206
-                        $this->in_seq[$this->seq[$k]] = false;
207
-                        $this->seq[$k] = $y;
208
-                        $this->in_seq[$y] = 1;
209
-                    } elseif (empty($this->in_seq[$y])) {
210
-                        $k = $this->_lcsPos($y);
211
-                        assert($k > 0);
212
-                        $ymids[$k] = $ymids[$k - 1];
213
-                    }
214
-                }
215
-            }
216
-        }
217
-
218
-        $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff);
219
-        $ymid = $ymids[$this->lcs];
220
-        for ($n = 0; $n < $nchunks - 1; $n++) {
221
-            $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks);
222
-            $y1 = $ymid[$n] + 1;
223
-            $seps[] = $flip ? array($y1, $x1) : array($x1, $y1);
224
-        }
225
-        $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim);
226
-
227
-        return array($this->lcs, $seps);
228
-    }
229
-
230
-    function _lcsPos($ypos)
231
-    {
232
-        $end = $this->lcs;
233
-        if ($end == 0 || $ypos > $this->seq[$end]) {
234
-            $this->seq[++$this->lcs] = $ypos;
235
-            $this->in_seq[$ypos] = 1;
236
-            return $this->lcs;
237
-        }
238
-
239
-        $beg = 1;
240
-        while ($beg < $end) {
241
-            $mid = (int)(($beg + $end) / 2);
242
-            if ($ypos > $this->seq[$mid]) {
243
-                $beg = $mid + 1;
244
-            } else {
245
-                $end = $mid;
246
-            }
247
-        }
248
-
249
-        assert($ypos != $this->seq[$end]);
250
-
251
-        $this->in_seq[$this->seq[$end]] = false;
252
-        $this->seq[$end] = $ypos;
253
-        $this->in_seq[$ypos] = 1;
254
-        return $end;
255
-    }
256
-
257
-    /**
258
-     * Finds LCS of two sequences.
259
-     *
260
-     * The results are recorded in the vectors $this->{x,y}changed[], by
261
-     * storing a 1 in the element for each line that is an insertion or
262
-     * deletion (ie. is not in the LCS).
263
-     *
264
-     * The subsequence of file 0 is (XOFF, XLIM) and likewise for file 1.
265
-     *
266
-     * Note that XLIM, YLIM are exclusive bounds.  All line numbers are
267
-     * origin-0 and discarded lines are not counted.
268
-     */
269
-    function _compareseq ($xoff, $xlim, $yoff, $ylim)
270
-    {
271
-        /* Slide down the bottom initial diagonal. */
272
-        while ($xoff < $xlim && $yoff < $ylim
273
-               && $this->xv[$xoff] == $this->yv[$yoff]) {
274
-            ++$xoff;
275
-            ++$yoff;
276
-        }
277
-
278
-        /* Slide up the top initial diagonal. */
279
-        while ($xlim > $xoff && $ylim > $yoff
280
-               && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) {
281
-            --$xlim;
282
-            --$ylim;
283
-        }
284
-
285
-        if ($xoff == $xlim || $yoff == $ylim) {
286
-            $lcs = 0;
287
-        } else {
288
-            /* This is ad hoc but seems to work well.  $nchunks =
206
+						$this->in_seq[$this->seq[$k]] = false;
207
+						$this->seq[$k] = $y;
208
+						$this->in_seq[$y] = 1;
209
+					} elseif (empty($this->in_seq[$y])) {
210
+						$k = $this->_lcsPos($y);
211
+						assert($k > 0);
212
+						$ymids[$k] = $ymids[$k - 1];
213
+					}
214
+				}
215
+			}
216
+		}
217
+
218
+		$seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff);
219
+		$ymid = $ymids[$this->lcs];
220
+		for ($n = 0; $n < $nchunks - 1; $n++) {
221
+			$x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks);
222
+			$y1 = $ymid[$n] + 1;
223
+			$seps[] = $flip ? array($y1, $x1) : array($x1, $y1);
224
+		}
225
+		$seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim);
226
+
227
+		return array($this->lcs, $seps);
228
+	}
229
+
230
+	function _lcsPos($ypos)
231
+	{
232
+		$end = $this->lcs;
233
+		if ($end == 0 || $ypos > $this->seq[$end]) {
234
+			$this->seq[++$this->lcs] = $ypos;
235
+			$this->in_seq[$ypos] = 1;
236
+			return $this->lcs;
237
+		}
238
+
239
+		$beg = 1;
240
+		while ($beg < $end) {
241
+			$mid = (int)(($beg + $end) / 2);
242
+			if ($ypos > $this->seq[$mid]) {
243
+				$beg = $mid + 1;
244
+			} else {
245
+				$end = $mid;
246
+			}
247
+		}
248
+
249
+		assert($ypos != $this->seq[$end]);
250
+
251
+		$this->in_seq[$this->seq[$end]] = false;
252
+		$this->seq[$end] = $ypos;
253
+		$this->in_seq[$ypos] = 1;
254
+		return $end;
255
+	}
256
+
257
+	/**
258
+	 * Finds LCS of two sequences.
259
+	 *
260
+	 * The results are recorded in the vectors $this->{x,y}changed[], by
261
+	 * storing a 1 in the element for each line that is an insertion or
262
+	 * deletion (ie. is not in the LCS).
263
+	 *
264
+	 * The subsequence of file 0 is (XOFF, XLIM) and likewise for file 1.
265
+	 *
266
+	 * Note that XLIM, YLIM are exclusive bounds.  All line numbers are
267
+	 * origin-0 and discarded lines are not counted.
268
+	 */
269
+	function _compareseq ($xoff, $xlim, $yoff, $ylim)
270
+	{
271
+		/* Slide down the bottom initial diagonal. */
272
+		while ($xoff < $xlim && $yoff < $ylim
273
+			   && $this->xv[$xoff] == $this->yv[$yoff]) {
274
+			++$xoff;
275
+			++$yoff;
276
+		}
277
+
278
+		/* Slide up the top initial diagonal. */
279
+		while ($xlim > $xoff && $ylim > $yoff
280
+			   && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) {
281
+			--$xlim;
282
+			--$ylim;
283
+		}
284
+
285
+		if ($xoff == $xlim || $yoff == $ylim) {
286
+			$lcs = 0;
287
+		} else {
288
+			/* This is ad hoc but seems to work well.  $nchunks =
289 289
              * sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5); $nchunks =
290 290
              * max(2,min(8,(int)$nchunks)); */
291
-            $nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1;
292
-            list($lcs, $seps)
293
-                = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks);
294
-        }
291
+			$nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1;
292
+			list($lcs, $seps)
293
+				= $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks);
294
+		}
295 295
 
296
-        if ($lcs == 0) {
297
-            /* X and Y sequences have no common subsequence: mark all
296
+		if ($lcs == 0) {
297
+			/* X and Y sequences have no common subsequence: mark all
298 298
              * changed. */
299
-            while ($yoff < $ylim) {
300
-                $this->ychanged[$this->yind[$yoff++]] = 1;
301
-            }
302
-            while ($xoff < $xlim) {
303
-                $this->xchanged[$this->xind[$xoff++]] = 1;
304
-            }
305
-        } else {
306
-            /* Use the partitions to split this problem into subproblems. */
307
-            reset($seps);
308
-            $pt1 = $seps[0];
309
-            while ($pt2 = next($seps)) {
310
-                $this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]);
311
-                $pt1 = $pt2;
312
-            }
313
-        }
314
-    }
315
-
316
-    /**
317
-     * Adjusts inserts/deletes of identical lines to join changes as much as
318
-     * possible.
319
-     *
320
-     * We do something when a run of changed lines include a line at one end
321
-     * and has an excluded, identical line at the other.  We are free to
322
-     * choose which identical line is included.  `compareseq' usually chooses
323
-     * the one at the beginning, but usually it is cleaner to consider the
324
-     * following identical line to be the "change".
325
-     *
326
-     * This is extracted verbatim from analyze.c (GNU diffutils-2.7).
327
-     */
328
-    function _shiftBoundaries($lines, &$changed, $other_changed)
329
-    {
330
-        $i = 0;
331
-        $j = 0;
332
-
333
-        assert('count($lines) == count($changed)');
334
-        $len = count($lines);
335
-        $other_len = count($other_changed);
336
-
337
-        while (1) {
338
-            /* Scan forward to find the beginning of another run of
299
+			while ($yoff < $ylim) {
300
+				$this->ychanged[$this->yind[$yoff++]] = 1;
301
+			}
302
+			while ($xoff < $xlim) {
303
+				$this->xchanged[$this->xind[$xoff++]] = 1;
304
+			}
305
+		} else {
306
+			/* Use the partitions to split this problem into subproblems. */
307
+			reset($seps);
308
+			$pt1 = $seps[0];
309
+			while ($pt2 = next($seps)) {
310
+				$this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]);
311
+				$pt1 = $pt2;
312
+			}
313
+		}
314
+	}
315
+
316
+	/**
317
+	 * Adjusts inserts/deletes of identical lines to join changes as much as
318
+	 * possible.
319
+	 *
320
+	 * We do something when a run of changed lines include a line at one end
321
+	 * and has an excluded, identical line at the other.  We are free to
322
+	 * choose which identical line is included.  `compareseq' usually chooses
323
+	 * the one at the beginning, but usually it is cleaner to consider the
324
+	 * following identical line to be the "change".
325
+	 *
326
+	 * This is extracted verbatim from analyze.c (GNU diffutils-2.7).
327
+	 */
328
+	function _shiftBoundaries($lines, &$changed, $other_changed)
329
+	{
330
+		$i = 0;
331
+		$j = 0;
332
+
333
+		assert('count($lines) == count($changed)');
334
+		$len = count($lines);
335
+		$other_len = count($other_changed);
336
+
337
+		while (1) {
338
+			/* Scan forward to find the beginning of another run of
339 339
              * changes. Also keep track of the corresponding point in the
340 340
              * other file.
341 341
              *
@@ -346,91 +346,91 @@  discard block
 block discarded – undo
346 346
              *
347 347
              * Furthermore, $j is always kept so that $j == $other_len or
348 348
              * $other_changed[$j] == false. */
349
-            while ($j < $other_len && $other_changed[$j]) {
350
-                $j++;
351
-            }
352
-
353
-            while ($i < $len && ! $changed[$i]) {
354
-                assert('$j < $other_len && ! $other_changed[$j]');
355
-                $i++; $j++;
356
-                while ($j < $other_len && $other_changed[$j]) {
357
-                    $j++;
358
-                }
359
-            }
360
-
361
-            if ($i == $len) {
362
-                break;
363
-            }
364
-
365
-            $start = $i;
366
-
367
-            /* Find the end of this run of changes. */
368
-            while (++$i < $len && $changed[$i]) {
369
-                continue;
370
-            }
371
-
372
-            do {
373
-                /* Record the length of this run of changes, so that we can
349
+			while ($j < $other_len && $other_changed[$j]) {
350
+				$j++;
351
+			}
352
+
353
+			while ($i < $len && ! $changed[$i]) {
354
+				assert('$j < $other_len && ! $other_changed[$j]');
355
+				$i++; $j++;
356
+				while ($j < $other_len && $other_changed[$j]) {
357
+					$j++;
358
+				}
359
+			}
360
+
361
+			if ($i == $len) {
362
+				break;
363
+			}
364
+
365
+			$start = $i;
366
+
367
+			/* Find the end of this run of changes. */
368
+			while (++$i < $len && $changed[$i]) {
369
+				continue;
370
+			}
371
+
372
+			do {
373
+				/* Record the length of this run of changes, so that we can
374 374
                  * later determine whether the run has grown. */
375
-                $runlength = $i - $start;
375
+				$runlength = $i - $start;
376 376
 
377
-                /* Move the changed region back, so long as the previous
377
+				/* Move the changed region back, so long as the previous
378 378
                  * unchanged line matches the last changed one.  This merges
379 379
                  * with previous changed regions. */
380
-                while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) {
381
-                    $changed[--$start] = 1;
382
-                    $changed[--$i] = false;
383
-                    while ($start > 0 && $changed[$start - 1]) {
384
-                        $start--;
385
-                    }
386
-                    assert('$j > 0');
387
-                    while ($other_changed[--$j]) {
388
-                        continue;
389
-                    }
390
-                    assert('$j >= 0 && !$other_changed[$j]');
391
-                }
392
-
393
-                /* Set CORRESPONDING to the end of the changed run, at the
380
+				while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) {
381
+					$changed[--$start] = 1;
382
+					$changed[--$i] = false;
383
+					while ($start > 0 && $changed[$start - 1]) {
384
+						$start--;
385
+					}
386
+					assert('$j > 0');
387
+					while ($other_changed[--$j]) {
388
+						continue;
389
+					}
390
+					assert('$j >= 0 && !$other_changed[$j]');
391
+				}
392
+
393
+				/* Set CORRESPONDING to the end of the changed run, at the
394 394
                  * last point where it corresponds to a changed run in the
395 395
                  * other file. CORRESPONDING == LEN means no such point has
396 396
                  * been found. */
397
-                $corresponding = $j < $other_len ? $i : $len;
397
+				$corresponding = $j < $other_len ? $i : $len;
398 398
 
399
-                /* Move the changed region forward, so long as the first
399
+				/* Move the changed region forward, so long as the first
400 400
                  * changed line matches the following unchanged one.  This
401 401
                  * merges with following changed regions.  Do this second, so
402 402
                  * that if there are no merges, the changed region is moved
403 403
                  * forward as far as possible. */
404
-                while ($i < $len && $lines[$start] == $lines[$i]) {
405
-                    $changed[$start++] = false;
406
-                    $changed[$i++] = 1;
407
-                    while ($i < $len && $changed[$i]) {
408
-                        $i++;
409
-                    }
410
-
411
-                    assert('$j < $other_len && ! $other_changed[$j]');
412
-                    $j++;
413
-                    if ($j < $other_len && $other_changed[$j]) {
414
-                        $corresponding = $i;
415
-                        while ($j < $other_len && $other_changed[$j]) {
416
-                            $j++;
417
-                        }
418
-                    }
419
-                }
420
-            } while ($runlength != $i - $start);
421
-
422
-            /* If possible, move the fully-merged run of changes back to a
404
+				while ($i < $len && $lines[$start] == $lines[$i]) {
405
+					$changed[$start++] = false;
406
+					$changed[$i++] = 1;
407
+					while ($i < $len && $changed[$i]) {
408
+						$i++;
409
+					}
410
+
411
+					assert('$j < $other_len && ! $other_changed[$j]');
412
+					$j++;
413
+					if ($j < $other_len && $other_changed[$j]) {
414
+						$corresponding = $i;
415
+						while ($j < $other_len && $other_changed[$j]) {
416
+							$j++;
417
+						}
418
+					}
419
+				}
420
+			} while ($runlength != $i - $start);
421
+
422
+			/* If possible, move the fully-merged run of changes back to a
423 423
              * corresponding run in the other file. */
424
-            while ($corresponding < $i) {
425
-                $changed[--$start] = 1;
426
-                $changed[--$i] = 0;
427
-                assert('$j > 0');
428
-                while ($other_changed[--$j]) {
429
-                    continue;
430
-                }
431
-                assert('$j >= 0 && !$other_changed[$j]');
432
-            }
433
-        }
434
-    }
424
+			while ($corresponding < $i) {
425
+				$changed[--$start] = 1;
426
+				$changed[--$i] = 0;
427
+				assert('$j > 0');
428
+				while ($other_changed[--$j]) {
429
+					continue;
430
+				}
431
+				assert('$j >= 0 && !$other_changed[$j]');
432
+			}
433
+		}
434
+	}
435 435
 
436 436
 }
Please login to merge, or discard this patch.
src/wp-includes/Text/Diff/Renderer.php 4 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -148,6 +148,12 @@  discard block
 block discarded – undo
148 148
         return $output . $this->_endDiff();
149 149
     }
150 150
 
151
+    /**
152
+     * @param integer $xbeg
153
+     * @param integer $xlen
154
+     * @param integer $ybeg
155
+     * @param integer $ylen
156
+     */
151 157
     function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
152 158
     {
153 159
         $output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
@@ -204,6 +210,9 @@  discard block
 block discarded – undo
204 210
         return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
205 211
     }
206 212
 
213
+    /**
214
+     * @param string $header
215
+     */
207 216
     function _startBlock($header)
208 217
     {
209 218
         return $header . "\n";
Please login to merge, or discard this patch.
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -14,34 +14,34 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class Text_Diff_Renderer {
16 16
 
17
-    /**
18
-     * Number of leading context "lines" to preserve.
19
-     *
20
-     * This should be left at zero for this class, but subclasses may want to
21
-     * set this to other values.
22
-     */
23
-    var $_leading_context_lines = 0;
24
-
25
-    /**
26
-     * Number of trailing context "lines" to preserve.
27
-     *
28
-     * This should be left at zero for this class, but subclasses may want to
29
-     * set this to other values.
30
-     */
31
-    var $_trailing_context_lines = 0;
32
-
33
-    /**
34
-     * Constructor.
35
-     */
36
-    function __construct( $params = array() )
37
-    {
38
-        foreach ($params as $param => $value) {
39
-            $v = '_' . $param;
40
-            if (isset($this->$v)) {
41
-                $this->$v = $value;
42
-            }
43
-        }
44
-    }
17
+	/**
18
+	 * Number of leading context "lines" to preserve.
19
+	 *
20
+	 * This should be left at zero for this class, but subclasses may want to
21
+	 * set this to other values.
22
+	 */
23
+	var $_leading_context_lines = 0;
24
+
25
+	/**
26
+	 * Number of trailing context "lines" to preserve.
27
+	 *
28
+	 * This should be left at zero for this class, but subclasses may want to
29
+	 * set this to other values.
30
+	 */
31
+	var $_trailing_context_lines = 0;
32
+
33
+	/**
34
+	 * Constructor.
35
+	 */
36
+	function __construct( $params = array() )
37
+	{
38
+		foreach ($params as $param => $value) {
39
+			$v = '_' . $param;
40
+			if (isset($this->$v)) {
41
+				$this->$v = $value;
42
+			}
43
+		}
44
+	}
45 45
 
46 46
 	/**
47 47
 	 * PHP4 constructor.
@@ -50,193 +50,193 @@  discard block
 block discarded – undo
50 50
 		self::__construct( $params );
51 51
 	}
52 52
 
53
-    /**
54
-     * Get any renderer parameters.
55
-     *
56
-     * @return array  All parameters of this renderer object.
57
-     */
58
-    function getParams()
59
-    {
60
-        $params = array();
61
-        foreach (get_object_vars($this) as $k => $v) {
62
-            if ($k[0] == '_') {
63
-                $params[substr($k, 1)] = $v;
64
-            }
65
-        }
66
-
67
-        return $params;
68
-    }
69
-
70
-    /**
71
-     * Renders a diff.
72
-     *
73
-     * @param Text_Diff $diff  A Text_Diff object.
74
-     *
75
-     * @return string  The formatted output.
76
-     */
77
-    function render($diff)
78
-    {
79
-        $xi = $yi = 1;
80
-        $block = false;
81
-        $context = array();
82
-
83
-        $nlead = $this->_leading_context_lines;
84
-        $ntrail = $this->_trailing_context_lines;
85
-
86
-        $output = $this->_startDiff();
87
-
88
-        $diffs = $diff->getDiff();
89
-        foreach ($diffs as $i => $edit) {
90
-            /* If these are unchanged (copied) lines, and we want to keep
53
+	/**
54
+	 * Get any renderer parameters.
55
+	 *
56
+	 * @return array  All parameters of this renderer object.
57
+	 */
58
+	function getParams()
59
+	{
60
+		$params = array();
61
+		foreach (get_object_vars($this) as $k => $v) {
62
+			if ($k[0] == '_') {
63
+				$params[substr($k, 1)] = $v;
64
+			}
65
+		}
66
+
67
+		return $params;
68
+	}
69
+
70
+	/**
71
+	 * Renders a diff.
72
+	 *
73
+	 * @param Text_Diff $diff  A Text_Diff object.
74
+	 *
75
+	 * @return string  The formatted output.
76
+	 */
77
+	function render($diff)
78
+	{
79
+		$xi = $yi = 1;
80
+		$block = false;
81
+		$context = array();
82
+
83
+		$nlead = $this->_leading_context_lines;
84
+		$ntrail = $this->_trailing_context_lines;
85
+
86
+		$output = $this->_startDiff();
87
+
88
+		$diffs = $diff->getDiff();
89
+		foreach ($diffs as $i => $edit) {
90
+			/* If these are unchanged (copied) lines, and we want to keep
91 91
              * leading or trailing context lines, extract them from the copy
92 92
              * block. */
93
-            if (is_a($edit, 'Text_Diff_Op_copy')) {
94
-                /* Do we have any diff blocks yet? */
95
-                if (is_array($block)) {
96
-                    /* How many lines to keep as context from the copy
93
+			if (is_a($edit, 'Text_Diff_Op_copy')) {
94
+				/* Do we have any diff blocks yet? */
95
+				if (is_array($block)) {
96
+					/* How many lines to keep as context from the copy
97 97
                      * block. */
98
-                    $keep = $i == count($diffs) - 1 ? $ntrail : $nlead + $ntrail;
99
-                    if (count($edit->orig) <= $keep) {
100
-                        /* We have less lines in the block than we want for
98
+					$keep = $i == count($diffs) - 1 ? $ntrail : $nlead + $ntrail;
99
+					if (count($edit->orig) <= $keep) {
100
+						/* We have less lines in the block than we want for
101 101
                          * context => keep the whole block. */
102
-                        $block[] = $edit;
103
-                    } else {
104
-                        if ($ntrail) {
105
-                            /* Create a new block with as many lines as we need
102
+						$block[] = $edit;
103
+					} else {
104
+						if ($ntrail) {
105
+							/* Create a new block with as many lines as we need
106 106
                              * for the trailing context. */
107
-                            $context = array_slice($edit->orig, 0, $ntrail);
108
-                            $block[] = new Text_Diff_Op_copy($context);
109
-                        }
110
-                        /* @todo */
111
-                        $output .= $this->_block($x0, $ntrail + $xi - $x0,
112
-                                                 $y0, $ntrail + $yi - $y0,
113
-                                                 $block);
114
-                        $block = false;
115
-                    }
116
-                }
117
-                /* Keep the copy block as the context for the next block. */
118
-                $context = $edit->orig;
119
-            } else {
120
-                /* Don't we have any diff blocks yet? */
121
-                if (!is_array($block)) {
122
-                    /* Extract context lines from the preceding copy block. */
123
-                    $context = array_slice($context, count($context) - $nlead);
124
-                    $x0 = $xi - count($context);
125
-                    $y0 = $yi - count($context);
126
-                    $block = array();
127
-                    if ($context) {
128
-                        $block[] = new Text_Diff_Op_copy($context);
129
-                    }
130
-                }
131
-                $block[] = $edit;
132
-            }
133
-
134
-            if ($edit->orig) {
135
-                $xi += count($edit->orig);
136
-            }
137
-            if ($edit->final) {
138
-                $yi += count($edit->final);
139
-            }
140
-        }
141
-
142
-        if (is_array($block)) {
143
-            $output .= $this->_block($x0, $xi - $x0,
144
-                                     $y0, $yi - $y0,
145
-                                     $block);
146
-        }
147
-
148
-        return $output . $this->_endDiff();
149
-    }
150
-
151
-    function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
152
-    {
153
-        $output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
154
-
155
-        foreach ($edits as $edit) {
156
-            switch (strtolower(get_class($edit))) {
157
-            case 'text_diff_op_copy':
158
-                $output .= $this->_context($edit->orig);
159
-                break;
160
-
161
-            case 'text_diff_op_add':
162
-                $output .= $this->_added($edit->final);
163
-                break;
164
-
165
-            case 'text_diff_op_delete':
166
-                $output .= $this->_deleted($edit->orig);
167
-                break;
168
-
169
-            case 'text_diff_op_change':
170
-                $output .= $this->_changed($edit->orig, $edit->final);
171
-                break;
172
-            }
173
-        }
174
-
175
-        return $output . $this->_endBlock();
176
-    }
177
-
178
-    function _startDiff()
179
-    {
180
-        return '';
181
-    }
182
-
183
-    function _endDiff()
184
-    {
185
-        return '';
186
-    }
187
-
188
-    function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
189
-    {
190
-        if ($xlen > 1) {
191
-            $xbeg .= ',' . ($xbeg + $xlen - 1);
192
-        }
193
-        if ($ylen > 1) {
194
-            $ybeg .= ',' . ($ybeg + $ylen - 1);
195
-        }
196
-
197
-        // this matches the GNU Diff behaviour
198
-        if ($xlen && !$ylen) {
199
-            $ybeg--;
200
-        } elseif (!$xlen) {
201
-            $xbeg--;
202
-        }
203
-
204
-        return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
205
-    }
206
-
207
-    function _startBlock($header)
208
-    {
209
-        return $header . "\n";
210
-    }
211
-
212
-    function _endBlock()
213
-    {
214
-        return '';
215
-    }
216
-
217
-    function _lines($lines, $prefix = ' ')
218
-    {
219
-        return $prefix . implode("\n$prefix", $lines) . "\n";
220
-    }
221
-
222
-    function _context($lines)
223
-    {
224
-        return $this->_lines($lines, '  ');
225
-    }
226
-
227
-    function _added($lines)
228
-    {
229
-        return $this->_lines($lines, '> ');
230
-    }
231
-
232
-    function _deleted($lines)
233
-    {
234
-        return $this->_lines($lines, '< ');
235
-    }
236
-
237
-    function _changed($orig, $final)
238
-    {
239
-        return $this->_deleted($orig) . "---\n" . $this->_added($final);
240
-    }
107
+							$context = array_slice($edit->orig, 0, $ntrail);
108
+							$block[] = new Text_Diff_Op_copy($context);
109
+						}
110
+						/* @todo */
111
+						$output .= $this->_block($x0, $ntrail + $xi - $x0,
112
+												 $y0, $ntrail + $yi - $y0,
113
+												 $block);
114
+						$block = false;
115
+					}
116
+				}
117
+				/* Keep the copy block as the context for the next block. */
118
+				$context = $edit->orig;
119
+			} else {
120
+				/* Don't we have any diff blocks yet? */
121
+				if (!is_array($block)) {
122
+					/* Extract context lines from the preceding copy block. */
123
+					$context = array_slice($context, count($context) - $nlead);
124
+					$x0 = $xi - count($context);
125
+					$y0 = $yi - count($context);
126
+					$block = array();
127
+					if ($context) {
128
+						$block[] = new Text_Diff_Op_copy($context);
129
+					}
130
+				}
131
+				$block[] = $edit;
132
+			}
133
+
134
+			if ($edit->orig) {
135
+				$xi += count($edit->orig);
136
+			}
137
+			if ($edit->final) {
138
+				$yi += count($edit->final);
139
+			}
140
+		}
141
+
142
+		if (is_array($block)) {
143
+			$output .= $this->_block($x0, $xi - $x0,
144
+									 $y0, $yi - $y0,
145
+									 $block);
146
+		}
147
+
148
+		return $output . $this->_endDiff();
149
+	}
150
+
151
+	function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
152
+	{
153
+		$output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
154
+
155
+		foreach ($edits as $edit) {
156
+			switch (strtolower(get_class($edit))) {
157
+			case 'text_diff_op_copy':
158
+				$output .= $this->_context($edit->orig);
159
+				break;
160
+
161
+			case 'text_diff_op_add':
162
+				$output .= $this->_added($edit->final);
163
+				break;
164
+
165
+			case 'text_diff_op_delete':
166
+				$output .= $this->_deleted($edit->orig);
167
+				break;
168
+
169
+			case 'text_diff_op_change':
170
+				$output .= $this->_changed($edit->orig, $edit->final);
171
+				break;
172
+			}
173
+		}
174
+
175
+		return $output . $this->_endBlock();
176
+	}
177
+
178
+	function _startDiff()
179
+	{
180
+		return '';
181
+	}
182
+
183
+	function _endDiff()
184
+	{
185
+		return '';
186
+	}
187
+
188
+	function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
189
+	{
190
+		if ($xlen > 1) {
191
+			$xbeg .= ',' . ($xbeg + $xlen - 1);
192
+		}
193
+		if ($ylen > 1) {
194
+			$ybeg .= ',' . ($ybeg + $ylen - 1);
195
+		}
196
+
197
+		// this matches the GNU Diff behaviour
198
+		if ($xlen && !$ylen) {
199
+			$ybeg--;
200
+		} elseif (!$xlen) {
201
+			$xbeg--;
202
+		}
203
+
204
+		return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
205
+	}
206
+
207
+	function _startBlock($header)
208
+	{
209
+		return $header . "\n";
210
+	}
211
+
212
+	function _endBlock()
213
+	{
214
+		return '';
215
+	}
216
+
217
+	function _lines($lines, $prefix = ' ')
218
+	{
219
+		return $prefix . implode("\n$prefix", $lines) . "\n";
220
+	}
221
+
222
+	function _context($lines)
223
+	{
224
+		return $this->_lines($lines, '  ');
225
+	}
226
+
227
+	function _added($lines)
228
+	{
229
+		return $this->_lines($lines, '> ');
230
+	}
231
+
232
+	function _deleted($lines)
233
+	{
234
+		return $this->_lines($lines, '< ');
235
+	}
236
+
237
+	function _changed($orig, $final)
238
+	{
239
+		return $this->_deleted($orig) . "---\n" . $this->_added($final);
240
+	}
241 241
 
242 242
 }
Please login to merge, or discard this patch.
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -154,21 +154,21 @@
 block discarded – undo
154 154
 
155 155
         foreach ($edits as $edit) {
156 156
             switch (strtolower(get_class($edit))) {
157
-            case 'text_diff_op_copy':
158
-                $output .= $this->_context($edit->orig);
159
-                break;
157
+            	case 'text_diff_op_copy':
158
+                	$output .= $this->_context($edit->orig);
159
+                	break;
160 160
 
161
-            case 'text_diff_op_add':
162
-                $output .= $this->_added($edit->final);
163
-                break;
161
+            	case 'text_diff_op_add':
162
+                	$output .= $this->_added($edit->final);
163
+                	break;
164 164
 
165
-            case 'text_diff_op_delete':
166
-                $output .= $this->_deleted($edit->orig);
167
-                break;
165
+            	case 'text_diff_op_delete':
166
+                	$output .= $this->_deleted($edit->orig);
167
+                	break;
168 168
 
169
-            case 'text_diff_op_change':
170
-                $output .= $this->_changed($edit->orig, $edit->final);
171
-                break;
169
+            	case 'text_diff_op_change':
170
+                	$output .= $this->_changed($edit->orig, $edit->final);
171
+                	break;
172 172
             }
173 173
         }
174 174
 
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
     /**
34 34
      * Constructor.
35 35
      */
36
-    function __construct( $params = array() )
36
+    function __construct($params = array())
37 37
     {
38 38
         foreach ($params as $param => $value) {
39
-            $v = '_' . $param;
39
+            $v = '_'.$param;
40 40
             if (isset($this->$v)) {
41 41
                 $this->$v = $value;
42 42
             }
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * PHP4 constructor.
48 48
 	 */
49
-	public function Text_Diff_Renderer( $params = array() ) {
50
-		self::__construct( $params );
49
+	public function Text_Diff_Renderer($params = array()) {
50
+		self::__construct($params);
51 51
 	}
52 52
 
53 53
     /**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                 $context = $edit->orig;
119 119
             } else {
120 120
                 /* Don't we have any diff blocks yet? */
121
-                if (!is_array($block)) {
121
+                if ( ! is_array($block)) {
122 122
                     /* Extract context lines from the preceding copy block. */
123 123
                     $context = array_slice($context, count($context) - $nlead);
124 124
                     $x0 = $xi - count($context);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                                      $block);
146 146
         }
147 147
 
148
-        return $output . $this->_endDiff();
148
+        return $output.$this->_endDiff();
149 149
     }
150 150
 
151 151
     function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
             }
173 173
         }
174 174
 
175
-        return $output . $this->_endBlock();
175
+        return $output.$this->_endBlock();
176 176
     }
177 177
 
178 178
     function _startDiff()
@@ -188,25 +188,25 @@  discard block
 block discarded – undo
188 188
     function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
189 189
     {
190 190
         if ($xlen > 1) {
191
-            $xbeg .= ',' . ($xbeg + $xlen - 1);
191
+            $xbeg .= ','.($xbeg + $xlen - 1);
192 192
         }
193 193
         if ($ylen > 1) {
194
-            $ybeg .= ',' . ($ybeg + $ylen - 1);
194
+            $ybeg .= ','.($ybeg + $ylen - 1);
195 195
         }
196 196
 
197 197
         // this matches the GNU Diff behaviour
198
-        if ($xlen && !$ylen) {
198
+        if ($xlen && ! $ylen) {
199 199
             $ybeg--;
200
-        } elseif (!$xlen) {
200
+        } elseif ( ! $xlen) {
201 201
             $xbeg--;
202 202
         }
203 203
 
204
-        return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
204
+        return $xbeg.($xlen ? ($ylen ? 'c' : 'd') : 'a').$ybeg;
205 205
     }
206 206
 
207 207
     function _startBlock($header)
208 208
     {
209
-        return $header . "\n";
209
+        return $header."\n";
210 210
     }
211 211
 
212 212
     function _endBlock()
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
     function _lines($lines, $prefix = ' ')
218 218
     {
219
-        return $prefix . implode("\n$prefix", $lines) . "\n";
219
+        return $prefix.implode("\n$prefix", $lines)."\n";
220 220
     }
221 221
 
222 222
     function _context($lines)
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
     function _changed($orig, $final)
238 238
     {
239
-        return $this->_deleted($orig) . "---\n" . $this->_added($final);
239
+        return $this->_deleted($orig)."---\n".$this->_added($final);
240 240
     }
241 241
 
242 242
 }
Please login to merge, or discard this patch.
src/wp-includes/Text/Diff/Renderer/inline.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -100,6 +100,9 @@  discard block
 block discarded – undo
100 100
         return $header;
101 101
     }
102 102
 
103
+    /**
104
+     * @param string[] $lines
105
+     */
103 106
     function _lines($lines, $prefix = ' ', $encode = true)
104 107
     {
105 108
         if ($encode) {
@@ -178,6 +181,9 @@  discard block
 block discarded – undo
178 181
         return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
179 182
     }
180 183
 
184
+    /**
185
+     * @param string $string
186
+     */
181 187
     function _splitOnWords($string, $newlineEscape = "\n")
182 188
     {
183 189
         // Ignore \0; otherwise the while loop will never finish.
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -26,181 +26,181 @@
 block discarded – undo
26 26
  */
27 27
 class Text_Diff_Renderer_inline extends Text_Diff_Renderer {
28 28
 
29
-    /**
30
-     * Number of leading context "lines" to preserve.
31
-     *
32
-     * @var integer
33
-     */
34
-    var $_leading_context_lines = 10000;
35
-
36
-    /**
37
-     * Number of trailing context "lines" to preserve.
38
-     *
39
-     * @var integer
40
-     */
41
-    var $_trailing_context_lines = 10000;
42
-
43
-    /**
44
-     * Prefix for inserted text.
45
-     *
46
-     * @var string
47
-     */
48
-    var $_ins_prefix = '<ins>';
49
-
50
-    /**
51
-     * Suffix for inserted text.
52
-     *
53
-     * @var string
54
-     */
55
-    var $_ins_suffix = '</ins>';
56
-
57
-    /**
58
-     * Prefix for deleted text.
59
-     *
60
-     * @var string
61
-     */
62
-    var $_del_prefix = '<del>';
63
-
64
-    /**
65
-     * Suffix for deleted text.
66
-     *
67
-     * @var string
68
-     */
69
-    var $_del_suffix = '</del>';
70
-
71
-    /**
72
-     * Header for each change block.
73
-     *
74
-     * @var string
75
-     */
76
-    var $_block_header = '';
77
-
78
-    /**
79
-     * Whether to split down to character-level.
80
-     *
81
-     * @var boolean
82
-     */
83
-    var $_split_characters = false;
84
-
85
-    /**
86
-     * What are we currently splitting on? Used to recurse to show word-level
87
-     * or character-level changes.
88
-     *
89
-     * @var string
90
-     */
91
-    var $_split_level = 'lines';
92
-
93
-    function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
94
-    {
95
-        return $this->_block_header;
96
-    }
97
-
98
-    function _startBlock($header)
99
-    {
100
-        return $header;
101
-    }
102
-
103
-    function _lines($lines, $prefix = ' ', $encode = true)
104
-    {
105
-        if ($encode) {
106
-            array_walk($lines, array(&$this, '_encode'));
107
-        }
108
-
109
-        if ($this->_split_level == 'lines') {
110
-            return implode("\n", $lines) . "\n";
111
-        } else {
112
-            return implode('', $lines);
113
-        }
114
-    }
115
-
116
-    function _added($lines)
117
-    {
118
-        array_walk($lines, array(&$this, '_encode'));
119
-        $lines[0] = $this->_ins_prefix . $lines[0];
120
-        $lines[count($lines) - 1] .= $this->_ins_suffix;
121
-        return $this->_lines($lines, ' ', false);
122
-    }
123
-
124
-    function _deleted($lines, $words = false)
125
-    {
126
-        array_walk($lines, array(&$this, '_encode'));
127
-        $lines[0] = $this->_del_prefix . $lines[0];
128
-        $lines[count($lines) - 1] .= $this->_del_suffix;
129
-        return $this->_lines($lines, ' ', false);
130
-    }
131
-
132
-    function _changed($orig, $final)
133
-    {
134
-        /* If we've already split on characters, just display. */
135
-        if ($this->_split_level == 'characters') {
136
-            return $this->_deleted($orig)
137
-                . $this->_added($final);
138
-        }
139
-
140
-        /* If we've already split on words, just display. */
141
-        if ($this->_split_level == 'words') {
142
-            $prefix = '';
143
-            while ($orig[0] !== false && $final[0] !== false &&
144
-                   substr($orig[0], 0, 1) == ' ' &&
145
-                   substr($final[0], 0, 1) == ' ') {
146
-                $prefix .= substr($orig[0], 0, 1);
147
-                $orig[0] = substr($orig[0], 1);
148
-                $final[0] = substr($final[0], 1);
149
-            }
150
-            return $prefix . $this->_deleted($orig) . $this->_added($final);
151
-        }
152
-
153
-        $text1 = implode("\n", $orig);
154
-        $text2 = implode("\n", $final);
155
-
156
-        /* Non-printing newline marker. */
157
-        $nl = "\0";
158
-
159
-        if ($this->_split_characters) {
160
-            $diff = new Text_Diff('native',
161
-                                  array(preg_split('//', $text1),
162
-                                        preg_split('//', $text2)));
163
-        } else {
164
-            /* We want to split on word boundaries, but we need to preserve
29
+	/**
30
+	 * Number of leading context "lines" to preserve.
31
+	 *
32
+	 * @var integer
33
+	 */
34
+	var $_leading_context_lines = 10000;
35
+
36
+	/**
37
+	 * Number of trailing context "lines" to preserve.
38
+	 *
39
+	 * @var integer
40
+	 */
41
+	var $_trailing_context_lines = 10000;
42
+
43
+	/**
44
+	 * Prefix for inserted text.
45
+	 *
46
+	 * @var string
47
+	 */
48
+	var $_ins_prefix = '<ins>';
49
+
50
+	/**
51
+	 * Suffix for inserted text.
52
+	 *
53
+	 * @var string
54
+	 */
55
+	var $_ins_suffix = '</ins>';
56
+
57
+	/**
58
+	 * Prefix for deleted text.
59
+	 *
60
+	 * @var string
61
+	 */
62
+	var $_del_prefix = '<del>';
63
+
64
+	/**
65
+	 * Suffix for deleted text.
66
+	 *
67
+	 * @var string
68
+	 */
69
+	var $_del_suffix = '</del>';
70
+
71
+	/**
72
+	 * Header for each change block.
73
+	 *
74
+	 * @var string
75
+	 */
76
+	var $_block_header = '';
77
+
78
+	/**
79
+	 * Whether to split down to character-level.
80
+	 *
81
+	 * @var boolean
82
+	 */
83
+	var $_split_characters = false;
84
+
85
+	/**
86
+	 * What are we currently splitting on? Used to recurse to show word-level
87
+	 * or character-level changes.
88
+	 *
89
+	 * @var string
90
+	 */
91
+	var $_split_level = 'lines';
92
+
93
+	function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
94
+	{
95
+		return $this->_block_header;
96
+	}
97
+
98
+	function _startBlock($header)
99
+	{
100
+		return $header;
101
+	}
102
+
103
+	function _lines($lines, $prefix = ' ', $encode = true)
104
+	{
105
+		if ($encode) {
106
+			array_walk($lines, array(&$this, '_encode'));
107
+		}
108
+
109
+		if ($this->_split_level == 'lines') {
110
+			return implode("\n", $lines) . "\n";
111
+		} else {
112
+			return implode('', $lines);
113
+		}
114
+	}
115
+
116
+	function _added($lines)
117
+	{
118
+		array_walk($lines, array(&$this, '_encode'));
119
+		$lines[0] = $this->_ins_prefix . $lines[0];
120
+		$lines[count($lines) - 1] .= $this->_ins_suffix;
121
+		return $this->_lines($lines, ' ', false);
122
+	}
123
+
124
+	function _deleted($lines, $words = false)
125
+	{
126
+		array_walk($lines, array(&$this, '_encode'));
127
+		$lines[0] = $this->_del_prefix . $lines[0];
128
+		$lines[count($lines) - 1] .= $this->_del_suffix;
129
+		return $this->_lines($lines, ' ', false);
130
+	}
131
+
132
+	function _changed($orig, $final)
133
+	{
134
+		/* If we've already split on characters, just display. */
135
+		if ($this->_split_level == 'characters') {
136
+			return $this->_deleted($orig)
137
+				. $this->_added($final);
138
+		}
139
+
140
+		/* If we've already split on words, just display. */
141
+		if ($this->_split_level == 'words') {
142
+			$prefix = '';
143
+			while ($orig[0] !== false && $final[0] !== false &&
144
+				   substr($orig[0], 0, 1) == ' ' &&
145
+				   substr($final[0], 0, 1) == ' ') {
146
+				$prefix .= substr($orig[0], 0, 1);
147
+				$orig[0] = substr($orig[0], 1);
148
+				$final[0] = substr($final[0], 1);
149
+			}
150
+			return $prefix . $this->_deleted($orig) . $this->_added($final);
151
+		}
152
+
153
+		$text1 = implode("\n", $orig);
154
+		$text2 = implode("\n", $final);
155
+
156
+		/* Non-printing newline marker. */
157
+		$nl = "\0";
158
+
159
+		if ($this->_split_characters) {
160
+			$diff = new Text_Diff('native',
161
+								  array(preg_split('//', $text1),
162
+										preg_split('//', $text2)));
163
+		} else {
164
+			/* We want to split on word boundaries, but we need to preserve
165 165
              * whitespace as well. Therefore we split on words, but include
166 166
              * all blocks of whitespace in the wordlist. */
167
-            $diff = new Text_Diff('native',
168
-                                  array($this->_splitOnWords($text1, $nl),
169
-                                        $this->_splitOnWords($text2, $nl)));
170
-        }
171
-
172
-        /* Get the diff in inline format. */
173
-        $renderer = new Text_Diff_Renderer_inline
174
-            (array_merge($this->getParams(),
175
-                         array('split_level' => $this->_split_characters ? 'characters' : 'words')));
176
-
177
-        /* Run the diff and get the output. */
178
-        return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
179
-    }
180
-
181
-    function _splitOnWords($string, $newlineEscape = "\n")
182
-    {
183
-        // Ignore \0; otherwise the while loop will never finish.
184
-        $string = str_replace("\0", '', $string);
185
-
186
-        $words = array();
187
-        $length = strlen($string);
188
-        $pos = 0;
189
-
190
-        while ($pos < $length) {
191
-            // Eat a word with any preceding whitespace.
192
-            $spaces = strspn(substr($string, $pos), " \n");
193
-            $nextpos = strcspn(substr($string, $pos + $spaces), " \n");
194
-            $words[] = str_replace("\n", $newlineEscape, substr($string, $pos, $spaces + $nextpos));
195
-            $pos += $spaces + $nextpos;
196
-        }
197
-
198
-        return $words;
199
-    }
200
-
201
-    function _encode(&$string)
202
-    {
203
-        $string = htmlspecialchars($string);
204
-    }
167
+			$diff = new Text_Diff('native',
168
+								  array($this->_splitOnWords($text1, $nl),
169
+										$this->_splitOnWords($text2, $nl)));
170
+		}
171
+
172
+		/* Get the diff in inline format. */
173
+		$renderer = new Text_Diff_Renderer_inline
174
+			(array_merge($this->getParams(),
175
+						 array('split_level' => $this->_split_characters ? 'characters' : 'words')));
176
+
177
+		/* Run the diff and get the output. */
178
+		return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
179
+	}
180
+
181
+	function _splitOnWords($string, $newlineEscape = "\n")
182
+	{
183
+		// Ignore \0; otherwise the while loop will never finish.
184
+		$string = str_replace("\0", '', $string);
185
+
186
+		$words = array();
187
+		$length = strlen($string);
188
+		$pos = 0;
189
+
190
+		while ($pos < $length) {
191
+			// Eat a word with any preceding whitespace.
192
+			$spaces = strspn(substr($string, $pos), " \n");
193
+			$nextpos = strcspn(substr($string, $pos + $spaces), " \n");
194
+			$words[] = str_replace("\n", $newlineEscape, substr($string, $pos, $spaces + $nextpos));
195
+			$pos += $spaces + $nextpos;
196
+		}
197
+
198
+		return $words;
199
+	}
200
+
201
+	function _encode(&$string)
202
+	{
203
+		$string = htmlspecialchars($string);
204
+	}
205 205
 
206 206
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 /** Text_Diff_Renderer */
15 15
 
16 16
 // WP #7391
17
-require_once dirname(dirname(__FILE__)) . '/Renderer.php';
17
+require_once dirname(dirname(__FILE__)).'/Renderer.php';
18 18
 
19 19
 /**
20 20
  * "Inline" diff renderer.
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         }
108 108
 
109 109
         if ($this->_split_level == 'lines') {
110
-            return implode("\n", $lines) . "\n";
110
+            return implode("\n", $lines)."\n";
111 111
         } else {
112 112
             return implode('', $lines);
113 113
         }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     function _added($lines)
117 117
     {
118 118
         array_walk($lines, array(&$this, '_encode'));
119
-        $lines[0] = $this->_ins_prefix . $lines[0];
119
+        $lines[0] = $this->_ins_prefix.$lines[0];
120 120
         $lines[count($lines) - 1] .= $this->_ins_suffix;
121 121
         return $this->_lines($lines, ' ', false);
122 122
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     function _deleted($lines, $words = false)
125 125
     {
126 126
         array_walk($lines, array(&$this, '_encode'));
127
-        $lines[0] = $this->_del_prefix . $lines[0];
127
+        $lines[0] = $this->_del_prefix.$lines[0];
128 128
         $lines[count($lines) - 1] .= $this->_del_suffix;
129 129
         return $this->_lines($lines, ' ', false);
130 130
     }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                 $orig[0] = substr($orig[0], 1);
148 148
                 $final[0] = substr($final[0], 1);
149 149
             }
150
-            return $prefix . $this->_deleted($orig) . $this->_added($final);
150
+            return $prefix.$this->_deleted($orig).$this->_added($final);
151 151
         }
152 152
 
153 153
         $text1 = implode("\n", $orig);
@@ -170,12 +170,11 @@  discard block
 block discarded – undo
170 170
         }
171 171
 
172 172
         /* Get the diff in inline format. */
173
-        $renderer = new Text_Diff_Renderer_inline
174
-            (array_merge($this->getParams(),
173
+        $renderer = new Text_Diff_Renderer_inline(array_merge($this->getParams(),
175 174
                          array('split_level' => $this->_split_characters ? 'characters' : 'words')));
176 175
 
177 176
         /* Run the diff and get the output. */
178
-        return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
177
+        return str_replace($nl, "\n", $renderer->render($diff))."\n";
179 178
     }
180 179
 
181 180
     function _splitOnWords($string, $newlineEscape = "\n")
Please login to merge, or discard this patch.
src/wp-trackback.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
  *
21 21
  * @since 0.71
22 22
  *
23
- * @param mixed  $error         Whether there was an error.
23
+ * @param integer  $error         Whether there was an error.
24 24
  *                              Default '0'. Accepts '0' or '1', true or false.
25 25
  * @param string $error_message Error message if an error occurred.
26 26
  */
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -92,17 +92,17 @@
 block discarded – undo
92 92
 
93 93
 if ( !empty($tb_url) && !empty($title) ) {
94 94
 	/**
95
-	* Fires before the trackback is added to a post.
96
-	*
97
-	* @since 4.7.0
98
-	*
99
-	* @param int    $tb_id     Post ID related to the trackback.
100
-	* @param string $tb_url    Trackback URL.
101
-	* @param string $charset   Character Set.
102
-	* @param string $title     Trackback Title.
103
-	* @param string $excerpt   Trackback Excerpt.
104
-	* @param string $blog_name Blog Name.
105
-	*/
95
+	 * Fires before the trackback is added to a post.
96
+	 *
97
+	 * @since 4.7.0
98
+	 *
99
+	 * @param int    $tb_id     Post ID related to the trackback.
100
+	 * @param string $tb_url    Trackback URL.
101
+	 * @param string $charset   Character Set.
102
+	 * @param string $title     Trackback Title.
103
+	 * @param string $excerpt   Trackback Excerpt.
104
+	 * @param string $blog_name Blog Name.
105
+	 */
106 106
 	do_action( 'pre_trackback_post', $tb_id, $tb_url, $charset, $title, $excerpt, $blog_name );
107 107
 
108 108
 	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 if (empty($wp)) {
12
-	require_once( dirname( __FILE__ ) . '/wp-load.php' );
13
-	wp( array( 'tb' => '1' ) );
12
+	require_once(dirname(__FILE__).'/wp-load.php');
13
+	wp(array('tb' => '1'));
14 14
 }
15 15
 
16 16
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @param string $error_message Error message if an error occurred.
26 26
  */
27 27
 function trackback_response($error = 0, $error_message = '') {
28
-	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
28
+	header('Content-Type: text/xml; charset='.get_option('blog_charset'));
29 29
 	if ($error) {
30 30
 		echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
31 31
 		echo "<response>\n";
@@ -44,30 +44,30 @@  discard block
 block discarded – undo
44 44
 // Trackback is done by a POST.
45 45
 $request_array = 'HTTP_POST_VARS';
46 46
 
47
-if ( !isset($_GET['tb_id']) || !$_GET['tb_id'] ) {
47
+if ( ! isset($_GET['tb_id']) || ! $_GET['tb_id']) {
48 48
 	$tb_id = explode('/', $_SERVER['REQUEST_URI']);
49
-	$tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
49
+	$tb_id = intval($tb_id[count($tb_id) - 1]);
50 50
 }
51 51
 
52
-$tb_url  = isset($_POST['url'])     ? $_POST['url']     : '';
52
+$tb_url  = isset($_POST['url']) ? $_POST['url'] : '';
53 53
 $charset = isset($_POST['charset']) ? $_POST['charset'] : '';
54 54
 
55 55
 // These three are stripslashed here so they can be properly escaped after mb_convert_encoding().
56
-$title     = isset($_POST['title'])     ? wp_unslash($_POST['title'])      : '';
57
-$excerpt   = isset($_POST['excerpt'])   ? wp_unslash($_POST['excerpt'])    : '';
58
-$blog_name = isset($_POST['blog_name']) ? wp_unslash($_POST['blog_name'])  : '';
56
+$title     = isset($_POST['title']) ? wp_unslash($_POST['title']) : '';
57
+$excerpt   = isset($_POST['excerpt']) ? wp_unslash($_POST['excerpt']) : '';
58
+$blog_name = isset($_POST['blog_name']) ? wp_unslash($_POST['blog_name']) : '';
59 59
 
60 60
 if ($charset)
61
-	$charset = str_replace( array(',', ' '), '', strtoupper( trim($charset) ) );
61
+	$charset = str_replace(array(',', ' '), '', strtoupper(trim($charset)));
62 62
 else
63 63
 	$charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
64 64
 
65 65
 // No valid uses for UTF-7.
66
-if ( false !== strpos($charset, 'UTF-7') )
66
+if (false !== strpos($charset, 'UTF-7'))
67 67
 	die;
68 68
 
69 69
 // For international trackbacks.
70
-if ( function_exists('mb_convert_encoding') ) {
70
+if (function_exists('mb_convert_encoding')) {
71 71
 	$title     = mb_convert_encoding($title, get_option('blog_charset'), $charset);
72 72
 	$excerpt   = mb_convert_encoding($excerpt, get_option('blog_charset'), $charset);
73 73
 	$blog_name = mb_convert_encoding($blog_name, get_option('blog_charset'), $charset);
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 $excerpt   = wp_slash($excerpt);
79 79
 $blog_name = wp_slash($blog_name);
80 80
 
81
-if ( is_single() || is_page() )
81
+if (is_single() || is_page())
82 82
 	$tb_id = $posts[0]->ID;
83 83
 
84
-if ( !isset($tb_id) || !intval( $tb_id ) )
85
-	trackback_response( 1, __( 'I really need an ID for this to work.' ) );
84
+if ( ! isset($tb_id) || ! intval($tb_id))
85
+	trackback_response(1, __('I really need an ID for this to work.'));
86 86
 
87 87
 if (empty($title) && empty($tb_url) && empty($blog_name)) {
88 88
 	// If it doesn't look like a trackback at all.
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	exit;
91 91
 }
92 92
 
93
-if ( !empty($tb_url) && !empty($title) ) {
93
+if ( ! empty($tb_url) && ! empty($title)) {
94 94
 	/**
95 95
 	* Fires before the trackback is added to a post.
96 96
 	*
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
 	* @param string $excerpt   Trackback Excerpt.
104 104
 	* @param string $blog_name Blog Name.
105 105
 	*/
106
-	do_action( 'pre_trackback_post', $tb_id, $tb_url, $charset, $title, $excerpt, $blog_name );
106
+	do_action('pre_trackback_post', $tb_id, $tb_url, $charset, $title, $excerpt, $blog_name);
107 107
 
108
-	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
108
+	header('Content-Type: text/xml; charset='.get_option('blog_charset'));
109 109
 
110
-	if ( !pings_open($tb_id) )
111
-		trackback_response( 1, __( 'Sorry, trackbacks are closed for this item.' ) );
110
+	if ( ! pings_open($tb_id))
111
+		trackback_response(1, __('Sorry, trackbacks are closed for this item.'));
112 112
 
113
-	$title =  wp_html_excerpt( $title, 250, '&#8230;' );
114
-	$excerpt = wp_html_excerpt( $excerpt, 252, '&#8230;' );
113
+	$title = wp_html_excerpt($title, 250, '&#8230;');
114
+	$excerpt = wp_html_excerpt($excerpt, 252, '&#8230;');
115 115
 
116 116
 	$comment_post_ID = (int) $tb_id;
117 117
 	$comment_author = $blog_name;
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 	$comment_content = "<strong>$title</strong>\n\n$excerpt";
121 121
 	$comment_type = 'trackback';
122 122
 
123
-	$dupe = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url) );
124
-	if ( $dupe )
125
-		trackback_response( 1, __( 'We already have a ping from that URL for this post.' ) );
123
+	$dupe = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url));
124
+	if ($dupe)
125
+		trackback_response(1, __('We already have a ping from that URL for this post.'));
126 126
 
127 127
 	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
128 128
 
@@ -136,6 +136,6 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @param int $trackback_id Trackback ID.
138 138
 	 */
139
-	do_action( 'trackback_post', $trackback_id );
140
-	trackback_response( 0 );
139
+	do_action('trackback_post', $trackback_id);
140
+	trackback_response(0);
141 141
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -9 removed lines patch added patch discarded remove patch
@@ -57,14 +57,16 @@  discard block
 block discarded – undo
57 57
 $excerpt   = isset($_POST['excerpt'])   ? wp_unslash($_POST['excerpt'])    : '';
58 58
 $blog_name = isset($_POST['blog_name']) ? wp_unslash($_POST['blog_name'])  : '';
59 59
 
60
-if ($charset)
60
+if ($charset) {
61 61
 	$charset = str_replace( array(',', ' '), '', strtoupper( trim($charset) ) );
62
-else
62
+} else {
63 63
 	$charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
64
+}
64 65
 
65 66
 // No valid uses for UTF-7.
66
-if ( false !== strpos($charset, 'UTF-7') )
67
+if ( false !== strpos($charset, 'UTF-7') ) {
67 68
 	die;
69
+}
68 70
 
69 71
 // For international trackbacks.
70 72
 if ( function_exists('mb_convert_encoding') ) {
@@ -78,11 +80,13 @@  discard block
 block discarded – undo
78 80
 $excerpt   = wp_slash($excerpt);
79 81
 $blog_name = wp_slash($blog_name);
80 82
 
81
-if ( is_single() || is_page() )
83
+if ( is_single() || is_page() ) {
82 84
 	$tb_id = $posts[0]->ID;
85
+}
83 86
 
84
-if ( !isset($tb_id) || !intval( $tb_id ) )
87
+if ( !isset($tb_id) || !intval( $tb_id ) ) {
85 88
 	trackback_response( 1, __( 'I really need an ID for this to work.' ) );
89
+}
86 90
 
87 91
 if (empty($title) && empty($tb_url) && empty($blog_name)) {
88 92
 	// If it doesn't look like a trackback at all.
@@ -107,8 +111,9 @@  discard block
 block discarded – undo
107 111
 
108 112
 	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
109 113
 
110
-	if ( !pings_open($tb_id) )
111
-		trackback_response( 1, __( 'Sorry, trackbacks are closed for this item.' ) );
114
+	if ( !pings_open($tb_id) ) {
115
+			trackback_response( 1, __( 'Sorry, trackbacks are closed for this item.' ) );
116
+	}
112 117
 
113 118
 	$title =  wp_html_excerpt( $title, 250, '&#8230;' );
114 119
 	$excerpt = wp_html_excerpt( $excerpt, 252, '&#8230;' );
@@ -121,8 +126,9 @@  discard block
 block discarded – undo
121 126
 	$comment_type = 'trackback';
122 127
 
123 128
 	$dupe = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url) );
124
-	if ( $dupe )
125
-		trackback_response( 1, __( 'We already have a ping from that URL for this post.' ) );
129
+	if ( $dupe ) {
130
+			trackback_response( 1, __( 'We already have a ping from that URL for this post.' ) );
131
+	}
126 132
 
127 133
 	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
128 134
 
Please login to merge, or discard this patch.
tools/i18n/extract.php 4 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -40,11 +40,17 @@  discard block
 block discarded – undo
40 40
 		return $translations;
41 41
 	}
42 42
 
43
+	/**
44
+	 * @param string $prefix
45
+	 */
43 46
 	function extract_from_file( $file_name, $prefix ) {
44 47
 		$code = file_get_contents( $file_name );
45 48
 		return $this->extract_from_code( $code, $prefix . $file_name );
46 49
 	}
47 50
 
51
+	/**
52
+	 * @param string $path
53
+	 */
48 54
 	function does_file_name_match( $path, $excludes, $includes ) {
49 55
 		if ( $includes ) {
50 56
 			$matched_any_include = false;
@@ -128,6 +134,10 @@  discard block
 block discarded – undo
128 134
 		return $entry;
129 135
 	}
130 136
 
137
+	/**
138
+	 * @param string $code
139
+	 * @param string $file_name
140
+	 */
131 141
 	function extract_from_code( $code, $file_name ) {
132 142
 		$translations = new Translations;
133 143
 		$function_calls = $this->find_function_calls( array_keys( $this->rules ), $code );
Please login to merge, or discard this patch.
Switch Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -75,35 +75,35 @@
 block discarded – undo
75 75
 		for( $i = 0; $i < count( $rule ); ++$i ) {
76 76
 			if ( $rule[$i] && ( !isset( $call['args'][$i] ) || !is_string( $call['args'][$i] ) || '' == $call['args'][$i] ) ) return false;
77 77
 			switch( $rule[$i] ) {
78
-			case 'string':
79
-				if ( $complete ) {
80
-					$multiple[] = $entry;
81
-					$entry = new Translation_Entry;
82
-					$complete = false;
83
-				}
84
-				$entry->singular = $call['args'][$i];
85
-				$complete = true;
86
-				break;
87
-			case 'singular':
88
-				if ( $complete ) {
89
-					$multiple[] = $entry;
90
-					$entry = new Translation_Entry;
91
-					$complete = false;
92
-				}
93
-				$entry->singular = $call['args'][$i];
94
-				$entry->is_plural = true;
95
-				break;
96
-			case 'plural':
97
-				$entry->plural = $call['args'][$i];
98
-				$entry->is_plural = true;
99
-				$complete = true;
100
-				break;
101
-			case 'context':
102
-				$entry->context = $call['args'][$i];
103
-				foreach( $multiple as &$single_entry ) {
104
-					$single_entry->context = $entry->context;
105
-				}
106
-				break;
78
+				case 'string':
79
+					if ( $complete ) {
80
+						$multiple[] = $entry;
81
+						$entry = new Translation_Entry;
82
+						$complete = false;
83
+					}
84
+					$entry->singular = $call['args'][$i];
85
+					$complete = true;
86
+					break;
87
+				case 'singular':
88
+					if ( $complete ) {
89
+						$multiple[] = $entry;
90
+						$entry = new Translation_Entry;
91
+						$complete = false;
92
+					}
93
+					$entry->singular = $call['args'][$i];
94
+					$entry->is_plural = true;
95
+					break;
96
+				case 'plural':
97
+					$entry->plural = $call['args'][$i];
98
+					$entry->is_plural = true;
99
+					$complete = true;
100
+					break;
101
+				case 'context':
102
+					$entry->context = $call['args'][$i];
103
+					foreach( $multiple as &$single_entry ) {
104
+						$single_entry->context = $entry->context;
105
+					}
106
+					break;
107 107
 			}
108 108
 		}
109 109
 		if ( isset( $call['line'] ) && $call['line'] ) {
Please login to merge, or discard this patch.
Braces   +29 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		$translations = new Translations;
27 27
 		$file_names = (array) scandir( '.' );
28 28
 		foreach ( $file_names as $file_name ) {
29
-			if ( '.' == $file_name || '..' == $file_name ) continue;
29
+			if ( '.' == $file_name || '..' == $file_name ) {
30
+				continue;
31
+			}
30 32
 			if ( preg_match( '/\.php$/', $file_name ) && $this->does_file_name_match( $prefix . $file_name, $excludes, $includes ) ) {
31 33
 				$extracted = $this->extract_from_file( $file_name, $prefix );
32 34
 				$translations->merge_originals_with( $extracted );
@@ -54,7 +56,9 @@  discard block
 block discarded – undo
54 56
 					break;
55 57
 				}
56 58
 			}
57
-			if ( !$matched_any_include ) return false;
59
+			if ( !$matched_any_include ) {
60
+				return false;
61
+			}
58 62
 		}
59 63
 		if ( $excludes ) {
60 64
 			foreach( $excludes as $exclude ) {
@@ -68,12 +72,16 @@  discard block
 block discarded – undo
68 72
 
69 73
 	function entry_from_call( $call, $file_name ) {
70 74
 		$rule = isset( $this->rules[$call['name']] )? $this->rules[$call['name']] : null;
71
-		if ( !$rule ) return null;
75
+		if ( !$rule ) {
76
+			return null;
77
+		}
72 78
 		$entry = new Translation_Entry;
73 79
 		$multiple = array();
74 80
 		$complete = false;
75 81
 		for( $i = 0; $i < count( $rule ); ++$i ) {
76
-			if ( $rule[$i] && ( !isset( $call['args'][$i] ) || !is_string( $call['args'][$i] ) || '' == $call['args'][$i] ) ) return false;
82
+			if ( $rule[$i] && ( !isset( $call['args'][$i] ) || !is_string( $call['args'][$i] ) || '' == $call['args'][$i] ) ) {
83
+				return false;
84
+			}
77 85
 			switch( $rule[$i] ) {
78 86
 			case 'string':
79 87
 				if ( $complete ) {
@@ -133,11 +141,12 @@  discard block
 block discarded – undo
133 141
 		$function_calls = $this->find_function_calls( array_keys( $this->rules ), $code );
134 142
 		foreach( $function_calls as $call ) {
135 143
 			$entry = $this->entry_from_call( $call, $file_name );
136
-			if ( is_array( $entry ) )
137
-				foreach( $entry as $single_entry )
144
+			if ( is_array( $entry ) ) {
145
+							foreach( $entry as $single_entry )
138 146
 					$translations->add_entry_or_merge( $single_entry );
139
-			elseif ( $entry)
140
-				$translations->add_entry_or_merge( $entry );
147
+			} elseif ( $entry) {
148
+							$translations->add_entry_or_merge( $entry );
149
+			}
141 150
 		}
142 151
 		return $translations;
143 152
 	}
@@ -155,8 +164,12 @@  discard block
 block discarded – undo
155 164
 		$in_func = false;
156 165
 		foreach( $tokens as $token ) {
157 166
 			$id = $text = null;
158
-			if ( is_array( $token ) ) list( $id, $text, $line ) = $token;
159
-			if ( T_WHITESPACE == $id ) continue;
167
+			if ( is_array( $token ) ) {
168
+				list( $id, $text, $line ) = $token;
169
+			}
170
+			if ( T_WHITESPACE == $id ) {
171
+				continue;
172
+			}
160 173
 			if ( T_STRING == $id && in_array( $text, $function_names ) && !$in_func ) {
161 174
 				$in_func = true;
162 175
 				$paren_level = -1;
@@ -177,7 +190,9 @@  discard block
 block discarded – undo
177 190
 					$latest_comment = $text;
178 191
 				}
179 192
 			}
180
-			if ( !$in_func ) continue;
193
+			if ( !$in_func ) {
194
+				continue;
195
+			}
181 196
 			if ( '(' == $token ) {
182 197
 				$paren_level++;
183 198
 				if ( 0 == $paren_level ) { // start of first argument
@@ -197,7 +212,9 @@  discard block
 block discarded – undo
197 212
 					$in_func = false;
198 213
 					$args[] = $current_argument;
199 214
 					$call = array( 'name' => $func_name, 'args' => $args, 'line' => $func_line );
200
-					if ( $func_comment ) $call['comment'] = $func_comment;
215
+					if ( $func_comment ) {
216
+						$call['comment'] = $func_comment;
217
+					}
201 218
 					$function_calls[] = $call;
202 219
 				}
203 220
 				$paren_level--;
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-$pomo = dirname( dirname( dirname( __FILE__ ) ) ) . '/src/wp-includes/pomo';
2
+$pomo = dirname(dirname(dirname(__FILE__))).'/src/wp-includes/pomo';
3 3
 require_once "$pomo/entry.php";
4 4
 require_once "$pomo/translations.php";
5 5
 
@@ -10,55 +10,55 @@  discard block
 block discarded – undo
10 10
 class StringExtractor {
11 11
 
12 12
 	var $rules = array(
13
-		'__' => array( 'string' ),
14
-		'_e' => array( 'string' ),
15
-		'_n' => array( 'singular', 'plural' ),
13
+		'__' => array('string'),
14
+		'_e' => array('string'),
15
+		'_n' => array('singular', 'plural'),
16 16
 	);
17 17
 	var $comment_prefix = 'translators:';
18 18
 
19
-	function __construct( $rules = array() ) {
19
+	function __construct($rules = array()) {
20 20
 		$this->rules = $rules;
21 21
 	}
22 22
 
23
-	function extract_from_directory( $dir, $excludes = array(), $includes = array(), $prefix = '' ) {
23
+	function extract_from_directory($dir, $excludes = array(), $includes = array(), $prefix = '') {
24 24
 		$old_cwd = getcwd();
25
-		chdir( $dir );
25
+		chdir($dir);
26 26
 		$translations = new Translations;
27
-		$file_names = (array) scandir( '.' );
28
-		foreach ( $file_names as $file_name ) {
29
-			if ( '.' == $file_name || '..' == $file_name ) continue;
30
-			if ( preg_match( '/\.php$/', $file_name ) && $this->does_file_name_match( $prefix . $file_name, $excludes, $includes ) ) {
31
-				$extracted = $this->extract_from_file( $file_name, $prefix );
32
-				$translations->merge_originals_with( $extracted );
27
+		$file_names = (array) scandir('.');
28
+		foreach ($file_names as $file_name) {
29
+			if ('.' == $file_name || '..' == $file_name) continue;
30
+			if (preg_match('/\.php$/', $file_name) && $this->does_file_name_match($prefix.$file_name, $excludes, $includes)) {
31
+				$extracted = $this->extract_from_file($file_name, $prefix);
32
+				$translations->merge_originals_with($extracted);
33 33
 			}
34
-			if ( is_dir( $file_name ) ) {
35
-				$extracted = $this->extract_from_directory( $file_name, $excludes, $includes, $prefix . $file_name . '/' );
36
-				$translations->merge_originals_with( $extracted );
34
+			if (is_dir($file_name)) {
35
+				$extracted = $this->extract_from_directory($file_name, $excludes, $includes, $prefix.$file_name.'/');
36
+				$translations->merge_originals_with($extracted);
37 37
 			}
38 38
 		}
39
-		chdir( $old_cwd );
39
+		chdir($old_cwd);
40 40
 		return $translations;
41 41
 	}
42 42
 
43
-	function extract_from_file( $file_name, $prefix ) {
44
-		$code = file_get_contents( $file_name );
45
-		return $this->extract_from_code( $code, $prefix . $file_name );
43
+	function extract_from_file($file_name, $prefix) {
44
+		$code = file_get_contents($file_name);
45
+		return $this->extract_from_code($code, $prefix.$file_name);
46 46
 	}
47 47
 
48
-	function does_file_name_match( $path, $excludes, $includes ) {
49
-		if ( $includes ) {
48
+	function does_file_name_match($path, $excludes, $includes) {
49
+		if ($includes) {
50 50
 			$matched_any_include = false;
51
-			foreach( $includes as $include ) {
52
-				if ( preg_match( '|^'.$include.'$|', $path ) ) {
51
+			foreach ($includes as $include) {
52
+				if (preg_match('|^'.$include.'$|', $path)) {
53 53
 					$matched_any_include = true;
54 54
 					break;
55 55
 				}
56 56
 			}
57
-			if ( !$matched_any_include ) return false;
57
+			if ( ! $matched_any_include) return false;
58 58
 		}
59
-		if ( $excludes ) {
60
-			foreach( $excludes as $exclude ) {
61
-				if ( preg_match( '|^'.$exclude.'$|', $path ) ) {
59
+		if ($excludes) {
60
+			foreach ($excludes as $exclude) {
61
+				if (preg_match('|^'.$exclude.'$|', $path)) {
62 62
 					return false;
63 63
 				}
64 64
 			}
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
 		return true;
67 67
 	}
68 68
 
69
-	function entry_from_call( $call, $file_name ) {
70
-		$rule = isset( $this->rules[$call['name']] )? $this->rules[$call['name']] : null;
71
-		if ( !$rule ) return null;
69
+	function entry_from_call($call, $file_name) {
70
+		$rule = isset($this->rules[$call['name']]) ? $this->rules[$call['name']] : null;
71
+		if ( ! $rule) return null;
72 72
 		$entry = new Translation_Entry;
73 73
 		$multiple = array();
74 74
 		$complete = false;
75
-		for( $i = 0; $i < count( $rule ); ++$i ) {
76
-			if ( $rule[$i] && ( !isset( $call['args'][$i] ) || !is_string( $call['args'][$i] ) || '' == $call['args'][$i] ) ) return false;
77
-			switch( $rule[$i] ) {
75
+		for ($i = 0; $i < count($rule); ++$i) {
76
+			if ($rule[$i] && ( ! isset($call['args'][$i]) || ! is_string($call['args'][$i]) || '' == $call['args'][$i])) return false;
77
+			switch ($rule[$i]) {
78 78
 			case 'string':
79
-				if ( $complete ) {
79
+				if ($complete) {
80 80
 					$multiple[] = $entry;
81 81
 					$entry = new Translation_Entry;
82 82
 					$complete = false;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 				$complete = true;
86 86
 				break;
87 87
 			case 'singular':
88
-				if ( $complete ) {
88
+				if ($complete) {
89 89
 					$multiple[] = $entry;
90 90
 					$entry = new Translation_Entry;
91 91
 					$complete = false;
@@ -100,27 +100,27 @@  discard block
 block discarded – undo
100 100
 				break;
101 101
 			case 'context':
102 102
 				$entry->context = $call['args'][$i];
103
-				foreach( $multiple as &$single_entry ) {
103
+				foreach ($multiple as &$single_entry) {
104 104
 					$single_entry->context = $entry->context;
105 105
 				}
106 106
 				break;
107 107
 			}
108 108
 		}
109
-		if ( isset( $call['line'] ) && $call['line'] ) {
110
-			$references = array( $file_name . ':' . $call['line'] );
109
+		if (isset($call['line']) && $call['line']) {
110
+			$references = array($file_name.':'.$call['line']);
111 111
 			$entry->references = $references;
112
-			foreach( $multiple as &$single_entry ) {
112
+			foreach ($multiple as &$single_entry) {
113 113
 				$single_entry->references = $references;
114 114
 			}
115 115
 		}
116
-		if ( isset( $call['comment'] ) && $call['comment'] ) {
117
-			$comments = rtrim( $call['comment'] ) . "\n";
116
+		if (isset($call['comment']) && $call['comment']) {
117
+			$comments = rtrim($call['comment'])."\n";
118 118
 			$entry->extracted_comments = $comments;
119
-			foreach( $multiple as &$single_entry ) {
119
+			foreach ($multiple as &$single_entry) {
120 120
 				$single_entry->extracted_comments = $comments;
121 121
 			}
122 122
 		}
123
-		if ( $multiple && $entry ) {
123
+		if ($multiple && $entry) {
124 124
 			$multiple[] = $entry;
125 125
 			return $multiple;
126 126
 		}
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
 		return $entry;
129 129
 	}
130 130
 
131
-	function extract_from_code( $code, $file_name ) {
131
+	function extract_from_code($code, $file_name) {
132 132
 		$translations = new Translations;
133
-		$function_calls = $this->find_function_calls( array_keys( $this->rules ), $code );
134
-		foreach( $function_calls as $call ) {
135
-			$entry = $this->entry_from_call( $call, $file_name );
136
-			if ( is_array( $entry ) )
137
-				foreach( $entry as $single_entry )
138
-					$translations->add_entry_or_merge( $single_entry );
139
-			elseif ( $entry)
140
-				$translations->add_entry_or_merge( $entry );
133
+		$function_calls = $this->find_function_calls(array_keys($this->rules), $code);
134
+		foreach ($function_calls as $call) {
135
+			$entry = $this->entry_from_call($call, $file_name);
136
+			if (is_array($entry))
137
+				foreach ($entry as $single_entry)
138
+					$translations->add_entry_or_merge($single_entry);
139
+			elseif ($entry)
140
+				$translations->add_entry_or_merge($entry);
141 141
 		}
142 142
 		return $translations;
143 143
 	}
@@ -148,70 +148,70 @@  discard block
 block discarded – undo
148 148
 	 *	- args - array for the function arguments. Each string literal is represented by itself, other arguments are represented by null.
149 149
 	 *  - line - line number
150 150
 	 */
151
-	function find_function_calls( $function_names, $code ) {
152
-		$tokens = token_get_all( $code );
151
+	function find_function_calls($function_names, $code) {
152
+		$tokens = token_get_all($code);
153 153
 		$function_calls = array();
154 154
 		$latest_comment = false;
155 155
 		$in_func = false;
156
-		foreach( $tokens as $token ) {
156
+		foreach ($tokens as $token) {
157 157
 			$id = $text = null;
158
-			if ( is_array( $token ) ) list( $id, $text, $line ) = $token;
159
-			if ( T_WHITESPACE == $id ) continue;
160
-			if ( T_STRING == $id && in_array( $text, $function_names ) && !$in_func ) {
158
+			if (is_array($token)) list($id, $text, $line) = $token;
159
+			if (T_WHITESPACE == $id) continue;
160
+			if (T_STRING == $id && in_array($text, $function_names) && ! $in_func) {
161 161
 				$in_func = true;
162 162
 				$paren_level = -1;
163 163
 				$args = array();
164 164
 				$func_name = $text;
165 165
 				$func_line = $line;
166
-				$func_comment = $latest_comment? $latest_comment : '';
166
+				$func_comment = $latest_comment ? $latest_comment : '';
167 167
 
168 168
 				$just_got_into_func = true;
169 169
 				$latest_comment = false;
170 170
 				continue;
171 171
 			}
172
-			if ( T_COMMENT == $id ) {
173
-				$text = preg_replace( '%^\s+\*\s%m', '', $text );
174
-				$text = str_replace( array( "\r\n", "\n" ), ' ', $text );;
175
-				$text = trim( preg_replace( '%^(/\*|//)%', '', preg_replace( '%\*/$%', '', $text ) ) );
176
-				if ( 0 === stripos( $text, $this->comment_prefix ) ) {
172
+			if (T_COMMENT == $id) {
173
+				$text = preg_replace('%^\s+\*\s%m', '', $text);
174
+				$text = str_replace(array("\r\n", "\n"), ' ', $text); ;
175
+				$text = trim(preg_replace('%^(/\*|//)%', '', preg_replace('%\*/$%', '', $text)));
176
+				if (0 === stripos($text, $this->comment_prefix)) {
177 177
 					$latest_comment = $text;
178 178
 				}
179 179
 			}
180
-			if ( !$in_func ) continue;
181
-			if ( '(' == $token ) {
180
+			if ( ! $in_func) continue;
181
+			if ('(' == $token) {
182 182
 				$paren_level++;
183
-				if ( 0 == $paren_level ) { // start of first argument
183
+				if (0 == $paren_level) { // start of first argument
184 184
 					$just_got_into_func = false;
185 185
 					$current_argument = null;
186 186
 					$current_argument_is_just_literal = true;
187 187
 				}
188 188
 				continue;
189 189
 			}
190
-			if ( $just_got_into_func ) {
190
+			if ($just_got_into_func) {
191 191
 				// there wasn't a opening paren just after the function name -- this means it is not a function
192 192
 				$in_func = false;
193 193
 				$just_got_into_func = false;
194 194
 			}
195
-			if ( ')' == $token ) {
196
-				if ( 0 == $paren_level ) {
195
+			if (')' == $token) {
196
+				if (0 == $paren_level) {
197 197
 					$in_func = false;
198 198
 					$args[] = $current_argument;
199
-					$call = array( 'name' => $func_name, 'args' => $args, 'line' => $func_line );
200
-					if ( $func_comment ) $call['comment'] = $func_comment;
199
+					$call = array('name' => $func_name, 'args' => $args, 'line' => $func_line);
200
+					if ($func_comment) $call['comment'] = $func_comment;
201 201
 					$function_calls[] = $call;
202 202
 				}
203 203
 				$paren_level--;
204 204
 				continue;
205 205
 			}
206
-			if ( ',' == $token && 0 == $paren_level ) {
206
+			if (',' == $token && 0 == $paren_level) {
207 207
 				$args[] = $current_argument;
208 208
 				$current_argument = null;
209 209
 				$current_argument_is_just_literal = true;
210 210
 				continue;
211 211
 			}
212
-			if ( T_CONSTANT_ENCAPSED_STRING == $id && $current_argument_is_just_literal ) {
212
+			if (T_CONSTANT_ENCAPSED_STRING == $id && $current_argument_is_just_literal) {
213 213
 				// we can use eval safely, because we are sure $text is just a string literal
214
-				eval('$current_argument = '.$text.';' );
214
+				eval('$current_argument = '.$text.';');
215 215
 				continue;
216 216
 			}
217 217
 			$current_argument_is_just_literal = false;
Please login to merge, or discard this patch.