Merge "resourceloader: Add tests to verify empty string works"
[lhc/web/wiklou.git] / includes / parser / DateFormatter.php
index edb9ff1..40da368 100644 (file)
@@ -108,13 +108,13 @@ class DateFormatter {
                $this->rules[self::ALL][self::DM] = self::DM;
                $this->rules[self::NONE][self::ISO2] = self::ISO1;
 
-               $this->preferences = array(
+               $this->preferences = [
                        'default' => self::NONE,
                        'dmy' => self::DMY,
                        'mdy' => self::MDY,
                        'ymd' => self::YMD,
                        'ISO 8601' => self::ISO1,
-               );
+               ];
        }
 
        /**
@@ -151,7 +151,7 @@ class DateFormatter {
         *
         * @return string
         */
-       public function reformat( $preference, $text, $options = array( 'linked' ) ) {
+       public function reformat( $preference, $text, $options = [ 'linked' ] ) {
                $linked = in_array( 'linked', $options );
                $match_whole = in_array( 'match-whole', $options );
 
@@ -179,7 +179,7 @@ class DateFormatter {
 
                        // Horrible hack
                        if ( !$linked ) {
-                               $regex = str_replace( array( '\[\[', '\]\]' ), '', $regex );
+                               $regex = str_replace( [ '\[\[', '\]\]' ], '', $regex );
                        }
 
                        if ( $match_whole ) {
@@ -191,7 +191,7 @@ class DateFormatter {
 
                        // Another horrible hack
                        $this->mLinked = $linked;
-                       $text = preg_replace_callback( $regex, array( &$this, 'replace' ), $text );
+                       $text = preg_replace_callback( $regex, [ &$this, 'replace' ], $text );
                        unset( $this->mLinked );
                }
                return $text;
@@ -208,7 +208,7 @@ class DateFormatter {
                        $linked = $this->mLinked;
                }
 
-               $bits = array();
+               $bits = [];
                $key = $this->keys[$this->mSource];
                $keyLength = strlen( $key );
                for ( $p = 0; $p < $keyLength; $p++ ) {
@@ -232,7 +232,7 @@ class DateFormatter {
                        // strip piped links
                        $format = preg_replace( '/\[\[[^|]+\|([^\]]+)\]\]/', '$1', $format );
                        // strip remaining links
-                       $format = str_replace( array( '[[', ']]' ), '', $format );
+                       $format = str_replace( [ '[[', ']]' ], '', $format );
                }
 
                # Construct new date
@@ -304,7 +304,7 @@ class DateFormatter {
                        $text = $matches[0];
                }
 
-               $isoBits = array();
+               $isoBits = [];
                if ( isset( $bits['y'] ) ) {
                        $isoBits[] = $bits['y'];
                }
@@ -314,7 +314,7 @@ class DateFormatter {
 
                // Output is not strictly HTML (it's wikitext), but <span> is whitelisted.
                $text = Html::rawElement( 'span',
-                                       array( 'class' => 'mw-formatted-date', 'title' => $isoDate ), $text );
+                                       [ 'class' => 'mw-formatted-date', 'title' => $isoDate ], $text );
 
                return $text;
        }
@@ -324,7 +324,7 @@ class DateFormatter {
         * @return string regex to find the months with
         */
        public function getMonthRegex() {
-               $names = array();
+               $names = [];
                for ( $i = 1; $i <= 12; $i++ ) {
                        $names[] = $this->lang->getMonthName( $i );
                        $names[] = $this->lang->getMonthAbbreviation( $i );