29use UnexpectedValueException;
78 foreach ( $diff->edits as $edit ) {
79 if ( $edit->type ==
'copy' ) {
80 if ( is_array( $block ) ) {
81 if ( count( $edit->orig ) <= $nlead + $ntrail ) {
85 $context = array_slice( $edit->orig, 0, $ntrail );
88 $this->
block( $x0, $ntrail + $xi - $x0,
89 $y0, $ntrail + $yi - $y0,
94 $context = $edit->orig;
96 if ( !is_array( $block ) ) {
97 $context = array_slice( $context, count( $context ) - $nlead );
98 $x0 = $xi - count( $context );
99 $y0 = $yi - count( $context );
109 $xi += count( $edit->orig );
111 if ( $edit->closing ) {
112 $yi += count( $edit->closing );
116 if ( is_array( $block ) ) {
117 $this->
block( $x0, $xi - $x0,
134 protected function block( $xbeg, $xlen, $ybeg, $ylen, &$edits ) {
136 foreach ( $edits as $edit ) {
137 if ( $edit->type ==
'copy' ) {
139 } elseif ( $edit->type ==
'add' ) {
140 $this->
added( $edit->closing );
141 } elseif ( $edit->type ==
'delete' ) {
143 } elseif ( $edit->type ==
'change' ) {
144 $this->
changed( $edit->orig, $edit->closing );
146 throw new UnexpectedValueException(
"Unknown edit type: {$edit->type}" );
162 $this->result .= $text;
169 $val = $this->result;
185 $xbeg .=
',' . ( $xbeg + $xlen - 1 );
188 $ybeg .=
',' . ( $ybeg + $ylen - 1 );
191 return $xbeg . ( $xlen ? ( $ylen ?
'c' :
'd' ) :
'a' ) . $ybeg;
218 foreach (
$lines as $line ) {
250 protected function changed( $orig, $closing ) {
253 $this->
added( $closing );
259class_alias( DiffFormatter::class,
'DiffFormatter' );
if(!file_exists( $CREDITS)) $lines