jenkins-bot has submitted this change and it was merged. Change subject: Add php code sniffer ......................................................................
Add php code sniffer Requires https://gerrit.wikimedia.org/r/#/c/224819/ Change-Id: I3ba782e220b3f10e2b8008800459dabc0d647f16 --- M CollapsibleVector.hooks.php M CollapsibleVector.php M composer.json M switchExperimentPrefs.php 4 files changed, 37 insertions(+), 29 deletions(-) Approvals: Paladox: Looks good to me, but someone else must approve Hashar: Looks good to me, approved jenkins-bot: Verified diff --git a/CollapsibleVector.hooks.php b/CollapsibleVector.hooks.php index 71031ae..fed1479 100644 --- a/CollapsibleVector.hooks.php +++ b/CollapsibleVector.hooks.php @@ -1,15 +1,15 @@ <?php /** * Hooks for CollapsibleVector extension - * + * * @file * @ingroup Extensions */ class CollapsibleVectorHooks { - + /* Protected Static Members */ - + protected static $features = array( 'collapsiblenav' => array( 'preferences' => array( @@ -70,12 +70,15 @@ */ public static function isEnabled( $name ) { global $wgCollapsibleVectorFeatures, $wgUser; - + // Features with global set to true are always enabled - if ( !isset( $wgCollapsibleVectorFeatures[$name] ) || $wgCollapsibleVectorFeatures[$name]['global'] ) { + if ( + !isset( $wgCollapsibleVectorFeatures[$name] ) || $wgCollapsibleVectorFeatures[$name]['global'] + ) { return true; } - // Features with user preference control can have any number of preferences to be specific values to be enabled + // Features with user preference control can have any number of preferences + // to be specific values to be enabled if ( $wgCollapsibleVectorFeatures[$name]['user'] ) { if ( isset( self::$features[$name]['requirements'] ) ) { foreach ( self::$features[$name]['requirements'] as $requirement => $value ) { @@ -87,17 +90,18 @@ } return true; } - // Features controlled by $wgCollapsibleVectorFeatures with both global and user set to false are awlways disabled + // Features controlled by $wgCollapsibleVectorFeatures with both global and user set to false + // are awlways disabled return false; } - + /* Static Methods */ - + /** * BeforePageDisplay hook - * + * * Adds the modules to the page - * + * * @param $out OutputPage output page * @param $skin Skin current skin */ @@ -112,18 +116,18 @@ } return true; } - + /** * GetPreferences hook - * + * * Adds Vector-releated items to the preferences - * + * * @param $user User current user * @param $defaultPreferences array list of default user preference controls */ public static function getPreferences( $user, &$defaultPreferences ) { global $wgCollapsibleVectorFeatures; - + foreach ( self::$features as $name => $feature ) { if ( isset( $feature['preferences'] ) && @@ -136,15 +140,15 @@ } return true; } - + /** * ResourceLoaderGetConfigVars hook - * + * * Adds enabled/disabled switches for Vector modules */ public static function resourceLoaderGetConfigVars( &$vars ) { global $wgCollapsibleVectorFeatures; - + $configurations = array(); foreach ( self::$features as $name => $feature ) { if ( @@ -152,8 +156,8 @@ ( !isset( $wgCollapsibleVectorFeatures[$name] ) || self::isEnabled( $name ) ) ) { foreach ( $feature['configurations'] as $configuration ) { - global $$configuration; - $configurations[$configuration] = $$configuration; + global $$wgConfiguration; + $configurations[$configuration] = $$wgConfiguration; } } } @@ -173,7 +177,7 @@ foreach ( self::$features as $name => $feature ) { $enabledModules[$name] = self::isEnabled( $name ); } - + $vars['wgCollapsibleVectorEnabledModules'] = $enabledModules; return true; } diff --git a/CollapsibleVector.php b/CollapsibleVector.php index a8cdbcf..6334c39 100644 --- a/CollapsibleVector.php +++ b/CollapsibleVector.php @@ -4,7 +4,8 @@ // Keep i18n globals so mergeMessageFileList.php doesn't break $wgMessagesDirs['CollapsibleVector'] = __DIR__ . '/i18n'; /* wfWarn( - 'Deprecated PHP entry point used for CollapsibleVector extension. Please use wfLoadExtension instead, ' . + 'Deprecated PHP entry point used for CollapsibleVector extension.' . + 'Please use wfLoadExtension instead,' . 'see https://www.mediawiki.org/wiki/Extension_registration for more details.' ); */ return; diff --git a/composer.json b/composer.json index ced73b2..2fac10c 100644 --- a/composer.json +++ b/composer.json @@ -21,11 +21,13 @@ "irc": "irc://irc.freenode.org/mediawiki" }, "require-dev": { - "jakub-onderka/php-parallel-lint": "0.9.*" + "jakub-onderka/php-parallel-lint": "0.9.*", + "mediawiki/mediawiki-codesniffer": "0.3.0" }, "scripts": { "test": [ - "parallel-lint . --exclude vendor" + "parallel-lint . --exclude vendor", + "phpcs -p" ] } } diff --git a/switchExperimentPrefs.php b/switchExperimentPrefs.php index 2e84e37..491c235 100644 --- a/switchExperimentPrefs.php +++ b/switchExperimentPrefs.php @@ -6,14 +6,16 @@ $path = getenv( 'MW_INSTALL_PATH' ); } -require_once( $path . '/maintenance/Maintenance.php' ); +require_once ( $path . '/maintenance/Maintenance.php' ); class SwitchExperimentPrefs extends Maintenance { function __construct() { parent::__construct(); $this->addOption( 'pref', 'Preference to set', true, true ); $this->addOption( 'value', 'Value to set the preference to', true, true ); - $this->mDescription = 'Set a preference for all users that have the collapsiblevector-noexperiments preference enabled.'; + $this->mDescription = ' + Set a preference for all users that have the collapsiblevector-noexperiments preference enabled. + '; } function execute() { @@ -38,8 +40,7 @@ $ids[] = $row->up_user; } $lastUserID = max( $ids ); - - + foreach ( $ids as $id ) { $user = User::newFromId( $id ); if ( !$user->isLoggedIn() ) @@ -58,4 +59,4 @@ } $maintClass = 'SwitchExperimentPrefs'; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once ( RUN_MAINTENANCE_IF_MAIN ); -- To view, visit https://gerrit.wikimedia.org/r/225335 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3ba782e220b3f10e2b8008800459dabc0d647f16 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/CollapsibleVector Gerrit-Branch: master Gerrit-Owner: Paladox <[email protected]> Gerrit-Reviewer: Hashar <[email protected]> Gerrit-Reviewer: Paladox <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
