Skip to content

Implement ParameterOutTypeExtensions#3083

Merged
ondrejmirtes merged 4 commits intophpstan:1.11.xfrom
staabm:param-out-ext
Jun 20, 2024
Merged

Implement ParameterOutTypeExtensions#3083
ondrejmirtes merged 4 commits intophpstan:1.11.xfrom
staabm:param-out-ext

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented May 19, 2024

@staabm staabm marked this pull request as ready for review May 19, 2024 17:22
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@staabm
Copy link
Contributor Author

staabm commented May 19, 2024

I am not yet sure this feature is useful for the preg_match inference, because the type depends on context: https://github.com/phpstan/phpstan-src/pull/2589/files#diff-65e7da030813493bd5e549d34d89e84b206ed1f44cfc490ffaa52dcba136bd9bR128

@staabm
Copy link
Contributor Author

staabm commented May 20, 2024

Thinking more about it: maybe we need a param out type which depends on the function call return type for the preg_match case

@ondrejmirtes
Copy link
Member

My question is: How important that is? Can it work without this condition in the first release? I have some ideas but it'd require some exploration (conditional types).

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise 👍

@staabm
Copy link
Contributor Author

staabm commented May 20, 2024

My question is: How important that is? Can it work without this condition in the first release? I have some ideas but it'd require some exploration (conditional types).

we will see when looking into it. I think this PR as is also makes sense in general.

I think conditional param-out types could work.

@staabm staabm force-pushed the param-out-ext branch 3 times, most recently from d7fcc22 to b872fd6 Compare May 24, 2024 15:46
Copy link
Contributor Author

@staabm staabm May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this code path only exec on variables and not e.g. on PropertyFetch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can explore that in another PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this realistically ever return multiple types? I feel like the union should be done inside this method, and the method should return ?Type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can explore that in another PR.

@staabm staabm force-pushed the param-out-ext branch 2 times, most recently from 54481e3 to 2b593ec Compare June 17, 2024 06:10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've recently started dropping the "dynamic" part of the name from an extension. See FunctionParameterClosureTypeExtension for example.

Since you're also applying it here inconsistently (you're not mentioning "dynamic" in the PR title, and also LazyParameterOutTypeExtensionProvider doesn't contain it), please drop it from all the names in this PR. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@ondrejmirtes ondrejmirtes merged commit 3cbf045 into phpstan:1.11.x Jun 20, 2024
@ondrejmirtes
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants