Merge "Use const keyword for constant list of strings or ints"
This commit is contained in:
commit
a27ade70ee
18 changed files with 70 additions and 77 deletions
|
|
@ -21,7 +21,7 @@ namespace MediaWiki\Rest\HeaderParser;
|
|||
* If-Modified-Since.
|
||||
*/
|
||||
class HttpDate extends HeaderParserBase {
|
||||
private static $dayNames = [
|
||||
private const DAY_NAMES = [
|
||||
'Mon' => true,
|
||||
'Tue' => true,
|
||||
'Wed' => true,
|
||||
|
|
@ -31,7 +31,7 @@ class HttpDate extends HeaderParserBase {
|
|||
'Sun' => true
|
||||
];
|
||||
|
||||
private static $monthsByName = [
|
||||
private const MONTHS_BY_NAME = [
|
||||
'Jan' => 1,
|
||||
'Feb' => 2,
|
||||
'Mar' => 3,
|
||||
|
|
@ -46,7 +46,7 @@ class HttpDate extends HeaderParserBase {
|
|||
'Dec' => 12,
|
||||
];
|
||||
|
||||
private static $dayNamesLong = [
|
||||
private const DAY_NAMES_LONG = [
|
||||
'Monday',
|
||||
'Tuesday',
|
||||
'Wednesday',
|
||||
|
|
@ -157,7 +157,7 @@ class HttpDate extends HeaderParserBase {
|
|||
*/
|
||||
private function consumeDayName() {
|
||||
$next3 = substr( $this->input, $this->pos, 3 );
|
||||
if ( isset( self::$dayNames[$next3] ) ) {
|
||||
if ( isset( self::DAY_NAMES[$next3] ) ) {
|
||||
$this->dayName = $next3;
|
||||
$this->pos += 3;
|
||||
} else {
|
||||
|
|
@ -194,8 +194,8 @@ class HttpDate extends HeaderParserBase {
|
|||
*/
|
||||
private function consumeMonth() {
|
||||
$next3 = substr( $this->input, $this->pos, 3 );
|
||||
if ( isset( self::$monthsByName[$next3] ) ) {
|
||||
$this->month = self::$monthsByName[$next3];
|
||||
if ( isset( self::MONTHS_BY_NAME[$next3] ) ) {
|
||||
$this->month = self::MONTHS_BY_NAME[$next3];
|
||||
$this->pos += 3;
|
||||
} else {
|
||||
$this->error( 'expected month' );
|
||||
|
|
@ -264,7 +264,7 @@ class HttpDate extends HeaderParserBase {
|
|||
* @throws HeaderParserError
|
||||
*/
|
||||
private function consumeDayNameLong() {
|
||||
foreach ( self::$dayNamesLong as $dayName ) {
|
||||
foreach ( self::DAY_NAMES_LONG as $dayName ) {
|
||||
if ( substr_compare( $this->input, $dayName, $this->pos, strlen( $dayName ) ) === 0 ) {
|
||||
$this->dayName = substr( $dayName, 0, 3 );
|
||||
$this->pos += strlen( $dayName );
|
||||
|
|
|
|||
|
|
@ -359,12 +359,12 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
|
|||
ParamValidator::PARAM_TYPE => 'timestamp'
|
||||
],
|
||||
'prop' => [
|
||||
ParamValidator::PARAM_TYPE => ApiQueryImageInfo::getPropertyNames( $this->propertyFilter ),
|
||||
ParamValidator::PARAM_TYPE => ApiQueryImageInfo::getPropertyNames( self::PROPERTY_FILTER ),
|
||||
ParamValidator::PARAM_DEFAULT => 'timestamp|url',
|
||||
ParamValidator::PARAM_ISMULTI => true,
|
||||
ApiBase::PARAM_HELP_MSG => 'apihelp-query+imageinfo-param-prop',
|
||||
ApiBase::PARAM_HELP_MSG_PER_VALUE =>
|
||||
ApiQueryImageInfo::getPropertyMessages( $this->propertyFilter ),
|
||||
ApiQueryImageInfo::getPropertyMessages( self::PROPERTY_FILTER ),
|
||||
],
|
||||
'prefix' => null,
|
||||
'minsize' => [
|
||||
|
|
@ -406,7 +406,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
|
|||
return $ret;
|
||||
}
|
||||
|
||||
private $propertyFilter = [ 'archivename', 'thumbmime', 'uploadwarning' ];
|
||||
private const PROPERTY_FILTER = [ 'archivename', 'thumbmime', 'uploadwarning' ];
|
||||
|
||||
protected function getExamplesMessages() {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
|
|||
}
|
||||
}
|
||||
|
||||
private static $propertyFilter = [
|
||||
private const PROPERTY_FILTER = [
|
||||
'user', 'userid', 'comment', 'parsedcomment',
|
||||
'mediatype', 'archivename', 'uploadwarning',
|
||||
];
|
||||
|
|
@ -108,7 +108,7 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
|
|||
* @return array
|
||||
*/
|
||||
public static function getPropertyNames( $filter = null ) {
|
||||
return parent::getPropertyNames( $filter ?? self::$propertyFilter );
|
||||
return parent::getPropertyNames( $filter ?? self::PROPERTY_FILTER );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -118,7 +118,7 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
|
|||
* @return array
|
||||
*/
|
||||
public static function getPropertyMessages( $filter = null ) {
|
||||
return parent::getPropertyMessages( $filter ?? self::$propertyFilter );
|
||||
return parent::getPropertyMessages( $filter ?? self::PROPERTY_FILTER );
|
||||
}
|
||||
|
||||
public function getAllowedParams() {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ use MediaWiki\Xml\Xml;
|
|||
* @stable to extend
|
||||
*/
|
||||
class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
|
||||
private static $requiredParams = [
|
||||
private const REQUIRED_PARAMS = [
|
||||
// Required by underlying HTMLFormField
|
||||
'fieldname',
|
||||
// Required by HTMLCheckMatrix
|
||||
|
|
@ -52,7 +52,7 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
|
|||
* @inheritDoc
|
||||
*/
|
||||
public function __construct( $params ) {
|
||||
$missing = array_diff( self::$requiredParams, array_keys( $params ) );
|
||||
$missing = array_diff( self::REQUIRED_PARAMS, array_keys( $params ) );
|
||||
if ( $missing ) {
|
||||
throw new HTMLFormFieldRequiredOptionsException( $this, $missing );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class CliInstaller extends Installer {
|
|||
/** @var bool */
|
||||
private $specifiedScriptPath = false;
|
||||
|
||||
private $optionMap = [
|
||||
private const OPTION_MAP = [
|
||||
'dbtype' => 'wgDBtype',
|
||||
'dbserver' => 'wgDBserver',
|
||||
'dbname' => 'wgDBname',
|
||||
|
|
@ -71,7 +71,7 @@ class CliInstaller extends Installer {
|
|||
$this->specifiedScriptPath = true;
|
||||
}
|
||||
|
||||
foreach ( $this->optionMap as $opt => $global ) {
|
||||
foreach ( self::OPTION_MAP as $opt => $global ) {
|
||||
if ( isset( $options[$opt] ) ) {
|
||||
$GLOBALS[$global] = $options[$opt];
|
||||
$this->setVar( $global, $options[$opt] );
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ class ParamValidator {
|
|||
public const ALL_DEFAULT_STRING = '*';
|
||||
|
||||
/** A list of standard type names and types that may be passed as `$typeDefs` to __construct(). */
|
||||
public static $STANDARD_TYPES = [
|
||||
public const STANDARD_TYPES = [
|
||||
'boolean' => [ 'class' => TypeDef\BooleanDef::class ],
|
||||
'checkbox' => [ 'class' => TypeDef\PresenceBooleanDef::class ],
|
||||
'integer' => [ 'class' => TypeDef\IntegerDef::class ],
|
||||
|
|
@ -219,7 +219,7 @@ class ParamValidator {
|
|||
* @param Callbacks $callbacks
|
||||
* @param ObjectFactory $objectFactory To turn specs into TypeDef objects
|
||||
* @param array $options Associative array of additional settings
|
||||
* - 'typeDefs': (array) As for addTypeDefs(). If omitted, self::$STANDARD_TYPES will be used.
|
||||
* - 'typeDefs': (array) As for addTypeDefs(). If omitted, self::STANDARD_TYPES will be used.
|
||||
* Pass an empty array if you want to start with no registered types.
|
||||
* - 'ismultiLimits': (int[]) Two ints, being the default values for PARAM_ISMULTI_LIMIT1 and
|
||||
* PARAM_ISMULTI_LIMIT2. If not given, defaults to `[ 50, 500 ]`.
|
||||
|
|
@ -232,7 +232,7 @@ class ParamValidator {
|
|||
$this->callbacks = $callbacks;
|
||||
$this->objectFactory = $objectFactory;
|
||||
|
||||
$this->addTypeDefs( $options['typeDefs'] ?? self::$STANDARD_TYPES );
|
||||
$this->addTypeDefs( $options['typeDefs'] ?? self::STANDARD_TYPES );
|
||||
$this->ismultiLimit1 = $options['ismultiLimits'][0] ?? 50;
|
||||
$this->ismultiLimit2 = $options['ismultiLimits'][1] ?? 500;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ use Wikimedia\ParamValidator\TypeDef;
|
|||
*/
|
||||
class BooleanDef extends TypeDef {
|
||||
|
||||
public static $TRUEVALS = [ 'true', 't', 'yes', 'y', 'on', '1' ];
|
||||
public static $FALSEVALS = [ 'false', 'f', 'no', 'n', 'off', '0' ];
|
||||
public const TRUEVALS = [ 'true', 't', 'yes', 'y', 'on', '1' ];
|
||||
public const FALSEVALS = [ 'false', 'f', 'no', 'n', 'off', '0' ];
|
||||
|
||||
public function validate( $name, $value, array $settings, array $options ) {
|
||||
if ( is_bool( $value ) ) {
|
||||
|
|
@ -37,22 +37,22 @@ class BooleanDef extends TypeDef {
|
|||
}
|
||||
|
||||
$value = strtolower( $value );
|
||||
if ( in_array( $value, self::$TRUEVALS, true ) ) {
|
||||
if ( in_array( $value, self::TRUEVALS, true ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( $value === '' || in_array( $value, self::$FALSEVALS, true ) ) {
|
||||
if ( $value === '' || in_array( $value, self::FALSEVALS, true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->fatal(
|
||||
$this->failureMessage( 'badbool' )
|
||||
->textListParams( array_map( [ $this, 'quoteVal' ], self::$TRUEVALS ) )
|
||||
->numParams( count( self::$TRUEVALS ) )
|
||||
->textListParams( array_map( [ $this, 'quoteVal' ], self::TRUEVALS ) )
|
||||
->numParams( count( self::TRUEVALS ) )
|
||||
->textListParams( array_merge(
|
||||
array_map( [ $this, 'quoteVal' ], self::$FALSEVALS ),
|
||||
array_map( [ $this, 'quoteVal' ], self::FALSEVALS ),
|
||||
[ MessageValue::new( 'paramvalidator-emptystring' ) ]
|
||||
) )
|
||||
->numParams( count( self::$FALSEVALS ) + 1 ),
|
||||
->numParams( count( self::FALSEVALS ) + 1 ),
|
||||
$name, $value, $settings, $options
|
||||
);
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ class BooleanDef extends TypeDef {
|
|||
}
|
||||
|
||||
public function stringifyValue( $name, $value, array $settings, array $options ) {
|
||||
return $value ? self::$TRUEVALS[0] : self::$FALSEVALS[0];
|
||||
return $value ? self::TRUEVALS[0] : self::FALSEVALS[0];
|
||||
}
|
||||
|
||||
public function getHelpInfo( $name, array $settings, array $options ) {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class MSCompoundFileReader {
|
|||
public const ERROR_READ_PAST_END = 5;
|
||||
public const ERROR_INVALID_FORMAT = 6;
|
||||
|
||||
private static $mimesByClsid = [
|
||||
private const MIMES_BY_CLSID = [
|
||||
// From http://justsolve.archiveteam.org/wiki/Microsoft_Compound_File
|
||||
'00020810-0000-0000-C000-000000000046' => 'application/vnd.ms-excel',
|
||||
'00020820-0000-0000-C000-000000000046' => 'application/vnd.ms-excel',
|
||||
|
|
@ -345,8 +345,8 @@ class MSCompoundFileReader {
|
|||
$name = iconv( 'UTF-16LE', 'UTF-8', substr( $entry['name_raw'], 0, $entry['name_length'] - 2 ) );
|
||||
|
||||
$clsid = $this->decodeClsid( $entry['clsid'] );
|
||||
if ( $type == self::TYPE_ROOT && isset( self::$mimesByClsid[$clsid] ) ) {
|
||||
$this->mimeFromClsid = self::$mimesByClsid[$clsid];
|
||||
if ( $type == self::TYPE_ROOT && isset( self::MIMES_BY_CLSID[$clsid] ) ) {
|
||||
$this->mimeFromClsid = self::MIMES_BY_CLSID[$clsid];
|
||||
}
|
||||
|
||||
if ( $name === 'Workbook' ) {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class SpecialWhatLinksHere extends FormSpecialPage {
|
|||
private TitleFactory $titleFactory;
|
||||
private LinksMigration $linksMigration;
|
||||
|
||||
protected $limits = [ 20, 50, 100, 250, 500 ];
|
||||
private const LIMITS = [ 20, 50, 100, 250, 500 ];
|
||||
|
||||
/**
|
||||
* @param IConnectionProvider $dbProvider
|
||||
|
|
@ -626,7 +626,7 @@ class SpecialWhatLinksHere extends FormSpecialPage {
|
|||
->setPage( $this->getPageTitle( $this->target->getPrefixedDBkey() ) )
|
||||
// Remove 'target', already included in the request title
|
||||
->setLinkQuery( array_diff_key( $this->opts->getChangedValues(), [ 'target' => null ] ) )
|
||||
->setLimits( $this->limits )
|
||||
->setLimits( self::LIMITS )
|
||||
->setLimitLinkQueryParam( 'limit' )
|
||||
->setCurrentLimit( $this->opts->getValue( 'limit' ) )
|
||||
->setPrevMsg( 'whatlinkshere-prev' )
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Wikimedia\RemexHtml\Serializer\SerializerNode;
|
|||
* in Tokenizer to be used. If that option is not used, it will produce wrong results (T354361).
|
||||
*/
|
||||
class RemexCompatFormatter extends HtmlFormatter {
|
||||
private static $markedEmptyElements = [
|
||||
private const MARKED_EMPTY_ELEMENTS = [
|
||||
'li' => true,
|
||||
'p' => true,
|
||||
'tr' => true,
|
||||
|
|
@ -73,7 +73,7 @@ class RemexCompatFormatter extends HtmlFormatter {
|
|||
|
||||
$name = $node->name;
|
||||
$attrs = $node->attrs;
|
||||
if ( isset( self::$markedEmptyElements[$name] ) && $attrs->count() === 0
|
||||
if ( isset( self::MARKED_EMPTY_ELEMENTS[$name] ) && $attrs->count() === 0
|
||||
&& strspn( $contents, "\t\n\f\r " ) === strlen( $contents )
|
||||
) {
|
||||
return "<{$name} class=\"mw-empty-elt\">$contents</{$name}>";
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use Wikimedia\RemexHtml\TreeBuilder\TreeHandler;
|
|||
* @internal
|
||||
*/
|
||||
class RemexCompatMunger implements TreeHandler {
|
||||
private static $onlyInlineElements = [
|
||||
private const ONLY_INLINE_ELEMENTS = [
|
||||
"a" => true,
|
||||
"abbr" => true,
|
||||
"acronym" => true,
|
||||
|
|
@ -79,9 +79,8 @@ class RemexCompatMunger implements TreeHandler {
|
|||
* typically those that are themselves invisible in a browser's rendering.
|
||||
* This isn't a complete list, it's just the tags that we're likely to
|
||||
* encounter in practice.
|
||||
* @var array
|
||||
*/
|
||||
private static $metadataElements = [
|
||||
private const METADATA_ELEMENTS = [
|
||||
'style' => true,
|
||||
'script' => true,
|
||||
'link' => true,
|
||||
|
|
@ -90,7 +89,7 @@ class RemexCompatMunger implements TreeHandler {
|
|||
'meta' => true,
|
||||
];
|
||||
|
||||
private static $formattingElements = [
|
||||
private const FORMATTING_ELEMENTS = [
|
||||
'a' => true,
|
||||
'b' => true,
|
||||
'big' => true,
|
||||
|
|
@ -275,10 +274,10 @@ class RemexCompatMunger implements TreeHandler {
|
|||
$parentData = $parent->snData;
|
||||
$elementName = $element->htmlName;
|
||||
|
||||
$inline = isset( self::$onlyInlineElements[$elementName] );
|
||||
$inline = isset( self::ONLY_INLINE_ELEMENTS[$elementName] );
|
||||
$under = $preposition === TreeBuilder::UNDER;
|
||||
|
||||
if ( isset( self::$metadataElements[$elementName] )
|
||||
if ( isset( self::METADATA_ELEMENTS[$elementName] )
|
||||
&& !self::isTableOfContentsMarker( $element )
|
||||
) {
|
||||
// The element is a metadata element, that we allow to appear in
|
||||
|
|
@ -335,7 +334,7 @@ class RemexCompatMunger implements TreeHandler {
|
|||
$elementData = $element->userData->snData;
|
||||
}
|
||||
if ( ( $parentData->isPWrapper || $parentData->isSplittable )
|
||||
&& isset( self::$formattingElements[$elementName] )
|
||||
&& isset( self::FORMATTING_ELEMENTS[$elementName] )
|
||||
) {
|
||||
$elementData->isSplittable = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@
|
|||
* configuration settings is less cumbersome, and behavior is closer to that of eval.php.
|
||||
*/
|
||||
class CodeCleanerGlobalsPass extends \Psy\CodeCleaner\CodeCleanerPass {
|
||||
private static $superglobals = [
|
||||
private const SUPERGLOBALS = [
|
||||
'GLOBALS', '_SERVER', '_ENV', '_FILES', '_COOKIE', '_POST', '_GET', '_SESSION'
|
||||
];
|
||||
|
||||
public function beforeTraverse( array $nodes ) {
|
||||
$globalVars = array_diff( array_keys( $GLOBALS ), self::$superglobals );
|
||||
$globalVars = array_diff( array_keys( $GLOBALS ), self::SUPERGLOBALS );
|
||||
$validGlobalVars = array_filter( $globalVars, static function ( string $name ) {
|
||||
// https://www.php.net/manual/en/language.variables.basics.php
|
||||
return preg_match( '/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name );
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ require_once __DIR__ . '/Maintenance.php';
|
|||
|
||||
class ConvertExtensionToRegistration extends Maintenance {
|
||||
|
||||
protected $custom = [
|
||||
private const CUSTOM_GLOBALS = [
|
||||
'MessagesDirs' => 'handleMessagesDirs',
|
||||
'ExtensionMessagesFiles' => 'handleExtensionMessagesFiles',
|
||||
'AutoloadClasses' => 'removeAbsolutePath',
|
||||
|
|
@ -25,28 +25,22 @@ class ConvertExtensionToRegistration extends Maintenance {
|
|||
|
||||
/**
|
||||
* Things that were formerly globals and should still be converted
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $formerGlobals = [
|
||||
private const FORMER_GLOBALS = [
|
||||
'TrackingCategories',
|
||||
];
|
||||
|
||||
/**
|
||||
* No longer supported globals (with reason) should not be converted and emit a warning
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $noLongerSupportedGlobals = [
|
||||
private const NO_LONGER_SUPPORTED_GLOBALS = [
|
||||
'SpecialPageGroups' => 'deprecated', // Deprecated 1.21, removed in 1.26
|
||||
];
|
||||
|
||||
/**
|
||||
* Keys that should be put at the top of the generated JSON file (T86608)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $promote = [
|
||||
private const PROMOTE_ATTRIBUTES = [
|
||||
'name',
|
||||
'namemsg',
|
||||
'version',
|
||||
|
|
@ -75,7 +69,7 @@ class ConvertExtensionToRegistration extends Maintenance {
|
|||
$processor = new ReflectionClass( ExtensionProcessor::class );
|
||||
$settings = $processor->getProperty( 'globalSettings' );
|
||||
$settings->setAccessible( true );
|
||||
return array_merge( $settings->getValue(), $this->formerGlobals );
|
||||
return array_merge( $settings->getValue(), self::FORMER_GLOBALS );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
|
|
@ -83,7 +77,7 @@ class ConvertExtensionToRegistration extends Maintenance {
|
|||
// fatal unless an array is already set. So set an empty value.
|
||||
// And use the weird $__settings name to avoid any conflicts
|
||||
// with real poorly named settings.
|
||||
$__settings = array_merge( $this->getAllGlobals(), array_keys( $this->custom ) );
|
||||
$__settings = array_merge( $this->getAllGlobals(), array_keys( self::CUSTOM_GLOBALS ) );
|
||||
foreach ( $__settings as $var ) {
|
||||
$var = 'wg' . $var;
|
||||
$$var = [];
|
||||
|
|
@ -118,14 +112,14 @@ class ConvertExtensionToRegistration extends Maintenance {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $this->custom[$realName] ) ) {
|
||||
call_user_func_array( [ $this, $this->custom[$realName] ],
|
||||
if ( isset( self::CUSTOM_GLOBALS[$realName] ) ) {
|
||||
call_user_func_array( [ $this, self::CUSTOM_GLOBALS[$realName] ],
|
||||
[ $realName, $value, $vars ] );
|
||||
} elseif ( in_array( $realName, $globalSettings ) ) {
|
||||
$this->json[$realName] = $value;
|
||||
} elseif ( array_key_exists( $realName, $this->noLongerSupportedGlobals ) ) {
|
||||
} elseif ( array_key_exists( $realName, self::NO_LONGER_SUPPORTED_GLOBALS ) ) {
|
||||
$this->output( 'Warning: Skipped global "' . $name . '" (' .
|
||||
$this->noLongerSupportedGlobals[$realName] . '). ' .
|
||||
self::NO_LONGER_SUPPORTED_GLOBALS[$realName] . '). ' .
|
||||
"Please update the entry point before convert to registration.\n" );
|
||||
$this->hasWarning = true;
|
||||
} elseif ( strpos( $name, $configPrefix ) === 0 ) {
|
||||
|
|
@ -167,7 +161,7 @@ class ConvertExtensionToRegistration extends Maintenance {
|
|||
|
||||
// Move some keys to the top
|
||||
$out = [];
|
||||
foreach ( $this->promote as $key ) {
|
||||
foreach ( self::PROMOTE_ATTRIBUTES as $key ) {
|
||||
if ( isset( $this->json[$key] ) ) {
|
||||
$out[$key] = $this->json[$key];
|
||||
unset( $this->json[$key] );
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ use MediaWiki\WikiMap\WikiMap;
|
|||
* @ingroup Maintenance
|
||||
*/
|
||||
class CreateAndPromote extends Maintenance {
|
||||
private static $permitRoles = [ 'sysop', 'bureaucrat', 'interface-admin', 'bot' ];
|
||||
private const PERMIT_ROLES = [ 'sysop', 'bureaucrat', 'interface-admin', 'bot' ];
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
|
@ -48,7 +48,7 @@ class CreateAndPromote extends Maintenance {
|
|||
'force',
|
||||
'If account exists already, just grant it rights or change password.'
|
||||
);
|
||||
foreach ( self::$permitRoles as $role ) {
|
||||
foreach ( self::PERMIT_ROLES as $role ) {
|
||||
$this->addOption( $role, "Add the account to the {$role} group" );
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ class CreateAndPromote extends Maintenance {
|
|||
$inGroups = $services->getUserGroupManager()->getUserGroups( $user );
|
||||
}
|
||||
|
||||
$groups = array_filter( self::$permitRoles, [ $this, 'hasOption' ] );
|
||||
$groups = array_filter( self::PERMIT_ROLES, [ $this, 'hasOption' ] );
|
||||
if ( $this->hasOption( 'custom-groups' ) ) {
|
||||
$allGroups = array_fill_keys( $services->getUserGroupManager()->listAllGroups(), true );
|
||||
$customGroupsText = $this->getOption( 'custom-groups' );
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class GetConfiguration extends Maintenance {
|
|||
* List of format output internally supported.
|
||||
* Each item MUST be lower case.
|
||||
*/
|
||||
protected static $outFormats = [
|
||||
private const OUT_FORMATS = [
|
||||
'json',
|
||||
'php',
|
||||
'serialize',
|
||||
|
|
@ -57,7 +57,7 @@ class GetConfiguration extends Maintenance {
|
|||
$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', implode( ', ', self::$outFormats ), false, true );
|
||||
$this->addOption( 'format', implode( ', ', self::OUT_FORMATS ), false, true );
|
||||
$this->addOption(
|
||||
'json-partial-output-on-error',
|
||||
'Use JSON_PARTIAL_OUTPUT_ON_ERROR flag with json_encode(). This allows for partial response to ' .
|
||||
|
|
@ -72,7 +72,7 @@ class GetConfiguration extends Maintenance {
|
|||
# Get the format and make sure it is set to a valid default value
|
||||
$format = strtolower( $this->getOption( 'format', 'PHP' ) );
|
||||
|
||||
$validFormat = in_array( $format, self::$outFormats );
|
||||
$validFormat = in_array( $format, self::OUT_FORMATS );
|
||||
if ( !$validFormat ) {
|
||||
$this->error( "--format set to an unrecognized format" );
|
||||
$error_out = true;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ require_once __DIR__ . '/Maintenance.php';
|
|||
* @author Antoine Musso
|
||||
*/
|
||||
class ShowJobs extends Maintenance {
|
||||
protected static $stateMethods = [
|
||||
private const STATE_METHODS = [
|
||||
'unclaimed' => 'getAllQueuedJobs',
|
||||
'delayed' => 'getAllDelayedJobs',
|
||||
'claimed' => 'getAllAcquiredJobs',
|
||||
|
|
@ -63,8 +63,8 @@ class ShowJobs extends Maintenance {
|
|||
? [ $typeFilter ]
|
||||
: $group->getQueueTypes();
|
||||
$filteredStates = $stateFilter
|
||||
? array_intersect_key( self::$stateMethods, [ $stateFilter => 1 ] )
|
||||
: self::$stateMethods;
|
||||
? array_intersect_key( self::STATE_METHODS, [ $stateFilter => 1 ] )
|
||||
: self::STATE_METHODS;
|
||||
|
||||
if ( $this->hasOption( 'list' ) ) {
|
||||
$count = 0;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class ParamValidatorTest extends TestCase {
|
|||
new SimpleCallbacks( [] ),
|
||||
new ObjectFactory( $this->getMockForAbstractClass( ContainerInterface::class ) )
|
||||
);
|
||||
$this->assertSame( array_keys( ParamValidator::$STANDARD_TYPES ), $validator->knownTypes() );
|
||||
$this->assertSame( array_keys( ParamValidator::STANDARD_TYPES ), $validator->knownTypes() );
|
||||
|
||||
$validator = new ParamValidator(
|
||||
new SimpleCallbacks( [] ),
|
||||
|
|
@ -194,7 +194,7 @@ class ParamValidatorTest extends TestCase {
|
|||
$validator = new ParamValidator(
|
||||
$callbacks,
|
||||
new ObjectFactory( $this->getMockForAbstractClass( ContainerInterface::class ) ),
|
||||
[ 'typeDefs' => [ 'foo' => $mock1, 'NULL' => $mock2 ] + ParamValidator::$STANDARD_TYPES ]
|
||||
[ 'typeDefs' => [ 'foo' => $mock1, 'NULL' => $mock2 ] + ParamValidator::STANDARD_TYPES ]
|
||||
);
|
||||
|
||||
$this->assertEquals( $expect, $validator->checkSettings( 'dummy', $settings, [] ) );
|
||||
|
|
@ -603,7 +603,7 @@ class ParamValidatorTest extends TestCase {
|
|||
'foo' => 'x|y|z'
|
||||
] ),
|
||||
new ObjectFactory( $this->getMockForAbstractClass( ContainerInterface::class ) ),
|
||||
[ 'typeDefs' => ParamValidator::$STANDARD_TYPES ]
|
||||
[ 'typeDefs' => ParamValidator::STANDARD_TYPES ]
|
||||
);
|
||||
|
||||
$options = [
|
||||
|
|
@ -649,7 +649,7 @@ class ParamValidatorTest extends TestCase {
|
|||
$validator = new ParamValidator(
|
||||
new SimpleCallbacks( [] ),
|
||||
new ObjectFactory( $this->getMockForAbstractClass( ContainerInterface::class ) ),
|
||||
[ 'typeDefs' => ParamValidator::$STANDARD_TYPES ]
|
||||
[ 'typeDefs' => ParamValidator::STANDARD_TYPES ]
|
||||
);
|
||||
|
||||
$this->expectException( $expectedException );
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ class BooleanDefTest extends TypeDefTestCase {
|
|||
$enforceType = [ TypeDef::OPT_ENFORCE_JSON_TYPES => true ];
|
||||
|
||||
foreach ( [
|
||||
[ BooleanDef::$TRUEVALS, true ],
|
||||
[ BooleanDef::$FALSEVALS, false ],
|
||||
[ BooleanDef::TRUEVALS, true ],
|
||||
[ BooleanDef::FALSEVALS, false ],
|
||||
[ [ '' ], false ],
|
||||
] as [ $vals, $expect ] ) {
|
||||
foreach ( $vals as $v ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue