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

Type hinting PHPStan for Facing #89

Open
ShockedPlot7560 opened this issue Oct 8, 2023 · 1 comment · May be fixed by #91
Open

Type hinting PHPStan for Facing #89

ShockedPlot7560 opened this issue Oct 8, 2023 · 1 comment · May be fixed by #91

Comments

@ShockedPlot7560
Copy link
Member

It may be useful to specify the expected return type of Facing functions with: value-of<Facing::ALL>.

This can break many static analyses, because depending on the PHPstan levels, it will carry over if you pass a simple integer into a function accepting just a few values.

I think this option is worth considering, as it could prevent certain runtime errors in the event of an unaccepted value being supplied?

@dktapps
Copy link
Member

dktapps commented Oct 8, 2023

A better option is likely to just turn Facing into an enum. The PHPStan annotations of that sort have caused a great deal of headaches in the past due to easily lost type information when doing almost anything with the values.

@Dhaiven Dhaiven linked a pull request Nov 19, 2023 that will close this issue
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 a pull request may close this issue.

2 participants