Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129143 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 220481A00BC for ; Fri, 7 Nov 2025 22:20:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762554011; bh=qmV1arFfGYDAjpHpbfs5T4QWP38ySMSM2asV+causkg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FuY2E68gHhuGgeWwXu63En9MfIW1snd+ODCkOOmpaUI7VilfNeyBATJyGZmkPXZaz SYIx0BMkpDuDTVCpL8h1xuaa7CYxaJ/LXY/lRf9JSn3rDAa85llMv1xr+DttzB5uS6 FskNTyn4FlcuCD9m+hK2AjRxMk8IaQq1/fSQCcTp/wXYlFGl4KtNUczMgQLQP1Fh8o NW5Mhnl8imEVnBPT0W3Vr9hZtI2fNCojeU998ZV8/O8bedMD8iS2FjySRTd4+sEdca /A2E0cnkBvMEMRggH/CQAcovWYaliMLJ43Fz1C2b1VnVAgSxXrQRLCRPadnGlzpnWd udVHmhZlwnsqQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8B7B9180077 for ; Fri, 7 Nov 2025 22:20:09 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from outbound10.mail.transip.nl (outbound10.mail.transip.nl [136.144.136.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 7 Nov 2025 22:20:08 +0000 (UTC) Received: from submission9.mail.transip.nl (unknown [10.103.8.160]) by outbound10.mail.transip.nl (Postfix) with ESMTP id 4d3D5G2CWVzTPPFM for ; Fri, 7 Nov 2025 23:20:02 +0100 (CET) Received: from smtp.transip.email (mail-ed1-f52.google.com [209.85.208.52]) by submission9.mail.transip.nl (Postfix) with ESMTPA id 4d3D5F2531z2npd8k for ; Fri, 7 Nov 2025 23:20:01 +0100 (CET) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-640860f97b5so2199116a12.2 for ; Fri, 07 Nov 2025 14:20:01 -0800 (PST) X-Gm-Message-State: AOJu0YxYp1UR1ToyD4b+WE/jVsnHftqdY91JNJ+7Cdd+3DRlfTB+yy1c i8lyJnYwbPfhKGQkpsOLhnyYDOSpiH/3kUtcZcpJCssWnpCg+D71BYOUWFsOcbSMqBNUwQ47VUi wNV7Kdt9ej89jhh79MGecF5GjnabUGEU= X-Google-Smtp-Source: AGHT+IFJNyIx/IxODaLSxcpg7v0ZaquLSgPAnNlZiyAZJdDRE5ZcRHNFtJPTBoWOIlKOohRnALeksqFfBXtoofSm6h8= X-Received: by 2002:a05:6402:5188:b0:640:eb29:fc7e with SMTP id 4fb4d7f45d1cf-6415e8237b7mr443721a12.20.1762554000726; Fri, 07 Nov 2025 14:20:00 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 7 Nov 2025 22:20:35 +0000 X-Gmail-Original-Message-ID: X-Gm-Features: AWmQ_bl53u25EJ8Jz0jBgWSBlXZ2KHYtM4g_FPLx-p33YoaJ-TrTATAEXUi09_A Message-ID: Subject: Re: [PHP-DEV] Pre-RFC proposal: opt-in implicit interfaces / structural typing To: Spencer Malone Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000001c5e960643089557" X-Scanned-By: ClueGetter at submission9.mail.transip.nl DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=transip-a; d=pmmaga.net; t=1762554001; h=from:subject:to:cc: references:in-reply-to:date:mime-version:content-type; bh=Q25RiiJGk150WUukhSXXDjp/gxcHvUeR9FAhK3Y1Dlw=; b=gZTNFIajDG2A1uDJy73HvPN9qqdVsBhZ5+eIefO36yb5C6VCwLvmq/EbTGw7S4MlvXb6o/ tzxpTgF6ydyIWB79mavXvAnSOHgh2mzROyepIfFA289t34N6cjgFg7dIxu8sO2TS47ouBP oja8yaNs6JivXEi84HxKohQ01udIqls+tDZOgbPEO2mfsK3kUqiJVChAoFV/AauO6DOFDV CU8gZo2oGU7VVZAE0l0XW+f0vw3ZWAzoahTwk6IOEZnQ2BuxXV9HeRZ372zS+C8huPq4ft NuYBAm/iXhcgV2J1sxSnkcjWYkU7CY1VBoTsL5nde/x0DU3/O43TR8HKflXLjA== X-Report-Abuse-To: abuse@transip.nl From: mail@pmmaga.net (=?UTF-8?Q?Pedro_Magalh=C3=A3es?=) --0000000000001c5e960643089557 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Nov 7, 2025 at 5:05=E2=80=AFPM Spencer Malone wrote: > Hey all! Long time browser, first time emailer. I wanted to start a > pre-RFC discussion on the proposal of opt-in implicit interfaces / > structural typing / "golang style interfaces". > > I have an early mostly working POC at > https://github.com/php/php-src/compare/master...SpencerMalone:php-src:imp= licit, > and was curious if this was an idea that could get any traction as an RFC= ? > > For those who don't want to open the link, it's essentially: > > ``` > implicit interface Drawable { > public function draw(): void; > } > > class Circle { > public function draw(): void { > } > } > > assert((new Circle()) instanceof Drawable); // This would be true > ``` > > There is some previous art around here in the form of... > > https://wiki.php.net/rfc/protocol_type_hinting - I couldn't find any > discussion on this other than reading that the author withdrew all their > RFCs for unrelated reasons I think? Some of the core ideas here I think a= re > still relevant, although in my implementation I chose to use syntax that > adds a keyword onto the interface rather than at the call sites because I > wanted to provide the ability for interface definers to keep their > interfaces as explicit if they wanted, as well as... Well honestly, addin= g > angle brackets around objects feels like a syntax misstep since that > pattern is very associated with generics in my mind. I could be convinced > of this though if that's the syntax people prefer. > > https://externals.io/message/115554#115603 - Convinced me that others may > want this as well, although again that proposed syntax ended up stepping = on > the toes of attributes. I do think this does a good job of explaining _wh= y_ > I want this. > > - Spencer > > Hi Spencer, A few years ago I had a go at it. In case it is useful in any way, you can check it in https://github.com/php/php-src/compare/master...pmmaga:php-src:implicit-int= erfaces Regards, Pedro --0000000000001c5e960643089557 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Nov 7, 2025 at 5:05=E2=80=AFPM Spence= r Malone <malone.spencer@gma= il.com> wrote:
Hey all! Long time browser, first=C2=A0time ema= iler. I wanted to start a pre-RFC discussion on the proposal of opt-in impl= icit interfaces / structural typing / "golang style interfaces".<= /div>

I have an early mostly working POC at=C2=A0https://github.com/php/php-src/compare/master...= SpencerMalone:php-src:implicit, and was curious if this was an idea tha= t could get any traction as an RFC?

For those who = don't want to open the link, it's essentially:

```
implicit interface Drawable {
=C2=A0 =C2=A0 public function draw(): voi= d;
}

class Circle {
=C2=A0 =C2=A0 public function draw(): void= {
=C2=A0 =C2=A0 }
}

assert((new Circle()) i= nstanceof Drawable); // This would be true
```

There is some previous art around here in the form of...
<= br>
https://wiki.php.net/rfc/protocol_type_hinting - I coul= dn't find any discussion on this other than reading that the author wit= hdrew=C2=A0all their RFCs for unrelated reasons I think? Some of the core i= deas here I think are still relevant, although in my implementation I chose= to use syntax that adds a keyword onto the interface rather than at the ca= ll sites because I wanted to provide the ability for interface definers to = keep their interfaces as explicit if they wanted, as well as... Well honest= ly, adding angle brackets around objects feels like a syntax misstep since = that pattern is very associated with generics in my mind. I could be convin= ced of this though if that's the syntax people prefer.

https://externals.io/message/115554#115603 - Convinced me that o= thers may want this as well, although again that proposed syntax ended up s= tepping on the toes of attributes. I do think this does a good job of expla= ining _why_ I want this.

- Spencer

<= /div>

Hi Spencer,

A few years=C2=A0ago I had a go at it. In case it is useful in any wa= y, you can check it in=C2=A0https://github.com/php/php-= src/compare/master...pmmaga:php-src:implicit-interfaces

<= /div>
Regards,
Pedro
--0000000000001c5e960643089557--