php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75984 Function empty() throws E_NOTICE on undefined index of class const array
Submitted: 2018-02-20 09:33 UTC Modified: 2018-02-20 10:05 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: evgvzubkoff at gmail dot com Assigned:
Status: Wont fix Package: Arrays related
PHP Version: 5.6.33 OS: Ubuntu 16.04 LTS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
39 - 29 = ?
Subscribe to this entry?

 
 [2018-02-20 09:33 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-20 10:05 UTC] kelunik@php.net
-Status: Open +Status: Wont fix
 [2018-02-20 10:05 UTC] kelunik@php.net
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
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 14:01:29 2024 UTC