Initialise variables and update documentation
authorSiebrand Mazeland <s.mazeland@xs4all.nl>
Wed, 20 Nov 2013 19:57:15 +0000 (20:57 +0100)
committerSiebrand Mazeland <s.mazeland@xs4all.nl>
Wed, 20 Nov 2013 19:57:52 +0000 (20:57 +0100)
Change-Id: Idb242f65801ee79531c2300cf9fcb5b3929f66ab

includes/diff/DairikiDiff.php
includes/diff/DiffFormatter.php

index 37f1e59..2781597 100644 (file)
@@ -384,6 +384,8 @@ class DiffEngine {
                                if ( empty( $ymatches[$line] ) ) {
                                        continue;
                                }
+
+                               $k = 0;
                                $matches = $ymatches[$line];
                                reset( $matches );
                                while ( list( , $y ) = each( $matches ) ) {
@@ -394,6 +396,7 @@ class DiffEngine {
                                                break;
                                        }
                                }
+
                                while ( list( , $y ) = each( $matches ) ) {
                                        if ( $y > $this->seq[$k - 1] ) {
                                                assert( '$y < $this->seq[$k]' );
index 428e97d..66faea8 100644 (file)
@@ -66,6 +66,8 @@ abstract class DiffFormatter {
 
                $this->startDiff();
 
+               // Initialize $x0 and $y0 to prevent IDEs from getting confused.
+               $x0 = $y0 = 0;
                foreach ( $diff->edits as $edit ) {
                        if ( $edit->type == 'copy' ) {
                                if ( is_array( $block ) ) {
@@ -117,11 +119,12 @@ abstract class DiffFormatter {
        }
 
        /**
-        * @param $xbeg
-        * @param $xlen
-        * @param $ybeg
-        * @param $ylen
+        * @param int $xbeg
+        * @param int $xlen
+        * @param int $ybeg
+        * @param int $ylen
         * @param $edits
+        * @throws MWException
         */
        protected function block( $xbeg, $xlen, $ybeg, $ylen, &$edits ) {
                wfProfileIn( __METHOD__ );