feat: add dynamic parameter type extensions
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
$passedToTypeto the methods that needed it. However, I opted to rename this tooverriddenTypesince I wasn't quite sure what$passedToTypereally meant. Let me know if there's something you'd rather do differently.
CC: @canvural, @Neol3108
Thanks!
This pull request has been marked as ready for review.
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 😄 )
@calebdw @ondrejmirtes Sorry to bother you, but I wanted to ask how we can move this forward? I'm really interested in this feature.
No worries, just been busy with personal life, I'll try to get to the comments soon
@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: