proget-hq / phpstan-yii2

Yii2 extension for PHPStan
MIT License
52 stars 18 forks source link

container -> singletons #9

Closed Mike-Tranzit closed 5 years ago

Mike-Tranzit commented 5 years ago

При анализе появляется ошибка вида: image

Немного покопавшись в коде наткнулся на: image Что мы должны добавлять в этот массив в файле конфигурации?

fl0v commented 5 years ago

That section is to tell the container which classes are singletons see https://www.yiiframework.com/doc/guide/2.0/en/concept-di-container or https://www.yiiframework.com/doc/guide/2.0/ru/concept-di-container

You can just set it to an empty array if you don't nead it (make sure you define $config['container']['class'] aswell). I think the phpstan-yii2 code neads to check if the config is empty

    if (! empty($config['container']['singletons'])) {
        foreach ($config['container']['singletons'] as $id => $service) {
            ...
        }
    }