-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed as not planned
Closed as not planned
Copy link
Description
Description
The following codes:
BasicObject.php
<?php
class BasicObject
{
}Constant.php
<?php
class Constant extends BasicObject
{
public const
CONST_1 = 'PHP * Swoole',
CONST_2 = 'PHP * Fiber';
}SimpleConst.php
<?php
class SimpleConst
{
public const GREETINGS = 'hello world!';
}test.php
<?php
\spl_autoload_register(static function ($clsName) {
if ($clsName === 'BasicObject') {
Fiber::suspend('before load BasicObject in autoload');
}
$path = __DIR__ . '/' . \str_replace('\\', '/', $clsName) . '.php';
if (\is_file($path)) {
require $path;
} else {
echo "class {$clsName} not found\n";
}
});
function work_fn(...$args)
{
echo SimpleConst::GREETINGS . PHP_EOL;
echo Fiber::suspend("before load constant\n");
return Fiber::suspend(Constant::CONST_1);
}
$fiber = new Fiber(work_fn(...));
echo $fiber->start();
echo $fiber->resume("continue\n");
echo $fiber->resume(Constant::CONST_2);Resulted in this output:
hello world!
before load constant
continue
before load BasicObject in autoload
Fatal error: Uncaught Error: Class "Constant" not found in /path/to/test.php:25
Stack trace:
#0 {main}
thrown in /path/to/test.php on line 25
But I expected this output instead:
Class "Constant" should load successfully
This is similar to the issue discussed in swoole/swoole-src#5770.
Related codes:
Load unlinked CE
PHP Version
PHP 8.3.21 (cli) (built: May 6 2025 13:58:10) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.3.21, Copyright (c) Zend Technologies
with Zend OPcache v8.3.21, Copyright (c), by Zend Technologies
Operating System
Fedora 42