Skip to content

Combine multiple isset() calls when possible #22684

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

Closed
wants to merge 1 commit into from

Conversation

javiereguiluz
Copy link
Member

Q A
Branch? 2.7
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

isset($a) && isset($b) is the same as isset($a, $b), so we can save some function calls.

@stof
Copy link
Member

stof commented May 10, 2017

this does not change anything. isset is not a function in PHP. and both codes are generating exactly the same opcodes: https://3v4l.org/ZvRAY/vld#output

So I suggest keeping the existing code, which is more readable IMO.

@javiereguiluz
Copy link
Member Author

It's true that this doesn't save any function call. My bad!

If you don't think that the new version is more readable, let's close it. Thanks!

@stof
Copy link
Member

stof commented May 10, 2017

Well, with 2 arguments, people have to remember that isset does a AND. With the existing code, the operator is explicit. So this makes it a bit easier for people not remembering the exact behavior.
Note however that my preference would not be strong enough to make us change the codebase if we were already using the combined version. But I don't think switching to the combined version is worth it.

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

Successfully merging this pull request may close these issues.

3 participants