{"action":"created","issue":{"url":"https://api.github.com/repos/nikic/php-ast/issues/5","repository_url":"https://api.github.com/repos/nikic/php-ast","labels_url":"https://api.github.com/repos/nikic/php-ast/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/nikic/php-ast/issues/5/comments","events_url":"https://api.github.com/repos/nikic/php-ast/issues/5/events","html_url":"https://github.com/nikic/php-ast/issues/5","id":56673291,"number":5,"title":"Include this extension in the PHP core and provide a hook API","user":{"login":"lisachenko","id":640114,"avatar_url":"https://avatars.githubusercontent.com/u/640114?v=3","gravatar_id":"","url":"https://api.github.com/users/lisachenko","html_url":"https://github.com/lisachenko","followers_url":"https://api.github.com/users/lisachenko/followers","following_url":"https://api.github.com/users/lisachenko/following{/other_user}","gists_url":"https://api.github.com/users/lisachenko/gists{/gist_id}","starred_url":"https://api.github.com/users/lisachenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lisachenko/subscriptions","organizations_url":"https://api.github.com/users/lisachenko/orgs","repos_url":"https://api.github.com/users/lisachenko/repos","events_url":"https://api.github.com/users/lisachenko/events{/privacy}","received_events_url":"https://api.github.com/users/lisachenko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-02-05T13:59:56Z","updated_at":"2016-03-15T05:41:34Z","closed_at":null,"body":"I want to suggest to include this extension into the core to provide an API for miscellaneous userland extensions. Main idea is to give a userland code control over the produced source-code. \r\n\r\nChain is following: Source Code => Tokenizer => AST => Engine hooks+PHP userland hooks => Compiler => Opcodes => Execution\r\n\r\nWhy it can be a great thing: native source-code AST (static analyzers, code beautifiers), language extensions (AOP, DbC, SQL-like native syntax). \r\n\r\nThis requires to create an userland-function, probably, `register_parser_extension(ParserExtensionInterface $extension)` that will add an extension as parser hook.\r\n\r\nNext additional thing is `ParserExtensionInterface` interface with `process(Node $node)` method that will receive `ast\\Node` class and should return a modified node or tree.\r\n\r\nEach registered extension will be called consequently, allowing to transform the source code. Last result will be used by compiler to generate final version of opcodes.  "},"comment":{"url":"https://api.github.com/repos/nikic/php-ast/issues/comments/196674238","html_url":"https://github.com/nikic/php-ast/issues/5#issuecomment-196674238","issue_url":"https://api.github.com/repos/nikic/php-ast/issues/5","id":196674238,"user":{"login":"jansor","id":1769830,"avatar_url":"https://avatars.githubusercontent.com/u/1769830?v=3","gravatar_id":"","url":"https://api.github.com/users/jansor","html_url":"https://github.com/jansor","followers_url":"https://api.github.com/users/jansor/followers","following_url":"https://api.github.com/users/jansor/following{/other_user}","gists_url":"https://api.github.com/users/jansor/gists{/gist_id}","starred_url":"https://api.github.com/users/jansor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jansor/subscriptions","organizations_url":"https://api.github.com/users/jansor/orgs","repos_url":"https://api.github.com/users/jansor/repos","events_url":"https://api.github.com/users/jansor/events{/privacy}","received_events_url":"https://api.github.com/users/jansor/received_events","type":"User","site_admin":false},"created_at":"2016-03-15T05:41:34Z","updated_at":"2016-03-15T05:41:34Z","body":"+1"}}