/** @var array */
private $mInfo = [];
- protected $repoClass = 'ForeignApiRepo';
+ protected $repoClass = ForeignApiRepo::class;
/**
* @param Title|string|bool $title
}
/**
- * @param array $metadata
- * @return array
+ * @param mixed $metadata
+ * @return mixed
*/
public static function parseMetadata( $metadata ) {
if ( !is_array( $metadata ) ) {
/**
* @param int $audience
- * @param User $user
+ * @param User|null $user
* @return null|string
*/
public function getDescription( $audience = self::FOR_PUBLIC, User $user = null ) {
*/
function getMimeType() {
if ( !isset( $this->mInfo['mime'] ) ) {
- $magic = MimeMagic::singleton();
+ $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
$this->mInfo['mime'] = $magic->guessTypesForExtension( $this->getExtension() );
}
if ( isset( $this->mInfo['mediatype'] ) ) {
return $this->mInfo['mediatype'];
}
- $magic = MimeMagic::singleton();
+ $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
return $magic->getMediaType( null, $this->getMimeType() );
}
}
/**
- * @return array
+ * @return string[]
*/
function getThumbnails() {
$dir = $this->getThumbPath( $this->getName() );
$iter = $this->repo->getBackend()->getFileList( [ 'dir' => $dir ] );
$files = [];
- foreach ( $iter as $file ) {
- $files[] = $file;
+ if ( $iter ) {
+ foreach ( $iter as $file ) {
+ $files[] = $file;
+ }
}
return $files;