protected $repoClass = 'FileRepo';
/** @var array Cache of tmp filepaths pointing to generated bucket thumbnails, keyed by width */
- protected $tmpBucketedThumbCache = array();
+ protected $tmpBucketedThumbCache = [];
/**
* Call this constructor from child classes.
}
function __get( $name ) {
- $function = array( $this, 'get' . ucfirst( $name ) );
+ $function = [ $this, 'get' . ucfirst( $name ) ];
if ( !is_callable( $function ) ) {
return null;
} else {
*/
static function normalizeExtension( $extension ) {
$lower = strtolower( $extension );
- $squish = array(
+ $squish = [
'htm' => 'html',
'jpeg' => 'jpg',
'mpeg' => 'mpg',
'tiff' => 'tif',
- 'ogv' => 'ogg' );
+ 'ogv' => 'ogg' ];
if ( isset( $squish[$lower] ) ) {
return $squish[$lower];
} elseif ( preg_match( '/^[0-9a-z]+$/', $lower ) ) {
if ( strpos( $mime, '/' ) !== false ) {
return explode( '/', $mime, 2 );
} else {
- return array( $mime, 'unknown' );
+ return [ $mime, 'unknown' ];
}
}
if ( $handler ) {
return $handler->getAvailableLanguages( $this );
} else {
- return array();
+ return [];
}
}
if ( $this->repo ) {
$script = $this->repo->getThumbScriptUrl();
if ( $script ) {
- $this->transformScript = wfAppendQuery( $script, array( 'f' => $this->getName() ) );
+ $this->transformScript = wfAppendQuery( $script, [ 'f' => $this->getName() ] );
}
}
}
*
* @return string
*/
- function getUnscaledThumb( $handlerParams = array() ) {
+ function getUnscaledThumb( $handlerParams = [] ) {
$hp =& $handlerParams;
$page = isset( $hp['page'] ) ? $hp['page'] : false;
$width = $this->getWidth( $page );
* @return string
*/
public function createThumb( $width, $height = -1 ) {
- $params = array( 'width' => $width );
+ $params = [ 'width' => $width ];
if ( $height != -1 ) {
$params['height'] = $height;
}
$stats->timing( 'media.thumbnail.generate.store', 1000 * $statTiming );
// Give extensions a chance to do something with this thumbnail...
- Hooks::run( 'FileTransformed', array( $this, $thumb, $tmpThumbPath, $thumbPath ) );
+ Hooks::run( 'FileTransformed', [ $this, $thumb, $tmpThumbPath, $thumbPath ] );
}
return $thumb;
$tmpPath = $this->tmpBucketedThumbCache[$bucket];
if ( file_exists( $tmpPath ) ) {
- return array(
+ return [
'path' => $tmpPath,
'width' => $bucket,
'height' => $bucketHeight
- );
+ ];
}
}
$fsFile = $this->repo->getLocalReference( $bucketPath );
if ( $fsFile ) {
- return array(
+ return [
'path' => $fsFile->getPath(),
'width' => $bucket,
'height' => $bucketHeight
- );
+ ];
}
}
}
if ( $this->getSize() >= 1e7 ) { // 10MB
$that = $this;
$work = new PoolCounterWorkViaCallback( 'GetLocalFileCopy', sha1( $this->getName() ),
- array(
+ [
'doWork' => function () use ( $that ) {
return $that->getLocalRefPath();
}
- )
+ ]
);
$srcPath = $work->execute();
} else {
}
// Original file
- return array(
+ return [
'path' => $srcPath,
'width' => $this->getWidth(),
'height' => $this->getHeight()
- );
+ ];
}
/**
* @return string
*/
protected function getBucketThumbName( $bucket ) {
- return $this->thumbName( array( 'physicalWidth' => $bucket ) );
+ return $this->thumbName( [ 'physicalWidth' => $bucket ] );
}
/**
$assetsPath = "$wgResourceBasePath/resources/assets/file-type-icons/";
$assetsDirectory = "$IP/resources/assets/file-type-icons/";
- $try = array( 'fileicon-' . $this->getExtension() . '.png', 'fileicon.png' );
+ $try = [ 'fileicon-' . $this->getExtension() . '.png', 'fileicon.png' ];
foreach ( $try as $icon ) {
if ( file_exists( $assetsDirectory . $icon ) ) { // always FS
- $params = array( 'width' => 120, 'height' => 120 );
+ $params = [ 'width' => 120, 'height' => 120 ];
return new ThumbnailImage( $this, $assetsPath . $icon, false, $params );
}
* @return array
*/
function getThumbnails() {
- return array();
+ return [];
}
/**
* @param array $options Options, which include:
* 'forThumbRefresh' : The purging is only to refresh thumbnails
*/
- function purgeCache( $options = array() ) {
+ function purgeCache( $options = [] ) {
}
/**
* @return File[]
*/
function getHistory( $limit = null, $start = null, $end = null, $inc = true ) {
- return array();
+ return [];
}
/**
* STUB
* Overridden by LocalFile
*/
- function publish( $srcPath, $flags = 0, array $options = array() ) {
+ function publish( $srcPath, $flags = 0, array $options = [] ) {
$this->readOnlyError();
}
* STUB
* Overridden by LocalFile
*/
- function restore( $versions = array(), $unsuppress = false ) {
+ function restore( $versions = [], $unsuppress = false ) {
$this->readOnlyError();
}
wfDebug( "miss\n" );
}
wfDebug( "Fetching shared description from $renderUrl\n" );
- $res = Http::get( $renderUrl, array(), __METHOD__ );
+ $res = Http::get( $renderUrl, [], __METHOD__ );
if ( $res && $key ) {
$cache->set( $key, $res, $this->repo->descriptionCacheExpiry );
}
if ( $handler ) {
return $handler->getStreamHeaders( $this->getMetadata() );
} else {
- return array();
+ return [];
}
}