Add phan configuration

This required updating ThumbnailImage constructors to the new call
signature.

Change-Id: Ia04d4dd523e1778992dcd5f45e9d3126649369c1
This commit is contained in:
Kunal Mehta 2018-02-24 14:24:04 -08:00
parent b89ddbca99
commit 0a049abdcd
5 changed files with 30 additions and 4 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@
/node_modules/
/vendor/
/composer.lock
tests/phan/issues

View file

@ -3,7 +3,8 @@
"jakub-onderka/php-parallel-lint": "0.9.2",
"jakub-onderka/php-console-highlighter": "0.3.2",
"mediawiki/mediawiki-codesniffer": "16.0.0",
"mediawiki/minus-x": "0.3.1"
"mediawiki/minus-x": "0.3.1",
"mediawiki/mediawiki-phan-config": "0.1.0"
},
"scripts": {
"fix": [

View file

@ -159,7 +159,11 @@ class PdfHandler extends ImageHandler {
}
if ( $flags & self::TRANSFORM_LATER ) {
return new ThumbnailImage( $image, $dstUrl, $width, $height, false, $page );
return new ThumbnailImage( $image, $dstUrl, false, [
'width' => $width,
'height' => $height,
'page' => $page,
] );
}
if ( !wfMkdirParents( dirname( $dstPath ), null, __METHOD__ ) ) {
@ -223,7 +227,11 @@ class PdfHandler extends ImageHandler {
wfHostname(), $retval, trim( $err ), $cmd ) );
return new MediaTransformError( 'thumbnail_error', $width, $height, $err );
} else {
return new ThumbnailImage( $image, $dstUrl, $width, $height, $dstPath, $page );
return new ThumbnailImage( $image, $dstUrl, $dstPath, [
'width' => $width,
'height' => $height,
'page' => $page,
] );
}
}
@ -231,6 +239,7 @@ class PdfHandler extends ImageHandler {
* @param File $image
* @param string $path
* @return PdfImage
* @suppress PhanUndeclaredProperty
*/
function getPdfImage( $image, $path ) {
if ( !$image ) {
@ -246,7 +255,8 @@ class PdfHandler extends ImageHandler {
/**
* @param File $image
* @return bool
* @return bool|array
* @suppress PhanUndeclaredProperty
*/
function getMetaArray( $image ) {
if ( isset( $image->pdfMetaArray ) ) {
@ -264,6 +274,9 @@ class PdfHandler extends ImageHandler {
'PdfHandler-unserialize-metadata',
$image->getName(),
[
/**
* @suppress PhanUndeclaredProperty
*/
'doWork' => function () use ( $image, $metadata ) {
wfSuppressWarnings();
$image->pdfMetaArray = unserialize( $metadata );

View file

@ -30,6 +30,11 @@ use UtfNormal\Validator;
class PdfImage {
/**
* @var string
*/
private $mFilename;
/**
* @param string $filename
*/

6
tests/phan/config.php Normal file
View file

@ -0,0 +1,6 @@
<?php
$cfg = require __DIR__ . '/../../vendor/mediawiki/mediawiki-phan-config/src/config.php';
$cfg['suppress_issue_types'][] = 'PhanDeprecatedFunction';
return $cfg;