The Phing project class.

Represents a completely configured Phing project. The class defines the project and all tasks/targets. It also contains methods to start a build as well as some properties and FileSystem abstraction.

author | Andreas Aderhold
author | Hans Lellelid
version | $Id: 7e67218e8e616860f9c746f9ab600f523089ea2e $
package | phing

### Methods

## Constructor, sets any default vars.

    __construct()

## _makeCircularException()

    _makeCircularException($end, $stk)

### Parameters

#### $end

#### $stk

## Topologically sort a set of Targets.

    _topoSort(string $root, array $targets) : \An

### Parameters

#### $root

`string`

is the (String) name of the root Target. The sort is created in such a way that the sequence of Targets until the root target is the minimum possible such sequence.

#### $targets

`array`

is a array representing a "name to Target" mapping

### Returns

`\An`array of Strings with the names of the targets in sorted order.

## _tsort()

    _tsort($root, $targets, $state, $visiting, $ret)

### Parameters

#### $root

#### $targets

#### $state

#### $visiting

#### $ret

## addBuildListener()

    addBuildListener(\BuildListener $listener)

### Parameters

#### $listener

## Adds a data type definition.

    addDataTypeDefinition(string $typeName, string $typeClass, string $classpath)

### Parameters

#### $typeName

`string`

Name of the type.

#### $typeClass

`string`

The class to use.

#### $classpath

`string`

The classpath to use.

## Adds or replaces a target in the project

    addOrReplaceTarget(string $targetName, \Target $target)

### Parameters

#### $targetName

`string`

#### $target

`\Target`

## Adds a reference to an object.

    addReference(string $name, object $object)

This method is called when the parser detects a id="foo" attribute. It passes the id as $name and a reference to the object assigned to this id as $value

### Parameters

#### $name

`string`

#### $object

`object`

## Add a new target to the project

    addTarget(string $targetName, \Target $target)

### Parameters

#### $targetName

`string`

#### $target

`\Target`

## Adds a task definition.

    addTaskDefinition(string $name, string $class, string $classpath)

### Parameters

#### $name

`string`

Name of tag.

#### $class

`string`

The class path to use.

#### $classpath

`string`

The classpat to use.

## Copies all user properties that have not been set on the command line or a GUI tool from this instance to the Project instance given as the argument.

    copyInheritedProperties(\Project $other)

To copy all "user" properties, you will also have to call copyUserProperties.

since | phing 2.0

### Parameters

#### $other

`\Project`

the project to copy the properties to. Must not be null.

## Copies all user properties that have been set on the command line or a GUI tool from this instance to the Project instance given as the argument.

    copyUserProperties(\Project $other) : void

To copy all "user" properties, you will also have to call copyInheritedProperties.

since | phing 2.0

### Parameters

#### $other

`\Project`

the project to copy the properties to. Must not be null.

## Creates a new condition and returns the reference to it

    createCondition(string $conditionType) : \Condition

### Parameters

#### $conditionType

`string`

### Exceptions

`\BuildException` |

### Returns

`\Condition`

## Create a datatype instance and return reference to it See createTask() for explanation how this works

    createDataType(string $typeName) : object

### Parameters

#### $typeName

`string`

Type name

### Exceptions

`\BuildException` | Exception

### Returns

`object`A datatype object

## Create a new task instance and return reference to it.

    createTask(string $taskType) : \Task

This method is sorta factory like. A local instance is created and a reference returned to that instance. Usually PHP destroys local variables when the function call ends. But not if you return a reference to that variable. This is kinda error prone, because if no reference exists to the variable it is destroyed just like leaving the local scope with primitive vars. There's no central place where the instance is stored as in other OOP like languages.

[HL] Well, ZE2 is here now, and this is still working. We'll leave this alone unless there's any good reason not to.

### Parameters

#### $taskType

`string`

Task name

### Exceptions

`\BuildException` | Exception

### Returns

`\Task`A task object

## Executes a target

    executeTarget(string $targetName) : void

### Parameters

#### $targetName

`string`

Name of Target to execute

### Exceptions

`\BuildException` |

## Executes a list of targets

    executeTargets(array $targetNames) : void

### Parameters

#### $targetNames

`array`

List of target names to execute

### Exceptions

`\BuildException` |

## fireBuildFinished()

    fireBuildFinished($exception)

### Parameters

#### $exception

## fireBuildStarted()

    fireBuildStarted()

## fireMessageLogged()

    fireMessageLogged($object, $message, $priority)

### Parameters

#### $object

#### $message

#### $priority

## fireMessageLoggedEvent()

    fireMessageLoggedEvent($event, $message, $priority)

### Parameters

#### $event

#### $message

#### $priority

## fireTargetFinished()

    fireTargetFinished($target, $exception)

### Parameters

#### $target

#### $exception

## fireTargetStarted()

    fireTargetStarted($target)

### Parameters

#### $target

## fireTaskFinished()

    fireTaskFinished($task, $exception)

### Parameters

#### $task

#### $exception

## fireTaskStarted()

    fireTaskStarted($task)

### Parameters

#### $task

## Returns the basedir of this project

    getBasedir() : \PhingFile

access | public
author | Andreas Aderhold, andi@binarycloud.com

### Exceptions

`\BuildException` |

### Returns

`\PhingFile`Basedir PhingFile object

## getBuildListeners()

    getBuildListeners()

## Returns the data type definitions

    getDataTypeDefinitions() : array

### Returns

`array`

## Returns default target

    getDefaultTarget() : string

### Returns

`string`

## return the description, null otherwise

    getDescription() : string | null

