Why the property instances array is assigned in the instances method.
$this->app have a value.
Reply content:
Why the property instances array is assigned in the instances method.
$this->app have a value.
Or the morning brain sober, Container class looked at once found $this->app.
The Container class implements the Arrayaccess interface, and an introduction to the Arrayaccess interface can refer to the official documentation
Many Moden PHP frameworks now use this stuff.
The Offsetget method in the Container class is called by default when accessing $this->app, and then Offsetget calls the Make method of the Container class to get the type instance from Container based on the type passed in. The method. See the code for the Make method
if (isset($this->instances[$abstract])) { return $this->instances[$abstract]; }
Instantly understand the source of $this->app ~