2017 © Pedro Peláez
 

library php-ast-reverter

Reverts an AST back into (somewhat) PSR-compliant code

image

tpunt/php-ast-reverter

Reverts an AST back into (somewhat) PSR-compliant code

  • Thursday, August 10, 2017
  • by tpunt
  • Repository
  • 4 Watchers
  • 43 Stars
  • 26 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

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., (*1)

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

Installation

Composer

composer require tpunt/php-ast-reverter

Example

Running the following code snippet:, (*3)

<?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:, (*4)

<?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;
    }
}

The Versions

10/08 2017

dev-master

9999999-dev https://github.com/tpunt/php-ast-reverter

Reverts an AST back into (somewhat) PSR-compliant code

  Sources   Download

MIT

The Requires

  • php >=7.0
  • ext-ast *

 

The Development Requires

by Thomas Punt

ast abstract syntax tree parse tree

12/06 2017

v2.0

2.0.0.0 https://github.com/tpunt/php-ast-reverter

Reverts an AST back into (somewhat) PSR-compliant code

  Sources   Download

MIT

The Requires

  • php >=7.0
  • ext-ast *

 

The Development Requires

by Thomas Punt

ast abstract syntax tree parse tree

17/09 2015

v1.0

1.0.0.0 https://github.com/tpunt/php-ast-reverter

Reverts an AST back into (somewhat) PSR-compliant code

  Sources   Download

MIT

The Requires

  • php >=7.0
  • ext-ast *

 

by Thomas Punt

ast abstract syntax tree parse tree