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

Allow object&callable annotation for post- and preprocessors #35

Open
boesing opened this issue Jun 13, 2023 · 0 comments
Open

Allow object&callable annotation for post- and preprocessors #35

boesing opened this issue Jun 13, 2023 · 0 comments

Comments

@boesing
Copy link
Member

boesing commented Jun 13, 2023

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

Psalm is now able to properly understand something like:

object&callable(array):array

This would reduce errors with post processors being instantiated before being passed to the ConfigAggregator::__construct.

Example:

$parameterPostProcessor = new \Laminas\ConfigAggregatorParameters\LazyParameterPostProcessor(fn () => []);
$aggregator = new \Laminas\ConfigAggregator\ConfigAggregator([], null, [$parameterPostProcessor]);

This leads to an error:

InvalidArgument - config/config.php:45:50 - Argument 3 of Laminas\ConfigAggregator\ConfigAggregator::__construct expects list<callable(array<array-key, mixed>)|class-string>, but list{Laminas\ConfigAggregatorParameters\LazyParameterPostProcessor<array<string, mixed>>} provided (see https://psalm.dev/004)

To fix this, adding object&PostProcessorCallable and object&PreProcessorCallable to the annotation should fix the problem.
Something like this was also introduced in laminas-servicemanager with v4.0 and is supported by both psalm and phpstan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant