class ArrayNode extends BaseNode implements PrototypeNodeInterface

Represents an Array node in the config tree.

Constants

DEFAULT_PATH_SEPARATOR

Properties

protected $name from BaseNode
protected $parent from BaseNode
protected $normalizationClosures from BaseNode
protected $finalValidationClosures from BaseNode
protected $allowOverwrite from BaseNode
protected $required from BaseNode
protected $deprecationMessage from BaseNode
protected $equivalentValues from BaseNode
protected $attributes from BaseNode
protected $pathSeparator from BaseNode
protected $xmlRemappings
protected $children
protected $allowFalse
protected $allowNewKeys
protected $addIfNotSet
protected $performDeepMerging
protected $ignoreExtraKeys
protected $removeExtraKeys
protected $normalizeKeys

Methods

__construct(string|null $name, NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR)

No description

from BaseNode
static void
setPlaceholder(string $placeholder, array $values)

Register possible (dummy) values for a dynamic placeholder value.

from BaseNode
static void
setPlaceholderUniquePrefix(string $prefix)

Sets a common prefix for dynamic placeholder values.

from BaseNode
static void
resetPlaceholders()

Resets all current placeholders available.

from BaseNode
setAttribute($key, $value)

No description

from BaseNode
getAttribute($key, $default = null)

No description

from BaseNode
hasAttribute($key)

No description

from BaseNode
getAttributes()

No description

from BaseNode
setAttributes(array $attributes)

No description

from BaseNode
removeAttribute($key)

No description

from BaseNode
setInfo(string $info)

Sets an info message.

from BaseNode
string
getInfo()

Returns info message.

from BaseNode
setExample(string|array $example)

Sets the example configuration for this node.

from BaseNode
string|array
getExample()

Retrieves the example configuration for this node.

from BaseNode
addEquivalentValue(mixed $originalValue, mixed $equivalentValue)

Adds an equivalent value.

from BaseNode
setRequired(bool $boolean)

Set this node as required.

from BaseNode
setDeprecated(string|null $message)

Sets this node as deprecated.

from BaseNode
setAllowOverwrite(bool $allow)

Sets if this node can be overridden.

from BaseNode
setNormalizationClosures(array $closures)

Sets the closures used for normalization.

from BaseNode
setFinalValidationClosures(array $closures)

Sets the closures used for final validation.

from BaseNode
bool
isRequired()

Returns true when the node is required.

from BaseNode
bool
isDeprecated()

Checks if this node is deprecated.

from BaseNode
string
getDeprecationMessage(string $node, string $path)

Returns the deprecated message.

from BaseNode
string
getName()

Returns the name of the node.

from BaseNode
string
getPath()

Returns the path of the node.

from BaseNode
mixed
merge(mixed $leftSide, mixed $rightSide)

Merges two values together.

from BaseNode
mixed
normalize(mixed $value)

Normalizes a value.

from BaseNode
The
preNormalize($value)

Normalizes keys between the different configuration formats.

getParent()

Returns parent node for this node.

from BaseNode
mixed
finalize(mixed $value)

Finalizes a value.

from BaseNode
validateType(mixed $value)

Validates the type of the value.

mixed
normalizeValue(mixed $value)

Normalizes the value.

mixed
mergeValues(mixed $leftSide, mixed $rightSide)

Merges values together.

mixed
finalizeValue(mixed $value)

Finalizes the value of this node.

bool
allowPlaceholders()

Tests if placeholder values are allowed for this node.

bool
isHandlingPlaceholder()

Tests if a placeholder is being handled currently.

from BaseNode
array
getValidPlaceholderTypes()

Gets allowed dynamic types for this node.

from BaseNode
setNormalizeKeys($normalizeKeys)

No description

array
getChildren()

Retrieves the children of this node.

setXmlRemappings(array $remappings)

Sets the xml remappings that should be performed.

array
getXmlRemappings()

Gets the xml remappings that should be performed.

setAddIfNotSet(bool $boolean)

Sets whether to add default values for this array if it has not been defined in any of the configuration files.

setAllowFalse(bool $allow)

Sets whether false is allowed as value indicating that the array should be unset.

setAllowNewKeys(bool $allow)

Sets whether new keys can be defined in subsequent configurations.

