Merge "Improved readability of MediaWikiParserTest::suite code"
[lhc/web/wiklou.git] / includes / Hooks.php
index a29e5fe..16fee41 100644 (file)
@@ -45,7 +45,7 @@ class Hooks {
         *
         * @since 1.21
         *
-        * @param $name String: the name of the hook to clear.
+        * @param string $name the name of the hook to clear.
         *
         * @throws MWException if not in testing mode.
         */
@@ -57,17 +57,16 @@ class Hooks {
                unset( self::$handlers[$name] );
        }
 
-
        /**
         * Attach an event handler to a given hook
         *
         * @since 1.18
         *
-        * @param $name String: name of hook
+        * @param string $name name of hook
         * @param $callback Mixed: callback function to attach
         */
        public static function register( $name, $callback ) {
-               if( !isset( self::$handlers[$name] ) ) {
+               if ( !isset( self::$handlers[$name] ) ) {
                        self::$handlers[$name] = array();
                }
 
@@ -80,7 +79,7 @@ class Hooks {
         *
         * @since 1.18
         *
-        * @param $name String: name of hook
+        * @param string $name name of hook
         * @return Boolean: true if the hook has a function registered to it
         */
        public static function isRegistered( $name ) {
@@ -96,7 +95,7 @@ class Hooks {
         *
         * @throws MWException
         * @throws FatalError
-        * @param $name String: name of the hook
+        * @param string $name name of the hook
         *
         * @return array
         */
@@ -135,7 +134,7 @@ class Hooks {
        /**
         * Call hook functions defined in Hooks::register
         *
-        * @param $event String: event name
+        * @param string $event event name
         * @param $args  Array: parameters passed to hook functions
         *
         * @throws MWException
@@ -169,6 +168,7 @@ class Hooks {
                         */
                        if ( is_array( $hook ) ) {
                                if ( count( $hook ) < 1 ) {
+                                       wfProfileOut( 'hook: ' . $event );
                                        throw new MWException( 'Empty array in hooks for ' . $event . "\n" );
                                } elseif ( is_object( $hook[0] ) ) {
                                        $object = $hook[0];
@@ -191,11 +191,12 @@ class Hooks {
                                        }
                                } elseif ( is_string( $hook[0] ) ) {
                                        $func = $hook[0];
-                                       if ( count( $hook ) > 1) {
+                                       if ( count( $hook ) > 1 ) {
                                                $data = $hook[1];
                                                $have_data = true;
                                        }
                                } else {
+                                       wfProfileOut( 'hook: ' . $event );
                                        throw new MWException( 'Unknown datatype in hooks for ' . $event . "\n" );
                                }
                        } elseif ( is_string( $hook ) ) { # functions look like strings, too
@@ -208,6 +209,7 @@ class Hooks {
                                        $method = "on" . $event;
                                }
                        } else {
+                               wfProfileOut( 'hook: ' . $event );
                                throw new MWException( 'Unknown datatype in hooks for ' . $event . "\n" );
                        }
 
@@ -263,11 +265,11 @@ class Hooks {
                        /* String return is an error; false return means stop processing. */
                        if ( is_string( $retval ) ) {
                                throw new FatalError( $retval );
-                       } elseif( $retval === null ) {
+                       } elseif ( $retval === null ) {
                                if ( $closure ) {
                                        $prettyFunc = "$event closure";
-                               } elseif( is_array( $callback ) ) {
-                                       if( is_object( $callback[0] ) ) {
+                               } elseif ( is_array( $callback ) ) {
+                                       if ( is_object( $callback[0] ) ) {
                                                $prettyClass = get_class( $callback[0] );
                                        } else {
                                                $prettyClass = strval( $callback[0] );
@@ -277,11 +279,13 @@ class Hooks {
                                        $prettyFunc = strval( $callback );
                                }
                                if ( $badhookmsg ) {
+                                       wfProfileOut( 'hook: ' . $event );
                                        throw new MWException(
                                                'Detected bug in an extension! ' .
                                                "Hook $prettyFunc has invalid call signature; " . $badhookmsg
                                        );
                                } else {
+                                       wfProfileOut( 'hook: ' . $event );
                                        throw new MWException(
                                                'Detected bug in an extension! ' .
                                                "Hook $prettyFunc failed to return a value; " .
@@ -303,8 +307,8 @@ class Hooks {
         *
         * @since 1.18
         *
-        * @param $errno int Unused
-        * @param $errstr String: error message
+        * @param int $errno Unused
+        * @param string $errstr error message
         * @throws MWHookException
         * @return Boolean: false
         */