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

fix(eventdispatcher): Don't use all evaluating "or" #38955

Merged
merged 1 commit into from Jul 5, 2023

Conversation

nickvergessen
Copy link
Member

Summary

or is always evaluating all expressions. There is no need to do this here, so in order to emphasize best practises it should be replaced with ||

Checklist

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen added the 3. to review Waiting for reviews label Jun 23, 2023
@nickvergessen nickvergessen added this to the Nextcloud 28 milestone Jun 23, 2023
@nickvergessen nickvergessen self-assigned this Jun 23, 2023
@come-nc
Copy link
Contributor

come-nc commented Jun 26, 2023

Summary

or is always evaluating all expressions. There is no need to do this here, so in order to emphasize best practises it should be replaced with ||

Source?

https://www.php.net/manual/en/language.operators.logical.php does not state that and https://3v4l.org/06rEj shows second part is not evaluated if first one is true.

@nickvergessen
Copy link
Member Author

Arg this is the wrong thing in my brain I can't forget. So it's not about evaluation but about priority. As per docs:

// The constant false is assigned to $f before the "or" operation occurs
// Acts like: (($f = false) or true)
$f = false or true;

So it's not a problem, until someone extracts the condition into a variable. But yeah still bad enough and we shouldn't use it.

@nickvergessen nickvergessen merged commit 75a15dc into master Jul 5, 2023
39 checks passed
@nickvergessen nickvergessen deleted the bugfix/noid/dont-use-or branch July 5, 2023 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants