phpcs: Assignment expression not allowed
authorumherirrender <umherirrender_de.wp@web.de>
Thu, 12 Nov 2015 19:07:59 +0000 (20:07 +0100)
committerUmherirrender <umherirrender_de.wp@web.de>
Mon, 16 Nov 2015 20:56:32 +0000 (20:56 +0000)
Fix some "Assignment expression not allowed"

Found by tests:
https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs/2736/consoleFull

Change-Id: I9bc2eff20a317a74671acd49749bb336a0fd9f67

includes/diff/DairikiDiff.php
includes/diff/TableDiffFormatter.php
tests/phpunit/includes/api/RandomImageGenerator.php

index 14810da..264c87f 100644 (file)
@@ -324,7 +324,8 @@ class DiffEngine {
 
                        for ( $yi = $skip; $yi < $n_to - $endskip; $yi++ ) {
                                $line = $to_lines[$yi];
-                               if ( ( $this->ychanged[$yi] = empty( $xhash[$this->lineHash( $line )] ) ) ) {
+                               $this->ychanged[$yi] = empty( $xhash[$this->lineHash( $line )] );
+                               if ( $this->ychanged[$yi] ) {
                                        continue;
                                }
                                $yhash[$this->lineHash( $line )] = 1;
@@ -333,7 +334,8 @@ class DiffEngine {
                        }
                        for ( $xi = $skip; $xi < $n_from - $endskip; $xi++ ) {
                                $line = $from_lines[$xi];
-                               if ( ( $this->xchanged[$xi] = empty( $yhash[$this->lineHash( $line )] ) ) ) {
+                               $this->xchanged[$xi] = empty( $yhash[$this->lineHash( $line )] );
+                               if ( $this->xchanged[$xi] ) {
                                        continue;
                                }
                                $this->xv[] = $line;
index 4737f08..be38e87 100644 (file)
@@ -204,10 +204,12 @@ class TableDiffFormatter extends DiffFormatter {
                # Notice that WordLevelDiff returns HTML-escaped output.
                # Hence, we will be calling addedLine/deletedLine without HTML-escaping.
 
-               while ( $line = array_shift( $del ) ) {
+               $line = array_shift( $del );
+               while ( $line ) {
                        $aline = array_shift( $add );
                        echo '<tr>' . $this->deletedLine( $line ) .
                                $this->addedLine( $aline ) . "</tr>\n";
+                       $line = array_shift( $del );
                }
                foreach ( $add as $line ) { # If any leftovers
                        echo '<tr>' . $this->emptyLine() .
index 6374cfa..e27ba1c 100644 (file)
@@ -256,7 +256,8 @@ class RandomImageGenerator {
                        $shape->addAttribute( 'points', self::shapePointsToString( $drawSpec['shape'] ) );
                }
 
-               if ( !$fh = fopen( $filename, 'w' ) ) {
+               $fh = fopen( $filename, 'w' );
+               if ( !$fh ) {
                        throw new Exception( "couldn't open $filename for writing" );
                }
                fwrite( $fh, $svg->asXML() );