Fixed and suppressed some thumb.php IDEA errors
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 26 Aug 2015 19:19:50 +0000 (12:19 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Mon, 31 Aug 2015 17:55:37 +0000 (10:55 -0700)
Change-Id: If5ec6fd1d6d272633296b74d2d8e146feb924229

thumb.php

index 25bca87..2cfe6b1 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -190,6 +190,7 @@ function wfStreamThumb( array $params ) {
                                if ( $targetFile->exists() ) {
                                        $newThumbName = $targetFile->thumbName( $params );
                                        if ( $isOld ) {
+                                               /** @var array $bits */
                                                $newThumbUrl = $targetFile->getArchiveThumbUrl(
                                                        $bits[0] . '!' . $targetFile->getName(), $newThumbName );
                                        } else {
@@ -325,7 +326,7 @@ function wfStreamThumb( array $params ) {
 
        list( $thumb, $errorMsg ) = wfGenerateThumbnail( $img, $params, $thumbName, $thumbPath );
 
-       /** @var MediaTransformOutput|bool $thumb */
+       /** @var MediaTransformOutput|MediaTransformError|bool $thumb */
 
        // Check for thumbnail generation errors...
        $msg = wfMessage( 'thumbnail_error' );
@@ -412,7 +413,7 @@ function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath
                                'fallback' => function () {
                                        return wfMessage( 'generic-pool-error' )->parse();
                                },
-                               'error' => function ( $status ) {
+                               'error' => function ( Status $status ) {
                                        return $status->getHTML();
                                }
                        )
@@ -427,6 +428,7 @@ function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath
                // Tried to select a page on a non-paged file?
        }
 
+       /** @noinspection PhpUnusedLocalVariableInspection */
        $done = true; // no PHP fatal occured
 
        if ( !$thumb || $thumb->isError() ) {
@@ -497,7 +499,7 @@ function wfExtractThumbRequestInfo( $thumbRel ) {
  */
 function wfExtractThumbParams( $file, $params ) {
        if ( !isset( $params['thumbName'] ) ) {
-               throw new MWException( "No thumbnail name passed to wfExtractThumbParams" );
+               throw new InvalidArgumentException( "No thumbnail name passed to wfExtractThumbParams" );
        }
 
        $thumbname = $params['thumbName'];
@@ -536,7 +538,7 @@ function wfExtractThumbParams( $file, $params ) {
 
        // As a last ditch fallback, use the traditional common parameters
        if ( preg_match( '!^(page(\d*)-)*(\d*)px-[^/]*$!', $thumbname, $matches ) ) {
-               list( /* all */, $pagefull, $pagenum, $size ) = $matches;
+               list( /* all */, /* pagefull */, $pagenum, $size ) = $matches;
                $params['width'] = $size;
                if ( $pagenum ) {
                        $params['page'] = $pagenum;
@@ -551,7 +553,7 @@ function wfExtractThumbParams( $file, $params ) {
  * Output a thumbnail generation error message
  *
  * @param int $status
- * @param string $msg Plain text (will be html escaped)
+ * @param string $msgText Plain text (will be html escaped)
  * @return void
  */
 function wfThumbErrorText( $status, $msgText ) {