Bug #75984 [NEW]: Function empty() throws E_NOTICE on undefined index of class const array
| From: | evgvzubkoff at gmail dot com | Date: | Tue, 20 Feb 2018 09:33:11 +0000 |
| Subject: | Bug #75984 [NEW]: Function empty() throws E_NOTICE on undefined index of class const array | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-214043@lists.php.net to get a copy of this message | ||
From: evgvzubkoff at gmail dot com
Operating system: Ubuntu 16.04 LTS
PHP version: 5.6.33
Package: Arrays related
Bug Type: Bug
Bug description:Function empty() throws E_NOTICE on undefined index of class const array
Description:
------------
Test code - https://3v4l.org/7bfQS
Test script:
---------------
<?php
class Foo
{
/**
* Values
* @var array
*/
const VALUES = [
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3'
];
/**
* Test function
*/
public function execute()
{
$key = 'key4';
if (!empty(self::VALUES[$key])) {
self::VALUES[$key];
} else {
echo 'The key doesn\'t found in this array.';
}
}
}
$foo = new Foo();
$foo->execute();
Expected result:
----------------
There should not be E_NOTICE
Actual result:
--------------
I get E_NOTICE
--
Edit bug report at https://bugs.php.net/bug.php?id=75984&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75984&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75984&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75984&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75984&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75984&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75984&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75984&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75984&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75984&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75984&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75984&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75984&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75984&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75984&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75984&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75984&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75984&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75984&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75984&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75984&r=mysqlcfg