Re: Discussion Short Constructor
| From: | Paul M. Jones | Date: | Wed, 16 Jul 2025 18:27:41 +0000 |
| Subject: | Re: Discussion Short Constructor | ||
| References: | 1 2 3 4 5 | Groups: | php.internals php.internals |
| Request: | Send a blank email to internals+get-128089@lists.php.net to get a copy of this message | ||
Hi all,
> On Jul 16, 2025, at 11:40, Deleu <deleugyn@gmail.com> wrote:
...
> The blessing and the curse of PSR-4 is that it spoiled us (or maybe just me?) to:
>
> - never think about
require/include
> - never think about composer.json
> - never think about how classes/interfaces/traits are located
> - IDEs will auto-import stuff so I don't even need to think about
> use statement
> - I don't know how to debug "Class not found" issues because the last time I saw
> an error like this was 5 years ago when I was trying to mess up with custom autoload capabilities in
> order to declare multiple symbols in a single file.
As the lead on PSR-4, I appreciate (and am sympathetic to) this list, as well as the pros & cons
of one-class-per-file (which originated with PSR-0 and the Horde/PEAR standards before it).
> Maybe I'm alone in it and then it's fine for it to be just my problem. I'm
> sharing here in case it's also someone else's problem and we can do something about it.
> But please don't tell me it's not a real problem.
You're not alone; I hear similar stories from time to time. Larry may be many things, but
he's definitely not the final authority on what is and is not a "real problem."
I am open to developing an extension of, or alternative to, PSR-4 autoloading that would allow for
multiple-classes-per-file; please contact me off-list if you're interested in pursuing that
idea.
-- pmj