> On Sep 9, 2021, at 09:47, Mike Schinkel <m...@newclarity.net> wrote:
> 
>> On Sep 9, 2021, at 10:26 AM, Flávio Heleno <flaviohbati...@gmail.com> wrote:
>> 
>> On Tue, Sep 7, 2021 at 10:27 AM Sebastian Bergmann <sebast...@php.net>
>> wrote:
>> 
>>> Am 07.09.2021 um 12:28 schrieb Nikita Popov:
>>>> I have some reservations about this (which basically come down to $this
>>> not
>>>> being a proper "type", so should it be in the type system?) but I can see
>>>> the practical usefulness, so I think it's worth discussing this.
>>> 
>>> I am not conviced that there is enough value in this to introduce syntax
>>> for it, but if at all, then please not "$this" as the name for a type.
>>> 
>>> Off the top of my head, I think that "same" could make sense.
>>> 
>>> --
>>> PHP Internals - PHP Runtime Development Mailing List
>>> To unsubscribe, visit: https://www.php.net/unsub.php
>>> 
>>> 
>> Hi all,
>> 
>> I'm sorry if I'm being naive, or simply put dumb, but the main difference
>> that we're trying
>> to achieve with having "$this" (or variations of it) as a valid return type
>> as opposed to simply
>> using "self" is to ensure that the underlying code is actually doing a
>> "return $this" rather
>> than returning any other valid "self" instance (such as "return new
>> self();")?
> 
> So a *mutable* fluent style vs. an *immutable* fluent style?
> 
> -Mike


For clarity, in comparing to `self` and `static`…


`self`
:   the return value must be an instance of the same class that sets
    this type declaration


`static`
:   the return value must be an instance of the same class that calls
    the method with this type declaration


`$this`
:   the return value must be the same instance as the instance that
    calls the method with this type declaration


Cheers,
Ben


Attachment: signature.asc
Description: Message signed with OpenPGP

Reply via email to