php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76269 Empty on constant array
Submitted: 2018-04-25 16:09 UTC Modified: 2018-04-25 16:16 UTC
From: ivanis dot kouame+php at gmail dot com Assigned: peehaa (profile)
Status: Closed Package: Reproducible crash
PHP Version: 5.6.35 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ivanis dot kouame+php at gmail dot com
New email:
PHP Version: OS:

 

 [2018-04-25 16:09 UTC] ivanis dot kouame+php at gmail dot com
Description:
------------
I try to do an array access wrapped with empty on a constant array and a notice is thrown. I expected that empty would simply return false in the case the key is not found.

Test script:
---------------
<?php
class Test
{
  const FOO = ["a" => 0, "b" => 1, "b" => 2, "d" => 3];    

  public function getTest()
  {
    $a = ["a" => 0, "b" => 1, "b" => 2, "d" => 3];
    var_dump(empty($a["not_found"]));

    $b = self::FOO;
    var_dump(empty($b["not_found"]));

    var_dump(empty(self::FOO["not_found"]));
  }
}


$a = new Test();
$a->getTest();

Expected result:
----------------
bool(true)
bool(true)
bool(true)

Actual result:
--------------
bool(true)
bool(true)
<br />
<b>Notice</b>:  Undefined index: vsqsc in <b>[...][...]</b> on line <b>9</b><br />
bool(true)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-04-25 16:15 UTC] peehaa@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: peehaa
 [2018-04-25 16:15 UTC] peehaa@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

This seems to be already fixed as of 7.1 https://3v4l.org/UYg9F

Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php
 [2018-04-25 16:19 UTC] peehaa@php.net
Actually it was already fixed in 7.0
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 22:01:30 2024 UTC