Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129142 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id E325B1A00BC for ; Fri, 7 Nov 2025 21:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762551337; bh=4Xi/mwgAAks95grAVUjjLReM7KoWmWdxm5yO1+WBnvw=; h=Date:From:To:In-Reply-To:References:Subject:From; b=PapIO5hUP7NuyvY2QKh7CZ2RErGJYIKOF+RSZDu9//uIOfxeCoz9kjrvjS0h5dix4 MbMky+FUrb0ojKL9RY8+pGgzX+MPvRmPvRNs9Xyf/MxGkNKbppNxAZ/oIbtaEyH0gP IZrs39ym6c12tC9MEHAWEL6SagN92eTcItUekstyoQWFhy8RGvjTzFgrJfkzahk5Ey BSPHbR48iNMxf1FOhi54xntjegkPUL/FkB6Pndf8uN82TONnEuHKGIHPPlMhQnHYPH LfN0VvU7Mmlcb4khZAwr0Z3//4ejL90p1EgNh9yTTVAdDbrR/eXs1lRcBfQnKBfiTv 3Z4p2SccbfUMw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E0E2E180078 for ; Fri, 7 Nov 2025 21:35:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-b4-smtp.messagingengine.com (fout-b4-smtp.messagingengine.com [202.12.124.147]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 7 Nov 2025 21:35:36 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 9327C1D00150 for ; Fri, 7 Nov 2025 16:35:31 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Fri, 07 Nov 2025 16:35:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm3; t=1762551331; x=1762637731; bh=T4VREj7iLhqqdP+wyt1Xq eFMc5Hud2Xsk6MoWB4qiJM=; b=O8ii6+y6/5hodpr6Rw3ZQkFIbCL/mT6GcUWw7 CPkmhFwcQDyiOcQVkZ/EY3gFYyGJK97kF/X0UNenI3K/zCz+xreg7mKEskKOJ/BK 1Mj+aQzgyKtqT/4yjDB6f6xICWj7+dQTPICiI30c29/b8+E31f4WlnKqMqW2owAd AU0Vrb/++1pDJsS3PFkxo55yVDK0A8w9qZ+6cQDLdcvqbO1VRNew9/23cKCygxcA YoZEKzTEjXHQW9/5tRUVlO36w/6m3j1tg9d7X7sSUPQnmjwNCot8ltAcplNCJipU XpnSky5rhp5410M1bNEl9ijVDRidzTC6jb1K6Klr5mrwRytqA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1762551331; x=1762637731; bh=T 4VREj7iLhqqdP+wyt1XqeFMc5Hud2Xsk6MoWB4qiJM=; b=jg6YknGBd2qqZK0TE IQVRA3RxGtZWlXlMST3jezeiwucL2tsVx0OHrqSCsPM2eYrKcruwQ2oNe++fd+au qbZ+zP3MREWf1eH7cPoD8LoW/g+YUYybj2zyxNaGrPdtde70/NBP9sbUNNHxFeBW hibcW8eC0w2lzCO6BLd77JrOL3LAiJIIiUeXo7wtOqhEDwNOW3H0tYvfZRPok+5I RRf9dx9JPZJWJ5pREF/OmP1UwzOCuvjN9+Fv3eo9kAaa/65x2FsjGYXibDzH7Zvy okTt7R6eruG3PTirvRZW7t1rqJxkGdNyQgNluiD2CvrOecxxjvvJ2YB6Z32Do5E/ YvshA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduledtjeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthhqredtredtjeenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpeffieeivdfhvdeguddttdegteeiueegvefhteehfeeffeet udeitdehtdegjeeuieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghrtghp thhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsh eslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 2A1F7700054; Fri, 7 Nov 2025 16:35:31 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: AW0xd6Hg98_- Date: Fri, 07 Nov 2025 15:34:56 -0600 To: "php internals" Message-ID: <80487519-71ed-47d6-b499-a89636e1c18f@app.fastmail.com> In-Reply-To: <1fe53b85-5315-4dbb-94a1-9a514cb82ed6@rwec.co.uk> References: <1fe53b85-5315-4dbb-94a1-9a514cb82ed6@rwec.co.uk> Subject: Re: [PHP-DEV] Pre-RFC proposal: opt-in implicit interfaces / structural typing Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Fri, Nov 7, 2025, at 1:19 PM, Rowan Tommins [IMSoP] wrote: > On 07/11/2025 17:05, Spencer Malone wrote: >> Hey all! Long time browser, first=C2=A0time emailer. I wanted to star= t a=20 >> pre-RFC discussion on the proposal of opt-in implicit interfaces /=20 >> structural typing / "golang style interfaces". > > > Hi and welcome :) > > In general, I prefer explicit code over implicit, so wouldn't be an=20 > enthusiastic supporter of this (although I might abstain rather than=20 > voting against). > > However, I though it worth mentioning that PHP has one implicit=20 > interface already: any class with an __toString() method magically=20 > implements Stringable. I've never really understood why, or why that=20 > interface even exists; but at least having a general concept of=20 > "implicit interface" would make it less magical. __toString() is *old*. It may go all the way back to 5.0, but it was th= ere at least as of 5.2. The problem is that there was no way to type ag= ainst it. You could type `string`, but not `string or object that imple= ments string`. When we got union types in 8.0, that was tempting but no= t yet possible. So Stringable was added basically for typing against `s= tring|Stringable`. And it was made implicitly added because there were = a bajillion __toString() functions in the wild already that shouldn't ha= ve to be modified before you could type against them. --Larry Garfield