Description
The following code:
// preload.inc
#[Attribute]
class A {
function__construct(publicmixed$fn) {}
}
#[A(strlen(...))]
class C {
constCC = strlen(...);
#[A(strlen(...))]
functionf($arg = strlen(...)) {
return$arg;
}
}
constCC = strlen(...);// preload.phpecho"# Class const\n";
var_dump((C::CC)('hello'));
echo"# Class attr\n";
var_dump((newReflectionClass(C::class)->getAttributes(A::class)[0]->newInstance()->fn)('hello'));
echo"# Method attr\n";
var_dump((newReflectionMethod(C::class, 'f')->getAttributes(A::class)[0]->newInstance()->fn)('hello'));
echo"# Method default value\n";
var_dump((newC()->f())('hello'));When executed with
$ php -d opcache.enable_cli=1 -d opcache.preload=preload.inc preload.php
Resulted in two issues:
- Preloading evaluates class constants during compilation, but FCCs evaluate to objects, which can't be persisted
- zend_fcc_ast->fptr is allocated with ZEND_MAP_PTR_NEW during compilation, which results in map ptr collisions later
PHP Version
Operating System
No response
Description
The following code:
When executed with
Resulted in two issues:
PHP Version
Operating System
No response