Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,17 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
if ($this->isBooleanButNotTrueAndFalse($node->left)) {
return $this->processBoolTypeToNotBool($node, $node->left, $node->right);
// the rule only applies when one side is a true/false constant;
// check it first to avoid the expensive native type resolution below
if ($this->valueResolver->isTrueOrFalse($node->right)) {
if ($this->isBooleanButNotTrueAndFalse($node->left)) {
return $this->processBoolTypeToNotBool($node, $node->left, $node->right);
}

return null;
}

if ($this->isBooleanButNotTrueAndFalse($node->right)) {
if ($this->valueResolver->isTrueOrFalse($node->left) && $this->isBooleanButNotTrueAndFalse($node->right)) {
return $this->processBoolTypeToNotBool($node, $node->right, $node->left);
}

Expand Down
Loading