|
7 months ago | |
---|---|---|
fixtures | 7 months ago | |
parseutil | 9 months ago | |
vendor | 9 months ago | |
.gitignore | 9 months ago | |
README.md | 7 months ago | |
fixtures_test.go | 9 months ago | |
go.mod | 9 months ago | |
go.sum | 9 months ago | |
gotype.go | 9 months ago | |
hoistpass.go | 9 months ago | |
literal.go | 9 months ago | |
main.go | 7 months ago | |
node.go | 7 months ago | |
normalisealts.go | 9 months ago | |
quote.go | 9 months ago | |
scope.go | 9 months ago |
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.
namespace
-> package name transformationuse
statementsif
for
/foreach
switch
null
-> nil
define()
__LINE__
,__FILE__
etc)PHP_VERSION
, PHP_EOL
, PHP_OS
, PHP_INT_MAX
etc)isset
/unset
instanceof
die
try
/catch
/finally
finally
finally
would be more concisely implemented as defer inside an IIFE, but that is not idiomatic, maintainable Go codeeval
extract
init()
/main()
new X
constructor calls to NewX
use
var
/ :=
) or reuse (=
)
if foo := bar(); foo {
ob_start
/ ob_get_clean
)
fmt.Print
$_SERVER['argv']
to os.Args$_GET['name']
to r.FormValue('name')namespace { ... }
) and multiple namespaces in filego run