### Returns

`string` `null`

## returns the global filterset (future use)

    getGlobalFilterSet()

## Retrieves the current input handler.

    getInputHandler() : \InputHandler

### Returns

`\InputHandler`

## Returns the name of this project

    getName() : string

access | public
author | Andreas Aderhold, andi@binarycloud.com

### Returns

`string`projectname

## Get the minimum required phing version

    getPhingVersion() : string

### Returns

`string`

## Returns a copy of the properties table.

    getProperties() : array

### Returns

`array`A hashtable containing all properties (including user properties).

## Returns the value of a property, if it is set.

    getProperty(string $name) : string

### Parameters

#### $name

`string`

The name of the property. May be `null`, in which case the return value is also `null`.

### Returns

`string`The property value, or `null` for no match or if a `null` name is provided.

## Returns a specific reference.

    getReference(string $key) : object

### Parameters

#### $key

`string`

The reference id/key.

### Returns

`object`Reference or null if not defined

## Returns the references array.

    getReferences() : array

### Returns

`array`

## Returns the available targets

    getTargets() : array

### Returns

`array`

## Returns the task definitions

    getTaskDefinitions() : array

### Returns

`array`

## Returns a copy of the user property hashtable

    getUserProperties() : \a

### Returns

`\a`hashtable containing just the user properties

## Returns the value of a user property, if it is set.

    getUserProperty(string $name) : string

### Parameters

#### $name

`string`

The name of the property. May be `null`, in which case the return value is also `null`.

### Returns

`string`The property value, or `null` for no match or if a `null` name is provided.

## inits the project, called from main app

    init()

## Abstracting and simplifyling Logger calls for project messages

    log(string $msg, int $level)

### Parameters

#### $msg

`string`

#### $level

`int`

## logObject()

    logObject($obj, $msg, $level)

### Parameters

#### $obj

#### $msg

#### $level

## removeBuildListener()

    removeBuildListener(\BuildListener $listener)

### Parameters

#### $listener

## Replaces ${} style constructions in the given value with the string value of the corresponding data types.

    replaceProperties(\value $value) : \the

exception | BuildException if the given value has an unclosed property name, e.g. `${xxx`

### Parameters

#### $value

`\value`

The string to be scanned for property references. May be `null`.

### Returns

`\the`given string with embedded property names replaced by values, or `null` if the given string is `null`.

## Helper function

    resolveFile($fileName, $rootDir)

### Parameters

#### $fileName

#### $rootDir

## Set basedir object from xm

    setBasedir(\PhingFile | string $dir)

### Parameters

#### $dir

`\PhingFile` `string`

## Sets default target

    setDefaultTarget(string $targetName)

### Parameters

#### $targetName

`string`

## Set the projects description

    setDescription(string $description)

### Parameters

#### $description

`string`

## Sets a user property, which cannot be overwritten by set/unset property calls.

    setInheritedProperty(string $name, string $value)

Any previous value is overwritten. Also marks these properties as properties that have not come from the command line.

see | \global\#setProperty()

### Parameters

#### $name

`string`

The name of property to set. Must not be `null`.

#### $value

`string`

The new value of the property. Must not be `null`.

## Sets the input handler

    setInputHandler(\InputHandler $handler)

### Parameters

#### $handler

`\InputHandler`

## Sets the name of the current project

    setName(string $name) : void

access | public
author | Andreas Aderhold, andi@binarycloud.com

### Parameters

#### $name

`string`

name of project

## Sets a property if no value currently exists.

    setNewProperty(string $name, string $value)

If the property exists already, a message is logged and the method returns with no other effect.

since | 2.0

### Parameters

#### $name

`string`

The name of property to set. Must not be `null`.

#### $value

`string`

The new value of the property. Must not be `null`.

## Set the minimum required phing version

    setPhingVersion(string $version)

### Parameters

#### $version

`string`

## Sets a property.

    setProperty(string $name, string $value) : void

Any existing property of the same name is overwritten, unless it is a user property.

### Parameters

#### $name

`string`

The name of property to set. Must not be `null`.

#### $value

`string`

The new value of the property. Must not be `null`.

## Sets system properties and the environment variables for this project.

    setSystemProperties() : void

## Sets a user property, which cannot be overwritten by set/unset property calls.

    setUserProperty(string $name, string $value)

Any previous value is overwritten.

see | \global\#setProperty()

### Parameters

#### $name

`string`

The name of property to set. Must not be `null`.

#### $value

`string`

The new value of the property. Must not be `null`.

## Sets a property unless it is already defined as a user property (in which case the method returns silently).

    setPropertyInternal(\name $name, \value $value)

### Parameters

#### $name

`\name`

The name of the property. Must not be `null`.

#### $value

`\value`

The property value. Must not be `null`.

### Properties

##

    $basedir

##

    $defaultTarget

##

    $description

##

    $fileUtils

##

    $globalFilterSet

##

    $globalFilters

##

    $inheritedProperties

Mapping is String to String.

##

    $inputHandler

##

    $listeners

##

    $name

##

    $phingVersion

##

    $properties

##

    $references

##

    $targets

##

    $taskdefs

##

    $typedefs

##

    $userProperties

Note that these key/value pairs are also always put into the project properties, so only the project properties need to be queried. Mapping is String to String.

### Constants

## MSG_DEBUG

    MSG_DEBUG

## MSG_ERR

    MSG_ERR

## MSG_INFO

    MSG_INFO

## MSG_VERBOSE

    MSG_VERBOSE

## MSG_WARN

    MSG_WARN