application/vnd.oasis.opendocument.text-master otm
application/vnd.oasis.opendocument.text-template ott
application/vnd.oasis.opendocument.text-web oth
-application/x-javascript js
+application/javascript js
application/x-shockwave-flash swf
audio/midi mid midi kar
audio/mpeg mpga mpa mp2 mp3
application/vnd.oasis.opendocument.text-template [OFFICE]
application/vnd.oasis.opendocument.text-master [OFFICE]
application/vnd.oasis.opendocument.text-web [OFFICE]
-text/javascript application/x-javascript [EXECUTABLE]
+application/javascript text/javascript application/x-javascript [EXECUTABLE]
application/x-shockwave-flash [MULTIMEDIA]
audio/midi [AUDIO]
audio/x-aiff [AUDIO]
global $IP;
# Allow media handling extensions adding MIME-types and MIME-info
- Hooks::run( 'MimeMagicInit', array( $this ) );
+ Hooks::run( 'MimeMagicInit', [ $this ] );
$types = MM_WELL_KNOWN_MIME_TYPES;
$types .= "\n" . $this->mExtraTypes;
- $types = str_replace( array( "\r\n", "\n\r", "\n\n", "\r\r", "\r" ), "\n", $types );
+ $types = str_replace( [ "\r\n", "\n\r", "\n\n", "\r\r", "\r" ], "\n", $types );
$types = str_replace( "\t", " ", $types );
- $this->mMimeToExt = array();
- $this->mExtToMime = array();
+ $this->mMimeToExt = [];
+ $this->mExtToMime = [];
$lines = explode( "\n", $types );
foreach ( $lines as $s ) {
$info .= "\n" . $this->mExtraInfo;
- $info = str_replace( array( "\r\n", "\n\r", "\n\n", "\r\r", "\r" ), "\n", $info );
+ $info = str_replace( [ "\r\n", "\n\r", "\n\n", "\r\r", "\r" ], "\n", $info );
$info = str_replace( "\t", " ", $info );
- $this->mMimeTypeAliases = array();
- $this->mMediaTypes = array();
+ $this->mMimeTypeAliases = [];
+ $this->mMediaTypes = [];
$lines = explode( "\n", $info );
foreach ( $lines as $s ) {
# print "processing MIME INFO line $s<br>";
- $match = array();
+ $match = [];
if ( preg_match( '!\[\s*(\w+)\s*\]!', $s, $match ) ) {
$s = preg_replace( '!\[\s*(\w+)\s*\]!', '', $s );
$mtype = trim( strtoupper( $match[1] ) );
$m = explode( ' ', $s );
if ( !isset( $this->mMediaTypes[$mtype] ) ) {
- $this->mMediaTypes[$mtype] = array();
+ $this->mMediaTypes[$mtype] = [];
}
foreach ( $m as $mime ) {
*/
public function isPHPImageType( $mime ) {
// As defined by imagegetsize and image_type_to_mime
- static $types = array(
+ static $types = [
'image/gif', 'image/jpeg', 'image/png',
'image/x-bmp', 'image/xbm', 'image/tiff',
'image/jp2', 'image/jpeg2000', 'image/iff',
'image/vnd.wap.wbmp', 'image/vnd.xiff',
'image/x-photoshop',
'application/x-shockwave-flash',
- );
+ ];
return in_array( $mime, $types );
}
* @return bool
*/
function isRecognizableExtension( $extension ) {
- static $types = array(
+ static $types = [
// Types recognized by getimagesize()
'gif', 'jpeg', 'jpg', 'png', 'swf', 'psd',
'bmp', 'tiff', 'tif', 'jpc', 'jp2',
// XML formats we sure hope we recognize reliably
'svg',
- );
+ ];
return in_array( strtolower( $extension ), $types );
}
}
# Media handling extensions can improve the MIME detected
- Hooks::run( 'MimeMagicImproveFromExtension', array( $this, $ext, &$mime ) );
+ Hooks::run( 'MimeMagicImproveFromExtension', [ $this, $ext, &$mime ] );
if ( isset( $this->mMimeTypeAliases[$mime] ) ) {
$mime = $this->mMimeTypeAliases[$mime];
throw new MWException(
"Seeking $tailLength bytes from EOF failed in " . __METHOD__ );
}
- $tail = fread( $f, $tailLength );
+ $tail = $tailLength ? fread( $f, $tailLength ) : '';
fclose( $f );
wfDebug( __METHOD__ . ": analyzing head and tail of $file for magic numbers.\n" );
// Hardcode a few magic number checks...
- $headers = array(
+ $headers = [
// Multimedia...
'MThd' => 'audio/midi',
'OggS' => 'application/ogg',
'MZ' => 'application/octet-stream', // DOS/Windows executable
"\xca\xfe\xba\xbe" => 'application/octet-stream', // Mach-O binary
"\x7fELF" => 'application/octet-stream', // ELF binary
- );
+ ];
foreach ( $headers as $magic => $candidate ) {
if ( strncmp( $head, $magic, strlen( $magic ) ) == 0 ) {
if ( $script_type ) {
if ( $script_type !== "UTF-8" && $script_type !== "ASCII" ) {
// Quick and dirty fold down to ASCII!
- $pack = array( 'UTF-16BE' => 'n*', 'UTF-16LE' => 'v*' );
+ $pack = [ 'UTF-16BE' => 'n*', 'UTF-16LE' => 'v*' ];
$chars = unpack( $pack[$script_type], substr( $head, 2 ) );
$head = '';
foreach ( $chars as $codepoint ) {
}
}
- $match = array();
+ $match = [];
if ( preg_match( '%/?([^\s]+/)(\w+)%', $head, $match ) ) {
$mime = "application/x-{$match[2]}";
# Some strings by reference for performance - assuming well-behaved hooks
Hooks::run(
'MimeMagicGuessFromContent',
- array( $this, &$head, &$tail, $file, &$mime )
+ [ $this, &$head, &$tail, $file, &$mime ]
);
return $mime;
}
$mime = 'application/zip';
- $opendocTypes = array(
+ $opendocTypes = [
'chart-template',
'chart',
'formula-template',
'text-template',
'text-master',
'text-web',
- 'text' );
+ 'text' ];
// http://lists.oasis-open.org/archives/office/200505/msg00006.html
$types = '(?:' . implode( '|', $opendocTypes ) . ')';
$extMime = $this->mMimeTypeAliases[$extMime];
}
- $m = array( $extMime );
+ $m = [ $extMime ];
}
foreach ( $m as $mime ) {