[MediaWiki-commits] [Gerrit] mediawiki...CodeMirror[master]: Add phpcs and make pass
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/363887 ) Change subject: Add phpcs and make pass .. Add phpcs and make pass Change-Id: Ibddce88a08cdd59f6f7b60a297e37952c2f01b62 --- M CodeMirror.hooks.php M CodeMirror.i18n.php M composer.json A phpcs.xml 4 files changed, 42 insertions(+), 18 deletions(-) Approvals: MaxSem: Looks good to me, approved jenkins-bot: Verified diff --git a/CodeMirror.hooks.php b/CodeMirror.hooks.php index 34364fa..cf735f5 100644 --- a/CodeMirror.hooks.php +++ b/CodeMirror.hooks.php @@ -23,7 +23,8 @@ in_array( Action::getActionName( $context ), [ 'edit', 'submit' ] ) && $wgCodeMirrorBetaFeature && ExtensionRegistry::getInstance()->isLoaded( 'BetaFeatures' ) && - BetaFeatures::isFeatureEnabled( $context->getUser(), 'codemirror-syntax-highlight' ); + BetaFeatures::isFeatureEnabled( + $context->getUser(), 'codemirror-syntax-highlight' ); } } @@ -35,7 +36,6 @@ * removed * @deprecated since version 4.0.0 * @todo Remove usage in MobileFrontend and this function some time later -* @param IContextSource $context * @return array */ public static function getGlobalVariables() { @@ -58,6 +58,7 @@ // if we already created these variable array, return it if ( !$config ) { $contObj = $context->getLanguage(); + $registry = ExtensionRegistry::getInstance(); if ( !isset( $wgParser->mFunctionSynonyms ) ) { $wgParser->initialiseVariables(); @@ -66,8 +67,8 @@ // initialize configuration $config = [ - 'pluginModules' => ExtensionRegistry::getInstance()->getAttribute( 'CodeMirrorPluginModules' ), - 'tagModes' => ExtensionRegistry::getInstance()->getAttribute( 'CodeMirrorTagModes' ), + 'pluginModules' => $registry->getAttribute( 'CodeMirrorPluginModules' ), + 'tagModes' => $registry->getAttribute( 'CodeMirrorTagModes' ), 'tags' => array_fill_keys( $wgParser->getTags(), true ), 'doubleUnderscore' => [ [], [] ], 'functionSynonyms' => $wgParser->mFunctionSynonyms, @@ -80,7 +81,8 @@ if ( isset( $mw[$name] ) ) { $caseSensitive = array_shift( $mw[$name] ) == 0 ? 0 : 1; foreach ( $mw[$name] as $n ) { - $config['doubleUnderscore'][$caseSensitive][ $caseSensitive ? $n : $contObj->lc( $n ) ] = $name; + $n = $caseSensitive ? $n : $contObj->lc( $n ); + $config['doubleUnderscore'][$caseSensitive][$n] = $name; } } else { $config['doubleUnderscore'][0][] = $name; @@ -91,7 +93,8 @@ if ( isset( $mw[$name] ) ) { $caseSensitive = array_shift( $mw[$name] ) == 0 ? 0 : 1; foreach ( $mw[$name] as $n ) { - $config['functionSynonyms'][$caseSensitive][ $caseSensitive ? $n : $contObj->lc( $n ) ] = $name; + $n = $caseSensitive ? $n : $contObj->lc( $n ); + $config['functionSynonyms'][$caseSensitive][$n] = $name; } } } @@ -112,7 +115,7 @@ public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $out ) { $context = $out->getContext(); // add CodeMirror vars on edit pages, or if VE is installed - if ( self::isCodeMirrorEnabled( $context ) || class_exists( 'VisualEditorHooks' ) ) { + if ( self::isCodeMirrorEnabled( $context ) || class_exists( 'VisualEditorHooks' ) ) { $vars['extCodeMirrorConfig'] = self::getConfiguraton( $context ); } } @@ -140,8 +143,8 @@ * @param array $defaultPreferences */ public static function onGetPreferences( User $user, &$defaultPreferences ) { - // CodeMirror
[MediaWiki-commits] [Gerrit] mediawiki...CodeMirror[master]: Add phpcs and make pass
Umherirrender has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/363887 ) Change subject: Add phpcs and make pass .. Add phpcs and make pass Change-Id: Ibddce88a08cdd59f6f7b60a297e37952c2f01b62 --- M CodeMirror.hooks.php M CodeMirror.i18n.php M composer.json A phpcs.xml 4 files changed, 42 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CodeMirror refs/changes/87/363887/1 diff --git a/CodeMirror.hooks.php b/CodeMirror.hooks.php index 34364fa..cf735f5 100644 --- a/CodeMirror.hooks.php +++ b/CodeMirror.hooks.php @@ -23,7 +23,8 @@ in_array( Action::getActionName( $context ), [ 'edit', 'submit' ] ) && $wgCodeMirrorBetaFeature && ExtensionRegistry::getInstance()->isLoaded( 'BetaFeatures' ) && - BetaFeatures::isFeatureEnabled( $context->getUser(), 'codemirror-syntax-highlight' ); + BetaFeatures::isFeatureEnabled( + $context->getUser(), 'codemirror-syntax-highlight' ); } } @@ -35,7 +36,6 @@ * removed * @deprecated since version 4.0.0 * @todo Remove usage in MobileFrontend and this function some time later -* @param IContextSource $context * @return array */ public static function getGlobalVariables() { @@ -58,6 +58,7 @@ // if we already created these variable array, return it if ( !$config ) { $contObj = $context->getLanguage(); + $registry = ExtensionRegistry::getInstance(); if ( !isset( $wgParser->mFunctionSynonyms ) ) { $wgParser->initialiseVariables(); @@ -66,8 +67,8 @@ // initialize configuration $config = [ - 'pluginModules' => ExtensionRegistry::getInstance()->getAttribute( 'CodeMirrorPluginModules' ), - 'tagModes' => ExtensionRegistry::getInstance()->getAttribute( 'CodeMirrorTagModes' ), + 'pluginModules' => $registry->getAttribute( 'CodeMirrorPluginModules' ), + 'tagModes' => $registry->getAttribute( 'CodeMirrorTagModes' ), 'tags' => array_fill_keys( $wgParser->getTags(), true ), 'doubleUnderscore' => [ [], [] ], 'functionSynonyms' => $wgParser->mFunctionSynonyms, @@ -80,7 +81,8 @@ if ( isset( $mw[$name] ) ) { $caseSensitive = array_shift( $mw[$name] ) == 0 ? 0 : 1; foreach ( $mw[$name] as $n ) { - $config['doubleUnderscore'][$caseSensitive][ $caseSensitive ? $n : $contObj->lc( $n ) ] = $name; + $n = $caseSensitive ? $n : $contObj->lc( $n ); + $config['doubleUnderscore'][$caseSensitive][$n] = $name; } } else { $config['doubleUnderscore'][0][] = $name; @@ -91,7 +93,8 @@ if ( isset( $mw[$name] ) ) { $caseSensitive = array_shift( $mw[$name] ) == 0 ? 0 : 1; foreach ( $mw[$name] as $n ) { - $config['functionSynonyms'][$caseSensitive][ $caseSensitive ? $n : $contObj->lc( $n ) ] = $name; + $n = $caseSensitive ? $n : $contObj->lc( $n ); + $config['functionSynonyms'][$caseSensitive][$n] = $name; } } } @@ -112,7 +115,7 @@ public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $out ) { $context = $out->getContext(); // add CodeMirror vars on edit pages, or if VE is installed - if ( self::isCodeMirrorEnabled( $context ) || class_exists( 'VisualEditorHooks' ) ) { + if ( self::isCodeMirrorEnabled( $context ) || class_exists( 'VisualEditorHooks' ) ) { $vars['extCodeMirrorConfig'] = self::getConfiguraton( $context ); } } @@ -140,8 +143,8 @@ * @param array $defaultPreferences */ public static function onGetPreferences( User $user, &$defaultPreferences ) { -