@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | /** |
458 | 458 | * @param string $text |
459 | 459 | * |
460 | - * @return bool |
|
460 | + * @return integer |
|
461 | 461 | */ |
462 | 462 | protected function isPartOfWord($text) |
463 | 463 | { |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | /** |
610 | 610 | * @param string $str |
611 | 611 | * |
612 | - * @return bool |
|
612 | + * @return integer |
|
613 | 613 | */ |
614 | 614 | protected function ctypeAlphanumUnicode($str) |
615 | 615 | { |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | public function initPurifier($defaultPurifierSerializerCache = null) |
121 | 121 | { |
122 | 122 | if (null !== $this->purifierConfig) { |
123 | - $HTMLPurifierConfig = $this->purifierConfig; |
|
123 | + $HTMLPurifierConfig = $this->purifierConfig; |
|
124 | 124 | } else { |
125 | 125 | $HTMLPurifierConfig = \HTMLPurifier_Config::createDefault(); |
126 | 126 | } |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | { |
401 | 401 | $expStr = mb_split($start, $str, 2); |
402 | 402 | if (count($expStr) > 1) { |
403 | - $expStr = mb_split($end, $expStr[ 1 ]); |
|
403 | + $expStr = mb_split($end, $expStr[1]); |
|
404 | 404 | if (count($expStr) > 1) { |
405 | 405 | array_pop($expStr); |
406 | 406 |
@@ -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; |
@@ -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(mb_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(mb_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(mb_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'); |
@@ -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 (mb_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 (mb_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 = mb_strpos($word, ' ', 1); |
773 | 773 | |
774 | 774 | if ($space) { |
775 | - return '<' . mb_substr($word, 1, $space) . '>'; |
|
775 | + return '<'.mb_substr($word, 1, $space).'>'; |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | return trim($word, '<>'); |
@@ -795,15 +795,15 @@ discard block |
||
795 | 795 | |
796 | 796 | for ($indexInOld = $startInOld; $indexInOld < $endInOld; ++$indexInOld) { |
797 | 797 | $newMatchLengthAt = array(); |
798 | - $index = $this->oldWords[ $indexInOld ]; |
|
798 | + $index = $this->oldWords[$indexInOld]; |
|
799 | 799 | if ($this->isTag($index)) { |
800 | 800 | $index = $this->stripTagAttributes($index); |
801 | 801 | } |
802 | - if (!isset($this->wordIndices[ $index ])) { |
|
802 | + if (!isset($this->wordIndices[$index])) { |
|
803 | 803 | $matchLengthAt = $newMatchLengthAt; |
804 | 804 | continue; |
805 | 805 | } |
806 | - foreach ($this->wordIndices[ $index ] as $indexInNew) { |
|
806 | + foreach ($this->wordIndices[$index] as $indexInNew) { |
|
807 | 807 | if ($indexInNew < $startInNew) { |
808 | 808 | continue; |
809 | 809 | } |
@@ -811,8 +811,8 @@ discard block |
||
811 | 811 | break; |
812 | 812 | } |
813 | 813 | |
814 | - $newMatchLength = (isset($matchLengthAt[ $indexInNew - 1 ]) ? $matchLengthAt[ $indexInNew - 1 ] : 0) + 1; |
|
815 | - $newMatchLengthAt[ $indexInNew ] = $newMatchLength; |
|
814 | + $newMatchLength = (isset($matchLengthAt[$indexInNew - 1]) ? $matchLengthAt[$indexInNew - 1] : 0) + 1; |
|
815 | + $newMatchLengthAt[$indexInNew] = $newMatchLength; |
|
816 | 816 | |
817 | 817 | if ($newMatchLength > $bestMatchSize || |
818 | 818 | ( |