定制 janpiet/php-version-transpiler 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

janpiet/php-version-transpiler

Composer 安装命令:

composer require janpiet/php-version-transpiler

包简介

Transpile php 7 code to php 5.6 code

README 文档

README

Scrutinizer Code Quality Code Coverage Build Status | Latest Stable Version Latest Unstable Version License Monthly Downloads

PHP Version Transpiler

Remove PHP7 language features and add PHP 5.6 compatible syntax :)

Install:

composer require janpiet/php-version-transpiler

Usage:

_Bin_Path/_php-version-transpiler _PHP_7_Source_Directory_ _PHP_5_6_Target_Directory_

Run tests:

composer install
bin/phpunit

View the files it generates:

  • Input: tests/_fixtures
  • Output: tests/_out

Installation

requires composer & php7

composer install
bin/phpunit

Support

As with every solution to such a problem there is no way to solve erverything, and there is no way to solve everything with one thing. I suspect there will far more use cases for a Shim for many incompatibility between 5.6 and 7.0. Other stuff will be that hard to detect, that I am not sure it will be worth it. Especially some of the more subtle additions to the language will not be emaulatable. But maybe they are not worth pursuing either?

From http://php.net/manual/de/migration70.new-features.php

Feature Supported Emulated Possible SHIM Notes
Scalar type declarations x - x -
Return type declarations x - x -
Null coalescing operator x x x -
Spaceship operator x x ? -
Constant arrays using define() - - x -
Anonymous classes x x x - But get_class() will now give something real back
Unicode codepoint escape syntax - - partly? partly? Would need a shim
Closure::call() - - x -
Filtered unserialize() - - x - Generally a very hard implementation for such a simple feature
IntlChar - - - x
Expectations - - - - It is backwards compatible
Group use declarations - - x -
Generator Return Expressions - - partly? partly? Would need a shim
Generator delegation - - - -
Integer division with intdiv() - - - x Should be much easier to do this by Shim
Session options - - ? - maybe, but might be leaky
preg_replace_callback_array() - - x - Can be very easily a Shim
CSPRNG Functions - - . - Can be very easily a Shim

From http://php.net/manual/de/migration70.incompatible.php

Feature Supported Emulated Possible SHIM Notes
Changes to error and exception handling - - x - The docs contain a way out
Changes to the handling of indirect variables, properties, and methods - - x -
Changes to list() handling - - ? -
Array ordering when elements are automatically created during by reference assignments has changed - - - - And never will be....
Parentheses around function parameters no longer affect behaviour - - x - Can be removed automatically
foreach no longer changes the internal array pointer - - - - Therefore current() is essentially rendered useless here
foreach by-value operates on a copy of the array - - partly? partly? Would need support from a shim, might be hard to detect
foreach by-reference has improved iteration behaviour - - partly? partly? Would need support from a shim, might be hard to detect

统计信息

  • 总下载量: 1.34k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固