Update website
This commit is contained in:
parent
a0b0d3dae7
commit
ae7ef6ad45
3151 changed files with 566766 additions and 48 deletions
416
admin/phpMyAdmin/vendor/symfony/config/Definition/ArrayNode.php
vendored
Normal file
416
admin/phpMyAdmin/vendor/symfony/config/Definition/ArrayNode.php
vendored
Normal file
|
@ -0,0 +1,416 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
|
||||
|
||||
/**
|
||||
* Represents an Array node in the config tree.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
{
|
||||
protected $xmlRemappings = [];
|
||||
protected $children = [];
|
||||
protected $allowFalse = false;
|
||||
protected $allowNewKeys = true;
|
||||
protected $addIfNotSet = false;
|
||||
protected $performDeepMerging = true;
|
||||
protected $ignoreExtraKeys = false;
|
||||
protected $removeExtraKeys = true;
|
||||
protected $normalizeKeys = true;
|
||||
|
||||
public function setNormalizeKeys($normalizeKeys)
|
||||
{
|
||||
$this->normalizeKeys = (bool) $normalizeKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
protected function preNormalize($value)
|
||||
{
|
||||
if (!$this->normalizeKeys || !\is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$normalized = [];
|
||||
|
||||
foreach ($value as $k => $v) {
|
||||
if (false !== strpos($k, '-') && false === strpos($k, '_') && !\array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) {
|
||||
$normalized[$normalizedKey] = $v;
|
||||
} else {
|
||||
$normalized[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the children of this node.
|
||||
*
|
||||
* @return array<string, NodeInterface>
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the xml remappings that should be performed.
|
||||
*
|
||||
* @param array $remappings An array of the form [[string, string]]
|
||||
*/
|
||||
public function setXmlRemappings(array $remappings)
|
||||
{
|
||||
$this->xmlRemappings = $remappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the xml remappings that should be performed.
|
||||
*
|
||||
* @return array an array of the form [[string, string]]
|
||||
*/
|
||||
public function getXmlRemappings()
|
||||
{
|
||||
return $this->xmlRemappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to add default values for this array if it has not been
|
||||
* defined in any of the configuration files.
|
||||
*
|
||||
* @param bool $boolean
|
||||
*/
|
||||
public function setAddIfNotSet($boolean)
|
||||
{
|
||||
$this->addIfNotSet = (bool) $boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether false is allowed as value indicating that the array should be unset.
|
||||
*
|
||||
* @param bool $allow
|
||||
*/
|
||||
public function setAllowFalse($allow)
|
||||
{
|
||||
$this->allowFalse = (bool) $allow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether new keys can be defined in subsequent configurations.
|
||||
*
|
||||
* @param bool $allow
|
||||
*/
|
||||
public function setAllowNewKeys($allow)
|
||||
{
|
||||
$this->allowNewKeys = (bool) $allow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if deep merging should occur.
|
||||
*
|
||||
* @param bool $boolean
|
||||
*/
|
||||
public function setPerformDeepMerging($boolean)
|
||||
{
|
||||
$this->performDeepMerging = (bool) $boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether extra keys should just be ignored without an exception.
|
||||
*
|
||||
* @param bool $boolean To allow extra keys
|
||||
* @param bool $remove To remove extra keys
|
||||
*/
|
||||
public function setIgnoreExtraKeys($boolean, $remove = true)
|
||||
{
|
||||
$this->ignoreExtraKeys = (bool) $boolean;
|
||||
$this->removeExtraKeys = $this->ignoreExtraKeys && $remove;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasDefaultValue()
|
||||
{
|
||||
return $this->addIfNotSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultValue()
|
||||
{
|
||||
if (!$this->hasDefaultValue()) {
|
||||
throw new \RuntimeException(sprintf('The node at path "%s" has no default value.', $this->getPath()));
|
||||
}
|
||||
|
||||
$defaults = [];
|
||||
foreach ($this->children as $name => $child) {
|
||||
if ($child->hasDefaultValue()) {
|
||||
$defaults[$name] = $child->getDefaultValue();
|
||||
}
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a child node.
|
||||
*
|
||||
* @throws \InvalidArgumentException when the child node has no name
|
||||
* @throws \InvalidArgumentException when the child node's name is not unique
|
||||
*/
|
||||
public function addChild(NodeInterface $node)
|
||||
{
|
||||
$name = $node->getName();
|
||||
if (!\strlen($name)) {
|
||||
throw new \InvalidArgumentException('Child nodes must be named.');
|
||||
}
|
||||
if (isset($this->children[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('A child node named "%s" already exists.', $name));
|
||||
}
|
||||
|
||||
$this->children[$name] = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes the value of this node.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed The finalised value
|
||||
*
|
||||
* @throws UnsetKeyException
|
||||
* @throws InvalidConfigurationException if the node doesn't have enough children
|
||||
*/
|
||||
protected function finalizeValue($value)
|
||||
{
|
||||
if (false === $value) {
|
||||
throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: "%s".', $this->getPath(), json_encode($value)));
|
||||
}
|
||||
|
||||
foreach ($this->children as $name => $child) {
|
||||
if (!\array_key_exists($name, $value)) {
|
||||
if ($child->isRequired()) {
|
||||
$ex = new InvalidConfigurationException(sprintf('The child node "%s" at path "%s" must be configured.', $name, $this->getPath()));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
if ($child->hasDefaultValue()) {
|
||||
$value[$name] = $child->getDefaultValue();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($child->isDeprecated()) {
|
||||
@trigger_error($child->getDeprecationMessage($name, $this->getPath()), \E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
try {
|
||||
$value[$name] = $child->finalize($value[$name]);
|
||||
} catch (UnsetKeyException $e) {
|
||||
unset($value[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the type of the value.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @throws InvalidTypeException
|
||||
*/
|
||||
protected function validateType($value)
|
||||
{
|
||||
if (!\is_array($value) && (!$this->allowFalse || false !== $value)) {
|
||||
$ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected array, but got %s', $this->getPath(), \gettype($value)));
|
||||
if ($hint = $this->getInfo()) {
|
||||
$ex->addHint($hint);
|
||||
}
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the value.
|
||||
*
|
||||
* @param mixed $value The value to normalize
|
||||
*
|
||||
* @return mixed The normalized value
|
||||
*
|
||||
* @throws InvalidConfigurationException
|
||||
*/
|
||||
protected function normalizeValue($value)
|
||||
{
|
||||
if (false === $value) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$value = $this->remapXml($value);
|
||||
|
||||
$normalized = [];
|
||||
foreach ($value as $name => $val) {
|
||||
if (isset($this->children[$name])) {
|
||||
try {
|
||||
$normalized[$name] = $this->children[$name]->normalize($val);
|
||||
} catch (UnsetKeyException $e) {
|
||||
}
|
||||
unset($value[$name]);
|
||||
} elseif (!$this->removeExtraKeys) {
|
||||
$normalized[$name] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
// if extra fields are present, throw exception
|
||||
if (\count($value) && !$this->ignoreExtraKeys) {
|
||||
$proposals = array_keys($this->children);
|
||||
sort($proposals);
|
||||
$guesses = [];
|
||||
|
||||
foreach (array_keys($value) as $subject) {
|
||||
$minScore = \INF;
|
||||
foreach ($proposals as $proposal) {
|
||||
$distance = levenshtein($subject, $proposal);
|
||||
if ($distance <= $minScore && $distance < 3) {
|
||||
$guesses[$proposal] = $distance;
|
||||
$minScore = $distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$msg = sprintf('Unrecognized option%s "%s" under "%s"', 1 === \count($value) ? '' : 's', implode(', ', array_keys($value)), $this->getPath());
|
||||
|
||||
if (\count($guesses)) {
|
||||
asort($guesses);
|
||||
$msg .= sprintf('. Did you mean "%s"?', implode('", "', array_keys($guesses)));
|
||||
} else {
|
||||
$msg .= sprintf('. Available option%s %s "%s".', 1 === \count($proposals) ? '' : 's', 1 === \count($proposals) ? 'is' : 'are', implode('", "', $proposals));
|
||||
}
|
||||
|
||||
$ex = new InvalidConfigurationException($msg);
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remaps multiple singular values to a single plural value.
|
||||
*
|
||||
* @param array $value The source values
|
||||
*
|
||||
* @return array The remapped values
|
||||
*/
|
||||
protected function remapXml($value)
|
||||
{
|
||||
foreach ($this->xmlRemappings as [$singular, $plural]) {
|
||||
if (!isset($value[$singular])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value[$plural] = Processor::normalizeConfig($value, $singular, $plural);
|
||||
unset($value[$singular]);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges values together.
|
||||
*
|
||||
* @param mixed $leftSide The left side to merge
|
||||
* @param mixed $rightSide The right side to merge
|
||||
*
|
||||
* @return mixed The merged values
|
||||
*
|
||||
* @throws InvalidConfigurationException
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function mergeValues($leftSide, $rightSide)
|
||||
{
|
||||
if (false === $rightSide) {
|
||||
// if this is still false after the last config has been merged the
|
||||
// finalization pass will take care of removing this key entirely
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false === $leftSide || !$this->performDeepMerging) {
|
||||
return $rightSide;
|
||||
}
|
||||
|
||||
foreach ($rightSide as $k => $v) {
|
||||
// no conflict
|
||||
if (!\array_key_exists($k, $leftSide)) {
|
||||
if (!$this->allowNewKeys) {
|
||||
$ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file. If you are trying to overwrite an element, make sure you redefine it with the same name.', $this->getPath()));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$leftSide[$k] = $v;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($this->children[$k])) {
|
||||
if (!$this->ignoreExtraKeys || $this->removeExtraKeys) {
|
||||
throw new \RuntimeException('merge() expects a normalized config array.');
|
||||
}
|
||||
|
||||
$leftSide[$k] = $v;
|
||||
continue;
|
||||
}
|
||||
|
||||
$leftSide[$k] = $this->children[$k]->merge($leftSide[$k], $v);
|
||||
}
|
||||
|
||||
return $leftSide;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function allowPlaceholders(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
561
admin/phpMyAdmin/vendor/symfony/config/Definition/BaseNode.php
vendored
Normal file
561
admin/phpMyAdmin/vendor/symfony/config/Definition/BaseNode.php
vendored
Normal file
|
@ -0,0 +1,561 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
||||
use Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
|
||||
|
||||
/**
|
||||
* The base node class.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
abstract class BaseNode implements NodeInterface
|
||||
{
|
||||
public const DEFAULT_PATH_SEPARATOR = '.';
|
||||
|
||||
private static $placeholderUniquePrefixes = [];
|
||||
private static $placeholders = [];
|
||||
|
||||
protected $name;
|
||||
protected $parent;
|
||||
protected $normalizationClosures = [];
|
||||
protected $finalValidationClosures = [];
|
||||
protected $allowOverwrite = true;
|
||||
protected $required = false;
|
||||
protected $deprecationMessage = null;
|
||||
protected $equivalentValues = [];
|
||||
protected $attributes = [];
|
||||
protected $pathSeparator;
|
||||
|
||||
private $handlingPlaceholder;
|
||||
|
||||
/**
|
||||
* @throws \InvalidArgumentException if the name contains a period
|
||||
*/
|
||||
public function __construct(?string $name, NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR)
|
||||
{
|
||||
if (false !== strpos($name = (string) $name, $pathSeparator)) {
|
||||
throw new \InvalidArgumentException('The name must not contain ".'.$pathSeparator.'".');
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
$this->parent = $parent;
|
||||
$this->pathSeparator = $pathSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function setPlaceholder(string $placeholder, array $values): void
|
||||
{
|
||||
if (!$values) {
|
||||
throw new \InvalidArgumentException('At least one value must be provided.');
|
||||
}
|
||||
|
||||
self::$placeholders[$placeholder] = $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds 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.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function setPlaceholderUniquePrefix(string $prefix): void
|
||||
{
|
||||
self::$placeholderUniquePrefixes[] = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all current placeholders available.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function resetPlaceholders(): void
|
||||
{
|
||||
self::$placeholderUniquePrefixes = [];
|
||||
self::$placeholders = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*/
|
||||
public function setAttribute($key, $value)
|
||||
{
|
||||
$this->attributes[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAttribute($key, $default = null)
|
||||
{
|
||||
return $this->attributes[$key] ?? $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAttribute($key)
|
||||
{
|
||||
return isset($this->attributes[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
public function setAttributes(array $attributes)
|
||||
{
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*/
|
||||
public function removeAttribute($key)
|
||||
{
|
||||
unset($this->attributes[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an info message.
|
||||
*
|
||||
* @param string $info
|
||||
*/
|
||||
public function setInfo($info)
|
||||
{
|
||||
$this->setAttribute('info', $info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns info message.
|
||||
*
|
||||
* @return string|null The info text
|
||||
*/
|
||||
public function getInfo()
|
||||
{
|
||||
return $this->getAttribute('info');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the example configuration for this node.
|
||||
*
|
||||
* @param string|array $example
|
||||
*/
|
||||
public function setExample($example)
|
||||
{
|
||||
$this->setAttribute('example', $example);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the example configuration for this node.
|
||||
*
|
||||
* @return string|array|null The example
|
||||
*/
|
||||
public function getExample()
|
||||
{
|
||||
return $this->getAttribute('example');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an equivalent value.
|
||||
*
|
||||
* @param mixed $originalValue
|
||||
* @param mixed $equivalentValue
|
||||
*/
|
||||
public function addEquivalentValue($originalValue, $equivalentValue)
|
||||
{
|
||||
$this->equivalentValues[] = [$originalValue, $equivalentValue];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this node as required.
|
||||
*
|
||||
* @param bool $boolean Required node
|
||||
*/
|
||||
public function setRequired($boolean)
|
||||
{
|
||||
$this->required = (bool) $boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param string|null $message Deprecated message
|
||||
*/
|
||||
public function setDeprecated($message)
|
||||
{
|
||||
$this->deprecationMessage = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if this node can be overridden.
|
||||
*
|
||||
* @param bool $allow
|
||||
*/
|
||||
public function setAllowOverwrite($allow)
|
||||
{
|
||||
$this->allowOverwrite = (bool) $allow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the closures used for normalization.
|
||||
*
|
||||
* @param \Closure[] $closures An array of Closures used for normalization
|
||||
*/
|
||||
public function setNormalizationClosures(array $closures)
|
||||
{
|
||||
$this->normalizationClosures = $closures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the closures used for final validation.
|
||||
*
|
||||
* @param \Closure[] $closures An array of Closures used for final validation
|
||||
*/
|
||||
public function setFinalValidationClosures(array $closures)
|
||||
{
|
||||
$this->finalValidationClosures = $closures;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isRequired()
|
||||
{
|
||||
return $this->required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this node is deprecated.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDeprecated()
|
||||
{
|
||||
return null !== $this->deprecationMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the deprecated message.
|
||||
*
|
||||
* @param string $node the configuration node name
|
||||
* @param string $path the path of the node
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDeprecationMessage($node, $path)
|
||||
{
|
||||
return strtr($this->deprecationMessage, ['%node%' => $node, '%path%' => $path]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
if (null !== $this->parent) {
|
||||
return $this->parent->getPath().$this->pathSeparator.$this->name;
|
||||
}
|
||||
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
final public function merge($leftSide, $rightSide)
|
||||
{
|
||||
if (!$this->allowOverwrite) {
|
||||
throw new ForbiddenOverwriteException(sprintf('Configuration path "%s" cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one configuration section.', $this->getPath()));
|
||||
}
|
||||
|
||||
if ($leftSide !== $leftPlaceholders = self::resolvePlaceholderValue($leftSide)) {
|
||||
foreach ($leftPlaceholders as $leftPlaceholder) {
|
||||
$this->handlingPlaceholder = $leftSide;
|
||||
try {
|
||||
$this->merge($leftPlaceholder, $rightSide);
|
||||
} finally {
|
||||
$this->handlingPlaceholder = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $rightSide;
|
||||
}
|
||||
|
||||
if ($rightSide !== $rightPlaceholders = self::resolvePlaceholderValue($rightSide)) {
|
||||
foreach ($rightPlaceholders as $rightPlaceholder) {
|
||||
$this->handlingPlaceholder = $rightSide;
|
||||
try {
|
||||
$this->merge($leftSide, $rightPlaceholder);
|
||||
} finally {
|
||||
$this->handlingPlaceholder = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $rightSide;
|
||||
}
|
||||
|
||||
$this->doValidateType($leftSide);
|
||||
$this->doValidateType($rightSide);
|
||||
|
||||
return $this->mergeValues($leftSide, $rightSide);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
final public function normalize($value)
|
||||
{
|
||||
$value = $this->preNormalize($value);
|
||||
|
||||
// run custom normalization closures
|
||||
foreach ($this->normalizationClosures as $closure) {
|
||||
$value = $closure($value);
|
||||
}
|
||||
|
||||
// resolve placeholder value
|
||||
if ($value !== $placeholders = self::resolvePlaceholderValue($value)) {
|
||||
foreach ($placeholders as $placeholder) {
|
||||
$this->handlingPlaceholder = $value;
|
||||
try {
|
||||
$this->normalize($placeholder);
|
||||
} finally {
|
||||
$this->handlingPlaceholder = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
// replace value with their equivalent
|
||||
foreach ($this->equivalentValues as $data) {
|
||||
if ($data[0] === $value) {
|
||||
$value = $data[1];
|
||||
}
|
||||
}
|
||||
|
||||
// validate type
|
||||
$this->doValidateType($value);
|
||||
|
||||
// normalize value
|
||||
return $this->normalizeValue($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the value before any other normalization is applied.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed The normalized array value
|
||||
*/
|
||||
protected function preNormalize($value)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns parent node for this node.
|
||||
*
|
||||
* @return NodeInterface|null
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
final public function finalize($value)
|
||||
{
|
||||
if ($value !== $placeholders = self::resolvePlaceholderValue($value)) {
|
||||
foreach ($placeholders as $placeholder) {
|
||||
$this->handlingPlaceholder = $value;
|
||||
try {
|
||||
$this->finalize($placeholder);
|
||||
} finally {
|
||||
$this->handlingPlaceholder = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
$this->doValidateType($value);
|
||||
|
||||
$value = $this->finalizeValue($value);
|
||||
|
||||
// Perform validation on the final value if a closure has been set.
|
||||
// The closure is also allowed to return another value.
|
||||
foreach ($this->finalValidationClosures as $closure) {
|
||||
try {
|
||||
$value = $closure($value);
|
||||
} catch (Exception $e) {
|
||||
if ($e instanceof UnsetKeyException && null !== $this->handlingPlaceholder) {
|
||||
continue;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
} catch (\Exception $e) {
|
||||
throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": ', $this->getPath()).$e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the type of a Node.
|
||||
*
|
||||
* @param mixed $value The value to validate
|
||||
*
|
||||
* @throws InvalidTypeException when the value is invalid
|
||||
*/
|
||||
abstract protected function validateType($value);
|
||||
|
||||
/**
|
||||
* Normalizes the value.
|
||||
*
|
||||
* @param mixed $value The value to normalize
|
||||
*
|
||||
* @return mixed The normalized value
|
||||
*/
|
||||
abstract protected function normalizeValue($value);
|
||||
|
||||
/**
|
||||
* Merges two values together.
|
||||
*
|
||||
* @param mixed $leftSide
|
||||
* @param mixed $rightSide
|
||||
*
|
||||
* @return mixed The merged value
|
||||
*/
|
||||
abstract protected function mergeValues($leftSide, $rightSide);
|
||||
|
||||
/**
|
||||
* Finalizes a value.
|
||||
*
|
||||
* @param mixed $value The value to finalize
|
||||
*
|
||||
* @return mixed The finalized value
|
||||
*/
|
||||
abstract protected function finalizeValue($value);
|
||||
|
||||
/**
|
||||
* Tests if placeholder values are allowed for this node.
|
||||
*/
|
||||
protected function allowPlaceholders(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a placeholder is being handled currently.
|
||||
*/
|
||||
protected function isHandlingPlaceholder(): bool
|
||||
{
|
||||
return null !== $this->handlingPlaceholder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets allowed dynamic types for this node.
|
||||
*/
|
||||
protected function getValidPlaceholderTypes(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private static function resolvePlaceholderValue($value)
|
||||
{
|
||||
if (\is_string($value)) {
|
||||
if (isset(self::$placeholders[$value])) {
|
||||
return self::$placeholders[$value];
|
||||
}
|
||||
|
||||
foreach (self::$placeholderUniquePrefixes as $placeholderUniquePrefix) {
|
||||
if (0 === strpos($value, $placeholderUniquePrefix)) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function doValidateType($value): void
|
||||
{
|
||||
if (null !== $this->handlingPlaceholder && !$this->allowPlaceholders()) {
|
||||
$e = new InvalidTypeException(sprintf('A dynamic value is not compatible with a "%s" node type at path "%s".', static::class, $this->getPath()));
|
||||
$e->setPath($this->getPath());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (null === $this->handlingPlaceholder || null === $value) {
|
||||
$this->validateType($value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$knownTypes = array_keys(self::$placeholders[$this->handlingPlaceholder]);
|
||||
$validTypes = $this->getValidPlaceholderTypes();
|
||||
|
||||
if ($validTypes && array_diff($knownTypes, $validTypes)) {
|
||||
$e = new InvalidTypeException(sprintf(
|
||||
'Invalid type for path "%s". Expected %s, but got %s.',
|
||||
$this->getPath(),
|
||||
1 === \count($validTypes) ? '"'.reset($validTypes).'"' : 'one of "'.implode('", "', $validTypes).'"',
|
||||
1 === \count($knownTypes) ? '"'.reset($knownTypes).'"' : 'one of "'.implode('", "', $knownTypes).'"'
|
||||
));
|
||||
if ($hint = $this->getInfo()) {
|
||||
$e->addHint($hint);
|
||||
}
|
||||
$e->setPath($this->getPath());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->validateType($value);
|
||||
}
|
||||
}
|
55
admin/phpMyAdmin/vendor/symfony/config/Definition/BooleanNode.php
vendored
Normal file
55
admin/phpMyAdmin/vendor/symfony/config/Definition/BooleanNode.php
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
|
||||
/**
|
||||
* This node represents a Boolean value in the config tree.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class BooleanNode extends ScalarNode
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function validateType($value)
|
||||
{
|
||||
if (!\is_bool($value)) {
|
||||
$ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected boolean, but got %s.', $this->getPath(), \gettype($value)));
|
||||
if ($hint = $this->getInfo()) {
|
||||
$ex->addHint($hint);
|
||||
}
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function isValueEmpty($value)
|
||||
{
|
||||
// a boolean value cannot be empty
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getValidPlaceholderTypes(): array
|
||||
{
|
||||
return ['bool'];
|
||||
}
|
||||
}
|
548
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
vendored
Normal file
548
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
vendored
Normal file
|
@ -0,0 +1,548 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining an array node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinitionInterface
|
||||
{
|
||||
protected $performDeepMerging = true;
|
||||
protected $ignoreExtraKeys = false;
|
||||
protected $removeExtraKeys = true;
|
||||
protected $children = [];
|
||||
protected $prototype;
|
||||
protected $atLeastOne = false;
|
||||
protected $allowNewKeys = true;
|
||||
protected $key;
|
||||
protected $removeKeyItem;
|
||||
protected $addDefaults = false;
|
||||
protected $addDefaultChildren = false;
|
||||
protected $nodeBuilder;
|
||||
protected $normalizeKeys = true;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(?string $name, NodeParentInterface $parent = null)
|
||||
{
|
||||
parent::__construct($name, $parent);
|
||||
|
||||
$this->nullEquivalent = [];
|
||||
$this->trueEquivalent = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setBuilder(NodeBuilder $builder)
|
||||
{
|
||||
$this->nodeBuilder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function children()
|
||||
{
|
||||
return $this->getNodeBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a prototype for child nodes.
|
||||
*
|
||||
* @param string $type The type of node
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function prototype($type)
|
||||
{
|
||||
return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return VariableNodeDefinition
|
||||
*/
|
||||
public function variablePrototype()
|
||||
{
|
||||
return $this->prototype('variable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ScalarNodeDefinition
|
||||
*/
|
||||
public function scalarPrototype()
|
||||
{
|
||||
return $this->prototype('scalar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BooleanNodeDefinition
|
||||
*/
|
||||
public function booleanPrototype()
|
||||
{
|
||||
return $this->prototype('boolean');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IntegerNodeDefinition
|
||||
*/
|
||||
public function integerPrototype()
|
||||
{
|
||||
return $this->prototype('integer');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FloatNodeDefinition
|
||||
*/
|
||||
public function floatPrototype()
|
||||
{
|
||||
return $this->prototype('float');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function arrayPrototype()
|
||||
{
|
||||
return $this->prototype('array');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EnumNodeDefinition
|
||||
*/
|
||||
public function enumPrototype()
|
||||
{
|
||||
return $this->prototype('enum');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the default value if the node is not set in the configuration.
|
||||
*
|
||||
* This method is applicable to concrete nodes only (not to prototype nodes).
|
||||
* If this function has been called and the node is not set during the finalization
|
||||
* phase, it's default value will be derived from its children default values.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addDefaultsIfNotSet()
|
||||
{
|
||||
$this->addDefaults = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds children with a default value when none are defined.
|
||||
*
|
||||
* This method is applicable to prototype nodes only.
|
||||
*
|
||||
* @param int|string|array|null $children The number of children|The child name|The children names to be added
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addDefaultChildrenIfNoneSet($children = null)
|
||||
{
|
||||
$this->addDefaultChildren = $children;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires the node to have at least one element.
|
||||
*
|
||||
* This method is applicable to prototype nodes only.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function requiresAtLeastOneElement()
|
||||
{
|
||||
$this->atLeastOne = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disallows adding news keys in a subsequent configuration.
|
||||
*
|
||||
* If used all keys have to be defined in the same configuration file.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function disallowNewKeysInSubsequentConfigs()
|
||||
{
|
||||
$this->allowNewKeys = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a normalization rule for XML configurations.
|
||||
*
|
||||
* @param string $singular The key to remap
|
||||
* @param string $plural The plural of the key for irregular plurals
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function fixXmlConfig($singular, $plural = null)
|
||||
{
|
||||
$this->normalization()->remap($singular, $plural);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attribute which value is to be used as key.
|
||||
*
|
||||
* This is useful when you have an indexed array that should be an
|
||||
* associative array. You can select an item from within the array
|
||||
* to be the key of the particular item. For example, if "id" is the
|
||||
* "key", then:
|
||||
*
|
||||
* [
|
||||
* ['id' => 'my_name', 'foo' => 'bar'],
|
||||
* ];
|
||||
*
|
||||
* becomes
|
||||
*
|
||||
* [
|
||||
* 'my_name' => ['foo' => 'bar'],
|
||||
* ];
|
||||
*
|
||||
* If you'd like "'id' => 'my_name'" to still be present in the resulting
|
||||
* array, then you can set the second argument of this method to false.
|
||||
*
|
||||
* This method is applicable to prototype nodes only.
|
||||
*
|
||||
* @param string $name The name of the key
|
||||
* @param bool $removeKeyItem Whether or not the key item should be removed
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function useAttributeAsKey($name, $removeKeyItem = true)
|
||||
{
|
||||
$this->key = $name;
|
||||
$this->removeKeyItem = $removeKeyItem;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node can be unset.
|
||||
*
|
||||
* @param bool $allow
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function canBeUnset($allow = true)
|
||||
{
|
||||
$this->merge()->allowUnset($allow);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an "enabled" boolean to enable the current section.
|
||||
*
|
||||
* By default, the section is disabled. If any configuration is specified then
|
||||
* the node will be automatically enabled:
|
||||
*
|
||||
* enableableArrayNode: {enabled: true, ...} # The config is enabled & default values get overridden
|
||||
* enableableArrayNode: ~ # The config is enabled & use the default values
|
||||
* enableableArrayNode: true # The config is enabled & use the default values
|
||||
* enableableArrayNode: {other: value, ...} # The config is enabled & default values get overridden
|
||||
* enableableArrayNode: {enabled: false, ...} # The config is disabled
|
||||
* enableableArrayNode: false # The config is disabled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function canBeEnabled()
|
||||
{
|
||||
$this
|
||||
->addDefaultsIfNotSet()
|
||||
->treatFalseLike(['enabled' => false])
|
||||
->treatTrueLike(['enabled' => true])
|
||||
->treatNullLike(['enabled' => true])
|
||||
->beforeNormalization()
|
||||
->ifArray()
|
||||
->then(function ($v) {
|
||||
$v['enabled'] = $v['enabled'] ?? true;
|
||||
|
||||
return $v;
|
||||
})
|
||||
->end()
|
||||
->children()
|
||||
->booleanNode('enabled')
|
||||
->defaultFalse()
|
||||
;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an "enabled" boolean to enable the current section.
|
||||
*
|
||||
* By default, the section is enabled.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function canBeDisabled()
|
||||
{
|
||||
$this
|
||||
->addDefaultsIfNotSet()
|
||||
->treatFalseLike(['enabled' => false])
|
||||
->treatTrueLike(['enabled' => true])
|
||||
->treatNullLike(['enabled' => true])
|
||||
->children()
|
||||
->booleanNode('enabled')
|
||||
->defaultTrue()
|
||||
;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the deep merging of the node.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function performNoDeepMerging()
|
||||
{
|
||||
$this->performDeepMerging = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows extra config keys to be specified under an array without
|
||||
* throwing an exception.
|
||||
*
|
||||
* Those config values are ignored and removed from the resulting
|
||||
* array. This should be used only in special cases where you want
|
||||
* to send an entire configuration array through a special tree that
|
||||
* processes only part of the array.
|
||||
*
|
||||
* @param bool $remove Whether to remove the extra keys
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ignoreExtraKeys($remove = true)
|
||||
{
|
||||
$this->ignoreExtraKeys = true;
|
||||
$this->removeExtraKeys = $remove;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets key normalization.
|
||||
*
|
||||
* @param bool $bool Whether to enable key normalization
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function normalizeKeys($bool)
|
||||
{
|
||||
$this->normalizeKeys = (bool) $bool;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function append(NodeDefinition $node)
|
||||
{
|
||||
$this->children[$node->name] = $node->setParent($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a node builder to be used to add children and prototype.
|
||||
*
|
||||
* @return NodeBuilder The node builder
|
||||
*/
|
||||
protected function getNodeBuilder()
|
||||
{
|
||||
if (null === $this->nodeBuilder) {
|
||||
$this->nodeBuilder = new NodeBuilder();
|
||||
}
|
||||
|
||||
return $this->nodeBuilder->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createNode()
|
||||
{
|
||||
if (null === $this->prototype) {
|
||||
$node = new ArrayNode($this->name, $this->parent, $this->pathSeparator);
|
||||
|
||||
$this->validateConcreteNode($node);
|
||||
|
||||
$node->setAddIfNotSet($this->addDefaults);
|
||||
|
||||
foreach ($this->children as $child) {
|
||||
$child->parent = $node;
|
||||
$node->addChild($child->getNode());
|
||||
}
|
||||
} else {
|
||||
$node = new PrototypedArrayNode($this->name, $this->parent, $this->pathSeparator);
|
||||
|
||||
$this->validatePrototypeNode($node);
|
||||
|
||||
if (null !== $this->key) {
|
||||
$node->setKeyAttribute($this->key, $this->removeKeyItem);
|
||||
}
|
||||
|
||||
if (true === $this->atLeastOne || false === $this->allowEmptyValue) {
|
||||
$node->setMinNumberOfElements(1);
|
||||
}
|
||||
|
||||
if ($this->default) {
|
||||
$node->setDefaultValue($this->defaultValue);
|
||||
}
|
||||
|
||||
if (false !== $this->addDefaultChildren) {
|
||||
$node->setAddChildrenIfNoneSet($this->addDefaultChildren);
|
||||
if ($this->prototype instanceof static && null === $this->prototype->prototype) {
|
||||
$this->prototype->addDefaultsIfNotSet();
|
||||
}
|
||||
}
|
||||
|
||||
$this->prototype->parent = $node;
|
||||
$node->setPrototype($this->prototype->getNode());
|
||||
}
|
||||
|
||||
$node->setAllowNewKeys($this->allowNewKeys);
|
||||
$node->addEquivalentValue(null, $this->nullEquivalent);
|
||||
$node->addEquivalentValue(true, $this->trueEquivalent);
|
||||
$node->addEquivalentValue(false, $this->falseEquivalent);
|
||||
$node->setPerformDeepMerging($this->performDeepMerging);
|
||||
$node->setRequired($this->required);
|
||||
$node->setDeprecated($this->deprecationMessage);
|
||||
$node->setIgnoreExtraKeys($this->ignoreExtraKeys, $this->removeExtraKeys);
|
||||
$node->setNormalizeKeys($this->normalizeKeys);
|
||||
|
||||
if (null !== $this->normalization) {
|
||||
$node->setNormalizationClosures($this->normalization->before);
|
||||
$node->setXmlRemappings($this->normalization->remappings);
|
||||
}
|
||||
|
||||
if (null !== $this->merge) {
|
||||
$node->setAllowOverwrite($this->merge->allowOverwrite);
|
||||
$node->setAllowFalse($this->merge->allowFalse);
|
||||
}
|
||||
|
||||
if (null !== $this->validation) {
|
||||
$node->setFinalValidationClosures($this->validation->rules);
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the configuration of a concrete node.
|
||||
*
|
||||
* @throws InvalidDefinitionException
|
||||
*/
|
||||
protected function validateConcreteNode(ArrayNode $node)
|
||||
{
|
||||
$path = $node->getPath();
|
||||
|
||||
if (null !== $this->key) {
|
||||
throw new InvalidDefinitionException(sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s".', $path));
|
||||
}
|
||||
|
||||
if (false === $this->allowEmptyValue) {
|
||||
throw new InvalidDefinitionException(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s".', $path));
|
||||
}
|
||||
|
||||
if (true === $this->atLeastOne) {
|
||||
throw new InvalidDefinitionException(sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s".', $path));
|
||||
}
|
||||
|
||||
if ($this->default) {
|
||||
throw new InvalidDefinitionException(sprintf('->defaultValue() is not applicable to concrete nodes at path "%s".', $path));
|
||||
}
|
||||
|
||||
if (false !== $this->addDefaultChildren) {
|
||||
throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s".', $path));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the configuration of a prototype node.
|
||||
*
|
||||
* @throws InvalidDefinitionException
|
||||
*/
|
||||
protected function validatePrototypeNode(PrototypedArrayNode $node)
|
||||
{
|
||||
$path = $node->getPath();
|
||||
|
||||
if ($this->addDefaults) {
|
||||
throw new InvalidDefinitionException(sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s".', $path));
|
||||
}
|
||||
|
||||
if (false !== $this->addDefaultChildren) {
|
||||
if ($this->default) {
|
||||
throw new InvalidDefinitionException(sprintf('A default value and default children might not be used together at path "%s".', $path));
|
||||
}
|
||||
|
||||
if (null !== $this->key && (null === $this->addDefaultChildren || \is_int($this->addDefaultChildren) && $this->addDefaultChildren > 0)) {
|
||||
throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s".', $path));
|
||||
}
|
||||
|
||||
if (null === $this->key && (\is_string($this->addDefaultChildren) || \is_array($this->addDefaultChildren))) {
|
||||
throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s".', $path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeDefinition[]
|
||||
*/
|
||||
public function getChildNodeDefinitions()
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a node defined by the given $nodePath.
|
||||
*
|
||||
* @param string $nodePath The path of the node to find. e.g "doctrine.orm.mappings"
|
||||
*/
|
||||
public function find(string $nodePath): NodeDefinition
|
||||
{
|
||||
$firstPathSegment = (false === $pathSeparatorPos = strpos($nodePath, $this->pathSeparator))
|
||||
? $nodePath
|
||||
: substr($nodePath, 0, $pathSeparatorPos);
|
||||
|
||||
if (null === $node = ($this->children[$firstPathSegment] ?? null)) {
|
||||
throw new \RuntimeException(sprintf('Node with name "%s" does not exist in the current node "%s".', $firstPathSegment, $this->name));
|
||||
}
|
||||
|
||||
if (false === $pathSeparatorPos) {
|
||||
return $node;
|
||||
}
|
||||
|
||||
return $node->find(substr($nodePath, $pathSeparatorPos + \strlen($this->pathSeparator)));
|
||||
}
|
||||
}
|
53
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/BooleanNodeDefinition.php
vendored
Normal file
53
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/BooleanNodeDefinition.php
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\BooleanNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class BooleanNodeDefinition extends ScalarNodeDefinition
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(?string $name, NodeParentInterface $parent = null)
|
||||
{
|
||||
parent::__construct($name, $parent);
|
||||
|
||||
$this->nullEquivalent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a Node.
|
||||
*
|
||||
* @return BooleanNode The node
|
||||
*/
|
||||
protected function instantiateNode()
|
||||
{
|
||||
return new BooleanNode($this->name, $this->parent, $this->pathSeparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws InvalidDefinitionException
|
||||
*/
|
||||
public function cannotBeEmpty()
|
||||
{
|
||||
throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.');
|
||||
}
|
||||
}
|
25
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/BuilderAwareInterface.php
vendored
Normal file
25
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/BuilderAwareInterface.php
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* An interface that can be implemented by nodes which build other nodes.
|
||||
*
|
||||
* @author Roland Franssen <franssen.roland@gmail.com>
|
||||
*/
|
||||
interface BuilderAwareInterface
|
||||
{
|
||||
/**
|
||||
* Sets a custom children builder.
|
||||
*/
|
||||
public function setBuilder(NodeBuilder $builder);
|
||||
}
|
56
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/EnumNodeDefinition.php
vendored
Normal file
56
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/EnumNodeDefinition.php
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\EnumNode;
|
||||
|
||||
/**
|
||||
* Enum Node Definition.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class EnumNodeDefinition extends ScalarNodeDefinition
|
||||
{
|
||||
private $values;
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function values(array $values)
|
||||
{
|
||||
$values = array_unique($values);
|
||||
|
||||
if (empty($values)) {
|
||||
throw new \InvalidArgumentException('->values() must be called with at least one value.');
|
||||
}
|
||||
|
||||
$this->values = $values;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a Node.
|
||||
*
|
||||
* @return EnumNode The node
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function instantiateNode()
|
||||
{
|
||||
if (null === $this->values) {
|
||||
throw new \RuntimeException('You must call ->values() on enum nodes.');
|
||||
}
|
||||
|
||||
return new EnumNode($this->name, $this->parent, $this->values, $this->pathSeparator);
|
||||
}
|
||||
}
|
248
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/ExprBuilder.php
vendored
Normal file
248
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/ExprBuilder.php
vendored
Normal file
|
@ -0,0 +1,248 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
|
||||
|
||||
/**
|
||||
* This class builds an if expression.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*/
|
||||
class ExprBuilder
|
||||
{
|
||||
protected $node;
|
||||
public $ifPart;
|
||||
public $thenPart;
|
||||
|
||||
public function __construct(NodeDefinition $node)
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the expression as being always used.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function always(\Closure $then = null)
|
||||
{
|
||||
$this->ifPart = function ($v) { return true; };
|
||||
|
||||
if (null !== $then) {
|
||||
$this->thenPart = $then;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a closure to use as tests.
|
||||
*
|
||||
* The default one tests if the value is true.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifTrue(\Closure $closure = null)
|
||||
{
|
||||
if (null === $closure) {
|
||||
$closure = function ($v) { return true === $v; };
|
||||
}
|
||||
|
||||
$this->ifPart = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is a string.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifString()
|
||||
{
|
||||
$this->ifPart = function ($v) { return \is_string($v); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is null.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifNull()
|
||||
{
|
||||
$this->ifPart = function ($v) { return null === $v; };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is empty.
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function ifEmpty()
|
||||
{
|
||||
$this->ifPart = function ($v) { return empty($v); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is an array.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifArray()
|
||||
{
|
||||
$this->ifPart = function ($v) { return \is_array($v); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is in an array.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifInArray(array $array)
|
||||
{
|
||||
$this->ifPart = function ($v) use ($array) { return \in_array($v, $array, true); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is not in an array.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifNotInArray(array $array)
|
||||
{
|
||||
$this->ifPart = function ($v) use ($array) { return !\in_array($v, $array, true); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms variables of any type into an array.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function castToArray()
|
||||
{
|
||||
$this->ifPart = function ($v) { return !\is_array($v); };
|
||||
$this->thenPart = function ($v) { return [$v]; };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the closure to run if the test pass.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function then(\Closure $closure)
|
||||
{
|
||||
$this->thenPart = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a closure returning an empty array.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function thenEmptyArray()
|
||||
{
|
||||
$this->thenPart = function ($v) { return []; };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a closure marking the value as invalid at processing time.
|
||||
*
|
||||
* if you want to add the value of the node in your message just use a %s placeholder.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function thenInvalid($message)
|
||||
{
|
||||
$this->thenPart = function ($v) use ($message) { throw new \InvalidArgumentException(sprintf($message, json_encode($v))); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a closure unsetting this key of the array at processing time.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws UnsetKeyException
|
||||
*/
|
||||
public function thenUnset()
|
||||
{
|
||||
$this->thenPart = function ($v) { throw new UnsetKeyException('Unsetting key.'); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the related node.
|
||||
*
|
||||
* @return NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function end()
|
||||
{
|
||||
if (null === $this->ifPart) {
|
||||
throw new \RuntimeException('You must specify an if part.');
|
||||
}
|
||||
if (null === $this->thenPart) {
|
||||
throw new \RuntimeException('You must specify a then part.');
|
||||
}
|
||||
|
||||
return $this->node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the expressions.
|
||||
*
|
||||
* @param ExprBuilder[] $expressions An array of ExprBuilder instances to build
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function buildExpressions(array $expressions)
|
||||
{
|
||||
foreach ($expressions as $k => $expr) {
|
||||
if ($expr instanceof self) {
|
||||
$if = $expr->ifPart;
|
||||
$then = $expr->thenPart;
|
||||
$expressions[$k] = function ($v) use ($if, $then) {
|
||||
return $if($v) ? $then($v) : $v;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return $expressions;
|
||||
}
|
||||
}
|
32
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/FloatNodeDefinition.php
vendored
Normal file
32
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/FloatNodeDefinition.php
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\FloatNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a float node.
|
||||
*
|
||||
* @author Jeanmonod David <david.jeanmonod@gmail.com>
|
||||
*/
|
||||
class FloatNodeDefinition extends NumericNodeDefinition
|
||||
{
|
||||
/**
|
||||
* Instantiates a Node.
|
||||
*
|
||||
* @return FloatNode The node
|
||||
*/
|
||||
protected function instantiateNode()
|
||||
{
|
||||
return new FloatNode($this->name, $this->parent, $this->min, $this->max, $this->pathSeparator);
|
||||
}
|
||||
}
|
32
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/IntegerNodeDefinition.php
vendored
Normal file
32
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/IntegerNodeDefinition.php
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\IntegerNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining an integer node.
|
||||
*
|
||||
* @author Jeanmonod David <david.jeanmonod@gmail.com>
|
||||
*/
|
||||
class IntegerNodeDefinition extends NumericNodeDefinition
|
||||
{
|
||||
/**
|
||||
* Instantiates a Node.
|
||||
*
|
||||
* @return IntegerNode The node
|
||||
*/
|
||||
protected function instantiateNode()
|
||||
{
|
||||
return new IntegerNode($this->name, $this->parent, $this->min, $this->max, $this->pathSeparator);
|
||||
}
|
||||
}
|
67
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/MergeBuilder.php
vendored
Normal file
67
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/MergeBuilder.php
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This class builds merge conditions.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class MergeBuilder
|
||||
{
|
||||
protected $node;
|
||||
public $allowFalse = false;
|
||||
public $allowOverwrite = true;
|
||||
|
||||
public function __construct(NodeDefinition $node)
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node can be unset.
|
||||
*
|
||||
* @param bool $allow
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function allowUnset($allow = true)
|
||||
{
|
||||
$this->allowFalse = $allow;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node can be overwritten.
|
||||
*
|
||||
* @param bool $deny Whether the overwriting is forbidden or not
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function denyOverwrite($deny = true)
|
||||
{
|
||||
$this->allowOverwrite = !$deny;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the related node.
|
||||
*
|
||||
* @return NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition
|
||||
*/
|
||||
public function end()
|
||||
{
|
||||
return $this->node;
|
||||
}
|
||||
}
|
238
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/NodeBuilder.php
vendored
Normal file
238
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/NodeBuilder.php
vendored
Normal file
|
@ -0,0 +1,238 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for building a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class NodeBuilder implements NodeParentInterface
|
||||
{
|
||||
protected $parent;
|
||||
protected $nodeMapping;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->nodeMapping = [
|
||||
'variable' => VariableNodeDefinition::class,
|
||||
'scalar' => ScalarNodeDefinition::class,
|
||||
'boolean' => BooleanNodeDefinition::class,
|
||||
'integer' => IntegerNodeDefinition::class,
|
||||
'float' => FloatNodeDefinition::class,
|
||||
'array' => ArrayNodeDefinition::class,
|
||||
'enum' => EnumNodeDefinition::class,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent node.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParent(ParentNodeDefinitionInterface $parent = null)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child array node.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
*
|
||||
* @return ArrayNodeDefinition The child node
|
||||
*/
|
||||
public function arrayNode($name)
|
||||
{
|
||||
return $this->node($name, 'array');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child scalar node.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
*
|
||||
* @return ScalarNodeDefinition The child node
|
||||
*/
|
||||
public function scalarNode($name)
|
||||
{
|
||||
return $this->node($name, 'scalar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child Boolean node.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
*
|
||||
* @return BooleanNodeDefinition The child node
|
||||
*/
|
||||
public function booleanNode($name)
|
||||
{
|
||||
return $this->node($name, 'boolean');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child integer node.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
*
|
||||
* @return IntegerNodeDefinition The child node
|
||||
*/
|
||||
public function integerNode($name)
|
||||
{
|
||||
return $this->node($name, 'integer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child float node.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
*
|
||||
* @return FloatNodeDefinition The child node
|
||||
*/
|
||||
public function floatNode($name)
|
||||
{
|
||||
return $this->node($name, 'float');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child EnumNode.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return EnumNodeDefinition
|
||||
*/
|
||||
public function enumNode($name)
|
||||
{
|
||||
return $this->node($name, 'enum');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child variable node.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
*
|
||||
* @return VariableNodeDefinition The builder of the child node
|
||||
*/
|
||||
public function variableNode($name)
|
||||
{
|
||||
return $this->node($name, 'variable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent node.
|
||||
*
|
||||
* @return NodeDefinition&ParentNodeDefinitionInterface The parent node
|
||||
*/
|
||||
public function end()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child node.
|
||||
*
|
||||
* @param string|null $name The name of the node
|
||||
* @param string $type The type of the node
|
||||
*
|
||||
* @return NodeDefinition The child node
|
||||
*
|
||||
* @throws \RuntimeException When the node type is not registered
|
||||
* @throws \RuntimeException When the node class is not found
|
||||
*/
|
||||
public function node($name, $type)
|
||||
{
|
||||
$class = $this->getNodeClass($type);
|
||||
|
||||
$node = new $class($name);
|
||||
|
||||
$this->append($node);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a node definition.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* $node = new ArrayNodeDefinition('name')
|
||||
* ->children()
|
||||
* ->scalarNode('foo')->end()
|
||||
* ->scalarNode('baz')->end()
|
||||
* ->append($this->getBarNodeDefinition())
|
||||
* ->end()
|
||||
* ;
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function append(NodeDefinition $node)
|
||||
{
|
||||
if ($node instanceof BuilderAwareInterface) {
|
||||
$builder = clone $this;
|
||||
$builder->setParent(null);
|
||||
$node->setBuilder($builder);
|
||||
}
|
||||
|
||||
if (null !== $this->parent) {
|
||||
$this->parent->append($node);
|
||||
// Make this builder the node parent to allow for a fluid interface
|
||||
$node->setParent($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds or overrides a node Type.
|
||||
*
|
||||
* @param string $type The name of the type
|
||||
* @param string $class The fully qualified name the node definition class
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNodeClass($type, $class)
|
||||
{
|
||||
$this->nodeMapping[strtolower($type)] = $class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class name of the node definition.
|
||||
*
|
||||
* @param string $type The node type
|
||||
*
|
||||
* @return string The node definition class name
|
||||
*
|
||||
* @throws \RuntimeException When the node type is not registered
|
||||
* @throws \RuntimeException When the node class is not found
|
||||
*/
|
||||
protected function getNodeClass($type)
|
||||
{
|
||||
$type = strtolower($type);
|
||||
|
||||
if (!isset($this->nodeMapping[$type])) {
|
||||
throw new \RuntimeException(sprintf('The node type "%s" is not registered.', $type));
|
||||
}
|
||||
|
||||
$class = $this->nodeMapping[$type];
|
||||
|
||||
if (!class_exists($class)) {
|
||||
throw new \RuntimeException(sprintf('The node class "%s" does not exist.', $class));
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
}
|
375
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/NodeDefinition.php
vendored
Normal file
375
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/NodeDefinition.php
vendored
Normal file
|
@ -0,0 +1,375 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\BaseNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
abstract class NodeDefinition implements NodeParentInterface
|
||||
{
|
||||
protected $name;
|
||||
protected $normalization;
|
||||
protected $validation;
|
||||
protected $defaultValue;
|
||||
protected $default = false;
|
||||
protected $required = false;
|
||||
protected $deprecationMessage = null;
|
||||
protected $merge;
|
||||
protected $allowEmptyValue = true;
|
||||
protected $nullEquivalent;
|
||||
protected $trueEquivalent = true;
|
||||
protected $falseEquivalent = false;
|
||||
protected $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR;
|
||||
protected $parent;
|
||||
protected $attributes = [];
|
||||
|
||||
public function __construct(?string $name, NodeParentInterface $parent = null)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent node.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParent(NodeParentInterface $parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets info message.
|
||||
*
|
||||
* @param string $info The info text
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function info($info)
|
||||
{
|
||||
return $this->attribute('info', $info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets example configuration.
|
||||
*
|
||||
* @param string|array $example
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function example($example)
|
||||
{
|
||||
return $this->attribute('example', $example);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an attribute on the node.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function attribute($key, $value)
|
||||
{
|
||||
$this->attributes[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent node.
|
||||
*
|
||||
* @return NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null The builder of the parent node
|
||||
*/
|
||||
public function end()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the node.
|
||||
*
|
||||
* @param bool $forceRootNode Whether to force this node as the root node
|
||||
*
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getNode($forceRootNode = false)
|
||||
{
|
||||
if ($forceRootNode) {
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
if (null !== $this->normalization) {
|
||||
$this->normalization->before = ExprBuilder::buildExpressions($this->normalization->before);
|
||||
}
|
||||
|
||||
if (null !== $this->validation) {
|
||||
$this->validation->rules = ExprBuilder::buildExpressions($this->validation->rules);
|
||||
}
|
||||
|
||||
$node = $this->createNode();
|
||||
if ($node instanceof BaseNode) {
|
||||
$node->setAttributes($this->attributes);
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default value.
|
||||
*
|
||||
* @param mixed $value The default value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function defaultValue($value)
|
||||
{
|
||||
$this->default = true;
|
||||
$this->defaultValue = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node as required.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function isRequired()
|
||||
{
|
||||
$this->required = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node as deprecated.
|
||||
*
|
||||
* You can use %node% and %path% placeholders in your message to display,
|
||||
* respectively, the node name and its complete path.
|
||||
*
|
||||
* @param string $message Deprecation message
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDeprecated($message = 'The child node "%node%" at path "%path%" is deprecated.')
|
||||
{
|
||||
$this->deprecationMessage = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the equivalent value used when the node contains null.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function treatNullLike($value)
|
||||
{
|
||||
$this->nullEquivalent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the equivalent value used when the node contains true.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function treatTrueLike($value)
|
||||
{
|
||||
$this->trueEquivalent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the equivalent value used when the node contains false.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function treatFalseLike($value)
|
||||
{
|
||||
$this->falseEquivalent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets null as the default value.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function defaultNull()
|
||||
{
|
||||
return $this->defaultValue(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets true as the default value.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function defaultTrue()
|
||||
{
|
||||
return $this->defaultValue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets false as the default value.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function defaultFalse()
|
||||
{
|
||||
return $this->defaultValue(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an expression to run before the normalization.
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function beforeNormalization()
|
||||
{
|
||||
return $this->normalization()->before();
|
||||
}
|
||||
|
||||
/**
|
||||
* Denies the node value being empty.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function cannotBeEmpty()
|
||||
{
|
||||
$this->allowEmptyValue = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an expression to run for the validation.
|
||||
*
|
||||
* The expression receives the value of the node and must return it. It can
|
||||
* modify it.
|
||||
* An exception should be thrown when the node is not valid.
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
return $this->validation()->rule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node can be overwritten.
|
||||
*
|
||||
* @param bool $deny Whether the overwriting is forbidden or not
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function cannotBeOverwritten($deny = true)
|
||||
{
|
||||
$this->merge()->denyOverwrite($deny);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the builder for validation rules.
|
||||
*
|
||||
* @return ValidationBuilder
|
||||
*/
|
||||
protected function validation()
|
||||
{
|
||||
if (null === $this->validation) {
|
||||
$this->validation = new ValidationBuilder($this);
|
||||
}
|
||||
|
||||
return $this->validation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the builder for merging rules.
|
||||
*
|
||||
* @return MergeBuilder
|
||||
*/
|
||||
protected function merge()
|
||||
{
|
||||
if (null === $this->merge) {
|
||||
$this->merge = new MergeBuilder($this);
|
||||
}
|
||||
|
||||
return $this->merge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the builder for normalization rules.
|
||||
*
|
||||
* @return NormalizationBuilder
|
||||
*/
|
||||
protected function normalization()
|
||||
{
|
||||
if (null === $this->normalization) {
|
||||
$this->normalization = new NormalizationBuilder($this);
|
||||
}
|
||||
|
||||
return $this->normalization;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate and configure the node according to this definition.
|
||||
*
|
||||
* @return NodeInterface The node instance
|
||||
*
|
||||
* @throws InvalidDefinitionException When the definition is invalid
|
||||
*/
|
||||
abstract protected function createNode();
|
||||
|
||||
/**
|
||||
* Set PathSeparator to use.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPathSeparator(string $separator)
|
||||
{
|
||||
if ($this instanceof ParentNodeDefinitionInterface) {
|
||||
if (method_exists($this, 'getChildNodeDefinitions')) {
|
||||
foreach ($this->getChildNodeDefinitions() as $child) {
|
||||
$child->setPathSeparator($separator);
|
||||
}
|
||||
} else {
|
||||
@trigger_error(sprintf('Not implementing the "%s::getChildNodeDefinitions()" method in "%s" is deprecated since Symfony 4.1.', ParentNodeDefinitionInterface::class, static::class), \E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
$this->pathSeparator = $separator;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
21
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/NodeParentInterface.php
vendored
Normal file
21
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/NodeParentInterface.php
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* An interface that must be implemented by all node parents.
|
||||
*
|
||||
* @author Victor Berchet <victor@suumit.com>
|
||||
*/
|
||||
interface NodeParentInterface
|
||||
{
|
||||
}
|
60
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/NormalizationBuilder.php
vendored
Normal file
60
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/NormalizationBuilder.php
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This class builds normalization conditions.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class NormalizationBuilder
|
||||
{
|
||||
protected $node;
|
||||
public $before = [];
|
||||
public $remappings = [];
|
||||
|
||||
public function __construct(NodeDefinition $node)
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a key to remap to its plural form.
|
||||
*
|
||||
* @param string $key The key to remap
|
||||
* @param string $plural The plural of the key in case of irregular plural
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function remap($key, $plural = null)
|
||||
{
|
||||
$this->remappings[] = [$key, null === $plural ? $key.'s' : $plural];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a closure to run before the normalization or an expression builder to build it if null is provided.
|
||||
*
|
||||
* @return ExprBuilder|$this
|
||||
*/
|
||||
public function before(\Closure $closure = null)
|
||||
{
|
||||
if (null !== $closure) {
|
||||
$this->before[] = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this->before[] = new ExprBuilder($this->node);
|
||||
}
|
||||
}
|
73
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/NumericNodeDefinition.php
vendored
Normal file
73
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/NumericNodeDefinition.php
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
|
||||
/**
|
||||
* Abstract class that contains common code of integer and float node definitions.
|
||||
*
|
||||
* @author David Jeanmonod <david.jeanmonod@gmail.com>
|
||||
*/
|
||||
abstract class NumericNodeDefinition extends ScalarNodeDefinition
|
||||
{
|
||||
protected $min;
|
||||
protected $max;
|
||||
|
||||
/**
|
||||
* Ensures that the value is smaller than the given reference.
|
||||
*
|
||||
* @param mixed $max
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException when the constraint is inconsistent
|
||||
*/
|
||||
public function max($max)
|
||||
{
|
||||
if (isset($this->min) && $this->min > $max) {
|
||||
throw new \InvalidArgumentException(sprintf('You cannot define a max(%s) as you already have a min(%s).', $max, $this->min));
|
||||
}
|
||||
$this->max = $max;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the value is bigger than the given reference.
|
||||
*
|
||||
* @param mixed $min
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException when the constraint is inconsistent
|
||||
*/
|
||||
public function min($min)
|
||||
{
|
||||
if (isset($this->max) && $this->max < $min) {
|
||||
throw new \InvalidArgumentException(sprintf('You cannot define a min(%s) as you already have a max(%s).', $min, $this->max));
|
||||
}
|
||||
$this->min = $min;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws InvalidDefinitionException
|
||||
*/
|
||||
public function cannotBeEmpty()
|
||||
{
|
||||
throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to NumericNodeDefinition.');
|
||||
}
|
||||
}
|
46
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/ParentNodeDefinitionInterface.php
vendored
Normal file
46
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/ParentNodeDefinitionInterface.php
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* An interface that must be implemented by nodes which can have children.
|
||||
*
|
||||
* @author Victor Berchet <victor@suumit.com>
|
||||
*
|
||||
* @method NodeDefinition[] getChildNodeDefinitions() Gets the child node definitions - not implementing it is deprecated since Symfony 4.2
|
||||
*/
|
||||
interface ParentNodeDefinitionInterface extends BuilderAwareInterface
|
||||
{
|
||||
/**
|
||||
* Returns a builder to add children nodes.
|
||||
*
|
||||
* @return NodeBuilder
|
||||
*/
|
||||
public function children();
|
||||
|
||||
/**
|
||||
* Appends a node definition.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* $node = $parentNode
|
||||
* ->children()
|
||||
* ->scalarNode('foo')->end()
|
||||
* ->scalarNode('baz')->end()
|
||||
* ->append($this->getBarNodeDefinition())
|
||||
* ->end()
|
||||
* ;
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function append(NodeDefinition $node);
|
||||
}
|
32
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/ScalarNodeDefinition.php
vendored
Normal file
32
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/ScalarNodeDefinition.php
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ScalarNodeDefinition extends VariableNodeDefinition
|
||||
{
|
||||
/**
|
||||
* Instantiate a Node.
|
||||
*
|
||||
* @return ScalarNode The node
|
||||
*/
|
||||
protected function instantiateNode()
|
||||
{
|
||||
return new ScalarNode($this->name, $this->parent, $this->pathSeparator);
|
||||
}
|
||||
}
|
106
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/TreeBuilder.php
vendored
Normal file
106
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/TreeBuilder.php
vendored
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\TreeWithoutRootNodeException;
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
|
||||
/**
|
||||
* This is the entry class for building a config tree.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class TreeBuilder implements NodeParentInterface
|
||||
{
|
||||
protected $tree;
|
||||
protected $root;
|
||||
|
||||
public function __construct(string $name = null, string $type = 'array', NodeBuilder $builder = null)
|
||||
{
|
||||
if (null === $name) {
|
||||
@trigger_error('A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.', \E_USER_DEPRECATED);
|
||||
} else {
|
||||
$builder = $builder ?? new NodeBuilder();
|
||||
$this->root = $builder->node($name, $type)->setParent($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the root node.
|
||||
*
|
||||
* @param string $name The name of the root node
|
||||
* @param string $type The type of the root node
|
||||
*
|
||||
* @return ArrayNodeDefinition|NodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array')
|
||||
*
|
||||
* @throws \RuntimeException When the node type is not supported
|
||||
*
|
||||
* @deprecated since Symfony 4.3, pass the root name to the constructor instead
|
||||
*/
|
||||
public function root($name, $type = 'array', NodeBuilder $builder = null)
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method called for the "%s" configuration is deprecated since Symfony 4.3, pass the root name to the constructor instead.', __METHOD__, $name), \E_USER_DEPRECATED);
|
||||
|
||||
$builder = $builder ?? new NodeBuilder();
|
||||
|
||||
return $this->root = $builder->node($name, $type)->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeDefinition|ArrayNodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array')
|
||||
*/
|
||||
public function getRootNode(): NodeDefinition
|
||||
{
|
||||
if (null === $this->root) {
|
||||
throw new \RuntimeException(sprintf('Calling "%s()" before creating the root node is not supported, migrate to the new constructor signature instead.', __METHOD__));
|
||||
}
|
||||
|
||||
return $this->root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the tree.
|
||||
*
|
||||
* @return NodeInterface
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function buildTree()
|
||||
{
|
||||
$this->assertTreeHasRootNode();
|
||||
if (null !== $this->tree) {
|
||||
return $this->tree;
|
||||
}
|
||||
|
||||
return $this->tree = $this->root->getNode(true);
|
||||
}
|
||||
|
||||
public function setPathSeparator(string $separator)
|
||||
{
|
||||
$this->assertTreeHasRootNode();
|
||||
|
||||
// unset last built as changing path separator changes all nodes
|
||||
$this->tree = null;
|
||||
|
||||
$this->root->setPathSeparator($separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \RuntimeException if root node is not defined
|
||||
*/
|
||||
private function assertTreeHasRootNode()
|
||||
{
|
||||
if (null === $this->root) {
|
||||
throw new TreeWithoutRootNodeException('The configuration tree has no root node.');
|
||||
}
|
||||
}
|
||||
}
|
44
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/ValidationBuilder.php
vendored
Normal file
44
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/ValidationBuilder.php
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This class builds validation conditions.
|
||||
*
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*/
|
||||
class ValidationBuilder
|
||||
{
|
||||
protected $node;
|
||||
public $rules = [];
|
||||
|
||||
public function __construct(NodeDefinition $node)
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a closure to run as normalization or an expression builder to build it if null is provided.
|
||||
*
|
||||
* @return ExprBuilder|$this
|
||||
*/
|
||||
public function rule(\Closure $closure = null)
|
||||
{
|
||||
if (null !== $closure) {
|
||||
$this->rules[] = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this->rules[] = new ExprBuilder($this->node);
|
||||
}
|
||||
}
|
65
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/VariableNodeDefinition.php
vendored
Normal file
65
admin/phpMyAdmin/vendor/symfony/config/Definition/Builder/VariableNodeDefinition.php
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\VariableNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class VariableNodeDefinition extends NodeDefinition
|
||||
{
|
||||
/**
|
||||
* Instantiate a Node.
|
||||
*
|
||||
* @return VariableNode The node
|
||||
*/
|
||||
protected function instantiateNode()
|
||||
{
|
||||
return new VariableNode($this->name, $this->parent, $this->pathSeparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createNode()
|
||||
{
|
||||
$node = $this->instantiateNode();
|
||||
|
||||
if (null !== $this->normalization) {
|
||||
$node->setNormalizationClosures($this->normalization->before);
|
||||
}
|
||||
|
||||
if (null !== $this->merge) {
|
||||
$node->setAllowOverwrite($this->merge->allowOverwrite);
|
||||
}
|
||||
|
||||
if (true === $this->default) {
|
||||
$node->setDefaultValue($this->defaultValue);
|
||||
}
|
||||
|
||||
$node->setAllowEmptyValue($this->allowEmptyValue);
|
||||
$node->addEquivalentValue(null, $this->nullEquivalent);
|
||||
$node->addEquivalentValue(true, $this->trueEquivalent);
|
||||
$node->addEquivalentValue(false, $this->falseEquivalent);
|
||||
$node->setRequired($this->required);
|
||||
$node->setDeprecated($this->deprecationMessage);
|
||||
|
||||
if (null !== $this->validation) {
|
||||
$node->setFinalValidationClosures($this->validation->rules);
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
}
|
27
admin/phpMyAdmin/vendor/symfony/config/Definition/ConfigurationInterface.php
vendored
Normal file
27
admin/phpMyAdmin/vendor/symfony/config/Definition/ConfigurationInterface.php
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
/**
|
||||
* Configuration interface.
|
||||
*
|
||||
* @author Victor Berchet <victor@suumit.com>
|
||||
*/
|
||||
interface ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* Generates the configuration tree builder.
|
||||
*
|
||||
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
|
||||
*/
|
||||
public function getConfigTreeBuilder();
|
||||
}
|
305
admin/phpMyAdmin/vendor/symfony/config/Definition/Dumper/XmlReferenceDumper.php
vendored
Normal file
305
admin/phpMyAdmin/vendor/symfony/config/Definition/Dumper/XmlReferenceDumper.php
vendored
Normal file
|
@ -0,0 +1,305 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Dumper;
|
||||
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\BaseNode;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\Config\Definition\EnumNode;
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||
|
||||
/**
|
||||
* Dumps an XML reference configuration for the given configuration/node instance.
|
||||
*
|
||||
* @author Wouter J <waldio.webdesign@gmail.com>
|
||||
*/
|
||||
class XmlReferenceDumper
|
||||
{
|
||||
private $reference;
|
||||
|
||||
public function dump(ConfigurationInterface $configuration, $namespace = null)
|
||||
{
|
||||
return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree(), $namespace);
|
||||
}
|
||||
|
||||
public function dumpNode(NodeInterface $node, $namespace = null)
|
||||
{
|
||||
$this->reference = '';
|
||||
$this->writeNode($node, 0, true, $namespace);
|
||||
$ref = $this->reference;
|
||||
$this->reference = null;
|
||||
|
||||
return $ref;
|
||||
}
|
||||
|
||||
private function writeNode(NodeInterface $node, int $depth = 0, bool $root = false, string $namespace = null)
|
||||
{
|
||||
$rootName = ($root ? 'config' : $node->getName());
|
||||
$rootNamespace = ($namespace ?: ($root ? 'http://example.org/schema/dic/'.$node->getName() : null));
|
||||
|
||||
// xml remapping
|
||||
if ($node->getParent()) {
|
||||
$remapping = array_filter($node->getParent()->getXmlRemappings(), function ($mapping) use ($rootName) {
|
||||
return $rootName === $mapping[1];
|
||||
});
|
||||
|
||||
if (\count($remapping)) {
|
||||
[$singular] = current($remapping);
|
||||
$rootName = $singular;
|
||||
}
|
||||
}
|
||||
$rootName = str_replace('_', '-', $rootName);
|
||||
|
||||
$rootAttributes = [];
|
||||
$rootAttributeComments = [];
|
||||
$rootChildren = [];
|
||||
$rootComments = [];
|
||||
|
||||
if ($node instanceof ArrayNode) {
|
||||
$children = $node->getChildren();
|
||||
|
||||
// comments about the root node
|
||||
if ($rootInfo = $node->getInfo()) {
|
||||
$rootComments[] = $rootInfo;
|
||||
}
|
||||
|
||||
if ($rootNamespace) {
|
||||
$rootComments[] = 'Namespace: '.$rootNamespace;
|
||||
}
|
||||
|
||||
// render prototyped nodes
|
||||
if ($node instanceof PrototypedArrayNode) {
|
||||
$prototype = $node->getPrototype();
|
||||
|
||||
$info = 'prototype';
|
||||
if (null !== $prototype->getInfo()) {
|
||||
$info .= ': '.$prototype->getInfo();
|
||||
}
|
||||
array_unshift($rootComments, $info);
|
||||
|
||||
if ($key = $node->getKeyAttribute()) {
|
||||
$rootAttributes[$key] = str_replace('-', ' ', $rootName).' '.$key;
|
||||
}
|
||||
|
||||
if ($prototype instanceof PrototypedArrayNode) {
|
||||
$prototype->setName($key ?? '');
|
||||
$children = [$key => $prototype];
|
||||
} elseif ($prototype instanceof ArrayNode) {
|
||||
$children = $prototype->getChildren();
|
||||
} else {
|
||||
if ($prototype->hasDefaultValue()) {
|
||||
$prototypeValue = $prototype->getDefaultValue();
|
||||
} else {
|
||||
switch (\get_class($prototype)) {
|
||||
case 'Symfony\Component\Config\Definition\ScalarNode':
|
||||
$prototypeValue = 'scalar value';
|
||||
break;
|
||||
|
||||
case 'Symfony\Component\Config\Definition\FloatNode':
|
||||
case 'Symfony\Component\Config\Definition\IntegerNode':
|
||||
$prototypeValue = 'numeric value';
|
||||
break;
|
||||
|
||||
case 'Symfony\Component\Config\Definition\BooleanNode':
|
||||
$prototypeValue = 'true|false';
|
||||
break;
|
||||
|
||||
case 'Symfony\Component\Config\Definition\EnumNode':
|
||||
$prototypeValue = implode('|', array_map('json_encode', $prototype->getValues()));
|
||||
break;
|
||||
|
||||
default:
|
||||
$prototypeValue = 'value';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get attributes and elements
|
||||
foreach ($children as $child) {
|
||||
if ($child instanceof ArrayNode) {
|
||||
// get elements
|
||||
$rootChildren[] = $child;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// get attributes
|
||||
|
||||
// metadata
|
||||
$name = str_replace('_', '-', $child->getName());
|
||||
$value = '%%%%not_defined%%%%'; // use a string which isn't used in the normal world
|
||||
|
||||
// comments
|
||||
$comments = [];
|
||||
if ($child instanceof BaseNode && $info = $child->getInfo()) {
|
||||
$comments[] = $info;
|
||||
}
|
||||
|
||||
if ($child instanceof BaseNode && $example = $child->getExample()) {
|
||||
$comments[] = 'Example: '.$example;
|
||||
}
|
||||
|
||||
if ($child->isRequired()) {
|
||||
$comments[] = 'Required';
|
||||
}
|
||||
|
||||
if ($child instanceof BaseNode && $child->isDeprecated()) {
|
||||
$comments[] = sprintf('Deprecated (%s)', $child->getDeprecationMessage($child->getName(), $node->getPath()));
|
||||
}
|
||||
|
||||
if ($child instanceof EnumNode) {
|
||||
$comments[] = 'One of '.implode('; ', array_map('json_encode', $child->getValues()));
|
||||
}
|
||||
|
||||
if (\count($comments)) {
|
||||
$rootAttributeComments[$name] = implode(";\n", $comments);
|
||||
}
|
||||
|
||||
// default values
|
||||
if ($child->hasDefaultValue()) {
|
||||
$value = $child->getDefaultValue();
|
||||
}
|
||||
|
||||
// append attribute
|
||||
$rootAttributes[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// render comments
|
||||
|
||||
// root node comment
|
||||
if (\count($rootComments)) {
|
||||
foreach ($rootComments as $comment) {
|
||||
$this->writeLine('<!-- '.$comment.' -->', $depth);
|
||||
}
|
||||
}
|
||||
|
||||
// attribute comments
|
||||
if (\count($rootAttributeComments)) {
|
||||
foreach ($rootAttributeComments as $attrName => $comment) {
|
||||
$commentDepth = $depth + 4 + \strlen($attrName) + 2;
|
||||
$commentLines = explode("\n", $comment);
|
||||
$multiline = (\count($commentLines) > 1);
|
||||
$comment = implode(\PHP_EOL.str_repeat(' ', $commentDepth), $commentLines);
|
||||
|
||||
if ($multiline) {
|
||||
$this->writeLine('<!--', $depth);
|
||||
$this->writeLine($attrName.': '.$comment, $depth + 4);
|
||||
$this->writeLine('-->', $depth);
|
||||
} else {
|
||||
$this->writeLine('<!-- '.$attrName.': '.$comment.' -->', $depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// render start tag + attributes
|
||||
$rootIsVariablePrototype = isset($prototypeValue);
|
||||
$rootIsEmptyTag = (0 === \count($rootChildren) && !$rootIsVariablePrototype);
|
||||
$rootOpenTag = '<'.$rootName;
|
||||
if (1 >= ($attributesCount = \count($rootAttributes))) {
|
||||
if (1 === $attributesCount) {
|
||||
$rootOpenTag .= sprintf(' %s="%s"', current(array_keys($rootAttributes)), $this->writeValue(current($rootAttributes)));
|
||||
}
|
||||
|
||||
$rootOpenTag .= $rootIsEmptyTag ? ' />' : '>';
|
||||
|
||||
if ($rootIsVariablePrototype) {
|
||||
$rootOpenTag .= $prototypeValue.'</'.$rootName.'>';
|
||||
}
|
||||
|
||||
$this->writeLine($rootOpenTag, $depth);
|
||||
} else {
|
||||
$this->writeLine($rootOpenTag, $depth);
|
||||
|
||||
$i = 1;
|
||||
|
||||
foreach ($rootAttributes as $attrName => $attrValue) {
|
||||
$attr = sprintf('%s="%s"', $attrName, $this->writeValue($attrValue));
|
||||
|
||||
$this->writeLine($attr, $depth + 4);
|
||||
|
||||
if ($attributesCount === $i++) {
|
||||
$this->writeLine($rootIsEmptyTag ? '/>' : '>', $depth);
|
||||
|
||||
if ($rootIsVariablePrototype) {
|
||||
$rootOpenTag .= $prototypeValue.'</'.$rootName.'>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// render children tags
|
||||
foreach ($rootChildren as $child) {
|
||||
$this->writeLine('');
|
||||
$this->writeNode($child, $depth + 4);
|
||||
}
|
||||
|
||||
// render end tag
|
||||
if (!$rootIsEmptyTag && !$rootIsVariablePrototype) {
|
||||
$this->writeLine('');
|
||||
|
||||
$rootEndTag = '</'.$rootName.'>';
|
||||
$this->writeLine($rootEndTag, $depth);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a single config reference line.
|
||||
*/
|
||||
private function writeLine(string $text, int $indent = 0)
|
||||
{
|
||||
$indent = \strlen($text) + $indent;
|
||||
$format = '%'.$indent.'s';
|
||||
|
||||
$this->reference .= sprintf($format, $text).\PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the string conversion of the value.
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
private function writeValue($value): string
|
||||
{
|
||||
if ('%%%%not_defined%%%%' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (\is_string($value) || is_numeric($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (false === $value) {
|
||||
return 'false';
|
||||
}
|
||||
|
||||
if (true === $value) {
|
||||
return 'true';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
if (empty($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (\is_array($value)) {
|
||||
return implode(',', $value);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
250
admin/phpMyAdmin/vendor/symfony/config/Definition/Dumper/YamlReferenceDumper.php
vendored
Normal file
250
admin/phpMyAdmin/vendor/symfony/config/Definition/Dumper/YamlReferenceDumper.php
vendored
Normal file
|
@ -0,0 +1,250 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Dumper;
|
||||
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\BaseNode;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\Config\Definition\EnumNode;
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
use Symfony\Component\Config\Definition\VariableNode;
|
||||
use Symfony\Component\Yaml\Inline;
|
||||
|
||||
/**
|
||||
* Dumps a Yaml reference configuration for the given configuration/node instance.
|
||||
*
|
||||
* @author Kevin Bond <kevinbond@gmail.com>
|
||||
*/
|
||||
class YamlReferenceDumper
|
||||
{
|
||||
private $reference;
|
||||
|
||||
public function dump(ConfigurationInterface $configuration)
|
||||
{
|
||||
return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree());
|
||||
}
|
||||
|
||||
public function dumpAtPath(ConfigurationInterface $configuration, $path)
|
||||
{
|
||||
$rootNode = $node = $configuration->getConfigTreeBuilder()->buildTree();
|
||||
|
||||
foreach (explode('.', $path) as $step) {
|
||||
if (!$node instanceof ArrayNode) {
|
||||
throw new \UnexpectedValueException(sprintf('Unable to find node at path "%s.%s".', $rootNode->getName(), $path));
|
||||
}
|
||||
|
||||
/** @var NodeInterface[] $children */
|
||||
$children = $node instanceof PrototypedArrayNode ? $this->getPrototypeChildren($node) : $node->getChildren();
|
||||
|
||||
foreach ($children as $child) {
|
||||
if ($child->getName() === $step) {
|
||||
$node = $child;
|
||||
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException(sprintf('Unable to find node at path "%s.%s".', $rootNode->getName(), $path));
|
||||
}
|
||||
|
||||
return $this->dumpNode($node);
|
||||
}
|
||||
|
||||
public function dumpNode(NodeInterface $node)
|
||||
{
|
||||
$this->reference = '';
|
||||
$this->writeNode($node);
|
||||
$ref = $this->reference;
|
||||
$this->reference = null;
|
||||
|
||||
return $ref;
|
||||
}
|
||||
|
||||
private function writeNode(NodeInterface $node, NodeInterface $parentNode = null, int $depth = 0, bool $prototypedArray = false)
|
||||
{
|
||||
$comments = [];
|
||||
$default = '';
|
||||
$defaultArray = null;
|
||||
$children = null;
|
||||
$example = null;
|
||||
if ($node instanceof BaseNode) {
|
||||
$example = $node->getExample();
|
||||
}
|
||||
|
||||
// defaults
|
||||
if ($node instanceof ArrayNode) {
|
||||
$children = $node->getChildren();
|
||||
|
||||
if ($node instanceof PrototypedArrayNode) {
|
||||
$children = $this->getPrototypeChildren($node);
|
||||
}
|
||||
|
||||
if (!$children) {
|
||||
if ($node->hasDefaultValue() && \count($defaultArray = $node->getDefaultValue())) {
|
||||
$default = '';
|
||||
} elseif (!\is_array($example)) {
|
||||
$default = '[]';
|
||||
}
|
||||
}
|
||||
} elseif ($node instanceof EnumNode) {
|
||||
$comments[] = 'One of '.implode('; ', array_map('json_encode', $node->getValues()));
|
||||
$default = $node->hasDefaultValue() ? Inline::dump($node->getDefaultValue()) : '~';
|
||||
} elseif (VariableNode::class === \get_class($node) && \is_array($example)) {
|
||||
// If there is an array example, we are sure we dont need to print a default value
|
||||
$default = '';
|
||||
} else {
|
||||
$default = '~';
|
||||
|
||||
if ($node->hasDefaultValue()) {
|
||||
$default = $node->getDefaultValue();
|
||||
|
||||
if (\is_array($default)) {
|
||||
if (\count($defaultArray = $node->getDefaultValue())) {
|
||||
$default = '';
|
||||
} elseif (!\is_array($example)) {
|
||||
$default = '[]';
|
||||
}
|
||||
} else {
|
||||
$default = Inline::dump($default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// required?
|
||||
if ($node->isRequired()) {
|
||||
$comments[] = 'Required';
|
||||
}
|
||||
|
||||
// deprecated?
|
||||
if ($node instanceof BaseNode && $node->isDeprecated()) {
|
||||
$comments[] = sprintf('Deprecated (%s)', $node->getDeprecationMessage($node->getName(), $parentNode ? $parentNode->getPath() : $node->getPath()));
|
||||
}
|
||||
|
||||
// example
|
||||
if ($example && !\is_array($example)) {
|
||||
$comments[] = 'Example: '.Inline::dump($example);
|
||||
}
|
||||
|
||||
$default = '' != (string) $default ? ' '.$default : '';
|
||||
$comments = \count($comments) ? '# '.implode(', ', $comments) : '';
|
||||
|
||||
$key = $prototypedArray ? '-' : $node->getName().':';
|
||||
$text = rtrim(sprintf('%-21s%s %s', $key, $default, $comments), ' ');
|
||||
|
||||
if ($node instanceof BaseNode && $info = $node->getInfo()) {
|
||||
$this->writeLine('');
|
||||
// indenting multi-line info
|
||||
$info = str_replace("\n", sprintf("\n%".($depth * 4).'s# ', ' '), $info);
|
||||
$this->writeLine('# '.$info, $depth * 4);
|
||||
}
|
||||
|
||||
$this->writeLine($text, $depth * 4);
|
||||
|
||||
// output defaults
|
||||
if ($defaultArray) {
|
||||
$this->writeLine('');
|
||||
|
||||
$message = \count($defaultArray) > 1 ? 'Defaults' : 'Default';
|
||||
|
||||
$this->writeLine('# '.$message.':', $depth * 4 + 4);
|
||||
|
||||
$this->writeArray($defaultArray, $depth + 1);
|
||||
}
|
||||
|
||||
if (\is_array($example)) {
|
||||
$this->writeLine('');
|
||||
|
||||
$message = \count($example) > 1 ? 'Examples' : 'Example';
|
||||
|
||||
$this->writeLine('# '.$message.':', $depth * 4 + 4);
|
||||
|
||||
$this->writeArray(array_map([Inline::class, 'dump'], $example), $depth + 1);
|
||||
}
|
||||
|
||||
if ($children) {
|
||||
foreach ($children as $childNode) {
|
||||
$this->writeNode($childNode, $node, $depth + 1, $node instanceof PrototypedArrayNode && !$node->getKeyAttribute());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a single config reference line.
|
||||
*/
|
||||
private function writeLine(string $text, int $indent = 0)
|
||||
{
|
||||
$indent = \strlen($text) + $indent;
|
||||
$format = '%'.$indent.'s';
|
||||
|
||||
$this->reference .= sprintf($format, $text)."\n";
|
||||
}
|
||||
|
||||
private function writeArray(array $array, int $depth)
|
||||
{
|
||||
$isIndexed = array_values($array) === $array;
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
if (\is_array($value)) {
|
||||
$val = '';
|
||||
} else {
|
||||
$val = $value;
|
||||
}
|
||||
|
||||
if ($isIndexed) {
|
||||
$this->writeLine('- '.$val, $depth * 4);
|
||||
} else {
|
||||
$this->writeLine(sprintf('%-20s %s', $key.':', $val), $depth * 4);
|
||||
}
|
||||
|
||||
if (\is_array($value)) {
|
||||
$this->writeArray($value, $depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPrototypeChildren(PrototypedArrayNode $node): array
|
||||
{
|
||||
$prototype = $node->getPrototype();
|
||||
$key = $node->getKeyAttribute();
|
||||
|
||||
// Do not expand prototype if it isn't an array node nor uses attribute as key
|
||||
if (!$key && !$prototype instanceof ArrayNode) {
|
||||
return $node->getChildren();
|
||||
}
|
||||
|
||||
if ($prototype instanceof ArrayNode) {
|
||||
$keyNode = new ArrayNode($key, $node);
|
||||
$children = $prototype->getChildren();
|
||||
|
||||
if ($prototype instanceof PrototypedArrayNode && $prototype->getKeyAttribute()) {
|
||||
$children = $this->getPrototypeChildren($prototype);
|
||||
}
|
||||
|
||||
// add children
|
||||
foreach ($children as $childNode) {
|
||||
$keyNode->addChild($childNode);
|
||||
}
|
||||
} else {
|
||||
$keyNode = new ScalarNode($key, $node);
|
||||
}
|
||||
|
||||
$info = 'Prototype';
|
||||
if (null !== $prototype->getInfo()) {
|
||||
$info .= ': '.$prototype->getInfo();
|
||||
}
|
||||
$keyNode->setInfo($info);
|
||||
|
||||
return [$key => $keyNode];
|
||||
}
|
||||
}
|
62
admin/phpMyAdmin/vendor/symfony/config/Definition/EnumNode.php
vendored
Normal file
62
admin/phpMyAdmin/vendor/symfony/config/Definition/EnumNode.php
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
|
||||
/**
|
||||
* Node which only allows a finite set of values.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class EnumNode extends ScalarNode
|
||||
{
|
||||
private $values;
|
||||
|
||||
public function __construct(?string $name, NodeInterface $parent = null, array $values = [], string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR)
|
||||
{
|
||||
$values = array_unique($values);
|
||||
if (empty($values)) {
|
||||
throw new \InvalidArgumentException('$values must contain at least one element.');
|
||||
}
|
||||
|
||||
parent::__construct($name, $parent, $pathSeparator);
|
||||
$this->values = $values;
|
||||
}
|
||||
|
||||
public function getValues()
|
||||
{
|
||||
return $this->values;
|
||||
}
|
||||
|
||||
protected function finalizeValue($value)
|
||||
{
|
||||
$value = parent::finalizeValue($value);
|
||||
|
||||
if (!\in_array($value, $this->values, true)) {
|
||||
$ex = new InvalidConfigurationException(sprintf('The value %s is not allowed for path "%s". Permissible values: %s', json_encode($value), $this->getPath(), implode(', ', array_map('json_encode', $this->values))));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function allowPlaceholders(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
22
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/DuplicateKeyException.php
vendored
Normal file
22
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/DuplicateKeyException.php
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* This exception is thrown whenever the key of an array is not unique. This can
|
||||
* only be the case if the configuration is coming from an XML file.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class DuplicateKeyException extends InvalidConfigurationException
|
||||
{
|
||||
}
|
21
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/Exception.php
vendored
Normal file
21
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/Exception.php
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* Base exception for all configuration exceptions.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class Exception extends \RuntimeException
|
||||
{
|
||||
}
|
22
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/ForbiddenOverwriteException.php
vendored
Normal file
22
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/ForbiddenOverwriteException.php
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* This exception is thrown when a configuration path is overwritten from a
|
||||
* subsequent configuration file, but the entry node specifically forbids this.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ForbiddenOverwriteException extends InvalidConfigurationException
|
||||
{
|
||||
}
|
49
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/InvalidConfigurationException.php
vendored
Normal file
49
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/InvalidConfigurationException.php
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* A very general exception which can be thrown whenever non of the more specific
|
||||
* exceptions is suitable.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class InvalidConfigurationException extends Exception
|
||||
{
|
||||
private $path;
|
||||
private $containsHints = false;
|
||||
|
||||
public function setPath($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds extra information that is suffixed to the original exception message.
|
||||
*
|
||||
* @param string $hint
|
||||
*/
|
||||
public function addHint($hint)
|
||||
{
|
||||
if (!$this->containsHints) {
|
||||
$this->message .= "\nHint: ".$hint;
|
||||
$this->containsHints = true;
|
||||
} else {
|
||||
$this->message .= ', '.$hint;
|
||||
}
|
||||
}
|
||||
}
|
21
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/InvalidDefinitionException.php
vendored
Normal file
21
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/InvalidDefinitionException.php
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* Thrown when an error is detected in a node Definition.
|
||||
*
|
||||
* @author Victor Berchet <victor.berchet@suumit.com>
|
||||
*/
|
||||
class InvalidDefinitionException extends Exception
|
||||
{
|
||||
}
|
21
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/InvalidTypeException.php
vendored
Normal file
21
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/InvalidTypeException.php
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* This exception is thrown if an invalid type is encountered.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class InvalidTypeException extends InvalidConfigurationException
|
||||
{
|
||||
}
|
21
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/TreeWithoutRootNodeException.php
vendored
Normal file
21
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/TreeWithoutRootNodeException.php
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* @author Roland Franssen <franssen.roland@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TreeWithoutRootNodeException extends \RuntimeException
|
||||
{
|
||||
}
|
22
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/UnsetKeyException.php
vendored
Normal file
22
admin/phpMyAdmin/vendor/symfony/config/Definition/Exception/UnsetKeyException.php
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* This exception is usually not encountered by the end-user, but only used
|
||||
* internally to signal the parent scope to unset a key.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class UnsetKeyException extends Exception
|
||||
{
|
||||
}
|
51
admin/phpMyAdmin/vendor/symfony/config/Definition/FloatNode.php
vendored
Normal file
51
admin/phpMyAdmin/vendor/symfony/config/Definition/FloatNode.php
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
|
||||
/**
|
||||
* This node represents a float value in the config tree.
|
||||
*
|
||||
* @author Jeanmonod David <david.jeanmonod@gmail.com>
|
||||
*/
|
||||
class FloatNode extends NumericNode
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function validateType($value)
|
||||
{
|
||||
// Integers are also accepted, we just cast them
|
||||
if (\is_int($value)) {
|
||||
$value = (float) $value;
|
||||
}
|
||||
|
||||
if (!\is_float($value)) {
|
||||
$ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected float, but got %s.', $this->getPath(), \gettype($value)));
|
||||
if ($hint = $this->getInfo()) {
|
||||
$ex->addHint($hint);
|
||||
}
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getValidPlaceholderTypes(): array
|
||||
{
|
||||
return ['float'];
|
||||
}
|
||||
}
|
46
admin/phpMyAdmin/vendor/symfony/config/Definition/IntegerNode.php
vendored
Normal file
46
admin/phpMyAdmin/vendor/symfony/config/Definition/IntegerNode.php
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
|
||||
/**
|
||||
* This node represents an integer value in the config tree.
|
||||
*
|
||||
* @author Jeanmonod David <david.jeanmonod@gmail.com>
|
||||
*/
|
||||
class IntegerNode extends NumericNode
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function validateType($value)
|
||||
{
|
||||
if (!\is_int($value)) {
|
||||
$ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected int, but got %s.', $this->getPath(), \gettype($value)));
|
||||
if ($hint = $this->getInfo()) {
|
||||
$ex->addHint($hint);
|
||||
}
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getValidPlaceholderTypes(): array
|
||||
{
|
||||
return ['int'];
|
||||
}
|
||||
}
|
100
admin/phpMyAdmin/vendor/symfony/config/Definition/NodeInterface.php
vendored
Normal file
100
admin/phpMyAdmin/vendor/symfony/config/Definition/NodeInterface.php
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
|
||||
/**
|
||||
* Common Interface among all nodes.
|
||||
*
|
||||
* In most cases, it is better to inherit from BaseNode instead of implementing
|
||||
* this interface yourself.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
interface NodeInterface
|
||||
{
|
||||
/**
|
||||
* Returns the name of the node.
|
||||
*
|
||||
* @return string The name of the node
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Returns the path of the node.
|
||||
*
|
||||
* @return string The node path
|
||||
*/
|
||||
public function getPath();
|
||||
|
||||
/**
|
||||
* Returns true when the node is required.
|
||||
*
|
||||
* @return bool If the node is required
|
||||
*/
|
||||
public function isRequired();
|
||||
|
||||
/**
|
||||
* Returns true when the node has a default value.
|
||||
*
|
||||
* @return bool If the node has a default value
|
||||
*/
|
||||
public function hasDefaultValue();
|
||||
|
||||
/**
|
||||
* Returns the default value of the node.
|
||||
*
|
||||
* @return mixed The default value
|
||||
*
|
||||
* @throws \RuntimeException if the node has no default value
|
||||
*/
|
||||
public function getDefaultValue();
|
||||
|
||||
/**
|
||||
* Normalizes a value.
|
||||
*
|
||||
* @param mixed $value The value to normalize
|
||||
*
|
||||
* @return mixed The normalized value
|
||||
*
|
||||
* @throws InvalidTypeException if the value type is invalid
|
||||
*/
|
||||
public function normalize($value);
|
||||
|
||||
/**
|
||||
* Merges two values together.
|
||||
*
|
||||
* @param mixed $leftSide
|
||||
* @param mixed $rightSide
|
||||
*
|
||||
* @return mixed The merged value
|
||||
*
|
||||
* @throws ForbiddenOverwriteException if the configuration path cannot be overwritten
|
||||
* @throws InvalidTypeException if the value type is invalid
|
||||
*/
|
||||
public function merge($leftSide, $rightSide);
|
||||
|
||||
/**
|
||||
* Finalizes a value.
|
||||
*
|
||||
* @param mixed $value The value to finalize
|
||||
*
|
||||
* @return mixed The finalized value
|
||||
*
|
||||
* @throws InvalidTypeException if the value type is invalid
|
||||
* @throws InvalidConfigurationException if the value is invalid configuration
|
||||
*/
|
||||
public function finalize($value);
|
||||
}
|
64
admin/phpMyAdmin/vendor/symfony/config/Definition/NumericNode.php
vendored
Normal file
64
admin/phpMyAdmin/vendor/symfony/config/Definition/NumericNode.php
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
|
||||
/**
|
||||
* This node represents a numeric value in the config tree.
|
||||
*
|
||||
* @author David Jeanmonod <david.jeanmonod@gmail.com>
|
||||
*/
|
||||
class NumericNode extends ScalarNode
|
||||
{
|
||||
protected $min;
|
||||
protected $max;
|
||||
|
||||
public function __construct(?string $name, NodeInterface $parent = null, $min = null, $max = null, string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR)
|
||||
{
|
||||
parent::__construct($name, $parent, $pathSeparator);
|
||||
$this->min = $min;
|
||||
$this->max = $max;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function finalizeValue($value)
|
||||
{
|
||||
$value = parent::finalizeValue($value);
|
||||
|
||||
$errorMsg = null;
|
||||
if (isset($this->min) && $value < $this->min) {
|
||||
$errorMsg = sprintf('The value %s is too small for path "%s". Should be greater than or equal to %s', $value, $this->getPath(), $this->min);
|
||||
}
|
||||
if (isset($this->max) && $value > $this->max) {
|
||||
$errorMsg = sprintf('The value %s is too big for path "%s". Should be less than or equal to %s', $value, $this->getPath(), $this->max);
|
||||
}
|
||||
if (isset($errorMsg)) {
|
||||
$ex = new InvalidConfigurationException($errorMsg);
|
||||
$ex->setPath($this->getPath());
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function isValueEmpty($value)
|
||||
{
|
||||
// a numeric value cannot be empty
|
||||
return false;
|
||||
}
|
||||
}
|
97
admin/phpMyAdmin/vendor/symfony/config/Definition/Processor.php
vendored
Normal file
97
admin/phpMyAdmin/vendor/symfony/config/Definition/Processor.php
vendored
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
/**
|
||||
* This class is the entry point for config normalization/merging/finalization.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
* @final since version 4.1
|
||||
*/
|
||||
class Processor
|
||||
{
|
||||
/**
|
||||
* Processes an array of configurations.
|
||||
*
|
||||
* @param array $configs An array of configuration items to process
|
||||
*
|
||||
* @return array The processed configuration
|
||||
*/
|
||||
public function process(NodeInterface $configTree, array $configs)
|
||||
{
|
||||
$currentConfig = [];
|
||||
foreach ($configs as $config) {
|
||||
$config = $configTree->normalize($config);
|
||||
$currentConfig = $configTree->merge($currentConfig, $config);
|
||||
}
|
||||
|
||||
return $configTree->finalize($currentConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes an array of configurations.
|
||||
*
|
||||
* @param array $configs An array of configuration items to process
|
||||
*
|
||||
* @return array The processed configuration
|
||||
*/
|
||||
public function processConfiguration(ConfigurationInterface $configuration, array $configs)
|
||||
{
|
||||
return $this->process($configuration->getConfigTreeBuilder()->buildTree(), $configs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a configuration entry.
|
||||
*
|
||||
* This method returns a normalize configuration array for a given key
|
||||
* to remove the differences due to the original format (YAML and XML mainly).
|
||||
*
|
||||
* Here is an example.
|
||||
*
|
||||
* The configuration in XML:
|
||||
*
|
||||
* <twig:extension>twig.extension.foo</twig:extension>
|
||||
* <twig:extension>twig.extension.bar</twig:extension>
|
||||
*
|
||||
* And the same configuration in YAML:
|
||||
*
|
||||
* extensions: ['twig.extension.foo', 'twig.extension.bar']
|
||||
*
|
||||
* @param array $config A config array
|
||||
* @param string $key The key to normalize
|
||||
* @param string $plural The plural form of the key if it is irregular
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function normalizeConfig($config, $key, $plural = null)
|
||||
{
|
||||
if (null === $plural) {
|
||||
$plural = $key.'s';
|
||||
}
|
||||
|
||||
if (isset($config[$plural])) {
|
||||
return $config[$plural];
|
||||
}
|
||||
|
||||
if (isset($config[$key])) {
|
||||
if (\is_string($config[$key]) || !\is_int(key($config[$key]))) {
|
||||
// only one
|
||||
return [$config[$key]];
|
||||
}
|
||||
|
||||
return $config[$key];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
27
admin/phpMyAdmin/vendor/symfony/config/Definition/PrototypeNodeInterface.php
vendored
Normal file
27
admin/phpMyAdmin/vendor/symfony/config/Definition/PrototypeNodeInterface.php
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
/**
|
||||
* This interface must be implemented by nodes which can be used as prototypes.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
interface PrototypeNodeInterface extends NodeInterface
|
||||
{
|
||||
/**
|
||||
* Sets the name of the node.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
*/
|
||||
public function setName($name);
|
||||
}
|
380
admin/phpMyAdmin/vendor/symfony/config/Definition/PrototypedArrayNode.php
vendored
Normal file
380
admin/phpMyAdmin/vendor/symfony/config/Definition/PrototypedArrayNode.php
vendored
Normal file
|
@ -0,0 +1,380 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\DuplicateKeyException;
|
||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
|
||||
|
||||
/**
|
||||
* Represents a prototyped Array node in the config tree.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class PrototypedArrayNode extends ArrayNode
|
||||
{
|
||||
protected $prototype;
|
||||
protected $keyAttribute;
|
||||
protected $removeKeyAttribute = false;
|
||||
protected $minNumberOfElements = 0;
|
||||
protected $defaultValue = [];
|
||||
protected $defaultChildren;
|
||||
/**
|
||||
* @var NodeInterface[] An array of the prototypes of the simplified value children
|
||||
*/
|
||||
private $valuePrototypes = [];
|
||||
|
||||
/**
|
||||
* Sets the minimum number of elements that a prototype based node must
|
||||
* contain. By default this is zero, meaning no elements.
|
||||
*
|
||||
* @param int $number
|
||||
*/
|
||||
public function setMinNumberOfElements($number)
|
||||
{
|
||||
$this->minNumberOfElements = $number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attribute which value is to be used as key.
|
||||
*
|
||||
* This is useful when you have an indexed array that should be an
|
||||
* associative array. You can select an item from within the array
|
||||
* to be the key of the particular item. For example, if "id" is the
|
||||
* "key", then:
|
||||
*
|
||||
* [
|
||||
* ['id' => 'my_name', 'foo' => 'bar'],
|
||||
* ];
|
||||
*
|
||||
* becomes
|
||||
*
|
||||
* [
|
||||
* 'my_name' => ['foo' => 'bar'],
|
||||
* ];
|
||||
*
|
||||
* If you'd like "'id' => 'my_name'" to still be present in the resulting
|
||||
* array, then you can set the second argument of this method to false.
|
||||
*
|
||||
* @param string $attribute The name of the attribute which value is to be used as a key
|
||||
* @param bool $remove Whether or not to remove the key
|
||||
*/
|
||||
public function setKeyAttribute($attribute, $remove = true)
|
||||
{
|
||||
$this->keyAttribute = $attribute;
|
||||
$this->removeKeyAttribute = $remove;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the name of the attribute which value should be used as key.
|
||||
*
|
||||
* @return string|null The name of the attribute
|
||||
*/
|
||||
public function getKeyAttribute()
|
||||
{
|
||||
return $this->keyAttribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default value of this node.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @throws \InvalidArgumentException if the default value is not an array
|
||||
*/
|
||||
public function setDefaultValue($value)
|
||||
{
|
||||
if (!\is_array($value)) {
|
||||
throw new \InvalidArgumentException($this->getPath().': the default value of an array node has to be an array.');
|
||||
}
|
||||
|
||||
$this->defaultValue = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasDefaultValue()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds default children when none are set.
|
||||
*
|
||||
* @param int|string|array|null $children The number of children|The child name|The children names to be added
|
||||
*/
|
||||
public function setAddChildrenIfNoneSet($children = ['defaults'])
|
||||
{
|
||||
if (null === $children) {
|
||||
$this->defaultChildren = ['defaults'];
|
||||
} else {
|
||||
$this->defaultChildren = \is_int($children) && $children > 0 ? range(1, $children) : (array) $children;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* The default value could be either explicited or derived from the prototype
|
||||
* default value.
|
||||
*/
|
||||
public function getDefaultValue()
|
||||
{
|
||||
if (null !== $this->defaultChildren) {
|
||||
$default = $this->prototype->hasDefaultValue() ? $this->prototype->getDefaultValue() : [];
|
||||
$defaults = [];
|
||||
foreach (array_values($this->defaultChildren) as $i => $name) {
|
||||
$defaults[null === $this->keyAttribute ? $i : $name] = $default;
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
return $this->defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node prototype.
|
||||
*/
|
||||
public function setPrototype(PrototypeNodeInterface $node)
|
||||
{
|
||||
$this->prototype = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the prototype.
|
||||
*
|
||||
* @return PrototypeNodeInterface The prototype
|
||||
*/
|
||||
public function getPrototype()
|
||||
{
|
||||
return $this->prototype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable adding concrete children for prototyped nodes.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addChild(NodeInterface $node)
|
||||
{
|
||||
throw new Exception('A prototyped array node can not have concrete children.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes the value of this node.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed The finalized value
|
||||
*
|
||||
* @throws UnsetKeyException
|
||||
* @throws InvalidConfigurationException if the node doesn't have enough children
|
||||
*/
|
||||
protected function finalizeValue($value)
|
||||
{
|
||||
if (false === $value) {
|
||||
throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: "%s".', $this->getPath(), json_encode($value)));
|
||||
}
|
||||
|
||||
foreach ($value as $k => $v) {
|
||||
$prototype = $this->getPrototypeForChild($k);
|
||||
try {
|
||||
$value[$k] = $prototype->finalize($v);
|
||||
} catch (UnsetKeyException $e) {
|
||||
unset($value[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
if (\count($value) < $this->minNumberOfElements) {
|
||||
$ex = new InvalidConfigurationException(sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the value.
|
||||
*
|
||||
* @param mixed $value The value to normalize
|
||||
*
|
||||
* @return mixed The normalized value
|
||||
*
|
||||
* @throws InvalidConfigurationException
|
||||
* @throws DuplicateKeyException
|
||||
*/
|
||||
protected function normalizeValue($value)
|
||||
{
|
||||
if (false === $value) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$value = $this->remapXml($value);
|
||||
|
||||
$isList = array_is_list($value);
|
||||
$normalized = [];
|
||||
foreach ($value as $k => $v) {
|
||||
if (null !== $this->keyAttribute && \is_array($v)) {
|
||||
if (!isset($v[$this->keyAttribute]) && \is_int($k) && $isList) {
|
||||
$ex = new InvalidConfigurationException(sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath()));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
} elseif (isset($v[$this->keyAttribute])) {
|
||||
$k = $v[$this->keyAttribute];
|
||||
|
||||
if (\is_float($k)) {
|
||||
$k = var_export($k, true);
|
||||
}
|
||||
|
||||
// remove the key attribute when required
|
||||
if ($this->removeKeyAttribute) {
|
||||
unset($v[$this->keyAttribute]);
|
||||
}
|
||||
|
||||
// if only "value" is left
|
||||
if (array_keys($v) === ['value']) {
|
||||
$v = $v['value'];
|
||||
if ($this->prototype instanceof ArrayNode && ($children = $this->prototype->getChildren()) && \array_key_exists('value', $children)) {
|
||||
$valuePrototype = current($this->valuePrototypes) ?: clone $children['value'];
|
||||
$valuePrototype->parent = $this;
|
||||
$originalClosures = $this->prototype->normalizationClosures;
|
||||
if (\is_array($originalClosures)) {
|
||||
$valuePrototypeClosures = $valuePrototype->normalizationClosures;
|
||||
$valuePrototype->normalizationClosures = \is_array($valuePrototypeClosures) ? array_merge($originalClosures, $valuePrototypeClosures) : $originalClosures;
|
||||
}
|
||||
$this->valuePrototypes[$k] = $valuePrototype;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (\array_key_exists($k, $normalized)) {
|
||||
$ex = new DuplicateKeyException(sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath()));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
$prototype = $this->getPrototypeForChild($k);
|
||||
if (null !== $this->keyAttribute || !$isList) {
|
||||
$normalized[$k] = $prototype->normalize($v);
|
||||
} else {
|
||||
$normalized[] = $prototype->normalize($v);
|
||||
}
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges values together.
|
||||
*
|
||||
* @param mixed $leftSide The left side to merge
|
||||
* @param mixed $rightSide The right side to merge
|
||||
*
|
||||
* @return mixed The merged values
|
||||
*
|
||||
* @throws InvalidConfigurationException
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function mergeValues($leftSide, $rightSide)
|
||||
{
|
||||
if (false === $rightSide) {
|
||||
// if this is still false after the last config has been merged the
|
||||
// finalization pass will take care of removing this key entirely
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false === $leftSide || !$this->performDeepMerging) {
|
||||
return $rightSide;
|
||||
}
|
||||
|
||||
$isList = array_is_list($rightSide);
|
||||
foreach ($rightSide as $k => $v) {
|
||||
// prototype, and key is irrelevant there are no named keys, append the element
|
||||
if (null === $this->keyAttribute && $isList) {
|
||||
$leftSide[] = $v;
|
||||
continue;
|
||||
}
|
||||
|
||||
// no conflict
|
||||
if (!\array_key_exists($k, $leftSide)) {
|
||||
if (!$this->allowNewKeys) {
|
||||
$ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file.', $this->getPath()));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$leftSide[$k] = $v;
|
||||
continue;
|
||||
}
|
||||
|
||||
$prototype = $this->getPrototypeForChild($k);
|
||||
$leftSide[$k] = $prototype->merge($leftSide[$k], $v);
|
||||
}
|
||||
|
||||
return $leftSide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a prototype for the child node that is associated to $key in the value array.
|
||||
* For general child nodes, this will be $this->prototype.
|
||||
* But if $this->removeKeyAttribute is true and there are only two keys in the child node:
|
||||
* one is same as this->keyAttribute and the other is 'value', then the prototype will be different.
|
||||
*
|
||||
* For example, assume $this->keyAttribute is 'name' and the value array is as follows:
|
||||
*
|
||||
* [
|
||||
* [
|
||||
* 'name' => 'name001',
|
||||
* 'value' => 'value001'
|
||||
* ]
|
||||
* ]
|
||||
*
|
||||
* Now, the key is 0 and the child node is:
|
||||
*
|
||||
* [
|
||||
* 'name' => 'name001',
|
||||
* 'value' => 'value001'
|
||||
* ]
|
||||
*
|
||||
* When normalizing the value array, the 'name' element will removed from the child node
|
||||
* and its value becomes the new key of the child node:
|
||||
*
|
||||
* [
|
||||
* 'name001' => ['value' => 'value001']
|
||||
* ]
|
||||
*
|
||||
* Now only 'value' element is left in the child node which can be further simplified into a string:
|
||||
*
|
||||
* ['name001' => 'value001']
|
||||
*
|
||||
* Now, the key becomes 'name001' and the child node becomes 'value001' and
|
||||
* the prototype of child node 'name001' should be a ScalarNode instead of an ArrayNode instance.
|
||||
*
|
||||
* @return mixed The prototype instance
|
||||
*/
|
||||
private function getPrototypeForChild(string $key)
|
||||
{
|
||||
$prototype = $this->valuePrototypes[$key] ?? $this->prototype;
|
||||
$prototype->setName($key);
|
||||
|
||||
return $prototype;
|
||||
}
|
||||
}
|
67
admin/phpMyAdmin/vendor/symfony/config/Definition/ScalarNode.php
vendored
Normal file
67
admin/phpMyAdmin/vendor/symfony/config/Definition/ScalarNode.php
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
|
||||
/**
|
||||
* This node represents a scalar value in the config tree.
|
||||
*
|
||||
* The following values are considered scalars:
|
||||
* * booleans
|
||||
* * strings
|
||||
* * null
|
||||
* * integers
|
||||
* * floats
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ScalarNode extends VariableNode
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function validateType($value)
|
||||
{
|
||||
if (!is_scalar($value) && null !== $value) {
|
||||
$ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected scalar, but got %s.', $this->getPath(), \gettype($value)));
|
||||
if ($hint = $this->getInfo()) {
|
||||
$ex->addHint($hint);
|
||||
}
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function isValueEmpty($value)
|
||||
{
|
||||
// assume environment variables are never empty (which in practice is likely to be true during runtime)
|
||||
// not doing so breaks many configs that are valid today
|
||||
if ($this->isHandlingPlaceholder()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return null === $value || '' === $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getValidPlaceholderTypes(): array
|
||||
{
|
||||
return ['bool', 'int', 'float', 'string'];
|
||||
}
|
||||
}
|
143
admin/phpMyAdmin/vendor/symfony/config/Definition/VariableNode.php
vendored
Normal file
143
admin/phpMyAdmin/vendor/symfony/config/Definition/VariableNode.php
vendored
Normal file
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
|
||||
/**
|
||||
* This node represents a value of variable type in the config tree.
|
||||
*
|
||||
* This node is intended for values of arbitrary type.
|
||||
* Any PHP type is accepted as a value.
|
||||
*
|
||||
* @author Jeremy Mikola <jmikola@gmail.com>
|
||||
*/
|
||||
class VariableNode extends BaseNode implements PrototypeNodeInterface
|
||||
{
|
||||
protected $defaultValueSet = false;
|
||||
protected $defaultValue;
|
||||
protected $allowEmptyValue = true;
|
||||
|
||||
public function setDefaultValue($value)
|
||||
{
|
||||
$this->defaultValueSet = true;
|
||||
$this->defaultValue = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasDefaultValue()
|
||||
{
|
||||
return $this->defaultValueSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultValue()
|
||||
{
|
||||
$v = $this->defaultValue;
|
||||
|
||||
return $v instanceof \Closure ? $v() : $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if this node is allowed to have an empty value.
|
||||
*
|
||||
* @param bool $boolean True if this entity will accept empty values
|
||||
*/
|
||||
public function setAllowEmptyValue($boolean)
|
||||
{
|
||||
$this->allowEmptyValue = (bool) $boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function validateType($value)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function finalizeValue($value)
|
||||
{
|
||||
// deny environment variables only when using custom validators
|
||||
// this avoids ever passing an empty value to final validation closures
|
||||
if (!$this->allowEmptyValue && $this->isHandlingPlaceholder() && $this->finalValidationClosures) {
|
||||
@trigger_error(sprintf('Setting path "%s" to an environment variable is deprecated since Symfony 4.3. Remove "cannotBeEmpty()", "validate()" or include a prefix/suffix value instead.', $this->getPath()), \E_USER_DEPRECATED);
|
||||
// $e = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an environment variable when empty values are not allowed by definition and are validated.', $this->getPath()));
|
||||
// if ($hint = $this->getInfo()) {
|
||||
// $e->addHint($hint);
|
||||
// }
|
||||
// $e->setPath($this->getPath());
|
||||
//
|
||||
// throw $e;
|
||||
}
|
||||
|
||||
if (!$this->allowEmptyValue && $this->isValueEmpty($value)) {
|
||||
$ex = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an empty value, but got %s.', $this->getPath(), json_encode($value)));
|
||||
if ($hint = $this->getInfo()) {
|
||||
$ex->addHint($hint);
|
||||
}
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function normalizeValue($value)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function mergeValues($leftSide, $rightSide)
|
||||
{
|
||||
return $rightSide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates if the given value is to be treated as empty.
|
||||
*
|
||||
* By default, PHP's empty() function is used to test for emptiness. This
|
||||
* method may be overridden by subtypes to better match their understanding
|
||||
* of empty data.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @see finalizeValue()
|
||||
*/
|
||||
protected function isValueEmpty($value)
|
||||
{
|
||||
return empty($value);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue