Replace use of &$this

Use of &$this doesn't work in PHP 7.1. For callbacks to methods like
array_map() it's completely unnecessary, while for hooks we still need
to pass a reference and so we need to copy $this into a local variable.

Bug: T153505
Change-Id: Ib31f3bbffdd6b25ad9a21498294644e4dde33bd1
This commit is contained in:
Brad Jorsch 2017-01-31 22:54:07 -05:00
parent 0677292659
commit 1c3dd4fb0d
3 changed files with 9 additions and 3 deletions

View file

@ -116,8 +116,10 @@ class MathLaTeXML extends MathMathML {
if ( $jsonResult && json_last_error() === JSON_ERROR_NONE ) { if ( $jsonResult && json_last_error() === JSON_ERROR_NONE ) {
if ( $this->isValidMathML( $jsonResult->result ) ) { if ( $this->isValidMathML( $jsonResult->result ) ) {
$this->setMathml( $jsonResult->result ); $this->setMathml( $jsonResult->result );
// Avoid PHP 7.1 warning from passing $this by reference
$renderer = $this;
Hooks::run( 'MathRenderingResultRetrieved', Hooks::run( 'MathRenderingResultRetrieved',
[ &$this, &$jsonResult ] );// Enables debugging of server results [ &$renderer, &$jsonResult ] );// Enables debugging of server results
return true; return true;
} else { } else {
// Do not print bad mathml. It's probably too verbose and might // Do not print bad mathml. It's probably too verbose and might

View file

@ -521,8 +521,10 @@ class MathMathML extends MathRenderer {
if ( $this->getMode() != 'latexml' && $this->inputType != 'pmml' ) { if ( $this->getMode() != 'latexml' && $this->inputType != 'pmml' ) {
$this->setMathml( $jsonResult->mml ); $this->setMathml( $jsonResult->mml );
} }
// Avoid PHP 7.1 warning from passing $this by reference
$renderer = $this;
Hooks::run( 'MathRenderingResultRetrieved', Hooks::run( 'MathRenderingResultRetrieved',
[ &$this, &$jsonResult ] ); // Enables debugging of server results [ &$renderer, &$jsonResult ] ); // Enables debugging of server results
return true; return true;
} else { } else {
$this->lastError = $this->getError( 'math_unknown_error', $host ); $this->lastError = $this->getError( 'math_unknown_error', $host );

View file

@ -275,7 +275,9 @@ class MathTexvc extends MathRenderer {
$this->setHash( $newHash ); $this->setHash( $newHash );
} }
Hooks::run( 'MathAfterTexvc', [ &$this, &$errmsg ] ); // Avoid PHP 7.1 warning from passing $this by reference
$renderer = $this;
Hooks::run( 'MathAfterTexvc', [ &$renderer, &$errmsg ] );
if ( $errmsg ) { if ( $errmsg ) {
return $errmsg; return $errmsg;