Re: [RFC] Static class

From: Date: Wed, 26 Jun 2024 20:18:39 +0000
Subject: Re: [RFC] Static class
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 25/06/2024 16:17, Derick Rethans wrote:
we shouldn't be encouraging static classes as a bag of static functions, that ought to be just namespaced functions.
I understand this is the prevailing preference of a certain few, including (but not limited to) yourself and Larry. Nevertheless, classes as a bag of static functions is a phenomenon that exists and will continue to exist in PHP until such a time as static is completely removed from the language, so I don't really understand the avoidance of adding, in the interim, what seems like just a missing part of an existing feature. However, I still want to understand why a file of functions is strictly better than a class of functions. What are the benefits of a file over a class? For me, I dislike importing individual functions. It is often the case that, when such logic is so grouped in a static class, where we use one we may use several such functions. In such a case, we only need a single import statement instead of one for each function. This seems like a clear benefit. Even in the case that I only use one, I still prefer to import a class over a function, because it has better support in my editor and doesn't stick out like a sore thumb in the list of imports (why should it?). Cheers, Bilge

Thread (71 messages)

« previous php.internals (#123887) next »