MediaWiki master
UnifiedDiffFormatter.php
Go to the documentation of this file.
1<?php
13namespace Wikimedia\Diff;
14
21
23 protected $leadingContextLines = 2;
24
26 protected $trailingContextLines = 2;
27
32 protected function lines( $lines, $prefix = ' ' ) {
33 foreach ( $lines as $line ) {
34 $this->writeOutput( "{$prefix}{$line}\n" );
35 }
36 }
37
41 protected function added( $lines ) {
42 $this->lines( $lines, '+' );
43 }
44
48 protected function deleted( $lines ) {
49 $this->lines( $lines, '-' );
50 }
51
56 protected function changed( $orig, $closing ) {
57 $this->deleted( $orig );
58 $this->added( $closing );
59 }
60
69 protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
70 return "@@ -$xbeg,$xlen +$ybeg,$ylen @@";
71 }
72
73}
74
76class_alias( UnifiedDiffFormatter::class, 'UnifiedDiffFormatter' );
Base class for diff formatters.
writeOutput( $text)
Writes a string to the output buffer.
A formatter that outputs unified diffs.
blockHeader( $xbeg, $xlen, $ybeg, $ylen)