Can a constructor in a class in a laravel be passed in automatically by the new one?

Source: Internet
Author: User
This is LaravelIn Auth\Guard's constructor:

    /**     * Create a new authentication guard.     *     * @param  \Illuminate\Auth\UserProviderInterface  $provider     * @param  \Illuminate\Session\Store  $session     * @param  \Symfony\Component\HttpFoundation\Request  $request     * @return void     */    public function __construct(UserProviderInterface $provider,                                SessionStore $session,                                Request $request = null)    {        $this->session = $session;        $this->request = $request;        $this->provider = $provider;    }

Where parameters are passed inSessionStore $session
However session , the constructor is this:

public function __construct($name, SessionHandlerInterface $handler, $id = null)    {        $this->setId($id);        $this->name = $name;        $this->handler = $handler;        $this->metaBag = new MetadataBag;    }

Here is the parameter, why Guard the constructor can be generated automatically session ?
Was it provided by the php native or was it Laravel provided?

Reply content:

This is Laravel the Auth\Guard constructor in:

    /**     * Create a new authentication guard.     *     * @param  \Illuminate\Auth\UserProviderInterface  $provider     * @param  \Illuminate\Session\Store  $session     * @param  \Symfony\Component\HttpFoundation\Request  $request     * @return void     */    public function __construct(UserProviderInterface $provider,                                SessionStore $session,                                Request $request = null)    {        $this->session = $session;        $this->request = $request;        $this->provider = $provider;    }

Where parameters are passed inSessionStore $session
However session , the constructor is this:

public function __construct($name, SessionHandlerInterface $handler, $id = null)    {        $this->setId($id);        $this->name = $name;        $this->handler = $handler;        $this->metaBag = new MetadataBag;    }

Here is the parameter, why Guard the constructor can be generated automatically session ?
Was it provided by the php native or was it Laravel provided?

Https://github.com/laravel/framework/blob/4.2/src/Illuminate/Auth/AuthManager.php#L51

/** * Create an instance of the Eloquent driver. * * @return \Illuminate\Auth\Guard */public function createEloquentDriver(){    $provider = $this->createEloquentProvider();    return new Guard($provider, $this->app['session.store']);}
  • 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.