Breakbeat is a prototype php -> javascript compiler/porting tool. Currently a very early alpha. See the tests for examples of how it works.