Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130710 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 E73E51A00BC for ; Wed, 29 Apr 2026 17:31:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1777483869; bh=9mqEQNqRcurP/WVqP5CAnak81E9blFytYIcuTZIWpPE=; h=From:Date:Subject:To:From; b=LsCmKx0P3rwY67kahWKYxIFdVwllJbwsYqiFB3MHSpf0ldoMLHVQqLZWRFvKMp9T8 VmwISKPwGQMYd6vZhj2unwVUjU+DlW6WsyvDzF07hWCSugBCfb0goSEhdZERge6uEM Tz3gC9IJYIYMHXRV5vMwc8mu1nwsJ5bJKbCY+nBPTU986CRIHDtjdclqMNQCcTnriI ZgY51LHMsahav/7Ch6hrArxABCap8/Q7t3CbxGtO/MuZ0ywxrwT561WZe34f38UyvO MNmAm3HZHlHLVyd4/L13Y+1VdWtPpOdyCCKH+ur7ZMvguCq/X1Gi9BAFOR1Rlj6xVU 0a2/Q5DkHrAsQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CEB6F180032 for ; Wed, 29 Apr 2026 17:31:08 +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-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (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 ; Wed, 29 Apr 2026 17:31:08 +0000 (UTC) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-7982c3b7da9so126517b3.1 for ; Wed, 29 Apr 2026 10:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777483863; cv=none; d=google.com; s=arc-20240605; b=QJbCkUvaGzglhSamRawB30R0Ph1VTM8pbKB920pQlUUFrM5DOX+4b3GczO9pca256q HjzLzIAFRbaTRLxWIazBb2OORDy/LNiJUoWqYyNSf/F5LOWNDUlmxO2wlIilqXyUykFN Y3/GmgO70C8oIMUbE9n9x98YCras1tD7qVc6jK0nLwlTZPpqCEmE/OiVv04lEHAQ3ZWq 0nCAnrHI2lEYN7BWnTTvJmFFc1rLaSG+ub4qxYloiSIistVk6TZ6LyL3FebuXk6j8w6v 4jvNrk7Xw2hK302Rdqc7ni42oeGaA8PkUfWtDawvC+i2gN98yK6DqEWgwoE0GLr3PtfR nj3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=9mqEQNqRcurP/WVqP5CAnak81E9blFytYIcuTZIWpPE=; fh=RnZ+4KjfdZdxwVfzmjFoBvUAaJ227RJecqE9MM9tvfQ=; b=bsWhwWnob4+RPwSWyHhJ253D0rH7JTE99REpdLy30s0ptnqOyxBJ3i91SnM5jMzWBr yDz3JIUL2uEB/NZTAE/g12sCI9CI+FjCH3dUQWLoc5OlMWNEON+T50UwqCSb5Tf4QPKA Scd5KCTo6tAZVWgHMGgf2Uwd544vXycXUXJ57o65ie61jVAt2RGnw2dRtlVCulrLkpRE hrQCCDy6YWENK0yFDjB1I5omCsxwzvLMG2EguSFPJTjxJtwL/1yemg3TOad/mqk3c10l wrq3VwSem90Sni5nBmR50S+kRPJ8FeR5abvoSAz6CtzlqxzBrE5P1m4eQepqNyy4IKCi Zibw==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777483863; x=1778088663; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=9mqEQNqRcurP/WVqP5CAnak81E9blFytYIcuTZIWpPE=; b=tLGQL8LZyuk+3FUSYpVRLvDEMbRHR1lwfGA+HTrv3uitiEneAfbs00BqyI7FaovWFa 48c8/s6CpViCIrxyCA8OkFEI9DCyS0rzaT6s5Z0QOIFEz6Lwynh2ZDiNYhV0KJlR9FoC RI94e8eu5DibDGkV09c9jN7AFg/jv56D8VeXmt4W6axmfFshY0N/dzKLmC4xHYz7FWxg xWW0umk5ozUe5TktVll32lPyagINWvEDyoD19KLGeqoGiiStRI0TRNYgK5rHzoWShPqx O+iI14NoDm6BHu+NJ9TsDlCGe83zgseHwQIEYFcrDKEmvZ6S0mUdjqs81xZiZ4IVGj1A YK1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777483863; x=1778088663; 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=9mqEQNqRcurP/WVqP5CAnak81E9blFytYIcuTZIWpPE=; b=gixjTIlsxH7UoDkumgg+nDn6Ol5Zxbx0l9hKzosm7/iVlcKm53z0h61Q6TyJZ2VaPz ME7L6iRqg0rucOIXxO0FpapK02N4mTZxLsgxaXAGDaesyTlU2aLBBS/wc0q6owVslF97 n9hi+9Ys3LRUJ9gWXz9FFpMUjJT4Ou63IsI81Bn6VBb4aelarPw7WqBXuu4VISVOCqOW NbWfb1W6WIPV6cRubECzGl1I0J3CIXJS7U7AiP1BT/9FqohWavfczFj+7mRpau7dNnZ1 wqd0Snp3pMURuj2miRiQJ5wxwqGyr3uE6jUc9FVbcw/vCdsMEyfHPG4g7N+8yPKihkWD gbiQ== X-Gm-Message-State: AOJu0YyJ88tzFFikPX1dEYWiK/MGaEREKVIRtxPbOLIGywSrbTX54+91 lVeD566YHfMQKZMmc1mfN2UPMNNC5i4B7TbxslRodyQOGnRK3ufJkCyYFXHeCcrwvcIk/7DC+GG KkXgf1tCrwajh6nPcNe0RHJ8MJTF4x/FjbU+w X-Gm-Gg: AeBDiesRLKfk4ZZJyLEAJzZXJpzUDyLlFs8OUaJWTCRCgvcUWYFZDloA5akgvrjRtuI CzwpPcvkuVRPscZ8y6KXqlAfKdmodeVk5y8sH3D4ylNkvx9rC0+LazjsGxpjcftqJhKbG8m7It0 lAxm197/fH3V1yJDXdorvHfJb2CLHNQ5s+qaBoYO8k2VrY2aC8X4FWF7jEgna7Lc9P3ZLRFLW2N i/QEEkJu1pTXbb7mWQndnea1MZeu0X/WfA5u5hwkyvaojBaMQZ3yhuZ0O2HZooWJ9btEqQPkEBj VjWPZ6HBbV5X4k+yJQ== X-Received: by 2002:a05:690c:4c04:b0:79a:7ff5:93ee with SMTP id 00721157ae682-7bd1d6ec6cfmr53392437b3.22.1777483862613; Wed, 29 Apr 2026 10:31:02 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Wed, 29 Apr 2026 10:30:33 -0700 X-Gm-Features: AVHnY4If4kWd6xA6MTFbi6S-DhajgNhGJ7HRYDBSX8J1lNMp9ztHOfRWbozvTR8 Message-ID: Subject: [PHP-DEV] Pre-RFC discussion about adding friendship to PHP To: php internals Content-Type: multipart/alternative; boundary="00000000000039a21106509cb675" From: daniel.e.scherzer@gmail.com (Daniel Scherzer) --00000000000039a21106509cb675 Content-Type: text/plain; charset="UTF-8" Hi internals, 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. 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? 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 just for specific properties/methods/constants Attribute * matches how other metadata is added to classes * would make it look cleaner if subsequently support was added for friendship 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 For a more in-depth explanation of the inspiration 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 people would prefer a new keyword, or an attribute, for declaring friends. -Daniel --00000000000039a21106509cb675 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi internals,

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

I haven't starte= d work on implementing this yet, but there is a big question about how to i= ndicate friendship that I wanted to get some feedback on. Specifically, sho= uld it be added with a new keyword, or with an attribute?

Keyword* matches C++
* suggests that friends are aspects of the class, like pr= operties and constants and methods
* but would look a bit ugly if we add= ed support for friends that are just for specific properties/methods/consta= nts

Attribute
* matches how other metadata is added to classes* would make it look cleaner if subsequently support was added for friends= hip being applied to specific properties/methods/constants
* would diffe= r from the current builtin attributes in that it doesn't just add/remov= e warnings, but changes some functionality

For a more in-depth expla= nation of the inspiration and these two potential approaches, see https://scherzer.dev/Bl= og/20260309-php-friends. To be clear, I have not yet written an impleme= ntation, much less the RFC, but I wanted to get some initial feedback on if= people would prefer a new keyword, or an attribute, for declaring friends.=

-Daniel
--00000000000039a21106509cb675--