Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/rector/rector/vendor/symfony/config/Definition/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/rector/rector/vendor/symfony/config/Definition/EnumNode.php
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace RectorPrefix202308\Symfony\Component\Config\Definition;

use RectorPrefix202308\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
/**
 * Node which only allows a finite set of values.
 *
 * @author Johannes M. Schmitt <[email protected]>
 */
class EnumNode extends ScalarNode
{
    /**
     * @var mixed[]
     */
    private $values;
    public function __construct(?string $name, NodeInterface $parent = null, array $values = [], string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR)
    {
        if (!$values) {
            throw new \InvalidArgumentException('$values must contain at least one element.');
        }
        foreach ($values as $value) {
            if (null === $value || \is_scalar($value)) {
                continue;
            }
            if (!$value instanceof \UnitEnum) {
                throw new \InvalidArgumentException(\sprintf('"%s" only supports scalar, enum, or null values, "%s" given.', __CLASS__, \get_debug_type($value)));
            }
            if (\get_class($value) !== ($enumClass = $enumClass ?? \get_class($value))) {
                throw new \InvalidArgumentException(\sprintf('"%s" only supports one type of enum, "%s" and "%s" passed.', __CLASS__, $enumClass, \get_class($value)));
            }
        }
        parent::__construct($name, $parent, $pathSeparator);
        $this->values = $values;
    }
    /**
     * @return array
     */
    public function getValues()
    {
        return $this->values;
    }
    /**
     * @internal
     */
    public function getPermissibleValues(string $separator) : string
    {
        return \implode($separator, \array_unique(\array_map(static function ($value) : string {
            if (!$value instanceof \UnitEnum) {
                return \json_encode($value);
            }
            return \ltrim(\var_export($value, \true), '\\');
        }, $this->values)));
    }
    /**
     * @return void
     * @param mixed $value
     */
    protected function validateType($value)
    {
        if ($value instanceof \UnitEnum) {
            return;
        }
        parent::validateType($value);
    }
    /**
     * @param mixed $value
     * @return mixed
     */
    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(), $this->getPermissibleValues(', ')));
            $ex->setPath($this->getPath());
            throw $ex;
        }
        return $value;
    }
}

Spamworldpro Mini