setPerformDeepMerging(bool $boolean)

Sets if deep merging should occur.

setIgnoreExtraKeys(bool $boolean, bool $remove = true)

Whether extra keys should just be ignore without an exception.

setName(string $name)

Sets the name of the node.

bool
hasDefaultValue()

Returns true when the node has a default value.

mixed
getDefaultValue()

Returns the default value of the node.

addChild(NodeInterface $node)

Adds a child node.

array
remapXml(array $value)

Remaps multiple singular values to a single plural value.

Details

in BaseNode at line 48
__construct(string|null $name, NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR)

Parameters

string|null $name
NodeInterface $parent
string $pathSeparator

Exceptions

InvalidArgumentException if the name contains a period

in BaseNode at line 67
static void setPlaceholder(string $placeholder, array $values)

Register possible (dummy) values for a dynamic placeholder value.

Matching configuration values will be processed with a provided value, one by one. After a provided value is successfully processed the configuration value is returned as is, thus preserving the placeholder.

Parameters

string $placeholder
array $values

Return Value

void

in BaseNode at line 84
static void setPlaceholderUniquePrefix(string $prefix)

Sets a common prefix for dynamic placeholder values.

Matching configuration values will be skipped from being processed and are returned as is, thus preserving the placeholder. An exact match provided by {see setPlaceholder()} might take precedence.

Parameters

string $prefix

Return Value

void

in BaseNode at line 94
static void resetPlaceholders()

Resets all current placeholders available.

Return Value

void

in BaseNode at line 100
setAttribute($key, $value)

Parameters

$key
$value

in BaseNode at line 105
getAttribute($key, $default = null)

Parameters

$key
$default

in BaseNode at line 110
hasAttribute($key)

Parameters

$key

in BaseNode at line 115
getAttributes()

in BaseNode at line 120
setAttributes(array $attributes)

Parameters

array $attributes

in BaseNode at line 125
removeAttribute($key)

Parameters

$key

in BaseNode at line 135
setInfo(string $info)

Sets an info message.

Parameters

string $info

in BaseNode at line 145
string getInfo()

Returns info message.

Return Value

string The info text

in BaseNode at line 155
setExample(string|array $example)

Sets the example configuration for this node.

Parameters

string|array $example

in BaseNode at line 165
string|array getExample()

Retrieves the example configuration for this node.

Return Value

string|array The example

in BaseNode at line 176
addEquivalentValue(mixed $originalValue, mixed $equivalentValue)

Adds an equivalent value.

Parameters

mixed $originalValue
mixed $equivalentValue

in BaseNode at line 186
setRequired(bool $boolean)

Set this node as required.

Parameters

bool $boolean Required node

in BaseNode at line 199
setDeprecated(string|null $message)

Sets this node as deprecated.

You can use %node% and %path% placeholders in your message to display, respectively, the node name and its complete path.

Parameters

string|null $message Deprecated message

in BaseNode at line 209
setAllowOverwrite(bool $allow)

Sets if this node can be overridden.

Parameters

bool $allow

in BaseNode at line 219
setNormalizationClosures(array $closures)

Sets the closures used for normalization.

Parameters

array $closures An array of Closures used for normalization

in BaseNode at line 229
setFinalValidationClosures(array $closures)

Sets the closures used for final validation.

Parameters

array $closures An array of Closures used for final validation

in BaseNode at line 237
bool isRequired()

Returns true when the node is required.

Return Value

bool If the node is required

in BaseNode at line 247
bool isDeprecated()

Checks if this node is deprecated.

Return Value

bool

in BaseNode at line 260
string getDeprecationMessage(string $node, string $path)

Returns the deprecated message.

Parameters

string $node the configuration node name
string $path the path of the node

Return Value

string

in BaseNode at line 268
string getName()

Returns the name of the node.

Return Value

string The name of the node

in BaseNode at line 276
string getPath()

Returns the path of the node.

Return Value

string The node path

in BaseNode at line 288
final mixed merge(mixed $leftSide, mixed $rightSide)

Merges two values together.

Parameters

mixed $leftSide
mixed $rightSide

Return Value

mixed The merged value

Exceptions

ForbiddenOverwriteException if the configuration path cannot be overwritten
InvalidTypeException if the value type is invalid

