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

Test script:

class Test
    private const PRIVATE_ARRAY = [];

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

        return 1;

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-13 13:28 UTC]
-Status: Open +Status: Duplicate
 [2020-01-13 13:28 UTC]
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: Fri Mar 01 22:01:28 2024 UTC