What does the resolved mentioned in the laravel container mean.

Source: Internet
Author: User
{Code...} I saw it when reading laravel source code. It is located in IlluminateContainerContainer. Is this resolved used to mark whether the corresponding type name has been parsed? Translation of resolved in youdao dictionary ....
/** * An array of the types that have been resolved. * * @var array */protected $resolved = array();

Read the laravel source code.
Located in Illuminate \ Container.

Is this resolved used to mark whether the corresponding type name has been resolved?

Resolved translation in youdao dictionary.
Adj. Made up your mind; resolved; flatly
V. solution; decision; decomposition; Transformation (past word segmentation of resolve)

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

Read the laravel source code.
Located in Illuminate \ Container.

Is this resolved used to mark whether the corresponding type name has been resolved?

Resolved translation in youdao dictionary.
Adj. Made up your mind; resolved; flatly
V. solution; decision; decomposition; Transformation (past word segmentation of resolve)

Is this resolved used to mark whether the corresponding type name has been resolved?

Yes.

You tracked this variable.

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

It seems that this variable is the only place in the Framework ....

It's a counter, no more.

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

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

Is it estimated that there is a problem to facilitate debugging?

We know that there are a lot of Facade usage in Laravel, such as the router you wrote at the beginning, Router: get (). Do you know why you can write it like this? Router: get () is equivalent to $ app-> make ('router ')-> get (); $ app-> make ('router ') it is an image-like ioc container, $ app-> make () is the container, and 'router 'is the class (alias) that is put into resolution ), $ app-> make ('router ') can put an instance of the Route classAnalysis.

You may ask whyAnalysisWhat about it? What does parsing mean? Can I get an instance for the New class? First, if you bind a class to the Ioc container, it can automatically generate instances for you without the need to include or use new. Next, a new class cannot directly parse the class it depends on, especially the interface class. To use the new method, you must first create an instance with the new method, then input the dependent instance (meaning there are more new instances ).

For details, see Service Container (IOC Container)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.