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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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: Fri Dec 13 03:01:28 2024 UTC