Skip to content

Commit

Permalink
Fix options not passed to created instance
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoelker committed Nov 1, 2023
1 parent 367dfa6 commit 8edc418
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/AbstractPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,16 @@ public function setService($name, $service)
}

/**
* @param class-string<InstanceType>|string $name Service name of plugin to retrieve.
* @return mixed
* @psalm-return ($name is class-string<InstanceType> ? InstanceType : mixed)
* @param class-string<InstanceType>|string $id Service name of plugin to retrieve.
* @param null|array<mixed> $options Options to use when creating the instance.
* @psalm-return ($id is class-string<InstanceType> ? 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)) {
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8edc418

Please sign in to comment.