From ca7a84b5b2c3c8307da29f3c5e296d7c86856ffb Mon Sep 17 00:00:00 2001 From: Jackmcbarn Date: Fri, 26 Jun 2015 12:37:34 -0400 Subject: [PATCH] Fix some PHPCS issues Change-Id: I5a44d07553d45bc01db070c99856b35a3d275bd1 --- Scribunto.magic.php | 2 +- common/Base.php | 6 +++--- common/Common.php | 3 ++- common/Hooks.php | 8 +++++--- engines/LuaCommon/LanguageLibrary.php | 2 +- engines/LuaCommon/LuaCommon.php | 4 ++-- engines/LuaCommon/MessageLibrary.php | 4 ++-- engines/LuaCommon/UstringLibrary.php | 4 ++-- engines/LuaStandalone/LuaStandaloneEngine.php | 2 +- tests/engines/LuaCommon/CommonTest.php | 4 +--- tests/engines/LuaCommon/LuaEngineTestBase.php | 2 +- tests/engines/LuaCommon/LuaInterpreterTest.php | 2 +- tests/engines/LuaCommon/TitleLibraryTest.php | 1 - tests/engines/LuaCommon/UstringLibraryTest.php | 8 ++++---- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Scribunto.magic.php b/Scribunto.magic.php index 6d130494..60409850 100644 --- a/Scribunto.magic.php +++ b/Scribunto.magic.php @@ -128,4 +128,4 @@ $magicWords['zh-hans'] = array( /** Traditional Chinese (中文(繁體)‎) */ $magicWords['zh-hant'] = array( 'invoke' => array( 0, '調動' ), -); \ No newline at end of file +); diff --git a/common/Base.php b/common/Base.php index d1f014fd..9fa69077 100644 --- a/common/Base.php +++ b/common/Base.php @@ -248,7 +248,7 @@ abstract class ScribuntoEngineBase { * @deprecated * @return string */ - public function getLimitReport(){ + public function getLimitReport() { return ''; } @@ -258,7 +258,7 @@ abstract class ScribuntoEngineBase { * @param $output ParserOutput ParserOutput object in which to add limit data * @return null */ - public function reportLimitData( ParserOutput $output ){ + public function reportLimitData( ParserOutput $output ) { } /** @@ -271,7 +271,7 @@ abstract class ScribuntoEngineBase { * @param $localize bool * @return bool */ - public function formatLimitData( $key, &$value, &$report, $isHTML, $localize ){ + public function formatLimitData( $key, &$value, &$report, $isHTML, $localize ) { return true; } } diff --git a/common/Common.php b/common/Common.php index afaec7e4..2e053923 100644 --- a/common/Common.php +++ b/common/Common.php @@ -20,7 +20,8 @@ class Scribunto { /** * Create a new engine object with default parameters * - * @param $extraOptions array Extra options to pass to the constructor, in addition to the configured options + * @param $extraOptions array Extra options to pass to the constructor, + * in addition to the configured options * @throws MWException * @return ScribuntoEngineBase */ diff --git a/common/Hooks.php b/common/Hooks.php index f45d9fdf..da1f6be2 100644 --- a/common/Hooks.php +++ b/common/Hooks.php @@ -94,11 +94,13 @@ class ScribuntoHooks { $engine = Scribunto::getParserEngine( $parser ); $title = Title::makeTitleSafe( NS_MODULE, $moduleName ); if ( !$title || Scribunto::isDocPage( $title ) ) { - throw new ScribuntoException( 'scribunto-common-nosuchmodule', array( 'args' => array( $moduleName ) ) ); + throw new ScribuntoException( 'scribunto-common-nosuchmodule', + array( 'args' => array( $moduleName ) ) ); } $module = $engine->fetchModuleFromParser( $title ); if ( !$module ) { - throw new ScribuntoException( 'scribunto-common-nosuchmodule', array( 'args' => array( $moduleName ) ) ); + throw new ScribuntoException( 'scribunto-common-nosuchmodule', + array( 'args' => array( $moduleName ) ) ); } $functionName = trim( $frame->expand( $args[1] ) ); @@ -112,7 +114,7 @@ class ScribuntoHooks { $childFrame = $frame->newChild( $args, $title, $bits['index'] === '' ? 0 : 1 ); $result = $module->invoke( $functionName, $childFrame ); return UtfNormal::cleanUp( strval( $result ) ); - } catch( ScribuntoException $e ) { + } catch ( ScribuntoException $e ) { $trace = $e->getScriptTraceHtml( array( 'msgOptions' => array( 'content' ) ) ); $html = Html::element( 'p', array(), $e->getMessage() ); if ( $trace !== false ) { diff --git a/engines/LuaCommon/LanguageLibrary.php b/engines/LuaCommon/LanguageLibrary.php index 31e49ae6..232a2536 100644 --- a/engines/LuaCommon/LanguageLibrary.php +++ b/engines/LuaCommon/LanguageLibrary.php @@ -94,7 +94,7 @@ class Scribunto_LuaLanguageLibrary extends Scribunto_LuaLibraryBase { } function getFallbacksFor( $code ) { - $this->checkType( 'getFallbacksFor', 1, $code , 'string' ); + $this->checkType( 'getFallbacksFor', 1, $code, 'string' ); $ret = Language::getFallbacksFor( $code ); // Make 1-based if ( count( $ret ) ) { diff --git a/engines/LuaCommon/LuaCommon.php b/engines/LuaCommon/LuaCommon.php index c7316a53..08e94c3d 100644 --- a/engines/LuaCommon/LuaCommon.php +++ b/engines/LuaCommon/LuaCommon.php @@ -187,7 +187,7 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase { * * @return array */ - public abstract function getPerformanceCharacteristics(); + abstract public function getPerformanceCharacteristics(); /** * Get the current interpreter object @@ -524,7 +524,7 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase { */ protected function getFrameById( $frameId ) { if ( $frameId === 'empty' ) { - return $this->getParser()->getPreprocessor()->newFrame(); + return $this->getParser()->getPreprocessor()->newFrame(); } elseif ( isset( $this->currentFrames[$frameId] ) ) { return $this->currentFrames[$frameId]; } else { diff --git a/engines/LuaCommon/MessageLibrary.php b/engines/LuaCommon/MessageLibrary.php index 0ef9338e..ba426e6e 100644 --- a/engines/LuaCommon/MessageLibrary.php +++ b/engines/LuaCommon/MessageLibrary.php @@ -38,7 +38,7 @@ class Scribunto_LuaMessageLibrary extends Scribunto_LuaLibraryBase { try { $msg = $this->makeMessage( $data, true ); return array( $msg->plain() ); - } catch( MWException $ex ) { + } catch ( MWException $ex ) { throw new Scribunto_LuaError( "msg:plain() failed (" . $ex->getMessage() . ")" ); } } @@ -51,7 +51,7 @@ class Scribunto_LuaMessageLibrary extends Scribunto_LuaLibraryBase { try { $msg = $this->makeMessage( $data, false ); return array( call_user_func( array( $msg, $what ) ) ); - } catch( MWException $ex ) { + } catch ( MWException $ex ) { throw new Scribunto_LuaError( "msg:$what() failed (" . $ex->getMessage() . ")" ); } } diff --git a/engines/LuaCommon/UstringLibrary.php b/engines/LuaCommon/UstringLibrary.php index 4862fde2..8bf93aaa 100644 --- a/engines/LuaCommon/UstringLibrary.php +++ b/engines/LuaCommon/UstringLibrary.php @@ -437,7 +437,7 @@ class Scribunto_LuaUstringLibrary extends Scribunto_LuaLibraryBase { return $this->patternRegexCache->get( $cacheKey ); } - private function bracketedCharSetToRegex( $pat, $i, $len, $brcharsets ){ + private function bracketedCharSetToRegex( $pat, $i, $len, $brcharsets ) { $ii = $i + 1; $re = '['; $i++; @@ -445,7 +445,7 @@ class Scribunto_LuaUstringLibrary extends Scribunto_LuaLibraryBase { $re .= '^'; $i++; } - for ( ; $i < $len && $pat[$i] !== ']'; $i++ ) { + for (; $i < $len && $pat[$i] !== ']'; $i++ ) { if ( $pat[$i] === '%' ) { $i++; if ( $i >= $len ) { diff --git a/engines/LuaStandalone/LuaStandaloneEngine.php b/engines/LuaStandalone/LuaStandaloneEngine.php index ccf2be66..4202d25e 100644 --- a/engines/LuaStandalone/LuaStandaloneEngine.php +++ b/engines/LuaStandalone/LuaStandaloneEngine.php @@ -343,7 +343,7 @@ class Scribunto_LuaStandaloneInterpreter extends Scribunto_LuaInterpreter { } public function callFunction( $func /* ... */ ) { - if ( !($func instanceof Scribunto_LuaStandaloneInterpreterFunction) ) { + if ( !( $func instanceof Scribunto_LuaStandaloneInterpreterFunction ) ) { throw new MWException( __METHOD__.': invalid function type' ); } if ( $func->interpreterId !== $this->id ) { diff --git a/tests/engines/LuaCommon/CommonTest.php b/tests/engines/LuaCommon/CommonTest.php index 03144c11..e9fd0134 100644 --- a/tests/engines/LuaCommon/CommonTest.php +++ b/tests/engines/LuaCommon/CommonTest.php @@ -273,7 +273,7 @@ class Scribunto_LuaCommonTests extends Scribunto_LuaEngineTestBase { $loadcount = 0; $interpreter->callFunction( $interpreter->loadString( 'mw.markLoaded = ...', 'fortest' ), - $interpreter->wrapPHPFunction( function () use (&$loadcount) { + $interpreter->wrapPHPFunction( function () use ( &$loadcount ) { $loadcount++; } ) ); @@ -343,8 +343,6 @@ class Scribunto_LuaCommonTests extends Scribunto_LuaEngineTestBase { } public function testCallParserFunction() { - global $wgContLang; - $engine = $this->getEngine(); $parser = $engine->getParser(); diff --git a/tests/engines/LuaCommon/LuaEngineTestBase.php b/tests/engines/LuaCommon/LuaEngineTestBase.php index 4d7817ce..a7552a64 100644 --- a/tests/engines/LuaCommon/LuaEngineTestBase.php +++ b/tests/engines/LuaCommon/LuaEngineTestBase.php @@ -189,7 +189,7 @@ abstract class Scribunto_LuaEngineTestBase extends MediaWikiLangTestCase { } public function templateCallback( $title, $parser ) { - if ( isset($this->extraModules[$title->getFullText()]) ) { + if ( isset( $this->extraModules[$title->getFullText()] ) ) { return array( 'text' => $this->extraModules[$title->getFullText()], 'finalTitle' => $title, diff --git a/tests/engines/LuaCommon/LuaInterpreterTest.php b/tests/engines/LuaCommon/LuaInterpreterTest.php index 1c152898..d45ab25e 100644 --- a/tests/engines/LuaCommon/LuaInterpreterTest.php +++ b/tests/engines/LuaCommon/LuaInterpreterTest.php @@ -1,7 +1,7 @@ mCascadeSources = array(); $title->mCascadingRestrictions = array(); - // Note this depends on every iteration of the data provider running with a clean parser $this->getEngine()->getParser()->getOptions()->setExpensiveParserFunctionLimit( 10 ); diff --git a/tests/engines/LuaCommon/UstringLibraryTest.php b/tests/engines/LuaCommon/UstringLibraryTest.php index 5a71a013..3e24a5d4 100644 --- a/tests/engines/LuaCommon/UstringLibraryTest.php +++ b/tests/engines/LuaCommon/UstringLibraryTest.php @@ -92,7 +92,7 @@ class UstringLibraryNormalizationTestProvider extends Scribunto_LuaDataProvider public function rewind() { if ( $this->file ) { - rewind($this->file); + rewind( $this->file ); } $this->key = 0; $this->next(); @@ -100,9 +100,9 @@ class UstringLibraryNormalizationTestProvider extends Scribunto_LuaDataProvider public function valid() { if ( $this->file ) { - $v=!feof($this->file); + $v = !feof( $this->file ); } else { - $v=$this->key < count( self::$static ); + $v = $this->key < count( self::$static ); } return $v; } @@ -113,7 +113,7 @@ class UstringLibraryNormalizationTestProvider extends Scribunto_LuaDataProvider public function next() { $this->current = array( null, null, null, null, null, null ); - while( $this->valid() ) { + while ( $this->valid() ) { if ( $this->file ) { $line = fgets( $this->file ); } else {