php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23442 Trying to assign a reference inside an overloaded class
Submitted: 2003-05-01 15:23 UTC Modified: 2003-05-01 15:31 UTC
From: dirk at rackspace dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.3.2RC2 OS: Redhat Linux 7.3
Private report: No CVE-ID: None
 [2003-05-01 15:23 UTC] dirk at rackspace dot com
I was trying to assign a defined property inside an overloaded class to point at a non-overloaded class or an array.

I get:
Fatal error: Cannot create references to/from string offsets nor overloaded objects 

I understand the limitation that I cannot store references to overloaded objects - but the error message does not say references are just not allowed inside of overloaded classes.

So is the error message just vague or is this a bug in the way references in overloaded classes work?


Here is code that shows the problem

<?
$list= array(1,2,3,4);
class testList {
    var $list;
    function testList(&$list) {
        $this->list = &$list;
    }
}
class Test {
    var $data;
    var $list;
    function Test (&$list) {
        $this->list = &$list;
    }
    function __set($name,$value) {
    }
}

// Declare the class as overloaded
overload ("Test");
$test=new Test(new testList($list));

print var_dump($test->list);
$list = array(1,2);
print var_dump($test->list);

$test=new Test($list);
print var_dump($test->list);
$list = array(1,2);
print var_dump($test->list);



?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-01 15:31 UTC] dirk at rackspace dot com
It looks like I didn't need the second & inside the constructor for it to keep the reference properly.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Oct 17 19:03:35 2021 UTC