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

Transpile you app from PHP7 to PHP5 #330

Open
theofidry opened this issue Nov 21, 2018 · 6 comments
Open

Transpile you app from PHP7 to PHP5 #330

theofidry opened this issue Nov 21, 2018 · 6 comments

Comments

@theofidry
Copy link
Member

Feature Request

It could be interesting to have a Box compactor which transpile the code from PHP7 to PHP5. As a result, for example, one could ship a PHP 7.2 app into a PHAR which would be compatible with PHP 5.4.

Some transpilers already exists, such as:

@nunomaduro
Copy link

This would be the next level.

@rask
Copy link

rask commented Nov 21, 2018

But why?

@theofidry
Copy link
Member Author

@rask there is a number of CLI apps that by design should be compatible with low PHP targets, a few examples on top of my head: Composer, PHPBrew and Psysh.

In the case of those applications, having to stick with PHP 5.4 for example cripples the code-base, whereas a transpiler would allow to not abandon those lower versions whilst benefiting from the new PHP versions.

@rask
Copy link

rask commented Nov 22, 2018

I get the idea, but wouldn't this introduce issues with things like strict typehints, when transpiled to fully dynamic types (which rely on user input for instance)? The transpiler would need to generate type checking code on the fly to prevent issues like these.

@theofidry
Copy link
Member Author

Indeed if you had guards but dropped them in favour of strict types & typehints you would loose something.

However I think that's an acceptable loss, at least for the first iteration. In my experience very few people were putting guards properly before so I don't think this will be a big issue, at least to most users

@theofidry
Copy link
Member Author

Small update: no real progress on that front but now we do have Rector which allows to downgrade as well instead of upgrading. PHPStan does use it to some degree to add support for PHP 7.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants