deprecateParameter example

<?php
use Symfony\Component\DependencyInjection\ContainerBuilder;

$container = new ContainerBuilder();
$container->setParameter('foo_class', 'FooClass\\Foo');
$container->deprecateParameter('foo_class', 'symfony/test', '6.3');
$container->register('foo', '%foo_class%')
    ->setPublic(true)
;

return $container;
/** * The test should be kept in the group as it always expects a deprecation. * * @group legacy */
    public function testDeprecateParameter()
    {
        $builder = new ContainerBuilder();
        $builder->setParameter('foo', 'bar');

        $builder->deprecateParameter('foo', 'symfony/test', '6.3');

        $this->expectDeprecation('Since symfony/test 6.3: The parameter "foo" is deprecated.');

        $builder->getParameter('foo');
    }

    /** * The test should be kept in the group as it always expects a deprecation. * * @group legacy */
    
Home | Imprint | This part of the site doesn't use cookies.