php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #70095 Operator precedence changed in PHP 7
Submitted: 2015-07-18 16:14 UTC Modified: 2018-05-05 11:00 UTC
Votes:2
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: me at evertpot dot com Assigned: cmb (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.0.0beta1 OS: Any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: me at evertpot dot com
New email:
PHP Version: OS:

 

 [2015-07-18 16:14 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-18 16:19 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2015-07-18 16:19 UTC] requinix@php.net
Yes, it's intentional. https://wiki.php.net/rfc/uniform_variable_syntax
 [2015-07-18 16:37 UTC] pasindu@php.net
-Status: Not a bug +Status: Assigned -Type: Bug +Type: Documentation Problem -Assigned To: +Assigned To: pasindu
 [2015-07-18 16:37 UTC] pasindu@php.net
This is probably not documented, TODO for documentation
 [2017-10-24 06:28 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: pasindu +Assigned To:
 [2018-05-05 11:00 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2018-05-05 11:00 UTC] cmb@php.net
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>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 11:01:28 2024 UTC