@@ -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; |
@@ -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) |
@@ -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 | { |
@@ -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 | { |
@@ -130,10 +130,10 @@ discard block |
||
| 130 | 130 | if ($this->isTag($word)) { |
| 131 | 131 | $word = $this->stripTagAttributes($word); |
| 132 | 132 | } |
| 133 | - if (isset($this->wordIndices[ $word ])) { |
|
| 134 | - $this->wordIndices[ $word ][] = $i; |
|
| 133 | + if (isset($this->wordIndices[$word])) { |
|
| 134 | + $this->wordIndices[$word][] = $i; |
|
| 135 | 135 | } else { |
| 136 | - $this->wordIndices[ $word ] = array($i); |
|
| 136 | + $this->wordIndices[$word] = array($i); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | } else { |
| 550 | 550 | $firstOrDefault = false; |
| 551 | 551 | foreach ($this->config->getSpecialCaseOpeningTags() as $x) { |
| 552 | - if (preg_match($x, $words[ 0 ])) { |
|
| 552 | + if (preg_match($x, $words[0])) { |
|
| 553 | 553 | $firstOrDefault = $x; |
| 554 | 554 | break; |
| 555 | 555 | } |
@@ -557,13 +557,13 @@ discard block |
||
| 557 | 557 | if ($firstOrDefault) { |
| 558 | 558 | $specialCaseTagInjection = '<ins class="mod">'; |
| 559 | 559 | if ($tag == 'del') { |
| 560 | - unset($words[ 0 ]); |
|
| 560 | + unset($words[0]); |
|
| 561 | 561 | } |
| 562 | - } elseif (array_search($words[ 0 ], $this->config->getSpecialCaseClosingTags()) !== false) { |
|
| 562 | + } elseif (array_search($words[0], $this->config->getSpecialCaseClosingTags()) !== false) { |
|
| 563 | 563 | $specialCaseTagInjection = '</ins>'; |
| 564 | 564 | $specialCaseTagInjectionIsBefore = true; |
| 565 | 565 | if ($tag == 'del') { |
| 566 | - unset($words[ 0 ]); |
|
| 566 | + unset($words[0]); |
|
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | } |
@@ -574,12 +574,12 @@ discard block |
||
| 574 | 574 | $this->content .= $specialCaseTagInjection.implode('', $this->extractConsecutiveWords($words, 'tag')); |
| 575 | 575 | } else { |
| 576 | 576 | $workTag = $this->extractConsecutiveWords($words, 'tag'); |
| 577 | - if (isset($workTag[ 0 ]) && $this->isOpeningTag($workTag[ 0 ]) && !$this->isClosingTag($workTag[ 0 ])) { |
|
| 578 | - if ($this->stringUtil->strpos($workTag[ 0 ], 'class=')) { |
|
| 579 | - $workTag[ 0 ] = str_replace('class="', 'class="diffmod ', $workTag[ 0 ]); |
|
| 580 | - $workTag[ 0 ] = str_replace("class='", 'class="diffmod ', $workTag[ 0 ]); |
|
| 577 | + if (isset($workTag[0]) && $this->isOpeningTag($workTag[0]) && !$this->isClosingTag($workTag[0])) { |
|
| 578 | + if ($this->stringUtil->strpos($workTag[0], 'class=')) { |
|
| 579 | + $workTag[0] = str_replace('class="', 'class="diffmod ', $workTag[0]); |
|
| 580 | + $workTag[0] = str_replace("class='", 'class="diffmod ', $workTag[0]); |
|
| 581 | 581 | } else { |
| 582 | - $workTag[ 0 ] = str_replace('>', ' class="diffmod">', $workTag[ 0 ]); |
|
| 582 | + $workTag[0] = str_replace('>', ' class="diffmod">', $workTag[0]); |
|
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | $space = $this->stringUtil->strpos($word, ' ', 1); |
| 773 | 773 | |
| 774 | 774 | if ($space) { |
| 775 | - return '<' . $this->stringUtil->substr($word, 1, $space) . '>'; |
|
| 775 | + return '<'.$this->stringUtil->substr($word, 1, $space).'>'; |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | return trim($word, '<>'); |
@@ -796,15 +796,15 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | for ($indexInOld = $startInOld; $indexInOld < $endInOld; ++$indexInOld) { |
| 798 | 798 | $newMatchLengthAt = array(); |
| 799 | - $index = $this->oldWords[ $indexInOld ]; |
|
| 799 | + $index = $this->oldWords[$indexInOld]; |
|
| 800 | 800 | if ($this->isTag($index)) { |
| 801 | 801 | $index = $this->stripTagAttributes($index); |
| 802 | 802 | } |
| 803 | - if (!isset($this->wordIndices[ $index ])) { |
|
| 803 | + if (!isset($this->wordIndices[$index])) { |
|
| 804 | 804 | $matchLengthAt = $newMatchLengthAt; |
| 805 | 805 | continue; |
| 806 | 806 | } |
| 807 | - foreach ($this->wordIndices[ $index ] as $indexInNew) { |
|
| 807 | + foreach ($this->wordIndices[$index] as $indexInNew) { |
|
| 808 | 808 | if ($indexInNew < $startInNew) { |
| 809 | 809 | continue; |
| 810 | 810 | } |
@@ -812,8 +812,8 @@ discard block |
||
| 812 | 812 | break; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - $newMatchLength = (isset($matchLengthAt[ $indexInNew - 1 ]) ? $matchLengthAt[ $indexInNew - 1 ] : 0) + 1; |
|
| 816 | - $newMatchLengthAt[ $indexInNew ] = $newMatchLength; |
|
| 815 | + $newMatchLength = (isset($matchLengthAt[$indexInNew - 1]) ? $matchLengthAt[$indexInNew - 1] : 0) + 1; |
|
| 816 | + $newMatchLengthAt[$indexInNew] = $newMatchLength; |
|
| 817 | 817 | |
| 818 | 818 | if ($newMatchLength > $bestMatchSize || |
| 819 | 819 | ( |
@@ -70,8 +70,8 @@ |
||
| 70 | 70 | * @param $c |
| 71 | 71 | * @param $a |
| 72 | 72 | * @param $b |
| 73 | - * @param $i |
|
| 74 | - * @param $j |
|
| 73 | + * @param integer $i |
|
| 74 | + * @param integer $j |
|
| 75 | 75 | * @param $matches |
| 76 | 76 | */ |
| 77 | 77 | protected function compileMatches($c, $a, $b, $i, $j, &$matches) |
@@ -24,9 +24,9 @@ |
||
| 24 | 24 | * @var array |
| 25 | 25 | */ |
| 26 | 26 | protected static $listContentTags = array( |
| 27 | - 'h1','h2','h3','h4','h5','pre','div','br','hr','code', |
|
| 28 | - 'input','form','img','span','a','i','b','strong','em', |
|
| 29 | - 'font','big','del','tt','sub','sup','strike', |
|
| 27 | + 'h1', 'h2', 'h3', 'h4', 'h5', 'pre', 'div', 'br', 'hr', 'code', |
|
| 28 | + 'input', 'form', 'img', 'span', 'a', 'i', 'b', 'strong', 'em', |
|
| 29 | + 'font', 'big', 'del', 'tt', 'sub', 'sup', 'strike', |
|
| 30 | 30 | ); |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -527,7 +527,9 @@ |
||
| 527 | 527 | $mode = 'tag'; |
| 528 | 528 | } elseif (preg_match("/\s/u", $character)) { |
| 529 | 529 | $current_word .= $character; |
| 530 | - if (!$keepNewLines) $current_word = preg_replace('/\s+/Su', ' ', $current_word); |
|
| 530 | + if (!$keepNewLines) { |
|
| 531 | + $current_word = preg_replace('/\s+/Su', ' ', $current_word); |
|
| 532 | + } |
|
| 531 | 533 | } else { |
| 532 | 534 | if ($current_word != '') { |
| 533 | 535 | $words[] = $current_word; |
@@ -127,7 +127,7 @@ |
||
| 127 | 127 | public function initPurifier($defaultPurifierSerializerCache = null) |
| 128 | 128 | { |
| 129 | 129 | if (null !== $this->purifierConfig) { |
| 130 | - $HTMLPurifierConfig = $this->purifierConfig; |
|
| 130 | + $HTMLPurifierConfig = $this->purifierConfig; |
|
| 131 | 131 | } else { |
| 132 | 132 | $HTMLPurifierConfig = \HTMLPurifier_Config::createDefault(); |
| 133 | 133 | } |
@@ -286,6 +286,9 @@ discard block |
||
| 286 | 286 | return $diffList; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | + /** |
|
| 290 | + * @param string $type |
|
| 291 | + */ |
|
| 289 | 292 | protected function isOpeningListTag($word, $type = null) |
| 290 | 293 | { |
| 291 | 294 | $filter = $type !== null ? array('<'.$type) : array('<ul', '<ol', '<dl'); |
@@ -293,6 +296,9 @@ discard block |
||
| 293 | 296 | return in_array($this->stringUtil->substr($word, 0, 3), $filter); |
| 294 | 297 | } |
| 295 | 298 | |
| 299 | + /** |
|
| 300 | + * @param string $type |
|
| 301 | + */ |
|
| 296 | 302 | protected function isClosingListTag($word, $type = null) |
| 297 | 303 | { |
| 298 | 304 | $filter = $type !== null ? array('</'.$type) : array('</ul', '</ol', '</dl'); |
@@ -300,6 +306,9 @@ discard block |
||
| 300 | 306 | return in_array($this->stringUtil->substr($word, 0, 4), $filter); |
| 301 | 307 | } |
| 302 | 308 | |
| 309 | + /** |
|
| 310 | + * @param string $type |
|
| 311 | + */ |
|
| 303 | 312 | protected function isOpeningListItemTag($word, $type = null) |
| 304 | 313 | { |
| 305 | 314 | $filter = $type !== null ? array('<'.$type) : array('<li', '<dd', '<dt'); |
@@ -307,6 +316,9 @@ discard block |
||
| 307 | 316 | return in_array($this->stringUtil->substr($word, 0, 3), $filter); |
| 308 | 317 | } |
| 309 | 318 | |
| 319 | + /** |
|
| 320 | + * @param string $type |
|
| 321 | + */ |
|
| 310 | 322 | protected function isClosingListItemTag($word, $type = null) |
| 311 | 323 | { |
| 312 | 324 | $filter = $type !== null ? array('</'.$type) : array('</li', '</dd', '</dt'); |
@@ -4,6 +4,11 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Preprocessor |
| 6 | 6 | { |
| 7 | + /** |
|
| 8 | + * @param string $old |
|
| 9 | + * @param string $new |
|
| 10 | + * @param Util\MbStringUtil $stringUtil |
|
| 11 | + */ |
|
| 7 | 12 | public static function diffCommonPrefix($old, $new, $stringUtil) |
| 8 | 13 | { |
| 9 | 14 | // Quick check for common null cases. |
@@ -34,6 +39,11 @@ discard block |
||
| 34 | 39 | return $pointerMid; |
| 35 | 40 | } |
| 36 | 41 | |
| 42 | + /** |
|
| 43 | + * @param string $old |
|
| 44 | + * @param string $new |
|
| 45 | + * @param Util\MbStringUtil $stringUtil |
|
| 46 | + */ |
|
| 37 | 47 | public static function diffCommonSuffix($old, $new, $stringUtil) |
| 38 | 48 | { |
| 39 | 49 | // Quick check for common null cases. |