{"id":20608913,"url":"https://github.com/tpunt/php-ast-reverter","last_synced_at":"2025-04-15T04:24:31.628Z","repository":{"id":57072285,"uuid":"41452390","full_name":"tpunt/php-ast-reverter","owner":"tpunt","description":"Reverts the php-ast AST back into (somewhat) PSR-compliant code","archived":false,"fork":false,"pushed_at":"2018-11-02T08:46:06.000Z","size":66,"stargazers_count":52,"open_issues_count":2,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-28T15:51:49.521Z","etag":null,"topics":["ast","php-ast","pretty-printer"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tpunt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-26T22:12:02.000Z","updated_at":"2025-03-07T20:07:27.000Z","dependencies_parsed_at":"2022-08-24T10:40:53.128Z","dependency_job_id":null,"html_url":"https://github.com/tpunt/php-ast-reverter","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpunt%2Fphp-ast-reverter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpunt%2Fphp-ast-reverter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpunt%2Fphp-ast-reverter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpunt%2Fphp-ast-reverter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tpunt","download_url":"https://codeload.github.com/tpunt/php-ast-reverter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625564,"owners_count":21135518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","php-ast","pretty-printer"],"created_at":"2024-11-16T10:12:13.441Z","updated_at":"2025-04-15T04:24:31.603Z","avatar_url":"https://github.com/tpunt.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-ast-reverter\nA tool that reverts an abstract syntax tree (AST) produced by the\n[php-ast](https://github.com/nikic/php-ast) extension back into (somewhat)\nPSR-compliant code. This enables for code preprocessing to be done.\n\nRequirements:\n - PHP 7.*\n - [php-ast](https://github.com/nikic/php-ast) extension (compatible with\n versions 30, 35, 40, 45, and 50)\n\n## Installation\n\n### Composer\n```\ncomposer require tpunt/php-ast-reverter\n```\n\n## Example\n\nRunning the following code snippet:\n```php\n\u003c?php\n\n$code = \u003c\u003c\u003c'end'\n\u003c?php\n\n/**\n * My testing class\n */\nclass ClassName extends AnotherClass implements AnInterface\n{\n    /**\n     * Some property\n     */\n    private $prop = 0;\n\n    const TEST = 'string';\n\n    use TraitA, TraitB {\n        TraitA::func1 insteadof TraitB;\n        TraitB::func1 as protected func2;\n    }\n\n    /**\n     * Some useless constructor\n     */\n    function __construct(int $arg = 1)\n    {\n        $this-\u003eprop = $arg;\n    }\n}\nend;\n\n$ast = ast\\parse_code($code, $version=40);\n\necho (new AstReverter\\AstReverter)-\u003egetCode($ast);\n```\n\nWill output:\n```php\n\u003c?php\n\n/**\n * My testing class\n */\nclass ClassName extends AnotherClass implements AnInterface\n{\n    /**\n     * Some property\n     */\n    private $prop = 0;\n    const TEST = \"string\";\n    use TraitA, TraitB {\n        TraitA::func1 insteadof TraitB;\n        TraitB::func1 as protected func2;\n    }\n    /**\n     * Some useless constructor\n     */\n    public function __construct(int $arg = 1)\n    {\n        $this-\u003eprop = $arg;\n    }\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpunt%2Fphp-ast-reverter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftpunt%2Fphp-ast-reverter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpunt%2Fphp-ast-reverter/lists"}