From 8f7ffcb5c9006f28ddf8ab7aab253201a84c1370 Mon Sep 17 00:00:00 2001 From: Brent Roose Date: Thu, 30 May 2024 13:39:46 +0200 Subject: [PATCH] Dynamic initializer discovery --- src/Discovery/InitializerDiscovery.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Discovery/InitializerDiscovery.php b/src/Discovery/InitializerDiscovery.php index 17c8f99..b18cd86 100644 --- a/src/Discovery/InitializerDiscovery.php +++ b/src/Discovery/InitializerDiscovery.php @@ -6,6 +6,7 @@ use ReflectionClass; use Tempest\Container\Container; +use Tempest\Container\DynamicInitializer; use Tempest\Container\GenericContainer; use Tempest\Container\Initializer; @@ -20,9 +21,13 @@ public function __construct( public function discover(ReflectionClass $class): void { + if (! $class->isInstantiable()) { + return; + } + if ( - ! $class->isInstantiable() - || ! $class->implementsInterface(Initializer::class) + ! $class->implementsInterface(Initializer::class) + && ! $class->implementsInterface(DynamicInitializer::class) ) { return; }