Physikerwelt has uploaded a new change for review. https://gerrit.wikimedia.org/r/283041
Change subject: Convert all array() syntax to [] ...................................................................... Convert all array() syntax to [] Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Change-Id: I1d2604e3f246ede58ff8245ba2b940f258d2d80c --- M Math.alias.noTranslate.php M Math.alias.php M Math.hooks.php M MathFormatter.php M MathLaTeXML.php M MathMathML.php M MathRenderer.php M MathRestbaseInterface.php M MathSource.php M MathTexvc.php M SpecialMathShowImage.php M SpecialMathStatus.php M maintenance/MathGenerateTests.php M tests/MathCoverageTest.php M tests/MathLaTeXMLDatabaseTest.php M tests/MathSourceTest.php 16 files changed, 39 insertions(+), 39 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math refs/changes/41/283041/1 diff --git a/Math.alias.noTranslate.php b/Math.alias.noTranslate.php index 943237c..ad8143a 100644 --- a/Math.alias.noTranslate.php +++ b/Math.alias.noTranslate.php @@ -10,7 +10,7 @@ * @ingroup Extensions */ -$specialPageAliases = array(); +$specialPageAliases = []; /** English (English) */ $specialPageAliases['en'] = array( diff --git a/Math.alias.php b/Math.alias.php index 0a3dd14..80623c8 100644 --- a/Math.alias.php +++ b/Math.alias.php @@ -10,7 +10,7 @@ */ // @codingStandardsIgnoreFile -$specialPageAliases = array(); +$specialPageAliases = []; /** English (English) */ $specialPageAliases['en'] = array( diff --git a/Math.hooks.php b/Math.hooks.php index 2fc6b5f..ed47f06 100644 --- a/Math.hooks.php +++ b/Math.hooks.php @@ -9,7 +9,7 @@ use MediaWiki\Logger\LoggerFactory; class MathHooks { - private static $tags = array(); + private static $tags = []; const MATHCACHEKEY = 'math='; public static function mathConstantToString( $value, array $defs, $prefix, $default ) { @@ -30,7 +30,7 @@ } } if ( is_string( $value ) ) { - $newValues = array(); + $newValues = []; foreach ( $defs as $k => $v ) { $newValues[$k] = preg_replace_callback( '/_(.)/', function ( $matches ) { return strtoupper( $matches[1] ); @@ -102,7 +102,7 @@ * @param User $user reference to the current user * @param array &$forOptions userOptions used on that page */ - public static function onPageRenderingHash( &$confstr, $user = false, &$forOptions = array() ) { + public static function onPageRenderingHash( &$confstr, $user = false, &$forOptions = [] ) { global $wgUser; // To be independent of the MediaWiki core version, @@ -273,7 +273,7 @@ * @return array of strings */ public static function getMathNames() { - $names = array(); + $names = []; foreach ( MathRenderer::getValidModes() as $mode ) { $names[$mode] = wfMessage( 'mw_math_' . $mode )->escaped(); } @@ -374,7 +374,7 @@ * @return bool */ public static function onParserAfterTidy( &$parser, &$text ) { - $rbis = array(); + $rbis = []; foreach ( self::$tags as $key => $tag ){ /** @var MathRenderer $renderer */ $renderer = $tag[0]; @@ -392,7 +392,7 @@ $text = str_replace( $key, $value, $text ); } // This hook might be called multiple times. However one the tags are rendered the job is done. - self::$tags = array(); + self::$tags = []; return true; } /** diff --git a/MathFormatter.php b/MathFormatter.php index a4c99af..59ea8d1 100644 --- a/MathFormatter.php +++ b/MathFormatter.php @@ -95,7 +95,7 @@ $html .= Html::rawElement( 'div', array( 'class' => 'wb-details wb-math-details' ), - Html::element( 'code', array(), $tex ) + Html::element( 'code', [], $tex ) ); return $html; diff --git a/MathLaTeXML.php b/MathLaTeXML.php index 38d595b..3c9e98f 100644 --- a/MathLaTeXML.php +++ b/MathLaTeXML.php @@ -16,7 +16,7 @@ /** @var String settings for LaTeXML daemon */ private $LaTeXMLSettings = ''; - public function __construct( $tex = '', $params = array() ) { + public function __construct( $tex = '', $params = [] ) { global $wgMathLaTeXMLUrl; parent::__construct( $tex, $params ); $this->hosts = $wgMathLaTeXMLUrl; diff --git a/MathMathML.php b/MathMathML.php index 6d8f6a8..f1f83fa 100644 --- a/MathMathML.php +++ b/MathMathML.php @@ -23,7 +23,7 @@ private $svgPath = false; private $mathoidStyle; - public function __construct( $tex = '', $params = array() ) { + public function __construct( $tex = '', $params = [] ) { global $wgMathMathMLUrl; parent::__construct( $tex, $params ); $this->setMode( 'mathml' ); @@ -374,7 +374,7 @@ private function getFallbackImage( $noRender = false, $classOverride = false ) { $url = $this->getFallbackImageUrl( $noRender ); - $attribs = array(); + $attribs = []; if ( $classOverride === false ) { // $class = '' suppresses class attribute $class = $this->getClassName( true ); } else { @@ -436,7 +436,7 @@ } else { $element = 'span'; } - $attribs = array(); + $attribs = []; if ( $this->getID() !== '' ) { $attribs['id'] = $this->getID(); } diff --git a/MathRenderer.php b/MathRenderer.php index d51be40..543f104 100644 --- a/MathRenderer.php +++ b/MathRenderer.php @@ -35,7 +35,7 @@ /** @var ('inlineDisplaystyle'|'display'|'inline'|'linebreak') the rendering style */ protected $mathStyle = 'inlineDisplaystyle'; /** @var array with userdefined parameters passed to the extension (not used) */ - protected $params = array(); + protected $params = []; /** @var string a userdefined identifier to link to the equation. */ protected $id = ''; @@ -67,7 +67,7 @@ * @param string $tex (optional) LaTeX markup * @param array $params (optional) HTML attributes */ - public function __construct( $tex = '', $params = array() ) { + public function __construct( $tex = '', $params = [] ) { $this->params = $params; if ( isset( $params['id'] ) ) { $this->id = $params['id']; @@ -109,7 +109,7 @@ * @param string $mode constant indicating rendering mode * @return string HTML for math tag */ - public static function renderMath( $tex, $params = array(), $mode = 'png' ) { + public static function renderMath( $tex, $params = [], $mode = 'png' ) { $renderer = self::getRenderer( $tex, $params, $mode ); if ( $renderer->render() ) { return $renderer->getHtmlOutput(); @@ -140,7 +140,7 @@ * @param string $mode indicating rendering mode * @return MathRenderer appropriate renderer for mode */ - public static function getRenderer( $tex, $params = array(), $mode = 'png' ) { + public static function getRenderer( $tex, $params = [], $mode = 'png' ) { global $wgDefaultUserOptions, $wgMathEnableExperimentalInputFormats; if ( isset( $params['forcemathmode'] ) ) { @@ -395,7 +395,7 @@ * @param array $overrides attributes to override defaults * @return array HTML attributes */ - protected function getAttributes( $tag, $defaults = array(), $overrides = array() ) { + protected function getAttributes( $tag, $defaults = [], $overrides = [] ) { $attribs = Sanitizer::validateTagAttributes( $this->params, $tag ); $attribs = Sanitizer::mergeAttributes( $defaults, $attribs ); $attribs = Sanitizer::mergeAttributes( $attribs, $overrides ); @@ -485,14 +485,14 @@ /** * Get the attributes of the math tag * - * @return array() + * @return [] */ public function getParams() { return $this->params; } /** - * @param array() $params + * @param [] $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 86ac502..7c58c31 100644 --- a/MathRestbaseInterface.php +++ b/MathRestbaseInterface.php @@ -36,8 +36,8 @@ * @param $serviceClient */ private static function batchGetMathML( $rbis, $serviceClient ) { - $requests = array(); - $skips = array(); + $requests = []; + $skips = []; $i = 0; foreach ( $rbis as $rbi ) { /** @var MathRestbaseInterface $rbi */ @@ -129,7 +129,7 @@ if ( count( $rbis ) == 0 ) { return; } - $requests = array(); + $requests = []; /** @var MathRestbaseInterface $first */ $first = $rbis[0]; $serviceClient = $first->getServiceClient(); @@ -152,7 +152,7 @@ private function getServiceClient() { global $wgVirtualRestConfig; - $serviceClient = new VirtualRESTServiceClient( new MultiHttpClient( array() ) ); + $serviceClient = new VirtualRESTServiceClient( new MultiHttpClient( [] ) ); if ( isset( $wgVirtualRestConfig['modules']['restbase'] ) ) { $cfg = $wgVirtualRestConfig['modules']['restbase']; $cfg['parsoidCompat'] = false; diff --git a/MathSource.php b/MathSource.php index 517d8d0..26fa022 100644 --- a/MathSource.php +++ b/MathSource.php @@ -23,7 +23,7 @@ * @param string $tex * @param array $params */ - function __construct( $tex = '', $params = array() ) { + function __construct( $tex = '', $params = [] ) { parent::__construct( $tex, $params ); $this->setMode( 'source' ); } diff --git a/MathTexvc.php b/MathTexvc.php index 514a512..5a6cc39 100644 --- a/MathTexvc.php +++ b/MathTexvc.php @@ -35,7 +35,7 @@ * @return array */ public function dbOutArray() { - $out = array(); + $out = []; $dbr = wfGetDB( DB_SLAVE ); $outmd5_sql = $dbr->encodeBlob( pack( 'H32', $this->hash ) ); if ( $outmd5_sql instanceof Blob ) { @@ -292,7 +292,7 @@ // Store the file at the final storage path... // Bug 56769: buffer the writes and do them at the end. if ( !isset( $wgHooks['ParserAfterParse']['FlushMathBackend'] ) ) { - $backend->mathBufferedWrites = array(); + $backend->mathBufferedWrites = []; $wgHooks['ParserAfterParse']['FlushMathBackend'] = function () use ( $backend ) { global $wgHooks; unset( $wgHooks['ParserAfterParse']['FlushMathBackend'] ); @@ -325,7 +325,7 @@ $backend = new FSFileBackend( array( 'name' => 'math-backend', 'wikiId' => wfWikiId(), - 'lockManager' => new NullLockManager( array() ), + 'lockManager' => new NullLockManager( [] ), 'containerPaths' => array( 'math-render' => $wgMathDirectory ), 'fileMode' => 0777 ) ); diff --git a/SpecialMathShowImage.php b/SpecialMathShowImage.php index 615efad..1534a85 100644 --- a/SpecialMathShowImage.php +++ b/SpecialMathShowImage.php @@ -82,14 +82,14 @@ $mmlRenderer = MathMathML::newFromMd5( $hash ); $mmlRenderer->readFromDatabase(); $this->renderer = MathRenderer::getRenderer( - $mmlRenderer->getUserInputTex(), array(), 'png' + $mmlRenderer->getUserInputTex(), [], 'png' ); $this->renderer->setMathStyle( $mmlRenderer->getMathStyle() ); } $success = $this->renderer->render(); } } elseif ( $asciimath === '' ) { - $this->renderer = MathRenderer::getRenderer( $tex, array(), $this->mode ); + $this->renderer = MathRenderer::getRenderer( $tex, [], $this->mode ); $success = $this->renderer->render(); } else { $this->renderer = MathRenderer::getRenderer( diff --git a/SpecialMathStatus.php b/SpecialMathStatus.php index c9ee42f..2783edb 100644 --- a/SpecialMathStatus.php +++ b/SpecialMathStatus.php @@ -63,7 +63,7 @@ } public function testSpecialCaseText() { - $renderer = MathRenderer::getRenderer( 'x^2+\text{a sample Text}', array(), 'mathml' ); + $renderer = MathRenderer::getRenderer( 'x^2+\text{a sample Text}', [], 'mathml' ); $expected = 'a sample Text</mtext>'; $this->assertTrue( $renderer->render(), 'Rendering the input "x^2+\text{a sample Text}"' ); $this->assertContains( @@ -78,7 +78,7 @@ public function testMathMLIntegration() { $svgRef = file_get_contents( __DIR__ .'/images/reference.svg' ); $svgRefNoSpeech = file_get_contents( __DIR__ .'/images/reference-nospeech.svg' ); - $renderer = MathRenderer::getRenderer( "a+b", array(), 'mathml' ); + $renderer = MathRenderer::getRenderer( "a+b", [], 'mathml' ); $this->assertTrue( $renderer->render( true ), "Rendering of a+b in plain MathML mode" ); $real = str_replace( "\n", '', $renderer->getHtmlOutput() ); $expected = '<mo>+</mo>'; @@ -113,7 +113,7 @@ * i.e. if the span element is generated right. */ public function testLaTeXMLIntegration() { - $renderer = MathRenderer::getRenderer( "a+b", array(), 'latexml' ); + $renderer = MathRenderer::getRenderer( "a+b", [], 'latexml' ); $this->assertTrue( $renderer->render( true ), "Rendering of a+b in LaTeXML mode" ); // @codingStandardsIgnoreStart $expected = '<math xmlns="http://www.w3.org/1998/Math/MathML" id="p1.m1" class="ltx_Math" alttext="{\displaystyle a+b}" ><semantics><mrow id="p1.m1.4" xref="p1.m1.4.cmml"><mi id="p1.m1.1" xref="p1.m1.1.cmml">a</mi><mo id="p1.m1.2" xref="p1.m1.2.cmml">+</mo><mi id="p1.m1.3" xref="p1.m1.3.cmml">b</mi></mrow><annotation-xml encoding="MathML-Content"><apply id="p1.m1.4.cmml" xref="p1.m1.4"><plus id="p1.m1.2.cmml" xref="p1.m1.2"/><ci id="p1.m1.1.cmml" xref="p1.m1.1">a</ci><ci id="p1.m1.3.cmml" xref="p1.m1.3">b</ci></apply></annotation-xml><annotation encoding="application/x-tex">{\displaystyle a+b}</annotation></semantics></math>'; diff --git a/maintenance/MathGenerateTests.php b/maintenance/MathGenerateTests.php index 51fd14e..3ac337e 100644 --- a/maintenance/MathGenerateTests.php +++ b/maintenance/MathGenerateTests.php @@ -55,14 +55,14 @@ $wikiText = Sanitizer::removeHTMLcomments( $wikiText ); $wikiText = preg_replace( '#<nowiki>(.*)</nowiki>#', '', $wikiText ); - $math = array(); + $math = []; Parser::extractTagsAndParams( array( 'math' ), $wikiText, $math ); return $math; } public function execute() { global $wgUser; - $parserTests = array(); + $parserTests = []; $page = $this->getArg( 0, self::REFERENCE_PAGE ); $offset = $this->getOption( 'offset', 0 ); $length = $this->getOption( 'length', PHP_INT_MAX ); diff --git a/tests/MathCoverageTest.php b/tests/MathCoverageTest.php index 43c8693..d932151 100644 --- a/tests/MathCoverageTest.php +++ b/tests/MathCoverageTest.php @@ -78,7 +78,7 @@ // TODO: Link to the wikipage that contains the reference rendering $this->assertEquals( $this->normalize( $output ), - $this->normalize( MathRenderer::renderMath( $input, array(), 'png' ) ), + $this->normalize( MathRenderer::renderMath( $input, [], 'png' ) ), "Failed to render $input" ); } diff --git a/tests/MathLaTeXMLDatabaseTest.php b/tests/MathLaTeXMLDatabaseTest.php index 7018eab..233f7d6 100644 --- a/tests/MathLaTeXMLDatabaseTest.php +++ b/tests/MathLaTeXMLDatabaseTest.php @@ -71,7 +71,7 @@ public function testTableName() { $fnGetMathTableName = self::getMethod( 'getMathTableName' ); $obj = new MathLaTeXML(); - $tableName = $fnGetMathTableName->invokeArgs( $obj, array() ); + $tableName = $fnGetMathTableName->invokeArgs( $obj, [] ); $this->assertEquals( $tableName, "mathlatexml", "Wrong latexml table name" ); } diff --git a/tests/MathSourceTest.php b/tests/MathSourceTest.php index 97084d7..06ca7b4 100644 --- a/tests/MathSourceTest.php +++ b/tests/MathSourceTest.php @@ -16,7 +16,7 @@ * i.e. if the span element is generated right. */ public function testBasics() { - $real = MathRenderer::renderMath( "a+b", array(), 'source' ); + $real = MathRenderer::renderMath( "a+b", [], 'source' ); $this->assertEquals( '<span class="mwe-math-fallback-source-inline tex" dir="ltr">$ a+b $</span>', $real, @@ -28,7 +28,7 @@ * Checks if newlines are converted to spaces correctly. */ public function testNewLines() { - $real = MathRenderer::renderMath( "a\n b", array(), 'source' ); + $real = MathRenderer::renderMath( "a\n b", [], 'source' ); $this->assertSame( '<span class="mwe-math-fallback-source-inline tex" dir="ltr">$ a b $</span>', $real, -- To view, visit https://gerrit.wikimedia.org/r/283041 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1d2604e3f246ede58ff8245ba2b940f258d2d80c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Math Gerrit-Branch: master Gerrit-Owner: Physikerwelt <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
