@@ -127,7 +127,7 @@ final class Differ
127
127
* The constructor.
128
128
*
129
129
* @param string[] $old array containing the lines of the old string to compare
130
- * @param string[] $new array containing the lines for the new string to compare
130
+ * @param string[] $new array containing the lines of the new string to compare
131
131
* @param array $options the options
132
132
*/
133
133
public function __construct (array $ old , array $ new , array $ options = [])
@@ -296,6 +296,8 @@ public function getStatistics(): array
296
296
}
297
297
}
298
298
299
+ var_dump ($ this ->oldSrcLength );
300
+
299
301
$ ret ['unmodified ' ] = $ this ->oldSrcLength - $ ret ['deleted ' ];
300
302
$ ret ['changedRatio ' ] = 1 - ($ ret ['unmodified ' ] / $ this ->oldSrcLength );
301
303
@@ -321,20 +323,20 @@ public function getGroupedOpcodes(): array
321
323
$ old = $ this ->old ;
322
324
$ new = $ this ->new ;
323
325
326
+ $ this ->getGroupedOpcodesPre ($ old , $ new );
327
+
324
328
if ($ this ->oldNewComparison === 0 && $ this ->options ['fullContextIfIdentical ' ]) {
325
- return [
329
+ $ opcodes = [
326
330
[
327
331
[SequenceMatcher::OP_EQ , 0 , \count ($ old ), 0 , \count ($ new )],
328
332
],
329
333
];
334
+ } else {
335
+ $ opcodes = $ this ->sequenceMatcher
336
+ ->setSequences ($ old , $ new )
337
+ ->getGroupedOpcodes ($ this ->options ['context ' ]);
330
338
}
331
339
332
- $ this ->getGroupedOpcodesPre ($ old , $ new );
333
-
334
- $ opcodes = $ this ->sequenceMatcher
335
- ->setSequences ($ old , $ new )
336
- ->getGroupedOpcodes ($ this ->options ['context ' ]);
337
-
338
340
$ this ->getGroupedOpcodesPost ($ opcodes );
339
341
340
342
return $ this ->groupedOpcodes = $ opcodes ;
@@ -356,20 +358,20 @@ public function getGroupedOpcodesGnu(): array
356
358
$ old = $ this ->old ;
357
359
$ new = $ this ->new ;
358
360
361
+ $ this ->getGroupedOpcodesGnuPre ($ old , $ new );
362
+
359
363
if ($ this ->oldNewComparison === 0 && $ this ->options ['fullContextIfIdentical ' ]) {
360
- return [
364
+ $ opcodes = [
361
365
[
362
366
[SequenceMatcher::OP_EQ , 0 , \count ($ old ), 0 , \count ($ new )],
363
367
],
364
368
];
369
+ } else {
370
+ $ opcodes = $ this ->sequenceMatcher
371
+ ->setSequences ($ old , $ new )
372
+ ->getGroupedOpcodes ($ this ->options ['context ' ]);
365
373
}
366
374
367
- $ this ->getGroupedOpcodesGnuPre ($ old , $ new );
368
-
369
- $ opcodes = $ this ->sequenceMatcher
370
- ->setSequences ($ old , $ new )
371
- ->getGroupedOpcodes ($ this ->options ['context ' ]);
372
-
373
375
$ this ->getGroupedOpcodesGnuPost ($ opcodes );
374
376
375
377
return $ this ->groupedOpcodesGnu = $ opcodes ;
0 commit comments