Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130716 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 74D231A00BC for ; Thu, 30 Apr 2026 11:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1777546825; bh=R7rtyIEDHZUgwk/RjcmdT38ghPx1ob7giJlaxO8erdQ=; h=Date:From:To:In-Reply-To:References:Subject:From; b=HQz5Bxv0/LqeAkUaB4U3PrUMoVMNP/YXdrzLmpipOxSPOQ5t/3tbbHbNQYdoC+K21 cFALN1HDzcHfJlO/nbEKbwAL2Neg6loCURDZO6tPE4xm6y9NbezpcSkHWEVyEW2Arg TlgQAK4GzReV/DmakAlNDzTCPiLoA6gSUEC6BmCjBmV006RaasFSzUwWbT7LHBjHI0 oHSzsEqIPm6zAkc4RU1VfTq1QZ4+JyTfxMs2Lu3nuhEF8VqgXV9IwIFagEbl5F/uaA iHT78YQjAM8SgnSR5puTDyclLabU2hIEDyULvEX5V/h4e7FIo5+8GcFLlYcmRHtqip WpdxfVeoGdFcg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2CE9D180061 for ; Thu, 30 Apr 2026 11:00:25 +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_MISSING,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 fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) (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 ; Thu, 30 Apr 2026 11:00:24 +0000 (UTC) Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id 9EA8814000BA for ; Thu, 30 Apr 2026 07:00:19 -0400 (EDT) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-12.internal (MEProxy); Thu, 30 Apr 2026 07:00:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=1777546819; x=1777633219; bh=R7rtyIEDHZ Ugwk/RjcmdT38ghPx1ob7giJlaxO8erdQ=; b=c7W76TK7uInZVGIezTKAInHJWU hZhRwVnHpIdawPJKSpYvdsoVZaHR8AQCcSyQ2hOQSiiojVwSFT4CA9onNbpNi+nz FWvuCZJeh8B2PBjya1CU+LCetmx3NVeJHzAfIsKT5KmYWPVfnTDIUsei0o/goVW6 qRzOteHS9E35P8NiFMm3YUy3ons8FFKmFD8CEuuHqGIqBr1aSBcUSPXCr6hYDCYx ZN8adxbX97f0S11Egll16XETtEQSySTmkGqvWMsRKW3axtG7T7XwXBlL+6oDzecp 18B/tp6+kA3UEGUqXOYkazUQtJSLR9QLys/g2BDZZ/TIbyTlJY8CawCHJPLA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm2; t= 1777546819; x=1777633219; bh=R7rtyIEDHZUgwk/RjcmdT38ghPx1ob7giJl axO8erdQ=; b=Ot0gElG9uMYmahvjH0cExrnhMfdN4DCZPHsaKdTMOdyRqVjuYJM RfcTX3kEQn0edZ+UPNRRHIo5Q/A+qxAtbxn449C7u7wLknHeYAdN1nm8c9cc87yD 6i4webMdfV069tzCULFsnLerMLNiNQlksrgMZSiK3VKFPmeu65efHjeTjv/Pe4A9 rpPMN0aZHf3/I2maEldEauY14GlmEDPJ6P98vu5cGeIqEVxtDXPkM9scfvD4egbU yxo48IZ6pw7ZCFpeoWmFwaLXi1/FM1dKVlvwWHyrse62+4qDGt02KhjAkUaZqKr5 qmsA7dTlIA/hFflxM7G7OMbExVI81EwTINA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdekjedugecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepofggfffhvffkjghfufgtsegrtderreertd ejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdr tghouggvsheqnecuggftrfgrthhtvghrnheptdetheduffekfeetjeelvedugfekieeuke ekieeffefgtdeltdehleefjeejvdeinecuffhomhgrihhnpehstghhvghriigvrhdruggv vhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehroh gssegsohhtthhlvggurdgtohguvghspdhnsggprhgtphhtthhopedupdhmohguvgepshhm thhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvg ht X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 45444182007E; Thu, 30 Apr 2026 07:00:19 -0400 (EDT) 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: AeruKgxAS4zg Date: Thu, 30 Apr 2026 12:59:57 +0200 To: internals@lists.php.net Message-ID: <880fe036-4cfd-46a7-949d-9d7f5664b678@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] Pre-RFC discussion about adding friendship to PHP Content-Type: multipart/alternative; boundary=3df3fc0d8bce7578527652b46328fd9fa2a14457 From: rob@bottled.codes ("Rob Landers") --3df3fc0d8bce7578527652b46328fd9fa2a14457 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Apr 29, 2026, at 19:30, Daniel Scherzer wrote: > Hi internals, >=20 > I'd like to add support for friendship in PHP. I don't mean friendship= in the PSR-8 huggable way, but rather in the C++ way of allowing access= to non-public parts of a class without needing to use Reflection. >=20 > I haven't started work on implementing this yet, but there is a big qu= estion about how to indicate friendship that I wanted to get some feedba= ck on. Specifically, should it be added with a new keyword, or with an a= ttribute? >=20 > Keyword > * matches C++ > * suggests that friends are aspects of the class, like properties and = constants and methods > * but would look a bit ugly if we added support for friends that are j= ust for specific properties/methods/constants >=20 > Attribute > * matches how other metadata is added to classes > * would make it look cleaner if subsequently support was added for fri= endship being applied to specific properties/methods/constants > * would differ from the current builtin attributes in that it doesn't = just add/remove warnings, but changes some functionality >=20 > For a more in-depth explanation of the inspiration and these two poten= tial approaches, see https://scherzer.dev/Blog/20260309-php-friends. To = be clear, I have not yet written an implementation, much less the RFC, b= ut I wanted to get some initial feedback on if people would prefer a new= keyword, or an attribute, for declaring friends. >=20 > -Daniel Hi Daniel, We saw some friendship discussions in my nested class RFC, where nested = classes implicitly became friends of the outer class. I'd recommend chec= king those threads for feedback about friendship and scope. =E2=80=94 Rob --3df3fc0d8bce7578527652b46328fd9fa2a14457 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Wed, Apr 29, 2026, at 19:30, Daniel Scherzer wrote:=
Hi internals,

I'd like to add support for fr= iendship in PHP. I don't mean friendship in the PSR-8 huggable way, but = rather in the C++ way of allowing access to non-public parts of a class = without needing to use Reflection.

I haven't st= arted work on implementing this yet, but there is a big question about h= ow to indicate friendship that I wanted to get some feedback on. Specifi= cally, should it be added with a new keyword, or with an attribute?

Keyword
* matches C++
* suggest= s that friends are aspects of the class, like properties and constants a= nd methods
* but would look a bit ugly if we added support for= friends that are just for specific properties/methods/constants

Attribute
* matches how other metadata is ad= ded to classes
* would make it look cleaner if subsequently su= pport was added for friendship being applied to specific properties/meth= ods/constants
* would differ from the current builtin attribut= es in that it doesn't just add/remove warnings, but changes some functio= nality

For a more in-depth explanation of the i= nspiration and these two potential approaches, see https://scherzer.dev/Blog/20260309= -php-friends. To be clear, I have not yet written an implementation,= much less the RFC, but I wanted to get some initial feedback on if peop= le would prefer a new keyword, or an attribute, for declaring friends.

-Daniel

<= div id=3D"sig121229152">Hi Daniel,

We saw some friendship discussions in my nes= ted class RFC, where nested classes implicitly became friends of the out= er class. I'd recommend checking those threads for feedback about friend= ship and scope.

=E2=80=94 Rob
--3df3fc0d8bce7578527652b46328fd9fa2a14457--