{"action":"created","comment":{"url":"https://api.github.com/repos/titon/framework/pulls/comments/24787095","id":24787095,"diff_hunk":"@@ -0,0 +1,106 @@\n+<?hh // strict\n+/**\n+ * @copyright   2010-2015, The Titon Project\n+ * @license     http://opensource.org/licenses/bsd-license.php\n+ * @link        http://titon.io\n+ */\n+\n+namespace Titon\\Context\\Definition;\n+\n+use ReflectionClass;\n+use ReflectionMethod;\n+use Titon\\Context\\Depository;\n+\n+/**\n+ * A class definition determines how a class is created, including necessary\n+ * arguments passed into the constructor as well as methods to be called after\n+ * instantiation before returning the object for use.\n+ *\n+ * @package Titon\\Context\\Definition\n+ */\n+class ClassDefinition extends Definition implements DefinitionInterface\n+{\n+    /**\n+     * The name of the class defined\n+     *\n+     * @var string\n+     */\n+    protected string $class;\n+\n+    /**\n+     * Data structure of methods and arguments to be called on the class after\n+     * instantiation\n+     *\n+     * @var array\n+     */\n+    protected array $methods = [];\n+\n+    /**\n+     * Construct a new class definition\n+     *\n+     * @param string     $key           The class name or key associated with\n+     * @param mixed      $class         The class to define\n+     * @param Depository $depository    The container that the definition is\n+     *                                  contained in\n+     */\n+    public function __construct(string $key, mixed $class, Depository $depository)\n+    {\n+        parent::__construct($key, $depository);\n+\n+        $this->class = $class;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function create(...$arguments)\n+    {\n+        $reflection = new ReflectionClass($this->class);\n+        $object = $reflection->newInstanceArgs(\n+            $this->resolveArguments(...$arguments)\n+        );\n+\n+        return $this->callMethods($object);\n+    }\n+\n+    /**\n+     * Add a method to be called on the class after instantiating a new instance\n+     *\n+     * @param string $method        Name of th emethod\n+     * @param        ...$arguments  Arguments to pass into the method\n+     *\n+     * @return $this    The definition for fluent method chaining\n+     */\n+    public function call(string $method, ...$arguments): this\n+    {\n+        $this->methods[] = [\n+            'method' => $method,\n+            'arguments' => $arguments,\n+        ];\n+\n+        return $this;\n+    }\n+\n+    /**\n+     * After instantiating the instance, this method will call any necessary\n+     * methods on the instance with the specified arguments\n+     *\n+     * @param object $object    The object to call the methods on\n+     *\n+     * @return mixed    The new object instance\n+     */\n+    protected function callMethods($object)","path":"src/Titon/Context/Definition/ClassDefinition.hh","position":92,"original_position":92,"commit_id":"890c0b00e6eceb3a65b46af1621f3e58bdea5b76","original_commit_id":"890c0b00e6eceb3a65b46af1621f3e58bdea5b76","user":{"login":"exonintrendo","id":3135216,"avatar_url":"https://avatars.githubusercontent.com/u/3135216?v=3","gravatar_id":"","url":"https://api.github.com/users/exonintrendo","html_url":"https://github.com/exonintrendo","followers_url":"https://api.github.com/users/exonintrendo/followers","following_url":"https://api.github.com/users/exonintrendo/following{/other_user}","gists_url":"https://api.github.com/users/exonintrendo/gists{/gist_id}","starred_url":"https://api.github.com/users/exonintrendo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exonintrendo/subscriptions","organizations_url":"https://api.github.com/users/exonintrendo/orgs","repos_url":"https://api.github.com/users/exonintrendo/repos","events_url":"https://api.github.com/users/exonintrendo/events{/privacy}","received_events_url":"https://api.github.com/users/exonintrendo/received_events","type":"User","site_admin":false},"body":"Ended up making this ```protected function callMethods<T>(T $object): T```. Let me know if that isn't good practice.","created_at":"2015-02-17T01:34:13Z","updated_at":"2015-02-17T01:34:13Z","html_url":"https://github.com/titon/framework/pull/58#discussion_r24787095","pull_request_url":"https://api.github.com/repos/titon/framework/pulls/58","_links":{"self":{"href":"https://api.github.com/repos/titon/framework/pulls/comments/24787095"},"html":{"href":"https://github.com/titon/framework/pull/58#discussion_r24787095"},"pull_request":{"href":"https://api.github.com/repos/titon/framework/pulls/58"}}},"pull_request":{"url":"https://api.github.com/repos/titon/framework/pulls/58","id":29347818,"html_url":"https://github.com/titon/framework/pull/58","diff_url":"https://github.com/titon/framework/pull/58.diff","patch_url":"https://github.com/titon/framework/pull/58.patch","issue_url":"https://api.github.com/repos/titon/framework/issues/58","number":58,"state":"open","locked":false,"title":"Context package","user":{"login":"exonintrendo","id":3135216,"avatar_url":"https://avatars.githubusercontent.com/u/3135216?v=3","gravatar_id":"","url":"https://api.github.com/users/exonintrendo","html_url":"https://github.com/exonintrendo","followers_url":"https://api.github.com/users/exonintrendo/followers","following_url":"https://api.github.com/users/exonintrendo/following{/other_user}","gists_url":"https://api.github.com/users/exonintrendo/gists{/gist_id}","starred_url":"https://api.github.com/users/exonintrendo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exonintrendo/subscriptions","organizations_url":"https://api.github.com/users/exonintrendo/orgs","repos_url":"https://api.github.com/users/exonintrendo/repos","events_url":"https://api.github.com/users/exonintrendo/events{/privacy}","received_events_url":"https://api.github.com/users/exonintrendo/received_events","type":"User","site_admin":false},"body":"This adds the Context package for dependency injection","created_at":"2015-02-16T03:18:52Z","updated_at":"2015-02-17T01:34:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cd58b57ba2801ffd300f1ec084917109110e27b7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/titon/framework/pulls/58/commits","review_comments_url":"https://api.github.com/repos/titon/framework/pulls/58/comments","review_comment_url":"https://api.github.com/repos/titon/framework/pulls/comments/{number}","comments_url":"https://api.github.com/repos/titon/framework/issues/58/comments","statuses_url":"https://api.github.com/repos/titon/framework/statuses/890c0b00e6eceb3a65b46af1621f3e58bdea5b76","head":{"label":"exonintrendo:context","ref":"context","sha":"890c0b00e6eceb3a65b46af1621f3e58bdea5b76","user":{"login":"exonintrendo","id":3135216,"avatar_url":"https://avatars.githubusercontent.com/u/3135216?v=3","gravatar_id":"","url":"https://api.github.com/users/exonintrendo","html_url":"https://github.com/exonintrendo","followers_url":"https://api.github.com/users/exonintrendo/followers","following_url":"https://api.github.com/users/exonintrendo/following{/other_user}","gists_url":"https://api.github.com/users/exonintrendo/gists{/gist_id}","starred_url":"https://api.github.com/users/exonintrendo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exonintrendo/subscriptions","organizations_url":"https://api.github.com/users/exonintrendo/orgs","repos_url":"https://api.github.com/users/exonintrendo/repos","events_url":"https://api.github.com/users/exonintrendo/events{/privacy}","received_events_url":"https://api.github.com/users/exonintrendo/received_events","type":"User","site_admin":false},"repo":{"id":30048074,"name":"framework","full_name":"exonintrendo/framework","owner":{"login":"exonintrendo","id":3135216,"avatar_url":"https://avatars.githubusercontent.com/u/3135216?v=3","gravatar_id":"","url":"https://api.github.com/users/exonintrendo","html_url":"https://github.com/exonintrendo","followers_url":"https://api.github.com/users/exonintrendo/followers","following_url":"https://api.github.com/users/exonintrendo/following{/other_user}","gists_url":"https://api.github.com/users/exonintrendo/gists{/gist_id}","starred_url":"https://api.github.com/users/exonintrendo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exonintrendo/subscriptions","organizations_url":"https://api.github.com/users/exonintrendo/orgs","repos_url":"https://api.github.com/users/exonintrendo/repos","events_url":"https://api.github.com/users/exonintrendo/events{/privacy}","received_events_url":"https://api.github.com/users/exonintrendo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/exonintrendo/framework","description":"A full-stack Hack framework that runs on HHVM.","fork":true,"url":"https://api.github.com/repos/exonintrendo/framework","forks_url":"https://api.github.com/repos/exonintrendo/framework/forks","keys_url":"https://api.github.com/repos/exonintrendo/framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/exonintrendo/framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/exonintrendo/framework/teams","hooks_url":"https://api.github.com/repos/exonintrendo/framework/hooks","issue_events_url":"https://api.github.com/repos/exonintrendo/framework/issues/events{/number}","events_url":"https://api.github.com/repos/exonintrendo/framework/events","assignees_url":"https://api.github.com/repos/exonintrendo/framework/assignees{/user}","branches_url":"https://api.github.com/repos/exonintrendo/framework/branches{/branch}","tags_url":"https://api.github.com/repos/exonintrendo/framework/tags","blobs_url":"https://api.github.com/repos/exonintrendo/framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/exonintrendo/framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/exonintrendo/framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/exonintrendo/framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/exonintrendo/framework/statuses/{sha}","languages_url":"https://api.github.com/repos/exonintrendo/framework/languages","stargazers_url":"https://api.github.com/repos/exonintrendo/framework/stargazers","contributors_url":"https://api.github.com/repos/exonintrendo/framework/contributors","subscribers_url":"https://api.github.com/repos/exonintrendo/framework/subscribers","subscription_url":"https://api.github.com/repos/exonintrendo/framework/subscription","commits_url":"https://api.github.com/repos/exonintrendo/framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/exonintrendo/framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/exonintrendo/framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/exonintrendo/framework/issues/comments/{number}","contents_url":"https://api.github.com/repos/exonintrendo/framework/contents/{+path}","compare_url":"https://api.github.com/repos/exonintrendo/framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/exonintrendo/framework/merges","archive_url":"https://api.github.com/repos/exonintrendo/framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/exonintrendo/framework/downloads","issues_url":"https://api.github.com/repos/exonintrendo/framework/issues{/number}","pulls_url":"https://api.github.com/repos/exonintrendo/framework/pulls{/number}","milestones_url":"https://api.github.com/repos/exonintrendo/framework/milestones{/number}","notifications_url":"https://api.github.com/repos/exonintrendo/framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/exonintrendo/framework/labels{/name}","releases_url":"https://api.github.com/repos/exonintrendo/framework/releases{/id}","created_at":"2015-01-30T00:15:07Z","updated_at":"2015-01-30T00:15:09Z","pushed_at":"2015-02-16T03:17:08Z","git_url":"git://github.com/exonintrendo/framework.git","ssh_url":"git@github.com:exonintrendo/framework.git","clone_url":"https://github.com/exonintrendo/framework.git","svn_url":"https://github.com/exonintrendo/framework","homepage":"http://titon.io","size":1772,"stargazers_count":0,"watchers_count":0,"language":"Hack","has_issues":false,"has_downloads":true,"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":"master"}},"base":{"label":"titon:master","ref":"master","sha":"ee5e0477cbf09216b09f3260a995041e6bfeb95e","user":{"login":"titon","id":224313,"avatar_url":"https://avatars.githubusercontent.com/u/224313?v=3","gravatar_id":"","url":"https://api.github.com/users/titon","html_url":"https://github.com/titon","followers_url":"https://api.github.com/users/titon/followers","following_url":"https://api.github.com/users/titon/following{/other_user}","gists_url":"https://api.github.com/users/titon/gists{/gist_id}","starred_url":"https://api.github.com/users/titon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/titon/subscriptions","organizations_url":"https://api.github.com/users/titon/orgs","repos_url":"https://api.github.com/users/titon/repos","events_url":"https://api.github.com/users/titon/events{/privacy}","received_events_url":"https://api.github.com/users/titon/received_events","type":"Organization","site_admin":false},"repo":{"id":20363624,"name":"framework","full_name":"titon/framework","owner":{"login":"titon","id":224313,"avatar_url":"https://avatars.githubusercontent.com/u/224313?v=3","gravatar_id":"","url":"https://api.github.com/users/titon","html_url":"https://github.com/titon","followers_url":"https://api.github.com/users/titon/followers","following_url":"https://api.github.com/users/titon/following{/other_user}","gists_url":"https://api.github.com/users/titon/gists{/gist_id}","starred_url":"https://api.github.com/users/titon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/titon/subscriptions","organizations_url":"https://api.github.com/users/titon/orgs","repos_url":"https://api.github.com/users/titon/repos","events_url":"https://api.github.com/users/titon/events{/privacy}","received_events_url":"https://api.github.com/users/titon/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/titon/framework","description":"A full-stack Hack framework that runs on HHVM.","fork":false,"url":"https://api.github.com/repos/titon/framework","forks_url":"https://api.github.com/repos/titon/framework/forks","keys_url":"https://api.github.com/repos/titon/framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/titon/framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/titon/framework/teams","hooks_url":"https://api.github.com/repos/titon/framework/hooks","issue_events_url":"https://api.github.com/repos/titon/framework/issues/events{/number}","events_url":"https://api.github.com/repos/titon/framework/events","assignees_url":"https://api.github.com/repos/titon/framework/assignees{/user}","branches_url":"https://api.github.com/repos/titon/framework/branches{/branch}","tags_url":"https://api.github.com/repos/titon/framework/tags","blobs_url":"https://api.github.com/repos/titon/framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/titon/framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/titon/framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/titon/framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/titon/framework/statuses/{sha}","languages_url":"https://api.github.com/repos/titon/framework/languages","stargazers_url":"https://api.github.com/repos/titon/framework/stargazers","contributors_url":"https://api.github.com/repos/titon/framework/contributors","subscribers_url":"https://api.github.com/repos/titon/framework/subscribers","subscription_url":"https://api.github.com/repos/titon/framework/subscription","commits_url":"https://api.github.com/repos/titon/framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/titon/framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/titon/framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/titon/framework/issues/comments/{number}","contents_url":"https://api.github.com/repos/titon/framework/contents/{+path}","compare_url":"https://api.github.com/repos/titon/framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/titon/framework/merges","archive_url":"https://api.github.com/repos/titon/framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/titon/framework/downloads","issues_url":"https://api.github.com/repos/titon/framework/issues{/number}","pulls_url":"https://api.github.com/repos/titon/framework/pulls{/number}","milestones_url":"https://api.github.com/repos/titon/framework/milestones{/number}","notifications_url":"https://api.github.com/repos/titon/framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/titon/framework/labels{/name}","releases_url":"https://api.github.com/repos/titon/framework/releases{/id}","created_at":"2014-05-31T19:37:47Z","updated_at":"2015-02-16T13:09:48Z","pushed_at":"2015-02-16T07:08:17Z","git_url":"git://github.com/titon/framework.git","ssh_url":"git@github.com:titon/framework.git","clone_url":"https://github.com/titon/framework.git","svn_url":"https://github.com/titon/framework","homepage":"http://titon.io","size":2654,"stargazers_count":107,"watchers_count":107,"language":"Hack","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":2,"forks":7,"open_issues":2,"watchers":107,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/titon/framework/pulls/58"},"html":{"href":"https://github.com/titon/framework/pull/58"},"issue":{"href":"https://api.github.com/repos/titon/framework/issues/58"},"comments":{"href":"https://api.github.com/repos/titon/framework/issues/58/comments"},"review_comments":{"href":"https://api.github.com/repos/titon/framework/pulls/58/comments"},"review_comment":{"href":"https://api.github.com/repos/titon/framework/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/titon/framework/pulls/58/commits"},"statuses":{"href":"https://api.github.com/repos/titon/framework/statuses/890c0b00e6eceb3a65b46af1621f3e58bdea5b76"}}}}