|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-11-10 03:05 UTC] reeze@php.net
-Status: Open
+Status: Feedback
[2015-11-10 03:05 UTC] reeze@php.net
[2015-11-22 04:22 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 23:00:01 2025 UTC |
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"