in BaseNode at line 329
final mixed normalize(mixed $value)

Normalizes a value.

Parameters

mixed $value The value to normalize

Return Value

mixed The normalized value

Exceptions

InvalidTypeException if the value type is invalid

at line 53
protected The preNormalize($value)

Normalizes keys between the different configuration formats.

Namely, you mostly have foo_bar in YAML while you have foo-bar in XML. After running this method, all keys are normalized to foo_bar.

If you have a mixed key like foo-bar_moo, it will not be altered. The key will also not be altered if the target key already exists.

Parameters

$value

Return Value

The normalized array value

in BaseNode at line 383
NodeInterface|null getParent()

Returns parent node for this node.

Return Value

NodeInterface|null

in BaseNode at line 391
final mixed finalize(mixed $value)

Finalizes a value.

Parameters

mixed $value The value to finalize

Return Value

mixed The finalized value

Exceptions

InvalidTypeException if the value type is invalid
InvalidConfigurationException if the value is invalid configuration

at line 262
protected validateType(mixed $value)

Validates the type of the value.

Parameters

mixed $value The value to validate

Exceptions

InvalidTypeException

at line 284
protected mixed normalizeValue(mixed $value)

Normalizes the value.

Parameters

mixed $value The value to normalize

Return Value

mixed The normalized value

Exceptions

InvalidConfigurationException

at line 348
protected mixed mergeValues(mixed $leftSide, mixed $rightSide)

Merges values together.

Parameters

mixed $leftSide
mixed $rightSide

Return Value

mixed The merged value

Exceptions

InvalidConfigurationException
RuntimeException

at line 219
protected mixed finalizeValue(mixed $value)

Finalizes the value of this node.

Parameters

mixed $value The value to finalize

Return Value

mixed The finalized value

Exceptions

UnsetKeyException
InvalidConfigurationException if the node doesn't have enough children

at line 387
protected bool allowPlaceholders()

Tests if placeholder values are allowed for this node.

Return Value

bool

in BaseNode at line 477
protected bool isHandlingPlaceholder()

Tests if a placeholder is being handled currently.

Return Value

bool

in BaseNode at line 485
protected array getValidPlaceholderTypes()

Gets allowed dynamic types for this node.

Return Value

array

at line 35
setNormalizeKeys($normalizeKeys)

Parameters

$normalizeKeys

at line 77
array getChildren()

Retrieves the children of this node.

Return Value

array The children

at line 87
setXmlRemappings(array $remappings)

Sets the xml remappings that should be performed.

Parameters

array $remappings An array of the form [[string, string]]

at line 97
array getXmlRemappings()

Gets the xml remappings that should be performed.

Return Value

array an array of the form [[string, string]]

at line 108
setAddIfNotSet(bool $boolean)

Sets whether to add default values for this array if it has not been defined in any of the configuration files.

Parameters

bool $boolean

at line 118
setAllowFalse(bool $allow)

Sets whether false is allowed as value indicating that the array should be unset.

Parameters

bool $allow

at line 128
setAllowNewKeys(bool $allow)

Sets whether new keys can be defined in subsequent configurations.

Parameters

bool $allow

at line 138
setPerformDeepMerging(bool $boolean)

Sets if deep merging should occur.

Parameters

bool $boolean

at line 149
setIgnoreExtraKeys(bool $boolean, bool $remove = true)

Whether extra keys should just be ignore without an exception.

Parameters

bool $boolean To allow extra keys
bool $remove To remove extra keys

at line 158
setName(string $name)

Sets the name of the node.

Parameters

string $name The name of the node

at line 166
bool hasDefaultValue()

Returns true when the node has a default value.

Return Value

bool If the node has a default value

at line 174
mixed getDefaultValue()

Returns the default value of the node.

Return Value

mixed The default value

Exceptions

RuntimeException if the node has no default value

at line 196
addChild(NodeInterface $node)

Adds a child node.

Parameters

NodeInterface $node

Exceptions

InvalidArgumentException when the child node has no name
InvalidArgumentException when the child node's name is not unique

at line 323
protected array remapXml(array $value)

Remaps multiple singular values to a single plural value.

Parameters

array $value The source values

Return Value

array The remapped values