简体   繁体   English

将php 5.4移植到5.3

[英]Porting php 5.4 to 5.3

Is there any automation tool for converting a php 5.4 script back to 5.3? 是否有任何自动化工具将PHP 5.4脚本转换回5.3? Mostly there are new style arrays causing problems. 大多数都有新的样式数组导致问题。

This: 这个:

<?php
$x = [1, 2, 3];
$y = [
  'a' => [1,2],
  'b' => 'c',
];
function ff($x = []) { ...}

Should be converted to this: 应转换为:

<?php
$x = array(1, 2, 3);
$y = array(
  'a' => array(1,2),
  'b' => 'c',
);
function ff($x = array()) { ...}

Other backward compatibility issues are just a few and can be fixed by hand. 其他向后兼容性问题只是一些,可以手动修复。 I'm very bad at language processing, has anyone already done this? 我在语言处理上非常糟糕,有人已经这样做了吗? the converter doesn't need to be PHP. 转换器不需要是PHP。 python, Java, ... are all file (I just prefer python, that's all). python,Java,...都是文件(我只是喜欢python,这就是全部)。

You can use a tool to convert your codebase from PHP 5.4+ to PHP 5.3, such as: http://github.com/endel/php-code-downgrade/ 您可以使用工具将代码库从PHP 5.4+转换为PHP 5.3,例如: http ://github.com/endel/php-code-downgrade/

This tool will read all your files and rewrite code using PHP 5.3 standards, even for your composer dependencies. 该工具将使用PHP 5.3标准读取所有文件并重写代码,即使对于您的作曲家依赖项也是如此。

The ideal scenario is to write code compatible with your production server, but sometimes it is not possible to know it by antecedence, so this tool may do the job for you. 理想的情况是编写与生产服务器兼容的代码,但有时无法通过先行知识来知道它,因此该工具可以为您完成工作。

The advantages of using this is that you can write modern code without worrying about legacy PHP version support. 使用它的优点是您可以编写现代代码而无需担心遗留的PHP版本支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM