From d37698535ac20f9d7309260d281f9943a639c5bd Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Fri, 2 Nov 2018 18:52:06 +0100 Subject: [PATCH] Add method scope visibility Change-Id: I6b8e90017c9862fc082b216d44bebab34f3a6095 --- .phpcs.xml | 1 - src/MathHooks.php | 18 +++++++++--------- src/MathRenderer.php | 6 +++--- src/MathSource.php | 6 +++--- src/SpecialMathShowImage.php | 6 +++--- src/SpecialMathStatus.php | 2 +- tests/phpunit/MathMathMLTest.php | 8 ++++---- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/.phpcs.xml b/.phpcs.xml index 9be5cd2..2bc2d29 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -6,7 +6,6 @@ - . diff --git a/src/MathHooks.php b/src/MathHooks.php index 5c6b846..833f83d 100644 --- a/src/MathHooks.php +++ b/src/MathHooks.php @@ -151,7 +151,7 @@ class MathHooks { /** * Set up $wgMathPath and $wgMathDirectory globals if they're not already set. */ - static function setup() { + public static function setup() { global $wgMathPath, $wgMathDirectory, $wgUploadPath, $wgUploadDirectory; @@ -170,7 +170,7 @@ class MathHooks { * @param Parser $parser instance of Parser * @return bool true */ - static function onParserFirstCallInit( $parser ) { + public static function onParserFirstCallInit( $parser ) { $parser->setHook( 'math', [ self::class, 'mathTagHook' ] ); // @deprecated the ce tag is deprecated in favour of chem cf. T153606 $parser->setHook( 'ce', [ self::class, 'chemTagHook' ] ); @@ -187,7 +187,7 @@ class MathHooks { * @param Parser $parser * @return array|string */ - static function mathTagHook( $content, $attributes, $parser ) { + public static function mathTagHook( $content, $attributes, $parser ) { static $n = 1; if ( trim( $content ) === '' ) { // bug 8372 https://phabricator.wikimedia.org/rSVN18870 return ''; @@ -258,7 +258,7 @@ class MathHooks { * @param array &$defaultPreferences Preferences array * @return bool true */ - static function onGetPreferences( $user, &$defaultPreferences ) { + public static function onGetPreferences( $user, &$defaultPreferences ) { global $wgDefaultUserOptions; $defaultPreferences['math'] = [ 'type' => 'radio', @@ -300,7 +300,7 @@ class MathHooks { * @param Maintenance $maint * @return bool hook return code */ - static function onMaintenanceRefreshLinksInit( $maint ) { + public static function onMaintenanceRefreshLinksInit( $maint ) { global $wgUser; # Don't generate TeX PNGs (the lack of a sensible current directory causes errors anyway) @@ -316,7 +316,7 @@ class MathHooks { * @throws Exception * @return bool */ - static function onLoadExtensionSchemaUpdates( $updater = null ) { + public static function onLoadExtensionSchemaUpdates( $updater = null ) { $type = $updater->getDB()->getType(); if ( in_array( 'latexml', MathRenderer::getValidModes() ) ) { @@ -354,7 +354,7 @@ class MathHooks { * @param array &$tables * @return bool */ - static function onParserTestTables( &$tables ) { + public static function onParserTestTables( &$tables ) { $tables[] = 'math'; $tables[] = 'mathlatexml'; return true; @@ -388,7 +388,7 @@ class MathHooks { /** * @param string &$toolbar HTML */ - static function onEditPageBeforeEditToolbar( &$toolbar ) { + public static function onEditPageBeforeEditToolbar( &$toolbar ) { global $wgOut; $wgOut->addModules( [ 'ext.math.editbutton.enabler' ] ); } @@ -411,7 +411,7 @@ class MathHooks { * @param Parser $parser * @return array */ - static function chemTagHook( $content, $attributes, $parser ) { + public static function chemTagHook( $content, $attributes, $parser ) { $attributes['chem'] = true; return self::mathTagHook( '\ce{' . $content . '}', $attributes, $parser ); } diff --git a/src/MathRenderer.php b/src/MathRenderer.php index 3652f18..ef16df6 100644 --- a/src/MathRenderer.php +++ b/src/MathRenderer.php @@ -524,7 +524,7 @@ abstract class MathRenderer { * Checks if there is an explicit user request to rerender the math-tag. * @return bool */ - function isPurge() { + public function isPurge() { if ( $this->purge ) { return true; } @@ -544,12 +544,12 @@ abstract class MathRenderer { * use a cached version. * @param bool $purge */ - function setPurge( $purge = true ) { + public function setPurge( $purge = true ) { $this->changed = true; $this->purge = $purge; } - function getLastError() { + public function getLastError() { return $this->lastError; } diff --git a/src/MathSource.php b/src/MathSource.php index 222fe8e..a609222 100644 --- a/src/MathSource.php +++ b/src/MathSource.php @@ -23,7 +23,7 @@ class MathSource extends MathRenderer { * @param string $tex * @param array $params */ - function __construct( $tex = '', $params = [] ) { + public function __construct( $tex = '', $params = [] ) { parent::__construct( $tex, $params ); $this->setMode( 'source' ); } @@ -33,7 +33,7 @@ class MathSource extends MathRenderer { * * @return string span tag with TeX */ - function getHtmlOutput() { + public function getHtmlOutput() { # No need to render or parse anything more! # New lines are replaced with spaces, which avoids confusing our parser (bugs 23190, 22818) if ( $this->getMathStyle() == 'display' ) { @@ -63,7 +63,7 @@ class MathSource extends MathRenderer { * No rendering required in plain text mode * @return bool */ - function render() { + public function render() { // assume unchanged to avoid unnecessary database access $this->changed = false; return true; diff --git a/src/SpecialMathShowImage.php b/src/SpecialMathShowImage.php index 201d090..d8a5fd1 100644 --- a/src/SpecialMathShowImage.php +++ b/src/SpecialMathShowImage.php @@ -9,7 +9,7 @@ class SpecialMathShowImage extends SpecialPage { private $renderer = null; private $mode = 'mathml'; - function __construct() { + public function __construct() { parent::__construct( 'MathShowImage', '', // Don't restrict @@ -21,7 +21,7 @@ class SpecialMathShowImage extends SpecialPage { * Sets headers - this should be called from the execute() method of all derived classes! * @param bool $success */ - function setHeaders( $success = true ) { + public function setHeaders( $success = true ) { $out = $this->getOutput(); $request = $this->getRequest(); $out->setArticleBodyOnly( true ); @@ -41,7 +41,7 @@ class SpecialMathShowImage extends SpecialPage { } } - function execute( $par ) { + public function execute( $par ) { global $wgMathEnableExperimentalInputFormats, $wgMathoidCli; $request = $this->getRequest(); $hash = $request->getText( 'hash', '' ); diff --git a/src/SpecialMathStatus.php b/src/SpecialMathStatus.php index 16808f0..13c085c 100644 --- a/src/SpecialMathStatus.php +++ b/src/SpecialMathStatus.php @@ -22,7 +22,7 @@ class SpecialMathStatus extends SpecialPage { * @throws MWException * @throws PermissionsError */ - function execute( $query ) { + public function execute( $query ) { $this->setHeaders(); if ( ! ( $this->getUser()->isAllowed( 'purge' ) ) ) { // The effect of loading this page is comparable to purge a page. diff --git a/tests/phpunit/MathMathMLTest.php b/tests/phpunit/MathMathMLTest.php index 0ec6c28..e2d6600 100644 --- a/tests/phpunit/MathMathMLTest.php +++ b/tests/phpunit/MathMathMLTest.php @@ -268,11 +268,11 @@ class MathMLHttpRequestTester { */ class MathMLTestStatus { - static function isGood() { + public static function isGood() { return MathMathMLTest::$good; } - static function hasMessage( $s ) { + public static function hasMessage( $s ) { if ( $s == 'http-timed-out' ) { return MathMathMLTest::$timeout; } else { @@ -280,11 +280,11 @@ class MathMLTestStatus { } } - static function getHtml() { + public static function getHtml() { return MathMathMLTest::$html; } - static function getWikiText() { + public static function getWikiText() { return MathMathMLTest::$html; }