Bug #70884 [Fbk->NoF]: Empty() throws E_NOTICE on undefined index of class const array

From: Date: Sun, 22 Nov 2015 04:22:19 +0000
Subject: Bug #70884 [Fbk->NoF]: Empty() throws E_NOTICE on undefined index of class const array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197364@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70884&edit=1

 ID:               70884
 Updated by:       php-bugs@lists.php.net
 Reported by:      info at ronin-design dot com
 Summary:          Empty() throws E_NOTICE on undefined index of class
                   const array
-Status:           Feedback
+Status:           No Feedback
 Type:             Bug
 Package:          Class/Object related
 Operating System: OS X 10.10.4 (14E46)
 PHP Version:      5.6.15
 Private report:   N

 New Comment:

No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.


Previous Comments:
------------------------------------------------------------------------
[2015-11-10 03:05:06] reeze@php.net

Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


https://3v4l.org/Ue5Cj  There is no Notice.  please provider
more information.

------------------------------------------------------------------------
[2015-11-09 23:04:03] info at ronin-design dot com

Description:
------------
Empty() function throws E_NOTICE "Notice: Undefined index" when checking a class constant
of type ARRAY for non-existent element. However, isset() works as expected.

Test script:
---------------
class Test
{
  private $obj;
  const MAP = ['testKey' => 'test'];
  
  function __construct()
  {
    $this->obj       = new \stdClass();
    $this->obj->test = "testObject";
  }

  public function isKey($name = 'testKey') {
    var_dump(empty($this->obj->{static::MAP[$name]}));
    var_dump(empty($this->obj->$name));
  }
}

Expected result:
----------------
Expect to see var_dump() return boolean result of empty() WITHOUT E_NOTICE generation.

Actual result:
--------------
var_dump() correctly returns result of empty(), but also generates E_NOTICE "Notice: Undefined
index"


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70884&edit=1


Thread (3 messages)

« previous php.bugs (#197364) next »