@@ -505,6 +505,7 @@ discard block |
||
505 | 505 | * @param string $oldList |
506 | 506 | * @param array $match |
507 | 507 | * @param array $index |
508 | + * @param string $type |
|
508 | 509 | * @return string |
509 | 510 | */ |
510 | 511 | protected function addListElementToContent($newList, $oldList, array $match, array $index, $type) |
@@ -588,7 +589,7 @@ discard block |
||
588 | 589 | /** |
589 | 590 | * Converts the list (li) content arrays to string. |
590 | 591 | * |
591 | - * @param array $listContentArray |
|
592 | + * @param string $listContentArray |
|
592 | 593 | * @return string |
593 | 594 | */ |
594 | 595 | protected function convertListContentArrayToString($listContentArray) |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | protected $listIsolatedDiffTags = array(); |
21 | 21 | |
22 | 22 | /** @var array */ |
23 | - protected $isolatedDiffTags = array ( |
|
23 | + protected $isolatedDiffTags = array( |
|
24 | 24 | 'ol' => '[[REPLACE_ORDERED_LIST]]', |
25 | 25 | 'ul' => '[[REPLACE_UNORDERED_LIST]]', |
26 | 26 | 'dl' => '[[REPLACE_DEFINITION_LIST]]', |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $columns = $this->getArrayColumn($bestMatchPercentages, $key); |
358 | 358 | $thisBestMatches = array_filter( |
359 | 359 | $columns, |
360 | - function ($v) use ($percent) { |
|
360 | + function($v) use ($percent) { |
|
361 | 361 | return $v > $percent; |
362 | 362 | } |
363 | 363 | ); |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | $match = $word == self::$listPlaceHolder; |
606 | 606 | |
607 | 607 | $content[] = $match |
608 | - ? "<li>" . $this->convertListContentArrayToString($listContentArray['kids'][$nestedListCount]) . "</li>" |
|
608 | + ? "<li>".$this->convertListContentArrayToString($listContentArray['kids'][$nestedListCount])."</li>" |
|
609 | 609 | : $word; |
610 | 610 | |
611 | 611 | if ($match) { |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | $content = $preContent; |
653 | 653 | } |
654 | 654 | |
655 | - $returnText[] = is_array($preContent) ? $preContent[0] . $content . $preContent[2] : $content; |
|
655 | + $returnText[] = is_array($preContent) ? $preContent[0].$content.$preContent[2] : $content; |
|
656 | 656 | } |
657 | 657 | // Return the result. |
658 | 658 | return implode(' ', $returnText); |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | if ($opening) { |
788 | 788 | return $this->newParentTag ?: $this->oldParentTag; |
789 | 789 | } else { |
790 | - return "<" . (!$opening ? "/" : '') . $this->listType . ">"; |
|
790 | + return "<".(!$opening ? "/" : '').$this->listType.">"; |
|
791 | 791 | } |
792 | 792 | } |
793 | 793 |
@@ -14,6 +14,9 @@ |
||
14 | 14 | |
15 | 15 | protected $endTag; |
16 | 16 | |
17 | + /** |
|
18 | + * @param null|string $listType |
|
19 | + */ |
|
17 | 20 | public function __construct($listType, $startTag, $endTag, $listItems = array(), $attributes = array()) |
18 | 21 | { |
19 | 22 | $this->listType = $listType; |
@@ -217,12 +217,18 @@ discard block |
||
217 | 217 | return $diffList; |
218 | 218 | } |
219 | 219 | |
220 | + /** |
|
221 | + * @param string $type |
|
222 | + */ |
|
220 | 223 | protected function isOpeningListTag($word, $type = null) |
221 | 224 | { |
222 | 225 | $filter = $type !== null ? array('<' . $type) : array('<ul', '<ol', '<dl'); |
223 | 226 | return in_array(substr($word, 0, 3), $filter); |
224 | 227 | } |
225 | 228 | |
229 | + /** |
|
230 | + * @param string $type |
|
231 | + */ |
|
226 | 232 | protected function isClosingListTag($word, $type = null) |
227 | 233 | { |
228 | 234 | $filter = $type !== null ? array('</' . $type) : array('</ul', '</ol', '</dl'); |
@@ -230,6 +236,9 @@ discard block |
||
230 | 236 | return in_array(substr($word, 0, 4), $filter); |
231 | 237 | } |
232 | 238 | |
239 | + /** |
|
240 | + * @param string $type |
|
241 | + */ |
|
233 | 242 | protected function isOpeningListItemTag($word, $type = null) |
234 | 243 | { |
235 | 244 | $filter = $type !== null ? array('<' . $type) : array('<li', '<dd', '<dt'); |
@@ -237,6 +246,9 @@ discard block |
||
237 | 246 | return in_array(substr($word, 0, 3), $filter); |
238 | 247 | } |
239 | 248 | |
249 | + /** |
|
250 | + * @param string $type |
|
251 | + */ |
|
240 | 252 | protected function isClosingListItemTag($word, $type = null) |
241 | 253 | { |
242 | 254 | $filter = $type !== null ? array('</' . $type) : array('</li', '</dd', '</dt'); |
@@ -219,27 +219,27 @@ |
||
219 | 219 | |
220 | 220 | protected function isOpeningListTag($word, $type = null) |
221 | 221 | { |
222 | - $filter = $type !== null ? array('<' . $type) : array('<ul', '<ol', '<dl'); |
|
222 | + $filter = $type !== null ? array('<'.$type) : array('<ul', '<ol', '<dl'); |
|
223 | 223 | return in_array(substr($word, 0, 3), $filter); |
224 | 224 | } |
225 | 225 | |
226 | 226 | protected function isClosingListTag($word, $type = null) |
227 | 227 | { |
228 | - $filter = $type !== null ? array('</' . $type) : array('</ul', '</ol', '</dl'); |
|
228 | + $filter = $type !== null ? array('</'.$type) : array('</ul', '</ol', '</dl'); |
|
229 | 229 | |
230 | 230 | return in_array(substr($word, 0, 4), $filter); |
231 | 231 | } |
232 | 232 | |
233 | 233 | protected function isOpeningListItemTag($word, $type = null) |
234 | 234 | { |
235 | - $filter = $type !== null ? array('<' . $type) : array('<li', '<dd', '<dt'); |
|
235 | + $filter = $type !== null ? array('<'.$type) : array('<li', '<dd', '<dt'); |
|
236 | 236 | |
237 | 237 | return in_array(substr($word, 0, 3), $filter); |
238 | 238 | } |
239 | 239 | |
240 | 240 | protected function isClosingListItemTag($word, $type = null) |
241 | 241 | { |
242 | - $filter = $type !== null ? array('</' . $type) : array('</li', '</dd', '</dt'); |
|
242 | + $filter = $type !== null ? array('</'.$type) : array('</li', '</dd', '</dt'); |
|
243 | 243 | |
244 | 244 | return in_array(substr($word, 0, 4), $filter); |
245 | 245 | } |
@@ -8,6 +8,10 @@ |
||
8 | 8 | public $startInNew; |
9 | 9 | public $size; |
10 | 10 | |
11 | + /** |
|
12 | + * @param integer $startInOld |
|
13 | + * @param integer $size |
|
14 | + */ |
|
11 | 15 | public function __construct($startInOld, $startInNew, $size) |
12 | 16 | { |
13 | 17 | $this->startInOld = $startInOld; |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | |
230 | 230 | /** |
231 | 231 | * @param Operation $operation |
232 | - * @param array $oldRows |
|
233 | - * @param array $newRows |
|
232 | + * @param TableRow[] $oldRows |
|
233 | + * @param TableRow[] $newRows |
|
234 | 234 | * @param array $appliedRowSpans |
235 | 235 | */ |
236 | 236 | protected function processEqualOperation(Operation $operation, $oldRows, $newRows, &$appliedRowSpans) |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | |
250 | 250 | /** |
251 | 251 | * @param Operation $operation |
252 | - * @param array $oldRows |
|
253 | - * @param array $newRows |
|
252 | + * @param TableRow[] $oldRows |
|
253 | + * @param TableRow[] $newRows |
|
254 | 254 | * @param array $appliedRowSpans |
255 | 255 | */ |
256 | 256 | protected function processReplaceOperation(Operation $operation, $oldRows, $newRows, &$appliedRowSpans) |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function getColspan() |
44 | 44 | { |
45 | - return (int)$this->getAttribute('colspan') ?: 1; |
|
45 | + return (int) $this->getAttribute('colspan') ?: 1; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -50,6 +50,6 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function getRowspan() |
52 | 52 | { |
53 | - return (int)$this->getAttribute('rowspan') ?: 1; |
|
53 | + return (int) $this->getAttribute('rowspan') ?: 1; |
|
54 | 54 | } |
55 | 55 | } |
@@ -95,7 +95,7 @@ |
||
95 | 95 | /** |
96 | 96 | * @param int $matchThreshold |
97 | 97 | * |
98 | - * @return AbstractDiff |
|
98 | + * @return HtmlDiffConfig |
|
99 | 99 | */ |
100 | 100 | public function setMatchThreshold($matchThreshold) |
101 | 101 | { |
@@ -282,13 +282,13 @@ discard block |
||
282 | 282 | */ |
283 | 283 | protected function getStringBetween($str, $start, $end) |
284 | 284 | { |
285 | - $expStr = explode( $start, $str, 2 ); |
|
286 | - if ( count( $expStr ) > 1 ) { |
|
287 | - $expStr = explode( $end, $expStr[ 1 ] ); |
|
288 | - if ( count( $expStr ) > 1 ) { |
|
289 | - array_pop( $expStr ); |
|
285 | + $expStr = explode($start, $str, 2); |
|
286 | + if (count($expStr) > 1) { |
|
287 | + $expStr = explode($end, $expStr[1]); |
|
288 | + if (count($expStr) > 1) { |
|
289 | + array_pop($expStr); |
|
290 | 290 | |
291 | - return implode( $end, $expStr ); |
|
291 | + return implode($end, $expStr); |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | */ |
303 | 303 | protected function purifyHtml($html) |
304 | 304 | { |
305 | - if ( class_exists( 'Tidy' ) && false ) { |
|
306 | - $config = array( 'output-xhtml' => true, 'indent' => false ); |
|
305 | + if (class_exists('Tidy') && false) { |
|
306 | + $config = array('output-xhtml' => true, 'indent' => false); |
|
307 | 307 | $tidy = new tidy(); |
308 | - $tidy->parseString( $html, $config, 'utf8' ); |
|
308 | + $tidy->parseString($html, $config, 'utf8'); |
|
309 | 309 | $html = (string) $tidy; |
310 | 310 | |
311 | - return $this->getStringBetween( $html, '<body>' ); |
|
311 | + return $this->getStringBetween($html, '<body>'); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | return $html; |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | |
317 | 317 | protected function splitInputsToWords() |
318 | 318 | { |
319 | - $this->oldWords = $this->convertHtmlToListOfWords( $this->explode( $this->oldText ) ); |
|
320 | - $this->newWords = $this->convertHtmlToListOfWords( $this->explode( $this->newText ) ); |
|
319 | + $this->oldWords = $this->convertHtmlToListOfWords($this->explode($this->oldText)); |
|
320 | + $this->newWords = $this->convertHtmlToListOfWords($this->explode($this->newText)); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | foreach ($characterString as $i => $character) { |
344 | 344 | switch ($mode) { |
345 | 345 | case 'character': |
346 | - if ( $this->isStartOfTag( $character ) ) { |
|
346 | + if ($this->isStartOfTag($character)) { |
|
347 | 347 | if ($current_word != '') { |
348 | 348 | $words[] = $current_word; |
349 | 349 | } |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | } else { |
359 | 359 | if ( |
360 | 360 | (ctype_alnum($character) && (strlen($current_word) == 0 || $this->isPartOfWord($current_word))) || |
361 | - (in_array($character, $this->config->getSpecialCaseChars()) && isset($characterString[$i+1]) && $this->isPartOfWord($characterString[$i+1])) |
|
361 | + (in_array($character, $this->config->getSpecialCaseChars()) && isset($characterString[$i + 1]) && $this->isPartOfWord($characterString[$i + 1])) |
|
362 | 362 | ) { |
363 | 363 | $current_word .= $character; |
364 | 364 | } else { |
@@ -368,12 +368,12 @@ discard block |
||
368 | 368 | } |
369 | 369 | break; |
370 | 370 | case 'tag' : |
371 | - if ( $this->isEndOfTag( $character ) ) { |
|
371 | + if ($this->isEndOfTag($character)) { |
|
372 | 372 | $current_word .= ">"; |
373 | 373 | $words[] = $current_word; |
374 | 374 | $current_word = ""; |
375 | 375 | |
376 | - if ( !preg_match('[^\s]', $character ) ) { |
|
376 | + if (!preg_match('[^\s]', $character)) { |
|
377 | 377 | $mode = 'whitespace'; |
378 | 378 | } else { |
379 | 379 | $mode = 'character'; |
@@ -383,13 +383,13 @@ discard block |
||
383 | 383 | } |
384 | 384 | break; |
385 | 385 | case 'whitespace': |
386 | - if ( $this->isStartOfTag( $character ) ) { |
|
386 | + if ($this->isStartOfTag($character)) { |
|
387 | 387 | if ($current_word !== '') { |
388 | 388 | $words[] = $current_word; |
389 | 389 | } |
390 | 390 | $current_word = "<"; |
391 | 391 | $mode = 'tag'; |
392 | - } elseif ( preg_match( "/\s/", $character ) ) { |
|
392 | + } elseif (preg_match("/\s/", $character)) { |
|
393 | 393 | $current_word .= $character; |
394 | 394 | $current_word = preg_replace('/\s+/S', ' ', $current_word); |
395 | 395 | } else { |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | */ |
439 | 439 | protected function isWhiteSpace($value) |
440 | 440 | { |
441 | - return !preg_match( '[^\s]', $value ); |
|
441 | + return !preg_match('[^\s]', $value); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -449,6 +449,6 @@ discard block |
||
449 | 449 | protected function explode($value) |
450 | 450 | { |
451 | 451 | // as suggested by @onassar |
452 | - return preg_split( '//u', $value ); |
|
452 | + return preg_split('//u', $value); |
|
453 | 453 | } |
454 | 454 | } |
@@ -387,6 +387,12 @@ discard block |
||
387 | 387 | return $diff->build(); |
388 | 388 | } |
389 | 389 | |
390 | + /** |
|
391 | + * @param string $oldText |
|
392 | + * @param string $newText |
|
393 | + * @param string $attribute |
|
394 | + * @param string $element |
|
395 | + */ |
|
390 | 396 | protected function diffElementsByAttribute($oldText, $newText, $attribute, $element) |
391 | 397 | { |
392 | 398 | $oldAttribute = $this->getAttributeFromTag($oldText, $attribute); |
@@ -662,7 +668,7 @@ discard block |
||
662 | 668 | /** |
663 | 669 | * @param string $item |
664 | 670 | * |
665 | - * @return bool |
|
671 | + * @return integer |
|
666 | 672 | */ |
667 | 673 | protected function isOpeningTag($item) |
668 | 674 | { |
@@ -672,7 +678,7 @@ discard block |
||
672 | 678 | /** |
673 | 679 | * @param string $item |
674 | 680 | * |
675 | - * @return bool |
|
681 | + * @return integer |
|
676 | 682 | */ |
677 | 683 | protected function isClosingTag($item) |
678 | 684 | { |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | $operations = $this->operations(); |
105 | 105 | foreach ($operations as $item) { |
106 | - $this->performOperation( $item ); |
|
106 | + $this->performOperation($item); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | if ($this->hasDiffCache()) { |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | { |
118 | 118 | $this->wordIndices = array(); |
119 | 119 | foreach ($this->newWords as $i => $word) { |
120 | - if ( $this->isTag( $word ) ) { |
|
121 | - $word = $this->stripTagAttributes( $word ); |
|
120 | + if ($this->isTag($word)) { |
|
121 | + $word = $this->stripTagAttributes($word); |
|
122 | 122 | } |
123 | - if ( isset( $this->wordIndices[ $word ] ) ) { |
|
124 | - $this->wordIndices[ $word ][] = $i; |
|
123 | + if (isset($this->wordIndices[$word])) { |
|
124 | + $this->wordIndices[$word][] = $i; |
|
125 | 125 | } else { |
126 | - $this->wordIndices[ $word ] = array( $i ); |
|
126 | + $this->wordIndices[$word] = array($i); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | } elseif ($openIsolatedDiffTags > 0 && $this->isClosingIsolatedDiffTag($word, $currentIsolatedDiffTag)) { |
168 | 168 | $openIsolatedDiffTags--; |
169 | 169 | if ($openIsolatedDiffTags == 0) { |
170 | - $isolatedDiffTagIndices[] = array ('start' => $isolatedDiffTagStart, 'length' => $index - $isolatedDiffTagStart + 1, 'tagType' => $currentIsolatedDiffTag); |
|
170 | + $isolatedDiffTagIndices[] = array('start' => $isolatedDiffTagStart, 'length' => $index - $isolatedDiffTagStart + 1, 'tagType' => $currentIsolatedDiffTag); |
|
171 | 171 | $currentIsolatedDiffTag = null; |
172 | 172 | } |
173 | 173 | } |
@@ -239,16 +239,16 @@ discard block |
||
239 | 239 | { |
240 | 240 | switch ($operation->action) { |
241 | 241 | case 'equal' : |
242 | - $this->processEqualOperation( $operation ); |
|
242 | + $this->processEqualOperation($operation); |
|
243 | 243 | break; |
244 | 244 | case 'delete' : |
245 | - $this->processDeleteOperation( $operation, "diffdel" ); |
|
245 | + $this->processDeleteOperation($operation, "diffdel"); |
|
246 | 246 | break; |
247 | 247 | case 'insert' : |
248 | - $this->processInsertOperation( $operation, "diffins"); |
|
248 | + $this->processInsertOperation($operation, "diffins"); |
|
249 | 249 | break; |
250 | 250 | case 'replace': |
251 | - $this->processReplaceOperation( $operation ); |
|
251 | + $this->processReplaceOperation($operation); |
|
252 | 252 | break; |
253 | 253 | default: |
254 | 254 | break; |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | */ |
261 | 261 | protected function processReplaceOperation($operation) |
262 | 262 | { |
263 | - $this->processDeleteOperation( $operation, "diffmod" ); |
|
264 | - $this->processInsertOperation( $operation, "diffmod" ); |
|
263 | + $this->processDeleteOperation($operation, "diffmod"); |
|
264 | + $this->processInsertOperation($operation, "diffmod"); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | } |
283 | 283 | } |
284 | 284 | } |
285 | - $this->insertTag( "ins", $cssClass, $text ); |
|
285 | + $this->insertTag("ins", $cssClass, $text); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | } |
304 | 304 | } |
305 | 305 | } |
306 | - $this->insertTag( "del", $cssClass, $text ); |
|
306 | + $this->insertTag("del", $cssClass, $text); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | |
359 | 359 | $diff = HtmlDiff::create($oldText, $newText, $this->config); |
360 | 360 | |
361 | - return $wrapStart . $diff->build() . $wrapEnd; |
|
361 | + return $wrapStart.$diff->build().$wrapEnd; |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | } |
423 | 423 | } |
424 | 424 | } |
425 | - $this->content .= implode( "", $result ); |
|
425 | + $this->content .= implode("", $result); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -527,22 +527,22 @@ discard block |
||
527 | 527 | protected function insertTag($tag, $cssClass, &$words) |
528 | 528 | { |
529 | 529 | while (true) { |
530 | - if ( count( $words ) == 0 ) { |
|
530 | + if (count($words) == 0) { |
|
531 | 531 | break; |
532 | 532 | } |
533 | 533 | |
534 | - $nonTags = $this->extractConsecutiveWords( $words, 'noTag' ); |
|
534 | + $nonTags = $this->extractConsecutiveWords($words, 'noTag'); |
|
535 | 535 | |
536 | 536 | $specialCaseTagInjection = ''; |
537 | 537 | $specialCaseTagInjectionIsBefore = false; |
538 | 538 | |
539 | - if ( count( $nonTags ) != 0 ) { |
|
540 | - $text = $this->wrapText( implode( "", $nonTags ), $tag, $cssClass ); |
|
539 | + if (count($nonTags) != 0) { |
|
540 | + $text = $this->wrapText(implode("", $nonTags), $tag, $cssClass); |
|
541 | 541 | $this->content .= $text; |
542 | 542 | } else { |
543 | 543 | $firstOrDefault = false; |
544 | 544 | foreach ($this->config->getSpecialCaseOpeningTags() as $x) { |
545 | - if ( preg_match( $x, $words[ 0 ] ) ) { |
|
545 | + if (preg_match($x, $words[0])) { |
|
546 | 546 | $firstOrDefault = $x; |
547 | 547 | break; |
548 | 548 | } |
@@ -550,33 +550,33 @@ discard block |
||
550 | 550 | if ($firstOrDefault) { |
551 | 551 | $specialCaseTagInjection = '<ins class="mod">'; |
552 | 552 | if ($tag == "del") { |
553 | - unset( $words[ 0 ] ); |
|
553 | + unset($words[0]); |
|
554 | 554 | } |
555 | - } elseif ( array_search( $words[ 0 ], $this->config->getSpecialCaseClosingTags()) !== false ) { |
|
555 | + } elseif (array_search($words[0], $this->config->getSpecialCaseClosingTags()) !== false) { |
|
556 | 556 | $specialCaseTagInjection = "</ins>"; |
557 | 557 | $specialCaseTagInjectionIsBefore = true; |
558 | 558 | if ($tag == "del") { |
559 | - unset( $words[ 0 ] ); |
|
559 | + unset($words[0]); |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | } |
563 | - if ( count( $words ) == 0 && count( $specialCaseTagInjection ) == 0 ) { |
|
563 | + if (count($words) == 0 && count($specialCaseTagInjection) == 0) { |
|
564 | 564 | break; |
565 | 565 | } |
566 | 566 | if ($specialCaseTagInjectionIsBefore) { |
567 | - $this->content .= $specialCaseTagInjection . implode( "", $this->extractConsecutiveWords( $words, 'tag' ) ); |
|
567 | + $this->content .= $specialCaseTagInjection.implode("", $this->extractConsecutiveWords($words, 'tag')); |
|
568 | 568 | } else { |
569 | - $workTag = $this->extractConsecutiveWords( $words, 'tag' ); |
|
570 | - if ( isset( $workTag[ 0 ] ) && $this->isOpeningTag( $workTag[ 0 ] ) && !$this->isClosingTag( $workTag[ 0 ] ) ) { |
|
571 | - if ( strpos( $workTag[ 0 ], 'class=' ) ) { |
|
572 | - $workTag[ 0 ] = str_replace( 'class="', 'class="diffmod ', $workTag[ 0 ] ); |
|
573 | - $workTag[ 0 ] = str_replace( "class='", 'class="diffmod ', $workTag[ 0 ] ); |
|
569 | + $workTag = $this->extractConsecutiveWords($words, 'tag'); |
|
570 | + if (isset($workTag[0]) && $this->isOpeningTag($workTag[0]) && !$this->isClosingTag($workTag[0])) { |
|
571 | + if (strpos($workTag[0], 'class=')) { |
|
572 | + $workTag[0] = str_replace('class="', 'class="diffmod ', $workTag[0]); |
|
573 | + $workTag[0] = str_replace("class='", 'class="diffmod ', $workTag[0]); |
|
574 | 574 | } else { |
575 | - $workTag[ 0 ] = str_replace( ">", ' class="diffmod">', $workTag[ 0 ] ); |
|
575 | + $workTag[0] = str_replace(">", ' class="diffmod">', $workTag[0]); |
|
576 | 576 | } |
577 | 577 | } |
578 | 578 | |
579 | - $appendContent = implode( "", $workTag ) . $specialCaseTagInjection; |
|
579 | + $appendContent = implode("", $workTag).$specialCaseTagInjection; |
|
580 | 580 | if (isset($workTag[0]) && false !== stripos($workTag[0], '<img')) { |
581 | 581 | $appendContent = $this->wrapText($appendContent, $tag, $cssClass); |
582 | 582 | } |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | */ |
594 | 594 | protected function checkCondition($word, $condition) |
595 | 595 | { |
596 | - return $condition == 'tag' ? $this->isTag( $word ) : !$this->isTag( $word ); |
|
596 | + return $condition == 'tag' ? $this->isTag($word) : !$this->isTag($word); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | */ |
606 | 606 | protected function wrapText($text, $tagName, $cssClass) |
607 | 607 | { |
608 | - return sprintf( '<%1$s class="%2$s">%3$s</%1$s>', $tagName, $cssClass, $text ); |
|
608 | + return sprintf('<%1$s class="%2$s">%3$s</%1$s>', $tagName, $cssClass, $text); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | $indexOfFirstTag = null; |
620 | 620 | $words = array_values($words); |
621 | 621 | foreach ($words as $i => $word) { |
622 | - if ( !$this->checkCondition( $word, $condition ) ) { |
|
622 | + if (!$this->checkCondition($word, $condition)) { |
|
623 | 623 | $indexOfFirstTag = $i; |
624 | 624 | break; |
625 | 625 | } |
@@ -632,18 +632,18 @@ discard block |
||
632 | 632 | } |
633 | 633 | } |
634 | 634 | if ($indexOfFirstTag > 0) { |
635 | - array_splice( $words, 0, $indexOfFirstTag ); |
|
635 | + array_splice($words, 0, $indexOfFirstTag); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | return $items; |
639 | 639 | } else { |
640 | 640 | $items = array(); |
641 | 641 | foreach ($words as $pos => $s) { |
642 | - if ( $pos >= 0 && $pos <= count( $words ) ) { |
|
642 | + if ($pos >= 0 && $pos <= count($words)) { |
|
643 | 643 | $items[] = $s; |
644 | 644 | } |
645 | 645 | } |
646 | - array_splice( $words, 0, count( $words ) ); |
|
646 | + array_splice($words, 0, count($words)); |
|
647 | 647 | |
648 | 648 | return $items; |
649 | 649 | } |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | */ |
657 | 657 | protected function isTag($item) |
658 | 658 | { |
659 | - return $this->isOpeningTag( $item ) || $this->isClosingTag( $item ); |
|
659 | + return $this->isOpeningTag($item) || $this->isClosingTag($item); |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | /** |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | */ |
667 | 667 | protected function isOpeningTag($item) |
668 | 668 | { |
669 | - return preg_match( "#<[^>]+>\\s*#iU", $item ); |
|
669 | + return preg_match("#<[^>]+>\\s*#iU", $item); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | */ |
677 | 677 | protected function isClosingTag($item) |
678 | 678 | { |
679 | - return preg_match( "#</[^>]+>\\s*#iU", $item ); |
|
679 | + return preg_match("#</[^>]+>\\s*#iU", $item); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
@@ -688,10 +688,10 @@ discard block |
||
688 | 688 | $positionInNew = 0; |
689 | 689 | $operations = array(); |
690 | 690 | $matches = $this->matchingBlocks(); |
691 | - $matches[] = new Match( count( $this->oldWords ), count( $this->newWords ), 0 ); |
|
691 | + $matches[] = new Match(count($this->oldWords), count($this->newWords), 0); |
|
692 | 692 | foreach ($matches as $i => $match) { |
693 | - $matchStartsAtCurrentPositionInOld = ( $positionInOld == $match->startInOld ); |
|
694 | - $matchStartsAtCurrentPositionInNew = ( $positionInNew == $match->startInNew ); |
|
693 | + $matchStartsAtCurrentPositionInOld = ($positionInOld == $match->startInOld); |
|
694 | + $matchStartsAtCurrentPositionInNew = ($positionInNew == $match->startInNew); |
|
695 | 695 | $action = 'none'; |
696 | 696 | |
697 | 697 | if ($matchStartsAtCurrentPositionInOld == false && $matchStartsAtCurrentPositionInNew == false) { |
@@ -704,10 +704,10 @@ discard block |
||
704 | 704 | $action = 'none'; |
705 | 705 | } |
706 | 706 | if ($action != 'none') { |
707 | - $operations[] = new Operation( $action, $positionInOld, $match->startInOld, $positionInNew, $match->startInNew ); |
|
707 | + $operations[] = new Operation($action, $positionInOld, $match->startInOld, $positionInNew, $match->startInNew); |
|
708 | 708 | } |
709 | - if ( count( $match ) != 0 ) { |
|
710 | - $operations[] = new Operation( 'equal', $match->startInOld, $match->endInOld(), $match->startInNew, $match->endInNew() ); |
|
709 | + if (count($match) != 0) { |
|
710 | + $operations[] = new Operation('equal', $match->startInOld, $match->endInOld(), $match->startInNew, $match->endInNew()); |
|
711 | 711 | } |
712 | 712 | $positionInOld = $match->endInOld(); |
713 | 713 | $positionInNew = $match->endInNew(); |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | protected function matchingBlocks() |
723 | 723 | { |
724 | 724 | $matchingBlocks = array(); |
725 | - $this->findMatchingBlocks( 0, count( $this->oldWords ), 0, count( $this->newWords ), $matchingBlocks ); |
|
725 | + $this->findMatchingBlocks(0, count($this->oldWords), 0, count($this->newWords), $matchingBlocks); |
|
726 | 726 | |
727 | 727 | return $matchingBlocks; |
728 | 728 | } |
@@ -736,14 +736,14 @@ discard block |
||
736 | 736 | */ |
737 | 737 | protected function findMatchingBlocks($startInOld, $endInOld, $startInNew, $endInNew, &$matchingBlocks) |
738 | 738 | { |
739 | - $match = $this->findMatch( $startInOld, $endInOld, $startInNew, $endInNew ); |
|
739 | + $match = $this->findMatch($startInOld, $endInOld, $startInNew, $endInNew); |
|
740 | 740 | if ($match !== null) { |
741 | 741 | if ($startInOld < $match->startInOld && $startInNew < $match->startInNew) { |
742 | - $this->findMatchingBlocks( $startInOld, $match->startInOld, $startInNew, $match->startInNew, $matchingBlocks ); |
|
742 | + $this->findMatchingBlocks($startInOld, $match->startInOld, $startInNew, $match->startInNew, $matchingBlocks); |
|
743 | 743 | } |
744 | 744 | $matchingBlocks[] = $match; |
745 | - if ( $match->endInOld() < $endInOld && $match->endInNew() < $endInNew ) { |
|
746 | - $this->findMatchingBlocks( $match->endInOld(), $endInOld, $match->endInNew(), $endInNew, $matchingBlocks ); |
|
745 | + if ($match->endInOld() < $endInOld && $match->endInNew() < $endInNew) { |
|
746 | + $this->findMatchingBlocks($match->endInOld(), $endInOld, $match->endInNew(), $endInNew, $matchingBlocks); |
|
747 | 747 | } |
748 | 748 | } |
749 | 749 | } |
@@ -755,9 +755,9 @@ discard block |
||
755 | 755 | */ |
756 | 756 | protected function stripTagAttributes($word) |
757 | 757 | { |
758 | - $word = explode( ' ', trim( $word, '<>' ) ); |
|
758 | + $word = explode(' ', trim($word, '<>')); |
|
759 | 759 | |
760 | - return '<' . $word[ 0 ] . '>'; |
|
760 | + return '<'.$word[0].'>'; |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | /** |
@@ -776,23 +776,23 @@ discard block |
||
776 | 776 | $matchLengthAt = array(); |
777 | 777 | for ($indexInOld = $startInOld; $indexInOld < $endInOld; $indexInOld++) { |
778 | 778 | $newMatchLengthAt = array(); |
779 | - $index = $this->oldWords[ $indexInOld ]; |
|
780 | - if ( $this->isTag( $index ) ) { |
|
781 | - $index = $this->stripTagAttributes( $index ); |
|
779 | + $index = $this->oldWords[$indexInOld]; |
|
780 | + if ($this->isTag($index)) { |
|
781 | + $index = $this->stripTagAttributes($index); |
|
782 | 782 | } |
783 | - if ( !isset( $this->wordIndices[ $index ] ) ) { |
|
783 | + if (!isset($this->wordIndices[$index])) { |
|
784 | 784 | $matchLengthAt = $newMatchLengthAt; |
785 | 785 | continue; |
786 | 786 | } |
787 | - foreach ($this->wordIndices[ $index ] as $indexInNew) { |
|
787 | + foreach ($this->wordIndices[$index] as $indexInNew) { |
|
788 | 788 | if ($indexInNew < $startInNew) { |
789 | 789 | continue; |
790 | 790 | } |
791 | 791 | if ($indexInNew >= $endInNew) { |
792 | 792 | break; |
793 | 793 | } |
794 | - $newMatchLength = ( isset( $matchLengthAt[ $indexInNew - 1 ] ) ? $matchLengthAt[ $indexInNew - 1 ] : 0 ) + 1; |
|
795 | - $newMatchLengthAt[ $indexInNew ] = $newMatchLength; |
|
794 | + $newMatchLength = (isset($matchLengthAt[$indexInNew - 1]) ? $matchLengthAt[$indexInNew - 1] : 0) + 1; |
|
795 | + $newMatchLengthAt[$indexInNew] = $newMatchLength; |
|
796 | 796 | if ($newMatchLength > $bestMatchSize || |
797 | 797 | ( |
798 | 798 | $this->isGroupDiffs() && |