Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128085 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 5FA2C1A00BC for ; Wed, 16 Jul 2025 15:45:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1752680625; bh=RcMvDhf3+nsQOBr7hQ1EN6uqP1VhuiI9gkPKkBVUBYM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OjvDTjJcP1utOZJ4STTaWleaKHlFANxOK9p5NUp4MSqicfKtY33YEhi9Mk5Pdb5w4 eOqx+AL9F2lZfs02ErK767pslV0TJVKxUI18OHpolrJkuc+ZNZdd72w5qLlF+iFros 8tOBfEreUvAvpxsML0+bgciBeooEMaBk17J4JKzQqGeMkEGlSxYVYjoH+OmOEiGBVV jksKtnb8pb+LEeKwTSHW8uKv6R67ufe3qMmwGdUAfKdupgvjuIZPpUVPhVThw9xRv9 O51yUhoNoB0M5gCY8TiKE0dHeaZMvJnbaR2HECHY6d0zr6fFw7xz8cfrg1eElS+zxe 5Q3RpCzGhnXgA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0B061180079 for ; Wed, 16 Jul 2025 15:43:45 +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.4 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: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) (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:43:44 +0000 (UTC) Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-e8bd443c9c9so2179276.1 for ; Wed, 16 Jul 2025 08:45:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752680731; x=1753285531; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=RcMvDhf3+nsQOBr7hQ1EN6uqP1VhuiI9gkPKkBVUBYM=; b=XjUor2pXLPd0XE8ppO0HFNeSburIBH3B8KDxSTFumgNheHED2fTS02O1cYuULsFqL1 Xjksr/P9oowWLLjroW1SExcgMDbfKwF6ulcSpdyTrCZivnIsLxmi/yg88DMsjtG/QL9Z bt8PW7Qiy+ortR0flPl4sUxGLOOh7MTcPQfmHwuxE7BLA/y4/CYVOpGdEXR4VEijn8O1 kYPJnrvNeE0GYQRQRSIzFmSqAY/CL7+1gwI9dLThNre9mW0JPam+PUbbkGmz6k7iAFSQ uP82dgqZZ7M7PGSxMyJSkd4ZQzi/gdAAw69YYTQZ4e6hcKLxkdZ8caBBBj8yat2knOzr 1Nrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752680731; x=1753285531; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RcMvDhf3+nsQOBr7hQ1EN6uqP1VhuiI9gkPKkBVUBYM=; b=Mir4kto7quXVSsSdQe8oMLrouKe/90xGSRaSg07FNWJ4Ygnn6se7OOHrZvSmdf7NxN 9iKYBuYKZhiBiwzKIGf5tpZN7fGgxS0BURoSfz0jltSo5c8wWRVQ4TSOiRtBhP6GFdpr TW4mQOqsq7nYaDW5r4BZcSc+GtZuXITMAr1N3EqtS65ogm/Bym0ZLJl6tpHna2X/VQzG Tj3B7uAtgLbBnOjx0o4I+CIU12fHed7ifk0z5ii4NsDS44yTNyFCW3obH5KRZerniNz9 4RQhiIJPmFW7GG9klXt5/09PREIEWr9JDhVa/LIa/X5iUGaw9OTUG5oap7xmbtCJf8Fu snsw== X-Gm-Message-State: AOJu0YzdeRztfEV57lcEsBxe1L+/xNXivK58BXbTYeiqSAJRvVx38tfM Eg2W52Ry0Y9QwV2aiuiytz8tptLiR91uSqwcsAv2As3nRFgxNwhYV3/1PYtBYuNlOOqA+rCkcir xOkeAd4vupfbubUuRlq067QdivZDxpVoEwB8U X-Gm-Gg: ASbGnctU9TMvdbBqTjUsGfL8B+isDV+iDenn6QAytMUtp0aOzYqkh1q/j7OW+nvbxPf 7X21XZQllpLghdrWqHxGtECINNoKJmzrKABKkjYjkkIbkzUnv8JxvjeS535/2vb9a7umaRqjfjH xbKeiq9B2GiGTqx5ZA3mqe1efNlFXeIxdaW/+uq2RiwEFx3B+JTQJ2plKysYuEbWLkVZYzPoQLl qaVgXZ0i3fvBjyfCcRWj6lgUHWXbHEPYYQQSCY= X-Google-Smtp-Source: AGHT+IFv3Y0k7eL7PF/O8aHqd5xpFjwvaS97VBVGj21SUnQrHTsOo0VtRbSCXZGM+5oEgDH9jMZk2dmmPTj4W33vN+c= X-Received: by 2002:a05:6902:490d:b0:e8b:ca74:622e with SMTP id 3f1490d57ef6-e8bca7464f5mr1312120276.1.1752680731150; Wed, 16 Jul 2025 08:45:31 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 16 Jul 2025 12:44:54 -0300 X-Gm-Features: Ac12FXwgKC0mEF5PtP4N8MyYEC9rNOOMCP-AIiLL7T7vrsx2R31bkwUYzy3ox6g Message-ID: Subject: Re: [PHP-DEV] Discussion Short Constructor To: Rob Landers Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000628f69063a0dc880" From: deleugyn@gmail.com (Deleu) --000000000000628f69063a0dc880 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jul 16, 2025 at 3:49=E2=80=AFAM Rob Landers wro= te: > > Why I haven't proposed it as a separate RFC: with PSR-4 being so popular, > 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 that would b= e > a lot of the feedback you'd get here (see: PSR-4). I'm more convinced tha= n > 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 longer discussion > period, but that's fine, IMHO. > > If you'd like to continue with this RFC, I'd love to discuss it further > with you and help you out. I believe it is a bit more than "just" syntax > sugar, but I'd have to dig out my records implementation. > > =E2=80=94 Rob > I remember PHP from ~2000's and PSR-4 and Composer were probably one of the biggest improvements to the ecosystem. However, I feel like a "2.0" version is long overdue. I have participated in some internals discussions that point out a fact from the other direction: PHP makes no imposition about file structure. 1-class-per-file is strictly a PSR-4 implementation of a custom autoloader which we have gotten used to for so long. I would really love to be able to declare small related classes/interfaces in a single file much like we can do with Typescript, but the current state of PHP "register your autoloader however you would like it" vs the current state of the community "PSR-4 is THE standard", we end up between a rock and a hard place. I don't particularly enjoy nested classes and how the syntax and its contexts get involved. Sure it would be nice to have private classes, but it gets quite cumbersome to have to do it while nesting classes within classes. On the other hand, we can see from constructor property promotion that these little syntax sugar can be such a massive improvement to cognitive load, readability, writability, etc. I would really love to have something much like this RFC even if at first I need to do it as a one-line-per-file. To me, the more interesting chicken-egg problem to address is whether PHP needs to provide some change to symbols, namespaces, autoloader or if the community needs to expand PSR-4 in a way that allow us to not reject this RFC on the basis of "PSR-4 will drastically limit syntax sugar improvements". --=20 Marco Deleu --000000000000628f69063a0dc880 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Wed, Jul 16,= 2025 at 3:49=E2=80=AFAM Rob Landers <rob@bottled.codes> wrote:

=
Why I haven't proposed it as a separate RFC: with PSR-4 bein= g so popular, 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 (aft= er 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 g= ot on nested classes was "when would I use this?" -- and I suspec= t that would be a lot of the feedback you'd get here (see: PSR-4). I= 9;m more convinced than ever that short constructors and nested classes cre= ate a chicken-and-egg problem. They only really make sense together; at lea= st with our current coding conventions and standards. It will create a long= er discussion period, but that's fine, IMHO.

I= f you'd like to continue with this RFC, I'd love to discuss it furt= her with you and help you out. I believe it is a bit more than "just&q= uot; syntax sugar, but I'd have to dig out my records implementation.

=E2=80=94 = Rob

I remem= ber PHP from ~2000's and PSR-4 and Composer were probably one of the bi= ggest improvements to the ecosystem. However, I feel like a "2.0"= version is long overdue. I have participated in some internals discussions= that point out a fact from the other direction: PHP makes no imposition ab= out file structure. 1-class-per-file is strictly a PSR-4 implementation of = a custom autoloader which we have gotten used to for so long. I would reall= y love to be able to declare small related classes/interfaces in a single f= ile much like we can do with Typescript, but the current state of PHP "= ;register your autoloader however you would like it" vs the current st= ate of the community "PSR-4 is THE standard", we end up between a= rock and a hard place. I don't particularly enjoy nested classes and h= ow the syntax and its contexts get involved. Sure it would be nice to have = private classes, but it gets quite cumbersome to have to do it while nestin= g classes within classes.

On the other hand, we ca= n see from constructor property promotion that these little syntax sugar ca= n be such a massive improvement to cognitive load, readability, writability= , etc. I would really love to have something much like this RFC even if at = first I need to do it as a one-line-per-file. To me, the more interesting c= hicken-egg problem to address is whether PHP needs to provide some change t= o symbols, namespaces, autoloader or if the community needs to expand PSR-4= in a way that allow us to not reject this RFC on the basis of "PSR-4 = will drastically limit syntax sugar improvements".

--
Marco Del= eu
--000000000000628f69063a0dc880--