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