在laravel容器中所提到的resolved是什么意思.



 /**
 * An array of the types that have been resolved.
 *
 * @var array
 */
protected $resolved = array();

在阅读laravel源码的时候看到的.
位于Illuminate\Container\Container.

请问这个resolved是用来标记对应类型名是否已被解析过吗?

resolved在有道词典中的翻译.
adj. 下定决心的;已解决的;断然的
v. 解决;决定;分解;转变(resolve的过去分词)

laravel 英语 php

saya、 9 years, 9 months ago

请问这个resolved是用来标记对应类型名是否已被解析过吗?

是啊.

你跟踪下这个变量.


 public function make($abstract, $parameters = array())
{
    $abstract = $this->getAlias($abstract);

    $this->resolved[$abstract] = true;

貌似这里就是这个变量在整个框架唯一出现的地方了....

就是一个计数器,没了.

View::make(...) , App::make('foo')

$resolved = array('view'=>true,'foo'=>true);

估计为了方便debug而存在的?

POONHK answered 9 years, 9 months ago

Your Answer