php-src/ext/opcache/tests/gh8846-2.inc
Ilija Tovilo 0600f513b3
Implement delayed early binding for classes without parents
Normally, we add classes without parents (and no interfaces or traits) directly
to the class map, early binding the class. However, if the same class has
already been registered, we would instead just add a ZEND_DECLARE_CLASS
instruction and let the handler throw a duplicate class declaration exception.

However, with opcache, if on the next request the files are included in the
opposite order, we won't perform early binding. To fix this, create a
ZEND_DECLARE_CLASS_DELAYED instruction instead and handle classes without
parents accordingly, skipping any linking for classes that are already linked in
delayed early binding.

Fixes GH-8846
2023-05-15 10:25:33 +02:00

6 lines
59 B
PHP

<?php
var_dump(Foo::BAR);
class Foo {
const BAR = true;
}