{"action":"created","issue":{"url":"https://api.github.com/repos/http-interop/http-middleware/issues/41","repository_url":"https://api.github.com/repos/http-interop/http-middleware","labels_url":"https://api.github.com/repos/http-interop/http-middleware/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/http-interop/http-middleware/issues/41/comments","events_url":"https://api.github.com/repos/http-interop/http-middleware/issues/41/events","html_url":"https://github.com/http-interop/http-middleware/pull/41","id":192573790,"number":41,"title":"Practical Discussion about callable Delegates","user":{"login":"mindplay-dk","id":103348,"avatar_url":"https://avatars.githubusercontent.com/u/103348?v=3","gravatar_id":"","url":"https://api.github.com/users/mindplay-dk","html_url":"https://github.com/mindplay-dk","followers_url":"https://api.github.com/users/mindplay-dk/followers","following_url":"https://api.github.com/users/mindplay-dk/following{/other_user}","gists_url":"https://api.github.com/users/mindplay-dk/gists{/gist_id}","starred_url":"https://api.github.com/users/mindplay-dk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mindplay-dk/subscriptions","organizations_url":"https://api.github.com/users/mindplay-dk/orgs","repos_url":"https://api.github.com/users/mindplay-dk/repos","events_url":"https://api.github.com/users/mindplay-dk/events{/privacy}","received_events_url":"https://api.github.com/users/mindplay-dk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-11-30T14:05:31Z","updated_at":"2016-11-30T16:53:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/http-interop/http-middleware/pulls/41","html_url":"https://github.com/http-interop/http-middleware/pull/41","diff_url":"https://github.com/http-interop/http-middleware/pull/41.diff","patch_url":"https://github.com/http-interop/http-middleware/pull/41.patch"},"body":"To put issue #37 in a more practical context, I have started this `discussion` branch, along with a matching [middleman discussion-branch](https://github.com/mindplay-dk/middleman/tree/discussion) which has been updated to match those changes.\r\n\r\nPer the commit-log so far, I have made two changes:\r\n\r\n> in `ServerMiddlewareInterface`, allow `callable` as `$delegate` in middleware-signature, using a static type-hint of callable. In `DelegateInterface`, using the method-name `__invoke()` then becomes necessary, so this has been changed.\r\n\r\n> since the removal of `MiddlewareInterface`, we decided to use a type-hint of `RequestInterface` in `DelegateInterface`, for future compatibility with non-server-middleware - I think there is no longer any reason to exclude `MiddlewareInterface` from the standard. This will also align better with the de-facto standard.\r\n\r\nPer the [test-suite](https://github.com/mindplay-dk/middleman/blob/discussion/test/test.php), this all works as expected - it's simpler than previously, and inspections in Php Storm seem to make sense.\r\n\r\nThe only thing I would do differently, if it was possible, is have `ServerMiddlewareInterface` extend `MiddlewareInterface`, but we've explored that, and it's not really possible. Having to select and implement either one or the other appears to make sense though - your middleware will effectively support either `RequestInterface|ServerRequestInterface` for client/server-middleware, *or* `ServerRequestInterface` for server-only middleware.\r\n"},"comment":{"url":"https://api.github.com/repos/http-interop/http-middleware/issues/comments/263927989","html_url":"https://github.com/http-interop/http-middleware/pull/41#issuecomment-263927989","issue_url":"https://api.github.com/repos/http-interop/http-middleware/issues/41","id":263927989,"user":{"login":"schnittstabil","id":6059032,"avatar_url":"https://avatars.githubusercontent.com/u/6059032?v=3","gravatar_id":"","url":"https://api.github.com/users/schnittstabil","html_url":"https://github.com/schnittstabil","followers_url":"https://api.github.com/users/schnittstabil/followers","following_url":"https://api.github.com/users/schnittstabil/following{/other_user}","gists_url":"https://api.github.com/users/schnittstabil/gists{/gist_id}","starred_url":"https://api.github.com/users/schnittstabil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schnittstabil/subscriptions","organizations_url":"https://api.github.com/users/schnittstabil/orgs","repos_url":"https://api.github.com/users/schnittstabil/repos","events_url":"https://api.github.com/users/schnittstabil/events{/privacy}","received_events_url":"https://api.github.com/users/schnittstabil/received_events","type":"User","site_admin":false},"created_at":"2016-11-30T16:53:27Z","updated_at":"2016-11-30T16:53:27Z","body":"> **Why isn't the delegate a `callable`?**\r\n> Using an interface type hint improves runtime safety and IDE support.\r\n\r\nAs far as I can see, that is the only valid argument against `callable`. The mentioned [PHP-FIG discussion of FrameInterface](https://groups.google.com/d/msg/php-fig/V12AAcT_SxE/aRXmNnIVCwAJ) considers PHP7 return types etc. – which we cannot enforced by this PSR.\r\n\r\nAs far as I know, the backwards compatibility and `__invoke` argument is about middlewares, and not delegates – furthermore I think it is flawed too.\r\n\r\nThus I think, the only benefit of the interface over `callable` are the enforcement of the amount of parameters and there type."}}
{"actor":{"display_login":"schnittstabil"}}