每天laravel-20160813| Container -16

php中文网
发布: 2016-06-23 13:05:11
原创
1097人浏览过

   /**    * get the contextual concrete binding for the given abstract.    *    * @param  string  $abstract    * @return string|null    */   protected function getcontextualconcrete($abstract)   {       if (isset($this->contextual[end($this->buildstack)][$abstract])) {           return $this->contextual[end($this->buildstack)][$abstract];       }   }//has it then return it,// this array is too complex   /**    * normalize the given class name by removing leading slashes.    *    * @param  mixed  $service    * @return mixed    */   protected function normalize($service)   {       return is_string($service) ? ltrim($service, '\') : $service;// back the normal string like namespace   }// normalize the given class name by removing leading slashes   /**    * get the extender callbacks for a given type.    *    * @param  string  $abstract    * @return array    */   protected function getextenders($abstract)   {       if (isset($this->extenders[$abstract])) {// has then return           return $this->extenders[$abstract];       }       return [];   }// get the extender callbacks for a given type.   /**    * instantiate a concrete instance of the given type.    *    * @param  string  $concrete    * @param  array   $parameters    * @return mixed    *    * @throws illuminatecontractscontainerindingresolutionexception    */// make a concrete instance of the given type live.   public function build($concrete, array $parameters = [])// like to make a floor   {       // if the concrete type is actually a closure, we will just execute it and       // hand back the results of the functions, which allows functions to be       // used as resolvers for more fine-tuned resolution of these objects.       if ($concrete instanceof closure) {           return $concrete($this, $parameters);       }// if it a concrete as closure.       $reflector = new reflectionclass($concrete);// else throw the concrete function to get the class name       // if the type is not instantiable, the developer is attempting to resolve       // an abstract type such as an interface of abstract class and there is       // no binding registered for the abstractions so we need to bail out.       if (! $reflector->isinstantiable()) {// if it a abstract class so can not be instance           if (! empty($this->buildstack)) {// if has the buildstack               $previous = implode(', ', $this->buildstack);//implode the buildstack               $message = "target [$concrete] is not instantiable while building [$previous].";// it is a trace           } else {               $message = "target [$concrete] is not instantiable.";           }           throw new bindingresolutionexception($message);// throw a exception       }       $this->buildstack[] = $concrete;// add the concrete to the concrete       $constructor = $reflector->getconstructor();// get the constructor       // if there are no constructors, that means there are no dependencies then       // we can just resolve the instances of the objects right away, without       // resolving any other types or dependencies out of these containers.       if (is_null($constructor)) {           array_pop($this->buildstack);// if no has the array_pop  delete the concrete           return new $concrete;// return new concrete       }       $dependencies = $constructor->getparameters();//get parameters       // once we have all the constructor's parameters we can create each of the       // dependency instances and then use the reflection instances to make a       // new instance of this class, injecting the created dependencies in.       $parameters = $this->keyparametersbyargument(           $dependencies, $parameters       );// get       $instances = $this->getdependencies(           $dependencies, $parameters       );       array_pop($this->buildstack);       return $reflector->newinstanceargs($instances);   }// build function is so powerful, can use a instance and a parameters to new a new instance.
登录后复制


天工
天工

昆仑万维推出的通用AI智能体平台,原天工AI

天工 212
查看详情 天工
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号