The main challenge of the project was bridging the gap between PHP and C++. PHP is a scripting language with dynamic, weak typing. C++ is a compiled language with static typing. While PHP allows you to write magical dynamic features, most PHP is relatively straightforward. It’s more likely that you see if (…) {…} else {..} than it is to see function foo($x) { include $x; }. This is where we gain in performance. Whenever possible our generated code uses static binding for functions and variables. We also use type inference to pick the most specific type possible for our variables and thus save memory.
The transformation process includes three main steps:
- Static analysis where we collect information on who declares what and dependencies,
- Type inference where we choose the most specific type between C++ scalars, String, Array, classes, Object, and Variant, and
- Code generation which for the most part is a direct correspondence from PHP statements and expressions to C++ statements and expressions.

