diff --git a/src/AbstractPluginManager.php b/src/AbstractPluginManager.php index 9733981..f29d827 100644 --- a/src/AbstractPluginManager.php +++ b/src/AbstractPluginManager.php @@ -142,16 +142,16 @@ public function setService($name, $service) } /** - * @param class-string|string $name Service name of plugin to retrieve. - * @return mixed - * @psalm-return ($name is class-string ? InstanceType : mixed) + * @param class-string|string $id Service name of plugin to retrieve. + * @param null|array $options Options to use when creating the instance. + * @psalm-return ($id is class-string ? InstanceType : mixed) * @throws Exception\ServiceNotFoundException If the manager does not have * a service definition for the instance, and the service is not * auto-invokable. * @throws InvalidServiceException If the plugin created is invalid for the * plugin context. */ - public function get(string $id): mixed + public function get(string $id, ?array $options = null): mixed { if (! $this->has($id)) { if (! $this->autoAddInvokableClass || ! class_exists($id)) { @@ -165,7 +165,7 @@ public function get(string $id): mixed $this->setFactory($id, Factory\InvokableFactory::class); } - $instance = parent::get($id); + $instance = ! $options ? parent::get($id) : $this->build($id, $options); $this->validate($instance); return $instance; } diff --git a/src/ServiceManager.php b/src/ServiceManager.php index 4895108..0dbd080 100644 --- a/src/ServiceManager.php +++ b/src/ServiceManager.php @@ -288,7 +288,7 @@ public function build($name, ?array $options = null) /** * {@inheritDoc} * - * @param string|class-string $name + * @param string|class-string $id * @return bool */ public function has(string $id): bool