diff --git a/CHANGELOG.md b/CHANGELOG.md index f618a4e..a4648c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* Added interface Archetype dereferencing + ## v0.1.4 (2023-11-27) * Improved type resolution stack ordering diff --git a/src/Slingshot.php b/src/Slingshot.php index f106d4f..c97f7eb 100644 --- a/src/Slingshot.php +++ b/src/Slingshot.php @@ -10,7 +10,6 @@ namespace DecodeLabs; use Closure; -use DecodeLAbs\Dovetail; use DecodeLabs\Pandora\Container as PandoraContainer; use Psr\Container\ContainerInterface as Container; use ReflectionClass; @@ -580,9 +579,13 @@ public function newInstance( array $parameters = [] ): object { if (!class_exists($class)) { - throw Exceptional::Logic( - 'Class ' . $class . ' does not exist' - ); + if (!interface_exists($class)) { + throw Exceptional::Logic( + 'Class ' . $class . ' does not exist' + ); + } + + $class = Archetype::resolve($class); } $ref = new ReflectionClass($class);