Bug #79055 [NEW]: Typed property become unknown with OPcache file cache

From: Date: Thu, 02 Jan 2020 10:01:57 +0000
Subject: Bug #79055 [NEW]: Typed property become unknown with OPcache file cache
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224657@lists.php.net to get a copy of this message
From:             kentaro at ranvis dot com
Operating system: Linux
PHP version:      7.4Git-2020-01-02 (Git)
Package:          opcache
Bug Type:         Bug
Bug description:Typed property become unknown with OPcache file cache

Description:
------------
When OPcache loads cached script from file,
PHP fails to identify typed property specifier in the loaded class, and
reports it typed as "unknown or null".

Fails on PHP-7.4 (8d2b20db58849d1f54303f66656a3776456cbe95),
while succeeds on master (a9c04aee67a1d787101c967b8980d679b1714bf0).

I'm sorry to bother if it's going to be fixed in 7.4 branch too.

Test script:
---------------
mkdir /dev/shm/opcache
./php -n -d extension_dir=modules/ -d zend_extension=opcache -d
opcache.enable=1 -d opcache.enable_cli=1 -d
opcache.file_cache=/dev/shm/opcache main.php
# run above script twice

[main.php]
<?php
opcache_reset();
spl_autoload_register(function ($cls) {
    echo "$cls\n";
    require_once(__DIR__ . "/$cls.php");
});
try {
    $c = new C();
    $x = new X($c);
    echo "Success\n";
} catch (Error $e) {
    echo $e->getMessage() . "\n";
}

[C.php]
<?php
class C {}

[X.php]
<?php
class X {
    private C $c;
    public function __construct(C $c) {
        $this->c = $c;
    }
}


Expected result:
----------------
$ ./php ...
C
X
Success
$ ./php ...
C
X
Success


Actual result:
--------------
$ ./php ...
C
X
Success
$ ./php ...
C
X
Typed property X::$c must be unknown or null, C used


-- 
Edit bug report at https://bugs.php.net/bug.php?id=79055&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79055&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79055&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79055&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79055&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79055&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79055&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79055&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79055&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79055&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79055&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79055&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79055&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79055&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79055&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79055&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79055&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79055&r=mysqlcfg


Thread (4 messages)

« previous php.bugs (#224657) next »