From: Kunal Mehta Date: Sat, 6 Apr 2019 06:40:01 +0000 (-0700) Subject: Fix PhanPluginDuplicateExpressionBinaryOp in DjVuImage (#9) X-Git-Tag: 1.34.0-rc.0~2111^2~2 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=e77937bbac44cf179800d4e6abc5fc391b1a9735;p=lhc%2Fweb%2Fwiklou.git Fix PhanPluginDuplicateExpressionBinaryOp in DjVuImage (#9) == has a higher precedence operator than &. So the line `$chunkLength & 1 == 1` is interepreted as: `$chunkLength & true`. Probably not what was intended, but it actually works out because true is cast to 1, and the expression will either result with 0 (falsey) or 1 (truthy), and we were looking for it to equal 1 anyways. Incredible. I assume that it was supposed to be `( $chunkLength & 1 ) == 1`, so I've modified it to use that. Change-Id: If03823b9286e0d8282519949bf46e2ba4cca0843 --- diff --git a/.phan/config.php b/.phan/config.php index 64197bf30d..c250bcd7ee 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -90,8 +90,6 @@ $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [ // approximate error count: 127 "PhanParamTooMany", // approximate error count: 2 - "PhanPluginDuplicateExpressionBinaryOp", - // approximate error count: 2 "PhanTraitParentReference", // approximate error count: 30 "PhanTypeArraySuspicious", diff --git a/includes/media/DjVuImage.php b/includes/media/DjVuImage.php index d059cd8289..35cbc434e9 100644 --- a/includes/media/DjVuImage.php +++ b/includes/media/DjVuImage.php @@ -108,7 +108,7 @@ class DjVuImage { $this->dumpForm( $file, $chunkLength, $indent + 1 ); } else { fseek( $file, $chunkLength, SEEK_CUR ); - if ( $chunkLength & 1 == 1 ) { + if ( ( $chunkLength & 1 ) == 1 ) { // Padding byte between chunks fseek( $file, 1, SEEK_CUR ); } @@ -166,7 +166,7 @@ class DjVuImage { private function skipChunk( $file, $chunkLength ) { fseek( $file, $chunkLength, SEEK_CUR ); - if ( $chunkLength & 0x01 == 1 && !feof( $file ) ) { + if ( ( $chunkLength & 0x01 ) == 1 && !feof( $file ) ) { // padding byte fseek( $file, 1, SEEK_CUR ); }