Decorating Symfony services

Code
<?php

use Symfony\Component\DependencyInjection\ContainerBuilder;

interface 
Fooable
{
    public function 
doFoo() : int;
}

class 
Foo implements Fooable
{
    public function 
doFoo() : int
    
{
        return 
9;
    }
}

class 
Bar implements Fooable
{
    private 
$foo;
    
    public function 
__construct(Foo $foo)
    {
        
$this->foo $foo;
    }
    
    public function 
doFoo() : int
    
{
        return 
$this->foo->doFoo() + 1;
    }
}

// create service definitions in container builder
$containerBuilder = new ContainerBuilder();
$fooDefinition $containerBuilder->autowire('Foo'Foo::class)
    ->
setPublic(true);
$containerBuilder->autowire('Bar'Bar::class)
    ->
setPublic(true)
    ->
setDecoratedService('Foo''Foo.inner')
    ->
setArgument('Foo'$fooDefinition);
$containerBuilder->compile();

// Calling the decorated "Foo" service, that is now an instance of Bar
dump($containerBuilder->get('Foo')->doFoo());
Result
^ 10
Used Versions
PHP 8.2, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8