Merge "Don't fallback from uk to ru"
[lhc/web/wiklou.git] / includes / Hooks.php
index cd38a7d..511781d 100644 (file)
@@ -36,7 +36,7 @@ class Hooks {
         * Array of events mapped to an array of callbacks to be run
         * when that event is triggered.
         */
-       protected static $handlers = array();
+       protected static $handlers = [];
 
        /**
         * Attach an event handler to a given hook.
@@ -48,7 +48,7 @@ class Hooks {
         */
        public static function register( $name, $callback ) {
                if ( !isset( self::$handlers[$name] ) ) {
-                       self::$handlers[$name] = array();
+                       self::$handlers[$name] = [];
                }
 
                self::$handlers[$name][] = $callback;
@@ -64,7 +64,7 @@ class Hooks {
         * @throws MWException If not in testing mode.
         */
        public static function clear( $name ) {
-               if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
+               if ( !defined( 'MW_PHPUNIT_TEST' ) && !defined( 'MW_PARSER_TEST' ) ) {
                        throw new MWException( 'Cannot reset hooks in operation.' );
                }
 
@@ -98,7 +98,7 @@ class Hooks {
                global $wgHooks;
 
                if ( !self::isRegistered( $name ) ) {
-                       return array();
+                       return [];
                } elseif ( !isset( self::$handlers[$name] ) ) {
                        return $wgHooks[$name];
                } elseif ( !isset( $wgHooks[$name] ) ) {
@@ -128,11 +128,11 @@ class Hooks {
         *   processing to continue. Not returning a value (or explicitly
         *   returning null) is equivalent to returning true.
         */
-       public static function run( $event, array $args = array(), $deprecatedVersion = null ) {
+       public static function run( $event, array $args = [], $deprecatedVersion = null ) {
                foreach ( self::getHandlers( $event ) as $hook ) {
                        // Turn non-array values into an array. (Can't use casting because of objects.)
                        if ( !is_array( $hook ) ) {
-                               $hook = array( $hook );
+                               $hook = [ $hook ];
                        }
 
                        if ( !array_filter( $hook ) ) {
@@ -163,7 +163,7 @@ class Hooks {
                                }
 
                                $func = get_class( $object ) . '::' . $method;
-                               $callback = array( $object, $method );
+                               $callback = [ $object, $method ];
                        } elseif ( is_string( $hook[0] ) ) {
                                $func = $callback = array_shift( $hook );
                        } else {