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