`*ParameterClosureTypeExtension` for functions which accept a array of callables
Feature request
using *ParameterClosureTypeExtension for preg_replace_callback in https://github.com/phpstan/phpstan-src/pull/3281 worked like a charm. I was able to easily wire togehter the RegexArrayShapeMatcher with the closure arg.
I try to do a similar thing for preg_replace_callback_array but since this function has a array-of-callables as a first arg my *ParameterClosureTypeExtension is not invoked.
example code
preg_replace_callback_array(
[
'~A([a]+)~i' => function ($match) {
var_dump($match);
\PHPStan\Testing\assertType('list<string>', $match);
},
'~B([b]+)?~i' => function ($match) {
//var_dump($match);
},
'/(foo)?(bar)?(baz)?/' => function ($match) {
//var_dump($match);
},
],
$subject
);
I think we either need a way to handle array-of-callables, or we need to hardcode preg_replace_callback_array directly into NodeScopeResolver - or maybe there is another path I did not yet think of.
lets use this issue to figure out how this can/should be done :-)
Did PHPStan help you today? Did it make you happy in any way?
No response
//cc @canvural
Oh, I'm not sure what to do about this, it's such a weird design...
yeah, its weird.
one more datapoint: the github search leads only 8k occurences.. might be not worth supporting in the end
We definitely don't need to force ourselves into a corner with a bad design, it's better to wait and maybe something emerges in the future.