{"action":"closed","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/13846","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/13846/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/13846/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/13846/events","html_url":"https://github.com/laravel/framework/issues/13846","id":158293222,"number":13846,"title":"Exception: ValidatesWhenResolvedTrait::failedValidation() should be compatible with FormRequest::failedValidation(Illuminate\\Contracts\\Validation\\Validator $validator)","user":{"login":"john052","id":5901961,"avatar_url":"https://avatars.githubusercontent.com/u/5901961?v=3","gravatar_id":"","url":"https://api.github.com/users/john052","html_url":"https://github.com/john052","followers_url":"https://api.github.com/users/john052/followers","following_url":"https://api.github.com/users/john052/following{/other_user}","gists_url":"https://api.github.com/users/john052/gists{/gist_id}","starred_url":"https://api.github.com/users/john052/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/john052/subscriptions","organizations_url":"https://api.github.com/users/john052/orgs","repos_url":"https://api.github.com/users/john052/repos","events_url":"https://api.github.com/users/john052/events{/privacy}","received_events_url":"https://api.github.com/users/john052/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-03T05:23:23Z","updated_at":"2016-06-06T13:47:49Z","closed_at":"2016-06-06T13:47:49Z","body":"This is a request and potentially a bug.\r\nThe `FormRequest` class has methods for validation and authorization.\r\n`failedValidation`, `failedAutorization` and a few others.\r\n\r\nThen the `ValidatesWhenResolvedTrait` implements the same methods, albeit slightly different. Ex. `ValidatesWhenResolvedTrait::passesAuthorization` returns true where `FormRequest::passesAuthorization` returns false.\r\n\r\n**The Request:**  Can the class and trait methods be changed to better reflect each other. (i.e throw the same exceptions, return the same values)\r\n\r\n**The Bug:** Since `FormRequest` uses the `ValidatesWhenResolvedTrait` trait, the methods in `FormRequest` aren't actually being overridden by the trait since a trait only overrides inherited methods. (see http://php.net/manual/en/language.oop5.traits.php precedence order). \r\n\r\nSo, to use the methods from the trait you'd have to use the trait in an inherited class. \r\nHowever, when I `use ValidatesWhenResolvedTrait` in my own classes, I get the error:\r\n\r\n`Declaration of Illuminate\\Validation\\ValidatesWhenResolvedTrait::failedValidation() should be compatible with Illuminate\\Foundation\\Http\\FormRequest::failedValidation(Illuminate\\Contracts\\Validation\\Validator $validator)`\r\n\r\nThis is because `ValidatesWhenResolvedTrait::failedValidation` uses `\\Illuminate\\Validation\\Validator`\r\nwhereas `FormRequest::failedValidation` uses `\\Illuminate\\Contracts\\Validation\\Validator`\r\n\r\nThe reason why the error isn't always being thrown is because the way the trait is being used currently, it's not implementing any methods apart from the `validate` method (since the trait isn't currently overriding anything in `FormRequest`)\r\n\r\nUsing Laravel 5.2\r\n\r\nIncluding simplified example: \r\nWorking example:\r\n```php\r\ntrait HelloTrait\r\n{\r\n    public function sayHello() {}\r\n}\r\n\r\nclass HelloBase\r\n{\r\n    use HelloTrait;\r\n    // this works because the trait is not overriding this\r\n    public function sayHello($some_variable) {}\r\n}\r\n\r\nclass HelloClass extends HelloBase\r\n{\r\n}\r\n```\r\nError Example:\r\n`ErrorException: Declaration of HelloTrait::sayHello() should be compatible with HelloBase::sayHello($some_variable)`\r\n```php\r\ntrait HelloTrait\r\n{\r\n    public function sayHello() {}\r\n}\r\n\r\nclass HelloBase\r\n{\r\n    use HelloTrait;\r\n    public function sayHello($some_variable) {}\r\n}\r\n\r\nclass HelloClass extends HelloBase\r\n{\r\n    use HelloTrait; // this throws the error because the trait is overriding the base method \r\n                   // but they have different parameters so they are not compatible\r\n}\r\n```"}}
{"actor":{"display_login":"john052"}}