Legoktm has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/360210 )

Change subject: build: Updating mediawiki/mediawiki-codesniffer to 0.9.0
......................................................................

build: Updating mediawiki/mediawiki-codesniffer to 0.9.0

The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.DuplicateReturn
* MediaWiki.Commenting.FunctionComment.MissingParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.MissingReturn
* MediaWiki.Commenting.FunctionComment.ParamNameNoMatch
* MediaWiki.Commenting.FunctionComment.WrongStyle
* MediaWiki.FunctionComment.Missing.Protected
* MediaWiki.FunctionComment.Missing.Public
* MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment

Change-Id: I46c900a5652a6560d18be6cd67badc37ed7f8d97
---
M Math.hooks.php
M MathFormatter.php
M MathInputCheckRestbase.php
M MathInputCheckTexvc.php
M MathLaTeXML.php
M MathMathML.php
M MathRenderer.php
M MathRestbaseInterface.php
M MathTexvc.php
M MathValidator.php
M MathWikidataHook.php
M SpecialMathShowImage.php
M SpecialMathStatus.php
M composer.json
M maintenance/MathGenerateTests.php
M phpcs.xml
M tests/MathDatabaseTest.php
M tests/MathHooksTest.php
M tests/MathInputCheckRestbaseTest.php
M tests/MathInputCheckTest.php
M tests/MathRendererTest.php
21 files changed, 52 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math 
refs/changes/10/360210/1

