{"action":"opened","number":159,"pull_request":{"url":"https://api.github.com/repos/cakephp/bake/pulls/159","id":44270066,"html_url":"https://github.com/cakephp/bake/pull/159","diff_url":"https://github.com/cakephp/bake/pull/159.diff","patch_url":"https://github.com/cakephp/bake/pull/159.patch","issue_url":"https://api.github.com/repos/cakephp/bake/issues/159","number":159,"state":"open","locked":false,"title":"Entity property hints","user":{"login":"ndm2","id":5031606,"avatar_url":"https://avatars.githubusercontent.com/u/5031606?v=3","gravatar_id":"","url":"https://api.github.com/users/ndm2","html_url":"https://github.com/ndm2","followers_url":"https://api.github.com/users/ndm2/followers","following_url":"https://api.github.com/users/ndm2/following{/other_user}","gists_url":"https://api.github.com/users/ndm2/gists{/gist_id}","starred_url":"https://api.github.com/users/ndm2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndm2/subscriptions","organizations_url":"https://api.github.com/users/ndm2/orgs","repos_url":"https://api.github.com/users/ndm2/repos","events_url":"https://api.github.com/users/ndm2/events{/privacy}","received_events_url":"https://api.github.com/users/ndm2/received_events","type":"User","site_admin":false},"body":"This is a first implementation of baking entity property type hints.\r\n\r\nIt includes types for known datbase-types and associations. Custom/Unknown database-types will be ignored for now, as I can't think of any realiable way to figure the possible types.\r\n\r\nProperties that belong to `belongsTo` associations are being inserted after the corresponding foreign key, I thought that might be nice, but I'm not sure if it's really overly useful, since all other association properties will just be appended.\r\n\r\nFor the last two hours I've been stewing over where to put what, and I really couldn't decide, as everything seems to have its pros and cons. For now a property \"schema\" is set for the view, and a bunch of logic goes into the template to build a map of property names and docblock types. Theoretically some of the logic could be moved in the bake helper, this could reduce the code, like\r\n\r\n```php\r\n$properties = [];\r\nif (!empty($propertySchema)) {\r\n    foreach ($propertySchema as $property => $info) {\r\n        switch ($info['kind']) {\r\n            case 'column':\r\n                $properties[$property] = $this->Bake->columnTypeToDocType($info['type']);\r\n                break;\r\n\r\n            case 'association':\r\n                $type = $this->Bake->entityTypeToDocType($info['type'], $info['association']);\r\n\t\t\t\tif ($info['association']->type() === Association::MANY_TO_ONE) {\r\n                    $property = $info['association']->property();\r\n                    $index = array_search($info['association']->foreignKey(), array_keys($properties));\r\n                    if ($index !== false) {\r\n                        $properties = array_merge(\r\n                            array_slice($properties, 0, $index + 1),\r\n                            [$property => $type],\r\n                            array_slice($properties, $index + 1, null)\r\n                        );\r\n                    } else {\r\n                        $properties[$property] = $type;\r\n                    }\r\n                } else {\r\n                    $properties[$property] = $type;\r\n                }\r\n                break;\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nand ditching the \"insert after foreign key\" feature for `belongsTo` associations would reduce the code to a minimum.\r\n\r\nOn the other hand this seems all very tightly entity docblock related, so having this in the global helper feels kinda akward. Moving everything into the task would also be an option, but again I'm not sure whether this would really be of any use outside of the entity view template...\r\n\r\nThe struggle is real  :cold_sweat:","created_at":"2015-09-04T23:19:49Z","updated_at":"2015-09-04T23:19:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cakephp/bake/pulls/159/commits","review_comments_url":"https://api.github.com/repos/cakephp/bake/pulls/159/comments","review_comment_url":"https://api.github.com/repos/cakephp/bake/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cakephp/bake/issues/159/comments","statuses_url":"https://api.github.com/repos/cakephp/bake/statuses/7490f9152c35173c635280322df981258a1f2102","head":{"label":"ndm2:entity-property-hints","ref":"entity-property-hints","sha":"7490f9152c35173c635280322df981258a1f2102","user":{"login":"ndm2","id":5031606,"avatar_url":"https://avatars.githubusercontent.com/u/5031606?v=3","gravatar_id":"","url":"https://api.github.com/users/ndm2","html_url":"https://github.com/ndm2","followers_url":"https://api.github.com/users/ndm2/followers","following_url":"https://api.github.com/users/ndm2/following{/other_user}","gists_url":"https://api.github.com/users/ndm2/gists{/gist_id}","starred_url":"https://api.github.com/users/ndm2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndm2/subscriptions","organizations_url":"https://api.github.com/users/ndm2/orgs","repos_url":"https://api.github.com/users/ndm2/repos","events_url":"https://api.github.com/users/ndm2/events{/privacy}","received_events_url":"https://api.github.com/users/ndm2/received_events","type":"User","site_admin":false},"repo":{"id":36578934,"name":"bake","full_name":"ndm2/bake","owner":{"login":"ndm2","id":5031606,"avatar_url":"https://avatars.githubusercontent.com/u/5031606?v=3","gravatar_id":"","url":"https://api.github.com/users/ndm2","html_url":"https://github.com/ndm2","followers_url":"https://api.github.com/users/ndm2/followers","following_url":"https://api.github.com/users/ndm2/following{/other_user}","gists_url":"https://api.github.com/users/ndm2/gists{/gist_id}","starred_url":"https://api.github.com/users/ndm2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndm2/subscriptions","organizations_url":"https://api.github.com/users/ndm2/orgs","repos_url":"https://api.github.com/users/ndm2/repos","events_url":"https://api.github.com/users/ndm2/events{/privacy}","received_events_url":"https://api.github.com/users/ndm2/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ndm2/bake","description":"The Bake Command Plugin","fork":true,"url":"https://api.github.com/repos/ndm2/bake","forks_url":"https://api.github.com/repos/ndm2/bake/forks","keys_url":"https://api.github.com/repos/ndm2/bake/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ndm2/bake/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ndm2/bake/teams","hooks_url":"https://api.github.com/repos/ndm2/bake/hooks","issue_events_url":"https://api.github.com/repos/ndm2/bake/issues/events{/number}","events_url":"https://api.github.com/repos/ndm2/bake/events","assignees_url":"https://api.github.com/repos/ndm2/bake/assignees{/user}","branches_url":"https://api.github.com/repos/ndm2/bake/branches{/branch}","tags_url":"https://api.github.com/repos/ndm2/bake/tags","blobs_url":"https://api.github.com/repos/ndm2/bake/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ndm2/bake/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ndm2/bake/git/refs{/sha}","trees_url":"https://api.github.com/repos/ndm2/bake/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ndm2/bake/statuses/{sha}","languages_url":"https://api.github.com/repos/ndm2/bake/languages","stargazers_url":"https://api.github.com/repos/ndm2/bake/stargazers","contributors_url":"https://api.github.com/repos/ndm2/bake/contributors","subscribers_url":"https://api.github.com/repos/ndm2/bake/subscribers","subscription_url":"https://api.github.com/repos/ndm2/bake/subscription","commits_url":"https://api.github.com/repos/ndm2/bake/commits{/sha}","git_commits_url":"https://api.github.com/repos/ndm2/bake/git/commits{/sha}","comments_url":"https://api.github.com/repos/ndm2/bake/comments{/number}","issue_comment_url":"https://api.github.com/repos/ndm2/bake/issues/comments{/number}","contents_url":"https://api.github.com/repos/ndm2/bake/contents/{+path}","compare_url":"https://api.github.com/repos/ndm2/bake/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ndm2/bake/merges","archive_url":"https://api.github.com/repos/ndm2/bake/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ndm2/bake/downloads","issues_url":"https://api.github.com/repos/ndm2/bake/issues{/number}","pulls_url":"https://api.github.com/repos/ndm2/bake/pulls{/number}","milestones_url":"https://api.github.com/repos/ndm2/bake/milestones{/number}","notifications_url":"https://api.github.com/repos/ndm2/bake/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ndm2/bake/labels{/name}","releases_url":"https://api.github.com/repos/ndm2/bake/releases{/id}","created_at":"2015-05-30T22:59:09Z","updated_at":"2015-05-30T22:59:10Z","pushed_at":"2015-09-04T23:13:26Z","git_url":"git://github.com/ndm2/bake.git","ssh_url":"git@github.com:ndm2/bake.git","clone_url":"https://github.com/ndm2/bake.git","svn_url":"https://github.com/ndm2/bake","homepage":null,"size":3835,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"cakephp:master","ref":"master","sha":"2567b5f686305970630c46afb3d4d7bf990c0a32","user":{"login":"cakephp","id":23666,"avatar_url":"https://avatars.githubusercontent.com/u/23666?v=3","gravatar_id":"","url":"https://api.github.com/users/cakephp","html_url":"https://github.com/cakephp","followers_url":"https://api.github.com/users/cakephp/followers","following_url":"https://api.github.com/users/cakephp/following{/other_user}","gists_url":"https://api.github.com/users/cakephp/gists{/gist_id}","starred_url":"https://api.github.com/users/cakephp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cakephp/subscriptions","organizations_url":"https://api.github.com/users/cakephp/orgs","repos_url":"https://api.github.com/users/cakephp/repos","events_url":"https://api.github.com/users/cakephp/events{/privacy}","received_events_url":"https://api.github.com/users/cakephp/received_events","type":"Organization","site_admin":false},"repo":{"id":27730883,"name":"bake","full_name":"cakephp/bake","owner":{"login":"cakephp","id":23666,"avatar_url":"https://avatars.githubusercontent.com/u/23666?v=3","gravatar_id":"","url":"https://api.github.com/users/cakephp","html_url":"https://github.com/cakephp","followers_url":"https://api.github.com/users/cakephp/followers","following_url":"https://api.github.com/users/cakephp/following{/other_user}","gists_url":"https://api.github.com/users/cakephp/gists{/gist_id}","starred_url":"https://api.github.com/users/cakephp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cakephp/subscriptions","organizations_url":"https://api.github.com/users/cakephp/orgs","repos_url":"https://api.github.com/users/cakephp/repos","events_url":"https://api.github.com/users/cakephp/events{/privacy}","received_events_url":"https://api.github.com/users/cakephp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cakephp/bake","description":"The Bake Command Plugin","fork":false,"url":"https://api.github.com/repos/cakephp/bake","forks_url":"https://api.github.com/repos/cakephp/bake/forks","keys_url":"https://api.github.com/repos/cakephp/bake/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cakephp/bake/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cakephp/bake/teams","hooks_url":"https://api.github.com/repos/cakephp/bake/hooks","issue_events_url":"https://api.github.com/repos/cakephp/bake/issues/events{/number}","events_url":"https://api.github.com/repos/cakephp/bake/events","assignees_url":"https://api.github.com/repos/cakephp/bake/assignees{/user}","branches_url":"https://api.github.com/repos/cakephp/bake/branches{/branch}","tags_url":"https://api.github.com/repos/cakephp/bake/tags","blobs_url":"https://api.github.com/repos/cakephp/bake/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cakephp/bake/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cakephp/bake/git/refs{/sha}","trees_url":"https://api.github.com/repos/cakephp/bake/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cakephp/bake/statuses/{sha}","languages_url":"https://api.github.com/repos/cakephp/bake/languages","stargazers_url":"https://api.github.com/repos/cakephp/bake/stargazers","contributors_url":"https://api.github.com/repos/cakephp/bake/contributors","subscribers_url":"https://api.github.com/repos/cakephp/bake/subscribers","subscription_url":"https://api.github.com/repos/cakephp/bake/subscription","commits_url":"https://api.github.com/repos/cakephp/bake/commits{/sha}","git_commits_url":"https://api.github.com/repos/cakephp/bake/git/commits{/sha}","comments_url":"https://api.github.com/repos/cakephp/bake/comments{/number}","issue_comment_url":"https://api.github.com/repos/cakephp/bake/issues/comments{/number}","contents_url":"https://api.github.com/repos/cakephp/bake/contents/{+path}","compare_url":"https://api.github.com/repos/cakephp/bake/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cakephp/bake/merges","archive_url":"https://api.github.com/repos/cakephp/bake/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cakephp/bake/downloads","issues_url":"https://api.github.com/repos/cakephp/bake/issues{/number}","pulls_url":"https://api.github.com/repos/cakephp/bake/pulls{/number}","milestones_url":"https://api.github.com/repos/cakephp/bake/milestones{/number}","notifications_url":"https://api.github.com/repos/cakephp/bake/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cakephp/bake/labels{/name}","releases_url":"https://api.github.com/repos/cakephp/bake/releases{/id}","created_at":"2014-12-08T19:22:54Z","updated_at":"2015-09-01T01:53:06Z","pushed_at":"2015-09-04T01:34:04Z","git_url":"git://github.com/cakephp/bake.git","ssh_url":"git@github.com:cakephp/bake.git","clone_url":"https://github.com/cakephp/bake.git","svn_url":"https://github.com/cakephp/bake","homepage":null,"size":51291,"stargazers_count":29,"watchers_count":29,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":15,"forks":28,"open_issues":15,"watchers":29,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cakephp/bake/pulls/159"},"html":{"href":"https://github.com/cakephp/bake/pull/159"},"issue":{"href":"https://api.github.com/repos/cakephp/bake/issues/159"},"comments":{"href":"https://api.github.com/repos/cakephp/bake/issues/159/comments"},"review_comments":{"href":"https://api.github.com/repos/cakephp/bake/pulls/159/comments"},"review_comment":{"href":"https://api.github.com/repos/cakephp/bake/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cakephp/bake/pulls/159/commits"},"statuses":{"href":"https://api.github.com/repos/cakephp/bake/statuses/7490f9152c35173c635280322df981258a1f2102"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":2,"additions":249,"deletions":0,"changed_files":4}}