{"action":"created","issue":{"url":"https://api.github.com/repos/InterNations/type-jail/issues/1","labels_url":"https://api.github.com/repos/InterNations/type-jail/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/InterNations/type-jail/issues/1/comments","events_url":"https://api.github.com/repos/InterNations/type-jail/issues/1/events","html_url":"https://github.com/InterNations/type-jail/issues/1","id":53987267,"number":1,"title":"Fatal errors instead of exceptions?","user":{"login":"Ocramius","id":154256,"avatar_url":"https://avatars.githubusercontent.com/u/154256?v=3","gravatar_id":"","url":"https://api.github.com/users/Ocramius","html_url":"https://github.com/Ocramius","followers_url":"https://api.github.com/users/Ocramius/followers","following_url":"https://api.github.com/users/Ocramius/following{/other_user}","gists_url":"https://api.github.com/users/Ocramius/gists{/gist_id}","starred_url":"https://api.github.com/users/Ocramius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ocramius/subscriptions","organizations_url":"https://api.github.com/users/Ocramius/orgs","repos_url":"https://api.github.com/users/Ocramius/repos","events_url":"https://api.github.com/users/Ocramius/events{/privacy}","received_events_url":"https://api.github.com/users/Ocramius/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-01-11T09:56:22Z","updated_at":"2015-01-14T16:40:40Z","closed_at":"2015-01-13T21:10:51Z","body":"As of current API, access to type-safe proxies causes exceptions to be thrown (when non-interfaced methods are used), rather than fatal errors.\r\n\r\nThis may lead to unexpected behavior when a consumer of the instance relies on \"magic\" and uses reflection-ish API (`method_exists()`, for example) to discover available methods (many templating libraries do that).\r\n\r\nThe [current implementation](https://github.com/InterNations/type-police/blob/ae9c1c858f77287a0e3b667638698478b7b82ee4/src/InterNations/Factory/PolicedProxyFactory.php#L49) uses the class name of the proxied `$instance` as class signature for the generated code. Using the `$class` would restrict access even further.\r\n\r\nA simple test (that will not require `.phpt` testing) for this kind of functionality can look like following:\r\n\r\n```php\r\npublic function testDoesNotExposeNonInterfaceMethods()\r\n{\r\n    $interface = uniqid('interface');\r\n    $class     = uniqid('class');\r\n\r\n    eval('interface ' . $interface . ' { function foo(); }');\r\n    eval('class ' . $class . ' { function foo() {} function bar() {} }');\r\n\r\n    $police = $this->factory->policeInstance(new $class, $interface);\r\n\r\n    $this->assertTrue(method_exists($police, 'foo'));\r\n    $this->assertFalse(method_exists($police, 'bar'));\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/InterNations/type-jail/issues/comments/69946292","html_url":"https://github.com/InterNations/type-jail/issues/1#issuecomment-69946292","issue_url":"https://api.github.com/repos/InterNations/type-jail/issues/1","id":69946292,"user":{"login":"Ocramius","id":154256,"avatar_url":"https://avatars.githubusercontent.com/u/154256?v=3","gravatar_id":"","url":"https://api.github.com/users/Ocramius","html_url":"https://github.com/Ocramius","followers_url":"https://api.github.com/users/Ocramius/followers","following_url":"https://api.github.com/users/Ocramius/following{/other_user}","gists_url":"https://api.github.com/users/Ocramius/gists{/gist_id}","starred_url":"https://api.github.com/users/Ocramius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ocramius/subscriptions","organizations_url":"https://api.github.com/users/Ocramius/orgs","repos_url":"https://api.github.com/users/Ocramius/repos","events_url":"https://api.github.com/users/Ocramius/events{/privacy}","received_events_url":"https://api.github.com/users/Ocramius/received_events","type":"User","site_admin":false},"created_at":"2015-01-14T16:40:40Z","updated_at":"2015-01-14T16:40:40Z","body":"![already done](http://37.media.tumblr.com/c3bbb7973deeb4a1c60570bde1a948bf/tumblr_n42bd22XPs1smcbm7o1_250.gif)"}}