Re: [PHP-DEV] Inline conditional that returns null if falsy

2021-02-23 Thread Guilliam Xavier
Hi, On Fri, Feb 12, 2021 at 8:45 PM Ben Ramsey wrote: > > I think it might be a good idea to check other languages to see if they > support something like this. We could use their examples as points of > reference for discussing whether to include this functionality in PHP. > On Sat, Feb 13,

Re: [PHP-DEV] Inline conditional that returns null if falsy

2021-02-23 Thread Chase Peeler
On Tue, Feb 23, 2021 at 9:31 AM Nikita Popov wrote: > On Fri, Feb 12, 2021 at 8:25 PM David Rodrigues > wrote: > > > Hello! > > > > It is just a suggestion to be discussed. > > > > A lot of places on my projects I have codes like: > > > > $companies = $user->companies->count() > > ? new

[PHP-DEV] [VOTE] fsync function

2021-02-23 Thread David Gebler
Hi internals, As there appear to be no objections or concerns, I intend to open voting on https://wiki.php.net/rfc/fsync_function tomorrow and voting will remain open for two weeks. The RFC and its implementation - Adds functions fsync() and fdatasync() for plain file streams on Unix systems. -

Re: [PHP-DEV] Inline conditional that returns null if falsy

2021-02-23 Thread Albert Casademont
On Tue, Feb 23, 2021 at 6:28 PM Larry Garfield wrote: > > 1) Please don't top post. > Sorry for that! > 2) > > The advantage of ?: over long-ternary is that the part it lets you omit is > of variable size, and is often verbose (nested array elements). That's not > the case here, as the

Re: [PHP-DEV] Inline conditional that returns null if falsy

2021-02-23 Thread Rowan Tommins
On 23/02/2021 18:41, Albert Casademont wrote: Sure, it's not a big deal having to write the ": null" but it doesn't add any value On the contrary, it adds an important piece of information: that the default value is "null", rather than "false", or "0", or "new EmptyValue()". For instance,

Re: [PHP-DEV] Inline conditional that returns null if falsy

2021-02-23 Thread Sara Golemon
On Tue, Feb 23, 2021 at 1:05 PM Rowan Tommins wrote: > > On 23/02/2021 18:41, Albert Casademont wrote: > > Sure, it's not a big deal having to write the ": null" but it doesn't add > > any value > > On the contrary, it adds an important piece of information: that the > default value is "null",

Re: [PHP-DEV] Inline conditional that returns null if falsy

2021-02-23 Thread Guilliam Xavier
On Tue, Feb 23, 2021 at 6:28 PM Larry Garfield wrote: > On Tue, Feb 23, 2021, at 10:49 AM, Albert Casademont wrote: > > Another example is when a scalar input needs to be either left null or > > converted to a Value Object: > > > > $color = $data['color'] ? new Color($data['color']) : null; > >

[PHP-DEV] Support JSON With Commas and Comments (JWCC) in json_decode

2021-02-23 Thread Pavel Djundik via internals
See https://nigeltao.github.io/blog/2021/json-with-commas-comments.html for more information. It is quite common to have trailing commas in JSON, and a lot of parsers support it. I believe this could be trivially supported by PHP, even if you skip adding support for comments. Perhaps this could

Re: [PHP-DEV] Support JSON With Commas and Comments (JWCC) in json_decode

2021-02-23 Thread Rowan Tommins
On 23/02/2021 18:21, Pavel Djundik via internals wrote: See https://nigeltao.github.io/blog/2021/json-with-commas-comments.html for more information. It is quite common to have trailing commas in JSON, and a lot of parsers support it. I believe this could be trivially supported by PHP, even if

Re: [PHP-DEV] Replies on lists.php.net

2021-02-23 Thread Kris Craig
On Tue, Feb 23, 2021 at 7:30 AM Chase Peeler wrote: > On Tue, Feb 23, 2021 at 10:27 AM Ben Ramsey wrote: > > > > On Feb 23, 2021, at 09:21, Larry Garfield > > wrote: > > > > > > On Mon, Feb 22, 2021, at 4:26 AM, Christian Schneider wrote: > > >> Am 15.02.2021 um 13:20 schrieb Pierre : > > >>>

Re: [PHP-DEV] Inline conditional that returns null if falsy

2021-02-23 Thread Larry Garfield
On Tue, Feb 23, 2021, at 10:49 AM, Albert Casademont wrote: > Another example is when a scalar input needs to be either left null or > converted to a Value Object: > > $color = $data['color'] ? new Color($data['color']) : null; > > This would become; > > $color = $data['color'] ? new

Re: [PHP-DEV] Replies on lists.php.net

2021-02-23 Thread Ben Ramsey
> On Feb 23, 2021, at 09:21, Larry Garfield wrote: > > On Mon, Feb 22, 2021, at 4:26 AM, Christian Schneider wrote: >> Am 15.02.2021 um 13:20 schrieb Pierre : >>> I noticed I receive almost all your replies to the list along with a >>> duplicated copy addressed to me or other conversation

Re: [PHP-DEV] Replies on lists.php.net

2021-02-23 Thread Larry Garfield
On Mon, Feb 22, 2021, at 4:26 AM, Christian Schneider wrote: > Am 15.02.2021 um 13:20 schrieb Pierre : > > I noticed I receive almost all your replies to the list along with a > > duplicated copy addressed to me or other conversation participants, I think > > you always click "reply to all"

Re: [PHP-DEV] Interaction between finally blocks and exit()

