When using Psl\Type\converted(), PHPStan fails to infer the type of produced shapes:
/**
* @return \Psl\Type\TypeInterface<array{foo: non-empty-string}>
*/
function test() {
return \Psl\Type\converted(
\Psl\Type\shape([
'foo' => \Psl\Type\int(),
]),
\Psl\Type\shape([
'foo' => \Psl\Type\non_empty_string(),
]),
static function (array $in): array {
return [
'foo' => (string) $in['foo']
];
}
);
}
This could well be a PHPStan limitation, given that Psl\Type\Converted has the output type bound to both the target type and the closure, and PHPStan does not parse any /** @return ... */ declarations on closures.
/cc @ondrejmirtes this is probably related to PHPStan not parsing docblocks on closures
When using
Psl\Type\converted(), PHPStan fails to infer the type of produced shapes:This could well be a PHPStan limitation, given that
Psl\Type\Convertedhas the output type bound to both the target type and the closure, and PHPStan does not parse any/** @return ... */declarations on closures./cc @ondrejmirtes this is probably related to PHPStan not parsing docblocks on closures