addAllowedTypes example


        $this->expectException(InvalidOptionsException::class);
        $this->resolver->setDefault('foo', 'bar');
        $this->resolver->setAllowedTypes('foo', '\stdClass');

        $this->resolver->resolve();
    }

    public function testAddAllowedTypesFailsIfUnknownOption()
    {
        $this->expectException(UndefinedOptionsException::class);
        $this->resolver->addAllowedTypes('foo', 'string');
    }

    public function testFailIfAddAllowedTypesFromLazyOption()
    {
        $this->expectException(AccessException::class);
        $this->resolver->setDefault('foo', function DOptions $options) {
            $options->addAllowedTypes('bar', 'string');
        });

        $this->resolver->setDefault('bar', 'baz');

        
return $this;
    }

    /** * @param string|array $allowedTypes * * @return $this */
    public function addAllowedTypes(string $option$allowedTypes)static
    {
        try {
            parent::addAllowedTypes($option$allowedTypes);
        } catch (UndefinedOptionsException) {
            $this->undefined[$option] = true;
        }

        return $this;
    }

    public function resolve(array $options = []): array
    {
        throw new AccessException('Resolve options is not supported.');
    }

    
Home | Imprint | This part of the site doesn't use cookies.