php.net |  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
Votes:1
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:
 [2003-07-11 12:48 UTC] jaanus at heeringson dot com
Description:
------------
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:
---------------
<?php
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-16 02:13 UTC] andrew@php.net
Have you tried adding a __get() function into the class, and seeing if this returns the same output?
 [2004-01-05 06:53 UTC] stas@php.net
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-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 22:02:05 2014 UTC