ZM\Container\Container
getParent
public function getParent(): ZM\Container\ContainerInterface
描述
获取父容器
返回
| 类型 |
描述 |
| ZM\Container\ContainerInterface |
|
has
public function has(string $id): bool
描述
Returns true if the container can return an entry for the given identifier.
Returns false otherwise.
has($id) returning true does not mean that get($id) will not throw an exception.
It does however mean that get($id) will not throw a NotFoundExceptionInterface.
参数
| 名称 |
类型 |
描述 |
| id |
string |
identifier of the entry to look for |
返回
make
public function make(class-string<T> $abstract, array $parameters): Closure|mixed|T
描述
获取一个绑定的实例
参数
| 名称 |
类型 |
描述 |
| abstract |
class-string |
类或接口名 |
| parameters |
array |
参数 |
返回
getInstance
public function getInstance(): static
描述
获取类实例
返回
bound
public function bound(string $abstract): bool
描述
判断对应的类或接口是否已经注册
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
返回
getAlias
public function getAlias(string $abstract): string
描述
获取类别名(如存在)
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
返回
| 类型 |
描述 |
| string |
别名,不存在时返回传入的类或接口名 |
alias
public function alias(string $abstract, string $alias): void
描述
注册一个类别名
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
| alias |
string |
别名 |
返回
bind
public function bind(string $abstract, null|Closure|string $concrete, bool $shared): void
描述
注册绑定
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
| concrete |
null |
Closure |
| shared |
bool |
是否共享 |
返回
bindIf
public function bindIf(string $abstract, null|Closure|string $concrete, bool $shared): void
描述
注册绑定
在已经绑定时不会重复注册
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
| concrete |
null |
Closure |
| shared |
bool |
是否共享 |
返回
singleton
public function singleton(string $abstract, null|Closure|string $concrete): void
描述
注册一个单例绑定
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
| concrete |
null |
Closure |
返回
singletonIf
public function singletonIf(string $abstract, null|Closure|string $concrete): void
描述
注册一个单例绑定
在已经绑定时不会重复注册
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
| concrete |
null |
Closure |
返回
instance
public function instance(string $abstract, mixed $instance): mixed
描述
注册一个已有的实例,效果等同于单例绑定
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
| instance |
mixed |
实例 |
返回
factory
public function factory(string $abstract): Closure
描述
获取一个解析对应类实例的闭包
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
返回
flush
public function flush(): void
描述
清除所有绑定和实例
返回
traitMake
public function traitMake(class-string<T> $abstract, array $parameters): Closure|mixed|T
描述
获取一个绑定的实例
参数
| 名称 |
类型 |
描述 |
| abstract |
class-string |
类或接口名 |
| parameters |
array |
参数 |
返回
build
public function build(Closure|string $concrete): mixed
描述
实例化具体的类实例
参数
| 名称 |
类型 |
描述 |
| concrete |
Closure |
string |
返回
call
public function call(callable|string $callback, array $parameters, null|string $default_method): mixed
描述
调用对应的方法,并自动注入依赖
参数
| 名称 |
类型 |
描述 |
| callback |
callable |
string |
| parameters |
array |
参数 |
| default_method |
null |
string |
返回
get
public function get(string $id): mixed
描述
Finds an entry of the container by its identifier and returns it.
参数
| 名称 |
类型 |
描述 |
| id |
string |
identifier of the entry to look for * |
返回
extend
public function extend(string $abstract, Closure $closure): void
描述
扩展一个类或接口
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
| closure |
Closure |
扩展闭包 |
返回
getLogPrefix
public function getLogPrefix(): string
描述
获取日志前缀
返回
setLogPrefix
public function setLogPrefix(string $prefix): void
描述
设置日志前缀
参数
返回
getExtenders
public function getExtenders(string $abstract): Closure[]
描述
获取对应类型的所有扩展器
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
返回
isAlias
public function isAlias(string $name): bool
描述
判断传入的是否为别名
参数
返回
dropStaleInstances
public function dropStaleInstances(string $abstract): void
描述
抛弃所有过时的实例和别名
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
返回
getClosure
public function getClosure(string $abstract, string $concrete): Closure
描述
获取一个解析对应类的闭包
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
| concrete |
string |
实际类名 |
返回
getLastParameterOverride
public function getLastParameterOverride(): array
描述
获取最后一次的覆盖参数
返回
notInstantiable
public function notInstantiable(string $concrete, string $reason): void
描述
抛出实例化异常
参数
| 名称 |
类型 |
描述 |
| concrete |
string |
|
| reason |
string |
|
返回
resolveDependencies
public function resolveDependencies(ReflectionParameter[] $dependencies): array
描述
解析依赖
参数
| 名称 |
类型 |
描述 |
| dependencies |
ReflectionParameter[] |
|
返回
hasParameterOverride
public function hasParameterOverride(ReflectionParameter $parameter): bool
描述
判断传入的参数是否存在覆盖参数
参数
| 名称 |
类型 |
描述 |
| parameter |
ReflectionParameter |
|
返回
getParameterOverride
public function getParameterOverride(ReflectionParameter $parameter): mixed
描述
获取覆盖参数
参数
| 名称 |
类型 |
描述 |
| parameter |
ReflectionParameter |
|
返回
hasParameterTypeOverride
public function hasParameterTypeOverride(ReflectionParameter $parameter): bool
描述
判断传入的参数是否存在临时注入的参数
参数
| 名称 |
类型 |
描述 |
| parameter |
ReflectionParameter |
|
返回
getParameterTypeOverride
public function getParameterTypeOverride(ReflectionParameter $parameter): mixed
描述
获取临时注入的参数
参数
| 名称 |
类型 |
描述 |
| parameter |
ReflectionParameter |
|
返回
resolvePrimitive
public function resolvePrimitive(ReflectionParameter $parameter): mixed
描述
解析基本类型
参数
| 名称 |
类型 |
描述 |
| parameter |
ReflectionParameter |
|
返回
resolveClass
public function resolveClass(ReflectionParameter $parameter): mixed
描述
解析类
参数
| 名称 |
类型 |
描述 |
| parameter |
ReflectionParameter |
|
返回
getConcrete
public function getConcrete(string $abstract): Closure|string
描述
获取类名的实际类型
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
返回
isBuildable
public function isBuildable(mixed $concrete, string $abstract): bool
描述
判断传入的实际类型是否可以构造
参数
| 名称 |
类型 |
描述 |
| concrete |
mixed |
实际类型 |
| abstract |
string |
类或接口名 |
返回
isShared
public function isShared(string $abstract): bool
描述
判断传入的类型是否为共享实例
参数
| 名称 |
类型 |
描述 |
| abstract |
string |
类或接口名 |
返回
shouldLog
public function shouldLog(): bool
描述
判断是否输出日志
返回
log
public function log(string $message): void
描述
记录日志(自动附加容器日志前缀)
参数
返回