Re: invalid array key/index not generating notices

From: Date: Sat, 30 Dec 2006 16:55:40 +0000
Subject: Re: invalid array key/index not generating notices
Groups: php.internals 
Request: Send a blank email to internals+get-27218@lists.php.net to get a copy of this message
I came across a subtle bug a developer introduced into our application. It took us a month to realize the bug was there because PHP didn't throw a notice. http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute.c?revision=1.755&view=markup
Down inside zend_fetch_dimension_address(), you'll find this block: switch(Z_TYPE_P(container)) { /* ... */ case IS_NULL: {
    /* for read-mode only */
    if (result) {
      result->var.ptr_ptr = &EG(uninitialized_zval_ptr);
      PZVAL_LOCK(*result->var.ptr_ptr);
    }
    if (type==BP_VAR_W || type==BP_VAR_RW) {
      zend_error(E_WARNING, "Cannot use a NULL value as an array");
    }
    break;
} /* ... */ } To me, that screams intentional, and since BC trumps reason, this isn't going to change. -Sara

« previous php.internals (#27218) next »