php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79109 foreach on empty array
Submitted: 2020-01-13 13:25 UTC Modified: 2020-01-13 13:28 UTC
From: a dot dankovtsev at mail dot ru Assigned:
Status: Duplicate Package: opcache
PHP Version: 7.4.1 OS: debian stretch
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: a dot dankovtsev at mail dot ru
New email:
PHP Version: OS:

 

 [2020-01-13 13:25 UTC] a dot dankovtsev at mail dot ru
Description:
------------
In test env in our product sometimes caused Undefined variable $value with empty array
But local don't reproduce


Test script:
---------------
<?php

class Test
{
    private const PRIVATE_ARRAY = [];

    public function run(): int
    {
        foreach (self::PRIVATE_ARRAY as $key => $value) {
            return $value;
        }

        return 1;
    }
}

(new Test())->run();



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-13 13:28 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2020-01-13 13:28 UTC] nikic@php.net
I don't think we have a bug reference for it, but this issue is already fixed in 7.4.2.

It is related to opcache, which is likely why you can't reproduce locally.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Oct 25 09:01:23 2020 UTC