Thiemo Mättig (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/364177 )
Change subject: Fix and add missing documentation and fix minor code smell
issues
......................................................................
Fix and add missing documentation and fix minor code smell issues
Change-Id: Ifa2f8a47fbd0bdd20334f59dd06a21339b9a4292
---
M Math.hooks.php
M MathFormatter.php
M MathMathML.php
M MathRenderer.php
M MathRestbaseInterface.php
M MathTexvc.php
M tests/MathCoverageTest.php
M tests/MathIdTest.php
M tests/MathMathMLTest.php
9 files changed, 29 insertions(+), 19 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math
refs/changes/77/364177/1
diff --git a/Math.hooks.php b/Math.hooks.php
index 49cf0b9..13b8845 100644
--- a/Math.hooks.php
+++ b/Math.hooks.php
@@ -9,7 +9,12 @@
use MediaWiki\Logger\LoggerFactory;
class MathHooks {
+
+ /**
+ * @var array[]
+ */
private static $tags = [];
+
const MATHCACHEKEY = 'math=';
public static function mathConstantToString( $value, array $defs,
$prefix, $default ) {
@@ -388,10 +393,9 @@
self::$tags = [];
return true;
}
+
/**
- *
- * @global type $wgOut
- * @param type $toolbar
+ * @param string $toolbar HTML
*/
static function onEditPageBeforeEditToolbar( &$toolbar ) {
global $wgOut;
diff --git a/MathFormatter.php b/MathFormatter.php
index a326eb4..5e3c68c 100644
--- a/MathFormatter.php
+++ b/MathFormatter.php
@@ -63,7 +63,7 @@
default:
$renderer = new MathMathML( $tex );
- if ( $renderer->checkTex() &&
$renderer->render() ) {
+ if ( $renderer->checkTeX() &&
$renderer->render() ) {
$html = $renderer->getHtmlOutput();
} else {
$html = $renderer->getLastError();
diff --git a/MathMathML.php b/MathMathML.php
index 23aa645..6ce53a2 100644
--- a/MathMathML.php
+++ b/MathMathML.php
@@ -20,7 +20,12 @@
/** @var boolean if false MathML output is not validated */
private $XMLValidation = true;
+
+ /**
+ * @var string|bool
+ */
private $svgPath = false;
+
private $mathoidStyle;
public function __construct( $tex = '', $params = [] ) {
@@ -176,9 +181,8 @@
$this->getPostData();
}
$options = [ 'method' => 'POST', 'postData' => $post, 'timeout'
=> $wgMathLaTeXMLTimeout ];
- /** @var $req (CurlHttpRequest|PhpHttpRequest) the request
object */
+ /** @var CurlHttpRequest|PhpHttpRequest $req the request object
*/
$req = $httpRequestClass::factory( $host, $options );
- /** @var Status $req Status the request status */
$status = $req->execute();
if ( $status->isGood() ) {
$res = $req->getContent();
@@ -334,7 +338,7 @@
/**
* @param boolean $noRender
- * @return type
+ * @return Title|string
*/
private function getFallbackImageUrl( $noRender = false ) {
if ( $this->svgPath ) {
diff --git a/MathRenderer.php b/MathRenderer.php
index 5cd16d7..7b2db14 100644
--- a/MathRenderer.php
+++ b/MathRenderer.php
@@ -487,14 +487,14 @@
/**
* Get the attributes of the math tag
*
- * @return []
+ * @return array
*/
public function getParams() {
return $this->params;
}
/**
- * @param [] $params
+ * @param array $params
*/
public function setParams( $params ) {
// $changed is not set to true here, because the attributes do
not affect
diff --git a/MathRestbaseInterface.php b/MathRestbaseInterface.php
index 2c29ec0..f248f48 100644
--- a/MathRestbaseInterface.php
+++ b/MathRestbaseInterface.php
@@ -22,7 +22,6 @@
private $purge = false;
/**
- * MathRestbaseInterface constructor.
* @param string $tex
* @param string $type
*/
@@ -34,8 +33,8 @@
/**
* Bundles several requests for fetching MathML.
* Does not send requests, if the the input TeX is invalid.
- * @param $rbis
- * @param $serviceClient
+ * @param MathRestbaseInterface[] $rbis
+ * @param VirtualRESTServiceClient $serviceClient
*/
private static function batchGetMathML( $rbis, $serviceClient ) {
$requests = [];
@@ -135,7 +134,7 @@
}
/**
- * @param array $rbis array of MathRestbaseInterface instances
+ * @param MathRestbaseInterface[] $rbis
*/
public static function batchEvaluate( $rbis ) {
if ( count( $rbis ) == 0 ) {
@@ -162,6 +161,9 @@
self::batchGetMathML( $rbis, $serviceClient );
}
+ /**
+ * @return VirtualRESTServiceClient
+ */
private function getServiceClient() {
global $wgVirtualRestConfig, $wgMathConcurrentReqs;
$http = new MultiHttpClient( [ 'maxConnsPerHost' =>
$wgMathConcurrentReqs ] );
@@ -263,6 +265,7 @@
[ 'uniqueTeX' => $uniqueTeX ] );
return false;
}
+
try {
$url = $testInterface->getFullSvgUrl();
$req = MWHttpRequest::factory( $url );
diff --git a/MathTexvc.php b/MathTexvc.php
index 6d28385..85c5407 100644
--- a/MathTexvc.php
+++ b/MathTexvc.php
@@ -57,7 +57,7 @@
}
/**
- * @param database_row $rpage
+ * @param stdClass $rpage
* @return bool
*/
protected function initializeFromDatabaseRow( $rpage ) {
@@ -330,7 +330,7 @@
if ( !$backend ) {
$backend = new FSFileBackend( [
'name' => 'math-backend',
- 'wikiId' => wfWikiId(),
+ 'wikiId' => wfWikiID(),
'lockManager' => new
NullLockManager( [] ),
'containerPaths' => [ 'math-render' =>
$wgMathDirectory ],
'fileMode' => 0777,
diff --git a/tests/MathCoverageTest.php b/tests/MathCoverageTest.php
index 17abed0..05abcf9 100644
--- a/tests/MathCoverageTest.php
+++ b/tests/MathCoverageTest.php
@@ -85,7 +85,7 @@
/**
* Gets the test-data from the file ParserTest.json
- * @return [$input, $output] where $input is the test input string
+ * @return string[] [ $input, $output ] where $input is the test input
string
* and $output is the rendered html5-output string
*/
public function provideCoverage() {
diff --git a/tests/MathIdTest.php b/tests/MathIdTest.php
index 38ac6bc..0f5e053 100644
--- a/tests/MathIdTest.php
+++ b/tests/MathIdTest.php
@@ -17,7 +17,7 @@
public function testBasics() {
define( 'RANDOM_ID', 'a_random_id' );
$renderer = MathRenderer::getRenderer( "a+b", [ 'id' =>
RANDOM_ID ] );
- $this->assertEquals( RANDOM_ID, $renderer->getId() );
+ $this->assertEquals( RANDOM_ID, $renderer->getID() );
}
}
diff --git a/tests/MathMathMLTest.php b/tests/MathMathMLTest.php
index 745c449..5f36c60 100644
--- a/tests/MathMathMLTest.php
+++ b/tests/MathMathMLTest.php
@@ -69,7 +69,7 @@
$requestReturn = $renderer->makeRequest( $url, 'a+b', $res,
$error,
'MathMLHttpRequestTester' );
$this->assertEquals( true, $requestReturn, "successful call
return" );
- $this->isTrue( $res, "successfull call" );
+ $this->assertTrue( $res, 'successfull call' );
$this->assertEquals( $error, '', "successfull call
errormessage" );
}
@@ -139,7 +139,6 @@
* Helper class for testing
* @author physikerwelt
* @see MWHttpRequestTester
- *
*/
class MathMLHttpRequestTester {
--
To view, visit https://gerrit.wikimedia.org/r/364177
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifa2f8a47fbd0bdd20334f59dd06a21339b9a4292
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits