每天laravel-20160819| Container -22

php中文网
发布: 2016-06-23 13:03:35
原创
1053人浏览过

   /**    * get the alias for an abstract if available.    *    * @param  string  $abstract    * @return string    */   protected function getalias($abstract)   {// get alias ,if has aliases return it ,or return it self       return isset($this->aliases[$abstract]) ? $this->aliases[$abstract] : $abstract;   }// get the alias for an abstract if available.   /**    * get the container's bindings.    *    * @return array    */   public function getbindings()   {       return $this->bindings;// return it self like a big _get function   }   /**    * drop all of the stale instances and aliases.    *    * @param  string  $abstract    * @return void    */   protected function dropstaleinstances($abstract)   {       unset($this->instances[$abstract], $this->aliases[$abstract]);   }// drop every thing about the abstract ,// use the system function unset   /**    * remove a resolved instance from the instance cache.    *    * @param  string  $abstract    * @return void    */   public function forgetinstance($abstract)   {       unset($this->instances[$this->normalize($abstract)]);   }// in php ,drop and remove ,all about this use the unset  even forget   /**    * clear all of the instances from the container.    *    * @return void    */   public function forgetinstances()   {       $this->instances = [];   }// clear all drop remove forget ,this is better then unset(self)   /**    * flush the container of all bindings and resolved instances.    *    * @return void    */   public function flush()   {       $this->aliases = [];       $this->resolved = [];       $this->bindings = [];       $this->instances = [];   }// flush means to refresh it ,so like empty this alias resolved bindings instances   /**    * set the globally available instance of the container.    *    * @return static    */   public static function getinstance()   {       return static::$instance;// return the $instance not the self instance.   }   /**    * set the shared instance of the container.    *    * @param  \illuminate\contracts\container\container  $container    * @return void    */   public static function setinstance(containercontract $container)   {       static::$instance = $container;   }// set the instance use the container   /**    * determine if a given offset exists.    *    * @param  string  $key    * @return bool    */   public function offsetexists($key)   {       return isset($this->bindings[$this->normalize($key)]);   }// determine like check ,// if has the bindings been set return true   /**    * get the value at a given offset.    *    * @param  string  $key    * @return mixed    */   public function offsetget($key)   {       return $this->make($key);// make is too powerful   }// return it a   /**    * set the value at a given offset.    *    * @param  string  $key    * @param  mixed   $value    * @return void    */   public function offsetset($key, $value)   {       // if the value is not a closure, we will make it one. this simply gives       // more "drop-in" replacement functionality for the pimple which this       // container's simplest functions are base modeled and built after.       if (! $value instanceof closure) {           $value = function () use ($value) {               return $value;           };       }// if the value is a closure.       $this->bind($key, $value);// use bind function   }   /**    * unset the value at a given offset.    *    * @param  string  $key    * @return void    */   public function offsetunset($key)   {       $key = $this->normalize($key);       unset($this->bindings[$key], $this->instances[$key], $this->resolved[$key]);   }// unset all offset   /**    * dynamically access container services.    *    * @param  string  $key    * @return mixed    */   public function __get($key)   {       return $this[$key];// a big   }   /**    * dynamically set container services.    *    * @param  string  $key    * @param  mixed   $value    * @return void    */   public function __set($key, $value)   {       $this[$key] = $value; // big set   }
登录后复制


天工
天工

昆仑万维推出的通用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号