Req #72266 [Opn->Dup]: AND and OR combined operators
| From: | cmb@php.net | Date: | Wed, 06 Apr 2022 14:07:37 +0000 |
| Subject: | Req #72266 [Opn->Dup]: AND and OR combined operators | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-240704@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72266&edit=1
ID: 72266
Updated by: cmb@php.net
Reported by: remyfox at hotmail dot com
Summary: AND and OR combined operators
-Status: Open
+Status: Duplicate
Type: Feature/Change Request
Package: Variables related
Operating System: Any
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Closing as duplicate of bug #49718.
Previous Comments:
------------------------------------------------------------------------
[2019-08-14 12:55:18] tolsen at southern dot edu
The following pull request has been associated:
Patch Name: Added request #72266
On GitHub: https://github.com/php/php-src/pull/4535
Patch: https://github.com/php/php-src/pull/4535.patch
------------------------------------------------------------------------
[2016-05-26 11:15:35] remyfox at hotmail dot com
Description:
------------
From the manual http://php.net/manual/en/language.operators.assignment.php:
there are "combined operators" for all of the binary arithmetic, array union and string
operators that allow you to use a value in an expression and then set its value to the result of
that expression.
Wouldn't it be better to allow combined operations for all binary operators? It seems arbitrary
that some binary operators (such as the logical ones) don't support this. There seem to be
plenty of use cases.
Test script:
---------------
// In a system where a user obtains a permission if he has at least one role that gives such a
permission.
$permitted = false;
foreach ($user_roles as $user_role) {
$permitted ||= $user_role["permitted"];
}
// In a system where multiple validations exists which each return a boolean.
$valid = true;
foreach ($validations as $validation) {
$valid &&= $validation();
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72266&edit=1