Description
The following code:
// preload.inc
#[Attribute]
class A {
function __construct(public mixed $fn) {}
}
#[A(strlen(...))]
class C {
const CC = strlen(...);
#[A(strlen(...))]
function f($arg = strlen(...)) {
return $arg;
}
}
const CC = strlen(...);
// preload.php
echo "# Class const\n";
var_dump((C::CC)('hello'));
echo "# Class attr\n";
var_dump((new ReflectionClass(C::class)->getAttributes(A::class)[0]->newInstance()->fn)('hello'));
echo "# Method attr\n";
var_dump((new ReflectionMethod(C::class, 'f')->getAttributes(A::class)[0]->newInstance()->fn)('hello'));
echo "# Method default value\n";
var_dump((new C()->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