Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126606 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 qa.php.net (Postfix) with ESMTPS id 420371A00BC for ; Thu, 6 Mar 2025 19:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741289554; bh=myrI9Xrk++llZl7CdErbk4y5VxWH25036fmiFogK9ZU=; h=Date:From:To:In-Reply-To:References:Subject:From; b=dZnx1ca95MVNvBTx8THv/s35wOd0yxXuE8COm/QFTsqVUCxqw1fs32XjSVnSxAHak 5GroccQgeTyq5IfFTHEstxw9R/oMbZe2JFrQEtWg073hkW7T3MQ09kroDK0/YNtM5T /UncRvUjSKHaAf7h1Tv9BasMXJExbFzF3gykV0T0y7jh1E0X7iNcmam8eMDmV3UAsL j7FRxfuZSr/qGY7qdP5VV29AlWFZWrDqdMzaAVnReoeKZhlYAmrrard9w3IEbQJrXp gnX/13TpBo9TloSMqSqqHAj6FRAhfoNjHKEhN7lAmEX0s9bvqmitLstm6fcMq/qlJM lPjNy91R8PBEA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id ABEE7180086 for ; Thu, 6 Mar 2025 19:32:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-b7-smtp.messagingengine.com (fout-b7-smtp.messagingengine.com [202.12.124.150]) (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, 6 Mar 2025 19:32:33 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 7D0E811400F4 for ; Thu, 6 Mar 2025 14:35:08 -0500 (EST) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-04.internal (MEProxy); Thu, 06 Mar 2025 14:35:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=fm1; t=1741289708; x=1741376108; bh=G0sbq+uWKM2u7k93SRwuG 73gF+TknNkeWhvFLpyY0xM=; b=vB+2YDSu50WKI8yiQd01W8ZuMvCwB7vjy8cQD jabeVwcs1he7KcKKuqMKieZOo/5uUCa56SwrYETv+oNOtpQTb23Yct+4suqujY7p GC1gcvOw2+lizdQWDG8xXcZqPd7hq4NxOascOKwywwriW5GtsY85tVfbeEuv/K33 vKbJBxvf8A3VMgW8o/ItqCWW442Hgmt6XYB8egu8HwCoxZMYfqbSz7o4MQdeS28G ETj/cHy1moKYHotPgCWKFWxc8vEVxdzxjmvpGPaxd2bKeTHo+pBxNDQ8n3ayKqZd H/p14L7EzjIVyguK14k2awyF59FXqit6GBDdGTTswsHLyrMcw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=fm1; t=1741289708; x=1741376108; bh=G 0sbq+uWKM2u7k93SRwuG73gF+TknNkeWhvFLpyY0xM=; b=d2rKiw8K3Y7ghjg7p FOdVvUWlVUHd4KFR0YifS+S8DUpheheqy32ytxSpp9y+Om4i5roaPrvNnOCBUB08 Jle1YHKkv+J3rzOpLOOiIsB3VjmTih1uaAS/xDTrVjuMzOceGnCwJVwquvoxHAs8 5pLfA5F7BfM99ykHrSCX3lERaxxRqaspmQpNGeFYNV8UsAwUZePu9dApZMvESRRA 4KoyPegABM+ejDk86avZiOuCIjdX3agsP/jLnN4cpY5wPvN/Z+/EgeVYx9mW0bum jDuo16oKBJywQ/Yt0504+Lev6f6PvDpKKGIJkY6xlEblTm0qzXBBizyHgYeDPtrU fWr9Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdekieduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthhqredtredt jeenucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrh hfihgvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpeeugfetieejueevffdu lefhhfethfekvedtueevgfffvdefiedvtefgheevteelffenucffohhmrghinhepphhhph drnhgvthenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghrtghpthhtohepud dpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishht shdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 1F12129C006F; Thu, 6 Mar 2025 14:35:08 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 06 Mar 2025 13:33:56 -0600 To: "php internals" Message-ID: In-Reply-To: References: Subject: Re: [PHP-DEV] RFC: short and inner classes Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Wed, Mar 5, 2025, at 5:11 PM, Rob Landers wrote: > Hello PHP Internals, > > I'd like to introduce my RFC for discussion:=20 > https://wiki.php.net/rfc/short-and-inner-classes I agree with others who have said this should be two RFCs. They stand a= lone, but can complement each other well. That's fine, talk about how t= hat works, but they're separate RFCs. (Like we split hooks and aviz.) I'm broadly in favor of short classes and warm on inner classes, with as= sorted caveats as below. ## Short classes The no-method-definitions restriction seems odd to me. I don't really s= ee what value that provides. The main advantages are 1. Even shorter way to define promoted properties for the common case. 2. No need to define a body if you don't need one. Neither of those conflicts with defining methods. If the concern is the verbosity of method definitions, well, I tried: https://wiki.php.net/rfc/short-functions I still think that would be beneficial, but am frying other fish at the = moment. So really, all it need to do is allow inline definition of the propertie= s by the class name as an alternative to a constructor. class Point(int $x, int $y) {} class Rect(Point $tl, Point $br) { public method area() { /* ... */=20 } } (Also allowing to skip the empty {} is fine with me, but that the last o= f my concerns.) The other question is trait usage. The RFC proposes just shifting that = up to the declaration line. That also seems fine to do either way, rega= rdless of whether there are methods. My biggest concern with this is that it makes methods and short-classes = mutually incompatible. So if you have a class that uses short-syntax, a= nd as it evolves you realize it needs one method, sucks to be you, now y= ou have to rewrite basically the whole class to a long-form constructor.= That sucks even more than rewriting a short-lambda arrow function to a= long-form closure, except without the justification of capture semantic= s. Additionally: The RFC doesn't specify if or how properties with hooks ar= e supported. That should be defined so we can argue about it. :-) Additionally: What happens here: class Point(int $x, int $y); class 3DPoint(int $z) extends Point; I have to redeclare all of the parameters from the parent, just to add o= ne? That's ugly.=20 ## Inner classes I'm on board with the use case. What I'm not sure on is inner classes v= s file-private visibility, something that Ilija was working on at one po= int and Micha=C5=82 Brzuchalski suggested in his post. Both solve large= ly the same problem with different spelling. Arguably, inner classes have fewer issues with current autoload conventi= ons. I must ponder this further. > However, no classes may not inherit from inner classes, but inner clas= ses may inherit from other classes, including the outer class.=20 I think you have one too many negatives in that sentence. --Larry Garfield