{"action":"created","comment":{"url":"https://api.github.com/repos/zendframework/zend-di/pulls/comments/216669043","pull_request_review_id":154197970,"id":216669043,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNjY2OTA0Mw==","diff_hunk":"@@ -90,39 +97,46 @@ public function __construct(\n         $this->logger = $logger ?? new NullLogger();\n     }\n \n-    /**\n-     * Generate injector\n-     *\n-     * @param array $factories\n-     */\n-    private function generateInjector(array $factories)\n+    private function buildFromTemplate(string $templateFile, string $outputFile, array $replacements) : void\n     {\n-        $listFile = new FileGenerator();\n-        $listFile->setFilename($this->outputDirectory . '/factories.php')\n-            ->setDocBlock(new DocBlockGenerator('AUTO GENERATED FACTORY LIST'))\n-            ->setBody('return ' . var_export($factories, true) . ';');\n+        $template = file_get_contents($templateFile);\n+        $code = strtr($template, $replacements);\n+        $file = new SplFileObject($outputFile, 'w');\n \n-        $class = new ClassGenerator('GeneratedInjector', $this->namespace);\n-        $classFile = new FileGenerator();\n+        $file->fwrite($code);\n+        $file->fflush();\n+    }\n \n-        $loadFactoryCode = '$this->factories = require __DIR__ . \\'/factories.php\\';';\n-        $class->setExtendedClass('\\\\' . AbstractInjector::class)\n-            ->addMethod('loadFactoryList', [], MethodGenerator::FLAG_PUBLIC, $loadFactoryCode);\n+    private function generateInjector() : void\n+    {\n+        $file = $this->outputDirectory . '/GeneratedInjector.php';\n+        $replacements = [\n+            '%namespace%' => $this->namespace ? \"namespace {$this->namespace};\\n\" : '',\n+        ];\n \n-        $classFile->setFilename($this->outputDirectory . '/GeneratedInjector.php')\n-            ->setDocBlock(new DocBlockGenerator('AUTO GENERATED DEPENDENCY INJECTOR'))\n-            ->setNamespace($class->getNamespaceName())\n-            ->setClass($class);\n+        $this->buildFromTemplate(self::INJECTOR_TEMPLATE, $file, $replacements);\n+    }\n \n-        $listFile->write();\n-        $classFile->write();\n+    private function generateFactoryList(array $factories) : void\n+    {\n+        $file = $this->outputDirectory . '/factories.php';\n+        $indent = str_repeat(' ', 4);\n+        $codeLines = array_map(\n+            function (string $key, string $value) : string {\n+                return var_export($key, true) . ' => ' . var_export($value, true) . ',';","path":"src/CodeGenerator/InjectorGenerator.php","position":89,"original_position":89,"commit_id":"d2d83289610f91fd464fffeb5ce9f55b28a3f420","original_commit_id":"d2d83289610f91fd464fffeb5ce9f55b28a3f420","user":{"login":"weierophinney","id":25943,"node_id":"MDQ6VXNlcjI1OTQz","avatar_url":"https://avatars1.githubusercontent.com/u/25943?v=4","gravatar_id":"","url":"https://api.github.com/users/weierophinney","html_url":"https://github.com/weierophinney","followers_url":"https://api.github.com/users/weierophinney/followers","following_url":"https://api.github.com/users/weierophinney/following{/other_user}","gists_url":"https://api.github.com/users/weierophinney/gists{/gist_id}","starred_url":"https://api.github.com/users/weierophinney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weierophinney/subscriptions","organizations_url":"https://api.github.com/users/weierophinney/orgs","repos_url":"https://api.github.com/users/weierophinney/repos","events_url":"https://api.github.com/users/weierophinney/events{/privacy}","received_events_url":"https://api.github.com/users/weierophinney/received_events","type":"User","site_admin":false},"body":"Same comment I had on a previous class - use `sprintf()` here to make it more clear that you're returning a string, vs yielding a key/value pair.","created_at":"2018-09-11T13:30:46Z","updated_at":"2018-09-11T13:45:18Z","html_url":"https://github.com/zendframework/zend-di/pull/38#discussion_r216669043","pull_request_url":"https://api.github.com/repos/zendframework/zend-di/pulls/38","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/zendframework/zend-di/pulls/comments/216669043"},"html":{"href":"https://github.com/zendframework/zend-di/pull/38#discussion_r216669043"},"pull_request":{"href":"https://api.github.com/repos/zendframework/zend-di/pulls/38"}}},"pull_request":{"url":"https://api.github.com/repos/zendframework/zend-di/pulls/38","id":211725655,"node_id":"MDExOlB1bGxSZXF1ZXN0MjExNzI1NjU1","html_url":"https://github.com/zendframework/zend-di/pull/38","diff_url":"https://github.com/zendframework/zend-di/pull/38.diff","patch_url":"https://github.com/zendframework/zend-di/pull/38.patch","issue_url":"https://api.github.com/repos/zendframework/zend-di/issues/38","number":38,"state":"open","locked":false,"title":"Improve code quality","user":{"login":"tux-rampage","id":558326,"node_id":"MDQ6VXNlcjU1ODMyNg==","avatar_url":"https://avatars3.githubusercontent.com/u/558326?v=4","gravatar_id":"","url":"https://api.github.com/users/tux-rampage","html_url":"https://github.com/tux-rampage","followers_url":"https://api.github.com/users/tux-rampage/followers","following_url":"https://api.github.com/users/tux-rampage/following{/other_user}","gists_url":"https://api.github.com/users/tux-rampage/gists{/gist_id}","starred_url":"https://api.github.com/users/tux-rampage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tux-rampage/subscriptions","organizations_url":"https://api.github.com/users/tux-rampage/orgs","repos_url":"https://api.github.com/users/tux-rampage/repos","events_url":"https://api.github.com/users/tux-rampage/events{/privacy}","received_events_url":"https://api.github.com/users/tux-rampage/received_events","type":"User","site_admin":false},"body":"This PR intends to provide the following QA improvements:\r\n\r\n- [x] Increase Test-Coverage (Missing tests)\r\n- [x] Make resolved type/value injections immutable\r\n  - Setters/Getters are not needed, the whole property name is not needed at all\r\n  - Provide `toValue()` to obtain the value to inject\r\n- [x] Create an interface for type/value injection to get rid of too complex `instanceof` checks\r\n- [x] Generate PHP 7.1+ code\r\n\r\nI will add comments to the diff to clarify my indentations \r\n\r\n- [x] Is this related to quality assurance?\r\n\r\n## TODOs:\r\n\r\n - [x] Update documentation\r\n - [x] Add `CHANGELOG.md` entries","created_at":"2018-08-29T11:53:05Z","updated_at":"2018-09-11T13:45:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"95b6aa9715ad18d386f7c39683c239eb2dc6cbad","assignee":{"login":"tux-rampage","id":558326,"node_id":"MDQ6VXNlcjU1ODMyNg==","avatar_url":"https://avatars3.githubusercontent.com/u/558326?v=4","gravatar_id":"","url":"https://api.github.com/users/tux-rampage","html_url":"https://github.com/tux-rampage","followers_url":"https://api.github.com/users/tux-rampage/followers","following_url":"https://api.github.com/users/tux-rampage/following{/other_user}","gists_url":"https://api.github.com/users/tux-rampage/gists{/gist_id}","starred_url":"https://api.github.com/users/tux-rampage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tux-rampage/subscriptions","organizations_url":"https://api.github.com/users/tux-rampage/orgs","repos_url":"https://api.github.com/users/tux-rampage/repos","events_url":"https://api.github.com/users/tux-rampage/events{/privacy}","received_events_url":"https://api.github.com/users/tux-rampage/received_events","type":"User","site_admin":false},"assignees":[{"login":"tux-rampage","id":558326,"node_id":"MDQ6VXNlcjU1ODMyNg==","avatar_url":"https://avatars3.githubusercontent.com/u/558326?v=4","gravatar_id":"","url":"https://api.github.com/users/tux-rampage","html_url":"https://github.com/tux-rampage","followers_url":"https://api.github.com/users/tux-rampage/followers","following_url":"https://api.github.com/users/tux-rampage/following{/other_user}","gists_url":"https://api.github.com/users/tux-rampage/gists{/gist_id}","starred_url":"https://api.github.com/users/tux-rampage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tux-rampage/subscriptions","organizations_url":"https://api.github.com/users/tux-rampage/orgs","repos_url":"https://api.github.com/users/tux-rampage/repos","events_url":"https://api.github.com/users/tux-rampage/events{/privacy}","received_events_url":"https://api.github.com/users/tux-rampage/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":219339192,"node_id":"MDU6TGFiZWwyMTkzMzkxOTI=","url":"https://api.github.com/repos/zendframework/zend-di/labels/WIP","name":"WIP","color":"0b02e1","default":false},{"id":209128062,"node_id":"MDU6TGFiZWwyMDkxMjgwNjI=","url":"https://api.github.com/repos/zendframework/zend-di/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":812524105,"node_id":"MDU6TGFiZWw4MTI1MjQxMDU=","url":"https://api.github.com/repos/zendframework/zend-di/labels/review","name":"review","color":"fef2c0","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/zendframework/zend-di/pulls/38/commits","review_comments_url":"https://api.github.com/repos/zendframework/zend-di/pulls/38/comments","review_comment_url":"https://api.github.com/repos/zendframework/zend-di/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zendframework/zend-di/issues/38/comments","statuses_url":"https://api.github.com/repos/zendframework/zend-di/statuses/d2d83289610f91fd464fffeb5ce9f55b28a3f420","head":{"label":"tux-rampage:code-quality","ref":"code-quality","sha":"d2d83289610f91fd464fffeb5ce9f55b28a3f420","user":{"login":"tux-rampage","id":558326,"node_id":"MDQ6VXNlcjU1ODMyNg==","avatar_url":"https://avatars3.githubusercontent.com/u/558326?v=4","gravatar_id":"","url":"https://api.github.com/users/tux-rampage","html_url":"https://github.com/tux-rampage","followers_url":"https://api.github.com/users/tux-rampage/followers","following_url":"https://api.github.com/users/tux-rampage/following{/other_user}","gists_url":"https://api.github.com/users/tux-rampage/gists{/gist_id}","starred_url":"https://api.github.com/users/tux-rampage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tux-rampage/subscriptions","organizations_url":"https://api.github.com/users/tux-rampage/orgs","repos_url":"https://api.github.com/users/tux-rampage/repos","events_url":"https://api.github.com/users/tux-rampage/events{/privacy}","received_events_url":"https://api.github.com/users/tux-rampage/received_events","type":"User","site_admin":false},"repo":{"id":39972205,"node_id":"MDEwOlJlcG9zaXRvcnkzOTk3MjIwNQ==","name":"zend-di","full_name":"tux-rampage/zend-di","owner":{"login":"tux-rampage","id":558326,"node_id":"MDQ6VXNlcjU1ODMyNg==","avatar_url":"https://avatars3.githubusercontent.com/u/558326?v=4","gravatar_id":"","url":"https://api.github.com/users/tux-rampage","html_url":"https://github.com/tux-rampage","followers_url":"https://api.github.com/users/tux-rampage/followers","following_url":"https://api.github.com/users/tux-rampage/following{/other_user}","gists_url":"https://api.github.com/users/tux-rampage/gists{/gist_id}","starred_url":"https://api.github.com/users/tux-rampage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tux-rampage/subscriptions","organizations_url":"https://api.github.com/users/tux-rampage/orgs","repos_url":"https://api.github.com/users/tux-rampage/repos","events_url":"https://api.github.com/users/tux-rampage/events{/privacy}","received_events_url":"https://api.github.com/users/tux-rampage/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tux-rampage/zend-di","description":"Di component from Zend Framework","fork":true,"url":"https://api.github.com/repos/tux-rampage/zend-di","forks_url":"https://api.github.com/repos/tux-rampage/zend-di/forks","keys_url":"https://api.github.com/repos/tux-rampage/zend-di/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tux-rampage/zend-di/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tux-rampage/zend-di/teams","hooks_url":"https://api.github.com/repos/tux-rampage/zend-di/hooks","issue_events_url":"https://api.github.com/repos/tux-rampage/zend-di/issues/events{/number}","events_url":"https://api.github.com/repos/tux-rampage/zend-di/events","assignees_url":"https://api.github.com/repos/tux-rampage/zend-di/assignees{/user}","branches_url":"https://api.github.com/repos/tux-rampage/zend-di/branches{/branch}","tags_url":"https://api.github.com/repos/tux-rampage/zend-di/tags","blobs_url":"https://api.github.com/repos/tux-rampage/zend-di/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tux-rampage/zend-di/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tux-rampage/zend-di/git/refs{/sha}","trees_url":"https://api.github.com/repos/tux-rampage/zend-di/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tux-rampage/zend-di/statuses/{sha}","languages_url":"https://api.github.com/repos/tux-rampage/zend-di/languages","stargazers_url":"https://api.github.com/repos/tux-rampage/zend-di/stargazers","contributors_url":"https://api.github.com/repos/tux-rampage/zend-di/contributors","subscribers_url":"https://api.github.com/repos/tux-rampage/zend-di/subscribers","subscription_url":"https://api.github.com/repos/tux-rampage/zend-di/subscription","commits_url":"https://api.github.com/repos/tux-rampage/zend-di/commits{/sha}","git_commits_url":"https://api.github.com/repos/tux-rampage/zend-di/git/commits{/sha}","comments_url":"https://api.github.com/repos/tux-rampage/zend-di/comments{/number}","issue_comment_url":"https://api.github.com/repos/tux-rampage/zend-di/issues/comments{/number}","contents_url":"https://api.github.com/repos/tux-rampage/zend-di/contents/{+path}","compare_url":"https://api.github.com/repos/tux-rampage/zend-di/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tux-rampage/zend-di/merges","archive_url":"https://api.github.com/repos/tux-rampage/zend-di/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tux-rampage/zend-di/downloads","issues_url":"https://api.github.com/repos/tux-rampage/zend-di/issues{/number}","pulls_url":"https://api.github.com/repos/tux-rampage/zend-di/pulls{/number}","milestones_url":"https://api.github.com/repos/tux-rampage/zend-di/milestones{/number}","notifications_url":"https://api.github.com/repos/tux-rampage/zend-di/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tux-rampage/zend-di/labels{/name}","releases_url":"https://api.github.com/repos/tux-rampage/zend-di/releases{/id}","deployments_url":"https://api.github.com/repos/tux-rampage/zend-di/deployments","created_at":"2015-07-30T20:58:33Z","updated_at":"2018-09-05T21:33:09Z","pushed_at":"2018-09-11T10:53:17Z","git_url":"git://github.com/tux-rampage/zend-di.git","ssh_url":"git@github.com:tux-rampage/zend-di.git","clone_url":"https://github.com/tux-rampage/zend-di.git","svn_url":"https://github.com/tux-rampage/zend-di","homepage":"https://github.com/zendframework/zf2","size":2645,"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":1,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"zendframework:develop","ref":"develop","sha":"753457e39b32b9e2deb56b957e1c5860def27650","user":{"login":"zendframework","id":296074,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5NjA3NA==","avatar_url":"https://avatars2.githubusercontent.com/u/296074?v=4","gravatar_id":"","url":"https://api.github.com/users/zendframework","html_url":"https://github.com/zendframework","followers_url":"https://api.github.com/users/zendframework/followers","following_url":"https://api.github.com/users/zendframework/following{/other_user}","gists_url":"https://api.github.com/users/zendframework/gists{/gist_id}","starred_url":"https://api.github.com/users/zendframework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendframework/subscriptions","organizations_url":"https://api.github.com/users/zendframework/orgs","repos_url":"https://api.github.com/users/zendframework/repos","events_url":"https://api.github.com/users/zendframework/events{/privacy}","received_events_url":"https://api.github.com/users/zendframework/received_events","type":"Organization","site_admin":false},"repo":{"id":35280794,"node_id":"MDEwOlJlcG9zaXRvcnkzNTI4MDc5NA==","name":"zend-di","full_name":"zendframework/zend-di","owner":{"login":"zendframework","id":296074,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5NjA3NA==","avatar_url":"https://avatars2.githubusercontent.com/u/296074?v=4","gravatar_id":"","url":"https://api.github.com/users/zendframework","html_url":"https://github.com/zendframework","followers_url":"https://api.github.com/users/zendframework/followers","following_url":"https://api.github.com/users/zendframework/following{/other_user}","gists_url":"https://api.github.com/users/zendframework/gists{/gist_id}","starred_url":"https://api.github.com/users/zendframework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendframework/subscriptions","organizations_url":"https://api.github.com/users/zendframework/orgs","repos_url":"https://api.github.com/users/zendframework/repos","events_url":"https://api.github.com/users/zendframework/events{/privacy}","received_events_url":"https://api.github.com/users/zendframework/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendframework/zend-di","description":"Di component from Zend Framework","fork":false,"url":"https://api.github.com/repos/zendframework/zend-di","forks_url":"https://api.github.com/repos/zendframework/zend-di/forks","keys_url":"https://api.github.com/repos/zendframework/zend-di/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendframework/zend-di/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendframework/zend-di/teams","hooks_url":"https://api.github.com/repos/zendframework/zend-di/hooks","issue_events_url":"https://api.github.com/repos/zendframework/zend-di/issues/events{/number}","events_url":"https://api.github.com/repos/zendframework/zend-di/events","assignees_url":"https://api.github.com/repos/zendframework/zend-di/assignees{/user}","branches_url":"https://api.github.com/repos/zendframework/zend-di/branches{/branch}","tags_url":"https://api.github.com/repos/zendframework/zend-di/tags","blobs_url":"https://api.github.com/repos/zendframework/zend-di/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendframework/zend-di/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendframework/zend-di/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendframework/zend-di/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendframework/zend-di/statuses/{sha}","languages_url":"https://api.github.com/repos/zendframework/zend-di/languages","stargazers_url":"https://api.github.com/repos/zendframework/zend-di/stargazers","contributors_url":"https://api.github.com/repos/zendframework/zend-di/contributors","subscribers_url":"https://api.github.com/repos/zendframework/zend-di/subscribers","subscription_url":"https://api.github.com/repos/zendframework/zend-di/subscription","commits_url":"https://api.github.com/repos/zendframework/zend-di/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendframework/zend-di/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendframework/zend-di/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendframework/zend-di/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendframework/zend-di/contents/{+path}","compare_url":"https://api.github.com/repos/zendframework/zend-di/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendframework/zend-di/merges","archive_url":"https://api.github.com/repos/zendframework/zend-di/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendframework/zend-di/downloads","issues_url":"https://api.github.com/repos/zendframework/zend-di/issues{/number}","pulls_url":"https://api.github.com/repos/zendframework/zend-di/pulls{/number}","milestones_url":"https://api.github.com/repos/zendframework/zend-di/milestones{/number}","notifications_url":"https://api.github.com/repos/zendframework/zend-di/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendframework/zend-di/labels{/name}","releases_url":"https://api.github.com/repos/zendframework/zend-di/releases{/id}","deployments_url":"https://api.github.com/repos/zendframework/zend-di/deployments","created_at":"2015-05-08T13:27:55Z","updated_at":"2018-08-01T19:49:58Z","pushed_at":"2018-09-11T10:53:18Z","git_url":"git://github.com/zendframework/zend-di.git","ssh_url":"git@github.com:zendframework/zend-di.git","clone_url":"https://github.com/zendframework/zend-di.git","svn_url":"https://github.com/zendframework/zend-di","homepage":"https://docs.zendframework.com/zend-di/","size":3780,"stargazers_count":23,"watchers_count":23,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":22,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":22,"open_issues":2,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zendframework/zend-di/pulls/38"},"html":{"href":"https://github.com/zendframework/zend-di/pull/38"},"issue":{"href":"https://api.github.com/repos/zendframework/zend-di/issues/38"},"comments":{"href":"https://api.github.com/repos/zendframework/zend-di/issues/38/comments"},"review_comments":{"href":"https://api.github.com/repos/zendframework/zend-di/pulls/38/comments"},"review_comment":{"href":"https://api.github.com/repos/zendframework/zend-di/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zendframework/zend-di/pulls/38/commits"},"statuses":{"href":"https://api.github.com/repos/zendframework/zend-di/statuses/d2d83289610f91fd464fffeb5ce9f55b28a3f420"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"weierophinney"}}