|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53770 __set Doesn't Allow Pass By Reference (Even On Objects) And Isn't Called On Ref
Submitted: 2011-01-17 22:50 UTC Modified: -
Avg. Score:4.3 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: stormingphoenix at yahoo dot com Assigned:
Status: Open Package: Class/Object related
PHP Version: 5.3.5 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: stormingphoenix at yahoo dot com
New email:
PHP Version: OS:


 [2011-01-17 22:50 UTC] stormingphoenix at yahoo dot com
When using __set($strProp, &$strValue), you are given the error: 

Method foo::__set() cannot take arguments by reference

If, you use $obj->property =& $that it will not call __set at all, but rather auto-create 'property';

Not a major issue, but at the least the __set not being called may need to be fixed.

Test script:
	class foo {
		private $var = NULL;
		function __set($strProp, $strValue) {
	class bar {
		var $that = 'that';
	$that = 'that';
	$foo = new foo();
	$foo->Property =& $that;
	$bar = new bar();
	$foo->Property =& $bar;

Expected result:
string(4) "here" 
undefined variable: $bar

Actual result:
string(4) "that"
object(bar)#7 (1) { ["that"]=> string(4) "that" } 


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Sep 29 04:01:23 2020 UTC