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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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 20:01:29 2024 UTC