Bug #25124 [Com]: overload() messes with array member variables

From: Date: Wed, 01 Sep 2021 18:51:23 +0000
Subject: Bug #25124 [Com]: overload() messes with array member variables
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236307@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=25124&edit=1 ID: 25124 Comment by: lildurk25124 at gmail dot com Reported by: ian at ardes dot com Summary: overload() messes with array member variables Status: Not a bug Type: Bug Package: Class/Object related Operating System: * PHP Version: 4CVS-2004-02-11 Block user comment: N Private report: N New Comment: Lil Durk is a private agency dedicated to providing responsible access to legal cannabis for adults aged 19 and older. We’re an exclusively online retailer and wholesaler for recreational cannabis and a trusted source for information about cannabis and cannabis-related issues. We believe our work is meaningful and we take pride in our mandate to promote the socially responsible use of legal cannabis. https://lildurk.com/ Previous Comments: ------------------------------------------------------------------------ [2004-02-24 10:05:24] ian at ardes dot com I thought that the overload functiality only applied to attributes that were not defined: defined attributes are passed over by the magic functions. The example given is of a *defined* attribute being messed up, not an example of attempting to overload with array indexes. If this is expected behavior, then I guess the disclaimer should read something like 'You cannot use array attributes on a class which is overloaded' rather than 'Overloading of array indexes is not supported'. Thanks. ------------------------------------------------------------------------ [2004-02-17 16:37:42] sniper@php.net Expected behaviour -> bogus. ------------------------------------------------------------------------ [2004-02-17 15:52:56] andrei@php.net Overloading of array indexes is not supported. This is expected behavior. ------------------------------------------------------------------------ [2003-08-18 02:34:02] ian at ardes dot com Description: ------------ Summary: When a class is overloaded with overload(), array member variables go wrong. If you overload a class, then access to declared array member variables from within member functions (and anywhere else I think) stops working correctly. The very simple class in the code should not change it's behaviour at all once it is overloaded. But it does. Reproduce code: --------------- class Overloaded { var $_my_array = array(); function Overloaded() { $this->_my_array[1] = '1st element'; } function __get($nm, &$val) { return false; } function __set($nm, $val) { return false; } } $o1 = new Overloaded(); print ("before overload(): "); print_r($o1); overload('Overloaded'); $o2 = new Overloaded(); print ("after overload(): "); print_r($o2); Expected result: ---------------- before overload(): overloaded Object ( [_my_array] => Array ( [1] => 1st element ) ) after overload(): overloaded Object ( [_my_array] => Array ( [1] => 1st element ) ) Actual result: -------------- before overload(): overloaded Object ( [_my_array] => Array ( [1] => 1st element ) ) after overload(): overloaded Object ( [_my_array] => 1st element ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=25124&edit=1

« previous php.bugs (#236307) next »