Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConditionalExpressionTypes todos #8360

Open
4 of 13 tasks
rajyan opened this issue Nov 13, 2022 · 9 comments
Open
4 of 13 tasks

ConditionalExpressionTypes todos #8360

rajyan opened this issue Nov 13, 2022 · 9 comments

Comments

@rajyan
Copy link
Contributor

rajyan commented Nov 13, 2022

Feature request

Make ConditionalExpressionTypes to work for all expressions

Add conditional types for these types of dependent types

Replace conditionalExpressionTypes with a LateResolvableType

  • Create a LateResolvableType to handle conditionalExpressionTypes
  • Replace conditionalExpressionTypes usage in MutatingScope
  • Replace conditionalExpressionTypes usage in NodeScopeResolver
  • Replace conditionalExpressionTypes usage in TypeSpecifier
@staabm
Copy link
Contributor

staabm commented Nov 15, 2022

Not sure its goal of this issue, but this should also work:

https://phpstan.org/r/fada5ae5-5144-4a85-8c93-f0079fe49b4c

@rajyan
Copy link
Contributor Author

rajyan commented Nov 15, 2022

Thank you for the example. This should work after

Make processBooleanConditionalTypes work for all expressions

is done:+1:

@rajyan
Copy link
Contributor Author

rajyan commented Dec 2, 2022

https://phpstan.org/r/8dba4abf-3e1c-499b-9c43-92495d677850

some examples of non working assertainty

@rajyan
Copy link
Contributor Author

rajyan commented Dec 2, 2022

Brain stormed a lot about conditional types, I think merging them as LateResolvableType might not be possible.
Maybe there is a hint in muglug's comment
#3677

@rajyan
Copy link
Contributor Author

rajyan commented Dec 2, 2022

Merging conditional types can be improved than simple intersection.
we can delete resolved conditions here
https://github.com/phpstan/phpstan-src/pull/2030/files#diff-dc817f2bab8672057a95375a542e68599164f6ab2380e4cccd1b50583e295d85R3737-R3752
if the conditional type is same as the other variable type we don't have to delete the conditional types.

https://github.com/phpstan/phpstan-src/blob/615dcd274a8d4b6e8da9a01a1b69df19a2dbbbb6/tests/PHPStan/Analyser/data/bug-8361.php#L1-L32

This test should be helpful when making that improvemnet

@rajyan
Copy link
Contributor Author

rajyan commented Dec 6, 2022

Another improvement I can think of

https://github.com/phpstan/phpstan-src/pull/2056/files#diff-1df21d1d92824f6e7a9f5a77cb3af7c598a540f19507d1d9851fe4c4f4cfbb58R32

we can resolve conditional type here for union types

@rajyan
Copy link
Contributor Author

rajyan commented Dec 7, 2022

@rajyan
Copy link
Contributor Author

rajyan commented Dec 8, 2022

@rajyan
Copy link
Contributor Author

rajyan commented Dec 17, 2022

#8543 (comment)

The conditional type seems created before the assign? and invalidated?

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

No branches or pull requests

3 participants