Doc #71902 [Asn->Csd]: Invalid precedence order of => (T_DOUBLE_ARROW) operator

From: Date: Thu, 31 Mar 2016 16:07:31 +0000
Subject: Doc #71902 [Asn->Csd]: Invalid precedence order of => (T_DOUBLE_ARROW) operator
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13370@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71902&edit=1 ID: 71902 Updated by: cmb@php.net Reported by: vnd at vndh dot net Summary: Invalid precedence order of => (T_DOUBLE_ARROW) operator -Status: Assigned +Status: Closed Type: Documentation Problem Package: Scripting Engine problem Operating System: N/A PHP Version: 5.6.19 Assigned To: cmb Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2016-03-31 16:06:31] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&revision=338859 Log: fixed #71902 (Invalid precedence order of => (T_DOUBLE_ARROW) operator) Actually, T_DOUBLE_ARROW isn't an operator. ------------------------------------------------------------------------ [2016-03-31 15:59:18] cmb@php.net > I'd remove that whole paragraph. ACK. For the record: that paragraph had been added to fix bug #51454, and the "wrong precedence" had already pointed out back then, obviously going unnoticed. > => is weird because it's not really an operator like everything else. ACK. Listing the comma as operator seems even worse, though (bug #66772). ------------------------------------------------------------------------ [2016-03-26 05:33:08] requinix@php.net (Modifying the summary to include searchable terms.) => is weird because it's not really an operator like everything else. It's a token used in other expressions and constructs, like arrays or foreach. I don't think it makes sense to include it in the operator precedence table at all. Then there's > For arrays, assigning a value to a named key is performed using the "=>" > operator. The precedence of this operator is the same as other assignment > operators. In the context of "assignment operators", it suggests to me that one is supposed to write code like $array = array(); $array["foo"] => "bar"; which is, of course, wrong. I'd remove that whole paragraph. ------------------------------------------------------------------------ [2016-03-25 19:50:47] vnd at vndh dot net Description: ------------ The array's value to key assignment operator "=>" priority is less than the priority of operators "and", "xor" and "or". It can be verified by the code attached to this issue. I also assume that this is documentation problem as the priority of logical operators seems valid in the mentioned context. I've found two pages where the documentation is wrong: 1) http://php.net/manual/en/language.operators.assignment.php states that: "The precedence of this operator is the same as other assignment operators". 2) http://php.net/manual/en/language.operators.precedence.php shows that "=>" operator has the same priority as other assignment operators. Test script: --------------- // below expression should not evaluate nor be lexically valid when "=>" has the priority over "and", "xor" or "or" var_dump(array("a" => true and false xor false or false)); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71902&edit=1

« previous php.doc.bugs (#13370) next »