Bug #78017 [Opn->Nab]: Null coalesce operator in if paranthesis causes unexpected behaviour
| From: | nikic@php.net | Date: | Wed, 15 May 2019 13:37:17 +0000 |
| Subject: | Bug #78017 [Opn->Nab]: Null coalesce operator in if paranthesis causes unexpected behaviour | ||
| References: | 1 | Groups: | php.standards |
| Request: | Send a blank email to standards-+get-1441@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78017&edit=1
ID: 78017
Updated by: nikic@php.net
Reported by: dorndorf at featdd dot de
Summary: Null coalesce operator in if paranthesis causes
unexpected behaviour
-Status: Open
+Status: Not a bug
Type: Bug
Package: PHP Language Specification
Operating System: macOS 10.14.4
PHP Version: 7.2.18
Block user comment: N
Private report: N
New Comment:
?? has lower precedence than &&, so this is true ?? (false && 0 > 0). See https://www.php.net/manual/en/language.operators.precedence.php
for operator precedence in PHP.
Previous Comments:
------------------------------------------------------------------------
[2019-05-15 13:26:07] dorndorf at featdd dot de
Description:
------------
Using the null coalesce operator inside an if paranthesis using and resulting in false will match
the condition anyway when the returned value is true.
Test script:
---------------
if (true ?? false && 0 > 0) {
echo 'Should not be true';
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78017&edit=1