每天laravel-20160817| Container -20
2016-05-30 09:46
453 查看
/** * Register a new resolving callback by type of its first argument. * * @param \Closure $callback * @return void */ // Register a new resolving callback by type of its first argument protected function resolvingCallback(Closure $callback) { $abstract = $this->getFunctionHint($callback);// get the abstract function if ($abstract) {// if get the abstract function set in $this->resolvingCallbacks[$abstract][] = $callback;// one is abstract function } else { $this->globalResolvingCallbacks[] = $callback;// other set in the global Resolving Call backs } } /** * Register a new after resolving callback by type of its first argument. * * @param \Closure $callback * @return void */ protected function afterResolvingCallback(Closure $callback) { $abstract = $this->getFunctionHint($callback);// get the result if ($abstract) { $this->afterResolvingCallbacks[$abstract][] = $callback;// one is in the abstract } else { $this->globalAfterResolvingCallbacks[] = $callback; } } /** * Get the type hint for this closure's first argument. * * @param \Closure $callback * @return mixed */ // hint is type or a way protected function getFunctionHint(Closure $callback) { $function = new ReflectionFunction($callback);// get the new Reflection Function if ($function->getNumberOfParameters() == 0) { return; }// if $function $expected = $function->getParameters()[0]; if (! $expected->getClass()) {// getClass return; } return $expected->getClass()->name;// get the class name. } // sorry ,this too easy
相关文章推荐
- PHP双引号的隐患
- 浅析——SCTP协议(转)
- codeigniter 中使用 phpexcel
- [PHP源码阅读]array_pop和array_shift函数
- ThinkPHP+AJAX三级联动
- PHP异常类
- php str_getcsv把字符串解析为数组的使用方法
- yii2搭建完美后台并实现rbac权限控制案例--之左侧菜单子级无法高亮的问题
- php实现的一段简单概率相关代码
- php求圆周率的简单实现方法 原创
- Yii2中如何使用modal弹窗(基本使用)
- php while循环控制的简单实例
- PHP如何实现跨域
- PHP将页面中点击数量高的链接进行高亮显示的方法
- Yii2与Yii1的模块中Layout使用区别
- PHP - 日期时间的转换
- PHP - 获取音频长度
- Laravel 下 artisan 命令工具使用
- PHPexcel手册
- PHPexcel实列