Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129132 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 CB54B1A00BC for ; Fri, 7 Nov 2025 17:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762535121; bh=THvTCIPsi+JLJFWYUgWTQseh/GcFtQVCRrwqDVKOluo=; h=From:Date:Subject:To:From; b=VaRBFIa/tasPtxxi5QSEN3FCIFP8OYFqn5cAAPXROG8DowwFi3IUBjqiptHN0B7VL aUWU2ynL8jN2ZhG1x4pNtTe0ZYHcHNOgN+9l87vkU6c8nOMc5YOn0EQesDsUcRb8FV uGyxAdFWLR8/EX0YwYnh1nbGw1eXvRWbDwpRk028E/coxVxqbX1oeO43TbAl/69LUH YfRRIoQLQgPaSuBEbCXvHQNE1mBwR9fC2s8JZD8TOTdXCqaUvGzu6WloXAAcYN0lOb 3WeMSmmAHOjOdoQHO/Yy1SqmF48ahlBxciDKVUO4RUZ/KIrKxD0PFutV9/vUli9sPc 8fCVtAeHxB3iQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8E54B18003E for ; Fri, 7 Nov 2025 17:05:20 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) (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 17:05:20 +0000 (UTC) Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-4332d5be8adso8037905ab.0 for ; Fri, 07 Nov 2025 09:05:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762535114; x=1763139914; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=FcEGXKWnB17c6b4XXhtabxqwejjhmyIjkBhxcsBA+Xs=; b=X7EuAADbuU7Qaa+2VJjki2sAli3xLJ9JveMQFHmy5EA04fuaaL1fx+/bxO4AOLphSp XgAr95/pA4kt8qmMucf9CFpVFCIEoJPmwCujklVFI95Nd5doAX/gGussN/BI3N7nhhlr tnT/JBqhw1R0UIOOvzPHnFViRZoD/vBgPqvD4ck18kIYXLhaGFAdllNlDNEByDXehhRX 2MQkrJDGmAoWIgwECD5ufb4gDLALBJz4VpTI1i1f8nZITwqvG+8ww0plx41wRw2fFD9D 5aEpAZdMNN/jal0O41ZLlWmFvq4lWGZxqUGY2Cbp4WmG7KgjuIVyOYMKM1FqjGRtyuzX KYow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762535114; x=1763139914; h=to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FcEGXKWnB17c6b4XXhtabxqwejjhmyIjkBhxcsBA+Xs=; b=jgLJdNqXgqQwO1+UuhJRu2BzTnNeGAKnf5PDB+xGLnB3QfFoXFub7TEWzRZkX/52L5 QjNxtrQJKVoo0vV5x9oXOIhugnEnQpw9IExeQhh5IGfTlTOsNpIoG3KXsJQUHHS1Oo69 CrZ0RQBxbvV/3eZkkfzxs3QkSKMbgdbutgGqVf9hoCqEQnEMuAgulYdj5SovqcSfCxeQ kvEZOkGm8rkB7uYpJqpMCzqutcUV3WCpgFEiz7inqkjXMNKU1nvRQpslyx3gw5XMKiGl 9Oi8/mQ/fi0CAvPFyiltn7P3EXgA1BrnP8KWXdIvExWvgfo4h3/dRqOMIox7e9z2JvXi cB/Q== X-Gm-Message-State: AOJu0YwfBV9k0UZl2w+HgAe67pu0Gh507wkQpeeYS+BmPR0UW6kmvezd tpmox7w6pWyw6tei53OOlH36hQ9MwuBSiS6nYPf0guYdChdLVoiZpJY9g13obkJUvnZYa0YopOF q9fsjFhleaLfCy0cW9QZ6MkFrofDmoSKKOTeU X-Gm-Gg: ASbGnctLm2S2bQl20SeQpbP96CSQrAXoZORlvYJxlICsHJXz2JjHD8I/a98cz2UYga+ uctQUFfB8/jU1fqMCt3ZR499QT2LKDbninEZnQ/THmfMsDJe07Hw6kTPmNzbfn1z07oWS/qbRaQ S37plPVLWdm4B/pk3W4Wi7m3IW5CUr80DJnDCXdNJtJYQzhGu/QLIEkRuN5Rg52nj1cNQsOUv4a wQpXZVWBgxW6QXYhp+K3ykolCZzMEBTXq8Fdxj9fPjO1FCeV3qWWyqRQwN0X35WtC/BndhwAMWU gZS6wjQZ X-Google-Smtp-Source: AGHT+IF1r3drYJ6SrM6ZHqNanUqWL2hPHXEvWlNBRswa5A7gl3Nvo70yOuDxwE+hLmjRT7t9ch8Po7wXpabxl7LwDEs= X-Received: by 2002:a05:6e02:1a2f:b0:433:59ee:c243 with SMTP id e9e14a558f8ab-43367e489a9mr2153515ab.19.1762535114068; Fri, 07 Nov 2025 09:05:14 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 7 Nov 2025 09:05:03 -0800 X-Gm-Features: AWmQ_bmwZH7Gmr4D1SrENYsI-XFiR7mS1Q8nEnncgFsaKh7tpUxJs-6BO0CkAz8 Message-ID: Subject: [PHP-DEV] Pre-RFC proposal: opt-in implicit interfaces / structural typing To: internals@lists.php.net Content-Type: multipart/alternative; boundary="00000000000060d88f0643042fff" From: malone.spencer@gmail.com (Spencer Malone) --00000000000060d88f0643042fff Content-Type: text/plain; charset="UTF-8" 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:implicit, 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 are 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, adding 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 _why_ I want this. - Spencer --00000000000060d88f0643042fff Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hey all! Long time browser, first=C2=A0time emailer. = I wanted to start a pre-RFC discussion on the proposal of opt-in implicit i= nterfaces / 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:im= plicit, and was curious if this was an idea that could get any traction= as an RFC?

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

```
implicit interface Draw= able {
=C2=A0 =C2=A0 public function draw(): void;
}

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

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

There is some pre= vious art around here in the form of...

https://wiki.php.net/rfc/p= rotocol_type_hinting - I couldn't find any discussion on this other= than reading that the author withdrew=C2=A0all their RFCs for unrelated re= asons I think? Some of the core ideas here I think are still relevant, alth= ough in my implementation I chose to use syntax that adds a keyword onto th= e interface rather than at the call sites because I wanted to provide the a= bility for interface definers to keep their interfaces as explicit if they = wanted, as well as... Well honestly, adding angle brackets around objects f= eels like a syntax misstep since that pattern is very associated with gener= ics in my mind. I could be convinced of this though if that's the synta= x people prefer.

https://externals.io/message/115554#115603 - Conv= inced me that others may want this as well, although again that proposed sy= ntax ended up stepping on the toes of attributes. I do think this does a go= od job of explaining _why_ I want this.

- Spencer<= /div>

--00000000000060d88f0643042fff--