{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/25287","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/25287/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/25287/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/25287/events","html_url":"https://github.com/laravel/framework/issues/25287","id":352675835,"node_id":"MDU6SXNzdWUzNTI2NzU4MzU=","number":25287,"title":"BadMethodCallException in Illuminate\\Validation\\Validator@fails is not working properly","user":{"login":"leandrowkz","id":1237231,"node_id":"MDQ6VXNlcjEyMzcyMzE=","avatar_url":"https://avatars1.githubusercontent.com/u/1237231?v=4","gravatar_id":"","url":"https://api.github.com/users/leandrowkz","html_url":"https://github.com/leandrowkz","followers_url":"https://api.github.com/users/leandrowkz/followers","following_url":"https://api.github.com/users/leandrowkz/following{/other_user}","gists_url":"https://api.github.com/users/leandrowkz/gists{/gist_id}","starred_url":"https://api.github.com/users/leandrowkz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leandrowkz/subscriptions","organizations_url":"https://api.github.com/users/leandrowkz/orgs","repos_url":"https://api.github.com/users/leandrowkz/repos","events_url":"https://api.github.com/users/leandrowkz/events{/privacy}","received_events_url":"https://api.github.com/users/leandrowkz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-08-21T19:22:17Z","updated_at":"2018-08-22T00:59:39Z","closed_at":null,"author_association":"NONE","body":"- Laravel Version: 5.6.16\r\n- PHP Version: 7.2.9 (also tested on 7.1.16)\r\n\r\n### Description:\r\nThe BadMethodCallException thrown by Illuminate\\Validation\\Validator@fails (which calls **passes()**, then **validateAttribute()**, then **__call()**) is not being catchable inside a try/catch block, when an invalid rule is given to Validator::make();\r\n\r\n### Steps To Reproduce:\r\n```\r\ntry {\r\n    $validator = Validator::make($data, ['field' => 'invalid_rule']);\r\n    if ($validator->fails()) {\r\n        // do something\r\n    } \r\n} catch (BadMethodCallException $e) {\r\n    // Not firing, never catch this\r\n}\r\n```\r\n\r\n### Additional information:\r\nI've found out that if I change the parameters order on this line https://github.com/laravel/framework/blob/5.6/src/Illuminate/Validation/Validator.php#L365 then the exception is catch normally, but I have no idea why. So changing this:\r\n```\r\nif ($validatable && ! $this->$method($attribute, $value, $parameters, $this)) {\r\n```\r\nto this:\r\n```\r\nif (! $this->$method($attribute, $value, $parameters, $this) && $validatable) {\r\n\r\n```\r\nmakes my try/catch works.\r\n\r\nPlease, could you guys help me to find out what is happening?"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/414870942","html_url":"https://github.com/laravel/framework/issues/25287#issuecomment-414870942","issue_url":"https://api.github.com/repos/laravel/framework/issues/25287","id":414870942,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDg3MDk0Mg==","user":{"login":"staudenmeir","id":1853169,"node_id":"MDQ6VXNlcjE4NTMxNjk=","avatar_url":"https://avatars3.githubusercontent.com/u/1853169?v=4","gravatar_id":"","url":"https://api.github.com/users/staudenmeir","html_url":"https://github.com/staudenmeir","followers_url":"https://api.github.com/users/staudenmeir/followers","following_url":"https://api.github.com/users/staudenmeir/following{/other_user}","gists_url":"https://api.github.com/users/staudenmeir/gists{/gist_id}","starred_url":"https://api.github.com/users/staudenmeir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/staudenmeir/subscriptions","organizations_url":"https://api.github.com/users/staudenmeir/orgs","repos_url":"https://api.github.com/users/staudenmeir/repos","events_url":"https://api.github.com/users/staudenmeir/events{/privacy}","received_events_url":"https://api.github.com/users/staudenmeir/received_events","type":"User","site_admin":false},"created_at":"2018-08-22T00:59:39Z","updated_at":"2018-08-22T00:59:39Z","author_association":"CONTRIBUTOR","body":"Does your `$data` have a `field` value? I can catch the exception when my `$data` has one. If it doesn't, the validator just passes (as expected)."}}
{"actor":{"display_login":"staudenmeir"}}