Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128086 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 906801A00BC for ; Wed, 16 Jul 2025 15:57:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1752681340; bh=d92IGNFxZeFTywlM7tUNbkGXnoDzuy4INF3tiRMN6Xg=; h=Date:From:To:In-Reply-To:References:Subject:From; b=fL0sVvuvcG3uKkwPE2tU0SdVh6Q7CagEnkFHa/4+bnIA4JDheri5neVjD5PI7Iiff 24irzG1ivVzBe/pssyMmDIruORicM0nZ3DkL+8Xw04MEC5BJY+rlutAsds1UuYCB0X Jrq2+0MYMRCZWL/NKiaNf9yi6E8cd70bsco5NWepm/581TTV8hlXt+ULJKIfOeoFfb lpftOzm0kNvs1ETuccN1OfnoLMytpGUmmeuolN3QX7sAXkp5KLr/Xsg0FrDnJ9aefP bKR7pYltyae81Y81gCvE0hqjJMXu7Wq1QzzyAX2+KeaVciYaWv5XJXiZsWETbw7cpD 7PQ8yLEC/dq+w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F03621805C0 for ; Wed, 16 Jul 2025 15:55:39 +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=-1.4 required=5.0 tests=BAYES_05,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.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (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, 16 Jul 2025 15:55:39 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.stl.internal (Postfix) with ESMTP id 880747A00AF for ; Wed, 16 Jul 2025 11:57:26 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Wed, 16 Jul 2025 11:57:26 -0400 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=fm2; t=1752681446; x=1752767846; bh=iUyEnu+aWM+2aiU5xppDX FCAcqdwOSXsKs4Pb9Q7DAw=; b=uZ5Nf8DJ9ir/3k1IE0yPshgEdnL8bpRhuH6IS 0f4KP78+yRVXBkrT7EY2SC6IqFECrgb/aqbHjOqoEaCvo37VMdLmAd57UuImI1nW CyY66eb3NES45bTDY4gpmxvcJ86sLE1n/qIoO7JxT0W67qHr61NaRvhbUkNgiaxi M/JtWD4NvNCIVZWuuHE9vPWELswEF88N2YW7nsXi3Uu71cbJE/HRRVtm6qMJXhla d/52QkyppuyKSemPB4kiwXqfo55NBAR98cCmVEfxMHJHp2KVJOP0oaRN+0m4eOrF k4BEwDhRucxjmiC2fpEXRD8pVXQWrqCBG1B/eGi7QaFn7EMWA== 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=fm2; t=1752681446; x=1752767846; bh=i UyEnu+aWM+2aiU5xppDXFCAcqdwOSXsKs4Pb9Q7DAw=; b=MzXYYgE4gzh2X4NA/ 7ozZNTg1iK4mUI5adytdilwDJCOr8zVYvRXhvnciVUy0nd6dxX5eoeB9gJPHBi5v NgfNr1aLztOPWByxx3QODXP5prZMfk2YIhngiQXM5oLGA+oVOSLLo6tztwSakfcc pT97cwqQpUzON12foviQvGL++G7Ap2qXCyrF2c/CMiOrPqKKFKcl6jETKz79orGU hBkO/ybCFCUMJ/ONPXTyNUfmO2u8sDhuHA0vaPAxXrzSFhG7oeHcqEClyYAYt3x4 oodcpzP9zMdx1kLVq/imp8DVavLoqQ4JllXUOwWd9oT9wSI2oVf1SxQUe9ooXfZu WY36w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdehkedufecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtqhertdertdejnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepffeiiedvhfdvgedutddtgeetieeugeevhfetheeffeeftedu iedthedtgeejueeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphht thhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhsse hlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 0089B700069; Wed, 16 Jul 2025 11:57:25 -0400 (EDT) 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 X-ThreadId: Tf253845da74d3ebf Date: Wed, 16 Jul 2025 10:57:04 -0500 To: "php internals" Message-ID: <1ecc1fd2-3837-4409-98c8-543b26de4955@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] Discussion Short Constructor Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Wed, Jul 16, 2025, at 10:44 AM, Deleu wrote: > On Wed, Jul 16, 2025 at 3:49=E2=80=AFAM Rob Landers wrote: >> __ >>=20 >> Why I haven't proposed it as a separate RFC: with PSR-4 being so popu= lar, nobody is going to write one-line files to take advantage of this. = Thus, when I was going to revisit nested classes later this year (after = all the release shenanigans and some personal issues), I was planning to= add this feature to the nested class v2 RFC (again). A lot of feedback = I got on nested classes was "when would I use this?" -- and I suspect th= at would be a lot of the feedback you'd get here (see: PSR-4). I'm more = convinced than ever that short constructors and nested classes create a = chicken-and-egg problem. They only really make sense together; at least = with our current coding conventions and standards. It will create a long= er discussion period, but that's fine, IMHO. >>=20 >> If you'd like to continue with this RFC, I'd love to discuss it furth= er with you and help you out. I believe it is a bit more than "just" syn= tax sugar, but I'd have to dig out my records implementation. >>=20 >> =E2=80=94 Rob > > I remember PHP from ~2000's and PSR-4 and Composer were probably one o= f=20 > the biggest improvements to the ecosystem. However, I feel like a "2.0= "=20 > version is long overdue. I have participated in some internals=20 > discussions that point out a fact from the other direction: PHP makes=20 > no imposition about file structure. 1-class-per-file is strictly a=20 > PSR-4 implementation of a custom autoloader which we have gotten used=20 > to for so long. I would really love to be able to declare small relate= d=20 > classes/interfaces in a single file much like we can do with=20 > Typescript, but the current state of PHP "register your autoloader=20 > however you would like it" vs the current state of the community "PSR-= 4=20 > is THE standard", we end up between a rock and a hard place. I don't=20 > particularly enjoy nested classes and how the syntax and its contexts=20 > get involved. Sure it would be nice to have private classes, but it=20 > gets quite cumbersome to have to do it while nesting classes within=20 > classes. I will reiterate what I have said many times in the context of function = autoloading: The only autoloader that really matters in practice is Composer. Composer supports "front-load this list of files". You can put whatever= you want in there. We have an opcache. I am really not concerned about the cost of front-l= oading a bunch of small functions or classes. =20 If you're using React, FrankenPHP, or many of the other new-wave run mod= els, you have a persistent process anyway so just expect everything to g= et loaded. So having a "dto.php" or "classes.php" file that Composer just front-loa= ds on every request that contains a bunch of one-liner class definitions= (or functions, or whatever) is perfectly fine, and works today. The only thing that would need to change is for SA tools (mostly PHPStor= m) to be less whiny if they see a class that doesn't match its file name= . But I am quite confident JetBrains can figure out how to do that. In short: This is not a real problem. There's no need for us to make it= one. --Larry Garfield