Fix wrongly constructed class

This commit is contained in:
crazywhalecc
2026-05-10 15:50:21 +08:00
parent 02d8f51bb2
commit 7107566da7
3 changed files with 15 additions and 6 deletions

View File

@@ -499,6 +499,10 @@ class PackageLoader
throw new RegistryException('Package name must not be empty when no package context is available for BeforeStage attribute.');
}
$package_name = $method_instance->package_name === '' ? $pkg->getName() : $method_instance->package_name;
if ($instance_class instanceof Package && isset(self::$packages[$package_name])) {
$instance_class = self::$packages[$package_name];
}
$conditionals = array_map(
fn (\ReflectionAttribute $a) => $a->newInstance()->class,
[...$method->getDeclaringClass()->getAttributes(ConditionalOn::class), ...$method->getAttributes(ConditionalOn::class)],
@@ -529,6 +533,11 @@ class PackageLoader
throw new RegistryException('Package name must not be empty when no package context is available for AfterStage attribute.');
}
$package_name = $method_instance->package_name === '' ? $pkg->getName() : $method_instance->package_name;
if ($instance_class instanceof Package && isset(self::$packages[$package_name])) {
$instance_class = self::$packages[$package_name];
}
$conditionals = array_map(
fn (\ReflectionAttribute $a) => $a->newInstance()->class,
[...$method->getDeclaringClass()->getAttributes(ConditionalOn::class), ...$method->getAttributes(ConditionalOn::class)],