Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116026 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 20597 invoked from network); 9 Sep 2021 14:22:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Sep 2021 14:22:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F00E11804DB for ; Thu, 9 Sep 2021 08:00:08 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 9 Sep 2021 08:00:07 -0700 (PDT) Received: by mail-il1-f182.google.com with SMTP id a20so2189059ilq.7 for ; Thu, 09 Sep 2021 08:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=benramsey.com; s=google; h=from:mime-version:subject:date:references:to:in-reply-to:message-id; bh=3xmtTOUHPRQrb+KH7nCKoYOEffi4cC1SgpiR5Aml6DU=; b=DohW6Fwy+8c0AHYkL+w3TddgpWpVyWkF2jPhvGE7a5exXNqc6TYNUWsxIiqq/Ics3w UXGRCmHLNiokgXgjKb6ow5RMuOsyXHyhP2mEClHhUqQuyCvqg/cGs+1Rf0XioO/LLVaB ssNlxSvluNvFrWp64bvGdNkySbcmYPftUfUpUK51MJiNzgCQG/DlB9KKBNlafamZ5MlH 764Wh3LqGzOeN3b/j3IzQhnJPgUq7jjHEnFDYaGzyOiQ0jM0/w6yRwSGHIEMFDDe6gKA UsttD0E1oyyh3ATByqBNeJbexS/U41znBaYoeTxkTw6CF8yMSXeUzTeRO69kzhWL4k5y JjRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:mime-version:subject:date:references:to :in-reply-to:message-id; bh=3xmtTOUHPRQrb+KH7nCKoYOEffi4cC1SgpiR5Aml6DU=; b=gEDFVq3LkyDZC2Sje6cqvNiQHvo7pN9bXV+AXCDinf/G9SOeQdEuJrtlBtwl7psIt8 BZpBAvKBWOOMQrtwxnMlg4XFZeWfK3JcqBgykWeGe91KmjYa0h3tAoYSdHRa/t9VDgnP tt89TqlR+lOSBiSztX2DD2/zSMFxmN+M0hhqxXJXuTbHJctQVfxyNVokbH8nurk04XBR 3pbrdZxCGYiw5hvsIAOLp1HwaWSKjnoJnhCGVWQJwRuJ2NZe83MpMbq3WJgJSGF1c34r xaQys8uVlpJNLvCKbccgwcqr7kAoPO/VA9kz+Gy+pe5ccfBrGNJFPV2N8UIIUwEWvB/W RHSA== X-Gm-Message-State: AOAM530a/jlokdXcZ95ZFM0M6kOtOtV8+pbNiLKsRhiSp7wzKd44XzB0 FKtxEzVf9L787+zIPI+20hdB72GA8H4vWA== X-Google-Smtp-Source: ABdhPJxNxlt1KqQ7VhUDl+X1zlFiR0eIR7Dg4RFQ5ouzQvLK6pd4nfdDqiizGAR5w+HE+L2c95rPiA== X-Received: by 2002:a92:6b0a:: with SMTP id g10mr2570179ilc.27.1631199606797; Thu, 09 Sep 2021 08:00:06 -0700 (PDT) Received: from smtpclient.apple (h96-61-105-82.lvrgtn.broadband.dynamic.tds.net. [96.61.105.82]) by smtp.gmail.com with ESMTPSA id p11sm1002189ilm.61.2021.09.09.08.00.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Sep 2021 08:00:05 -0700 (PDT) Content-Type: multipart/signed; boundary="Apple-Mail=_68547D94-8B59-45EE-99C9-838BC7ECBCE7"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Date: Thu, 9 Sep 2021 10:00:03 -0500 References: <75e31735-f082-5b05-1df3-40f14e0e9351@php.net> <30A88C4C-2156-43A9-A4AF-5EBCEA3ECCF8@newclarity.net> To: php internals In-Reply-To: <30A88C4C-2156-43A9-A4AF-5EBCEA3ECCF8@newclarity.net> Message-ID: X-Mailer: Apple Mail (2.3654.120.0.1.13) Subject: Re: [PHP-DEV] [RFC] $this return type From: ben@benramsey.com (Ben Ramsey) --Apple-Mail=_68547D94-8B59-45EE-99C9-838BC7ECBCE7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 9, 2021, at 09:47, Mike Schinkel wrote: >=20 >> On Sep 9, 2021, at 10:26 AM, Fl=C3=A1vio Heleno = wrote: >>=20 >> On Tue, Sep 7, 2021 at 10:27 AM Sebastian Bergmann = >> wrote: >>=20 >>> 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. >>>=20 >>> 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. >>>=20 >>> Off the top of my head, I think that "same" could make sense. >>>=20 >>> -- >>> PHP Internals - PHP Runtime Development Mailing List >>> To unsubscribe, visit: https://www.php.net/unsub.php >>>=20 >>>=20 >> Hi all, >>=20 >> 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();")? >=20 > So a *mutable* fluent style vs. an *immutable* fluent style? >=20 > -Mike For clarity, in comparing to `self` and `static`=E2=80=A6 `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 --Apple-Mail=_68547D94-8B59-45EE-99C9-838BC7ECBCE7 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iHUEAREIAB0WIQToXQMR3fpbrPOmEOewLZeYnIwHGwUCYTohcwAKCRCwLZeYnIwH G8MJAP9P0gf1aGGVhDR7NUa1SkvXcm+dtNyEp0anUiMvAlH23QD/dyFZWaDg270n nVLmkj9sRNiz0BHETQF1ij8BN81ZklQ= =yocV -----END PGP SIGNATURE----- --Apple-Mail=_68547D94-8B59-45EE-99C9-838BC7ECBCE7--