php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72266 AND and OR combined operators
Submitted: 2016-05-26 11:15 UTC Modified: 2022-04-06 14:07 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: remyfox at hotmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Variables related
PHP Version: Irrelevant OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: remyfox at hotmail dot com
New email:
PHP Version: OS:

 

 [2016-05-26 11:15 UTC] 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();
}


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-08-14 12:55 UTC] 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
 [2022-04-06 14:07 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2022-04-06 14:07 UTC] cmb@php.net
Closing as duplicate of bug #49718.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 10:01:28 2024 UTC