Re: Pre-RFC discussion about adding friendship to PHP

From: Date: Thu, 30 Apr 2026 07:43:26 +0000
Subject: Re: Pre-RFC discussion about adding friendship to PHP
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-130713@lists.php.net to get a copy of this message
Hi Am 2026-04-29 19:30, schrieb Daniel Scherzer:
I haven't started work on implementing this yet, but there is a big question about how to indicate friendship that I wanted to get some feedback on. Specifically, should it be added with a new keyword, or with an attribute?
It should be a proper keyword for the reasons that are also mentioned in your blog post: Attributes are not part of the public API and thus do not contribute to e.g. LSP checks. They are also expected to gracefully degrade when they do not exist, which means that running code written with friendship in mind on older PHP versions will silently expose a different API instead of failing in a visible way. See also the reasoning that I provided in the #[\Override] RFC: https://wiki.php.net/rfc/marking_overriden_methods#why_an_attribute_and_not_a_keyword. I think the related mailing list discussion provides additional context - and I seem to remember I wrote something similar in some other RFC discussion as well. Best regards Tim Düsterhus

« previous php.internals (#130713) next »