{"action":"created","issue":{"url":"https://api.github.com/repos/leocavalcante/siler/issues/116","repository_url":"https://api.github.com/repos/leocavalcante/siler","labels_url":"https://api.github.com/repos/leocavalcante/siler/issues/116/labels{/name}","comments_url":"https://api.github.com/repos/leocavalcante/siler/issues/116/comments","events_url":"https://api.github.com/repos/leocavalcante/siler/issues/116/events","html_url":"https://github.com/leocavalcante/siler/issues/116","id":372293664,"node_id":"MDU6SXNzdWUzNzIyOTM2NjQ=","number":116,"title":"Callable stops execution of router","user":{"login":"Sinevia","id":3450815,"node_id":"MDQ6VXNlcjM0NTA4MTU=","avatar_url":"https://avatars1.githubusercontent.com/u/3450815?v=4","gravatar_id":"","url":"https://api.github.com/users/Sinevia","html_url":"https://github.com/Sinevia","followers_url":"https://api.github.com/users/Sinevia/followers","following_url":"https://api.github.com/users/Sinevia/following{/other_user}","gists_url":"https://api.github.com/users/Sinevia/gists{/gist_id}","starred_url":"https://api.github.com/users/Sinevia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sinevia/subscriptions","organizations_url":"https://api.github.com/users/Sinevia/orgs","repos_url":"https://api.github.com/users/Sinevia/repos","events_url":"https://api.github.com/users/Sinevia/events{/privacy}","received_events_url":"https://api.github.com/users/Sinevia/received_events","type":"User","site_admin":false},"labels":[{"id":492852833,"node_id":"MDU6TGFiZWw0OTI4NTI4MzM=","url":"https://api.github.com/repos/leocavalcante/siler/labels/invalid","name":"invalid","color":"e6e6e6","default":true}],"state":"closed","locked":false,"assignee":{"login":"leocavalcante","id":183722,"node_id":"MDQ6VXNlcjE4MzcyMg==","avatar_url":"https://avatars3.githubusercontent.com/u/183722?v=4","gravatar_id":"","url":"https://api.github.com/users/leocavalcante","html_url":"https://github.com/leocavalcante","followers_url":"https://api.github.com/users/leocavalcante/followers","following_url":"https://api.github.com/users/leocavalcante/following{/other_user}","gists_url":"https://api.github.com/users/leocavalcante/gists{/gist_id}","starred_url":"https://api.github.com/users/leocavalcante/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leocavalcante/subscriptions","organizations_url":"https://api.github.com/users/leocavalcante/orgs","repos_url":"https://api.github.com/users/leocavalcante/repos","events_url":"https://api.github.com/users/leocavalcante/events{/privacy}","received_events_url":"https://api.github.com/users/leocavalcante/received_events","type":"User","site_admin":false},"assignees":[{"login":"leocavalcante","id":183722,"node_id":"MDQ6VXNlcjE4MzcyMg==","avatar_url":"https://avatars3.githubusercontent.com/u/183722?v=4","gravatar_id":"","url":"https://api.github.com/users/leocavalcante","html_url":"https://github.com/leocavalcante","followers_url":"https://api.github.com/users/leocavalcante/followers","following_url":"https://api.github.com/users/leocavalcante/following{/other_user}","gists_url":"https://api.github.com/users/leocavalcante/gists{/gist_id}","starred_url":"https://api.github.com/users/leocavalcante/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leocavalcante/subscriptions","organizations_url":"https://api.github.com/users/leocavalcante/orgs","repos_url":"https://api.github.com/users/leocavalcante/repos","events_url":"https://api.github.com/users/leocavalcante/events{/privacy}","received_events_url":"https://api.github.com/users/leocavalcante/received_events","type":"User","site_admin":false}],"milestone":null,"comments":5,"created_at":"2018-10-21T08:58:09Z","updated_at":"2018-10-22T05:36:11Z","closed_at":"2018-10-21T22:38:38Z","author_association":"NONE","body":"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.\r\n\r\n```\r\nclass TestController {\r\n    function __construct() {\r\n         if (has_access() == false){\r\n             die('No Access');\r\n         }\r\n    }\r\n    function page() {\r\n        return \"Page A\";\r\n    }\r\n}\r\nRoute\\get('/user', [(new TestController), \"page\"]);\r\nRoute\\get('/', function(){\r\n    return \"Home\";   \r\n});\r\n```\r\n\r\nI would suggest a workaround for calling non-static methods\r\n\r\nRoute\\get('/user', \"TestController@page\");"},"comment":{"url":"https://api.github.com/repos/leocavalcante/siler/issues/comments/431744271","html_url":"https://github.com/leocavalcante/siler/issues/116#issuecomment-431744271","issue_url":"https://api.github.com/repos/leocavalcante/siler/issues/116","id":431744271,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMTc0NDI3MQ==","user":{"login":"Sinevia","id":3450815,"node_id":"MDQ6VXNlcjM0NTA4MTU=","avatar_url":"https://avatars1.githubusercontent.com/u/3450815?v=4","gravatar_id":"","url":"https://api.github.com/users/Sinevia","html_url":"https://github.com/Sinevia","followers_url":"https://api.github.com/users/Sinevia/followers","following_url":"https://api.github.com/users/Sinevia/following{/other_user}","gists_url":"https://api.github.com/users/Sinevia/gists{/gist_id}","starred_url":"https://api.github.com/users/Sinevia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sinevia/subscriptions","organizations_url":"https://api.github.com/users/Sinevia/orgs","repos_url":"https://api.github.com/users/Sinevia/repos","events_url":"https://api.github.com/users/Sinevia/events{/privacy}","received_events_url":"https://api.github.com/users/Sinevia/received_events","type":"User","site_admin":false},"created_at":"2018-10-22T05:36:11Z","updated_at":"2018-10-22T05:36:11Z","author_association":"NONE","body":"@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.\r\n\r\nI believe other routers have recognized this as a problem and have come up with a solution:\r\n\r\n![image](https://user-images.githubusercontent.com/3450815/47278804-a4802280-d5c3-11e8-8346-76d21a3a1881.png)\r\n\r\nExample at:\r\nhttps://github.com/magnus-eriksson/router"}}
{"actor":{"display_login":"Sinevia"}}