mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-18 05:04:51 +08:00
add container generics type hint
This commit is contained in:
parent
9f7ebceeb9
commit
90290bee94
@ -13,12 +13,9 @@ class Container extends WorkerContainer
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $parent 父容器
|
||||
*/
|
||||
public function __construct(ContainerInterface $parent)
|
||||
public function __construct()
|
||||
{
|
||||
$this->parent = $parent;
|
||||
$this->parent = WorkerContainer::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,10 +43,11 @@ class Container extends WorkerContainer
|
||||
/**
|
||||
* 获取一个绑定的实例
|
||||
*
|
||||
* @template T
|
||||
* @param string $abstract 类或接口名
|
||||
* @param array $parameters 参数
|
||||
* @throws EntryResolutionException
|
||||
* @return mixed 实例
|
||||
* @return T 实例
|
||||
*/
|
||||
public function make(string $abstract, array $parameters = [])
|
||||
{
|
||||
|
||||
@ -91,9 +91,10 @@ interface ContainerInterface extends PsrContainerInterface
|
||||
/**
|
||||
* 获取一个绑定的实例
|
||||
*
|
||||
* @template T
|
||||
* @param string $abstract 类或接口名
|
||||
* @param array $parameters 参数
|
||||
* @return mixed 实例
|
||||
* @return T 实例
|
||||
*/
|
||||
public function make(string $abstract, array $parameters = []);
|
||||
|
||||
|
||||
@ -210,10 +210,11 @@ class WorkerContainer implements ContainerInterface
|
||||
/**
|
||||
* 获取一个绑定的实例
|
||||
*
|
||||
* @template T
|
||||
* @param string $abstract 类或接口名
|
||||
* @param array $parameters 参数
|
||||
* @throws EntryResolutionException
|
||||
* @return mixed 实例
|
||||
* @return T 实例
|
||||
*/
|
||||
public function make(string $abstract, array $parameters = [])
|
||||
{
|
||||
|
||||
@ -655,7 +655,9 @@ function container(): ContainerInterface
|
||||
/**
|
||||
* 解析类实例(使用容器)
|
||||
*
|
||||
* @return mixed
|
||||
* @template T
|
||||
* @param string<T> $abstract
|
||||
* @return T
|
||||
*/
|
||||
function resolve(string $abstract, array $parameters = [])
|
||||
{
|
||||
@ -665,8 +667,9 @@ function resolve(string $abstract, array $parameters = [])
|
||||
/**
|
||||
* 获取容器实例
|
||||
*
|
||||
* @param null|string $abstract 类或接口名,不传入则返回容器实例
|
||||
* @return ContainerInterface|mixed
|
||||
* @template T
|
||||
* @param null|string<T> $abstract
|
||||
* @return ContainerInterface|T
|
||||
*/
|
||||
function app(string $abstract = null, array $parameters = [])
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user