Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Levi Morrison via internals
> c) Two such functions were proposed and rejected during the > array_key_first/last RFC > (https://wiki.php.net/rfc/array_key_first_last) > > Yes, that was in 2018. At that time, functions like str_contains() or > str_starts_with() wouldn't have even come into existence, just because > there was

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Aleksander Machniak
On 17.10.2023 11:29, Robert Landers wrote: $value = array_value_first($array, $key); if($key === null) // handle error else // do something with $value You can also freely ignore the key, if you don't need it or care about error checking. That would save doing two function calls on the same

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Robert Landers
On Tue, Oct 17, 2023 at 11:10 AM Levi Morrison via internals wrote: > > > c) Two such functions were proposed and rejected during the > > array_key_first/last RFC > > (https://wiki.php.net/rfc/array_key_first_last) > > > > Yes, that was in 2018. At that time, functions like str_contains() or > >

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Robert Landers
On Tue, Oct 17, 2023 at 11:37 AM Robert Landers wrote: > > On Tue, Oct 17, 2023 at 11:34 AM Aleksander Machniak wrote: > > > > On 17.10.2023 11:29, Robert Landers wrote: > > > $value = array_value_first($array, $key); > > > if($key === null) // handle error > > > else // do something with $value

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Lynn
On Tue, Oct 17, 2023 at 11:15 AM Robert Landers wrote: > On Tue, Oct 17, 2023 at 11:10 AM Levi Morrison via internals > wrote: > > How is returning null any different than $array[0] on an empty array? > https://3v4l.org/ > > > c) Two such functions were proposed and

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Robert Landers
On Tue, Oct 17, 2023 at 11:34 AM Aleksander Machniak wrote: > > On 17.10.2023 11:29, Robert Landers wrote: > > $value = array_value_first($array, $key); > > if($key === null) // handle error > > else // do something with $value > > > > You can also freely ignore the key, if you don't need it or

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Robert Landers
On Tue, Oct 17, 2023 at 11:22 AM Lynn wrote: > > > > On Tue, Oct 17, 2023 at 11:15 AM Robert Landers > wrote: >> >> On Tue, Oct 17, 2023 at 11:10 AM Levi Morrison via internals >> wrote: >> >> How is returning null any different than $array[0] on an empty array? >> https://3v4l.org/> > > > >

Re: [PHP-DEV] RFC Karma Request

2023-10-17 Thread Ilija Tovilo
Hi Yuya RFC karma was granted, good luck with your RFC! Ilija On Tue, Oct 17, 2023 at 5:07 PM youkidearitai wrote: > > Hi, internals. > > I writing to trim for multibyte support function, mb_trim, mb_ltrim > and mb_rtrim. > https://github.com/php/php-src/pull/12459 > > Please give me RFC

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Aimeos | Norbert Sendetzky
On 17.10.23 17:16, Ken Guest wrote: Having array_value_first and array_value_last to match the existing array_key_first and array_key_last functions make sense, and would seem to me to be more intuitive than function names that would not match that scheme. Please don't make things more

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Ken Guest
Having array_value_first and array_value_last to match the existing array_key_first and array_key_last functions make sense, and would seem to me to be more intuitive than function names that would not match that scheme. On Tue, 17 Oct 2023 at 10:41, Robert Landers wrote: > On Tue, Oct 17, 2023

[PHP-DEV] RFC Karma Request

2023-10-17 Thread youkidearitai
Hi, internals. I writing to trim for multibyte support function, mb_trim, mb_ltrim and mb_rtrim. https://github.com/php/php-src/pull/12459 Please give me RFC Karma. Username: youkidearitai Regards. Yuya -- --- Yuya Hamada (tekimen) - https://tekitoh-memdhoi.info -

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Brandon Jackson
> There is also a technique to make the return value `[$key => $value]` instead > of just a value, but this loses simplicity. Hmm, since the naming array_first and array_last doesn't clarify that it's returning a key or a value. What if it returned both as ?[key, value]. That opens quite a few

[PHP-DEV] RFC Karma request

2023-10-17 Thread Daniil Gentili
Hi, internals. I'd like to create RFCs at least for final anonymous classes (https://externals.io/message/121356) and a small tweak to JIT defaults (https://externals.io/message/121359). Please give me RFC Karma :) Username: danog Kind regards, Daniil Gentili. -- GitHub:

[PHP-DEV] Final anonymous classes

2023-10-17 Thread Daniil Gentili
Hi everyone, I'd like to submit an RFC to add support for final anonymous classes. This should also allow some additional opcache optimizations. I've already prepared the implementation at https://github.com/php/php-src/pull/11126, what do you think? Personally, I would have instead

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Saki Takamachi
> What about a signature like: > > ```php > array_first(array $array, mixed $value_if_missing = null); > ``` > > That would let you specify your own sentinel (or default) where appropriate, > without losing the convenience of this function. This is a problem that should be addressed in your

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Michael Cordover
On Tue, Oct 17, 2023, at 12:19, Saki Takamachi wrote: >> What about a signature like: >> >> ```php >> array_first(array $array, mixed $value_if_missing = null); >> ``` >> >> That would let you specify your own sentinel (or default) where appropriate, >> without losing the convenience of this

Re: [PHP-DEV] Final anonymous classes

2023-10-17 Thread Saki Takamachi
Hi, Daniil > Personally, I would have instead preferred the much cleaner approach of > making *all* anonymous classes final by default, (preferrably) without > offering the option to make them non-final. > > However, I understand that this might be a little bit too restrictive for > something

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Michael Cordover
On Tue, Oct 17, 2023, at 05:10, Levi Morrison via internals wrote: > It's true that sentiment may have shifted in this time. However, a > common argument at that time still stands: `null` is not a good > sentintenal for failure because the value inside the array very well > could have been null.

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Saki Takamachi
I see now, that makes sense. There is also a technique to make the return value `[$key => $value]` instead of just a value, but this loses simplicity. Thanks. Saki -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php

[PHP-DEV] Deprecate posix_times

2023-10-17 Thread Daniil Gentili
Hi everyone, I would like to submit an RFC (and related PR) to deprecate posix_times for PHP 8.4, removing it for PHP 9. There are multiple reasons to deprecate this function: 1) The values which times(2) returns are expressed as the number of clock ticks elapsed since the process was

