jenkins-bot has submitted this change and it was merged.

Change subject: Replace extract() with explicit variable definitions in 
DjVuImage
......................................................................


Replace extract() with explicit variable definitions in DjVuImage

Bug: T28496
Change-Id: I09e012674e4d6c141912db6ef53dc51b2fcf0a66
---
M includes/media/DjVuImage.php
1 file changed, 20 insertions(+), 42 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/media/DjVuImage.php b/includes/media/DjVuImage.php
index 16740d8..ed361eb 100644
--- a/includes/media/DjVuImage.php
+++ b/includes/media/DjVuImage.php
@@ -84,11 +84,9 @@
        function dump() {
                $file = fopen( $this->mFilename, 'rb' );
                $header = fread( $file, 12 );
-               // @todo FIXME: Would be good to replace this extract() call 
with
-               // something that explicitly initializes local variables.
-               extract( unpack( 'a4magic/a4chunk/NchunkLength', $header ) );
-               /** @var string $chunk
-                * @var string $chunkLength */
+               $arr = unpack( 'a4magic/a4chunk/NchunkLength', $header );
+               $chunk = $arr['chunk'];
+               $chunkLength = $arr['chunkLength'];
                echo "$chunk $chunkLength\n";
                $this->dumpForm( $file, $chunkLength, 1 );
                fclose( $file );
@@ -103,11 +101,9 @@
                        if ( $chunkHeader == '' ) {
                                break;
                        }
-                       // @todo FIXME: Would be good to replace this extract() 
call with
-                       // something that explicitly initializes local 
variables.
-                       extract( unpack( 'a4chunk/NchunkLength', $chunkHeader ) 
);
-                       /** @var string $chunk
-                        * @var string $chunkLength */
+                       $arr = unpack( 'a4chunk/NchunkLength', $chunkHeader );
+                       $chunk = $arr['chunk'];
+                       $chunkLength = $arr['chunkLength'];
                        echo str_repeat( ' ', $indent * 4 ) . "$chunk 
$chunkLength\n";
 
                        if ( $chunk == 'FORM' ) {
@@ -138,24 +134,19 @@
                if ( strlen( $header ) < 16 ) {
                        wfDebug( __METHOD__ . ": too short file header\n" );
                } else {
-                       // @todo FIXME: Would be good to replace this extract() 
call with
-                       // something that explicitly initializes local 
variables.
-                       extract( unpack( 
'a4magic/a4form/NformLength/a4subtype', $header ) );
+                       $arr = unpack( 'a4magic/a4form/NformLength/a4subtype', 
$header );
 
-                       /** @var string $magic
-                        * @var string $subtype
-                        * @var string $formLength
-                        * @var string $formType */
-                       if ( $magic != 'AT&T' ) {
+                       $subtype = $arr['subtype'];
+                       if ( $arr['magic'] != 'AT&T' ) {
                                wfDebug( __METHOD__ . ": not a DjVu file\n" );
                        } elseif ( $subtype == 'DJVU' ) {
                                // Single-page document
                                $info = $this->getPageInfo( $file );
                        } elseif ( $subtype == 'DJVM' ) {
                                // Multi-page document
-                               $info = $this->getMultiPageInfo( $file, 
$formLength );
+                               $info = $this->getMultiPageInfo( $file, 
$arr['formLength'] );
                        } else {
-                               wfDebug( __METHOD__ . ": unrecognized DJVU file 
type '$formType'\n" );
+                               wfDebug( __METHOD__ . ": unrecognized DJVU file 
type '{$arr['subtype']}'\n" );
                        }
                }
                fclose( $file );
@@ -168,13 +159,9 @@
                if ( strlen( $header ) < 8 ) {
                        return [ false, 0 ];
                } else {
-                       // @todo FIXME: Would be good to replace this extract() 
call with
-                       // something that explicitly initializes local 
variables.
-                       extract( unpack( 'a4chunk/Nlength', $header ) );
+                       $arr = unpack( 'a4chunk/Nlength', $header );
 
-                       /** @var string $chunk
-                        * @var string $length */
-                       return [ $chunk, $length ];
+                       return [ $arr['chunk'], $arr['length'] ];
                }
        }
 
@@ -236,31 +223,22 @@
                        return false;
                }
 
-               // @todo FIXME: Would be good to replace this extract() call 
with
-               // something that explicitly initializes local variables.
-               extract( unpack(
+               $arr = unpack(
                        'nwidth/' .
                        'nheight/' .
                        'Cminor/' .
                        'Cmajor/' .
                        'vresolution/' .
-                       'Cgamma', $data ) );
+                       'Cgamma', $data );
 
                # Newer files have rotation info in byte 10, but we don't use 
it yet.
 
-               /** @var string $width
-                * @var string $height
-                * @var string $major
-                * @var string $minor
-                * @var string $resolution
-                * @var string $length
-                * @var string $gamma */
                return [
-                       'width' => $width,
-                       'height' => $height,
-                       'version' => "$major.$minor",
-                       'resolution' => $resolution,
-                       'gamma' => $gamma / 10.0 ];
+                       'width' => $arr['width'],
+                       'height' => $arr['height'],
+                       'version' => "{$arr['major']}.{$arr['minor']}",
+                       'resolution' => $arr['resolution'],
+                       'gamma' => $arr['gamma'] / 10.0 ];
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/271358
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I09e012674e4d6c141912db6ef53dc51b2fcf0a66
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisa...@openmailbox.org>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Tpt <thoma...@hotmail.fr>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to