Convert PHP source code to Go by AST walking
Go to file
mappu c89f3232ae vendor: commit github.com/z7zmey/php-parser v0.7.0 (MIT license) 2020-04-05 16:36:06 +12:00
fixtures initial commit 2020-04-05 16:35:44 +12:00
vendor vendor: commit github.com/z7zmey/php-parser v0.7.0 (MIT license) 2020-04-05 16:36:06 +12:00
.gitignore initial commit 2020-04-05 16:35:44 +12:00
README.md initial commit 2020-04-05 16:35:44 +12:00
fixtures_test.go initial commit 2020-04-05 16:35:44 +12:00
go.mod initial commit 2020-04-05 16:35:44 +12:00
go.sum initial commit 2020-04-05 16:35:44 +12:00
literal.go initial commit 2020-04-05 16:35:44 +12:00
main.go initial commit 2020-04-05 16:35:44 +12:00
node.go initial commit 2020-04-05 16:35:44 +12:00
scope.go initial commit 2020-04-05 16:35:44 +12:00

README.md

php2go

Convert PHP source code to Go by AST walking.

The goal is to produce idiomatic, maintainable Go code as part of a one-off conversion. This is not generally possible for highly dynamic PHP code, that may require manual fixups.

Progress

[X] Convert some small programs [X] All functions return (type, error) - [X] Convert throw to err return - [ ] Elide error return for functions that cannot throw - ?? Could be a standalone Go refactoring tool - [ ] Non-leaf function calls need to check + bubble errors [ ] Comprehensive coverage of all AST node types - [ ] Expr - [ ] Binary - [ ] Scalar - [ ] ... - [ ] Convert instanceof for Exception types to Go1.13 errors.Is [ ] Array handling - [ ] Infer whether to use slice/map for PHP array - [ ] Infer whether map use should be order-preserving [ ] Multi-file programs - [ ] Include/Require [ ] Namespaces [ ] Generators [X] Convert top-level calls to init()/main() - Currently always init [ ] Class/object transformations - [X] Convert new X constructor calls to NewX - [ ] Convert class inheritance to interfaces with interface assertion - [ ] Traits / use - [ ] Abstract methods [ ] Type inference - [ ] Parse extra types from phpdoc blocks [ ] Infer whether to declare variable (var / :=) or reuse (=) - [ ] Track current visibility scope [ ] Standard library transformations - [ ] Track golang package imports - [ ] Handle conflicts between golang stdlib packages / local variable names [ ] PHP Superglobal transformations - [ ] $_SERVER['argv'] to os.Args - [ ] $_GET['name'] to r.FormValue('name') [ ] Closures - [ ] Handle value/reference captures [X] Variadic function parameters [ ] Convert wordpress / mediawiki / symfony