How does the Runtime Converter work?
The Runtime Converter produces code (right now in Java) that is automatically converted from PHP. It has a dependency on a library of helper functions and on the PHP runtime library itself, which is used to provide the library of standard functions.
When the user calls a method from one of the user-space classes that they converted, this call is made in the target language. The functions, classes, and include files from their project are all converted to code in the target language, which is then compiled and linked with the runtime library.
When the converter encounters code that calls on of the php standard library functions, or a function from an extenseion, it maps that call to the runtime which in turn passes that call directly to PHP. The function arguments are converted from Java objects to PHP objects, and after the function is called, its return value is also converted back to a Java object (or an object from another target language such as Swift). While there is some considerable overhead in this, especially in Java because of JNI, the result is that your user-space code always works with native objects whenever possible.
When working with arrays, there is no equivelent in the Java language of the php "array" type. For this reason, we have created our own array type called "ConverterRuntimeArray". Its implmentation (right now in Java nd Swift) is a "hash map list" with integer + string keys, just like the php "array" type. The majority of the php array functions are also implemented as native, to work with these native arrays instead of passing them over the JNI bridge and converting them to php and back all the time. This cuts down a lot of the overhead of working with JNI functions because, aside from these array functions, the majority of the php standard library functions do not take array arguments at all.
In addition to this, a large library of helper functions, including a unit tested implementation of the php comparison functions (ie. <, >, <=, >=, ==, === !=, <==>, etc) is used to get equiveent behavior between the source scirpts and the target binaries.