Hi,
Just looking at the foreach list behaviour and it does this...
$i = [1, 2, 3];
foreach($i as list($a, $b))
var_dump($a, $b);
Outputs....
NULL
NULL
NULL
NULL
NULL
NULL
There is no test I can see covering this, so cannot tell if its
expected.
To me, $i does not meet the expected format, so should be some sort of
error happening.
Jared
Hi:
this is expected behavior, like:
<?php
list($a, $b) = 1;
var_dump($a);
thanks
On Mon, Sep 3, 2012 at 7:07 AM, Jared Williams
jared.williams@ntlworld.com wrote:
Hi,
Just looking at the foreach list behaviour and it does this...
$i = [1, 2, 3];
foreach($i as list($a, $b))
var_dump($a, $b);Outputs....
NULL
NULL
NULL
NULL
NULL
NULL
There is no test I can see covering this, so cannot tell if its
expected.To me, $i does not meet the expected format, so should be some sort of
error happening.Jared
--
--
Laruence Xinchen Hui
http://www.laruence.com/
Just looking at the foreach list behaviour and it does this...
$i = [1, 2, 3];
foreach($i as list($a, $b))
var_dump($a, $b);Outputs....
NULL
NULL
NULL
NULL
NULL
NULL
There is no test I can see covering this, so cannot tell if its
expected.To me, $i does not meet the expected format, so should be some sort of
error happening.this is expected behavior, like:
<?php
list($a, $b) = 1;
var_dump($a);
Ew, that's quite nasty (in both cases). Is there a way how we could turn
those into a notice or so?
cheers,
Derick
--
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
Posted with an email client that doesn't mangle email: alpine
Just looking at the foreach list behaviour and it does this...
$i = [1, 2, 3];
foreach($i as list($a, $b))
var_dump($a, $b);Outputs....
NULL
NULL
NULL
NULL
NULL
NULL
There is no test I can see covering this, so cannot tell if its
expected.To me, $i does not meet the expected format, so should be some sort of
error happening.this is expected behavior, like:
<?php
list($a, $b) = 1;
var_dump($a);Ew, that's quite nasty (in both cases). Is there a way how we could turn
those into a notice or so?
Hi:
yeah, we can trigger a notice if the container is not a array.
but maybe deserve a RFC?
thanks
cheers,
Derick--
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
Posted with an email client that doesn't mangle email: alpine
--
Laruence Xinchen Hui
http://www.laruence.com/
hi,
Just looking at the foreach list behaviour and it does this...
$i = [1, 2, 3];
foreach($i as list($a, $b))
var_dump($a, $b);Outputs....
NULL
NULL
NULL
NULL
NULL
NULL
There is no test I can see covering this, so cannot tell if its
expected.To me, $i does not meet the expected format, so should be some sort of
error happening.this is expected behavior, like:
<?php
list($a, $b) = 1;
var_dump($a);Ew, that's quite nasty (in both cases). Is there a way how we could turn
those into a notice or so?
Hi:yeah, we can trigger a notice if the container is not a array.
but maybe deserve a RFC?
I do not think it is necessary. It is an improvement of this newly
added feature and list.
Cheers,
Pierre
@pierrejoye
hi,
Just looking at the foreach list behaviour and it does this...
$i = [1, 2, 3];
foreach($i as list($a, $b))
var_dump($a, $b);Outputs....
NULL
NULL
NULL
NULL
NULL
NULL
There is no test I can see covering this, so cannot tell if its
expected.To me, $i does not meet the expected format, so should be some sort of
error happening.this is expected behavior, like:
<?php
list($a, $b) = 1;
var_dump($a);Ew, that's quite nasty (in both cases). Is there a way how we could turn
those into a notice or so?
Hi:yeah, we can trigger a notice if the container is not a array.
but maybe deserve a RFC?
I do not think it is necessary. It is an improvement of this newly
added feature and list.
Hi:
if we fixed this, what about following example:
<?php
$num = NULL;
echo $num["xxx"];
does this also deserve a notice?
thanks
Cheers,
Pierre
@pierrejoye
--
Laruence Xinchen Hui
http://www.laruence.com/
Laruence laruence@php.net wrote:
Hi:
if we fixed this, what about following example:<?php
$num = NULL;
echo $num["xxx"];
does this also deserve a notice?
thanks
No because NULL
is just the first element in implicit array conversion
--
Laruence Xinchen Hui
http://www.laruence.com/--
--
Sent from my Android phone with K-9 Mail.
Andrew Faulds
http://ajf.me/
Ew, that's quite nasty (in both cases). Is there a way how we could turn
those into a notice or so?cheers,
Derick
Sorry, hit reply instead of reply-all...
list($a,$b) = 1;
var_dump($a,$b);
/*
NULL
NULL
*/
This doesn't throw notices anywhere else... why should it throw
notices in foreach? I guess the only logical answer would be to notify
you if you were using scalar values with foreach and list, but then we
don't notify you if you're using scalar values with list anywhere else
in the language anyway. I'm starting to see huge inconsistencies with
how list is being implemented in foreach.
Ew, that's quite nasty (in both cases). Is there a way how we could turn
those into a notice or so?cheers,
DerickSorry, hit reply instead of reply-all...
list($a,$b) = 1;
var_dump($a,$b);
/*
NULL
NULL
*/This doesn't throw notices anywhere else... why should it throw
notices in foreach? I guess the only logical answer would be to notify
you if you were using scalar values with foreach and list, but then we
don't notify you if you're using scalar values with list anywhere else
in the language anyway. I'm starting to see huge inconsistencies with
how list is being implemented in foreach.
Possibly more importantly, since 1 should cast to, er, [1] (I think...),
why is $a === NULL?
--
Andrew Faulds
http://ajf.me/
Ew, that's quite nasty (in both cases). Is there a way how we could turn
those into a notice or so?cheers,
DerickSorry, hit reply instead of reply-all...
list($a,$b) = 1;
var_dump($a,$b);
/*
NULL
NULL
*/This doesn't throw notices anywhere else... why should it throw
notices in foreach? I guess the only logical answer would be to notify
you if you were using scalar values with foreach and list, but then we
don't notify you if you're using scalar values with list anywhere else
in the language anyway. I'm starting to see huge inconsistencies with
how list is being implemented in foreach.Possibly more importantly, since 1 should cast to, er, [1] (I think...), why
is $a === NULL?--
Andrew Faulds
http://ajf.me/
It should absolute not cast anything. list($a, $b) = $c; is the
equivalent of saying $a = $c[0]; $b = $c[1]; In this case $c just
happens to be a scalar value and as such you can not derive anything
from the scalar value in that context. It is implicitly null.
It should absolute not cast anything. list($a, $b) = $c; is the
equivalent of saying $a = $c[0]; $b = $c[1]; In this case $c just
happens to be a scalar value and as such you can not derive anything
from the scalar value in that context. It is implicitly null.
Ah, I guess I'm confusing GML and PHP array semantics, somehow... my bad.
--
Andrew Faulds
http://ajf.me/