简体   繁体   中英

How is method call passed from `Routes` to `RoutesCollection`?

I am trying to understand how Laravel gets all fresh application routes at this line :

$this->getFreshApplication()['router']->getRoutes()

When I dump $this->getFreshApplication()['router'] then I find an instance of Illuminate/Routing/Route :

在此处输入图像描述

This instance (and its traits) have no method getRoutes . This is a method from Illuminate/Routing/RouteCollection .

Why does the method call getRoutes() on the Route instance endup on RouteCollection ? I also checked the magic method __get() from Route but it is not evoked when calling getRoutes() .

I think the correct type you get for $this->getFreshApplication()['router'] is Illuminate\Routing\Router instead of a Illuminate/Routing/Route instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM