Skip to content

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

@boesing

Description

@boesing

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions