// This seems ugly to wrap non-array's in an array just to unwrap again,
// especially when most of the time it is not an array
if ( !is_array( $tags[$tag] ) ) {
- $vals = array( $vals );
+ $vals = [ $vals ];
}
// _type is a special value to say what array type
case 'PhotometricInterpretation':
switch ( $val ) {
+ case 0:
+ case 1:
case 2:
+ case 3:
+ case 4:
+ case 5:
case 6:
+ case 8:
+ case 9:
+ case 10:
+ case 32803:
+ case 34892:
$val = $this->exifMsg( $tag, $val );
break;
default:
break;
case 'Flash':
- $flashDecode = array(
+ $flashDecode = [
'fired' => $val & bindec( '00000001' ),
'return' => ( $val & bindec( '00000110' ) ) >> 1,
'mode' => ( $val & bindec( '00011000' ) ) >> 3,
'function' => ( $val & bindec( '00100000' ) ) >> 5,
'redeye' => ( $val & bindec( '01000000' ) ) >> 6,
// 'reserved' => ($val & bindec( '10000000' )) >> 7,
- );
- $flashMsgs = array();
+ ];
+ $flashMsgs = [];
# We do not need to handle unknown values since all are used.
foreach ( $flashDecode as $subTag => $subValue ) {
# We do not need any message for zeroed values.
if ( $this->singleLang ) {
return Html::rawElement( 'span',
- array( 'lang' => $pLang ), $vals[$pLang] );
+ [ 'lang' => $pLang ], $vals[$pLang] );
}
}
}
$lang, false, $noHtml );
if ( $this->singleLang ) {
return Html::rawElement( 'span',
- array( 'lang' => $lang ), $item );
+ [ 'lang' => $lang ], $item );
}
}
if ( $defaultItem !== false ) {
* @return mixed A floating point number or whatever we were fed
*/
private function formatNum( $num, $round = false ) {
- $m = array();
+ $m = [];
if ( is_array( $num ) ) {
- $out = array();
+ $out = [];
foreach ( $num as $number ) {
$out[] = $this->formatNum( $number );
}
* @return mixed A floating point number or whatever we were fed
*/
private function formatFraction( $num ) {
- $m = array();
+ $m = [];
if ( preg_match( '/^(-?\d+)\/(\d+)$/', $num, $m ) ) {
$numerator = intval( $m[1] );
$denominator = intval( $m[2] );
. '</span>';
}
if ( isset( $vals['CiEmailWork'] ) ) {
- $emails = array();
+ $emails = [];
// Have to split multiple emails at commas/new lines.
$splitEmails = explode( "\n", $vals['CiEmailWork'] );
foreach ( $splitEmails as $e1 ) {
* @since 1.23
*/
public static function getVisibleFields() {
- $fields = array();
+ $fields = [];
$lines = explode( "\n", wfMessage( 'metadata-fields' )->inContentLanguage()->text() );
foreach ( $lines as $line ) {
- $matches = array();
+ $matches = [];
if ( preg_match( '/^\\*\s*(.*?)\s*$/', $line, $matches ) ) {
$fields[] = $matches[1];
}
* @since 1.23
*/
public function fetchExtendedMetadata( File $file ) {
- global $wgMemc;
+ $cache = ObjectCache::getMainWANInstance();
// If revision deleted, exit immediately
if ( $file->isDeleted( File::DELETED_FILE ) ) {
- return array();
+ return [];
}
$cacheKey = wfMemcKey(
$file->getSha1()
);
- $cachedValue = $wgMemc->get( $cacheKey );
+ $cachedValue = $cache->get( $cacheKey );
if (
$cachedValue
- && Hooks::run( 'ValidateExtendedMetadataCache', array( $cachedValue['timestamp'], $file ) )
+ && Hooks::run( 'ValidateExtendedMetadataCache', [ $cachedValue['timestamp'], $file ] )
) {
$extendedMetadata = $cachedValue['data'];
} else {
// outside fetchExtendedMetadata, but this way we don't need to redo the
// computation on a cache hit.
$this->sanitizeArrayForAPI( $extendedMetadata );
- $valueToCache = array( 'data' => $extendedMetadata, 'timestamp' => wfTimestampNow() );
- $wgMemc->set( $cacheKey, $valueToCache, $maxCacheTime );
+ $valueToCache = [ 'data' => $extendedMetadata, 'timestamp' => wfTimestampNow() ];
+ $cache->set( $cacheKey, $valueToCache, $maxCacheTime );
}
return $extendedMetadata;
if ( $file instanceof ForeignAPIFile ) {
// In case of error we pretend no metadata - this will get cached.
// Might or might not be a good idea.
- return $file->getExtendedMetadata() ?: array();
+ return $file->getExtendedMetadata() ?: [];
}
$uploadDate = wfTimestamp( TS_ISO_8601, $file->getTimestamp() );
- $fileMetadata = array(
+ $fileMetadata = [
// This is modification time, which is close to "upload" time.
- 'DateTime' => array(
+ 'DateTime' => [
'value' => $uploadDate,
'source' => 'mediawiki-metadata',
- ),
- );
+ ],
+ ];
$title = $file->getTitle();
if ( $title ) {
$name = $text;
}
- $fileMetadata['ObjectName'] = array(
+ $fileMetadata['ObjectName'] = [
'value' => $name,
'source' => 'mediawiki-metadata',
- );
+ ];
}
return $fileMetadata;
&$maxCacheTime
) {
- Hooks::run( 'GetExtendedMetadata', array(
+ Hooks::run( 'GetExtendedMetadata', [
&$extendedMetadata,
$file,
$this->getContext(),
$this->singleLang,
&$maxCacheTime
- ) );
+ ] );
$visible = array_flip( self::getVisibleFields() );
foreach ( $extendedMetadata as $key => $value ) {
return $value;
} elseif ( isset( $value['_type'] ) && $value['_type'] === 'lang' ) {
// if this is a multilang array, process fields separately
- $newValue = array();
+ $newValue = [];
foreach ( $value as $k => $v ) {
$newValue[$k] = $this->resolveMultivalueValue( $v );
}