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
This commit is contained in:
Kunal Mehta 2017-06-20 00:11:57 -07:00 committed by Esanders
parent 08b6259bb4
commit fbd17b4fef
21 changed files with 57 additions and 58 deletions

View File

@ -311,7 +311,6 @@ class MathHooks {
* @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,7 +368,7 @@ class MathHooks {
*/
public static function onParserAfterTidy( &$parser, &$text ) {
$rbis = [];
foreach ( self::$tags as $key => $tag ){
foreach ( self::$tags as $key => $tag ) {
/** @var MathRenderer $renderer */
$renderer = $tag[0];
$rbi = new MathRestbaseInterface( $renderer->getTex(), $renderer->getInputType() );
@ -377,7 +376,7 @@ class MathHooks {
$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 ) .

View File

@ -5,14 +5,14 @@ use ValueFormatters\Exceptions\MismatchingDataValueTypeException;
use ValueFormatters\ValueFormatter;
use Wikibase\Lib\SnakFormatter;
/*
* 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
* Formats can look like this: "text/html; disposition=widget"
* or just "text/plain"
*/
/**
* 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
* Formats can look like this: "text/html; disposition=widget"
* or just "text/plain"
*/
class MathFormatter implements ValueFormatter {

View File

@ -39,7 +39,7 @@ class MathInputCheckRestbase extends MathInputCheck {
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 @@ class MathInputCheckRestbase extends MathInputCheck {
*/
public function getError() {
$err = $this->restbaseInterface->getError();
if ( $err === null ){
if ( $err === null ) {
return null;
}
return $this->errorObjectToHtml( $err );

View File

@ -51,7 +51,7 @@ class MathInputCheckTexvc extends MathInputCheck {
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 @@ class MathInputCheckTexvc extends MathInputCheck {
*/
public function doValidCheck() {
global $wgMathTexvcCheckExecutable;
if ( $wgMathTexvcCheckExecutable === false ){
if ( $wgMathTexvcCheckExecutable === false ) {
$texvcCheckExecutable = __DIR__ . '/texvccheck/texvccheck';
} else {
$texvcCheckExecutable = $wgMathTexvcCheckExecutable;

View File

@ -106,7 +106,7 @@ class MathLaTeXML extends MathMathML {
$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 @@ class MathLaTeXML extends MathMathML {
return 'mathlatexml';
}
}

View File

@ -34,7 +34,7 @@ class MathMathML extends MathRenderer {
$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 @@ class MathMathML extends MathRenderer {
$this->userInputTex = $rpage->math_input;
}
parent::initializeFromDatabaseRow( $rpage );
}
/**

View File

@ -553,11 +553,11 @@ abstract class MathRenderer {
* @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 @@ abstract class MathRenderer {
// 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 @@ abstract class MathRenderer {
*/
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 );

View File

@ -85,7 +85,7 @@ class MathRestbaseInterface {
* @throws MWException
*/
public function getMathML() {
if ( !$this->mml ){
if ( !$this->mml ) {
$this->mml = $this->getContent( 'mml' );
}
return $this->mml;
@ -132,7 +132,6 @@ class MathRestbaseInterface {
] );
}
return $response;
}
/**
@ -259,7 +258,7 @@ class MathRestbaseInterface {
// 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 @@ class MathRestbaseInterface {
$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 @@ class MathRestbaseInterface {
$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;

View File

@ -144,7 +144,7 @@ class MathTexvc extends MathRenderer {
'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 @@ class MathTexvc extends MathRenderer {
]
)
);
}
/**
@ -178,7 +177,7 @@ class MathTexvc extends MathRenderer {
*/
public function callTexvc() {
global $wgTexvc, $wgTexvcBackgroundColor, $wgHooks;
if ( $wgTexvc === false ){
if ( $wgTexvc === false ) {
$texvc = __DIR__ . '/math/texvc';
} else {
$texvc = $wgTexvc;

View File

@ -27,7 +27,7 @@ class MathValidator implements ValueValidator {
$tex = $value->getValue();
$checker = new MathInputCheckRestbase( $tex );
if ( $checker->isValid() ) {
if ( $checker->isValid() ) {
return Result::newSuccess();
}

View File

@ -23,7 +23,7 @@ class MathWikidataHook {
$dataTypeDefinitions['PT:math'] = [
'value-type' => 'string',
'validator-factory-callback' => function() {
'validator-factory-callback' => function () {
// load validator builders
$factory = WikibaseRepo::getDefaultValidatorBuilders();
@ -34,12 +34,12 @@ class MathWikidataHook {
$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 @@ class MathWikidataHook {
$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 );

View File

@ -60,7 +60,7 @@ class SpecialMathShowImage extends SpecialPage {
$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,7 +113,7 @@ class SpecialMathShowImage extends SpecialPage {
}
$this->setHeaders( $success );
echo $output;
if ( $success ){
if ( $success ) {
$this->renderer->writeCache();
}
}

View File

@ -35,7 +35,7 @@ class SpecialMathStatus extends SpecialPage {
$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 @@ class SpecialMathStatus extends SpecialPage {
}
private function assertTrue( $expression, $message = '' ) {
if ( $expression ){
if ( $expression ) {
$this->getOutput()->addWikiMsgArray( 'math-test-success', $message );
return true;
} else {
@ -163,7 +163,7 @@ class SpecialMathStatus extends SpecialPage {
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;

View File

@ -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": {

View File

@ -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 @@ class MathGenerateTests extends Maintenance
);
$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 ) {

View File

@ -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>

View File

@ -118,6 +118,5 @@ class MathDatabaseTest extends MediaWikiTestCase {
$this->assertFalse( $this->renderer->writeCache() );
// as a result no entry can be found in the database.
$this->assertFalse( $this->renderer->readFromDatabase() );
}
}

View File

@ -35,7 +35,7 @@ class MathHooksTest extends MediaWikiTestCase {
'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 @@ class MathHooksTest extends MediaWikiTestCase {
'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 @@ class MathHooksTest extends MediaWikiTestCase {
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 @@ class MathHooksTest extends MediaWikiTestCase {
'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" );
}

View File

@ -27,7 +27,6 @@ class MathInputCheckRestbaseTest extends MediaWikiTestCase {
}
$this->BadObject = new MathInputCheckRestbase( '\newcommand{\text{do evil things}}' );
$this->GoodObject = new MathInputCheckRestbase( '\sin\left(\frac12x\right)' );
}
/**

View File

@ -7,8 +7,7 @@
*
* @licence GNU GPL v2+
*/
class MathInputCheckTest extends MediaWikiTestCase
{
class MathInputCheckTest extends MediaWikiTestCase {
/**
* @covers MathInputCheck::isValid
*/

View File

@ -85,7 +85,6 @@ class MathRendererTest extends MediaWikiTestCase {
] )->disableOriginalConstructor()->getMock();
$renderer->setPurge();
$this->assertEquals( $renderer->isPurge(), true, "Test purge." );
}
public function testDisableCheckingAlways() {
@ -104,7 +103,6 @@ class MathRendererTest extends MediaWikiTestCase {
$this->assertEquals( $renderer->checkTeX(), true );
// now setTex sould not be called again
$this->assertEquals( $renderer->checkTeX(), true );
}
public function testDisableCheckingNever() {