Re: Allow empty property names

From: Date: Sun, 27 Mar 2016 20:22:40 +0000
Subject: Re: Allow empty property names
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-91970@lists.php.net to get a copy of this message
On Sat, Mar 26, 2016 at 12:17 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote: > On Sat, Mar 26, 2016 at 8:08 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote: > > On Sat, Mar 26, 2016 at 8:00 AM, Marco Pivetta <ocramius@gmail.com> > wrote: > >> On 25 March 2016 at 23:56, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote: > >>> > >>> Hi all, > >>> > >>> On Sat, Mar 26, 2016 at 5:31 AM, Marco Pivetta <ocramius@gmail.com> > wrote: > >>> > var_dump((object) ['' => 'foo']); > >>> > var_dump((object) ["\0*\0" => 'foo']); > >>> > var_dump((object) ["\0Foo\0" => 'foo']); > >>> > >>> Allowing null char would be too much. We reject null char in path > >>> parameters, it should be rejected like path parameter. IMHO. > >> > >> > >> The sequence "\0*\0" means "protected property", while the > >> sequence > >> "\0Foo\0" means "private property of class Foo": that's been > >> the case > for a > >> looooong time :-) > > > > Oh. Was it? I've never used and encountered this. Thanks. > > I'll avoid null char as I use PostgreSQL JSONB extensively, though. > > > >> Not suggesting allowing "\0" for property names: the example just shows > >> creating a public, private and protected property with an empty name. > > > > Could you show some real world example use cases? > > You mean PHP converts private/protected property to this form, not > currently used as JSON string. > I understand your point! > > It would be good for PHP users supporting null chars in names, then. > As the discussion seems to going off on a tangent I'd like to clarify: I'm only suggesting to remove the restriction on empty property names. The restrictions we have on properties starting with NUL bytes stay intact, as these do serve a purpose with regard to name mangling. To add one further data point, dropping the empty property restriction also fixes this bug about returning an array with an empty key from __debugInfo(): https://bugs.php.net/bug.php?id=69537 Nikita

« previous php.internals (#91970) next »