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

feat: add dynamic parameter type extensions

Open calebdw opened this issue 4 months ago • 5 comments

Closes https://github.com/phpstan/phpstan/issues/11707, closes https://github.com/phpstan/phpstan/issues/12585

Supersedes https://github.com/phpstan/phpstan-src/pull/3828, supersedes https://github.com/phpstan/phpstan-src/pull/3131, supersedes https://github.com/phpstan/phpstan-src/pull/3823

Hello!

This adds generalized dynamic parameter type extensions and deprecates the parameter closure type extensions per https://github.com/phpstan/phpstan/issues/11707#issuecomment-2358932350.

This also fixes the return.type and the argument.type errors described in https://github.com/phpstan/phpstan/issues/12585 when the parameter type is overridden via the extension.

[!NOTE] The original type from the closure type extensions was being passed around as $passedToType to the methods that needed it. However, I opted to rename this to overriddenType since I wasn't quite sure what $passedToType really meant. Let me know if there's something you'd rather do differently.

CC: @canvural, @Neol3108

Thanks!

calebdw avatar Sep 05 '25 13:09 calebdw

This pull request has been marked as ready for review.

phpstan-bot avatar Sep 05 '25 17:09 phpstan-bot

I tested it by porting my previous implementation for Larastan to this one, and looks like it works fine! Will try to implement more use cases and see if I can find any bugs. Also will try to test it on real projects.But so far so good. Thanks for this!

I'll also try to review this PR (though Ondrej would do a better job 😄 )

canvural avatar Sep 06 '25 10:09 canvural

@calebdw @ondrejmirtes Sorry to bother you, but I wanted to ask how we can move this forward? I'm really interested in this feature.

canvural avatar Oct 02 '25 19:10 canvural

No worries, just been busy with personal life, I'll try to get to the comments soon

calebdw avatar Oct 02 '25 19:10 calebdw

@ondrejmirtes, @canvural, sorry it took so long to address these comments---just been busy with personal life but hoping to move this forward now :pray:

calebdw avatar Nov 10 '25 15:11 calebdw