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

Clarify if-statements when variable is declared #44

Open
YogiLai opened this issue Feb 18, 2020 · 2 comments
Open

Clarify if-statements when variable is declared #44

YogiLai opened this issue Feb 18, 2020 · 2 comments

Comments

@YogiLai
Copy link

YogiLai commented Feb 18, 2020

代码bug?
bug

@jens1o
Copy link
Contributor

jens1o commented Feb 18, 2020

Thanks for filing the issue and reading/checking the code for errors! :)

No, in fact the = operator has a higher binding than the strictly-not comparison to null.

PS C:\Users\Jens> psysh
Psy Shell v0.9.12 (PHP 7.4.2 — cli) by Justin Hileman
>>> null !== $binary = true
=> true
>>> if (null !== $binary = true) { echo "Win!"; }
Win!⏎
>>> if (null !== ($binary = true)) { echo "Win!"; }
Win!⏎

Yet I'd agree this would increase readability. If you want to file a merge request, you're free to do so! :)

@jens1o jens1o changed the title Code bug? Clarify if-statements when variable is declared Feb 18, 2020
@YogiLai
Copy link
Author

YogiLai commented May 6, 2020

Thank you for your answer

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

2 participants