brownbear / php-transpiler
Transpiles PHP 5.x into PHP 5.6 or PHP 7 optimized code
dev-develop
2016-02-29 20:41 UTC
Requires
- php: >=5.6
- nikic/php-parser: 2.0.0
- symfony/console: 3.0.2
- symfony/event-dispatcher: 3.0.2
Requires (Dev)
- codeclimate/php-test-reporter: ~0.3
- mikey179/vfsstream: ^1.6
- phpunit/phpunit: ~5.2
This package is not auto-updated.
Last update: 2024-11-09 19:45:29 UTC
README
This tool transpiles PHP code into optimized PHP code.
Implemented features:
-
Inlines
require
andinclude
statements. -
Strips unnecessary whitespaces from the code.
-
Strips comments from code.
Example
Run against files test.php and include.php in the same directory given as:
test.php
<?php require 'include.php'; class Foo { public function msg() { return (new Bar)->msg(); } } echo (new Foo)->msg();
include.php
<?php class Bar { public function msg() { return "Example Return Message\n"; } }
Transpiles into a single test.php that contains:
<?php class Bar{public function msg(){return 'Example Return Message ';}}class Foo{public function msg(){return (new Bar())->msg();}}echo (new Foo())->msg();
For more examples and details on this project see the project page.
Usage
Installation
To install globally via composer run
composer global require brownbear/php-transpiler
CLI
Either analyze a source file or directory via:
php-transpiler analyze /src
or transpile a source directory into /out
via:
php-transpiler transpile /src /out
Library
Not documented yet :/