aboutsummaryrefslogtreecommitdiffstats
path: root/includes/media/WebPHandler.php
diff options
context:
space:
mode:
authorDerk-Jan Hartman <hartman.wiki@gmail.com>2023-03-08 21:44:20 +0100
committerTheDJ <hartman.wiki@gmail.com>2023-03-09 11:07:32 +0000
commit9556256bda4b5d3c0311477d80006d09e2de6890 (patch)
tree4e868d905b2b64b58a234b223e8c7ec5a9489405 /includes/media/WebPHandler.php
parentf139afe1cf2ffe1bcbab35eab594fc904590b20b (diff)
downloadmediawikicore-9556256bda4b5d3c0311477d80006d09e2de6890.tar.gz
mediawikicore-9556256bda4b5d3c0311477d80006d09e2de6890.zip
media: code style improvements
- Avoid unnecesary else branching - Static vs non-static fixes - string, int and float casting instead of strval, intval, floatval (faster and more readable) - Strict comparisons (but not for all '' and 0 as might have implicit falsey behavior) - Few spelling mistakes - Remove TimestampException handling, caught by parent function Change-Id: I08725c8e391965529a2766dfaf5d8f6cf8a86db8
Diffstat (limited to 'includes/media/WebPHandler.php')
-rw-r--r--includes/media/WebPHandler.php12
1 files changed, 6 insertions, 6 deletions
diff --git a/includes/media/WebPHandler.php b/includes/media/WebPHandler.php
index 3806960b1e84..a33e740607d8 100644
--- a/includes/media/WebPHandler.php
+++ b/includes/media/WebPHandler.php
@@ -105,7 +105,7 @@ class WebPHandler extends BitmapHandler {
return false;
}
- if ( $info['fourCC'] != 'WEBP' ) {
+ if ( $info['fourCC'] !== 'WEBP' ) {
wfDebugLog( 'WebP', __METHOD__ . ': FourCC was not WEBP: ' .
bin2hex( $info['fourCC'] ) );
return false;
@@ -168,7 +168,7 @@ class WebPHandler extends BitmapHandler {
// Bytes 8-10 are the frame tag
// Bytes 11-13 are 0x9D 0x01 0x2A called the sync code
$syncCode = substr( $header, 11, 3 );
- if ( $syncCode != "\x9D\x01\x2A" ) {
+ if ( $syncCode !== "\x9D\x01\x2A" ) {
wfDebugLog( 'WebP', __METHOD__ . ': Invalid sync code: ' .
bin2hex( $syncCode ) );
return [];
@@ -192,7 +192,7 @@ class WebPHandler extends BitmapHandler {
// Bytes 0-3 are 'VP8L'
// Bytes 4-7 are chunk stream size
// Byte 8 is 0x2F called the signature
- if ( $header[8] != "\x2F" ) {
+ if ( $header[8] !== "\x2F" ) {
wfDebugLog( 'WebP', __METHOD__ . ': Invalid signature: ' .
bin2hex( $header[8] ) );
return [];
@@ -225,8 +225,8 @@ class WebPHandler extends BitmapHandler {
return [
'compression' => 'unknown',
- 'animated' => ( $flags[1] & self::VP8X_ANIM ) == self::VP8X_ANIM,
- 'transparency' => ( $flags[1] & self::VP8X_ALPHA ) == self::VP8X_ALPHA,
+ 'animated' => ( $flags[1] & self::VP8X_ANIM ) === self::VP8X_ANIM,
+ 'transparency' => ( $flags[1] & self::VP8X_ALPHA ) === self::VP8X_ALPHA,
'width' => ( $width[1] & 0xFFFFFF ) + 1,
'height' => ( $height[1] & 0xFFFFFF ) + 1
];
@@ -245,7 +245,7 @@ class WebPHandler extends BitmapHandler {
* @return bool False if we are unable to render this image
*/
public function canRender( $file ) {
- if ( self::isAnimatedImage( $file ) ) {
+ if ( $this->isAnimatedImage( $file ) ) {
return false;
}
return true;