PHPackages                             hacktophp/hacktophp - 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. hacktophp/hacktophp

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

hacktophp/hacktophp
===================

A Hack to PHP transpiler that attempts to preserve as many types as possible

0.0.1(7y ago)17302[2 issues](https://github.com/hacktophp/hacktophp/issues)MITPHPPHP ^7.1

Since Jan 2Pushed 6y ago2 watchersCompare

[ Source](https://github.com/hacktophp/hacktophp)[ Packagist](https://packagist.org/packages/hacktophp/hacktophp)[ RSS](/packages/hacktophp-hacktophp/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

[![Hack to PHP logo](https://camo.githubusercontent.com/83f661fa49b36b99a79504beac7a381fe91c4b2e24c121510c71938cfab26ea2/68747470733a2f2f6861636b746f7068702e6769746875622e696f2f6861636b746f7068702f6c6f676f2e7376673f31)](https://camo.githubusercontent.com/83f661fa49b36b99a79504beac7a381fe91c4b2e24c121510c71938cfab26ea2/68747470733a2f2f6861636b746f7068702e6769746875622e696f2f6861636b746f7068702f6c6f676f2e7376673f31)

A proof-of-concept Hack to PHP transpiler, written in PHP
=========================================================

[](#a-proof-of-concept-hack-to-php-transpiler-written-in-php)

This project uses HHVM's builtin parser (`hh_parse`) and [an existing library](https://github.com/hhvm/hhast) to turn Hack code into PHP code. It generates [PHP-Parser](https://github.com/nikic/php-parser)-equivalent nodes for the original Hack AST, then prints the result.

It aims to preserve all of Hack’s types so that the resultant PHP code can be checked by a tool like [Psalm](https://github.com/vimeo/psalm), converting any asynchronous code to its synchronous equivalent.

You can install via composer (`composer require --dev hacktophp/hacktophp`) and run it like so:

```
vendor/bin/hacktophp --input= --output=

```

Indefinitely unsupported features
---------------------------------

[](#indefinitely-unsupported-features)

While a lot of code has easy-to-compute PHP equivalents, some builtin Hack constructs are essentially impossible to replicate:

### async/await

[](#asyncawait)

All `async`/`await` calls have been made synchronous, converted to promises that use [`amphp`](https://github.com/amphp)

### keyset

[](#keyset)

This valid Hack code

```
$a = keyset[];
$a[] = "hello";
echo $a["hello"];
```

transpiles to the valid (but not-equivalent) PHP code

```
$a = [];
$a[] = "hello";
var_dump($a["hello"]);
```

The only valid option here would be to convert `keyset`s to ArrayObjects, but I'm not sure if that's wise.

Currently unsupported features
------------------------------

[](#currently-unsupported-features)

- Pretty much all builtins, but I'm adding things slowly, and `HH\Lib\...` functions are supported via [`hacktophp/hsl-php`](https://github.com/hacktophp/hsl-php)
- XHP
- Class constant types e.g. ```
    class A {
      const type Foo = int;
    }
    ```
- Docblock annotations for Parameterised `extends`, `implements` and `trait` - dependent on Psalm support
- Docblock annotations for `require extends` - dependent on future Psalm support
- User attributes, especially ``
- types of `const` (Psalm does a reasonably good job inferring them, but it should be added for completeness)
- probably many more things I haven't considered

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.3% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2688d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/37a992956f2ceb043547091360fe71dacdd2b227d5450e7022b2a53660ba4e44?d=identicon)[muglug](/maintainers/muglug)

---

Top Contributors

[![muglug](https://avatars.githubusercontent.com/u/2292638?v=4)](https://github.com/muglug "muglug (135 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hacktophp-hacktophp/health.svg)

```
[![Health](https://phpackages.com/badges/hacktophp-hacktophp/health.svg)](https://phpackages.com/packages/hacktophp-hacktophp)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

5953.3M56](/packages/roave-backward-compatibility-check)[coenjacobs/mozart

Composes all dependencies as a package inside a WordPress plugin

4723.6M20](/packages/coenjacobs-mozart)[recca0120/laravel-erd

Laravel ERD automatically generates Entity-Relationship Diagrams from your Laravel models and displays them using Vuerd.

36072.0k](/packages/recca0120-laravel-erd)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[php-standard-library/psalm-plugin

Psalm plugin for the PHP Standard Library

252.0M47](/packages/php-standard-library-psalm-plugin)

PHPackages © 2026

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