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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 12:01:30 2024 UTC