Re: Re: [VOTE] Userspace operator overloading
| From: | Christoph M. Becker | Date: | Thu, 26 Mar 2020 17:25:56 +0000 |
| Subject: | Re: Re: [VOTE] Userspace operator overloading | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-109346@lists.php.net to get a copy of this message | ||
On 26.03.2020 at 18:18, Guilliam Xavier wrote:
> On Thu, Mar 26, 2020 at 5:37 PM <jan.h.boehmer@gmx.de> wrote:
>>
>> The overloaded concat operator has higher priority than the __toString() method.
>> So if Class A overloades the concat operator, then calling $a . $b means
>> ClassA::__concat($a, $b); (Note that both operands are passed in their original form)
>> If you want to concat the string representations, you will have to explicitly convert the
>> objects to strings:
>> $ret = (string) $a . (string) $b;
>
> This first part seems legit to me.
>
>> If the concat operator is not overloaded, the behavior is like now, and the objects are
>> converted implicitly to strings (so $a . $b actually means (string) $a . (string) $b).
>> Furthermore an notice is triggered, hinting the user that he could overload the concat
>> operator. (Maybe here a different message than for the other operators would be useful).
>
> I fear that "hint" notice could break Symfony apps... Couldn't you
> just not trigger it in this case?
Either that (it's what I would prefer), or clearly document that BC
break (even if it's just about a notice).
Thanks,
Christoph