*
* @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.
*/
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();
}
*
* @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 ) {
*
* @throws MWException
* @throws FatalError
- * @param $name String: name of the hook
+ * @param string $name name of the hook
*
* @return array
*/
/**
* 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
*/
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];
}
} 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
$method = "on" . $event;
}
} else {
+ wfProfileOut( 'hook: ' . $event );
throw new MWException( 'Unknown datatype in hooks for ' . $event . "\n" );
}
/* 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] );
$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; " .
*
* @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
*/