[PHP-DEV] Change default method of disabling JIT for PHP 8.4

2023-10-17 Thread Daniil Gentili
Hello, I would like to submit an RFC and PR to change a few INI defaults for opcache, changing how JIT is disabled by default. Currently, JIT is disabled by default using the |opcache.jit_buffer_size=0| default, instead of |opcache.jit=0|. I.e. here are the defaults for these two

Re: [PHP-DEV] Previous discussions about generics syntax only?

2023-10-17 Thread Rowan Tommins
On 16/10/2023 15:08, Olle Härstedt wrote: Hello internals, Was there a previous discussion about the pros/cons of adding only the syntax needed for generics, but not the functionality? So static analyzers could use it, instead of docblocks. I looked at externals.io but couldn't find anything

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Saki Takamachi
Since reset() and end() return false when the array is empty, in a sense, there is an idea that there is no need to take such strict care of the return value. If you were to take proper care, you would probably specify a default value or throw an exception, as has already been suggested.

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Deleu
On Tue, Oct 17, 2023 at 3:43 PM Brandon Jackson wrote: > > There is also a technique to make the return value `[$key => $value]` > instead of just a value, but this loses simplicity. > > Hmm, since the naming array_first and array_last doesn't clarify that > it's returning a key or a value. What

Re: [PHP-DEV] proc_open() resource to opaque object migration

2023-10-17 Thread Máté Kocsis
Hi Tim, > I agree here. While I'm totally in favor of using namespaces in core, it > should be done somewhat consistently. If the proc_* functions are in the > global namespace, then so should the resource object. > While I don't necessarily want to add a dedicated namespace for Process (or

Re: [PHP-DEV] Change default method of disabling JIT for PHP 8.4

2023-10-17 Thread Jorg Sowa
Hello Daniil, I like this proposition. I never understood why the JIT is disabled by the ini setting `buffer_size` rather than other simple 'switch' like setting. Kind regards, Jorg

Re: [PHP-DEV] RFC Karma request

2023-10-17 Thread Ilija Tovilo
Hi Daniil On Tue, Oct 17, 2023 at 8:25 PM Daniil Gentili wrote: > I'd like to create RFCs at least for final anonymous classes > (https://externals.io/message/121356) and a small tweak to JIT defaults > (https://externals.io/message/121359). > > Please give me RFC Karma :) > > Username: danog

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Saki Takamachi
I thought of it after sending the email, so I'll post it again. By combining my two ideas, I think I can come up with a smarter proposal. ``` array_first(array $array, int|string &$key = null) ``` If you want to accurately determine whether an array is empty or not, you can satisfy your