容器類 Container
Illuminate\Container\Container
說明Container
實現契約 ContainerContract
,並且實現了 ArrayAccess
使得容器物件能夠以陣列方式訪問。
相關文章
PHP 預定義介面 ArrayAccess
容器契約 ContainerContract
速查
<?php
namespace Illuminate\Container;
class Container implements ArrayAccess, ContainerContract
{
//當前全域性可用的容器(如果有的話)--這裡是指容器本身例項物件$this
protected static $instance;
//已解析的型別的陣列
protected $resolved = [];
//容器的繫結
protected $bindings = [];
//容器的方法繫結
protected $methodBindings = [];
//容器的共享例項 ['app'=>(obj例項)]
protected $instances = [];
//註冊的型別別名
protected $aliases = [];
//以抽象名稱為鍵的已註冊別名
protected $abstractAliases = [];
//服務的擴充套件閉包
protected $extenders = [];
//所有註冊的標籤
protected $tags = [];
//正在建造的混凝土(具體實現類)堆疊
protected $buildStack = [];
//引數覆蓋堆疊
protected $with = [];
//上下文繫結對映
public $contextual = [];
//所有已註冊的反彈回撥
protected $reboundCallbacks = [];
//所有全域性解析回撥
protected $globalResolvingCallbacks = [];
//解析回撥後的所有全域性變數
protected $globalAfterResolvingCallbacks = [];
//根據類的型別解析的所有回撥
protected $resolvingCallbacks = [];
//根據類型別解析後的所有回撥
protected $afterResolvingCallbacks = [];
//----------------實現 ContainerContract 的方法----------------
//在容器中註冊一個共享的現有例項
public function instance($abstract, $instance){};
//定義上下文繫結
public function when($concrete){};
//如果繫結尚未註冊,則註冊它
public function bindIf($abstract, $concrete = null, $shared = false){};
//向容器註冊繫結
public function bind($abstract, $concrete = null, $shared = false){};
//在容器中註冊一個共享繫結 singleton(x,y)=bind(x,y,true)
public function singleton($abstract, $concrete = null){};
//“擴充套件”容器中的抽象型別
public function extend($abstract, Closure $closure){};
//呼叫給定的 閉包/class@method 並且注入它的依賴
public function call($callback, array $parameters = [], $defaultMethod = null){};
//獲取一個閉包來從容器中解析給定的型別
public function factory($abstract){};
//從容器中解析給定型別
public function make($abstract, array $parameters = []){};
//註冊一個新的解析回撥
public function resolving($abstract, Closure $callback = null){};
//在解析回撥之後註冊一個新的
public function afterResolving($abstract, Closure $callback = null){};
//將一組標記分配給給定的繫結
public function tag($abstracts, $tags){};
//解析給定標記的所有繫結
public function tagged($tag){};
//將型別別名化為另一個名稱
public function alias($abstract, $alias){};
//確定給定的抽象型別是否已被繫結
public function bound($abstract){};
//確定給定的抽象型別是否已解析
public function resolved($abstract){};
//----------------其他方法----------------
//包裝給定的閉包,以便在執行時注入其依賴項
public function wrap(Closure $callback, array $parameters = []){};
//make()的別名函式名
public function makeWith($abstract, array $parameters = []){};
//確定給定的具體類是否可構建
protected function isBuildable($concrete, $abstract){};
//例項化給定型別的具體例項
public function build($concrete){};
//設定?容器的全域性可用例項
public static function getInstance(){};
//設定容器的共享例項
public static function setInstance(ContainerContract $container = null){};
//丟擲一個具體例項化不了的異常
protected function notInstantiable($concrete){};
//從例項快取中刪除已解析的例項
public function forgetInstance($abstract){};
//從容器中清除所有例項
public function forgetInstances(){};
//獲取給定型別的extender回撥
protected function getExtenders($abstract){};
//獲得在構建型別時使用的閉包
protected function getClosure($abstract, $concrete){};
//獲取給定抽象的具體型別
protected function getConcrete($abstract){};
//獲取容器的繫結
public function getBindings(){};
//刪除給定型別的所有extender回撥
public function forgetExtenders($abstract){};
//將新的回撥繫結到抽象的重新繫結事件
public function rebinding($abstract, Closure $callback){};
//從容器中解析給定型別
protected function resolve($abstract, $parameters = []){};
//解析一個非類暗示的原始依賴項。Primitive(原始)
protected function resolvePrimitive(ReflectionParameter $parameter){};
//從容器中解析基於類的依賴項
protected function resolveClass(ReflectionParameter $parameter){};
//為無法解析的原語丟擲異常
protected function unresolvablePrimitive(ReflectionParameter $parameter){};
//確定是否共享給定的型別
public function isShared($abstract){};
//確定給定字串是否為別名
public function isAlias($name){};
//獲取抽象的別名(如果可用)
public function getAlias($abstract){};
//確定容器是否具有方法繫結
public function hasMethodBinding($method){};
//繫結回撥來解析 Container::call
public function bindMethod($method, $callback){};
//獲取給定方法的方法繫結
public function callMethodBinding($method, $instance){};
//在上下文繫結陣列中查詢給定抽象的具體繫結
protected function findInContextualBindings($abstract){};
//獲取給定抽象的上下文具體繫結
protected function getContextualConcrete($abstract){};
//向容器中新增上下文繫結
public function addContextualBinding($concrete, $abstract, $implementation){};
//從上下文繫結別名快取中刪除別名
protected function removeAbstractAlias($searched){};
//刪除所有陳舊的例項和別名
protected function dropStaleInstances($abstract){};
//重新整理給定目標和方法上的例項
public function refresh($abstract, $target, $method){};
//重新整理所有繫結和已解析例項的容器
public function flush(){};
//從ReflectionParameters解析所有依賴項
protected function resolveDependencies(array $dependencies){};
//確定給定的依賴項是否有引數覆蓋
protected function hasParameterOverride($dependency){};
//獲取依賴項的引數覆蓋
protected function getParameterOverride($dependency){};
//獲取最後一個引數覆蓋
protected function getLastParameterOverride(){};
//為給定的抽象型別觸發“反彈”回撥
protected function rebound($abstract){};
//獲取給定型別的反彈回撥
protected function getReboundCallbacks($abstract){};
//發出所有解析回撥
protected function fireResolvingCallbacks($abstract, $object){};
//在解決回撥後觸發所有的回撥
protected function fireAfterResolvingCallbacks($abstract, $object){};
//獲取給定型別的所有回撥
protected function getCallbacksForType($abstract, $object, array $callbacksPerType){};
//使用一個物件觸發一個回撥陣列
protected function fireCallbackArray($object, array $callbacks){};
//----------------實現 ContainerInterface 的方法----------------
//如果容器可以返回給定識別符號的條目,則返回true.否則返回false
public function has($id){};
//根據容器的識別符號查詢容器的項並返回它
public function get($id){};
//----------------實現 ArrayAccess 的方法----------------
//確定給定偏移量是否存在
public function offsetExists($key){};
//獲取給定偏移量處的值
public function offsetGet($key){};
//將該值設定為給定的偏移量
public function offsetSet($key, $value){};
//取消設定給定偏移量的值
public function offsetUnset($key){};
//----------------魔術方法----------------
//動態訪問容器服務
public function __get($key){};
//動態設定容器服務
public function __set($key, $value){};
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結