Stop passing objects by reference

Bug: T193950
Change-Id: I8c4aabe75ffce55f81c7ffb0f76b67155db1f761
This commit is contained in:
Max Semenik 2019-11-18 19:28:05 -08:00 committed by Thiemo Kreuz (WMDE)
parent 1c950c84a4
commit 9380fa050e
4 changed files with 24 additions and 19 deletions

View file

@ -173,12 +173,12 @@ HTML;
}
/**
* @param ApiBase &$module
* @param ApiBase $module
* @param array &$params
* @param int $flags
* @return bool
*/
public function apiGetAllowedParams( &$module, &$params, $flags ) {
public function apiGetAllowedParams( ApiBase $module, &$params, $flags ) {
if ( $flags && $this->isAPICaptchaModule( $module ) ) {
$params['g-recaptcha-response'] = [
ApiBase::PARAM_HELP_MSG => 'renocaptcha-apihelp-param-g-recaptcha-response',

View file

@ -197,10 +197,10 @@ class SimpleCaptcha {
/**
* Show error message for missing or incorrect captcha on EditPage.
* @param EditPage &$editPage
* @param OutputPage &$out
* @param EditPage $editPage
* @param OutputPage $out
*/
public function showEditFormFields( &$editPage, &$out ) {
public function showEditFormFields( EditPage $editPage, OutputPage $out ) {
$out->enableOOUI();
$page = $editPage->getArticle()->getPage();
if ( !isset( $page->ConfirmEdit_ActivateCaptcha ) ) {
@ -251,10 +251,10 @@ class SimpleCaptcha {
/**
* Inject whazawhoo
* @fixme if multiple thingies insert a header, could break
* @param HTMLForm &$form
* @param HTMLForm $form
* @return bool true to keep running callbacks
*/
public function injectEmailUser( &$form ) {
public function injectEmailUser( HTMLForm $form ) {
$out = $form->getOutput();
$user = $form->getUser();
if ( $this->triggersCaptcha( CaptchaTriggers::SENDEMAIL ) ) {
@ -919,12 +919,12 @@ class SimpleCaptcha {
}
/**
* @param ApiBase &$module
* @param ApiBase $module
* @param array &$params
* @param int $flags
* @return bool
*/
public function apiGetAllowedParams( &$module, &$params, $flags ) {
public function apiGetAllowedParams( ApiBase $module, &$params, $flags ) {
if ( $this->isAPICaptchaModule( $module ) ) {
$params['captchaword'] = [
ApiBase::PARAM_HELP_MSG => 'captcha-apihelp-param-captchaword',

View file

@ -80,17 +80,17 @@ class ConfirmEditHooks {
/**
* @param EditPage $editPage
* @param OutputPage &$out
* @param OutputPage $out
*/
public static function showEditFormFields( $editPage, &$out ) {
public static function showEditFormFields( EditPage $editPage, OutputPage $out ) {
self::getInstance()->showEditFormFields( $editPage, $out );
}
/**
* @param HTMLForm &$form
* @param HTMLForm $form
* @return bool
*/
public static function injectEmailUser( &$form ) {
public static function injectEmailUser( $form ) {
return self::getInstance()->injectEmailUser( $form );
}
@ -109,12 +109,12 @@ class ConfirmEditHooks {
/**
* APIGetAllowedParams hook handler
* Default $flags to 1 for backwards-compatible behavior
* @param ApiBase &$module
* @param ApiBase $module
* @param array &$params
* @param int $flags
* @return bool
*/
public static function onAPIGetAllowedParams( &$module, &$params, $flags = 1 ) {
public static function onAPIGetAllowedParams( ApiBase $module, &$params, $flags = 1 ) {
return self::getInstance()->apiGetAllowedParams( $module, $params, $flags );
}
@ -185,12 +185,17 @@ class ConfirmEditHooks {
* interface message, if it validates as an IP address.
*
* @param EditPage $editor
* @param Content &$content
* @param Content $content
* @param string &$html
* @param ParserOutput &$po
* @param ?ParserOutput $parserOutput
* @return bool
*/
public static function onAlternateEditPreview( EditPage $editor, &$content, &$html, &$po ) {
public static function onAlternateEditPreview(
EditPage $editor,
Content $content,
&$html,
$parserOutput
) {
$title = $editor->getTitle();
$exceptionTitle = Title::makeTitle( NS_MEDIAWIKI, 'Captcha-ip-whitelist' );

View file

@ -142,7 +142,7 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiTestCase {
* @dataProvider provideTestForAccountCreation
*/
public function testTestForAccountCreation( $req, $creator, $result, $disableTrigger = false ) {
$this->setMwHook( 'PingLimiter', function ( &$user, $action, &$result ) {
$this->setMwHook( 'PingLimiter', function ( $user, $action, &$result ) {
$result = false;
return false;
} );