nette / routing

Nette Routing: two-ways URL conversion
https://doc.nette.org/routing
Other
231 stars 3 forks source link

SimpleRouter: fix compatiblity with non-stringable (e.g. Closure) default parameter values #9

Closed xificurk closed 3 years ago

xificurk commented 3 years ago

The bug was intoroduced in d989c52fa70708816253f2adab7f57ba039a4b4f. SimpleRouter should support non-stringable (e.g. Closure instance) default parameter values - a typical use case is Nette:Micro presenter.

dg commented 3 years ago

I changed it that this will work since PHP 8, because == behaves too loosely in < 8.

xificurk commented 3 years ago

@dg Does this mean you do not intend to support routing of requests to MicroPresenter using SimpleRouter on PHP < 8?

I am not sure we understood each other. This use-case was originally supported, but it was broken by changes in d989c52. The problem is that MicroPresenter requires closure callback parameter, so the parameter value is non-stringable object and URL construction crashes on this if you try to use SimpleRouter.

dg commented 3 years ago

I get it now.

dg commented 3 years ago

No. I still don't get it :-)

Can you give me a realworld example where constructUrl() is called and the parameter is closure?

xificurk commented 3 years ago

The original context for this PR is in this thread: https://pehapkari.slack.com/archives/C2R30BLKA/p1607199796381500

Here is example on top of current sandbox: https://github.com/xificurk/sandbox/tree/simplerouter-bug-example error

dg commented 3 years ago

Thanks