/** * 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
每天laravel-20160817| Container -20
原创
©著作权归作者所有:来自51CTO博客作者lijingsan1的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
每天laravel-20160815| Container -18
/** *
sed scala -
每天laravel-20160819| Container -22
/** * Get the alias for an abstract if available. * * @param 
abstract function available