phpstan-laminas-framework icon indicating copy to clipboard operation
phpstan-laminas-framework copied to clipboard

Calling MvcEvent::getApplication()->getServiceManager()->get('config') hangs phpstan

Open Nowicki opened this issue 3 years ago • 1 comments

I have few modules which do someting like this:

class Module
{
    public function onBootstrap(MvcEvent $event): void
    {
        $config = $event->getApplication()->getServiceManager()->get('config');
        // ....
    }
}

This code hangs phpstan for about 5 minutes. Calling $event->getApplication()->getServiceManager()->get('AnyService') works without any issues. Currently I am using a workaround:

use Interop\Container\ContainerInterface;

class Module
{
    public function onBootstrap(MvcEvent $event): void
    {
         /** @var ContainerInterface $serviceManager */
        $serviceManager = $event->getApplication()->getServiceManager();
        $config = $serviceManager->get('config');
        // ....
    }
}

Tested on: PHP 8.0.15 PHPStan 1.4.10 PHPStan Laminas Framework 1.0.0

Nowicki avatar Mar 18 '22 17:03 Nowicki

I have no idea, sorry

Slamdunk avatar Mar 20 '22 08:03 Slamdunk