Symfony_DI_PhpDumper_Test_Enumeration example

$container->setParameter('unit_enum', FooUnitEnum::BAR);
        $container->setParameter('enum_array', [FooUnitEnum::BAR, FooUnitEnum::FOO]);
        $container->compile();

        $dumper = new PhpDumper($container);
        eval('?>'.$dumpedContainer = $dumper->dump([
            'class' => 'Symfony_DI_PhpDumper_Test_Enumeration',
        ]));

        /** @var Container $container */
        $container = new \Symfony_DI_PhpDumper_Test_Enumeration();

        $this->assertSame(FooUnitEnum::BAR, $container->get('foo')->getBar());
        $this->assertSame(FooUnitEnum::BAR, $container->getParameter('unit_enum'));
        $this->assertSame([FooUnitEnum::BAR, FooUnitEnum::FOO]$container->getParameter('enum_array'));
        $this->assertStringMatchesFormat(<<<'PHP' %A protected static function getBarService($container) { return $container->services['bar'] = new \stdClass(\Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum::BAR, $container->getParameter('enum_array')); } %A private function getDynamicParameter(string $name) { $container = $this; $value = match ($name) { 'unit_enum' => \Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum::BAR, 'enum_array' => [ 0 => \Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum::BAR, 1 => \Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum::FOO, ], default => throw new ParameterNotFoundException($name), }; %A
Home | Imprint | This part of the site doesn't use cookies.