Bug #76269 [Opn->Csd]: Empty on constant array

From: Date: Wed, 25 Apr 2018 16:15:57 +0000
Subject: Bug #76269 [Opn->Csd]: Empty on constant array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214891@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 Updated by: peehaa@php.net Reported by: ivanis dot kouame+php at gmail dot com Summary: Empty on constant array -Status: Open +Status: Closed Type: Bug Package: Reproducible crash Operating System: Linux PHP Version: 5.6.35 -Assigned To: +Assigned To: peehaa Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#214891) next »