Merge "Add some settings and quoted test in code tags"
[lhc/web/wiklou.git] / includes / diff / DairikiDiff.php
index 351a9dd..0e38d68 100644 (file)
  */
 abstract class DiffOp {
 
+       /**
+        * @var string
+        */
        public $type;
+
+       /**
+        * @var string[]
+        */
        public $orig;
+
+       /**
+        * @var string[]
+        */
        public $closing;
 
+       /**
+        * @return string
+        */
        public function getType() {
                return $this->type;
        }
 
+       /**
+        * @return string[]
+        */
        public function getOrig() {
                return $this->orig;
        }
 
+       /**
+        * @param int $i
+        * @return string|null
+        */
        public function getClosing( $i = null ) {
-               if( $i === null ) {
+               if ( $i === null ) {
                        return $this->closing;
                }
-               if( array_key_exists( $i, $this->closing ) ) {
+               if ( array_key_exists( $i, $this->closing ) ) {
                        return $this->closing[$i];
                }
                return null;
@@ -195,9 +216,10 @@ class DiffEngine {
        protected $lcs = 0;
 
        /**
-        * @param $from_lines
-        * @param $to_lines
-        * @return array
+        * @param string[] $from_lines
+        * @param string[] $to_lines
+        *
+        * @return DiffOp[]
         */
        public function diff( $from_lines, $to_lines ) {
                wfProfileIn( __METHOD__ );
@@ -256,8 +278,8 @@ class DiffEngine {
        }
 
        /**
-        * @param $from_lines
-        * @param $to_lines
+        * @param string[] $from_lines
+        * @param string[] $to_lines
         */
        private function diffLocal( $from_lines, $to_lines ) {
                global $wgExternalDiffEngine;
@@ -329,7 +351,9 @@ class DiffEngine {
 
        /**
         * Returns the whole line if it's small enough, or the MD5 hash otherwise
-        * @param $line string
+        *
+        * @param string $line
+        *
         * @return string
         */
        private function lineHash( $line ) {
@@ -356,12 +380,14 @@ class DiffEngine {
         * of the two files do not match, and likewise that the last lines do not
         * match.  The caller must trim matching lines from the beginning and end
         * of the portions it is going to specify.
-        * @param $xoff
-        * @param $xlim
-        * @param $yoff
-        * @param $ylim
-        * @param $nchunks
-        * @return array
+        *
+        * @param int $xoff
+        * @param int $xlim
+        * @param int $yoff
+        * @param int $ylim
+        * @param int $nchunks
+        *
+        * @return array List of two elements, integer and array[].
         */
        private function diag( $xoff, $xlim, $yoff, $ylim, $nchunks ) {
                $flip = false;
@@ -446,7 +472,8 @@ class DiffEngine {
        }
 
        /**
-        * @param $ypos
+        * @param int $ypos
+        *
         * @return int
         */
        private function lcsPos( $ypos ) {
@@ -488,10 +515,11 @@ class DiffEngine {
         *
         * Note that XLIM, YLIM are exclusive bounds.
         * All line numbers are origin-0 and discarded lines are not counted.
-        * @param $xoff
-        * @param $xlim
-        * @param $yoff
-        * @param $ylim
+        *
+        * @param int $xoff
+        * @param int $xlim
+        * @param int $yoff
+        * @param int $ylim
         */
        private function compareSeq( $xoff, $xlim, $yoff, $ylim ) {
                // Slide down the bottom initial diagonal.
@@ -688,9 +716,9 @@ class Diff {
         * Constructor.
         * Computes diff between sequences of strings.
         *
-        * @param $from_lines array An array of strings.
+        * @param string[] $from_lines An array of strings.
         *   Typically these are lines from a file.
-        * @param $to_lines array An array of strings.
+        * @param string[] $to_lines An array of strings.
         */
        public function __construct( $from_lines, $to_lines ) {
                $eng = new DiffEngine;
@@ -698,7 +726,7 @@ class Diff {
        }
 
        /**
-        * @return array|DiffOp[]
+        * @return DiffOp[]
         */
        public function getEdits() {
                return $this->edits;
@@ -711,6 +739,7 @@ class Diff {
         *
         *    $diff = new Diff($lines1, $lines2);
         *    $rev = $diff->reverse();
+        *
         * @return Object A Diff object representing the inverse of the
         *   original diff.
         */
@@ -764,7 +793,7 @@ class Diff {
         * This reconstructs the $from_lines parameter passed to the
         * constructor.
         *
-        * @return array The original sequence of strings.
+        * @return string[] The original sequence of strings.
         */
        public function orig() {
                $lines = array();
@@ -784,7 +813,7 @@ class Diff {
         * This reconstructs the $to_lines parameter passed to the
         * constructor.
         *
-        * @return array The sequence of strings.
+        * @return string[] The sequence of strings.
         */
        public function closing() {
                $lines = array();
@@ -814,18 +843,15 @@ class MappedDiff extends Diff {
         * case-insensitve diffs, or diffs which ignore
         * changes in white-space.
         *
-        * @param $from_lines array An array of strings.
+        * @param string[] $from_lines An array of strings.
         *   Typically these are lines from a file.
-        *
-        * @param $to_lines array An array of strings.
-        *
-        * @param $mapped_from_lines array This array should
+        * @param string[] $to_lines An array of strings.
+        * @param string[] $mapped_from_lines This array should
         *   have the same size number of elements as $from_lines.
         *   The elements in $mapped_from_lines and
         *   $mapped_to_lines are what is actually compared
         *   when computing the diff.
-        *
-        * @param $mapped_to_lines array This array should
+        * @param string[] $mapped_to_lines This array should
         *   have the same number of elements as $to_lines.
         */
        public function __construct( $from_lines, $to_lines,
@@ -875,7 +901,7 @@ class HWLDFWordAccumulator {
        private $tag = '';
 
        /**
-        * @param $new_tag
+        * @param string $new_tag
         */
        private function flushGroup( $new_tag ) {
                if ( $this->group !== '' ) {
@@ -894,7 +920,7 @@ class HWLDFWordAccumulator {
        }
 
        /**
-        * @param $new_tag
+        * @param string $new_tag
         */
        private function flushLine( $new_tag ) {
                $this->flushGroup( $new_tag );
@@ -908,8 +934,8 @@ class HWLDFWordAccumulator {
        }
 
        /**
-        * @param $words
-        * @param $tag string
+        * @param string[] $words
+        * @param string $tag
         */
        public function addWords( $words, $tag = '' ) {
                if ( $tag != $this->tag ) {
@@ -931,7 +957,7 @@ class HWLDFWordAccumulator {
        }
 
        /**
-        * @return array
+        * @return string[]
         */
        public function getLines() {
                $this->flushLine( '~done' );
@@ -949,8 +975,8 @@ class WordLevelDiff extends MappedDiff {
        const MAX_LINE_LENGTH = 10000;
 
        /**
-        * @param $orig_lines
-        * @param $closing_lines
+        * @param string[] $orig_lines
+        * @param string[] $closing_lines
         */
        public function __construct( $orig_lines, $closing_lines ) {
                wfProfileIn( __METHOD__ );
@@ -964,8 +990,9 @@ class WordLevelDiff extends MappedDiff {
        }
 
        /**
-        * @param $lines
-        * @return array
+        * @param string[] $lines
+        *
+        * @return array[]
         */
        private function split( $lines ) {
                wfProfileIn( __METHOD__ );
@@ -1005,7 +1032,7 @@ class WordLevelDiff extends MappedDiff {
        }
 
        /**
-        * @return array
+        * @return string[]
         */
        public function orig() {
                wfProfileIn( __METHOD__ );
@@ -1025,7 +1052,7 @@ class WordLevelDiff extends MappedDiff {
        }
 
        /**
-        * @return array
+        * @return string[]
         */
        public function closing() {
                wfProfileIn( __METHOD__ );
@@ -1043,4 +1070,5 @@ class WordLevelDiff extends MappedDiff {
 
                return $lines;
        }
+
 }