From e77937bbac44cf179800d4e6abc5fc391b1a9735 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Fri, 5 Apr 2019 23:40:01 -0700 Subject: [PATCH] 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 --- .phan/config.php | 2 -- includes/media/DjVuImage.php | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) 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 ); } -- 2.20.1