Re: 5.4 regression: non-existent sub-sub keys now have values
| From: | Richard Quadling | Date: | Wed, 23 Nov 2011 17:58:42 +0000 |
| Subject: | Re: 5.4 regression: non-existent sub-sub keys now have values | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-56517@lists.php.net to get a copy of this message | ||
On 23 November 2011 15:31, Daniel Convissor
<danielc@analysisandsolutions.com> wrote:
> Hi Again Folks:
>
> On Wed, Nov 23, 2011 at 09:14:09AM -0500, Daniel Convissor wrote:
>> $a = 'foo';
>> echo $a['blah'] . "\n";
>>
>> But that second one echos out "f". This is a huge WTF.
>
> Two things for the record on this front. First, i've been actively
> using PHP for, what, ten years or so, and have never run into this
> behavior before. Second, this behavior turns the following one liner:
>
> if (isset($arr['package']['attribs']['version'])) {
>
> Into this:
>
> if (is_array($arr)
> && array_key_exists('package', $arr)
> && is_array($arr['package'])
> && array_key_exists('attribs',
> $arr['package'])
> && is_array($arr['package']['attribs'])
> && array_key_exists('version',
> $arr['package']['attribs'])
> &&
> !empty($arr['package']['attribs']['version']))
> {
I agree with Daniel on this.
Just looking for any test relating to isset() to see what tests will now fail.
Neither of the isset() tests ext/standard/tests/general_functions look
at arrays with associative indices.
The behaviour with regard to unavailable associative indices has no tests.
But using loose typing as a fallback for non existent keys seems
really really wrong.
Especially if the key is a constant. On what planet should ...
isset($arr['exists']['test_existance']) should become
isset($arr['exists'][0])
That just seems really wrong and the work around is awful.
--
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370