From: sven at leon dot uia dot mx
Operating system: All (redhat 90)
PHP version: 5.0.0b1 (beta1)
PHP Bug Type: Class/Object related
Bug description: array returning mechanism from objects?
Description:
------------
Im not sure if it is a bug or not.
with an object inside an object, this is possible:
echo $test->testobject()->color;
with and array inside an object, this is NOT possible:
echo $test->testarray()["color"];
In other words, when an object returns an array, I can not directly access
it.
This will work:
$temparray=$test->testarray();
echo $temparray["color"];
Reproduce code:
---------------
<?php
class c_testobject{
function __construct(){
$this->color="red";
}
}
class c_test{
private $testobject; private $testarray=array("color" => "red");
function testobject(){
$testobject=new c_testobject;
return $testobject;
}
function testarray(){
return $testarray;
}
}
$test=new c_test();
echo $test->testobject()->color;
echo $test->testarray()["color"];
?>
Expected result:
----------------
redred
Actual result:
--------------
Parse error: parse error, expecting `','' or `';'' in
/var/www/html/php-easy/test.php on line 19
--
Edit bug report at http://bugs.php.net/?id=25898&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25898&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25898&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=25898&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=25898&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=25898&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=25898&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=25898&r=support
Expected behavior: http://bugs.php.net/fix.php?id=25898&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=25898&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=25898&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=25898&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25898&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=25898&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=25898&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=25898&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25898&r=float