Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in type inference of @psalm-type ServiceManagerConfiguration on ServiceManager? #165

Closed
Ocramius opened this issue Dec 5, 2022 · 4 comments
Labels
Awaiting Maintainer Response Bug Something isn't working Invalid This doesn't seem right

Comments

@Ocramius
Copy link
Member

Ocramius commented Dec 5, 2022

Bug Report

Q A
Version(s) 3.20.0

Summary

When upgrading from 3.19.0 to 3.20.0, the some type information got lost.

This is mostly visible in laminas/laminas-hydrator#100 and similar patches, where errors like this one occur:

Error: src/HydratorPluginManagerFactory.php:48:64: ArgumentTypeCoercion: Argument 2 of Laminas\Hydrator\HydratorPluginManager::__construct expects array{abstract_factories?: array<array-key, Laminas\ServiceManager\Factory\AbstractFactoryInterface|class-string<Laminas\ServiceManager\Factory\AbstractFactoryInterface>>, aliases?: array<string, string>, delegators?: array<string, array<array-key, Laminas\ServiceManager\Factory\DelegatorFactoryInterface|callable(Psr\Container\ContainerInterface, string, callable():object, array<array-key, mixed>|null):object|class-string<Laminas\ServiceManager\Factory\DelegatorFactoryInterface>>>, factories?: array<string, Laminas\ServiceManager\Factory\FactoryInterface|callable(Psr\Container\ContainerInterface, null|string, array<array-key, mixed>|null):object|class-string<Laminas\ServiceManager\Factory\FactoryInterface>>, initializers?: array<array-key, Laminas\ServiceManager\Initializer\InitializerInterface|callable(Psr\Container\ContainerInterface, object):void|class-string<Laminas\ServiceManager\Initializer\InitializerInterface>>, invokables?: array<string, string>, lazy_services?: array{class_map?: array<string, class-string>, proxies_namespace?: non-empty-string, proxies_target_dir?: non-empty-string, write_proxy_files?: bool}, services?: array<string, array<array-key, mixed>|object>, shared?: array<string, bool>, shared_by_default?: bool, ...<array-key, mixed>}, but parent type array<array-key, mixed> provided (see https://psalm.dev/193)

Seems like this declaration is mis-interpreted due to the final ... 🤔

* @psalm-type ServiceManagerConfiguration = array{
* abstract_factories?: AbstractFactoriesConfigurationType,
* aliases?: array<string,string>,
* delegators?: DelegatorsConfigurationType,
* factories?: FactoriesConfigurationType,
* initializers?: InitializersConfigurationType,
* invokables?: array<string,string>,
* lazy_services?: LazyServicesConfigurationType,
* services?: array<string,object|array>,
* shared?:array<string,bool>,
* shared_by_default?:bool,
* ...
* }

Possibly also a psalm bug?

@gsteel
Copy link
Member

gsteel commented Dec 5, 2022

I think this is because psalm 4.30 (present in the lockfile) does not understand ... - Upgrading to psalm 5 in the these libs should just solve everything like mezzio/mezzio-laminasviewrenderer#33

@Ocramius
Copy link
Member Author

Ocramius commented Dec 5, 2022

Hmm, true that 🤔

Perhaps really a question of upgrading vimeo/psalm 👍

@Ocramius Ocramius removed this from the 3.20.1 milestone Dec 5, 2022
@Ocramius Ocramius added Awaiting Maintainer Response Invalid This doesn't seem right and removed Help Wanted labels Dec 5, 2022
@boesing
Copy link
Member

boesing commented Mar 5, 2023

I've modified the types a little bit in #179 as I found some issues there. Maybe that also fixes this issue?
Should we close here or do you want us to dive deeper into this?

@boesing
Copy link
Member

boesing commented May 2, 2023

Closing here as it should be handled by #179

@boesing boesing closed this as completed May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Maintainer Response Bug Something isn't working Invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants