proget-hq / phpstan-yii2

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

String service definitions are considered function #37

Closed przepompownia closed 3 years ago

przepompownia commented 3 years ago

For entry

[
    'singletons' => [
        CacheInterface::class => FileCache::class
    ]
]

in container configurations I get

In ServiceMap.php line 87:

  Function yii\caching\FileCache() does not exist

because this service definition is considered function.

Probably adding

        if (\is_string($service) && class_exists($service)) {
            $this->services[$id] = $service;
            return;
        }

at the top of addServiceDefinition() is enough to resolve this problem.

akondas commented 3 years ago

Thanks for reporting. Do you think you are able to open a PR with the required change?