Skip to content

Unable to import types from laminas/laminas-servicemanager #9019

@internalsystemerror

Description

@internalsystemerror

Bug report

When trying to use the types setup in laminas/laminas-servicemanager its telling me that I'm using an invalid return type. It appears the reason is due to errors when analysing laminas/laminas-servicemanager src/ConfigInterface.php.

/**
 * @phpstan-import-type ServiceManagerConfigurationType from ConfigInterface
 */
final class ConfigProvider {
    /**
     * @return array{dependencies: ServiceManagerConfigurationType}
     */
    public function __invoke(): array
    {
        return [
            'dependencies' => [
                'factories' => [
                    'doctrine.entity_manager.orm_default' => EntityManagerFactory::class,
                ],
            ],
        ];
    }
}

Gives the following errors:

  • Method ConfigProvider::__invoke() return type has no value type specified in iterable type array.
  • Method ConfigProvider::dependencies() has invalid return type Laminas\ServiceManager\DelegatorsConfigurationType.
  • Method ConfigProvider::dependencies() has invalid return type Laminas\ServiceManager\FactoriesConfigurationType.
  • Method ConfigProvider::dependencies() has invalid return type Laminas\ServiceManager\InitializersConfigurationType.
  • Method ConfigProvider::dependencies() return type has no value type specified in iterable type array.
  • Method ConfigProvider::dependencies() should return array{......} but returns array{......}. Offset 'factories' (Laminas\ServiceManager\FactoriesConfigurationType) does not accept type array<string, string>.

Code snippet that reproduces the problem

https://phpstan.org/r/c42f32d0-68fb-4a6d-a0e8-9e180ded8d6c

Note the above is running phpstan on the relevant class in laminas/laminas-servicemanager, however these same errors show up when importing this type in a ConfigProvider.

Expected output

I should be able to use the types provided by laminas/laminas-servicemanager without error.

Did PHPStan help you today? Did it make you happy in any way?

I had to stop my sponsorship due to a change in circumstances however I do aim to start this again when possible. As always many thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions