Bug #76269 [Com]: Empty on constant array
| From: | peehaa@php.net | Date: | Wed, 25 Apr 2018 16:19:54 +0000 |
| Subject: | Bug #76269 [Com]: Empty on constant array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214892@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76269&edit=1
ID: 76269
Comment by: peehaa@php.net
Reported by: ivanis dot kouame+php at gmail dot com
Summary: Empty on constant array
Status: Closed
Type: Bug
Package: Reproducible crash
Operating System: Linux
PHP Version: 5.6.35
Assigned To: peehaa
Block user comment: N
Private report: N
New Comment:
Actually it was already fixed in 7.0
Previous Comments:
------------------------------------------------------------------------
[2018-04-25 16:15:56] 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:09:02] 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)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76269&edit=1