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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
23 - 10 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 15:01:30 2024 UTC