2021-02-23 Thread Guilliam Xavier
On Fri, Feb 5, 2021 at 2:10 PM G. P. B. wrote: > Greetings internals, > > While working on rewriting the PHP docs about errors and error handling [1] > I came across a change of behaviour in an edge case of an edge case. > > finally blocks are meant to be always executed regardless that an

Re: [PHP-DEV] Inline conditional that returns null if falsy

2021-02-23 Thread Albert Casademont
Another example is when a scalar input needs to be either left null or converted to a Value Object: $color = $data['color'] ? new Color($data['color']) : null; This would become; $color = $data['color'] ? new Color($data['color']); //the ": null" part is implicit It's actually kinda the

Re: [PHP-DEV] Interaction between finally blocks and exit()

2021-02-23 Thread Guilliam Xavier
On Tue, Feb 23, 2021 at 5:12 PM Nikita Popov wrote: > On Tue, Feb 23, 2021 at 4:52 PM Guilliam Xavier > wrote: > >> On Fri, Feb 5, 2021 at 2:10 PM G. P. B. wrote: >> >> > Greetings internals, >> > >> > While working on rewriting the PHP docs about errors and error handling >> [1] >> > I came

Re: [PHP-DEV] Avoiding enum reserved keyword

2021-02-23 Thread Larry Garfield
On Tue, Feb 23, 2021, at 5:21 AM, Nikita Popov wrote: > Hi internals, > > I'm a bit concerned about the addition of the "enum" reserved keyword as > part of https://wiki.php.net/rfc/enumerations. The problem is that there > are quite a few existing enum libraries (such as >

Re: [PHP-DEV] Replies on lists.php.net

2021-02-23 Thread Chase Peeler
On Tue, Feb 23, 2021 at 10:27 AM Ben Ramsey wrote: > > On Feb 23, 2021, at 09:21, Larry Garfield > wrote: > > > > On Mon, Feb 22, 2021, at 4:26 AM, Christian Schneider wrote: > >> Am 15.02.2021 um 13:20 schrieb Pierre : > >>> I noticed I receive almost all your replies to the list along with a

Re: [PHP-DEV] [VOTE]: Change Default mysqli Error Mode

2021-02-23 Thread Benjamin Eberlei
On Thu, Feb 11, 2021 at 12:36 AM Kamil Tekiela wrote: > Hi internals, > > I have started voting on https://wiki.php.net/rfc/mysqli_default_errmode > The voting period is 2020-02-11 -- 2020-02-28 > While the change in itself is something I want to see, I voted no on this proposal because its a

[PHP-DEV] [RFC] Static variables in inherited methods

2021-02-23 Thread Nikita Popov
Hi internals, While looking into various issues related to static variable handling, I've become increasingly convinced that our handling of static variables in inherited methods is outright buggy. However, it's also long-standing behavior, so I've put up an RFC:

Re: [PHP-DEV] Interaction between finally blocks and exit()

2021-02-23 Thread Nikita Popov
On Tue, Feb 23, 2021 at 4:52 PM Guilliam Xavier wrote: > On Fri, Feb 5, 2021 at 2:10 PM G. P. B. wrote: > > > Greetings internals, > > > > While working on rewriting the PHP docs about errors and error handling > [1] > > I came across a change of behaviour in an edge case of an edge case. > > >

Re: [PHP-DEV] Inline conditional that returns null if falsy

2021-02-23 Thread Mike Schinkel
> On Feb 23, 2021, at 2:05 PM, Rowan Tommins wrote: > > On 23/02/2021 18:41, Albert Casademont wrote: >> Sure, it's not a big deal having to write the ": null" but it doesn't add >> any value > > > On the contrary, it adds an important piece of information: that the default > value is "null",

Re: [PHP-DEV] Avoiding enum reserved keyword

2021-02-23 Thread Matthew Brown
On Tue, 23 Feb 2021 at 06:21, Nikita Popov wrote: > Another possibility would be to recognize T_ENUM in the lexer, but only if > it is followed by whitespace and an identifier. This would possibly be > friendlier for tooling using token_get_all(). It would not permit comments > in between the

[PHP-DEV] Avoiding enum reserved keyword

2021-02-23 Thread Nikita Popov
Hi internals, I'm a bit concerned about the addition of the "enum" reserved keyword as part of https://wiki.php.net/rfc/enumerations. The problem is that there are quite a few existing enum libraries (such as https://github.com/myclabs/php-enum) that define an Enum class. While the implementation

Re: [PHP-DEV] Inline conditional that returns null if falsy

2021-02-23 Thread Nikita Popov
On Fri, Feb 12, 2021 at 8:25 PM David Rodrigues wrote: > Hello! > > It is just a suggestion to be discussed. > > A lot of places on my projects I have codes like: > > $companies = $user->companies->count() > ? new Collection($user->companies) > : null; > > So $companies will be null

[PHP-DEV] Re: VM reentry limit

2021-02-23 Thread Nikita Popov
On Mon, Feb 3, 2020 at 2:29 PM Nikita Popov wrote: > Hi internals, > > We have a long-standing issue (tracked at > https://bugs.php.net/bug.php?id=64196 and the very numerous duplicates) > that certain types of infinite recursion can lead to a stack overflow. > While for us it is easy to

Re: [PHP-DEV] [VOTE]: Change Default mysqli Error Mode

2021-02-23 Thread Johannes Schlüter
Hi, On Wed, 2021-02-10 at 23:35 +, Kamil Tekiela wrote: > I have started voting on > https://wiki.php.net/rfc/mysqli_default_errmode > The voting period is 2020-02-11 -- 2020-02-28 Sorry, I didn't see this before. I agree that Exceptions are the way to go and it were good if that had been