diff --git a/Math.hooks.php b/Math.hooks.php
index 223b80e..8728e46 100644
--- a/Math.hooks.php
+++ b/Math.hooks.php
@@ -311,7 +311,6 @@
         * @return bool
         */
        static function onLoadExtensionSchemaUpdates( $updater = null ) {
-
                if ( is_null( $updater ) ) {
                        throw new Exception( 'Math extension is only necessary 
in 1.18 or above' );
                }
@@ -369,15 +368,14 @@
         */
        public static function onParserAfterTidy( &$parser, &$text ) {
                $rbis = [];
-               foreach ( self::$tags as $key => $tag ){
-                       /** @var MathRenderer $renderer */
-                       $renderer = $tag[0];
+               foreach ( self::$tags as $key => $tag ) {
+                       /** @var MathRenderer $renderer */                      
$renderer = $tag[0];
                        $rbi = new MathRestbaseInterface( $renderer->getTex(), 
$renderer->getInputType() );
                        $renderer->setRestbaseInterface( $rbi );
                        $rbis[] = $rbi;
                }
                MathRestbaseInterface::batchEvaluate( $rbis );
-               foreach ( self::$tags as $key => $tag ){
+               foreach ( self::$tags as $key => $tag ) {
                        $value = call_user_func_array( [ 
"MathHooks","mathPostTagHook" ], $tag );
                        // Workaround for 
https://phabricator.wikimedia.org/T103269
                        $text = preg_replace( '/(<mw:editsection[^>]*>.*?)' . 
preg_quote( $key ) .
diff --git a/MathFormatter.php b/MathFormatter.php
index db7c722..1e96e92 100644
--- a/MathFormatter.php
+++ b/MathFormatter.php
@@ -5,8 +5,7 @@
 use ValueFormatters\ValueFormatter;
 use Wikibase\Lib\SnakFormatter;
 
-/*
-* Formats the tex string based on the known formats
+/** Formats the tex string based on the known formats
 * * text/plain: used in the value input field of Wikidata
 * * text/x-wiki: wikitext
 * * text/html: used in Wikidata to display the value of properties
diff --git a/MathInputCheckRestbase.php b/MathInputCheckRestbase.php
index b2627c5..b72f88a 100644
--- a/MathInputCheckRestbase.php
+++ b/MathInputCheckRestbase.php
@@ -39,7 +39,7 @@
                if ( $errorRenderer === null ) {
                        $errorRenderer =  new MathSource( $this->inputTeX );
                }
-               if ( isset( $e->error->message ) ){
+               if ( isset( $e->error->message ) ) {
                        if ( $e->error->message === 'Illegal TeX function' ) {
                                return $errorRenderer->getError( 
'math_unknown_function', $e->error->found );
                        } elseif ( preg_match( '/Math extension/', 
$e->error->message ) ) {
@@ -81,7 +81,7 @@
         */
        public function getError() {
                $err = $this->restbaseInterface->getError();
-               if ( $err === null ){
+               if ( $err === null ) {
                        return null;
                }
                return $this->errorObjectToHtml( $err );
diff --git a/MathInputCheckTexvc.php b/MathInputCheckTexvc.php
index 40fb0ac..7d22f9d 100644
--- a/MathInputCheckTexvc.php
+++ b/MathInputCheckTexvc.php
@@ -51,7 +51,7 @@
        public function isValid() {
                $us = $this;
                $checkWork = new PoolCounterWorkViaCallback( 'MathTexvc-check', 
"", [
-                       'doWork' => function() use ( $us ) {
+                       'doWork' => function () use ( $us ) {
                                return $us->doValidCheck();
                        }
                ] );
@@ -63,7 +63,7 @@
         */
        public function doValidCheck() {
                global $wgMathTexvcCheckExecutable;
-               if ( $wgMathTexvcCheckExecutable === false ){
+               if ( $wgMathTexvcCheckExecutable === false ) {
                        $texvcCheckExecutable = __DIR__ . 
'/texvccheck/texvccheck';
                } else {
                        $texvcCheckExecutable = $wgMathTexvcCheckExecutable;
diff --git a/MathLaTeXML.php b/MathLaTeXML.php
index d5ae368..aa0c055 100644
--- a/MathLaTeXML.php
+++ b/MathLaTeXML.php
@@ -106,7 +106,7 @@
                $post = $this->getLaTeXMLPostData();
                // There is an API-inconsistency between different versions of 
the LaTeXML daemon
                // some versions require the literal prefix other don't allow 
it.
-               if ( ! strpos( $host, '/convert' ) ){
+               if ( ! strpos( $host, '/convert' ) ) {
                        $post = preg_replace( '/&tex=/', '&tex=literal:', 
$post, 1 );
                }
                $this->lastError = '';
@@ -218,4 +218,3 @@
                return 'mathlatexml';
        }
 }
-
diff --git a/MathMathML.php b/MathMathML.php
index e1e6f06..23aa645 100644
--- a/MathMathML.php
+++ b/MathMathML.php
@@ -34,7 +34,7 @@
                                $this->setMathml( '<math>' . $tex . '</math>' );
                        } elseif ( $params['type'] == 'ascii' ) {
                                $this->inputType = 'ascii';
-                       } elseif ( $params['type'] == 'chem' ){
+                       } elseif ( $params['type'] == 'chem' ) {
                                $this->inputType = 'chem';
                        }
                }
@@ -493,7 +493,6 @@
                        $this->userInputTex = $rpage->math_input;
                }
                parent::initializeFromDatabaseRow( $rpage );
-
        }
 
        /**
diff --git a/MathRenderer.php b/MathRenderer.php
index 99216f8..5cd16d7 100644
--- a/MathRenderer.php
+++ b/MathRenderer.php
@@ -553,11 +553,11 @@
         * @param string $mathStyle ('inlineDisplaystyle'|'display'|'inline')
         */
        public function setMathStyle( $mathStyle = 'display' ) {
-               if ( $this->mathStyle !== $mathStyle ){
+               if ( $this->mathStyle !== $mathStyle ) {
                        $this->changed = true;
                }
                $this->mathStyle = $mathStyle;
-               if ( $mathStyle == 'inline' ){
+               if ( $mathStyle == 'inline' ) {
                        $this->inputType = 'inline-tex';
                } else {
                        $this->inputType = 'tex';
@@ -589,7 +589,7 @@
                        // equation was already checked or checking is disabled
                        return true;
                } else {
-                       if ( self::getDisableTexFilter() == 'new' && 
$this->mode != 'source' ){
+                       if ( self::getDisableTexFilter() == 'new' && 
$this->mode != 'source' ) {
                                if ( $this->readFromDatabase() ) {
                                        return true;
                                }
@@ -651,7 +651,7 @@
         */
        public function getSvg( /** @noinspection PhpUnusedParameterInspection 
*/ $render = 'render' ) {
                // Spaces will prevent the image from being displayed correctly 
in the browser
-               if ( !$this->svg && $this->rbi ){
+               if ( !$this->svg && $this->rbi ) {
                        $this->svg = $this->rbi->getSvg();
                }
                return trim( $this->svg );
diff --git a/MathRestbaseInterface.php b/MathRestbaseInterface.php
index a2d8470..2c29ec0 100644
--- a/MathRestbaseInterface.php
+++ b/MathRestbaseInterface.php
@@ -85,7 +85,7 @@
         * @throws MWException
         */
        public function getMathML() {
-               if ( !$this->mml ){
+               if ( !$this->mml ) {
                        $this->mml = $this->getContent( 'mml' );
                }
                return $this->mml;
@@ -132,7 +132,6 @@
                        ] );
                }
                return $response;
-
        }
 
        /**
@@ -259,7 +258,7 @@
                // Generates a TeX string that probably has not been generated 
before
                $uniqueTeX = uniqid( 't=', true );
                $testInterface = new MathRestbaseInterface( $uniqueTeX );
-               if ( ! $testInterface->checkTeX() ){
+               if ( ! $testInterface->checkTeX() ) {
                        $this->log()->warning( 'Config check failed, since test 
expression was considered as invalid.',
                                [ 'uniqueTeX' => $uniqueTeX ] );
                        return false;
@@ -268,7 +267,7 @@
                        $url = $testInterface->getFullSvgUrl();
                        $req = MWHttpRequest::factory( $url );
                        $status = $req->execute();
-                       if ( $status->isOK() ){
+                       if ( $status->isOK() ) {
                                return true;
                        }
                        $this->log()->warning( 'Config check failed, due to an 
invalid response code.',
@@ -440,7 +439,7 @@
                $detail = 'Server problem.';
                $json = json_decode( $body );
                if ( isset( $json->detail ) ) {
-                       if ( is_array( $json->detail ) ){
+                       if ( is_array( $json->detail ) ) {
                                $detail = $json->detail[0];
                        } elseif ( is_string( $json->detail ) ) {
                                $detail = $json->detail;
diff --git a/MathTexvc.php b/MathTexvc.php
index 88c8610..6d28385 100644
--- a/MathTexvc.php
+++ b/MathTexvc.php
@@ -144,7 +144,7 @@
                        'class' => 'mwe-math-fallback-image-inline tex',
                        'alt' => $this->getTex()
                ];
-               if ( $this->getMathStyle() === 'display' ){
+               if ( $this->getMathStyle() === 'display' ) {
                        // if DisplayStyle is true, the equation will be 
centered in a new line
                        $attributes[ 'class' ] = 
'mwe-math-fallback-image-display tex';
                }
@@ -157,7 +157,6 @@
                                ]
                        )
                );
-
        }
 
        /**
@@ -178,7 +177,7 @@
         */
        public function callTexvc() {
                global $wgTexvc, $wgTexvcBackgroundColor, $wgHooks;
-               if ( $wgTexvc === false ){
+               if ( $wgTexvc === false ) {
                        $texvc = __DIR__ . '/math/texvc';
                } else {
                        $texvc = $wgTexvc;
diff --git a/MathValidator.php b/MathValidator.php
index e8f997f..d4713d3 100644
--- a/MathValidator.php
+++ b/MathValidator.php
@@ -27,7 +27,7 @@
                $tex = $value->getValue();
 
                $checker = new MathInputCheckRestbase( $tex );
-               if ( $checker->isValid() )  {
+               if ( $checker->isValid() ) {
                        return Result::newSuccess();
                }
 
diff --git a/MathWikidataHook.php b/MathWikidataHook.php
index cc14635..a0a15bb 100644
--- a/MathWikidataHook.php
+++ b/MathWikidataHook.php
@@ -23,7 +23,7 @@
 
                $dataTypeDefinitions['PT:math'] = [
                        'value-type'                 => 'string',
-                       'validator-factory-callback' => function() {
+                       'validator-factory-callback' => function () {
                                // load validator builders
                                $factory = 
WikibaseRepo::getDefaultValidatorBuilders();
 
@@ -34,12 +34,12 @@
                                $validators[] = new MathValidator();
                                return $validators;
                        },
-                       'parser-factory-callback' => function( ParserOptions 
$options ) {
+                       'parser-factory-callback' => function ( ParserOptions 
$options ) {
                                $repo = WikibaseRepo::getDefaultInstance();
                                $normalizer = new 
WikibaseStringValueNormalizer( $repo->getStringNormalizer() );
                                return new StringParser( $normalizer );
                        },
-                       'formatter-factory-callback' => function( $format, 
FormatterOptions $options ) {
+                       'formatter-factory-callback' => function ( $format, 
FormatterOptions $options ) {
                                global $wgOut;
                                $wgOut->addModuleStyles( [ 'ext.math.styles' ] 
);
                                return new MathFormatter( $format );
@@ -68,7 +68,7 @@
 
                $dataTypeDefinitions['PT:math'] = [
                        'value-type'                 => 'string',
-                       'formatter-factory-callback' => function( $format, 
FormatterOptions $options ) {
+                       'formatter-factory-callback' => function ( $format, 
FormatterOptions $options ) {
                                global $wgOut;
                                $wgOut->addModuleStyles( [ 'ext.math.styles' ] 
);
                                return new MathFormatter( $format );
diff --git a/SpecialMathShowImage.php b/SpecialMathShowImage.php
index 060e922..771ae93 100644
--- a/SpecialMathShowImage.php
+++ b/SpecialMathShowImage.php
@@ -60,7 +60,7 @@
                        $this->setHeaders( false );
                        echo $this->printSvgError( 'No Inputhash specified' );
                } else {
-                       if ( $tex === '' && $asciimath === '' ){
+                       if ( $tex === '' && $asciimath === '' ) {
                                switch ( $this->mode ) {
                                        case 'png':
                                                $this->renderer = 
MathTexvc::newFromMd5( $hash );
@@ -113,9 +113,9 @@
                        }
                        $this->setHeaders( $success );
                        echo $output;
-                       if ( $success ){
+                       if ( $success ) {
                                $this->renderer->writeCache();
-                       }
+   }
                }
        }
 
diff --git a/SpecialMathStatus.php b/SpecialMathStatus.php
index 53480d3..16386b1 100644
--- a/SpecialMathStatus.php
+++ b/SpecialMathStatus.php
@@ -35,7 +35,7 @@
                $enabledMathModes = MathHooks::getMathNames();
                $out->addWikiMsg( 'math-status-introduction', count( 
$enabledMathModes ) );
 
-               foreach ( $enabledMathModes as $modeNr => $modeName ){
+               foreach ( $enabledMathModes as $modeNr => $modeName ) {
                        $out->addWikiText( "=== $modeName ===" );
                        switch ( $modeNr ) {
                                case 'mathml':
@@ -146,7 +146,7 @@
        }
 
        private function assertTrue( $expression, $message = '' ) {
-               if ( $expression ){
+               if ( $expression ) {
                        $this->getOutput()->addWikiMsgArray( 
'math-test-success', $message );
                        return true;
                } else {
@@ -163,7 +163,7 @@
 
        private function assertEquals( $expected, $real, $message = '' ) {
                if ( is_array( $expected ) ) {
-                       foreach ( $expected as $alternative ){
+                       foreach ( $expected as $alternative ) {
                                if ( $alternative === $real ) {
                                        $this->getOutput()->addWikiMsgArray( 
'math-test-success', $message );
                                        return true;
diff --git a/composer.json b/composer.json
index 7a7cc76..fea45d1 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
 {
        "require-dev": {
                "jakub-onderka/php-parallel-lint": "0.9.2",
-               "mediawiki/mediawiki-codesniffer": "0.7.2",
+               "mediawiki/mediawiki-codesniffer": "0.9.0",
                "jakub-onderka/php-console-highlighter": "0.3.2"
        },
        "scripts": {
diff --git a/maintenance/MathGenerateTests.php 
b/maintenance/MathGenerateTests.php
index 6fc0577..bf8b0d9 100644
--- a/maintenance/MathGenerateTests.php
+++ b/maintenance/MathGenerateTests.php
@@ -21,8 +21,7 @@
 
 require_once __DIR__ . '/../../../maintenance/Maintenance.php';
 
-class MathGenerateTests extends Maintenance
-{
+class MathGenerateTests extends Maintenance {
        const REFERENCE_PAGE = 'mediawikiwiki:Extension:Math/CoverageTest';
 
        public function __construct() {
@@ -35,7 +34,6 @@
                );
                $this->addOption( 'length', "If set the only n equations were 
processed", false, true, "l" );
                $this->addOption( 'user', "User with rights to view the page", 
false, true, "u" );
-
        }
 
        private static function getMathTagsFromPage( $titleString ) {
diff --git a/phpcs.xml b/phpcs.xml
index d81a292..811d29e 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,8 +1,19 @@
 <?xml version="1.0"?>
 <ruleset>
-       <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+       <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
+               <exclude 
name="MediaWiki.Commenting.FunctionComment.DuplicateReturn" />
+               <exclude 
name="MediaWiki.Commenting.FunctionComment.MissingParamComment" />
+               <exclude 
name="MediaWiki.Commenting.FunctionComment.MissingParamName" />
+               <exclude 
name="MediaWiki.Commenting.FunctionComment.MissingParamTag" />
+               <exclude 
name="MediaWiki.Commenting.FunctionComment.MissingReturn" />
+               <exclude 
name="MediaWiki.Commenting.FunctionComment.ParamNameNoMatch" />
+               <exclude name="MediaWiki.Commenting.FunctionComment.WrongStyle" 
/>
+               <exclude name="MediaWiki.FunctionComment.Missing.Protected" />
+               <exclude name="MediaWiki.FunctionComment.Missing.Public" />
+               <exclude 
name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
+       </rule>
        <file>.</file>
-       <arg name="extensions" value="php,php5,inc"/>
-       <arg name="encoding" value="utf8"/>
+       <arg name="extensions" value="php,php5,inc" />
+       <arg name="encoding" value="utf8" />
        <exclude-pattern>vendor</exclude-pattern>
 </ruleset>
diff --git a/tests/MathDatabaseTest.php b/tests/MathDatabaseTest.php
index 5e521f7..7e55f7c 100644
--- a/tests/MathDatabaseTest.php
+++ b/tests/MathDatabaseTest.php
@@ -118,6 +118,5 @@
                $this->assertFalse( $this->renderer->writeCache() );
                // as a result no entry can be found in the database.
                $this->assertFalse( $this->renderer->readFromDatabase() );
-
        }
 }
diff --git a/tests/MathHooksTest.php b/tests/MathHooksTest.php
index eb52538..516652c 100644
--- a/tests/MathHooksTest.php
+++ b/tests/MathHooksTest.php
@@ -35,7 +35,7 @@
                        'mathml'              => 'mathml',
                        'latexml'             => 'latexml',
                ];
-               foreach ( $testCases as $input => $expected ){
+               foreach ( $testCases as $input => $expected ) {
                        $real = MathHooks::mathModeToString( $input, $default );
                        $this->assertEquals( $expected, $real, "Conversion math 
mode $input -> $expected" );
                }
@@ -54,7 +54,7 @@
                        'display'                           => 'display',
                        'inline'                            => 'inline',
                ];
-               foreach ( $testCases as $input => $expected ){
+               foreach ( $testCases as $input => $expected ) {
                        $real = MathHooks::mathStyleToString( $input, $default 
);
                        $this->assertEquals( $expected, $real, "Conversion in 
math style" );
                }
@@ -76,7 +76,7 @@
                        false                   => 'always'
                ];
 
-               foreach ( $testCases as $input => $expected ){
+               foreach ( $testCases as $input => $expected ) {
                        $real = MathHooks::mathCheckToString( $input, $default 
);
                        $this->assertEquals( $expected, $real, "Conversion in 
math check method" );
                }
@@ -92,7 +92,7 @@
                        'invalid'=> $default
                ];
 
-               foreach ( $testCases as $input => $expected ){
+               foreach ( $testCases as $input => $expected ) {
                        $real = MathHooks::mathModeToHashKey( $input, $default 
);
                        $this->assertEquals( $expected, $real, "Conversion to 
hash key" );
                }
diff --git a/tests/MathInputCheckRestbaseTest.php 
b/tests/MathInputCheckRestbaseTest.php
index dca32e0..4e565cb 100644
--- a/tests/MathInputCheckRestbaseTest.php
+++ b/tests/MathInputCheckRestbaseTest.php
@@ -27,7 +27,6 @@
                }
                $this->BadObject = new MathInputCheckRestbase( 
'\newcommand{\text{do evil things}}' );
                $this->GoodObject = new MathInputCheckRestbase( 
'\sin\left(\frac12x\right)' );
-
        }
 
        /**
diff --git a/tests/MathInputCheckTest.php b/tests/MathInputCheckTest.php
index 6d9a3f3..cb7781d 100644
--- a/tests/MathInputCheckTest.php
+++ b/tests/MathInputCheckTest.php
@@ -7,8 +7,7 @@
  *
  * @licence GNU GPL v2+
  */
-class MathInputCheckTest extends MediaWikiTestCase
-{
+class MathInputCheckTest extends MediaWikiTestCase {
        /**
         * @covers MathInputCheck::isValid
         */
diff --git a/tests/MathRendererTest.php b/tests/MathRendererTest.php
index 9ce8f40..f0d8845 100644
--- a/tests/MathRendererTest.php
+++ b/tests/MathRendererTest.php
@@ -85,7 +85,6 @@
                                ] )->disableOriginalConstructor()->getMock();
                $renderer->setPurge();
                $this->assertEquals( $renderer->isPurge(), true, "Test purge." 
);
-
        }
 
        public function testDisableCheckingAlways() {
@@ -104,7 +103,6 @@
                $this->assertEquals( $renderer->checkTeX(), true );
                // now setTex sould not be called again
                $this->assertEquals( $renderer->checkTeX(), true );
-
        }
 
        public function testDisableCheckingNever() {

-- 
To view, visit https://gerrit.wikimedia.org/r/360210
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I46c900a5652a6560d18be6cd67badc37ed7f8d97
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to