|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24608 __set not triggered when overloading with array
Submitted: 2003-07-11 12:48 UTC Modified: 2004-01-05 06:53 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: jaanus at heeringson dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2003-11-29 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: jaanus at heeringson dot com
New email:
PHP Version: OS:


 [2003-07-11 12:48 UTC] jaanus at heeringson dot com
When overloading a class with a property containing an array by assigning an element to to the new array the __set handle does not fire, but the element gets created.

Reproduce code:
class myclass {
	public function __set($name,$data) {
		echo("Name: {$name}<br/>\nData: {$data}<br/>\n"); //prints out input when fired

$test=new myclass();
$test->style['temp']='content'; //creates a new property

print_r($test->style); //check if property is created

Expected result:
Results from the echo in __set

Actual result:
The result of the print_r shows that the property is created, but id did not pass the __set


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-16 02:13 UTC]
Have you tried adding a __get() function into the class, and seeing if this returns the same output?
 [2004-01-05 06:53 UTC]
OK, this code actually cannot work (since __set cannot receive the right data to set style['temp'] - it gets only property name, and style['temp'] is not a name). However, you certailnly can make array beforenahd and then assign it to $test->style and it will go through the accessor.

I have fixed it to give an error in this case and not to do things which it is not supposed to do.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 18:01:33 2024 UTC