RE: [PHP-DEV] [PATCH] disallow arguments by ref in magic methods
| From: | Dmitry Stogov | Date: | Thu, 30 Aug 2007 13:46:50 +0000 |
| Subject: | RE: [PHP-DEV] [PATCH] disallow arguments by ref in magic methods | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-31985@lists.php.net to get a copy of this message | ||
I like this patch. It prevents stupid errors.
ZE always passes arguments to magic methods by value so they never may be
modified.
Thanks. Dmitry.
> -----Original Message-----
> From: Antony Dovgal [mailto:antony@zend.com]
> Sent: Thursday, August 30, 2007 4:56 PM
> To: php-dev
> Subject: [PHP-DEV] [PATCH] disallow arguments by ref in magic methods
>
>
> Hello.
>
> I'd like to commit these two patches (for HEAD and 5_2
> appropriately). The patches disallow declaring any magic
> methods as accepting arguments by ref (which makes no sense anyway).
>
> Example:
> <?php
> class test {
> function __set(&$name, $val) { }
> }
>
> $t = new test;
> $name = "prop";
> $t->$name = 1;
> ?>
>
> Expected result of this code is:
> Fatal error: Method test::__set() cannot take arguments by
> reference in %s on line %d
>
>
> The diffs:
> http://dev.daylessday.org/diff/magic_by_ref_5_2.diff
> http://dev.daylessday.org/diff/magic_by_ref_HEAD.diff
>
> If there are no objections, I'm going to commit them later in
> the evening.
>
> --
> Wbr,
> Antony Dovgal
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>