sters / phptogo
                                    Fund package maintenance!
                                                                            
                                                                                                                                        sters
                                                                                    
                                                                
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/sters/phptogo
Requires
- nikic/php-parser: ^4.0
- phpstan/phpdoc-parser: ^0.3.0
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2025-10-25 20:41:58 UTC
README
This is transpiler for PHP code to Go like something code.
Example and Usage
Let's see example directory, and try this.
First, execute git clone and composer install.
$ composer run -l
scripts:
  test             Runs the test script as defined in composer.json.
  convert          Runs the convert script as defined in composer.json.
  convert-example  Runs the convert-example script as defined in composer.json.
$ composer run convert-example
> cd example/simple-convert && rm result.go && php main.php -i target.php -o result.go
Starting: target.php
$ diff --ignore-all-space --side-by-side example/target01.php example/result01.go
<?php                                                         | // Code generated. MUST EDIT!
                                                              >
                                                              >
                                                              >
/**                                                             /**
 * @param int $count                                             * @param int $count
 * @return array                                                 * @return array
 */                                                              */
function fibonacci($count)                                    | func fibonacci(count){
{                                                             |     switch (count) {
    switch ($count) {                                         <
        case 1:                                                         case 1:
            return [1];                                       |             return []interface{}{
                                                              >                 1,
                                                              >             }
        case 2:                                                         case 2:
            return [1, 1];                                    |             return []interface{}{
                                                              >                 1,
                                                              >                 1,
                                                              >             }
        default:                                                        default:
            $tmp = fibonacci($count - 1);                     |             tmp = fibonacci(count - 1)
            $tmp[] = $tmp[count($tmp) - 1] + $tmp[count(      |             tmp[] = tmp[len(tmp) - 1] + tmp[len(tmp) - 2]
            return $tmp;                                      |             return tmp
    }                                                               }
}                                                               }
var_dump(fibonacci(10));                                      | fmt.Printf("%+v\n", fibonacci(10))
$ composer run convert
> php example/simple-convert/main.php
You must need some options:
	 -i input-file. If missing, program exit.
	 -o output-file. If empty, output to stdout.
Script php example/simple-convert/main.php handling the convert event returned with error code 1