MediaWiki master
UnifiedDiffFormatter.php
Go to the documentation of this file.
1<?php
27namespace Wikimedia\Diff;
28
35
37 protected $leadingContextLines = 2;
38
40 protected $trailingContextLines = 2;
41
46 protected function lines( $lines, $prefix = ' ' ) {
47 foreach ( $lines as $line ) {
48 $this->writeOutput( "{$prefix}{$line}\n" );
49 }
50 }
51
55 protected function added( $lines ) {
56 $this->lines( $lines, '+' );
57 }
58
62 protected function deleted( $lines ) {
63 $this->lines( $lines, '-' );
64 }
65
70 protected function changed( $orig, $closing ) {
71 $this->deleted( $orig );
72 $this->added( $closing );
73 }
74
83 protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
84 return "@@ -$xbeg,$xlen +$ybeg,$ylen @@";
85 }
86
87}
88
90class_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)
if(!file_exists( $CREDITS)) $lines