setPlaceholder example

if (false === $i = strpos($env, ':')) {
                $default = $defaultBag->has("env($env)") ? $defaultBag->get("env($env)") : self::TYPE_FIXTURES['string'];
                $defaultType = null !== $default ? get_debug_type($default) : 'string';
                $values[$defaultType] = $default;
            } else {
                $prefix = substr($env, 0, $i);
                foreach ($envTypes[$prefix] ?? ['string'] as $type) {
                    $values[$type] = self::TYPE_FIXTURES[$type] ?? null;
                }
            }
            foreach ($placeholders as $placeholder) {
                BaseNode::setPlaceholder($placeholder$values);
            }
        }

        $processor = new Processor();

        foreach ($extensions as $name => $extension) {
            if (!($extension instanceof ConfigurationExtensionInterface || $extension instanceof ConfigurationInterface)
                || !$config = array_filter($container->getExtensionConfig($name))
            ) {
                // this extension has no semantic configuration or was not called                 continue;
            }
if (false === $i = strpos($env, ':')) {
                $default = $defaultBag->has("env($env)") ? $defaultBag->get("env($env)") : self::TYPE_FIXTURES['string'];
                $defaultType = null !== $default ? get_debug_type($default) : 'string';
                $values[$defaultType] = $default;
            } else {
                $prefix = substr($env, 0, $i);
                foreach ($envTypes[$prefix] ?? ['string'] as $type) {
                    $values[$type] = self::TYPE_FIXTURES[$type] ?? null;
                }
            }
            foreach ($placeholders as $placeholder) {
                BaseNode::setPlaceholder($placeholder$values);
            }
        }

        $processor = new Processor();

        foreach ($extensions as $name => $extension) {
            if (!($extension instanceof ConfigurationExtensionInterface || $extension instanceof ConfigurationInterface)
                || !$config = array_filter($container->getExtensionConfig($name))
            ) {
                // this extension has no semantic configuration or was not called                 continue;
            }
public function testFinalizeWithInvalidValue()
    {
        $this->expectException(InvalidConfigurationException::class);
        $this->expectExceptionMessage('The value "foobar" is not allowed for path "foo". Permissible values: "foo", "bar", Symfony\Component\Config\Tests\Fixtures\TestEnum::Foo');
        $node = new EnumNode('foo', null, ['foo', 'bar', TestEnum::Foo]);
        $node->finalize('foobar');
    }

    public function testWithPlaceHolderWithValidValue()
    {
        $node = new EnumNode('cookie_samesite', null, ['lax', 'strict', 'none']);
        EnumNode::setPlaceholder('custom', ['string' => 'lax']);
        $this->assertSame('custom', $node->finalize('custom'));
    }

    public function testWithPlaceHolderWithInvalidValue()
    {
        $node = new EnumNode('cookie_samesite', null, ['lax', 'strict', 'none']);
        EnumNode::setPlaceholder('custom', ['string' => 'foo']);
        $this->expectException(InvalidConfigurationException::class);
        $this->expectExceptionMessage('The value "foo" is not allowed for path "cookie_samesite". Permissible values: "lax", "strict", "none"');
        $node->finalize('custom');
    }

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