Doc #70095 [Opn->Csd]: Operator precedence changed in PHP 7
Edit report at https://bugs.php.net/bug.php?id=70095&edit=1
ID: 70095
Updated by: cmb@php.net
Reported by: me at evertpot dot com
Summary: Operator precedence changed in PHP 7
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Scripting Engine problem
Operating System: Any
PHP Version: 7.0.0beta1
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Since this issue is now documented in the migration guide[1], and
also has a cautionary note in the variable variables section[2],
this ticket can be closed.
[1] <http://www.php.net/manual/en/migration70.incompatible.php#migration70.incompatible.variable-handling.indirect>
[2] <http://www.php.net/manual/en/language.variables.variable.php>
Previous Comments:
------------------------------------------------------------------------
[2015-07-18 16:37:29] pasindu@php.net
This is probably not documented, TODO for documentation
------------------------------------------------------------------------
[2015-07-18 16:19:14] requinix@php.net
Yes, it's intentional. https://wiki.php.net/rfc/uniform_variable_syntax
------------------------------------------------------------------------
[2015-07-18 16:14:49] me at evertpot dot com
Description:
------------
The code from the description now has a different output. I'm not sure if it's
intentional, so I decided to post it as a bug. It's definitely a BC change.
Also see:
http://3v4l.org/pE0UN
Test script:
---------------
<?php
$foo = [
'a' => 'b'
];
$bar = [
'b' => 'c'
];
$bar = (object)$bar;
// Note that the following line is interpreted as
// $bar->b in PHP < 7, and $bar->Array in PHP > 7.
echo $bar->$foo['a'];
Expected result:
----------------
c
Actual result:
--------------
Notice: Array to string conversion in /in/pE0UN on line 14 Notice: Undefined property:
stdClass::$Array in /in/pE0UN on line 14
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70095&edit=1
Thread (3 messages)