Req #72266 [PATCH]: AND and OR combined operators

From: Date: Wed, 14 Aug 2019 12:55:18 +0000
Subject: Req #72266 [PATCH]: AND and OR combined operators
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222248@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 Patch added by: tolsen@southern.edu Reported by: remyfox at hotmail dot com Summary: AND and OR combined operators Status: Open Type: Feature/Change Request Package: Variables related Operating System: Any PHP Version: Irrelevant Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#222248) next »