NOTE: To use the advanced features of this site you need javascript turned on.

Home Products nTile PtoJ Features Advanced

Advanced Features

Advanced features improve the quality of the translation output by making full use of Java's object-oriented nature and by detecting shortcomings of the original code.

Object extraction

PHP did not have object-oriented capabilities until version 4, while subsequent versions maintained backwards compatibility. This means that PHP applications can be written in a completely procedural manner.

nTile PtoJ translates PHP applications making full use of Java™'s object-oriented character. Each PHP file is transformed into a class, while each explicitly declared PHP class is moved into its own file.

Read more: Object extraction


Variable scope optimization

If a global variable is only used in the scope of a single PHP file, it becomes a field of that class. This ensures better encapsulation. For situations when the same variable name is used in multiple PHP files, but it represents in fact different entities, the manual override mechanisms provided by nTile PtoJ allow explicit partitioning. The variable scope optimization mentioned above can then proceed as usual.

Note that thread-safety is preserved for servlet instance variables, by using special mechanisms inside the framework.

Most of the examples in the Samples section have undergone variable scope optimization.


Extraction of common interfaces

It may happen that functions with the same signature exist in multiple PHP include paths. This scenario is typically used intentionally, to emulate object-oriented behavior (abstraction).

The nTile PtoJ algorithms detect these scenarios and extract common interfaces as comprehensively as possible. The included files are translated as classes that implement the common interfaces and, in addition, define their own specific (non-common) methods. The Common Interface Extraction sample illustrates this mechanism.


Detection of ambiguities

nTile PtoJ detects problematic scenarios in the PHP applications, allowing a manual correction on the original code. Such scenarios include:

  • erroneous function returns, e.g. mixing booleans with arrays
  • different counts for actual and formal function parameters
  • duplicated names of formal function parameters
  • class constructors used as regular functions

If specific translation projects require it, future evolutions of nTile PtoJ can be customized with additional detection capabilities.


Comment propagation

It is extremely important that all comments are correctly propagated during migration. nTile PtoJ implements this feature and, in addition, generates JavaDoc comments for class, function and field declarations, where applicable. The Comments sample provides a relevant illustration.