* @ingroup DifferenceEngine
*/
class TableDiffFormatter extends DiffFormatter {
+
function __construct() {
$this->leadingContextLines = 2;
$this->trailingContextLines = 2;
/**
* @static
- * @param $msg
+ * @param string $msg
+ *
* @return mixed
*/
public static function escapeWhiteSpace( $msg ) {
$msg = preg_replace( '/^ /m', '  ', $msg );
$msg = preg_replace( '/ $/m', '  ', $msg );
$msg = preg_replace( '/ /', '  ', $msg );
+
return $msg;
}
/**
- * @param $xbeg
- * @param $xlen
- * @param $ybeg
- * @param $ylen
+ * @param int $xbeg
+ * @param int $xlen
+ * @param int $ybeg
+ * @param int $ylen
+ *
* @return string
*/
protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
$r = '<tr><td colspan="2" class="diff-lineno"><!--LINE ' . $xbeg . "--></td>\n" .
'<td colspan="2" class="diff-lineno"><!--LINE ' . $ybeg . "--></td></tr>\n";
+
return $r;
}
/**
- * @param $header
+ * Writes the header to the output buffer.
+ *
+ * @param string $header
*/
protected function startBlock( $header ) {
echo $header;
protected function endBlock() {
}
+ /**
+ * @param string[] $lines
+ * @param string $prefix
+ * @param string $color
+ */
protected function lines( $lines, $prefix = ' ', $color = 'white' ) {
}
/**
* HTML-escape parameter before calling this
- * @param $line
+ *
+ * @param string $line
+ *
* @return string
*/
protected function addedLine( $line ) {
/**
* HTML-escape parameter before calling this
- * @param $line
+ *
+ * @param string $line
+ *
* @return string
*/
protected function deletedLine( $line ) {
/**
* HTML-escape parameter before calling this
- * @param $line
+ *
+ * @param string $line
+ *
* @return string
*/
protected function contextLine( $line ) {
}
/**
- * @param $marker
- * @param $class
- * @param $line
+ * @param string $marker
+ * @param string $class Unused
+ * @param string $line
+ *
* @return string
*/
protected function wrapLine( $marker, $class, $line ) {
// The <div> wrapper is needed for 'overflow: auto' style to scroll properly
$line = Xml::tags( 'div', null, $this->escapeWhiteSpace( $line ) );
}
+
return "<td class='diff-marker'>$marker</td><td class='$class'>$line</td>";
}
}
/**
- * @param $lines array
+ * Writes all lines to the output buffer, each enclosed in <tr>.
+ *
+ * @param string[] $lines
*/
protected function added( $lines ) {
foreach ( $lines as $line ) {
}
/**
- * @param $lines
+ * Writes all lines to the output buffer, each enclosed in <tr>.
+ *
+ * @param string[] $lines
*/
protected function deleted( $lines ) {
foreach ( $lines as $line ) {
}
/**
- * @param $lines
+ * Writes all lines to the output buffer, each enclosed in <tr>.
+ *
+ * @param string[] $lines
*/
protected function context( $lines ) {
foreach ( $lines as $line ) {
}
/**
- * @param $orig
- * @param $closing
+ * Writes the two sets of lines to the output buffer, each enclosed in <tr>.
+ *
+ * @param string[] $orig
+ * @param string[] $closing
*/
protected function changed( $orig, $closing ) {
wfProfileIn( __METHOD__ );
echo '<tr>' . $this->deletedLine( $line ) .
$this->addedLine( $aline ) . "</tr>\n";
}
- foreach ( $add as $line ) { # If any leftovers
+ foreach ( $add as $line ) { # If any leftovers
echo '<tr>' . $this->emptyLine() .
$this->addedLine( $line ) . "</tr>\n";
}
wfProfileOut( __METHOD__ );
}
+
}