Skip to content

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

@Nowicki

Description

@Nowicki

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions