# __set and reference

- Thread: https://externals.io/message/21180
- Original archive: https://news-web.php.net/php.internals/21180
- Started by Superbiji on 2005-12-12T03:49:06+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #21180 — Superbiji — 2005-12-12T03:49:06+00:00

URL: https://externals.io/message/21180#21180

Hi All,

in prior 5.1, it is allowed to do:
class MyClass {
public function __set($key, &$value) {}
}
$c = new MyClass();
$c->d=10;

in 5.1 up:
that code result this:
Fatal error: Couldn't execute method MyClass::__set in Unknown on line 0

I have submit this bug.
My question is, is it possible to assign as reference using setter method ?


--
kamus online - http://kamus.landak.com/

---

## #21184 — Marcus Boerger — 2005-12-12T07:33:57+00:00

URL: https://externals.io/message/21180#21184 · In reply to: #21180

Hello Superbiji,

Monday, December 12, 2005, 4:49:06 AM, you wrote:

> Hi All,

> in prior 5.1, it is allowed to do:
> class MyClass {
> public function __set($key, &$value) {}
> }
> $c = new MyClass();
> $c->d=10;

> in 5.1 up:
> that code result this:
> Fatal error: Couldn't execute method MyClass::__set in Unknown on line 0

> I have submit this bug.
> My question is, is it possible to assign as reference using setter method ?

So here the answer in slightly more words: No, you have to keep the
signature of __set() thus you cannot assign references using __set().
This was an error we fixed with 5.1.0.

Best regards,
 Marcus

---

## #21185 — Dmitry Stogov — 2005-12-12T07:50:04+00:00

URL: https://externals.io/message/21180#21185 · In reply to: #21180

Assign by reference is not possible with __set() method.

Thanks. Dmitry.

> -----Original Message-----
> From: Superbiji [mailto:superbiji@gmail.com] 
> Sent: Monday, December 12, 2005 6:49 AM
> To: internals@lists.php.net
> Subject: [PHP-DEV] __set and reference
> 
> 
> Hi All,
> 
> in prior 5.1, it is allowed to do:
> class MyClass {
> public function __set($key, &$value) {}
> }
> $c = new MyClass();
> $c->d=10;
> 
> in 5.1 up:
> that code result this:
> Fatal error: Couldn't execute method MyClass::__set in 
> Unknown on line 0
> 
> I have submit this bug.
> My question is, is it possible to assign as reference using 
> setter method ?
> 
> 
> --
> kamus online - http://kamus.landak.com/
