diff options
-rw-r--r-- | docs/hooks.txt | 17 | ||||
-rw-r--r-- | docs/magicword.txt | 6 |
2 files changed, 10 insertions, 13 deletions
diff --git a/docs/hooks.txt b/docs/hooks.txt index 50e5495e1423..cd1609d76868 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -74,10 +74,10 @@ Using a hook-running strategy, we can avoid having all this option-specific stuff in our mainline code. Using hooks, the function becomes: function showAnArticle( $article ) { - if ( Hooks::run( 'ArticleShow', [ &$article ] ) ) { + if ( Hooks::run( 'ArticleShow', [ $article ] ) ) { # code to actually show the article goes here - Hooks::run( 'ArticleShowComplete', [ &$article ] ); + Hooks::run( 'ArticleShowComplete', [ $article ] ); } } @@ -91,15 +91,15 @@ title-reversing if-blocks spread all over the codebase in showAnArticle, deleteAnArticle, exportArticle, etc., we can concentrate it all in an extension file: - function onArticleShow( &$article ) { + function onArticleShow( $article ) { # ... } - function onArticleDelete( &$article ) { + function onArticleDelete( $article ) { # ... } - function onArticleExport( &$article ) { + function onArticleExport( $article ) { # ... } @@ -217,12 +217,9 @@ related to a particular event, like so: function protect() { global $wgUser; - // Avoid PHP 7.1 warning from passing $this by reference - $article = $this; - - if ( Hooks::run( 'ArticleProtect', [ &$article, &$wgUser ] ) ) { + if ( Hooks::run( 'ArticleProtect', [ $this, $wgUser ] ) ) { # protect the article - Hooks::run( 'ArticleProtectComplete', [ &$article, &$wgUser ] ); + Hooks::run( 'ArticleProtectComplete', [ $this, $wgUser ] ); } } } diff --git a/docs/magicword.txt b/docs/magicword.txt index d24dd9bcc1a3..43eed3fa7e04 100644 --- a/docs/magicword.txt +++ b/docs/magicword.txt @@ -49,7 +49,7 @@ function wfAddCustomMagicWordID( &$magicWords ) { return true; } -function wfGetCustomMagicWordValue( $parser, &$variableCache, &$magicWordId, &$ret ){ +function wfGetCustomMagicWordValue( $parser, &$variableCache, $magicWordId, &$ret ){ if( $magicWordId == 'mag_custom' ){ $ret = $variableCache['mag_custom'] = "Custom value"; } @@ -77,12 +77,12 @@ $magicWords['es'] = [ $wgExtensionMessagesFiles['ExtensionNameMagic'] = __DIR__ . '/ExtensionName.i18n.magic.php'; $wgHooks['ParserFirstCallInit'][] = 'wfRegisterCustomMagicWord'; -function wfRegisterCustomMagicWord( &$parser ){ +function wfRegisterCustomMagicWord( $parser ){ $parser->setFunctionHook( 'mag_custom', 'wfGetCustomMagicWordValue' ); return true; } -function wfGetCustomMagicWordValue( &$parser, $var1, $var2 ){ +function wfGetCustomMagicWordValue( $parser, $var1, $var2 ){ return "custom: var1 is $var1, var2 is $var2"; } |