MediaWiki REL1_39
ArrayDiffFormatter.php
Go to the documentation of this file.
1<?php
33
40 public function format( $diff ) {
41 $oldline = 1;
42 $newline = 1;
43 $retval = [];
44 foreach ( $diff->getEdits() as $edit ) {
45 switch ( $edit->getType() ) {
46 case 'add':
47 foreach ( $edit->getClosing() as $line ) {
48 $retval[] = [
49 'action' => 'add',
50 'new' => $line,
51 'newline' => $newline++
52 ];
53 }
54 break;
55 case 'delete':
56 foreach ( $edit->getOrig() as $line ) {
57 $retval[] = [
58 'action' => 'delete',
59 'old' => $line,
60 'oldline' => $oldline++,
61 ];
62 }
63 break;
64 case 'change':
65 foreach ( $edit->getOrig() as $key => $line ) {
66 $retval[] = [
67 'action' => 'change',
68 'old' => $line,
69 'new' => $edit->getClosing( $key ),
70 'oldline' => $oldline++,
71 'newline' => $newline++,
72 ];
73 }
74 break;
75 case 'copy':
76 $oldline += $edit->norig();
77 $newline += $edit->norig();
78 }
79 }
80
81 return $retval;
82 }
83
84}
A pseudo-formatter that just passes along the Diff::$edits array.
Base class for diff formatters.
$line
Definition mcc.php:119