Skip to content

Fix logical operator for member and UUID checks#131

Open
denismosolov wants to merge 1 commit into
pubnub:masterfrom
denismosolov:patch-2
Open

Fix logical operator for member and UUID checks#131
denismosolov wants to merge 1 commit into
pubnub:masterfrom
denismosolov:patch-2

Conversation

@denismosolov
Copy link
Copy Markdown

It does not work the way it may look at first glance because of operator precedence (https://www.php.net/manual/en/language.operators.precedence.php )

or is called after the assignment =
|| is called before the assignment =

It is interpreted as:

($members = !empty($this->setMembers)) or !empty($this->removeMembers);

So if:

$this->setMembers has 0 elements → empty(...) is true → !empty(...) is false $this->removeMembers has 1 element → !empty(...) is true

Then:

$members = false;

It does not work the way it may look at first glance because of operator precedence (https://www.php.net/manual/en/language.operators.precedence.php
)

`or` is called after the assignment `=`
`||` is called before the assignment =

It is interpreted as:

```
($members = !empty($this->setMembers)) or !empty($this->removeMembers);
```

So if:

$this->setMembers has 0 elements → empty(...) is true → !empty(...) is false
$this->removeMembers has 1 element → !empty(...) is true

Then:

$members = false;
@pubnub-ops-terraform
Copy link
Copy Markdown

pubnub-ops-terraform commented May 11, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

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