php-src/Zend/tests/exception_during_variance_autoload.phpt
Nikita Popov c8fa477064 Convert exception during delayed autoload to fatal error
Same as with other exceptions during inheritance, convert those
thrown during delayed class loading into fatal errors. We can't
properly deal with such exceptions, as inheritance cannot be
gracefully aborted at this point.

Fixes oss-fuzz #39405.
2021-09-29 10:03:23 +02:00

29 lines
505 B
PHP

--TEST--
Exception during delayed variance autoload
--FILE--
<?php
spl_autoload_register(function($class) {
echo "$class\n";
if ($class == 'X') {
new Y;
}
if ($class == 'Y') {
new Q;
}
});
class A {
function method(): X {}
}
class B extends A {
function method(): Y {}
}
?>
--EXPECTF--
Y
Q
Fatal error: During inheritance of B, while autoloading Y: Uncaught Error: Class "Q" not found in %s:%d
Stack trace:
#0 %s(%d): {closure}('Y')
#1 {main} in %s on line %d