Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again)

2021-06-22 Thread Rowan Tommins
On 22/06/2021 01:03, tyson andre wrote: If linters and automatic fixers were set up for a project to enforce it (e.g. phpcbf), there would only be one way that literals would be used in a project either way. The only way to be consistent across a whole project would be to never use the new

Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again)

2021-06-22 Thread Mike Schinkel
> On Jun 21, 2021, at 1:34 PM, Rowan Tommins wrote: > > On 21/06/2021 17:54, tyson andre wrote: >> In every place where `key` is a valid php identifier >> (e.g. can be used in PHP 8.0's named parameters), >> I propose to allow `[key: expr]` to be used instead of `['key' => expr]`. > > This is

Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again)

2021-06-21 Thread Hamza Ahmad
Hi Tyson, Regardless of what others are saying, I personally like your RFC. The reasons are following: 1. Because named keys are valid PHP names, they are resolved at the parsing level. Thus, they will not be validated again and again. Later, no constants are looked for. 2. At the runtime level,

Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again)

2021-06-21 Thread tyson andre
Hi Mel Dafert, > >I would prefer an improved syntax for creation of anonymous objects. This > >is something which I have been annoyed with, myself.I'd like to see a > >simple way of creating anonymous objects with typed properties. > > Another advantage arrays currently have over anonymous

Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again)

2021-06-21 Thread tyson andre
Hi Christian Schneider, > > return [success: true, data: $data, cursor: $cursor]; > > // is equivalent to the following, but shorter: > > return ['success' => true, 'data' => $data, 'cursor' => $cursor]; > > Just a little side-note: A while ago I proposed a 2-line-patch to allow :$foo > as a

Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again)

2021-06-21 Thread tyson andre
Hi Rowan Tommins, > This is an immediate "no" from me: it multiplies the ways to write the > same thing from 2 to 4, in order to save a few bytes, in a few instances. It's from 4 to 6 if you include single quoted strings vs double quoted strings. If linters and automatic fixers were set up for a

Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again)

2021-06-21 Thread Christian Schneider
Am 21.06.2021 um 18:54 schrieb tyson andre : > return [success: true, data: $data, cursor: $cursor]; > // is equivalent to the following, but shorter: > return ['success' => true, 'data' => $data, 'cursor' => $cursor]; Just a little side-note: A while ago I proposed a 2-line-patch to allow :$foo

Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again)

2021-06-21 Thread Larry Garfield
On Mon, Jun 21, 2021, at 12:34 PM, Rowan Tommins wrote: > On 21/06/2021 17:54, tyson andre wrote: > > In every place where `key` is a valid php identifier > > (e.g. can be used in PHP 8.0's named parameters), > > I propose to allow `[key: expr]` to be used instead of `['key' => expr]`. > > >

Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again)

2021-06-21 Thread Mel Dafert
>I would prefer an improved syntax for creation of anonymous objects. This >is something which I have been annoyed with, myself.I'd like to see a >simple way of creating anonymous objects with typed properties. Another advantage arrays currently have over anonymous objects is destructuring - if

Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again)

2021-06-21 Thread Kamil Tekiela
Hi Tyson, Interesting proposal, but I was going to reply with the exact same response as Rowan. Why not use DTOs for such purposes? Arrays have rather limited use cases. If you need to return multiple results from a function then you should return an object with typed properties. I don't like the

Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again)

2021-06-21 Thread Rowan Tommins
On 21/06/2021 17:54, tyson andre wrote: In every place where `key` is a valid php identifier (e.g. can be used in PHP 8.0's named parameters), I propose to allow `[key: expr]` to be used instead of `['key' => expr]`. This is an immediate "no" from me: it multiplies the ways to write the same

[PHP-DEV] [PROPOSAL] Bare name array literals (again)

2021-06-21 Thread tyson andre
Hi internals, In every place where `key` is a valid php identifier (e.g. can be used in PHP 8.0's named parameters), I propose to allow `[key: expr]` to be used instead of `['key' => expr]`. (including `list(key: expr)` and `array(key: expr)` (This can be mixed anywhere with existing key/value