Re: [PHP-DEV] Array dereferencing of scalars

2015-06-14 Thread Rowan Collins
On 14 June 2015 04:33:16 BST, Yasuo Ohgaki wrote: >Hi Rowan, > >On Thu, Jun 11, 2015 at 5:59 PM, Rowan Collins > >wrote: >> This one has given a different message because of it being a >non-string >> value, but would be equally fatal if you tried to call any undefined >> function. Would coercing N

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-13 Thread Yasuo Ohgaki
Hi all, On Fri, Jun 12, 2015 at 9:36 AM, Chris Wright wrote: > On 12 June 2015 at 00:35, Rowan Collins wrote: > > > On 11/06/2015 21:22, Chris Wright wrote: > > > >> I'm inclined to agree that we should have consistency here, and that the > >> current behaviour in a function context is the corr

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-13 Thread Yasuo Ohgaki
Hi Rowan, On Thu, Jun 11, 2015 at 5:59 PM, Rowan Collins wrote: > Yasuo Ohgaki wrote on 11/06/2015 00:50: > >> If PHP should return NULL always against NULL variables, we may be better >> to >> reconsider these behavior. >> >> [yohgaki@dev Download]$ php >> > $v = NULL; >> $$v; >> >> >> PHP Noti

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-11 Thread Chris Wright
On 12 June 2015 at 00:35, Rowan Collins wrote: > On 11/06/2015 21:22, Chris Wright wrote: > >> I'm inclined to agree that we should have consistency here, and that the >> current behaviour in a function context is the correct one. A couple of >> (IMO) good arguments for this: >> >> - The function

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-11 Thread Rowan Collins
On 11/06/2015 21:22, Chris Wright wrote: I'm inclined to agree that we should have consistency here, and that the current behaviour in a function context is the correct one. A couple of (IMO) good arguments for this: - The function behaviour gives a more explanatory and useful error message -

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-11 Thread Chris Wright
On 11 June 2015 at 09:59, Rowan Collins wrote: > Yasuo Ohgaki wrote on 11/06/2015 00:50: > >> If PHP should return NULL always against NULL variables, we may be better >> to >> reconsider these behavior. >> >> [yohgaki@dev Download]$ php >> > $v = NULL; >> $$v; >> >> >> PHP Notice: Undefined var

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-11 Thread Rowan Collins
Yasuo Ohgaki wrote on 11/06/2015 00:50: If PHP should return NULL always against NULL variables, we may be better to reconsider these behavior. [yohgaki@dev Download]$ php This is not complaining that $v is NULL, it is warning you the same as if you wrote $v = 'some_name_you_never_assigned_to

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-10 Thread Yasuo Ohgaki
Hi all, On Thu, Jun 11, 2015 at 7:22 AM, Yasuo Ohgaki wrote: > I agree that NULL is debatable. In PHP, NULL is treated as 0/false by its > context. > It's simpler if we get rid of the behavior altogether. IMO. > If PHP should return NULL always against NULL variables, we may be better to recons

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-10 Thread Christoph Becker
Yasuo Ohgaki wrote: > On Wed, Jun 10, 2015 at 5:30 PM, Nikita Popov wrote: > >> On Wed, Jun 10, 2015 at 8:53 AM, Stanislav Malyshev >> wrote: >> >>> $foo = 42; $foo['bar']; // => NULL $v = NULL; $v[0][1][2][3][4][5][6][7][8][9]; // NULL this code is semantical

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-10 Thread Yasuo Ohgaki
Hi Stas and Nikita, On Wed, Jun 10, 2015 at 5:30 PM, Nikita Popov wrote: > On Wed, Jun 10, 2015 at 8:53 AM, Stanislav Malyshev > wrote: > >> Hi! >> >> > > > $foo = 42; >> > $foo['bar']; // => NULL >> > $v = NULL; >> > $v[0][1][2][3][4][5][6][7][8][9]; // NULL >> > >> > this code is semanti

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-10 Thread AllenJB
On , Nikita Popov wrote: On Wed, Jun 10, 2015 at 8:53 AM, Stanislav Malyshev wrote: Hi! >$foo = 42; > $foo['bar']; // => NULL > $v = NULL; > $v[0][1][2][3][4][5][6][7][8][9]; // NULL > > this code is semantically wrong and I would like to have error/exception > for such > erroneous co

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-10 Thread Nikita Popov
On Wed, Jun 10, 2015 at 8:53 AM, Stanislav Malyshev wrote: > Hi! > > > > $foo = 42; > > $foo['bar']; // => NULL > > $v = NULL; > > $v[0][1][2][3][4][5][6][7][8][9]; // NULL > > > > this code is semantically wrong and I would like to have error/exception > > for such > > erroneous codes. It'

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Stanislav Malyshev
Hi! >$foo = 42; > $foo['bar']; // => NULL > $v = NULL; > $v[0][1][2][3][4][5][6][7][8][9]; // NULL > > this code is semantically wrong and I would like to have error/exception > for such > erroneous codes. It's inconsistent with array object, too. Why it's wrong? You try to get that's s

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Christoph Becker
Rowan Collins wrote: > Christoph Becker wrote on 09/06/2015 14:09: >> I wonder where these coercion rules are described. The manual has a >> section about "Converting to array"[1] which actually describes casting, >> and is obviously not what is happening when the subscript operator (as >> the la

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Rowan Collins
Christoph Becker wrote on 09/06/2015 14:09: I wonder where these coercion rules are described. The manual has a section about "Converting to array"[1] which actually describes casting, and is obviously not what is happening when the subscript operator (as the langspec calls it[2]) is applied to

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Christoph Becker
Rowan Collins wrote: > Yasuo Ohgaki wrote on 09/06/2015 11:44: >> $v = NULL; >> $v[0][1][2][3][4][5][6][7][8][9]; // NULL >> >> this code is semantically wrong and I would like to have error/exception >> for such >> erroneous codes. > > PHP considers an uninitialised variable to have the valu

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Rowan Collins
Christoph Becker wrote on 09/06/2015 13:35: Current behavior: foo->bar; ?> Notice: Trying to get property of non-object in %s on line %d Notice: Trying to get property of non-object in %s on line %d So trying to access a property on NULL gives a notice, but trying to access an eleme

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Rowan Collins
Christoph Becker wrote on 08/06/2015 22:11: The behavior of dereferencing scalars as if they were arrays or strings is arguable: NULL A few things to note here: - accessing a *numeric* offset of a *string* is valid (selects a single character) - accessing a *string* offset of another str

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Christoph Becker
Matt Wilmas wrote: > Forgetting the NULL case for a sec... With: > > $v = []; > $v[0][1][2][3][4][5][6][7][8][9]; > > How/why are we going from 1 Notice to 10?! > > With: > > unset($v); > $v[0]; > > Why from 1 Notice about the undefined variable, to 2? That's totally > new, and it really do

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Rowan Collins
Yasuo Ohgaki wrote on 09/06/2015 11:44: $v = NULL; $v[0][1][2][3][4][5][6][7][8][9]; // NULL this code is semantically wrong and I would like to have error/exception for such erroneous codes. PHP considers an uninitialised variable to have the value NULL, and a NULL value to be coercable

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Matt Wilmas
Hi all, - Original Message - From: "Christoph Becker" Sent: Tuesday, June 09, 2015 Yasuo Ohgaki wrote: I fully agree that current behavior could be used meaningful ways. However, NULL $v = NULL; $v[0][1][2][3][4][5][6][7][8][9]; // NULL this code is semantically wrong and I wou

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Christoph Becker
Yasuo Ohgaki wrote: > I fully agree that current behavior could be used meaningful ways. However, > >$foo = 42; > $foo['bar']; // => NULL > $v = NULL; > $v[0][1][2][3][4][5][6][7][8][9]; // NULL > > this code is semantically wrong and I would like to have error/exception > for such > erro

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Yasuo Ohgaki
Hi Matt, On Tue, Jun 9, 2015 at 7:04 PM, Matt Wilmas wrote: > Hi all, > > > - Original Message - > From: "Yasuo Ohgaki" > Sent: Tuesday, June 09, 2015 > > Hi all, >> >> On Tue, Jun 9, 2015 at 6:21 AM, Stanislav Malyshev >> wrote: >> >> > Would throwing a notice or a warning on array d

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Matt Wilmas
Hi all, - Original Message - From: "Yasuo Ohgaki" Sent: Tuesday, June 09, 2015 Hi all, On Tue, Jun 9, 2015 at 6:21 AM, Stanislav Malyshev wrote: > Would throwing a notice or a warning on array deferencing scalars > be acceptable for PHP 7.0, or does this need an RFC? I think this d

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-09 Thread Yasuo Ohgaki
Hi all, On Tue, Jun 9, 2015 at 6:21 AM, Stanislav Malyshev wrote: > > Would throwing a notice or a warning on array deferencing scalars > > be acceptable for PHP 7.0, or does this need an RFC? > > I think this does need an RFC, and for 7.0, pretty much no new language > changes are acceptable an

Re: [PHP-DEV] Array dereferencing of scalars

2015-06-08 Thread Stanislav Malyshev
Hi! > Would throwing a notice or a warning on array deferencing scalars > be acceptable for PHP 7.0, or does this need an RFC? I think this does need an RFC, and for 7.0, pretty much no new language changes are acceptable anymore, since we're past the timeframe. -- Stas Malyshev smalys...@gmail.

[PHP-DEV] Array dereferencing of scalars

2015-06-08 Thread Christoph Becker
The behavior of dereferencing scalars as if they were arrays or strings is arguable: NULL This happens without notice or warning, whereas the array dereferencing of objects results in a fatal error: https://bugs.php.net/bug.php?id=54556> [2] [3]