All Projects → tpunt → php-ast-reverter

tpunt / php-ast-reverter

Licence: MIT License
Reverts the php-ast AST back into (somewhat) PSR-compliant code

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to php-ast-reverter

language-rust
Parser and pretty-printer for the Rust language
Stars: ✭ 78 (+59.18%)
Mutual labels:  ast, pretty-printer
ng-morph
Code mutations in schematics were never easier than now.
Stars: ✭ 63 (+28.57%)
Mutual labels:  ast
lpegrex
Parse programming languages syntax into an AST using PEGs with ease (LPeg Extension).
Stars: ✭ 32 (-34.69%)
Mutual labels:  ast
valast
Convert Go values to their AST
Stars: ✭ 251 (+412.24%)
Mutual labels:  ast
astra
Astra: a Java tool for analysing and refactoring Java source code
Stars: ✭ 35 (-28.57%)
Mutual labels:  ast
jsdast
JSDoc Abstract Syntax Tree
Stars: ✭ 20 (-59.18%)
Mutual labels:  ast
yode
Yode - Focused Code Editing
Stars: ✭ 28 (-42.86%)
Mutual labels:  ast
glitter
Display git status information in your shell prompt
Stars: ✭ 47 (-4.08%)
Mutual labels:  pretty-printer
qunit-migrate
Migrate old QUnit tests to 2.x. Uses regex and ASTs to convert old QUnit code.
Stars: ✭ 17 (-65.31%)
Mutual labels:  ast
ast-builder
Build your ASTs directly from code
Stars: ✭ 18 (-63.27%)
Mutual labels:  ast
tsquery-playground
Playground for TSQuery
Stars: ✭ 30 (-38.78%)
Mutual labels:  ast
ast ninja
The Elixir AST explorer
Stars: ✭ 59 (+20.41%)
Mutual labels:  ast
tydoc
The TypeScript documenter that meets you where you are
Stars: ✭ 28 (-42.86%)
Mutual labels:  ast
asty
Abstract Syntax Tree (AST) Data Structure
Stars: ✭ 28 (-42.86%)
Mutual labels:  ast
ucast
Conditions query translator for everything
Stars: ✭ 76 (+55.1%)
Mutual labels:  ast
verilogAST-cpp
C++17 implementation of an AST for Verilog code generation
Stars: ✭ 14 (-71.43%)
Mutual labels:  ast
esvalid
confirm that a SpiderMonkey format AST represents an ECMAScript program
Stars: ✭ 24 (-51.02%)
Mutual labels:  ast
parseclj
Clojure Parser for Emacs Lisp
Stars: ✭ 44 (-10.2%)
Mutual labels:  ast
lowcode
React Lowcode - prototype, develop and maintain internal apps easier
Stars: ✭ 32 (-34.69%)
Mutual labels:  ast
bright
Blazing fast parser for BrightScript that gives you ESTree like AST
Stars: ✭ 28 (-42.86%)
Mutual labels:  ast

php-ast-reverter

A tool that reverts an abstract syntax tree (AST) produced by the php-ast extension back into (somewhat) PSR-compliant code. This enables for code preprocessing to be done.

Requirements:

  • PHP 7.*
  • php-ast extension (compatible with versions 30, 35, 40, 45, and 50)

Installation

Composer

composer require tpunt/php-ast-reverter

Example

Running the following code snippet:

<?php

$code = <<<'end'
<?php

/**
 * My testing class
 */
class ClassName extends AnotherClass implements AnInterface
{
    /**
     * Some property
     */
    private $prop = 0;

    const TEST = 'string';

    use TraitA, TraitB {
        TraitA::func1 insteadof TraitB;
        TraitB::func1 as protected func2;
    }

    /**
     * Some useless constructor
     */
    function __construct(int $arg = 1)
    {
        $this->prop = $arg;
    }
}
end;

$ast = ast\parse_code($code, $version=40);

echo (new AstReverter\AstReverter)->getCode($ast);

Will output:

<?php

/**
 * My testing class
 */
class ClassName extends AnotherClass implements AnInterface
{
    /**
     * Some property
     */
    private $prop = 0;
    const TEST = "string";
    use TraitA, TraitB {
        TraitA::func1 insteadof TraitB;
        TraitB::func1 as protected func2;
    }
    /**
     * Some useless constructor
     */
    public function __construct(int $arg = 1)
    {
        $this->prop = $arg;
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].