Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request (wishful thinking mostly): Transcode PHP 5.5 code to older PHP 5.2 code or vice-versa #77

Closed
ZaDarkSide opened this issue Oct 18, 2013 · 2 comments

Comments

@ZaDarkSide
Copy link

Don't know if this should be a separate project or not, but a real benefit it will be to use the parser to transcode newer code to older code that could run on older versions of PHP. This should be one of the logical next steps with this parser.

So the parser can run on older versions of PHP, read newer code then transcode and maybe run the adapted code on the old version of PHP. Basically you could run PHP 5.5 code on PHP 5.2 for example via the Parser and an Adaptor or Transcoder or whatever you want to call it. The reverse process should be possible also, backporting code or forwardporting code auto-magically would be awesome.

But I know such a thing is hugely complex and probably it will never become a reality.

LATER EDIT:

Discovered https://github.com/ircmaxell/PHPPHP (PHPPHP VM) maybe this project is more appropriate for this idea :)

@tcopestake
Copy link

I'd imagine the performance of PHPPHP would be unsuitable for a production environment.

This is something I've considered doing myself, but I concluded that for the effort involved, people might as well just upgrade PHP. The challenge ranges from easy to unrealistically difficult, for reasons that would differ from feature to feature. Try to pick a feature at random and think about how you'd do it yourself. The 5.4 array syntax is easy, but what about generators or $this within closures with the proper protected/private scope? You'll quickly find that as you try to cover all bases, bearing in mind that you're also restricted to static analysis (or would have to program dynamic analysis into the output), it becomes very complex.

Nothing stopping you giving it a try, though - just for the experience.

@nikic
Copy link
Owner

nikic commented Oct 18, 2013

Backporting PHP code to older version was the original motivation behind this project. I started working on this with https://github.com/nikic/PHP-Backporter, but abandoned it pretty quickly (for no particular technical reason). There is another, newer project with the same goal (https://github.com/igorw/galapagos), but that doesn't look actively developed either.

PHPPHP could theoretically be used for this but a) it is really, really slow and b) it is rather incomplete and there currently is no intention to make it complete.

@nikic nikic closed this as completed Oct 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants