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

Generic typing of Option::fromValue results in Option<valueType|null> #63

Open
arnaud-lb opened this issue Mar 9, 2022 · 0 comments
Open

Comments

@arnaud-lb
Copy link

Option::fromValue uses the same type parameter C for the $value and $noneValue parameters. As a result, the type of C is inferred to a union of the types of $value and $noneValue:

https://phpstan.org/r/af2d3270-93fe-463a-9a29-4dd584012cc3

Typing $noneValue to mixed fixes the problem:

https://phpstan.org/r/c105ea3e-21e2-4dbc-a119-36fd1154ef3e

I believe that this would be ok since $noneValue doesn't contribute to type of Option.

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

No branches or pull requests

1 participant