Re: [VOTE] Fix list() behavior inconsistency
| From: | Patrick ALLAERT | Date: | Fri, 26 Sep 2014 15:32:42 +0000 |
| Subject: | Re: [VOTE] Fix list() behavior inconsistency | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-77679@lists.php.net to get a copy of this message | ||
2014-09-25 17:27 GMT+02:00 Patrick ALLAERT <patrickallaert@php.net>:
> 2014-09-25 9:42 GMT+02:00 Dmitry Stogov <dmitry@zend.com>:
>
>> Hi,
>>
>> The vote is opened at
>> https://wiki.php.net/rfc/fix_list_behavior_inconsistency
>>
>> Thanks. Dmitry.
>>
>
> Hi,
>
> I'm in favor of disabling for consistency as well, however, I wish a
> warning would be emitted.
> Not only it would tell me that I have a potential error while upgrading to
> PHP 7 but also if I am using it incorrectly, which is always the case when
> using a scalar value.
>
> I therefor propose that:
> list($a, $b) = 42;
> list($a, $b) = "42";
> list($a, $b) = null;
> ...
> generates a warning like: PHP Warning: list() expects right operand to be
> array, <type> given in <path> on line <line>
>
> Currently, all of the above lines wouldn't generate any notice / warning /
> error, however, using:
> list($a, $b) = [];
>
> generates the following notices:
> PHP Notice: Undefined offset: 1 in ... on line ...
> PHP Notice: Undefined offset: 0 in ... on line ...
>
> This is confusing since (to me) using an array is at least better than
> using scalars.
>
> Patrick
>
bump ?
(It is ok to say it's a stupid idea or that I just don't know what I am
talking about)
Patrick