janpiet/php-version-transpiler
Composer 安装命令:
composer require janpiet/php-version-transpiler
包简介
Transpile php 7 code to php 5.6 code
README 文档
README
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 |
janpiet/php-version-transpiler 适用场景与选型建议
janpiet/php-version-transpiler 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.34k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2016 年 05 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 janpiet/php-version-transpiler 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 janpiet/php-version-transpiler 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 13
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-05-22