[PHP-DEV] Fwd: Request for RFC Karma to Propose any_empty and all_empty Methods

Dear PHP Internals Team,

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.

Thank you for your time and consideration.

image.png
<image.png - Google Drive;

Best regards,

Elminson
PHP Wiki Username: elminson

Dude… what?

···

On 27/05/2024 17:51, Elminson De Oleo Baez wrote:

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.

https://wiki.php.net/rfc/array_find

Is it not already covered by array_any() and array_all() anyway? You can just write a predicate if you want the (awful) semantics of empty().

Bilge

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

On 27/05/2024 17:56, Bilge wrote:

On 27/05/2024 17:51, Elminson De Oleo Baez wrote:

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.

Dude... what? PHP: rfc:array_find

Please try to be polite, and remember that just because something seems obvious to you, that doesn't mean everyone else in the world already knows it.

How about we re-word with that in mind:

Hi Elminson,

As it happens, there has been a recent proposal which includes "array_any" and "array_all" functions, which could be combined with the existing "empty" function to achieve these results.

You can find the RFC here: PHP: rfc:array_find and the mailing list discussion here: RFC [Discussion]: array_find - Externals

Regards,

--
Rowan Tommins
[IMSoP]

On 04/06/2024 21:18, Rowan Tommins [IMSoP] wrote:

On 27/05/2024 17:56, Bilge wrote:

On 27/05/2024 17:51, Elminson De Oleo Baez wrote:

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.

Dude... what? PHP: rfc:array_find

Please try to be polite, and remember that just because something seems obvious to you, that doesn't mean everyone else in the world already knows it.

How about we re-word with that in mind:

Hi Elminson,

As it happens, there has been a recent proposal which includes "array_any" and "array_all" functions, which could be combined with the existing "empty" function to achieve these results.

You can find the RFC here: PHP: rfc:array_find and the mailing list discussion here: RFC [Discussion]: array_find - Externals

Regards,

--
Rowan Tommins
[IMSoP]

Hi all,

I would like to retract my original reply and apologise to everyone. Originally I thought the OP was submitting an identical proposal, but he was not, and that is on me for not reading properly. In any case, you're right I should have been more courteous. Hope there are no hard feelings.

Kind regards,
Bilge