Bug #78017 [Opn->Nab]: Null coalesce operator in if paranthesis causes unexpected behaviour
[email protected] Wed, 15 May 2019 13:37:17 +0000
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=78017&edit=1 ID: 78017 Updated by: [email protected] 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