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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: evgvzubkoff at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sat Dec 21 13:01:31 2024 UTC