Bug #55021 [NEW]: Multiple bug on variable variable error parse/comportement
| From: | dev at meta-gen dot com | Date: | Fri, 10 Jun 2011 00:07:10 +0000 |
| Subject: | Bug #55021 [NEW]: Multiple bug on variable variable error parse/comportement | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-161269@lists.php.net to get a copy of this message | ||
From:
Operating system: Debian lenny/SID
PHP version: 5.3SVN-2011-06-09 (snap)
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Multiple bug on variable variable error parse/comportement
Description:
------------
When use variable variable with property array in class, a multipe bug
occur.
On function exemple fn, variable variable cast in string
On function exemple fn3, parse error 'Cannot use [] for reading in'
Test script:
---------------
class C
{
public $a = array('first' => 'baz');
/**
* It's work but $this->a is cast in string and override array
* @note $this->a : string(3) "foo"
*/
public function fn($k)
{
$b = 'a';
$this->$b[$k] = 'foo';
}
/**
* Normaly use
* @note Similar result of fn
* @note $this->a : string(3) "foo"
*/
public function fn2($k)
{
$b = 'a';
$this->$b = 'foo';
}
/**
* This case is most interesting, because as it run parse error
* @note don't parse $this->$b
*/
public function fn3($k)
{
$b = 'a';
$this->$b[$k][] = 'foo'; ///BUG Error parse : PHP Fatal
error: Cannot use [] for reading in ....
}
/**
* Solution for fix fn3
*/
public function fn4($k)
{
$b = 'a';
$tmp =& $this->$b;
$tmp[$k][] = 'foo';
}
}
Expected result:
----------------
for function fn('key') : array('first' => 'baz', 'key'
=> 'foo')
for function fn3('key') :
array(2) {
["first"]=>
string(3) "baz"
["key"]=>
array(1) {
[0]=>
string(3) "foo"
}
}
Actual result:
--------------
for function fn('key') : string(3) "foo"
for function fn3('key') : Cannot use [] for reading in...
--
Edit bug report at http://bugs.php.net/bug.php?id=55021&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=55021&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=55021&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=55021&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=55021&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=55021&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=55021&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=55021&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=55021&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=55021&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=55021&r=support
Expected behavior: http://bugs.php.net/fix.php?id=55021&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=55021&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=55021&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=55021&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=55021&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=55021&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=55021&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=55021&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=55021&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=55021&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=55021&r=mysqlcfg