dongxing2030 2012-12-25 12:48
浏览 64
已采纳

PHP产品从PHP 5.2迁移到PHP 5.4的工具或方法

Existing product developed in core PHP is built in PHP 5.2 and now we want to migrate the product to PHP 5.4.

CodeSniffer can detect compatibility for version and generate report with warnings and errors.

Current approach could be:

  • Scan whole product and get report from CodeSniffer

  • Prepare a plan to fix each type of warning or error, like replace ereg_replace with preg_replace function and in first argument add delimiters

  • Example:

    Original: $new = ereg_replace(“oldstring“, “newstring“, $old);
    Replace:  $new = preg_replace(“/oldstring/“, “newstring“, $old);
    
  • Make a PHP script to implement the plan

  • Run the script, test with CodeSniffer again and run a test on whole product again

Is there any better tool or approach for migration PHP 5.2 to PHP 5.4?

  • 写回答

2条回答 默认 最新

  • dongren4099 2012-12-25 13:49
    关注

    I have PHPUnit tests for my project. The tests also record all warnings and notices. With PHP5.2 I made sure that had no warnings or notices. Then I upgraded to PHP 5.4 and got lots of warnings and notices, plus many tests failed. Then it was just a matter of fixing all of them. The most common issue that I had: assigning properties of uninitialized objects.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 表达式必须是可修改的左值
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题