@@ -121,7 +121,7 @@ final class Differ
121121 * The constructor.
122122 *
123123 * @param string[] $old array containing the lines of the old string to compare
124- * @param string[] $new array containing the lines for the new string to compare
124+ * @param string[] $new array containing the lines of the new string to compare
125125 * @param array $options the options
126126 */
127127 public function __construct (array $ old , array $ new , array $ options = [])
@@ -290,6 +290,8 @@ public function getStatistics(): array
290290 }
291291 }
292292
293+ var_dump ($ this ->oldSrcLength );
294+
293295 $ ret ['unmodified ' ] = $ this ->oldSrcLength - $ ret ['deleted ' ];
294296 $ ret ['changedRatio ' ] = 1 - ($ ret ['unmodified ' ] / $ this ->oldSrcLength );
295297
@@ -315,21 +317,21 @@ public function getGroupedOpcodes(): array
315317 $ old = $ this ->old ;
316318 $ new = $ this ->new ;
317319
320+ $ this ->getGroupedOpcodesPre ($ old , $ new );
321+
318322 if ($ this ->oldNewComparison === 0 && $ this ->options ['fullContextIfIdentical ' ]) {
319- return [
323+ $ opcodes = [
320324 [
321325 [SequenceMatcher::OP_EQ , 0 , \count ($ old ), 0 , \count ($ new )],
322326 ],
323327 ];
328+ } else {
329+ $ opcodes = $ this ->sequenceMatcher
330+ ->setSequences ($ old , $ new )
331+ ->getGroupedOpcodes ($ this ->options ['context ' ])
332+ ;
324333 }
325334
326- $ this ->getGroupedOpcodesPre ($ old , $ new );
327-
328- $ opcodes = $ this ->sequenceMatcher
329- ->setSequences ($ old , $ new )
330- ->getGroupedOpcodes ($ this ->options ['context ' ])
331- ;
332-
333335 $ this ->getGroupedOpcodesPost ($ opcodes );
334336
335337 return $ this ->groupedOpcodes = $ opcodes ;
@@ -351,21 +353,21 @@ public function getGroupedOpcodesGnu(): array
351353 $ old = $ this ->old ;
352354 $ new = $ this ->new ;
353355
356+ $ this ->getGroupedOpcodesGnuPre ($ old , $ new );
357+
354358 if ($ this ->oldNewComparison === 0 && $ this ->options ['fullContextIfIdentical ' ]) {
355- return [
359+ $ opcodes = [
356360 [
357361 [SequenceMatcher::OP_EQ , 0 , \count ($ old ), 0 , \count ($ new )],
358362 ],
359363 ];
364+ } else {
365+ $ opcodes = $ this ->sequenceMatcher
366+ ->setSequences ($ old , $ new )
367+ ->getGroupedOpcodes ($ this ->options ['context ' ])
368+ ;
360369 }
361370
362- $ this ->getGroupedOpcodesGnuPre ($ old , $ new );
363-
364- $ opcodes = $ this ->sequenceMatcher
365- ->setSequences ($ old , $ new )
366- ->getGroupedOpcodes ($ this ->options ['context ' ])
367- ;
368-
369371 $ this ->getGroupedOpcodesGnuPost ($ opcodes );
370372
371373 return $ this ->groupedOpcodesGnu = $ opcodes ;
0 commit comments