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->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() {
$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;
}
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." );
public function execute() {
// Settings we will display
- $res = array();
+ $res = [];
# Sane default: dump any wg / wmg variable
if ( !$this->regex && !$this->getOption( 'settings' ) ) {
# 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;