From 493f4222cb0e5305b0edb7a6ac0d26ac8ed56bf3 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Thu, 12 Nov 2015 20:07:59 +0100 Subject: [PATCH] phpcs: Assignment expression not allowed 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 | 6 ++++-- includes/diff/TableDiffFormatter.php | 4 +++- tests/phpunit/includes/api/RandomImageGenerator.php | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/includes/diff/DairikiDiff.php b/includes/diff/DairikiDiff.php index 14810da49c..264c87fdfc 100644 --- a/includes/diff/DairikiDiff.php +++ b/includes/diff/DairikiDiff.php @@ -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; diff --git a/includes/diff/TableDiffFormatter.php b/includes/diff/TableDiffFormatter.php index 4737f08546..be38e8759c 100644 --- a/includes/diff/TableDiffFormatter.php +++ b/includes/diff/TableDiffFormatter.php @@ -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 '' . $this->deletedLine( $line ) . $this->addedLine( $aline ) . "\n"; + $line = array_shift( $del ); } foreach ( $add as $line ) { # If any leftovers echo '' . $this->emptyLine() . diff --git a/tests/phpunit/includes/api/RandomImageGenerator.php b/tests/phpunit/includes/api/RandomImageGenerator.php index 6374cfac81..e27ba1c067 100644 --- a/tests/phpunit/includes/api/RandomImageGenerator.php +++ b/tests/phpunit/includes/api/RandomImageGenerator.php @@ -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() ); -- 2.20.1