# Php reverse

The Php code reverse is a plug-out directly written in C++.

Note that the Php code reverse cannot be used as a Php code round trip and doesn't allows to update already defined classes having at least one member.

The Php code reverse plug-out may be applied only on a package.

When you start the Php code reverse, it ask for a directory, then it reads all the sources placed under the selected directory and sub-directories. The sources read by the Php code reverse are the ones having the extension specified in the generation settings. The tree formed by the sub-directories produce an equivalent tree of sub-packages, on whose the needed class view and deployment view are made to support the classes and artifacts. When a type is referenced but not defined in the reverse files, a class having the same name is defined under an additional package named unknown.

Obviously the Php code reverse tries to produce the definitions made in BOUML at the artifact / class / operation / relation / attribute levels. When it is possible it creates a relation rather than an attribute.

The Php code reverse works in two steps, during the first step it scans all the files to establish the list of defined types, then the second step may reverse the files.

When the Php code reverse has a problem, for instance on a syntax error, it produces a warning in the trace window. The trace window is automatically opened by BOUML, it may also be manually opened through the Tools menu.

The reversed files are considered composed in three parts :

- a header without class definition and containing “<?php". This part if placed at the beginning of the generated artifact

- only classes / interfaces definition, this part start with the first class or interface and stops before the first form which is not a class nor an interface. The classes and interfaces must be at the toplevel level, this means not embedded in a if or other form. This part produces ${definition} in the definition of the artifact

- the rest if the file, probably containing the marker "?>", this part is placed at the end of the definition of the artifact.

When the reverse is done, the number of reversed classes, operations, attributes and relations is written, for instance in case I reverse the sources of Joomla 1.5RC :

Previous : Php generator

Next : Python Generator