Skip to content

Commit

Permalink
Add @template return types
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin D'Arcy committed Sep 1, 2021
1 parent 18345ed commit 7501607
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ public function __construct(
/**
* Returns an entry of the container by its name.
*
* @param string $name Entry name or a class name.
* @template T
* @param string|class-string<T> $name Entry name or a class name.
*
* @throws DependencyException Error while resolving the entry.
* @throws NotFoundException No entry found for the given name.
* @return mixed
* @return mixed|T
*/
public function get($name)
{
Expand Down Expand Up @@ -165,15 +166,16 @@ private function getDefinition($name)
*
* This method makes the container behave like a factory.
*
* @param string $name Entry name or a class name.
* @param array $parameters Optional parameters to use to build the entry. Use this to force specific parameters
* to specific values. Parameters not defined in this array will be resolved using
* the container.
* @template T
* @param string|class-string<T> $name Entry name or a class name.
* @param array $parameters Optional parameters to use to build the entry. Use this to force
* specific parameters to specific values. Parameters not defined in this
* array will be resolved using the container.
*
* @throws InvalidArgumentException The name parameter must be of type string.
* @throws DependencyException Error while resolving the entry.
* @throws NotFoundException No entry found for the given name.
* @return mixed
* @return mixed|T
*/
public function make($name, array $parameters = [])
{
Expand Down Expand Up @@ -229,10 +231,11 @@ public function has($name)
/**
* Inject all dependencies on an existing instance.
*
* @param object $instance Object to perform injection upon
* @template T
* @param object|T $instance Object to perform injection upon
* @throws InvalidArgumentException
* @throws DependencyException Error while injecting dependencies
* @return object $instance Returns the same instance
* @return object|T $instance Returns the same instance
*/
public function injectOn($instance)
{
Expand Down

0 comments on commit 7501607

Please sign in to comment.