-
-
Notifications
You must be signed in to change notification settings - Fork 90
Callable stops execution of router #116
Comments
Well, actually this isn't a bug. The constructor of |
I agree it cannot be prevented, this is why I propose a workaround that will work with non-static methods without side effects |
Handling class construction isn't a Siler concern, at least for now, you should look for something like Pimple. Yet you could just wrap it in a Closure: Route\get('user', function () {
$c = new TestController();
return $c->page();
}); |
@leocavalcante this is actually a problem as the documentation says the router can use any callable. In this case it is a problem as it causes code execution that the user will be unaware of. I agree its not a problem with Siler per se, but this is the way this particular callable works. If Siler decides not to address this, this is fine, but the documentation needs to be updated to caveat this case. I believe other routers have recognized this as a problem and have come up with a solution: Example at: |
3 similar comments
@leocavalcante this is actually a problem as the documentation says the router can use any callable. In this case it is a problem as it causes code execution that the user will be unaware of. I agree its not a problem with Siler per se, but this is the way this particular callable works. If Siler decides not to address this, this is fine, but the documentation needs to be updated to caveat this case. I believe other routers have recognized this as a problem and have come up with a solution: Example at: |
@leocavalcante this is actually a problem as the documentation says the router can use any callable. In this case it is a problem as it causes code execution that the user will be unaware of. I agree its not a problem with Siler per se, but this is the way this particular callable works. If Siler decides not to address this, this is fine, but the documentation needs to be updated to caveat this case. I believe other routers have recognized this as a problem and have come up with a solution: Example at: |
@leocavalcante this is actually a problem as the documentation says the router can use any callable. In this case it is a problem as it causes code execution that the user will be unaware of. I agree its not a problem with Siler per se, but this is the way this particular callable works. If Siler decides not to address this, this is fine, but the documentation needs to be updated to caveat this case. I believe other routers have recognized this as a problem and have come up with a solution: Example at: |
Sorry for reposting so many times. Github was showing 500 page and unable to post message. |
NP, I got some buggy behavior from Github too. |
Calling a non-static method using the default callable implementation always causes the constructors to be called, which is undesirable. See in the example below even if you call the / route, the execution will be stopped as the constructor in test will be called.
I would suggest a workaround for calling non-static methods
Route\get('/user', "TestController@page");
The text was updated successfully, but these errors were encountered: