PHPackages                             janpiet/php-version-transpiler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. janpiet/php-version-transpiler

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

janpiet/php-version-transpiler
==============================

Transpile php 7 code to php 5.6 code

101.3k41PHP

Since Dec 20Pushed 9y ago3 watchersCompare

[ Source](https://github.com/JanPietrzyk/php-version-transpiler)[ Packagist](https://packagist.org/packages/janpiet/php-version-transpiler)[ RSS](/packages/janpiet-php-version-transpiler/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (1)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/3061418494927421426f063c5f7794743f80cad7c8dfb4f355b08645395f893b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a616e50696574727a796b2f7068702d76657273696f6e2d7472616e7370696c65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JanPietrzyk/php-version-transpiler/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/0649769bfa5528501f0e3bb0d1d7f4ed0282f5e50eb9b8face680f9fb1bb922d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a616e50696574727a796b2f7068702d76657273696f6e2d7472616e7370696c65722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JanPietrzyk/php-version-transpiler/?branch=master)[![Build Status](https://camo.githubusercontent.com/e31222061f24b8eea322196276d1f050652bcb2276544ef75f10b7f37f6719cc/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a616e50696574727a796b2f7068702d76657273696f6e2d7472616e7370696c65722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JanPietrzyk/php-version-transpiler/build-status/master)| [![Latest Stable Version](https://camo.githubusercontent.com/e64f9114fbf4329a892b8f1f4361d4e1202c1dc52904b0ae8cd1610284a23285/68747470733a2f2f706f7365722e707567782e6f72672f6a616e706965742f7068702d76657273696f6e2d7472616e7370696c65722f762f737461626c65)](https://packagist.org/packages/janpiet/php-version-transpiler)[![Latest Unstable Version](https://camo.githubusercontent.com/a1b6c713933edf61f8a43ceed219bedaa32b1fe337286d8d202b9833af7e504d/68747470733a2f2f706f7365722e707567782e6f72672f6a616e706965742f7068702d76657273696f6e2d7472616e7370696c65722f762f756e737461626c65)](https://packagist.org/packages/janpiet/php-version-transpiler)[![License](https://camo.githubusercontent.com/f339fda696b11ab88a7bfd97c09095469227d6e97939058be8c133db746184b8/68747470733a2f2f706f7365722e707567782e6f72672f6a616e706965742f7068702d76657273696f6e2d7472616e7370696c65722f6c6963656e7365)](https://packagist.org/packages/janpiet/php-version-transpiler)[![Monthly Downloads](https://camo.githubusercontent.com/f4dfc092353a9a2f8d1535ee84722ef41dcebc2b491ff578196931015a1484ad/68747470733a2f2f706f7365722e707567782e6f72672f6a616e706965742f7068702d76657273696f6e2d7472616e7370696c65722f642f6d6f6e74686c79)](https://packagist.org/packages/janpiet/php-version-transpiler)

PHP Version Transpiler
======================

[](#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
------------

[](#installation)

requires composer &amp; php7

```
composer install
bin/phpunit

```

Support
-------

[](#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

[](#from-httpphpnetmanualdemigration70new-featuresphp)

FeatureSupportedEmulatedPossibleSHIMNotesScalar type declarationsx-x-Return type declarationsx-x-Null coalescing operatorxxx-Spaceship operatorxx?-Constant arrays using define()--x-Anonymous classesxxx-But get\_class() will now give something real backUnicode codepoint escape syntax--partly?partly?Would need a shimClosure::call()--x-Filtered unserialize()--x-Generally a very hard implementation for such a simple featureIntlChar---xExpectations----It is backwards compatibleGroup use declarations--x-Generator Return Expressions--partly?partly?Would need a shimGenerator delegation----Integer division with intdiv()---xShould be much easier to do this by ShimSession options--?-maybe, but might be leakypreg\_replace\_callback\_array()--x-Can be very easily a ShimCSPRNG Functions--.-Can be very easily a Shim#### From

[](#from-httpphpnetmanualdemigration70incompatiblephp)

FeatureSupportedEmulatedPossibleSHIMNotesChanges to error and exception handling--x-The docs contain a way outChanges 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 automaticallyforeach no longer changes the internal array pointer----Therefore current() is essentially rendered useless hereforeach by-value operates on a copy of the array--partly?partly?Would need support from a shim, might be hard to detectforeach by-reference has improved iteration behaviour--partly?partly?Would need support from a shim, might be hard to detect

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e4336d14d71c0db07bf2d904eb0dc39c9819de58ff3a71fdd5fd0069193884fb?d=identicon)[JanPietrzyk](/maintainers/JanPietrzyk)

---

Top Contributors

[![JanPietrzyk](https://avatars.githubusercontent.com/u/786075?v=4)](https://github.com/JanPietrzyk "JanPietrzyk (25 commits)")[![bcremer](https://avatars.githubusercontent.com/u/55820?v=4)](https://github.com/bcremer "bcremer (2 commits)")

### Embed Badge

![Health badge](/badges/janpiet-php-version-transpiler/health.svg)

```
[![Health](https://phpackages.com/badges/janpiet-php-version-transpiler/health.svg)](https://phpackages.com/packages/janpiet-php-version-transpiler)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
