I have been tasked with converting several php classes into java classes, which is quickly becoming a nightmare for me. I understand the basic language structure, it being simil
Caucho/Resin server converts PHP Code into Java servlets in run-time!
You could probably write something with the Reflection API to do some of this, but you really couldn't do anything with function bodies - you'd end up with stub classes that have no implementation.
It sounds like you're trying to convert PHP code that is procedural into an OO code base.
This is not so much a question of PHP to Java, but rather a paradigm shift. There's no automated way to do it, it's going to be rough. Especially if one code base is badly written.
Btw, I would also why are you converting? Is it just performance? And if so, is there nothing you can do to fix the performance issues. I don't think just converting from one language to another will fix it, you'll still have to find the bottleneck.
Someone implied that Java is not as flexible as PHP : it is, by default, far more flexible actually (in that the core API contains thousands of classes and built-in functionality). You just have to learn the core concepts of both languages, such as autoboxing for Java, for example, to make room for dynamic types. Check out http://www.javaworld.com and I am currently working on porting a big API from PHP to Java, should take me a few days. Two classes, libcurl, json parsing, and maybe a hundred methods / functions.
Check out http://www.numiton.com
I've been looking into Groovy as a transition language from PHP to Java. They (the Groovy developers) claim that it compiles to java byte code the same as Java code would.
It's also less strict, they have several examples of translation on their website.