Re: Fwd: Request for RFC Karma to Propose any_empty and all_empty Methods
| From: | Ilija Tovilo | Date: | Mon, 03 Jun 2024 20:42:32 +0000 |
| Subject: | Re: Fwd: Request for RFC Karma to Propose any_empty and all_empty Methods | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-123499@lists.php.net to get a copy of this message | ||
Hi Elminson!
On Mon, May 27, 2024 at 6:51 PM Elminson De Oleo Baez <edeoleo@gmail.com> wrote:
>
> I hope this message finds you well. I am writing to request RFC karma for my wiki account in
> order to propose a new RFC.
>
> My proposal involves the introduction of two new methods, any_empty and all_empty, for working
> with arrays. These methods are designed to provide boolean outputs indicating whether any of the
> elements in an array are empty, or if all elements are empty, respectively. I believe these methods
> will be valuable additions to PHP’s array manipulation functionalities.
>
> Below is a brief overview of the proposed methods:
>
> any_empty(array $array): bool - This method will return true if any element in the provided
> array is empty, and false otherwise.
> all_empty(array $array): bool - This method will return true if all elements in the provided
> array are empty, and false otherwise.
> These methods aim to simplify common array checks and improve code readability and efficiency.
>
> I look forward to your approval and any guidance you can provide on moving forward with this
> proposal.
I'm skeptical personally about these functions. empty() doesn't have
the best semantics, and it's going to be rare that all your input
types exactly follow these semantics. I think a deeper dive into
common validation requirements might be good, to see whether they can
be abstracted in some way. It's also worth noting that validation
entails much more than just yielding true or false, e.g. coercion or
graceful errors.
Anyway, I granted you RFC karma. Good luck!
Ilija