{"action":"created","comment":{"url":"https://api.github.com/repos/Roave/BetterReflection/pulls/comments/46286440","id":46286440,"diff_hunk":"@@ -0,0 +1,83 @@\n+<?php\n+\n+namespace BetterReflection\\SourceLocator\\Type;\n+\n+use Closure;\n+use BetterReflection\\Identifier\\Identifier;\n+use BetterReflection\\Identifier\\IdentifierType;\n+use BetterReflection\\Reflector\\Reflector;\n+use BetterReflection\\SourceLocator\\Ast\\Strategy\\AstConversionStrategy;\n+use BetterReflection\\SourceLocator\\Ast\\Strategy\\NodeToReflection;\n+use BetterReflection\\SourceLocator\\Located\\LocatedSource;\n+use PhpParser\\Node\\Name;\n+use PhpParser\\Node\\Stmt\\Namespace_;\n+use SuperClosure\\Analyzer\\AstAnalyzer;\n+use SuperClosure\\Analyzer\\ClosureAnalyzer;\n+use PhpParser\\Node\\Expr\\Closure as ClosureNode;\n+\n+class ClosureSourceLocator implements SourceLocator\n+{\n+    /**\n+     * @var Closure\n+     */\n+    private $closure;\n+\n+    /**\n+     * @var ClosureAnalyzer\n+     */\n+    private $closureAnalyzer;\n+\n+    /**\n+     * @var AstConversionStrategy\n+     */\n+    private $conversionStrategy;\n+\n+    public function __construct(Closure $closure, ClosureAnalyzer $closureAnalyzer = null, AstConversionStrategy $conversionStrategy = null)\n+    {\n+        $this->closure = $closure;\n+\n+        if (null === $closureAnalyzer) {\n+            $closureAnalyzer = new AstAnalyzer();\n+        }\n+        $this->closureAnalyzer = $closureAnalyzer;\n+\n+        if (null === $conversionStrategy) {\n+            $conversionStrategy = new NodeToReflection();\n+        }\n+        $this->conversionStrategy = $conversionStrategy;\n+    }\n+\n+    /**\n+     * {@inheritDoc}\n+     */\n+    public function locateIdentifier(Reflector $reflector, Identifier $identifier)\n+    {\n+        $closureData = $this->closureAnalyzer->analyze($this->closure);\n+\n+        if (!isset($closureData['ast']) || !($closureData['ast'] instanceof ClosureNode)) {\n+            return null;\n+        }\n+\n+        $locatedSource = new LocatedSource(\n+            '<?php ' . $closureData['code'],\n+            $closureData['reflection']->getFileName()\n+        );\n+\n+        $namespaceNode = null;\n+        if (isset($closureData['location']['namespace'])) {\n+            $namespaceNode = new Namespace_(new Name($closureData['location']['namespace']));\n+        }\n+\n+        return $this->conversionStrategy->__invoke(\n+            $reflector,\n+            $closureData['ast'],\n+            $locatedSource,\n+            $namespaceNode\n+        );\n+    }\n+\n+    public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType)\n+    {\n+        // @TODO: Implement locateIdentifiersByType() method.","path":"src/SourceLocator/Type/ClosureSourceLocator.php","position":null,"original_position":81,"commit_id":"d3e2e66776ec27d5601406d0815b6a6b9b3a4f7f","original_commit_id":"5c1a60fadc2905dc704b717894a73ba8f9327bbd","user":{"login":"asgrim","id":496145,"avatar_url":"https://avatars.githubusercontent.com/u/496145?v=3","gravatar_id":"","url":"https://api.github.com/users/asgrim","html_url":"https://github.com/asgrim","followers_url":"https://api.github.com/users/asgrim/followers","following_url":"https://api.github.com/users/asgrim/following{/other_user}","gists_url":"https://api.github.com/users/asgrim/gists{/gist_id}","starred_url":"https://api.github.com/users/asgrim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asgrim/subscriptions","organizations_url":"https://api.github.com/users/asgrim/orgs","repos_url":"https://api.github.com/users/asgrim/repos","events_url":"https://api.github.com/users/asgrim/events{/privacy}","received_events_url":"https://api.github.com/users/asgrim/received_events","type":"User","site_admin":false},"body":"Fixed in b0e899d","created_at":"2015-12-01T14:49:17Z","updated_at":"2015-12-01T14:49:17Z","html_url":"https://github.com/Roave/BetterReflection/pull/151#discussion_r46286440","pull_request_url":"https://api.github.com/repos/Roave/BetterReflection/pulls/151","_links":{"self":{"href":"https://api.github.com/repos/Roave/BetterReflection/pulls/comments/46286440"},"html":{"href":"https://github.com/Roave/BetterReflection/pull/151#discussion_r46286440"},"pull_request":{"href":"https://api.github.com/repos/Roave/BetterReflection/pulls/151"}}},"pull_request":{"url":"https://api.github.com/repos/Roave/BetterReflection/pulls/151","id":51934020,"html_url":"https://github.com/Roave/BetterReflection/pull/151","diff_url":"https://github.com/Roave/BetterReflection/pull/151.diff","patch_url":"https://github.com/Roave/BetterReflection/pull/151.patch","issue_url":"https://api.github.com/repos/Roave/BetterReflection/issues/151","number":151,"state":"open","locked":false,"title":"Reflect from Closures","user":{"login":"asgrim","id":496145,"avatar_url":"https://avatars.githubusercontent.com/u/496145?v=3","gravatar_id":"","url":"https://api.github.com/users/asgrim","html_url":"https://github.com/asgrim","followers_url":"https://api.github.com/users/asgrim/followers","following_url":"https://api.github.com/users/asgrim/following{/other_user}","gists_url":"https://api.github.com/users/asgrim/gists{/gist_id}","starred_url":"https://api.github.com/users/asgrim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asgrim/subscriptions","organizations_url":"https://api.github.com/users/asgrim/orgs","repos_url":"https://api.github.com/users/asgrim/repos","events_url":"https://api.github.com/users/asgrim/events{/privacy}","received_events_url":"https://api.github.com/users/asgrim/received_events","type":"User","site_admin":false},"body":"Handles issue #37 by adding ability to reflect on anonymous functions / closures.","created_at":"2015-11-26T17:07:59Z","updated_at":"2015-12-01T14:49:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"85de6bfb8eab66aa45bef516f34ae8241cc02968","assignee":{"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},"milestone":{"url":"https://api.github.com/repos/Roave/BetterReflection/milestones/3","html_url":"https://github.com/Roave/BetterReflection/milestones/1.0.0","labels_url":"https://api.github.com/repos/Roave/BetterReflection/milestones/3/labels","id":1389881,"number":3,"title":"1.0.0","description":"","creator":{"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},"open_issues":15,"closed_issues":3,"state":"open","created_at":"2015-11-02T20:22:46Z","updated_at":"2015-11-26T17:07:59Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/Roave/BetterReflection/pulls/151/commits","review_comments_url":"https://api.github.com/repos/Roave/BetterReflection/pulls/151/comments","review_comment_url":"https://api.github.com/repos/Roave/BetterReflection/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Roave/BetterReflection/issues/151/comments","statuses_url":"https://api.github.com/repos/Roave/BetterReflection/statuses/d3e2e66776ec27d5601406d0815b6a6b9b3a4f7f","head":{"label":"Roave:reflect-from-closure","ref":"reflect-from-closure","sha":"d3e2e66776ec27d5601406d0815b6a6b9b3a4f7f","user":{"login":"Roave","id":3029050,"avatar_url":"https://avatars.githubusercontent.com/u/3029050?v=3","gravatar_id":"","url":"https://api.github.com/users/Roave","html_url":"https://github.com/Roave","followers_url":"https://api.github.com/users/Roave/followers","following_url":"https://api.github.com/users/Roave/following{/other_user}","gists_url":"https://api.github.com/users/Roave/gists{/gist_id}","starred_url":"https://api.github.com/users/Roave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roave/subscriptions","organizations_url":"https://api.github.com/users/Roave/orgs","repos_url":"https://api.github.com/users/Roave/repos","events_url":"https://api.github.com/users/Roave/events{/privacy}","received_events_url":"https://api.github.com/users/Roave/received_events","type":"Organization","site_admin":false},"repo":{"id":36865277,"name":"BetterReflection","full_name":"Roave/BetterReflection","owner":{"login":"Roave","id":3029050,"avatar_url":"https://avatars.githubusercontent.com/u/3029050?v=3","gravatar_id":"","url":"https://api.github.com/users/Roave","html_url":"https://github.com/Roave","followers_url":"https://api.github.com/users/Roave/followers","following_url":"https://api.github.com/users/Roave/following{/other_user}","gists_url":"https://api.github.com/users/Roave/gists{/gist_id}","starred_url":"https://api.github.com/users/Roave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roave/subscriptions","organizations_url":"https://api.github.com/users/Roave/orgs","repos_url":"https://api.github.com/users/Roave/repos","events_url":"https://api.github.com/users/Roave/events{/privacy}","received_events_url":"https://api.github.com/users/Roave/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Roave/BetterReflection","description":"PHP's reflection API but without having to load the class","fork":false,"url":"https://api.github.com/repos/Roave/BetterReflection","forks_url":"https://api.github.com/repos/Roave/BetterReflection/forks","keys_url":"https://api.github.com/repos/Roave/BetterReflection/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Roave/BetterReflection/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Roave/BetterReflection/teams","hooks_url":"https://api.github.com/repos/Roave/BetterReflection/hooks","issue_events_url":"https://api.github.com/repos/Roave/BetterReflection/issues/events{/number}","events_url":"https://api.github.com/repos/Roave/BetterReflection/events","assignees_url":"https://api.github.com/repos/Roave/BetterReflection/assignees{/user}","branches_url":"https://api.github.com/repos/Roave/BetterReflection/branches{/branch}","tags_url":"https://api.github.com/repos/Roave/BetterReflection/tags","blobs_url":"https://api.github.com/repos/Roave/BetterReflection/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Roave/BetterReflection/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Roave/BetterReflection/git/refs{/sha}","trees_url":"https://api.github.com/repos/Roave/BetterReflection/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Roave/BetterReflection/statuses/{sha}","languages_url":"https://api.github.com/repos/Roave/BetterReflection/languages","stargazers_url":"https://api.github.com/repos/Roave/BetterReflection/stargazers","contributors_url":"https://api.github.com/repos/Roave/BetterReflection/contributors","subscribers_url":"https://api.github.com/repos/Roave/BetterReflection/subscribers","subscription_url":"https://api.github.com/repos/Roave/BetterReflection/subscription","commits_url":"https://api.github.com/repos/Roave/BetterReflection/commits{/sha}","git_commits_url":"https://api.github.com/repos/Roave/BetterReflection/git/commits{/sha}","comments_url":"https://api.github.com/repos/Roave/BetterReflection/comments{/number}","issue_comment_url":"https://api.github.com/repos/Roave/BetterReflection/issues/comments{/number}","contents_url":"https://api.github.com/repos/Roave/BetterReflection/contents/{+path}","compare_url":"https://api.github.com/repos/Roave/BetterReflection/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Roave/BetterReflection/merges","archive_url":"https://api.github.com/repos/Roave/BetterReflection/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Roave/BetterReflection/downloads","issues_url":"https://api.github.com/repos/Roave/BetterReflection/issues{/number}","pulls_url":"https://api.github.com/repos/Roave/BetterReflection/pulls{/number}","milestones_url":"https://api.github.com/repos/Roave/BetterReflection/milestones{/number}","notifications_url":"https://api.github.com/repos/Roave/BetterReflection/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Roave/BetterReflection/labels{/name}","releases_url":"https://api.github.com/repos/Roave/BetterReflection/releases{/id}","created_at":"2015-06-04T11:02:42Z","updated_at":"2015-11-30T09:00:28Z","pushed_at":"2015-12-01T14:48:41Z","git_url":"git://github.com/Roave/BetterReflection.git","ssh_url":"git@github.com:Roave/BetterReflection.git","clone_url":"https://github.com/Roave/BetterReflection.git","svn_url":"https://github.com/Roave/BetterReflection","homepage":null,"size":877,"stargazers_count":109,"watchers_count":109,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":31,"forks":7,"open_issues":31,"watchers":109,"default_branch":"master"}},"base":{"label":"Roave:master","ref":"master","sha":"fee3f36f97169c103d4720c5344e6ac6e8e0f7c2","user":{"login":"Roave","id":3029050,"avatar_url":"https://avatars.githubusercontent.com/u/3029050?v=3","gravatar_id":"","url":"https://api.github.com/users/Roave","html_url":"https://github.com/Roave","followers_url":"https://api.github.com/users/Roave/followers","following_url":"https://api.github.com/users/Roave/following{/other_user}","gists_url":"https://api.github.com/users/Roave/gists{/gist_id}","starred_url":"https://api.github.com/users/Roave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roave/subscriptions","organizations_url":"https://api.github.com/users/Roave/orgs","repos_url":"https://api.github.com/users/Roave/repos","events_url":"https://api.github.com/users/Roave/events{/privacy}","received_events_url":"https://api.github.com/users/Roave/received_events","type":"Organization","site_admin":false},"repo":{"id":36865277,"name":"BetterReflection","full_name":"Roave/BetterReflection","owner":{"login":"Roave","id":3029050,"avatar_url":"https://avatars.githubusercontent.com/u/3029050?v=3","gravatar_id":"","url":"https://api.github.com/users/Roave","html_url":"https://github.com/Roave","followers_url":"https://api.github.com/users/Roave/followers","following_url":"https://api.github.com/users/Roave/following{/other_user}","gists_url":"https://api.github.com/users/Roave/gists{/gist_id}","starred_url":"https://api.github.com/users/Roave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roave/subscriptions","organizations_url":"https://api.github.com/users/Roave/orgs","repos_url":"https://api.github.com/users/Roave/repos","events_url":"https://api.github.com/users/Roave/events{/privacy}","received_events_url":"https://api.github.com/users/Roave/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Roave/BetterReflection","description":"PHP's reflection API but without having to load the class","fork":false,"url":"https://api.github.com/repos/Roave/BetterReflection","forks_url":"https://api.github.com/repos/Roave/BetterReflection/forks","keys_url":"https://api.github.com/repos/Roave/BetterReflection/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Roave/BetterReflection/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Roave/BetterReflection/teams","hooks_url":"https://api.github.com/repos/Roave/BetterReflection/hooks","issue_events_url":"https://api.github.com/repos/Roave/BetterReflection/issues/events{/number}","events_url":"https://api.github.com/repos/Roave/BetterReflection/events","assignees_url":"https://api.github.com/repos/Roave/BetterReflection/assignees{/user}","branches_url":"https://api.github.com/repos/Roave/BetterReflection/branches{/branch}","tags_url":"https://api.github.com/repos/Roave/BetterReflection/tags","blobs_url":"https://api.github.com/repos/Roave/BetterReflection/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Roave/BetterReflection/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Roave/BetterReflection/git/refs{/sha}","trees_url":"https://api.github.com/repos/Roave/BetterReflection/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Roave/BetterReflection/statuses/{sha}","languages_url":"https://api.github.com/repos/Roave/BetterReflection/languages","stargazers_url":"https://api.github.com/repos/Roave/BetterReflection/stargazers","contributors_url":"https://api.github.com/repos/Roave/BetterReflection/contributors","subscribers_url":"https://api.github.com/repos/Roave/BetterReflection/subscribers","subscription_url":"https://api.github.com/repos/Roave/BetterReflection/subscription","commits_url":"https://api.github.com/repos/Roave/BetterReflection/commits{/sha}","git_commits_url":"https://api.github.com/repos/Roave/BetterReflection/git/commits{/sha}","comments_url":"https://api.github.com/repos/Roave/BetterReflection/comments{/number}","issue_comment_url":"https://api.github.com/repos/Roave/BetterReflection/issues/comments{/number}","contents_url":"https://api.github.com/repos/Roave/BetterReflection/contents/{+path}","compare_url":"https://api.github.com/repos/Roave/BetterReflection/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Roave/BetterReflection/merges","archive_url":"https://api.github.com/repos/Roave/BetterReflection/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Roave/BetterReflection/downloads","issues_url":"https://api.github.com/repos/Roave/BetterReflection/issues{/number}","pulls_url":"https://api.github.com/repos/Roave/BetterReflection/pulls{/number}","milestones_url":"https://api.github.com/repos/Roave/BetterReflection/milestones{/number}","notifications_url":"https://api.github.com/repos/Roave/BetterReflection/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Roave/BetterReflection/labels{/name}","releases_url":"https://api.github.com/repos/Roave/BetterReflection/releases{/id}","created_at":"2015-06-04T11:02:42Z","updated_at":"2015-11-30T09:00:28Z","pushed_at":"2015-12-01T14:48:41Z","git_url":"git://github.com/Roave/BetterReflection.git","ssh_url":"git@github.com:Roave/BetterReflection.git","clone_url":"https://github.com/Roave/BetterReflection.git","svn_url":"https://github.com/Roave/BetterReflection","homepage":null,"size":877,"stargazers_count":109,"watchers_count":109,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":31,"forks":7,"open_issues":31,"watchers":109,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Roave/BetterReflection/pulls/151"},"html":{"href":"https://github.com/Roave/BetterReflection/pull/151"},"issue":{"href":"https://api.github.com/repos/Roave/BetterReflection/issues/151"},"comments":{"href":"https://api.github.com/repos/Roave/BetterReflection/issues/151/comments"},"review_comments":{"href":"https://api.github.com/repos/Roave/BetterReflection/pulls/151/comments"},"review_comment":{"href":"https://api.github.com/repos/Roave/BetterReflection/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Roave/BetterReflection/pulls/151/commits"},"statuses":{"href":"https://api.github.com/repos/Roave/BetterReflection/statuses/d3e2e66776ec27d5601406d0815b6a6b9b3a4f7f"}}}}