X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FgetConfiguration.php;h=18dcc226da0dd0af75b7f7058baf07281607d137;hb=255d76f2a13a8378ded9f0cf1c2bb172f7f07a5b;hp=1db53f30c9da886dd52b64a8b3fd79389f737421;hpb=c7d3ebf125750a1e4b1601681801e0d761016788;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/getConfiguration.php b/maintenance/getConfiguration.php index 1db53f30c9..18dcc226da 100644 --- a/maintenance/getConfiguration.php +++ b/maintenance/getConfiguration.php @@ -34,26 +34,26 @@ class GetConfiguration extends Maintenance { protected $regex = null; - protected $settings_list = array(); + protected $settings_list = []; /** * List of format output internally supported. * Each item MUST be lower case. */ - protected static $outFormats = array( + protected static $outFormats = [ 'json', 'php', 'serialize', 'vardump', - ); + ]; public function __construct() { parent::__construct(); - $this->mDescription = "Get serialized MediaWiki site configuration"; + $this->addDescription( 'Get serialized MediaWiki site configuration' ); $this->addOption( 'regex', 'regex to filter variables with', false, true ); $this->addOption( 'iregex', 'same as --regex but case insensitive', false, true ); $this->addOption( 'settings', 'Space-separated list of wg* variables', false, true ); - $this->addOption( 'format', join( ', ', self::$outFormats ), false, true ); + $this->addOption( 'format', implode( ', ', self::$outFormats ), false, true ); } protected function validateParamsAndArgs() { @@ -64,7 +64,7 @@ class GetConfiguration extends Maintenance { $validFormat = in_array( $format, self::$outFormats ); if ( !$validFormat ) { - $this->error( "--format set to an unrecognized format", 0 ); + $this->error( "--format set to an unrecognized format" ); $error_out = true; } @@ -87,7 +87,7 @@ class GetConfiguration extends Maintenance { public function finalSetup() { parent::finalSetup(); - $this->regex = $this->getOption( 'regex' ) ? : $this->getOption( 'iregex' ); + $this->regex = $this->getOption( 'regex' ) ?: $this->getOption( 'iregex' ); if ( $this->regex ) { $this->regex = '/' . $this->regex . '/'; if ( $this->hasOption( 'iregex' ) ) { @@ -101,7 +101,7 @@ class GetConfiguration extends Maintenance { foreach ( $this->settings_list as $name ) { if ( !preg_match( '/^wg[A-Z]/', $name ) ) { throw new MWException( "Variable '$name' does start with 'wg'." ); - } elseif ( !isset( $GLOBALS[$name] ) ) { + } elseif ( !array_key_exists( $name, $GLOBALS ) ) { throw new MWException( "Variable '$name' is not set." ); } elseif ( !$this->isAllowedVariable( $GLOBALS[$name] ) ) { throw new MWException( "Variable '$name' includes non-array, non-scalar, items." ); @@ -112,7 +112,7 @@ class GetConfiguration extends Maintenance { public function execute() { // Settings we will display - $res = array(); + $res = []; # Sane default: dump any wg / wmg variable if ( !$this->regex && !$this->getOption( 'settings' ) ) { @@ -121,7 +121,7 @@ class GetConfiguration extends Maintenance { # Filter out globals based on the regex if ( $this->regex ) { - $res = array(); + $res = []; foreach ( $GLOBALS as $name => $value ) { if ( preg_match( $this->regex, $name ) ) { $res[$name] = $value; @@ -184,7 +184,7 @@ class GetConfiguration extends Maintenance { } return true; - } elseif ( is_scalar( $value ) ) { + } elseif ( is_scalar( $value ) || $value === null ) { return true; }