{"action":"created","issue":{"url":"https://api.github.com/repos/glayzzle/php-parser/issues/171","repository_url":"https://api.github.com/repos/glayzzle/php-parser","labels_url":"https://api.github.com/repos/glayzzle/php-parser/issues/171/labels{/name}","comments_url":"https://api.github.com/repos/glayzzle/php-parser/issues/171/comments","events_url":"https://api.github.com/repos/glayzzle/php-parser/issues/171/events","html_url":"https://github.com/glayzzle/php-parser/issues/171","id":351135512,"node_id":"MDU6SXNzdWUzNTExMzU1MTI=","number":171,"title":"Avoid `parenthesis` and `cast` nodes in ast","user":{"login":"evilebottnawi","id":4567934,"node_id":"MDQ6VXNlcjQ1Njc5MzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/4567934?v=4","gravatar_id":"","url":"https://api.github.com/users/evilebottnawi","html_url":"https://github.com/evilebottnawi","followers_url":"https://api.github.com/users/evilebottnawi/followers","following_url":"https://api.github.com/users/evilebottnawi/following{/other_user}","gists_url":"https://api.github.com/users/evilebottnawi/gists{/gist_id}","starred_url":"https://api.github.com/users/evilebottnawi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evilebottnawi/subscriptions","organizations_url":"https://api.github.com/users/evilebottnawi/orgs","repos_url":"https://api.github.com/users/evilebottnawi/repos","events_url":"https://api.github.com/users/evilebottnawi/events{/privacy}","received_events_url":"https://api.github.com/users/evilebottnawi/received_events","type":"User","site_admin":false},"labels":[{"id":509957486,"node_id":"MDU6TGFiZWw1MDk5NTc0ODY=","url":"https://api.github.com/repos/glayzzle/php-parser/labels/AST","name":"AST","color":"c5def5","default":false},{"id":155056625,"node_id":"MDU6TGFiZWwxNTUwNTY2MjU=","url":"https://api.github.com/repos/glayzzle/php-parser/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":{"login":"ichiriac","id":173203,"node_id":"MDQ6VXNlcjE3MzIwMw==","avatar_url":"https://avatars2.githubusercontent.com/u/173203?v=4","gravatar_id":"","url":"https://api.github.com/users/ichiriac","html_url":"https://github.com/ichiriac","followers_url":"https://api.github.com/users/ichiriac/followers","following_url":"https://api.github.com/users/ichiriac/following{/other_user}","gists_url":"https://api.github.com/users/ichiriac/gists{/gist_id}","starred_url":"https://api.github.com/users/ichiriac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ichiriac/subscriptions","organizations_url":"https://api.github.com/users/ichiriac/orgs","repos_url":"https://api.github.com/users/ichiriac/repos","events_url":"https://api.github.com/users/ichiriac/events{/privacy}","received_events_url":"https://api.github.com/users/ichiriac/received_events","type":"User","site_admin":false},"assignees":[{"login":"ichiriac","id":173203,"node_id":"MDQ6VXNlcjE3MzIwMw==","avatar_url":"https://avatars2.githubusercontent.com/u/173203?v=4","gravatar_id":"","url":"https://api.github.com/users/ichiriac","html_url":"https://github.com/ichiriac","followers_url":"https://api.github.com/users/ichiriac/followers","following_url":"https://api.github.com/users/ichiriac/following{/other_user}","gists_url":"https://api.github.com/users/ichiriac/gists{/gist_id}","starred_url":"https://api.github.com/users/ichiriac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ichiriac/subscriptions","organizations_url":"https://api.github.com/users/ichiriac/orgs","repos_url":"https://api.github.com/users/ichiriac/repos","events_url":"https://api.github.com/users/ichiriac/events{/privacy}","received_events_url":"https://api.github.com/users/ichiriac/received_events","type":"User","site_admin":false}],"milestone":null,"comments":6,"created_at":"2018-08-16T09:56:00Z","updated_at":"2018-09-27T11:41:08Z","closed_at":"2018-09-08T21:45:57Z","author_association":"NONE","body":"Example how this do babylon https://astexplorer.net/#/gist/56cf77073a7a8dcc4a785a423c26a1c7/209de623aac9c972645542acfcefdcf67a7bceb1\r\n\r\nWhy? Example from our code (print `return` node):\r\n```js\r\n case \"return\": {\r\n      const parts = [];\r\n\r\n      parts.push(\"return\");\r\n\r\n      if (node.expr) {\r\n        const printedExpr = path.call(print, \"expr\");\r\n\r\n        if (node.expr.kind === \"bin\") {\r\n          parts.push(\r\n            group(\r\n              concat([\r\n                ifBreak(\" (\", \" \"),\r\n                indent(concat([softline, printedExpr])),\r\n                softline,\r\n                ifBreak(\")\")\r\n              ])\r\n            )\r\n          );\r\n        } else {\r\n          parts.push(\" \", printedExpr);\r\n        }\r\n      }\r\n\r\n      if (hasDanglingComments(node)) {\r\n        parts.push(\r\n          \" \",\r\n          comments.printDanglingComments(path, options, /* sameIndent */ true)\r\n        );\r\n      }\r\n\r\n      return concat(parts);\r\n}\r\n```\r\n\r\nLook on `node.expr.kind === \"bin\"`, in some cases people can have `parenthesis` and our check does not works correctly and you will get bad output (ugly). Adding check on `parenthesis` and `parenthesis.inner` can solve this problem, but it is require a lot of code and new checks (in some places it is really a lot of code). Better use logic as in `prettier` for `js`. They have ast without `parenthesis` and print nodes as is and then add parens basic on own logic for `parenthesis` (https://github.com/prettier/prettier/blob/master/src/language-js/needs-parens.js#L43).\r\n\r\nSame for `cast` node.\r\n\r\nAll this would allow us to work in a beautiful form with the ast."},"comment":{"url":"https://api.github.com/repos/glayzzle/php-parser/issues/comments/425058849","html_url":"https://github.com/glayzzle/php-parser/issues/171#issuecomment-425058849","issue_url":"https://api.github.com/repos/glayzzle/php-parser/issues/171","id":425058849,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTA1ODg0OQ==","user":{"login":"evilebottnawi","id":4567934,"node_id":"MDQ6VXNlcjQ1Njc5MzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/4567934?v=4","gravatar_id":"","url":"https://api.github.com/users/evilebottnawi","html_url":"https://github.com/evilebottnawi","followers_url":"https://api.github.com/users/evilebottnawi/followers","following_url":"https://api.github.com/users/evilebottnawi/following{/other_user}","gists_url":"https://api.github.com/users/evilebottnawi/gists{/gist_id}","starred_url":"https://api.github.com/users/evilebottnawi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evilebottnawi/subscriptions","organizations_url":"https://api.github.com/users/evilebottnawi/orgs","repos_url":"https://api.github.com/users/evilebottnawi/repos","events_url":"https://api.github.com/users/evilebottnawi/events{/privacy}","received_events_url":"https://api.github.com/users/evilebottnawi/received_events","type":"User","site_admin":false},"created_at":"2018-09-27T11:41:08Z","updated_at":"2018-09-27T11:41:08Z","author_association":"NONE","body":"@ichiriac can we do same for `silent` node?"}}
{"actor":{"display_login":"evilebottnawi"}}