Skip to content

Commit

Permalink
Add generics
Browse files Browse the repository at this point in the history
Adds generics so `$container->get(Foo::class)` returns a `Foo` instance
  • Loading branch information
markhuot authored Nov 30, 2023
1 parent d43341a commit fca3d05
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions framework/di/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ class Container extends Component
* In this case, the constructor parameters and object configurations will be used
* only if the class is instantiated the first time.
*
* @param string|Instance $class the class Instance, name, or an alias name (e.g. `foo`) that was previously
* @template T
* @param class-string<T>|Instance $class the class Instance, name, or an alias name (e.g. `foo`) that was previously
* registered via [[set()]] or [[setSingleton()]].
* @param array $params a list of constructor parameter values. Use one of two definitions:
* - Parameters as name-value pairs, for example: `['posts' => PostRepository::class]`.
Expand All @@ -154,7 +155,7 @@ class Container extends Component
* parameter list.
* Dependencies indexed by name and by position in the same array are not allowed.
* @param array $config a list of name-value pairs that will be used to initialize the object properties.
* @return object an instance of the requested class.
* @return T an instance of the requested class.
* @throws InvalidConfigException if the class cannot be recognized or correspond to an invalid definition
* @throws NotInstantiableException If resolved to an abstract class or an interface (since 2.0.9)
*/
Expand Down

0 comments on commit fca3d05

Please sign in to comment.