Open hlecorche opened 1 year ago
Hello,
Since #192 (fix #191), the return type for ParameterBagInterface::get() works with dependency injection but not with ServiceSubscriberInterface :
ParameterBagInterface::get()
ServiceSubscriberInterface
namespace App\Issue; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Contracts\Service\ServiceSubscriberInterface; class Issue implements ServiceSubscriberInterface { public function __construct(protected ContainerInterface $container, protected ParameterBagInterface $parameterBag) { } public function test(): void { $parameterBagFromConstructor = $this->parameterBag; // Expected: Dumped type: Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface // Observed: Dumped type: Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface \PHPStan\dumpType($parameterBagFromConstructor); $parameterBagFromContainer = $this->container->get(ParameterBagInterface::class); // Expected: Dumped type: Symfony\Component\DependencyInjection\ParameterBag\ContainerBag // Observed: Dumped type: Symfony\Component\DependencyInjection\ParameterBag\ContainerBag \PHPStan\dumpType($parameterBagFromContainer); $parameterFromConstructor = $parameterBagFromConstructor->get('kernel.project_dir'); // Expected: Dumped type: string // Observed: Dumped type: string \PHPStan\dumpType($parameterFromConstructor); $parameterFromContainer = $parameterBagFromContainer->get('kernel.project_dir'); // Expected: Dumped type: string // Observed: Dumped type: array|bool|float|int|string|UnitEnum|null \PHPStan\dumpType($parameterFromContainer); } public static function getSubscribedServices(): array { return [ ParameterBagInterface::class, ]; } }
Is there a solution for add the support of ParameterBagInterface::get() with ServiceSubscriberInterface ?
Thanks
Same issues with ServiceLocators https://symfony.com/doc/current/service_container/service_subscribers_locators.html#defining-a-service-locator
Hello,
Since #192 (fix #191), the return type for
ParameterBagInterface::get()
works with dependency injection but not withServiceSubscriberInterface
:Is there a solution for add the support of
ParameterBagInterface::get()
withServiceSubscriberInterface
?Thanks