Re: [PHP-DEV] Is there any interest for object constructor shorthand *just forstdClass*

2020-10-23 Thread Rowan Tommins
On 23 October 2020 21:14:49 BST, Mike Schinkel wrote: >> On Oct 23, 2020, at 2:33 PM, Rowan Tommins >wrote: >> >> I don't follow; is the resulting JSON different if you cast to >object, or is there some other reason you prefer an object over using >an associative array directly? > >The by-refere

Re: [PHP-DEV] Is there any interest for object constructor shorthand *just forstdClass*

2020-10-23 Thread Mike Schinkel
> On Oct 23, 2020, at 2:33 PM, Rowan Tommins wrote: > > I don't follow; is the resulting JSON different if you cast to object, or is > there some other reason you prefer an object over using an associative array > directly? The by-reference semantics of objects vs arrays in PHP. > Also, to cl

Re: [PHP-DEV] Re: Is there any interest for object constructor shorthand *just forstdClass*

2020-10-23 Thread Rowan Tommins
On 23/10/2020 16:08, Andreas Bittner wrote: Closing I would like to make a short point with regards to the `(object)` cast: Both a cast of \stdClass to `(array)` and a cast of arrays to `(object)` are common use cases in (JSON-)API development. It is not unheard of for API signatures to contain

Re: [PHP-DEV] List of attributes

2020-10-23 Thread Rowan Tommins
On 23/10/2020 16:52, Theodore Brown wrote: The problem with this is that it results in inconsistent semantics, where the number of items in an attribute group results in a different type of value being passed. I.e. if you remove two of the three attributes from the list, suddenly the code will br

Re: [PHP-DEV] List of attributes

2020-10-23 Thread Benjamin Morel
On Fri, 23 Oct 2020 at 19:08, Michael Voříšek - ČVUT FEL < voris...@fel.cvut.cz> wrote: > We can deprecate comments with "#" in 8.0 or 8.1 > > ... > > Is there anything against excl. BC break of "#" comments? Who is for it? > > I'm all for it, especially considering that it's trivial to fix old co

Re: [PHP-DEV] List of attributes

2020-10-23 Thread Michael Voříšek - ČVUT FEL
Wdyt about dedicating "#" char for attributes? We can deprecate comments with "#" in 8.0 or 8.1 and in later version support attributes with "#" single character - without [] brackets, ie. support: #Attribute1 #Attribte2 public function x()... which will be equivalent to: #[ #Attribute

Re: [PHP-DEV] List of attributes

2020-10-23 Thread Theodore Brown
On Tue, Oct 20, 2020 at 10:13 AM Rowan Tommins wrote: > On Mon, 19 Oct 2020 at 16:17, Theodore Brown wrote: > > > > > In theory nested attributes could be supported in the same way with > > the `#[]` syntax, but it's more verbose and I think less intuitive > > (e.g. people may try to use the gr

[PHP-DEV] Re: Is there any interest for object constructor shorthand *just forstdClass*

2020-10-23 Thread Andreas Bittner
e.g. `$x = object{key: object{'escaped-literal': $v2 }};` (equivalent to `$x = (object)['key' => (object)['escaped-literal' => $v2]];`) For example, in JS, non-string key literals are surrounded in `[]` to unambiguously reference them. Here, that could be `object{[$key]: $value, [MY_CONST]: $oth