X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FHooks.php;h=511781dbbd300c0107b712a39bb3cd41eb2f5fd3;hb=c3bdadc7a6d2634462a226e928af0df1d3034540;hp=cd38a7d45e909b8cac48f1d0020559b0e5988404;hpb=9ab6887c8c93014a17afd6ab81f6bac3bf5effd6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Hooks.php b/includes/Hooks.php index cd38a7d45e..511781dbbd 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -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 {