{"action":"opened","number":14330,"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/14330","id":33126317,"html_url":"https://github.com/symfony/symfony/pull/14330","diff_url":"https://github.com/symfony/symfony/pull/14330.diff","patch_url":"https://github.com/symfony/symfony/pull/14330.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/14330","number":14330,"state":"open","locked":false,"title":"[WIP] Use callable typehints","user":{"login":"mpajunen","id":7025066,"avatar_url":"https://avatars.githubusercontent.com/u/7025066?v=3","gravatar_id":"","url":"https://api.github.com/users/mpajunen","html_url":"https://github.com/mpajunen","followers_url":"https://api.github.com/users/mpajunen/followers","following_url":"https://api.github.com/users/mpajunen/following{/other_user}","gists_url":"https://api.github.com/users/mpajunen/gists{/gist_id}","starred_url":"https://api.github.com/users/mpajunen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpajunen/subscriptions","organizations_url":"https://api.github.com/users/mpajunen/orgs","repos_url":"https://api.github.com/users/mpajunen/repos","events_url":"https://api.github.com/users/mpajunen/events{/privacy}","received_events_url":"https://api.github.com/users/mpajunen/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | no\r\n| New feature?  | no\r\n| BC breaks?    | yes\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets | -\r\n| License       | MIT\r\n| Doc PR        | -\r\n\r\nInitially discussed in #14293.\r\n\r\nThe `callable` typehint is used where applicable. Two types of changes are included:\r\n\r\n- Replace `\\Closure` typehints\r\n- Replace `is_callable()` checks\r\n\r\nThe PHP bug in the handling of callables of the `'Foo::bar'` type (https://bugs.php.net/bug.php?id=68475) causes some issues. To support every possible callable, `call_user_func($func, ...)` needs to be used instead of using `$func(...)` directly. Besides the more verbose syntax, `call_user_func` is also slower. There are a few options on how to deal with this:\r\n\r\n1. Use `call_user_func`.\r\n2. Don't support callables of the static string type. Possibly add an extra check and throw an exception when such a callback is passed.\r\n3. Don't change typehints where this is an issue, but continue to use `\\Closure`.\r\n\r\nEven option 2 doesn't sound entirely unworkable to me, static callback strings are very unwieldy -- especially with namespaces. That the error is thrown at call time is less than ideal of course.\r\n\r\nIn these cases using `call_user_func` doesn't look like a too bad option either. But in other places noticeable performance improvements could be possible if existing code could be converted to use direct calls. So the decision may have implications beyond just this PR.\r\n\r\nIn addition to handling the static strings, I still want to make sure that none of the `\\Closure` typehints that were replaced were intentionally strict. The one typehint in `OptionsResolver` mentioned by @stof in #14293 was already skipped.\r\n\r\n- [ ] Implement support for callables of `'Foo::bar'` type?\r\n- [ ] Make sure all `\\Closure` to `callable` changes are valid.\r\n- [ ] Add method signature changes to CHANGELOG / UPGRADE files.","created_at":"2015-04-12T20:55:59Z","updated_at":"2015-04-12T20:55:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/14330/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/14330/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/14330/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/e92101f9cc89cdf82ff727298a9a60a1160cf88c","head":{"label":"mpajunen:typehint-callable","ref":"typehint-callable","sha":"e92101f9cc89cdf82ff727298a9a60a1160cf88c","user":{"login":"mpajunen","id":7025066,"avatar_url":"https://avatars.githubusercontent.com/u/7025066?v=3","gravatar_id":"","url":"https://api.github.com/users/mpajunen","html_url":"https://github.com/mpajunen","followers_url":"https://api.github.com/users/mpajunen/followers","following_url":"https://api.github.com/users/mpajunen/following{/other_user}","gists_url":"https://api.github.com/users/mpajunen/gists{/gist_id}","starred_url":"https://api.github.com/users/mpajunen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpajunen/subscriptions","organizations_url":"https://api.github.com/users/mpajunen/orgs","repos_url":"https://api.github.com/users/mpajunen/repos","events_url":"https://api.github.com/users/mpajunen/events{/privacy}","received_events_url":"https://api.github.com/users/mpajunen/received_events","type":"User","site_admin":false},"repo":{"id":28002177,"name":"symfony","full_name":"mpajunen/symfony","owner":{"login":"mpajunen","id":7025066,"avatar_url":"https://avatars.githubusercontent.com/u/7025066?v=3","gravatar_id":"","url":"https://api.github.com/users/mpajunen","html_url":"https://github.com/mpajunen","followers_url":"https://api.github.com/users/mpajunen/followers","following_url":"https://api.github.com/users/mpajunen/following{/other_user}","gists_url":"https://api.github.com/users/mpajunen/gists{/gist_id}","starred_url":"https://api.github.com/users/mpajunen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpajunen/subscriptions","organizations_url":"https://api.github.com/users/mpajunen/orgs","repos_url":"https://api.github.com/users/mpajunen/repos","events_url":"https://api.github.com/users/mpajunen/events{/privacy}","received_events_url":"https://api.github.com/users/mpajunen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mpajunen/symfony","description":"The Symfony PHP framework","fork":true,"url":"https://api.github.com/repos/mpajunen/symfony","forks_url":"https://api.github.com/repos/mpajunen/symfony/forks","keys_url":"https://api.github.com/repos/mpajunen/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mpajunen/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mpajunen/symfony/teams","hooks_url":"https://api.github.com/repos/mpajunen/symfony/hooks","issue_events_url":"https://api.github.com/repos/mpajunen/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/mpajunen/symfony/events","assignees_url":"https://api.github.com/repos/mpajunen/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/mpajunen/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/mpajunen/symfony/tags","blobs_url":"https://api.github.com/repos/mpajunen/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mpajunen/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mpajunen/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/mpajunen/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mpajunen/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/mpajunen/symfony/languages","stargazers_url":"https://api.github.com/repos/mpajunen/symfony/stargazers","contributors_url":"https://api.github.com/repos/mpajunen/symfony/contributors","subscribers_url":"https://api.github.com/repos/mpajunen/symfony/subscribers","subscription_url":"https://api.github.com/repos/mpajunen/symfony/subscription","commits_url":"https://api.github.com/repos/mpajunen/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/mpajunen/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/mpajunen/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/mpajunen/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/mpajunen/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/mpajunen/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mpajunen/symfony/merges","archive_url":"https://api.github.com/repos/mpajunen/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mpajunen/symfony/downloads","issues_url":"https://api.github.com/repos/mpajunen/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/mpajunen/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/mpajunen/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/mpajunen/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mpajunen/symfony/labels{/name}","releases_url":"https://api.github.com/repos/mpajunen/symfony/releases{/id}","created_at":"2014-12-14T17:40:38Z","updated_at":"2014-12-29T21:37:50Z","pushed_at":"2015-04-12T19:20:24Z","git_url":"git://github.com/mpajunen/symfony.git","ssh_url":"git@github.com:mpajunen/symfony.git","clone_url":"https://github.com/mpajunen/symfony.git","svn_url":"https://github.com/mpajunen/symfony","homepage":"symfony.com","size":55070,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"2.7"}},"base":{"label":"symfony:master","ref":"master","sha":"73853c493bce71b8fee16582445a3c2f2d52a728","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","created_at":"2010-01-04T14:21:21Z","updated_at":"2015-04-12T20:53:09Z","pushed_at":"2015-04-12T18:28:36Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"symfony.com","size":220096,"stargazers_count":10008,"watchers_count":10008,"language":"PHP","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":3922,"mirror_url":null,"open_issues_count":817,"forks":3922,"open_issues":817,"watchers":10008,"default_branch":"2.7"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14330"},"html":{"href":"https://github.com/symfony/symfony/pull/14330"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/14330"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/14330/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14330/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14330/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/e92101f9cc89cdf82ff727298a9a60a1160cf88c"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":2,"additions":55,"deletions":183,"changed_files":20}}