Bug #75984 [Opn->Wfx]: Function empty() throws E_NOTICE on undefined index of class const array

From: Date: Tue, 20 Feb 2018 10:05:25 +0000
Subject: Bug #75984 [Opn->Wfx]: Function 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-214045@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75984&edit=1 ID: 75984 Updated by: kelunik@php.net Reported by: evgvzubkoff at gmail dot com Summary: Function empty() throws E_NOTICE on undefined index of class const array -Status: Open +Status: Wont fix Type: Bug Package: Arrays related Operating System: Ubuntu 16.04 LTS PHP Version: 5.6.33 Block user comment: N Private report: N New Comment: This bug has already been fixed in recent versions of PHP as you can see in the 3v4l.org link you posted. The version you're using (5.6.x) is in security-only support mode. No further bug fixes are provided for that version. Please upgrade to a newer version of PHP. See also https://secure.php.net/supported-versions.php Previous Comments: ------------------------------------------------------------------------ [2018-02-20 09:33:08] evgvzubkoff at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=75984&edit=1

« previous php.bugs (#214045) next »