Phing uses an ExpatParser class and PHP's native expat XML functions to handle the parsing of build files. The handler classes all extend the phing.parser.AbstractHandler class. These handler classes "handle" the tags that are found in the buildfile.
Core tasks and datatypes are mapped to XML tag names in the defaults.properties files -- specifically phing/tasks/defaults.properties and phing/types/defaults.properties.
It works roughly like this:
-
phing.parser.RootHandler
is registered to handle the buildfile XML document -
RootHanlder expects to find exactly one element:
<project>
. RootHandler invokes the ProjectHandler with the attributes from the <project> tag or throws an exception if no <project> is found, or if something else is found instead. -
ProjectHandler
expects to find<target>
tags; for theseProjectHandler
invokes theTargetHandler
. ProjectHandler also has exceptions for handling certain tasks that can be performed at the top-level:<resolve>
,<taskdef>
,<typedef>
, and<property>
; for theseProjectHandler
invokes the TaskHandler class. If a tag is presented that doesn't match any expected tags, thenProjectHandler
assumes it is a datatype and invokes theDataTypeHandler
. -
TargetHandler
expects all tags to be either tasks or datatypes and invokes the appropriate handler (based on the mappings provided in thedefaults.properties
files). -
Tasks and datatypes can have nested elements, but only if they correspond to a create*() method in the task or datatype class. E.g. a nested
<param>
tag must correspond to acreateParam()
method of the task or datatype.
... More to come ...