* 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.
*/
public static function register( $name, $callback ) {
if ( !isset( self::$handlers[$name] ) ) {
- self::$handlers[$name] = array();
+ self::$handlers[$name] = [];
}
self::$handlers[$name][] = $callback;
global $wgHooks;
if ( !self::isRegistered( $name ) ) {
- return array();
+ return [];
} elseif ( !isset( self::$handlers[$name] ) ) {
return $wgHooks[$name];
} elseif ( !isset( $wgHooks[$name] ) ) {
* 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 ) ) {
}
$func = get_class( $object ) . '::' . $method;
- $callback = array( $object, $method );
+ $callback = [ $object, $method ];
} elseif ( is_string( $hook[0] ) ) {
$func = $callback = array_shift( $hook );
} else {