RE: [PHP-DEV] Only variables can be passed by reference
| From: | Christian Stoller | Date: | Thu, 04 Dec 2014 08:47:02 +0000 |
| Subject: | RE: [PHP-DEV] Only variables can be passed by reference | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79415@lists.php.net to get a copy of this message | ||
From: Andrea Faulds [mailto:ajf@ajf.me], Thursday, December 04, 2014 9:33 AM
>
>> On 4 Dec 2014, at 08:28, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
>>
>> Hi all,
>>
>> I think we can get rid of this error now when literal is returned.
>> The reason we have E_STRICT error is that legacy PHP didn't
>> support this, I suppose.
>>
>> http://3v4l.org/8fISj
>
> Hmm, I think there’s some logic to having a warning anyway.
> If a parameter is taken by reference, then it’s > presumably
> going to be modified. So if you pass something that isn’t
> a variable (and therefore the modified result can’t be
> accessed) to a by-reference parameter, it doesn’t really
> make sense.
> --
> Andrea Faulds
> http://ajf.me/
>
I like Yasuo's proposal, because the developer who's passing a
non-variable by reference knows that the change will be lost. But this
could be desired as Yasuo's example shows.
I wished many times that this would be possible...