Bug #69194 [Opn->Nab]: Variable variables using an array to call a method broken
| From: | nikic@php.net | Date: | Thu, 05 Mar 2015 17:39:13 +0000 |
| Subject: | Bug #69194 [Opn->Nab]: Variable variables using an array to call a method broken | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-191196@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69194&edit=1
ID: 69194
Updated by: nikic@php.net
Reported by: donatj at gmail dot com
Summary: Variable variables using an array to call a method
broken
-Status: Open
+Status: Not a bug
Type: Bug
Package: Variables related
Operating System: Irrelevant
PHP Version: master-Git-2015-03-05 (Git)
Block user comment: N
Private report: N
New Comment:
This is an intentional BC break in PHP 7, please write $baz->{$qux["quux"]}() instead.
See https://github.com/php/php-src/blob/master/UPGRADING#L27
for a summary of related changes and https://wiki.php.net/rfc/uniform_variable_syntax
for detailed information.
Previous Comments:
------------------------------------------------------------------------
[2015-03-05 17:32:59] donatj at gmail dot com
Description:
------------
http://3v4l.org/3NKUS
The problem is illustrated here. It is causing a number of my tests to fail in 7 using build
20150201.
Test script:
---------------
<?php
class Foo {
function bar(){
echo "Futbal";
}
}
$baz = new Foo;
$qux = array("quux" => "bar");
$baz->$qux["quux"]();
Expected result:
----------------
"Futbal"
Actual result:
--------------
Notice: Array to string conversion in /in/3NKUS on line 13
Notice: Undefined property: Foo::$Array in /in/3NKUS on line 13
Fatal error: Function name must be a string in /in/3NKUS on line 13
Process exited with code 255.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69194&edit=1