Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115993 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 2314 invoked from network); 7 Sep 2021 12:46:40 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Sep 2021 12:46:40 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 09FE3180003 for ; Tue, 7 Sep 2021 06:24:06 -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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (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 ; Tue, 7 Sep 2021 06:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1631021043; bh=TKQfK20pBciJqYPnFyeZ1GkRs9l8kA1eem8w4rc8nDE=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=NKLW37jzdoPTLnILhEVjJO49wH+UwfZZi+Py90NE+K4kIy/imZTyQkwtiigRJK+8a DRYaD1l9hv/nIYJK4lzu7wdZjSqhWoZAVyLXJmp4/K5YWPH+bAXLKO5qHoxDoqM5OT 7q3+iZAeo69NjhVB8w61tkB++f7C3m1u7elwWDl0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.2.130] ([79.222.39.90]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M7b6l-1mK2hy1ACL-007zIj; Tue, 07 Sep 2021 15:24:03 +0200 To: Andreas Heigl , internals@lists.php.net References: Message-ID: <341d3b94-01ff-156c-fb80-0c036fb1b55a@gmx.de> Date: Tue, 7 Sep 2021 15:24:02 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:JgcGDajJiUBM8DEkGD1u99tBl6459Mr9+b67cyAvDfQT/npSTSN nYiVNImJt/MbLfMNbSrYxOYGbXmpXfxIwDE3j3TK3zSgg2/lZLtKpzsHPY4wghtZRYpLFaj ndfAIm0YsaEbd1dXUIKEgUOAPJ4saXvJCTdvSFz0+2I9QmisAvXrh1BRCtYH40a49oZtcga l2LoIiuPl1t1j/t30wQgQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:YOkpSCNS/Wg=:sUtnCwxZ5P/Fa92zhf7oM2 PvmkDIzImYuuA/SkBkdS2wFaXMRiwZNspKqQi+Z3kUZ7sEPFs1j8DNHHrmUGWTZcX1qwlxJXZ UyWa6epwf0cCxUzHyHOLaA/+0UghRCARxoXjE9DhzqOYTmpZCtlw+huJ7CKqZZ06Bkfmc6HjI VOL5vhq65L/XkuSnKE92IqNGgGCnK0JVB2sZd1NAq33bIsb90afA/3nQWO8nu2W60JgBaZ09r zLbmABWkWa4xdoAgDwUj0PGvt9QDQcComxXiEQnU9UjDj5Z7hFKoskMeNO5TTiLZJWF4AwCVg L036VC9lVtQJS/0ALmyFi96g741j5OmU1pQ6F0rgXzn+v3RkUGM1ycuzBblgtUfp1vg4krgTa lmjDbVQg+ct9J6fGJSpJ0fPqJY4VfNrKdTdwEbsDBt3nA2wzqFw7/4w7wT/PRvsxu2zMz8fJt JJkFR3OJCdobglKNpj4znzafZHdPbJKD5DpVu6CGfpOoiQM0u/rSCp2zgJgb387GRxRmJu3X/ jX+XPN7oqlLypoZqYS1qJv3BeD+EsA/fj6fegxkgXWXKdnWhaDJhLZHAPbxyG80NNJfvORwz2 lJdhaeDaPjKmY5WuhiAtwW3RaHHWElkxqpUCPlXS/JSJSaIyaW3SoZ791tt3VTEtOflBBxqqx QDjDIVkJqxO6APfIwWdQZca1BfwbrOT7TGOu2Sn06yyb8H6F7r8wuUsp0QFvudsuMz7ypzeXQ 3wWP5xqRS6uvURDujL5hM7hCDu/DEJ0sqFIwCnQdejocqUrsOB7kIJGojHdxSVZKgGCv4D5W8 dvdH/Ica7adzGWH5jth/Umx8/4mcsmfrOfoRuapR19mLvQSd5DTOwFNcZPSuUp82XnaAQwBq7 wo0GzfwZ1oVPchCHPraJFsreniPWT7LE0+OnhVRAtuVz7pedjOvSMPDowHkW3PaIPU4w0tRO3 AnNN2a3Te6KHAOkyLHIO8EySD1ilmgPR+a2jdGNs23irgdatmPN+hhIGcEmHA8L5IWgBljFyp D23TO2NYPQEHi7v9XO7BRWPS1DnGFHUc3sNF+0NaeOGqsGJmGkH+g6d0WlHQsi/lna2Yz0Jje Zp3hjLfX9PROkF+Y1x4K66zDxKaF32ZHm38eTqoW/ro4QEKXxTvcKI5+A== Subject: Re: [PHP-DEV] [RFC] $this return type From: cmbecker69@gmx.de ("Christoph M. Becker") On 07.09.2021 at 15:02, Andreas Heigl wrote: > On 07.09.21 12:28, Nikita Popov wrote: > >> I'd like to pick up a loose thread from the future scope of the >> https://wiki.php.net/rfc/static_return_type RFC, the $this return type >> for >> fluent APIs: >> >> https://wiki.php.net/rfc/this_return_type >> >> 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 s= ee >> the practical usefulness, so I think it's worth discussing this. > > If we allow a $this (let's keep the actual naming out for the moment) as > a returntype to clarify that it has to be the same instance that is > returned, I would also either expect that the returntype 'self' does > explicitly *not* allow the same instance to be returned. As that would > be a huge BC break I would on the other hand also think that we should > implement a returntype "!$this" to explicitly state that the contract > here returns *not*=C2=A0 the current instance but a new one. That way a = lot > of immutable contracts could be made more clear. > > What'S your or others idea regarding that? In my opinion, we should not muddy the waters here. $this is not a type. Instead we should consider to head for a more general solution, namely suporting post-conditions, i.e. assertions which are part of the function/method signature. But that would certainly be the topic of another RFC. Christoph