Core Features
Core features ensure that all possible variations of source code input are correctly translated.
Support for all PHP language constructsAll PHP language constructs (statements, expressions, operators etc.) are translated into their Java™ equivalents. Even complex constructs, such as LIST statements or nested arrays, are properly handled. PHP files are organized into include hierarchies, allowing the invocation of functions within the hierarchy. nTile PtoJ preserves include hierarchies and properly resolves the function calls. To see specific examples, please consult the Samples section. Type inferencePHP is a dynamically and weakly typed language, meaning that variables do not have a fixed type and can participate in all kinds of expressions, conversions being performed on-the-fly. On the other hand Java™ is a statically and strongly typed language, with each variable having a type that is fixed by a declaration, cannot change during the execution and limits the kinds of expressions and operations in which the variable can participate without explicit conversion. Transformation of dynamic constructsnTile PtoJ has specific algorithms for each category of dynamic constructs, transforming them into static evaluation expressions. Please consult the Dynamic Constructs samples for relevant examples. Handling of static class membersPHP static class members live across a single HTTP request. This means that they are not similar at all to the static concept in Java™. Instead, nTile PtoJ produces a translation that works on a shared class instance. For details, see the Static Members sample.Handling of constantsPHP constants cause nTile PtoJ to generate specific structures in the dedicated GlobalConsts class. These structures include getter and setter methods that preserve the PHP "set-only-once" semantics. See the Constants sample.Handling of referencesPHP supports explicit references and has a set of rules for reference propagation and operations. nTile PtoJ preserves the specific semantics of this concept. The Java™ translation uses a dedicated Ref class, parameterized with the base type of the reference. The References samples contain relevant examples of reference handling.Emulation of the PHP runtimeThe PHP standard runtime is extremely rich – it contains almost 3000 functions in the global namespace. nTile PtoJ emulates the most frequently used ones, and is easily extensible if a particular translation project requires it. The global namespace is partitioned into specialized Java™ classes, for better encapsulation and maintenance. The Web and DB Access samples contain a few examples of runtime usage. |