Skip to content

Conversation

flancer64
Copy link
Contributor

'&&' usage is shorter then '||', if first part of the equity is 'false' then all equity is 'false'

'&&' usage is shorter then '||', if first part of the equity is 'false' then all equity is 'false'
@GordonLesti
Copy link
Contributor

Hello @flancer64
why is && shorter as ||? You have 5 lines instead of 3 or?

@flancer64
Copy link
Contributor Author

flancer64 commented Aug 30, 2016

@GordonLesti PHP should calculate all parts of the complex condition in case of "||" - whole condition will be 'true' if all parts are 'true'. In case of "&&" PHP should compute conditions up to the first 'false'. If first condition is 'true' and second condition is 'false' then equity is 'false' and all other conditions are not calculated at all. This is what I meant when I said "shorter".

   $isSuitableMethodType = (
        !$method->isStatic() &&
        !$method->isFinal() &&
        !$method->isConstructor() &&
        !$method->isDestructor()
    );

If $method->isFinal() returns 'true' then methods $method->isConstructor() and $method->isDestructor() will not be called.

@GordonLesti
Copy link
Contributor

GordonLesti commented Aug 30, 2016

But I guess || is doing the same magic, just contrariwise. The expression

!($method->isConstructor() || $method->isFinal() || $method->isStatic() || $method->isDestructor())

gets false if the first condition $method->isConstructor() returns true.

@flancer64
Copy link
Contributor Author

Yes, it is. You are right :)

@flancer64 flancer64 closed this Aug 30, 2016
@flancer64 flancer64 deleted the patch-12 branch August 30, 2016 16:20
magento-engcom-team pushed a commit that referenced this pull request Nov 10, 2020
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 this pull request may close these issues.

2 participants