Re: [PHP-DEV] [Pre-RFC] Idea: named parameter lists

Alexander Egorov <[email protected]>
Newsgroups gmane.comp.php.devel
Message-ID <CAEM3Mn0i2srLQVAuTHa0BTu1FB8nqh9ELdkR_cwwoFGx1XX5Kg@mail.gmail.com>
On Tue, Aug 18, 2026 at 5:57 PM Larry Garfield <[email protected]> wrote:

> I really don't understand why people keep saying this.  What makes something "unworthy" of being a class?  Classes are not expensive, at least not as expensive as people seem to think.

Slightly offtopic, but I will try to answer this question. By
"unworthy", most often people mean a cognitive overhead as I would
call it. It's not necessarily about technical expensiveness, even
though many people do think that adding an additional class will add
some technical overhead. It's more about perception. And also about
development complexity sometimes.

I could give numerous examples, but will stick to only one. Imagine
you have a function which should return not only "main" data, but also
some additional data which comes for free while processing the
original request. If we were forced to go the "right way", we would
need to introduce a separate Dto which will hold "main" and
"secondary" data. But adding a Dto for this single case may seem
"unworthy", because from a cognitive point of view it is much easier
to return an array of [$main, $secondary]. And later on the calling
side do the unpacking [$main, $secondary] = $this->myFunction(...).
And given that we have lots of tools today to describe this array on
PhpDoc-level for static analysis, this solution won't be worse than a
dedicated Dto in terms of proper data-structures. But still looking
simpler cognitive-wise than a dedicated Dto.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.