feat: add dynamic parameter type extensions - #4290
Conversation
49c7da8 to
58e51fb
Compare
58e51fb to
79de0a6
Compare
|
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 😄 ) |
79de0a6 to
7c605c1
Compare
ondrejmirtes
left a comment
There was a problem hiding this comment.
This looks solid, just a few questions as a start, will do deep review later 👍
|
@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 |
b9ce6ac to
b293d32
Compare
|
@ondrejmirtes, @canvural, sorry it took so long to address these comments---just been busy with personal life but hoping to move this forward now 🙏 |
b293d32 to
16430bf
Compare
|
@calebdw - is this still planned on going ahead? Does this fix the issue with using whereHas with custom builders? I've seen multiple projects now look to using custom builders since the implementation of the attribute & official support from Laravel last year, only to find issues when trying to type the arguments in eloquent method for type hints / auto complete, etc. https://laravel-news.com/defining-a-dedicated-query-builder-in-laravel-12-with-php-attributes In the meantime, we have been using whereRelation, which compiles to whereHas under the hood, but it would be nice to use whereHas directly.
|
|
My team are also eagerly awaiting the outcome of this PR! Hope it can be pushed forward 🙏 |
08bc956 to
7823716
Compare
|
@CamKemBell, yes I just rebased and resolved all the conflicts @ondrejmirtes, this is ready to review 👍 |
7823716 to
9e68ce4
Compare
|
What is the status on this PR? |
|
Hi @calebdw sorry for the delay there is now more review for the PHPStan codebase. Are you still interested by the PR ? Thanks ! |
9e68ce4 to
c67e140
Compare
There was a problem hiding this comment.
I think it looks mostly good, a few questions
- if I did not miss it, it seems none of the tests is covering a error case?
- $overriddenType is passed thru a lot of handlers. I think we should have a few more tests which show that the overridden type gets correctly passed thru complex expressions
- I wonder if we really need end-to-end test-cases only or whether we could at least have some in-phpunit suite tests (these are easier to run, debug and maintain)
- you should look into issue-bot results and judge whether these are expected/related (some of them might go-away after rebase)
- we need this PR to target 2.2.x
|
@calebdw Would you have time to address the comments? Or if you allow, I can open another PR with your code and fix there. |
|
Yes, sorry been busy---I'll get to this shortly |
0a17a77 to
79dd1ad
Compare
| path: phpstan-dist | ||
| token: ${{ secrets.PHPSTAN_BOT_TOKEN }} | ||
| ref: 2.1.x | ||
| ref: 2.2.x |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| ref: 2.1.x | ||
| ref: 2.2.x |
There was a problem hiding this comment.
zizmor found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
79dd1ad to
edb86a0
Compare
3e2e16d to
9b99f72
Compare
|
Tested the latest PHAR, still works alright 👍🏽 Static analysis fails on CI looks legit though. But didn't happen at runtime 🤔 Maybe didn't hit that code path. |
|
Would love to see this over the line... |
|
Can I sponsor/pay someone to bring this over the finish line? Resolving conflicts <--> wait for review loop doesn't seem to end 😄 |
0bb1ff7 to
849e432
Compare
I've added tests
Same here, added tests
The existing |
849e432 to
cdeb328
Compare
0354bcc to
3e72bd1
Compare
3e72bd1 to
ee0d648
Compare

Closes phpstan/phpstan#11707, closes phpstan/phpstan#12585
Supersedes #3828, supersedes #3131, supersedes #3823
Hello!
This adds generalized dynamic parameter type extensions and deprecates the parameter closure type extensions per phpstan/phpstan#11707 (comment).
This also fixes the
return.typeand theargument.typeerrors described in phpstan/phpstan#12585 when the parameter type is overridden via the extension.Note
This currently only works for array and closure arguments, if support is desired for other argument types in the future then that will have to be added.
CC: @canvural, @Neol3108
Thanks!