{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/175460600","pull_request_review_id":104991934,"id":175460600,"diff_hunk":"@@ -0,0 +1,135 @@\n+<?php\n+\n+/*\n+ * This file is part of the Symfony package.\n+ *\n+ * (c) Fabien Potencier <fabien@symfony.com>\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace Symfony\\Component\\Security\\Core\\Tests\\Authorization\\Voter;\n+\n+use PHPUnit\\Framework\\TestCase;\n+use Symfony\\Component\\Security\\Core\\Authorization\\Voter\\CallableVoter;\n+use Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\n+\n+class CallableVoterTest extends TestCase\n+{\n+    /**\n+     * @dataProvider getVoteTests\n+     */\n+    public function testVote($callable, $expected)\n+    {\n+        $voter = new CallableVoter($callable);\n+        $tokenMock = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface')->getMock();\n+\n+        $this->assertSame($expected, $voter->vote($tokenMock, null, array()));\n+    }\n+\n+    public function getVoteTests()\n+    {\n+        return array(\n+            array(\n+                function () {\n+                    return true;\n+                },\n+                Voter::ACCESS_GRANTED,\n+            ),\n+            array(\n+                \\Closure::fromCallable(function () {","path":"src/Symfony/Component/Security/Core/Tests/Authorization/Voter/CallableVoterTest.php","position":41,"original_position":41,"commit_id":"828389e9620340fff03e98a2979da58bc68e5ffe","original_commit_id":"828389e9620340fff03e98a2979da58bc68e5ffe","user":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"body":"why wrapping in `Closure::fromCallable`? ","created_at":"2018-03-19T14:46:48Z","updated_at":"2018-03-19T14:46:48Z","html_url":"https://github.com/symfony/symfony/pull/26586#discussion_r175460600","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/26586","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/175460600"},"html":{"href":"https://github.com/symfony/symfony/pull/26586#discussion_r175460600"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/26586"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/26586","id":175743640,"html_url":"https://github.com/symfony/symfony/pull/26586","diff_url":"https://github.com/symfony/symfony/pull/26586.diff","patch_url":"https://github.com/symfony/symfony/pull/26586.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/26586","number":26586,"state":"open","locked":false,"title":"[Security] Add Callable voter","user":{"login":"instabledesign","id":1098878,"avatar_url":"https://avatars3.githubusercontent.com/u/1098878?v=4","gravatar_id":"","url":"https://api.github.com/users/instabledesign","html_url":"https://github.com/instabledesign","followers_url":"https://api.github.com/users/instabledesign/followers","following_url":"https://api.github.com/users/instabledesign/following{/other_user}","gists_url":"https://api.github.com/users/instabledesign/gists{/gist_id}","starred_url":"https://api.github.com/users/instabledesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/instabledesign/subscriptions","organizations_url":"https://api.github.com/users/instabledesign/orgs","repos_url":"https://api.github.com/users/instabledesign/repos","events_url":"https://api.github.com/users/instabledesign/events{/privacy}","received_events_url":"https://api.github.com/users/instabledesign/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Branch?       | master\r\n| Bug fix?      | no\r\n| New feature?  | yes\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets | \r\n| License       | MIT\r\n| Doc PR        | \r\n\r\nSimple implementation of a CallableVoter.\r\n\r\nThe `callable` must return true, false, mixed to respectively grant, denied, abstain.\r\n\r\nIt allow this multiple syntax use\r\n\r\n```php\r\nuse Symfony\\Component\\Security\\Core\\Authorization\\Voter\\CallableVoter;\r\n\r\nnew CallableVoter(\r\n    function () {\r\n        return true;\r\n    }\r\n);\r\n\r\nnew CallableVoter(\r\n    \\Closure::fromCallable(function () {\r\n        return true;\r\n    })\r\n);\r\n\r\nnew CallableVoter(\r\n    [\r\n        new class()\r\n        {\r\n            public function get()\r\n            {\r\n                return true;\r\n            }\r\n        },\r\n        'get',\r\n    ]\r\n);\r\n\r\nnew CallableVoter(\r\n    new class()\r\n    {\r\n        public function __invoke()\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n);\r\n```\r\n\r\nWhat did you think about such addition?\r\nFeel free to comment or close it.","created_at":"2018-03-18T10:08:25Z","updated_at":"2018-03-19T14:46:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0d14ef6d5cd6009ffe623ff3a3d708ba42c2c51a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":100378,"url":"https://api.github.com/repos/symfony/symfony/labels/Feature","name":"Feature","color":"02e10c","default":false},{"id":99600,"url":"https://api.github.com/repos/symfony/symfony/labels/Security","name":"Security","color":"DDDDDD","default":false},{"id":238909857,"url":"https://api.github.com/repos/symfony/symfony/labels/Status:%20Needs%20Work","name":"Status: Needs Work","color":"fad8c7","default":false}],"milestone":{"url":"https://api.github.com/repos/symfony/symfony/milestones/17","html_url":"https://github.com/symfony/symfony/milestone/17","labels_url":"https://api.github.com/repos/symfony/symfony/milestones/17/labels","id":2795131,"number":17,"title":"4.1","description":"https://symfony.com/roadmap?version=4.1#checker","creator":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"open_issues":142,"closed_issues":220,"state":"open","created_at":"2017-09-26T15:40:00Z","updated_at":"2018-03-19T14:42:47Z","due_on":"2018-05-31T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/26586/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/26586/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/26586/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/828389e9620340fff03e98a2979da58bc68e5ffe","head":{"label":"instabledesign:security-add-callable-voter","ref":"security-add-callable-voter","sha":"828389e9620340fff03e98a2979da58bc68e5ffe","user":{"login":"instabledesign","id":1098878,"avatar_url":"https://avatars3.githubusercontent.com/u/1098878?v=4","gravatar_id":"","url":"https://api.github.com/users/instabledesign","html_url":"https://github.com/instabledesign","followers_url":"https://api.github.com/users/instabledesign/followers","following_url":"https://api.github.com/users/instabledesign/following{/other_user}","gists_url":"https://api.github.com/users/instabledesign/gists{/gist_id}","starred_url":"https://api.github.com/users/instabledesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/instabledesign/subscriptions","organizations_url":"https://api.github.com/users/instabledesign/orgs","repos_url":"https://api.github.com/users/instabledesign/repos","events_url":"https://api.github.com/users/instabledesign/events{/privacy}","received_events_url":"https://api.github.com/users/instabledesign/received_events","type":"User","site_admin":false},"repo":{"id":124145046,"name":"symfony","full_name":"instabledesign/symfony","owner":{"login":"instabledesign","id":1098878,"avatar_url":"https://avatars3.githubusercontent.com/u/1098878?v=4","gravatar_id":"","url":"https://api.github.com/users/instabledesign","html_url":"https://github.com/instabledesign","followers_url":"https://api.github.com/users/instabledesign/followers","following_url":"https://api.github.com/users/instabledesign/following{/other_user}","gists_url":"https://api.github.com/users/instabledesign/gists{/gist_id}","starred_url":"https://api.github.com/users/instabledesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/instabledesign/subscriptions","organizations_url":"https://api.github.com/users/instabledesign/orgs","repos_url":"https://api.github.com/users/instabledesign/repos","events_url":"https://api.github.com/users/instabledesign/events{/privacy}","received_events_url":"https://api.github.com/users/instabledesign/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/instabledesign/symfony","description":"The Symfony PHP framework","fork":true,"url":"https://api.github.com/repos/instabledesign/symfony","forks_url":"https://api.github.com/repos/instabledesign/symfony/forks","keys_url":"https://api.github.com/repos/instabledesign/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/instabledesign/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/instabledesign/symfony/teams","hooks_url":"https://api.github.com/repos/instabledesign/symfony/hooks","issue_events_url":"https://api.github.com/repos/instabledesign/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/instabledesign/symfony/events","assignees_url":"https://api.github.com/repos/instabledesign/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/instabledesign/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/instabledesign/symfony/tags","blobs_url":"https://api.github.com/repos/instabledesign/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/instabledesign/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/instabledesign/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/instabledesign/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/instabledesign/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/instabledesign/symfony/languages","stargazers_url":"https://api.github.com/repos/instabledesign/symfony/stargazers","contributors_url":"https://api.github.com/repos/instabledesign/symfony/contributors","subscribers_url":"https://api.github.com/repos/instabledesign/symfony/subscribers","subscription_url":"https://api.github.com/repos/instabledesign/symfony/subscription","commits_url":"https://api.github.com/repos/instabledesign/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/instabledesign/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/instabledesign/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/instabledesign/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/instabledesign/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/instabledesign/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/instabledesign/symfony/merges","archive_url":"https://api.github.com/repos/instabledesign/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/instabledesign/symfony/downloads","issues_url":"https://api.github.com/repos/instabledesign/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/instabledesign/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/instabledesign/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/instabledesign/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/instabledesign/symfony/labels{/name}","releases_url":"https://api.github.com/repos/instabledesign/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/instabledesign/symfony/deployments","created_at":"2018-03-06T22:11:36Z","updated_at":"2018-03-06T22:11:57Z","pushed_at":"2018-03-18T10:16:08Z","git_url":"git://github.com/instabledesign/symfony.git","ssh_url":"git@github.com:instabledesign/symfony.git","clone_url":"https://github.com/instabledesign/symfony.git","svn_url":"https://github.com/instabledesign/symfony","homepage":"https://symfony.com","size":110101,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"symfony:master","ref":"master","sha":"0cfc00e7174f8658fdb75602e73d819af4dcdf86","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars3.githubusercontent.com/u/143937?v=4","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://avatars3.githubusercontent.com/u/143937?v=4","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}","deployments_url":"https://api.github.com/repos/symfony/symfony/deployments","created_at":"2010-01-04T14:21:21Z","updated_at":"2018-03-19T12:54:28Z","pushed_at":"2018-03-19T14:39:33Z","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":"https://symfony.com","size":114681,"stargazers_count":17011,"watchers_count":17011,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":6101,"mirror_url":null,"archived":false,"open_issues_count":850,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":6101,"open_issues":850,"watchers":17011,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/26586"},"html":{"href":"https://github.com/symfony/symfony/pull/26586"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/26586"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/26586/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/26586/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/26586/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/828389e9620340fff03e98a2979da58bc68e5ffe"}},"author_association":"NONE"}}
{"actor":{"display_login":"nicolas-grekas"}}