Skip to content

Commit

Permalink
improve IDE type-hinting
Browse files Browse the repository at this point in the history
  • Loading branch information
klimov-paul committed Aug 30, 2023
1 parent ed5663d commit f1e4c9f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/DI.php
Expand Up @@ -108,8 +108,10 @@ public static function injector(): InjectorContract
/**
* Finds an entry of the decorated container by its identifier and returns it.
*
* @param string $id identifier of the entry to look for.
* @return mixed entry.
* @template T
*
* @param string|class-string<T> $id identifier of the entry to look for.
* @return mixed|T entry.
* @throws \Psr\Container\ContainerExceptionInterface no entry was found for **this** identifier.
* @throws \Psr\Container\NotFoundExceptionInterface error while retrieving the entry.
*/
Expand All @@ -133,9 +135,11 @@ public static function has(string $id): bool
/**
* Invoke a callback with resolving dependencies based on parameter types.
*
* @param callable $callable callable to be invoked.
* @template T
*
* @param (callable():T) $callable callable to be invoked.
* @param array $arguments list of function arguments.
* @return mixed invocation result.
* @return mixed|T invocation result.
*/
public static function invoke(callable $callable, array $arguments = [])
{
Expand All @@ -145,9 +149,11 @@ public static function invoke(callable $callable, array $arguments = [])
/**
* Creates an object of a given class with resolving constructor dependencies based on parameter types.
*
* @param string $class class name.
* @template T
*
* @param string|class-string<T> $class class name.
* @param array $arguments list of constructor arguments.
* @return mixed created class instance.
* @return mixed|T created class instance.
*/
public static function make(string $class, array $arguments = [])
{
Expand All @@ -158,9 +164,11 @@ public static function make(string $class, array $arguments = [])
* Creates an object from the Yii-style configuration with resolving constructor dependencies based on parameter types.
* @see \YiiBase::createComponent()
*
* @param array|string $config the configuration. It can be either a string or an array.
* @template T
*
* @param array|string|class-string<T> $config the configuration. It can be either a string or an array.
* @param array $arguments list of constructor arguments.
* @return mixed the created object.
* @return mixed|T the created object.
* @throws \CException on invalid configuration.
*/
public static function create($config, array $arguments = [])
Expand Down

0 comments on commit f1e4c9f

Please sign in to comment.