phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

apply parameter closure type extension in FunctionCallParametersCheck

Open schlndh opened this issue 1 year ago • 2 comments

Fixes https://phpstan.org/r/8ff9bc8f-4162-4ccf-bf5c-8b3d2061e68d Partially fixes: https://github.com/phpstan/phpstan/issues/10396 Related to https://github.com/phpstan/phpstan-src/pull/3282#issuecomment-2306883685

schlndh avatar Aug 25 '24 11:08 schlndh

I thought about this. I thought I wanted a different solution using virtual nodes but it'd need a lot of refactoring. And maybe it'd still be very hard.

For similar reasons I already added $scope->pushInFunctionCall() in the same Check class.

So feel free to pursue the same direction you started 😊

ondrejmirtes avatar Aug 25 '24 16:08 ondrejmirtes

This pull request has been marked as ready for review.

phpstan-bot avatar Aug 30 '24 11:08 phpstan-bot

I've looked at this and here are my thoughts: I don't like that FunctionCallParametersCheck::check() gains full reflection as another parameter. This isn't how I would design this. There are enough things already passed from reflection that this change really feels like it's bolted on to achieve a single goal.

Since the goal is to basically change $parameter from already passed $parametersAcceptor, I feel like we should modify $parametersAcceptor before it's passed to the check() method.

So the rules that call FunctionCallParametersCheck should modify ParametersAcceptor before it's passed there.

ondrejmirtes avatar May 05 '25 08:05 ondrejmirtes

Alright, I see this is just an alternative to https://github.com/phpstan/phpstan-src/pull/3282. I will merge that instead. Thank you.

ondrejmirtes avatar May 05 '25 08:05 ondrejmirtes