MediaWiki 1.40.4
MediaWiki\Settings\Source\ReflectionSchemaSource Class Reference

Constructs a settings array based on a PHP class by inspecting class members to construct a schema. More...

Inherits MediaWiki\Settings\Source\SettingsSource.

Collaboration diagram for MediaWiki\Settings\Source\ReflectionSchemaSource:

Public Member Functions

 __construct (string $class, bool $includeDoc=false)
 
 __toString ()
 Returns this file source as a string.
 
 load ()
 

Detailed Description

Constructs a settings array based on a PHP class by inspecting class members to construct a schema.

The value of each constant must be an array structured like a JSON Schema. For convenience, type declarations support PHPDoc style types in addition to JSON types. To avoid confusion, use 'list' for sequential arrays and 'map' for associative arrays.

Dynamic default values can be declared using the 'dynamicDefault' key. The structure of the dynamic default declaration is an array with two keys:

  • 'callback': this is a PHP callable string or array, closures are not supported.
  • 'use': A list of other config variables that the dynamic default depends on. The values of these variables will be passed to the callback as parameters.

The following shorthands can be used with dynamic default declarations:

  • if the value for 'use' is empty, it can be omitted.
  • if 'callback' is omitted, it is assumed to be a static method "getDefault$name" on the same class where $name is the name of the variable.
  • if the dynamic default declaration is not an array but a string, that string is taken to be the callback, with no parameters.
  • if the dynamic default declaration is the boolean value true, the callback is assumed to be a static method "getDefault$name" on the same class where $name is the name of the variable.
Since
1.39

Definition at line 37 of file ReflectionSchemaSource.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Settings\Source\ReflectionSchemaSource::__construct ( string $class,
bool $includeDoc = false )
Parameters
string$class
bool$includeDoc

Definition at line 55 of file ReflectionSchemaSource.php.

Member Function Documentation

◆ __toString()

MediaWiki\Settings\Source\ReflectionSchemaSource::__toString ( )

Returns this file source as a string.

Returns
string

Definition at line 127 of file ReflectionSchemaSource.php.

◆ load()

MediaWiki\Settings\Source\ReflectionSchemaSource::load ( )
Exceptions
SettingsBuilderException
Returns
array

Implements MediaWiki\Settings\Source\SettingsSource.

Definition at line 64 of file ReflectionSchemaSource.php.


The documentation for this class was generated from the following file: