Skip to content

Commit

Permalink
qa: remove some unnecessary codepaths and add some more types
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Bösing <[email protected]>
  • Loading branch information
boesing committed Feb 23, 2023
1 parent 94809b2 commit 04edafb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
6 changes: 0 additions & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@
</MissingClosureReturnType>
<MissingReturnType>
<code>addAbstractFactory</code>
<code>addDelegator</code>
<code>addInitializer</code>
<code>mapLazyService</code>
<code>setInvokableClass</code>
</MissingReturnType>
<MixedArgument>
Expand Down Expand Up @@ -110,10 +108,6 @@
<code>$name</code>
<code>$name</code>
</ParamNameMismatch>
<TypeDoesNotContainType>
<code>$sharedAlias</code>
<code>$sharedAlias</code>
</TypeDoesNotContainType>
</file>
<file src="src/Test/CommonPluginManagerTrait.php">
<ArgumentTypeCoercion>
Expand Down
21 changes: 7 additions & 14 deletions src/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,6 @@ public function get($name)
// Cache the object for later, if it is supposed to be shared.
if ($sharedService) {
$this->services[$resolvedName] = $service;
}

// Also cache under the alias name; this allows sharing based on the
// service name used.
if ($sharedAlias) {
$this->services[$name] = $service;
}

Expand Down Expand Up @@ -411,7 +406,7 @@ public function setFactory(string $name, string|callable|Factory\FactoryInterfac
* @param null|string $class Class to which to map; if not provided, $name
* will be used for the mapping.
*/
public function mapLazyService(string $name, ?string $class = null)
public function mapLazyService(string $name, ?string $class = null): void
{
$this->configure(['lazy_services' => ['class_map' => [$name => $class ?: $name]]]);
}
Expand All @@ -434,10 +429,12 @@ public function addAbstractFactory($factory)
* @param string $name Service name
* @param string|callable|DelegatorFactoryInterface $factory Delegator
* factory to assign.
*
* @psalm-param class-string<Factory\DelegatorFactoryInterface>
* |callable(ContainerInterface,string,callable,array<mixed>|null) $factory
* |DelegatorCallableType
* |Factory\DelegatorFactoryInterface $factory
*/
public function addDelegator($name, $factory)
public function addDelegator(string $name, string|callable|Factory\DelegatorFactoryInterface $factory): void
{
$this->configure(['delegators' => [$name => [$factory]]]);
}
Expand All @@ -447,10 +444,10 @@ public function addDelegator($name, $factory)
*
* @param string|callable|Initializer\InitializerInterface $initializer
* @psalm-param class-string<Initializer\InitializerInterface>
* |callable(ContainerInterface,mixed):void
* |InitializerCallableType
* |Initializer\InitializerInterface $initializer
*/
public function addInitializer($initializer)
public function addInitializer(string|callable|Initializer\InitializerInterface $initializer)
{
$this->configure(['initializers' => [$initializer]]);
}
Expand Down Expand Up @@ -959,10 +956,6 @@ private function assertCallableDelegatorFactory(mixed $delegatorFactory): void
*/
private function resolveDelegatorFactory(mixed $delegatorFactory): callable|DelegatorFactoryInterface
{
if ($delegatorFactory instanceof DelegatorFactoryInterface) {
return $delegatorFactory;
}

if ($delegatorFactory === LazyServiceFactory::class) {
return $this->createLazyServiceDelegatorFactory();
}
Expand Down

0 comments on commit 04edafb

Please sign in to comment.