Completed
Push — master ( 24da9e...18bd75 )
by Josh
05:16
created
lib/Caxy/HtmlDiff/AbstractDiff.php 2 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -147,6 +147,10 @@  discard block
 block discarded – undo
147 147
         return "</".$tag.">";
148 148
     }
149 149
 
150
+    /**
151
+     * @param string $str
152
+     * @param string $start
153
+     */
150 154
     protected function getStringBetween($str, $start, $end)
151 155
     {
152 156
         $expStr = explode( $start, $str, 2 );
@@ -162,6 +166,9 @@  discard block
 block discarded – undo
162 166
         return '';
163 167
     }
164 168
 
169
+    /**
170
+     * @param string $html
171
+     */
165 172
     protected function purifyHtml($html, $tags = null)
166 173
     {
167 174
         if ( class_exists( 'Tidy' ) && false ) {
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 
150 150
     protected function getStringBetween($str, $start, $end)
151 151
     {
152
-        $expStr = explode( $start, $str, 2 );
153
-        if ( count( $expStr ) > 1 ) {
154
-            $expStr = explode( $end, $expStr[ 1 ] );
155
-            if ( count( $expStr ) > 1 ) {
156
-                array_pop( $expStr );
152
+        $expStr = explode($start, $str, 2);
153
+        if (count($expStr) > 1) {
154
+            $expStr = explode($end, $expStr[1]);
155
+            if (count($expStr) > 1) {
156
+                array_pop($expStr);
157 157
 
158
-                return implode( $end, $expStr );
158
+                return implode($end, $expStr);
159 159
             }
160 160
         }
161 161
 
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 
165 165
     protected function purifyHtml($html, $tags = null)
166 166
     {
167
-        if ( class_exists( 'Tidy' ) && false ) {
168
-            $config = array( 'output-xhtml'   => true, 'indent' => false );
167
+        if (class_exists('Tidy') && false) {
168
+            $config = array('output-xhtml'   => true, 'indent' => false);
169 169
             $tidy = new tidy();
170
-            $tidy->parseString( $html, $config, 'utf8' );
170
+            $tidy->parseString($html, $config, 'utf8');
171 171
             $html = (string) $tidy;
172 172
 
173
-            return $this->getStringBetween( $html, '<body>' );
173
+            return $this->getStringBetween($html, '<body>');
174 174
         }
175 175
 
176 176
         return $html;
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 
179 179
     protected function splitInputsToWords()
180 180
     {
181
-        $this->oldWords = $this->convertHtmlToListOfWords( $this->explode( $this->oldText ) );
182
-        $this->newWords = $this->convertHtmlToListOfWords( $this->explode( $this->newText ) );
181
+        $this->oldWords = $this->convertHtmlToListOfWords($this->explode($this->oldText));
182
+        $this->newWords = $this->convertHtmlToListOfWords($this->explode($this->newText));
183 183
     }
184 184
 
185 185
     protected function isPartOfWord($text)
@@ -195,13 +195,13 @@  discard block
 block discarded – undo
195 195
         foreach ($characterString as $i => $character) {
196 196
             switch ($mode) {
197 197
                 case 'character':
198
-                if ( $this->isStartOfTag( $character ) ) {
198
+                if ($this->isStartOfTag($character)) {
199 199
                     if ($current_word != '') {
200 200
                         $words[] = $current_word;
201 201
                     }
202 202
                     $current_word = "<";
203 203
                     $mode = 'tag';
204
-                } elseif ( preg_match( "[^\s]", $character ) > 0 ) {
204
+                } elseif (preg_match("[^\s]", $character) > 0) {
205 205
                     if ($current_word != '') {
206 206
                         $words[] = $current_word;
207 207
                     }
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
                 } else {
211 211
                     if (
212 212
                         (ctype_alnum($character) && (strlen($current_word) == 0 || $this->isPartOfWord($current_word))) ||
213
-                        (in_array($character, $this->specialCaseChars) && isset($characterString[$i+1]) && $this->isPartOfWord($characterString[$i+1]))
213
+                        (in_array($character, $this->specialCaseChars) && isset($characterString[$i + 1]) && $this->isPartOfWord($characterString[$i + 1]))
214 214
                     ) {
215 215
                         $current_word .= $character;
216 216
                     } else {
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
                 }
221 221
                 break;
222 222
                 case 'tag' :
223
-                if ( $this->isEndOfTag( $character ) ) {
223
+                if ($this->isEndOfTag($character)) {
224 224
                     $current_word .= ">";
225 225
                     $words[] = $current_word;
226 226
                     $current_word = "";
227 227
 
228
-                    if ( !preg_match('[^\s]', $character ) ) {
228
+                    if (!preg_match('[^\s]', $character)) {
229 229
                         $mode = 'whitespace';
230 230
                     } else {
231 231
                         $mode = 'character';
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
                 }
236 236
                 break;
237 237
                 case 'whitespace':
238
-                if ( $this->isStartOfTag( $character ) ) {
238
+                if ($this->isStartOfTag($character)) {
239 239
                     if ($current_word != '') {
240 240
                         $words[] = $current_word;
241 241
                     }
242 242
                     $current_word = "<";
243 243
                     $mode = 'tag';
244
-                } elseif ( preg_match( "[^\s]", $character ) ) {
244
+                } elseif (preg_match("[^\s]", $character)) {
245 245
                     $current_word .= $character;
246 246
                 } else {
247 247
                     if ($current_word != '') {
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 
275 275
     protected function isWhiteSpace($value)
276 276
     {
277
-        return !preg_match( '[^\s]', $value );
277
+        return !preg_match('[^\s]', $value);
278 278
     }
279 279
 
280 280
     protected function explode($value)
281 281
     {
282 282
         // as suggested by @onassar
283
-        return preg_split( '//u', $value );
283
+        return preg_split('//u', $value);
284 284
     }
285 285
 }
Please login to merge, or discard this patch.
lib/Caxy/HtmlDiff/HtmlDiff.php 2 patches
Doc Comments   +29 added lines patch added patch discarded remove patch
@@ -157,6 +157,9 @@  discard block
 block discarded – undo
157 157
         $this->processInsertOperation( $operation, "diffmod" );
158 158
     }
159 159
 
160
+    /**
161
+     * @param string $cssClass
162
+     */
160 163
     protected function processInsertOperation($operation, $cssClass)
161 164
     {
162 165
         $text = array();
@@ -174,6 +177,9 @@  discard block
 block discarded – undo
174 177
         $this->insertTag( "ins", $cssClass, $text );
175 178
     }
176 179
 
180
+    /**
181
+     * @param string $cssClass
182
+     */
177 183
     protected function processDeleteOperation($operation, $cssClass)
178 184
     {
179 185
         $text = array();
@@ -191,6 +197,10 @@  discard block
 block discarded – undo
191 197
         $this->insertTag( "del", $cssClass, $text );
192 198
     }
193 199
 
200
+    /**
201
+     * @param string $oldText
202
+     * @param string $newText
203
+     */
194 204
     protected function diffElements($oldText, $newText, $stripWrappingTags = true)
195 205
     {
196 206
         $wrapStart = '';
@@ -213,6 +223,10 @@  discard block
 block discarded – undo
213 223
         return $wrapStart . $diff->build() . $wrapEnd;
214 224
     }
215 225
 
226
+    /**
227
+     * @param string $oldText
228
+     * @param string $newText
229
+     */
216 230
     protected function diffList($oldText, $newText)
217 231
     {
218 232
         $diff = new ListDiff($oldText, $newText, $this->encoding, $this->specialCaseTags, $this->groupDiffs);
@@ -263,6 +277,9 @@  discard block
 block discarded – undo
263 277
         return $this->oldIsolatedDiffTags[$operation->startInOld + $offset];
264 278
     }
265 279
 
280
+    /**
281
+     * @param string $tag
282
+     */
266 283
     protected function insertTag($tag, $cssClass, &$words)
267 284
     {
268 285
         while (true) {
@@ -324,11 +341,17 @@  discard block
 block discarded – undo
324 341
         return $condition == 'tag' ? $this->isTag( $word ) : !$this->isTag( $word );
325 342
     }
326 343
 
344
+    /**
345
+     * @param string $text
346
+     */
327 347
     protected function wrapText($text, $tagName, $cssClass)
328 348
     {
329 349
         return sprintf( '<%1$s class="%2$s">%3$s</%1$s>', $tagName, $cssClass, $text );
330 350
     }
331 351
 
352
+    /**
353
+     * @param string $condition
354
+     */
332 355
     protected function extractConsecutiveWords(&$words, $condition)
333 356
     {
334 357
         $indexOfFirstTag = null;
@@ -420,6 +443,12 @@  discard block
 block discarded – undo
420 443
         return $matchingBlocks;
421 444
     }
422 445
 
446
+    /**
447
+     * @param integer $startInOld
448
+     * @param integer $endInOld
449
+     * @param integer $startInNew
450
+     * @param integer $endInNew
451
+     */
423 452
     protected function findMatchingBlocks($startInOld, $endInOld, $startInNew, $endInNew, &$matchingBlocks)
424 453
     {
425 454
         $match = $this->findMatch( $startInOld, $endInOld, $startInNew, $endInNew );
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
     protected $insertSpaceInReplace = false;
9 9
     protected $newIsolatedDiffTags;
10 10
     protected $oldIsolatedDiffTags;
11
-    protected $isolatedDiffTags = array (
11
+    protected $isolatedDiffTags = array(
12 12
         'ol' => '[[REPLACE_ORDERED_LIST]]',
13 13
         'ul' => '[[REPLACE_UNORDERED_LIST]]',
14 14
         'sub' => '[[REPLACE_SUB_SCRIPT]]',
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
         $operations = $this->operations();
46 46
         foreach ($operations as $item) {
47
-            $this->performOperation( $item );
47
+            $this->performOperation($item);
48 48
         }
49 49
 
50 50
         return $this->content;
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
     {
55 55
         $this->wordIndices = array();
56 56
         foreach ($this->newWords as $i => $word) {
57
-            if ( $this->isTag( $word ) ) {
58
-                $word = $this->stripTagAttributes( $word );
57
+            if ($this->isTag($word)) {
58
+                $word = $this->stripTagAttributes($word);
59 59
             }
60
-            if ( isset( $this->wordIndices[ $word ] ) ) {
61
-                $this->wordIndices[ $word ][] = $i;
60
+            if (isset($this->wordIndices[$word])) {
61
+                $this->wordIndices[$word][] = $i;
62 62
             } else {
63
-                $this->wordIndices[ $word ] = array( $i );
63
+                $this->wordIndices[$word] = array($i);
64 64
             }
65 65
         }
66 66
     }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
             } elseif ($openIsolatedDiffTags > 0 && $this->isClosingIsolatedDiffTag($word, $currentIsolatedDiffTag)) {
90 90
                 $openIsolatedDiffTags--;
91 91
                 if ($openIsolatedDiffTags == 0) {
92
-                    $isolatedDiffTagIndicies[] = array ('start' => $isolatedDiffTagStart, 'length' => $index - $isolatedDiffTagStart + 1, 'tagType' => $currentIsolatedDiffTag);
92
+                    $isolatedDiffTagIndicies[] = array('start' => $isolatedDiffTagStart, 'length' => $index - $isolatedDiffTagStart + 1, 'tagType' => $currentIsolatedDiffTag);
93 93
                     $currentIsolatedDiffTag = null;
94 94
                 }
95 95
             }
@@ -135,16 +135,16 @@  discard block
 block discarded – undo
135 135
     {
136 136
         switch ($operation->action) {
137 137
             case 'equal' :
138
-            $this->processEqualOperation( $operation );
138
+            $this->processEqualOperation($operation);
139 139
             break;
140 140
             case 'delete' :
141
-            $this->processDeleteOperation( $operation, "diffdel" );
141
+            $this->processDeleteOperation($operation, "diffdel");
142 142
             break;
143 143
             case 'insert' :
144
-            $this->processInsertOperation( $operation, "diffins");
144
+            $this->processInsertOperation($operation, "diffins");
145 145
             break;
146 146
             case 'replace':
147
-            $this->processReplaceOperation( $operation );
147
+            $this->processReplaceOperation($operation);
148 148
             break;
149 149
             default:
150 150
             break;
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 
154 154
     protected function processReplaceOperation($operation)
155 155
     {
156
-        $this->processDeleteOperation( $operation, "diffmod" );
157
-        $this->processInsertOperation( $operation, "diffmod" );
156
+        $this->processDeleteOperation($operation, "diffmod");
157
+        $this->processInsertOperation($operation, "diffmod");
158 158
     }
159 159
 
160 160
     protected function processInsertOperation($operation, $cssClass)
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                 }
172 172
             }
173 173
         }
174
-        $this->insertTag( "ins", $cssClass, $text );
174
+        $this->insertTag("ins", $cssClass, $text);
175 175
     }
176 176
 
177 177
     protected function processDeleteOperation($operation, $cssClass)
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                 }
189 189
             }
190 190
         }
191
-        $this->insertTag( "del", $cssClass, $text );
191
+        $this->insertTag("del", $cssClass, $text);
192 192
     }
193 193
 
194 194
     protected function diffElements($oldText, $newText, $stripWrappingTags = true)
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 
211 211
         $diff = new HtmlDiff($oldText, $newText, $this->encoding, $this->specialCaseTags, $this->groupDiffs);
212 212
 
213
-        return $wrapStart . $diff->build() . $wrapEnd;
213
+        return $wrapStart.$diff->build().$wrapEnd;
214 214
     }
215 215
 
216 216
     protected function diffList($oldText, $newText)
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
                 }
241 241
             }
242 242
         }
243
-        $this->content .= implode( "", $result );
243
+        $this->content .= implode("", $result);
244 244
     }
245 245
 
246 246
     protected function isListPlaceholder($text)
@@ -266,22 +266,22 @@  discard block
 block discarded – undo
266 266
     protected function insertTag($tag, $cssClass, &$words)
267 267
     {
268 268
         while (true) {
269
-            if ( count( $words ) == 0 ) {
269
+            if (count($words) == 0) {
270 270
                 break;
271 271
             }
272 272
 
273
-            $nonTags = $this->extractConsecutiveWords( $words, 'noTag' );
273
+            $nonTags = $this->extractConsecutiveWords($words, 'noTag');
274 274
 
275 275
             $specialCaseTagInjection = '';
276 276
             $specialCaseTagInjectionIsBefore = false;
277 277
 
278
-            if ( count( $nonTags ) != 0 ) {
279
-                $text = $this->wrapText( implode( "", $nonTags ), $tag, $cssClass );
278
+            if (count($nonTags) != 0) {
279
+                $text = $this->wrapText(implode("", $nonTags), $tag, $cssClass);
280 280
                 $this->content .= $text;
281 281
             } else {
282 282
                 $firstOrDefault = false;
283 283
                 foreach ($this->specialCaseOpeningTags as $x) {
284
-                    if ( preg_match( $x, $words[ 0 ] ) ) {
284
+                    if (preg_match($x, $words[0])) {
285 285
                         $firstOrDefault = $x;
286 286
                         break;
287 287
                     }
@@ -289,51 +289,51 @@  discard block
 block discarded – undo
289 289
                 if ($firstOrDefault) {
290 290
                     $specialCaseTagInjection = '<ins class="mod">';
291 291
                     if ($tag == "del") {
292
-                        unset( $words[ 0 ] );
292
+                        unset($words[0]);
293 293
                     }
294
-                } elseif ( array_search( $words[ 0 ], $this->specialCaseClosingTags ) !== false ) {
294
+                } elseif (array_search($words[0], $this->specialCaseClosingTags) !== false) {
295 295
                     $specialCaseTagInjection = "</ins>";
296 296
                     $specialCaseTagInjectionIsBefore = true;
297 297
                     if ($tag == "del") {
298
-                        unset( $words[ 0 ] );
298
+                        unset($words[0]);
299 299
                     }
300 300
                 }
301 301
             }
302
-            if ( count( $words ) == 0 && count( $specialCaseTagInjection ) == 0 ) {
302
+            if (count($words) == 0 && count($specialCaseTagInjection) == 0) {
303 303
                 break;
304 304
             }
305 305
             if ($specialCaseTagInjectionIsBefore) {
306
-                $this->content .= $specialCaseTagInjection . implode( "", $this->extractConsecutiveWords( $words, 'tag' ) );
306
+                $this->content .= $specialCaseTagInjection.implode("", $this->extractConsecutiveWords($words, 'tag'));
307 307
             } else {
308
-                $workTag = $this->extractConsecutiveWords( $words, 'tag' );
309
-                if ( isset( $workTag[ 0 ] ) && $this->isOpeningTag( $workTag[ 0 ] ) && !$this->isClosingTag( $workTag[ 0 ] ) ) {
310
-                    if ( strpos( $workTag[ 0 ], 'class=' ) ) {
311
-                        $workTag[ 0 ] = str_replace( 'class="', 'class="diffmod ', $workTag[ 0 ] );
312
-                        $workTag[ 0 ] = str_replace( "class='", 'class="diffmod ', $workTag[ 0 ] );
308
+                $workTag = $this->extractConsecutiveWords($words, 'tag');
309
+                if (isset($workTag[0]) && $this->isOpeningTag($workTag[0]) && !$this->isClosingTag($workTag[0])) {
310
+                    if (strpos($workTag[0], 'class=')) {
311
+                        $workTag[0] = str_replace('class="', 'class="diffmod ', $workTag[0]);
312
+                        $workTag[0] = str_replace("class='", 'class="diffmod ', $workTag[0]);
313 313
                     } else {
314
-                        $workTag[ 0 ] = str_replace( ">", ' class="diffmod">', $workTag[ 0 ] );
314
+                        $workTag[0] = str_replace(">", ' class="diffmod">', $workTag[0]);
315 315
                     }
316 316
                 }
317
-                $this->content .= implode( "", $workTag ) . $specialCaseTagInjection;
317
+                $this->content .= implode("", $workTag).$specialCaseTagInjection;
318 318
             }
319 319
         }
320 320
     }
321 321
 
322 322
     protected function checkCondition($word, $condition)
323 323
     {
324
-        return $condition == 'tag' ? $this->isTag( $word ) : !$this->isTag( $word );
324
+        return $condition == 'tag' ? $this->isTag($word) : !$this->isTag($word);
325 325
     }
326 326
 
327 327
     protected function wrapText($text, $tagName, $cssClass)
328 328
     {
329
-        return sprintf( '<%1$s class="%2$s">%3$s</%1$s>', $tagName, $cssClass, $text );
329
+        return sprintf('<%1$s class="%2$s">%3$s</%1$s>', $tagName, $cssClass, $text);
330 330
     }
331 331
 
332 332
     protected function extractConsecutiveWords(&$words, $condition)
333 333
     {
334 334
         $indexOfFirstTag = null;
335 335
         foreach ($words as $i => $word) {
336
-            if ( !$this->checkCondition( $word, $condition ) ) {
336
+            if (!$this->checkCondition($word, $condition)) {
337 337
                 $indexOfFirstTag = $i;
338 338
                 break;
339 339
             }
@@ -346,18 +346,18 @@  discard block
 block discarded – undo
346 346
                 }
347 347
             }
348 348
             if ($indexOfFirstTag > 0) {
349
-                array_splice( $words, 0, $indexOfFirstTag );
349
+                array_splice($words, 0, $indexOfFirstTag);
350 350
             }
351 351
 
352 352
             return $items;
353 353
         } else {
354 354
             $items = array();
355 355
             foreach ($words as $pos => $s) {
356
-                if ( $pos >= 0 && $pos <= count( $words ) ) {
356
+                if ($pos >= 0 && $pos <= count($words)) {
357 357
                     $items[] = $s;
358 358
                 }
359 359
             }
360
-            array_splice( $words, 0, count( $words ) );
360
+            array_splice($words, 0, count($words));
361 361
 
362 362
             return $items;
363 363
         }
@@ -365,17 +365,17 @@  discard block
 block discarded – undo
365 365
 
366 366
     protected function isTag($item)
367 367
     {
368
-        return $this->isOpeningTag( $item ) || $this->isClosingTag( $item );
368
+        return $this->isOpeningTag($item) || $this->isClosingTag($item);
369 369
     }
370 370
 
371 371
     protected function isOpeningTag($item)
372 372
     {
373
-        return preg_match( "#<[^>]+>\\s*#iU", $item );
373
+        return preg_match("#<[^>]+>\\s*#iU", $item);
374 374
     }
375 375
 
376 376
     protected function isClosingTag($item)
377 377
     {
378
-        return preg_match( "#</[^>]+>\\s*#iU", $item );
378
+        return preg_match("#</[^>]+>\\s*#iU", $item);
379 379
     }
380 380
 
381 381
     protected function operations()
@@ -384,10 +384,10 @@  discard block
 block discarded – undo
384 384
         $positionInNew = 0;
385 385
         $operations = array();
386 386
         $matches = $this->matchingBlocks();
387
-        $matches[] = new Match( count( $this->oldWords ), count( $this->newWords ), 0 );
387
+        $matches[] = new Match(count($this->oldWords), count($this->newWords), 0);
388 388
         foreach ($matches as $i => $match) {
389
-            $matchStartsAtCurrentPositionInOld = ( $positionInOld == $match->startInOld );
390
-            $matchStartsAtCurrentPositionInNew = ( $positionInNew == $match->startInNew );
389
+            $matchStartsAtCurrentPositionInOld = ($positionInOld == $match->startInOld);
390
+            $matchStartsAtCurrentPositionInNew = ($positionInNew == $match->startInNew);
391 391
             $action = 'none';
392 392
 
393 393
             if ($matchStartsAtCurrentPositionInOld == false && $matchStartsAtCurrentPositionInNew == false) {
@@ -400,10 +400,10 @@  discard block
 block discarded – undo
400 400
                 $action = 'none';
401 401
             }
402 402
             if ($action != 'none') {
403
-                $operations[] = new Operation( $action, $positionInOld, $match->startInOld, $positionInNew, $match->startInNew );
403
+                $operations[] = new Operation($action, $positionInOld, $match->startInOld, $positionInNew, $match->startInNew);
404 404
             }
405
-            if ( count( $match ) != 0 ) {
406
-                $operations[] = new Operation( 'equal', $match->startInOld, $match->endInOld(), $match->startInNew, $match->endInNew() );
405
+            if (count($match) != 0) {
406
+                $operations[] = new Operation('equal', $match->startInOld, $match->endInOld(), $match->startInNew, $match->endInNew());
407 407
             }
408 408
             $positionInOld = $match->endInOld();
409 409
             $positionInNew = $match->endInNew();
@@ -415,30 +415,30 @@  discard block
 block discarded – undo
415 415
     protected function matchingBlocks()
416 416
     {
417 417
         $matchingBlocks = array();
418
-        $this->findMatchingBlocks( 0, count( $this->oldWords ), 0, count( $this->newWords ), $matchingBlocks );
418
+        $this->findMatchingBlocks(0, count($this->oldWords), 0, count($this->newWords), $matchingBlocks);
419 419
 
420 420
         return $matchingBlocks;
421 421
     }
422 422
 
423 423
     protected function findMatchingBlocks($startInOld, $endInOld, $startInNew, $endInNew, &$matchingBlocks)
424 424
     {
425
-        $match = $this->findMatch( $startInOld, $endInOld, $startInNew, $endInNew );
425
+        $match = $this->findMatch($startInOld, $endInOld, $startInNew, $endInNew);
426 426
         if ($match !== null) {
427 427
             if ($startInOld < $match->startInOld && $startInNew < $match->startInNew) {
428
-                $this->findMatchingBlocks( $startInOld, $match->startInOld, $startInNew, $match->startInNew, $matchingBlocks );
428
+                $this->findMatchingBlocks($startInOld, $match->startInOld, $startInNew, $match->startInNew, $matchingBlocks);
429 429
             }
430 430
             $matchingBlocks[] = $match;
431
-            if ( $match->endInOld() < $endInOld && $match->endInNew() < $endInNew ) {
432
-                $this->findMatchingBlocks( $match->endInOld(), $endInOld, $match->endInNew(), $endInNew, $matchingBlocks );
431
+            if ($match->endInOld() < $endInOld && $match->endInNew() < $endInNew) {
432
+                $this->findMatchingBlocks($match->endInOld(), $endInOld, $match->endInNew(), $endInNew, $matchingBlocks);
433 433
             }
434 434
         }
435 435
     }
436 436
 
437 437
     protected function stripTagAttributes($word)
438 438
     {
439
-        $word = explode( ' ', trim( $word, '<>' ) );
439
+        $word = explode(' ', trim($word, '<>'));
440 440
 
441
-        return '<' . $word[ 0 ] . '>';
441
+        return '<'.$word[0].'>';
442 442
     }
443 443
 
444 444
     protected function findMatch($startInOld, $endInOld, $startInNew, $endInNew)
@@ -449,23 +449,23 @@  discard block
 block discarded – undo
449 449
         $matchLengthAt = array();
450 450
         for ($indexInOld = $startInOld; $indexInOld < $endInOld; $indexInOld++) {
451 451
             $newMatchLengthAt = array();
452
-            $index = $this->oldWords[ $indexInOld ];
453
-            if ( $this->isTag( $index ) ) {
454
-                $index = $this->stripTagAttributes( $index );
452
+            $index = $this->oldWords[$indexInOld];
453
+            if ($this->isTag($index)) {
454
+                $index = $this->stripTagAttributes($index);
455 455
             }
456
-            if ( !isset( $this->wordIndices[ $index ] ) ) {
456
+            if (!isset($this->wordIndices[$index])) {
457 457
                 $matchLengthAt = $newMatchLengthAt;
458 458
                 continue;
459 459
             }
460
-            foreach ($this->wordIndices[ $index ] as $indexInNew) {
460
+            foreach ($this->wordIndices[$index] as $indexInNew) {
461 461
                 if ($indexInNew < $startInNew) {
462 462
                     continue;
463 463
                 }
464 464
                 if ($indexInNew >= $endInNew) {
465 465
                     break;
466 466
                 }
467
-                $newMatchLength = ( isset( $matchLengthAt[ $indexInNew - 1 ] ) ? $matchLengthAt[ $indexInNew - 1 ] : 0 ) + 1;
468
-                $newMatchLengthAt[ $indexInNew ] = $newMatchLength;
467
+                $newMatchLength = (isset($matchLengthAt[$indexInNew - 1]) ? $matchLengthAt[$indexInNew - 1] : 0) + 1;
468
+                $newMatchLengthAt[$indexInNew] = $newMatchLength;
469 469
                 if ($newMatchLength > $bestMatchSize) {
470 470
                     $bestMatchInOld = $indexInOld - $newMatchLength + 1;
471 471
                     $bestMatchInNew = $indexInNew - $newMatchLength + 1;
Please login to merge, or discard this patch.
lib/Caxy/HtmlDiff/ListDiff.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -505,6 +505,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
lib/Caxy/HtmlDiff/Match.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -8,6 +8,9 @@
 block discarded – undo
8 8
     public $startInNew;
9 9
     public $size;
10 10
 
11
+    /**
12
+     * @param integer $size
13
+     */
11 14
     public function __construct($startInOld, $startInNew, $size)
12 15
     {
13 16
         $this->startInOld = $startInOld;
Please login to merge, or discard this patch.
lib/Caxy/HtmlDiff/ListDiff/DiffList.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -14,6 +14,9 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
lib/Caxy/HtmlDiff/ListDiffNew.php 2 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -217,12 +217,18 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -219,27 +219,27 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.