MediaWiki master
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 ()
 Loads and returns all settings from this source as an associative array.
Returns
array
Exceptions
SettingsBuilderException

 
 loadAsComponents ()
 
 loadAsSchema ()
 Load the data as a single top-level JSON Schema.
 

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 157 of file ReflectionSchemaSource.php.

◆ load()

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

Loads and returns all settings from this source as an associative array.

Returns
array
Exceptions
SettingsBuilderException

Implements MediaWiki\Settings\Source\SettingsSource.

Definition at line 63 of file ReflectionSchemaSource.php.

◆ loadAsComponents()

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

Definition at line 71 of file ReflectionSchemaSource.php.

◆ loadAsSchema()

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

Load the data as a single top-level JSON Schema.

Returned JSON Schema is for an object, which includes the individual config schemas. The returned schema may contain $defs, which then may be referenced internally in the schema via $ref.

Returns
array

Definition at line 138 of file ReflectionSchemaSource.php.


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