# Project

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 andi@binarycloud.com
author | Hans Lellelid hans@xmpl.org
package | phing

### Methods

## Constructor, sets any default vars.

    __construct()

## _makeCircularException

    _makeCircularException(string $end, array $stk) : \BuildException

### Arguments

#### $end

`string`

#### $stk

`array`

### Response

`\BuildException`

## Topologically sort a set of Targets.

    _topoSort(string $root, array &$targets) : array

throws |

### Arguments

#### $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

### Response

`array`

of Strings with the names of the targets in sorted order.

## _tsort

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

throws |

### Arguments

#### $root

``

#### $targets

``

#### $state

``

#### $visiting

``

#### $ret

``

## addBuildListener

    addBuildListener(\BuildListener $listener)

### Arguments

#### $listener

`\BuildListener`

## Adds a data type definition.

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

### Arguments

#### $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)

### Arguments

#### $targetName

`string`

#### $target

`\Target`

## Adds a reference to an 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

    addReference(string $name, object $object)

### Arguments

#### $name

`string`

#### $object

`object`

## Add a new target to the project

    addTarget(string $targetName, \Target $target)

throws |

### Arguments

#### $targetName

`string`

#### $target

`\Target`

## Adds a task definition.

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

### Arguments

#### $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

### Arguments

#### $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

### Arguments

#### $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

throws |

### Arguments

#### $conditionType

`string`

### Response

`\Condition`

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

    createDataType(string $typeName) : object

throws | Exception

### Arguments

#### $typeName

`string`

Type name

### Response

`object`

A datatype object

## Create a new task instance and return reference to it. 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.

    createTask(string $taskType) : \Task

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.

throws | Exception

### Arguments

#### $taskType

`string`

Task name

### Response

`\Task`

A task object

## Executes a target

    executeTarget(string $targetName) : void

throws |

### Arguments

#### $targetName

`string`

Name of Target to execute

## Executes a list of targets

    executeTargets(array $targetNames) : void

throws |

### Arguments

#### $targetNames

`array`

List of target names to execute

## fireBuildFinished

    fireBuildFinished(\Exception $exception)

### Arguments

#### $exception

`\Exception`

## fireBuildStarted

    fireBuildStarted()

## fireMessageLogged

    fireMessageLogged( $object,  $message,  $priority)

### Arguments

#### $object

``

#### $message

``

#### $priority

``

## fireMessageLoggedEvent

    fireMessageLoggedEvent( $event,  $message,  $priority)

### Arguments

#### $event

``

#### $message

``

#### $priority

``

## fireTargetFinished

    fireTargetFinished( $target,  $exception)

### Arguments

#### $target

``

#### $exception

``

## fireTargetStarted

    fireTargetStarted( $target)

### Arguments

#### $target

``

## fireTaskFinished

    fireTaskFinished( $task,  $exception)

### Arguments

#### $task

``

#### $exception

``

## fireTaskStarted

    fireTaskStarted( $task)

### Arguments

#### $task

``

## Returns the basedir of this project

    getBasedir() : \PhingFile

throws |
author | Andreas Aderhold, andi@binarycloud.com

### Response

`\PhingFile`

Basedir PhingFile object

## getBuildListeners

    getBuildListeners() : array

### Response

`array`

## Returns the data type definitions

    getDataTypeDefinitions() : array

### Response

`array`

## Returns default target

    getDefaultTarget() : string

### Response

`string`

## return the description, null otherwise

    getDescription() : string|null

### Response

`string|null`

## returns the global filterset (future use)

    getGlobalFilterSet()

## Retrieves the current input handler.

    getInputHandler() : \InputHandler

### Response

`\InputHandler`

## Returns the name of this project

    getName() : string

author | Andreas Aderhold, andi@binarycloud.com

### Response

`string`

projectname

## Get the minimum required phing version

    getPhingVersion() : string

### Response

`string`

## Returns a copy of the properties table.

    getProperties() : array

### Response

`array`

A hashtable containing all properties (including user properties).

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

    getProperty(string $name) : string

### Arguments

#### $name

`string`

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

### Response

`string`

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

## Returns a specific reference.

    getReference(string $key) : object

### Arguments

#### $key

`string`

The reference id/key.

### Response

`object`

Reference or null if not defined

## Returns the references array.

    getReferences() : array

### Response

`array`

## Returns the available targets

    getTargets() : array

### Response

`array`

## Returns the task definitions

    getTaskDefinitions() : array

### Response

`array`

## Returns a copy of the user property hashtable

    getUserProperties() : array

### Response

`array`

a hashtable containing just the user properties

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

    getUserProperty(string $name) : string

### Arguments

#### $name

`string`

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

### Response

`string`

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

## inits the project, called from main app

    init()

## Return the keep-going mode. If the keepGoing settor/getter methods are used in conjunction with the <code>phing.executor.class</code> property, they will have no effect.

    isKeepGoingMode() : boolean

### Response

`boolean`

"keep-going" mode

## Abstracting and simplifyling Logger calls for project messages

    log(string $msg, integer $level = \Project::MSG_INFO)

### Arguments

#### $msg

`string`

#### $level

`integer`

## logObject

    logObject( $obj,  $msg,  $level)

### Arguments

#### $obj

``

#### $msg

``

#### $level

``

## removeBuildListener

    removeBuildListener(\BuildListener $listener)

### Arguments

#### $listener

`\BuildListener`

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

    replaceProperties(string $value) : string

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

### Arguments

#### $value

`string`

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

### Response

`string`

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

## Helper function

    resolveFile( $fileName, null $rootDir = null) : \PhingFile

throws |

### Arguments

#### $fileName

``

#### $rootDir

`null`

### Response

`\PhingFile`

## Set basedir object from xm

    setBasedir(\PhingFile|string $dir)

throws |

### Arguments

#### $dir

`\PhingFile|string`

## Sets default target

    setDefaultTarget(string $targetName)

### Arguments

#### $targetName

`string`

## Set the projects description

    setDescription(string $description)

### Arguments

#### $description

`string`

## Sets a user property, which cannot be overwritten by set/unset property calls. Any previous value is overwritten. Also marks these properties as properties that have not come from the command line.

    setInheritedProperty(string $name, string $value)

see | \#setProperty()

### Arguments

#### $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)

### Arguments

#### $handler

`\InputHandler`

## Set &quot;keep-going&quot; mode. In this mode Ant will try to execute as many targets as possible. All targets that do not depend on failed target(s) will be executed. If the keepGoing settor/getter methods are used in conjunction with the <code>ant.executor.class</code> property, they will have no effect.

    setKeepGoingMode( $keepGoingMode)

### Arguments

#### $keepGoingMode

``

## Sets the name of the current project

    setName(string $name) : void

author | Andreas Aderhold, andi@binarycloud.com

### Arguments

#### $name

`string`

name of project

## Sets a property if no value currently exists. If the property exists already, a message is logged and the method returns with no other effect.

    setNewProperty(string $name, string $value)

since | 2.0

### Arguments

#### $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)

### Arguments

#### $version

`string`

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

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

### Arguments

#### $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(string $name, string $value)

### Arguments

#### $name

`string`

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

#### $value

`string`

The property value. 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. Any previous value is overwritten.

    setUserProperty(string $name, string $value)

see | \#setProperty()

### Arguments

#### $name

`string`

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

#### $value

`string`

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

### Constants

## MSG_DEBUG

    MSG_DEBUG

## MSG_VERBOSE

    MSG_VERBOSE

## MSG_INFO

    MSG_INFO

## MSG_WARN

    MSG_WARN

## MSG_ERR

    MSG_ERR

### Properties

## contains the targets

    targets :

### Type(s)

``

## global filterset (future use)

    globalFilterSet :

### Type(s)

``

## all globals filters (future use)

    globalFilters :

### Type(s)

``

## Project properties map (usually String to String).

    properties :

### Type(s)

``

## Map of "user" properties (as created in the Ant task, for example).

    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.

### Type(s)

``

## Map of inherited "user" properties - that are those "user" properties that have been created by tasks and not been set from the command line or a GUI tool.

    inheritedProperties :

Mapping is String to String.

### Type(s)

``

## task definitions for this project

    taskdefs :

### Type(s)

``

## type definitions for this project

    typedefs :

### Type(s)

``

## holds ref names and a reference to the referred object

    references :

### Type(s)

``

## The InputHandler being used by this project.

    inputHandler :

### Type(s)

``

## basedir (PhingFile object)

    basedir :

### Type(s)

``

## the default target name

    defaultTarget :

### Type(s)

``

## project name (required)

    name :

### Type(s)

``

## project description

    description :

### Type(s)

``

## require phing version

    phingVersion :

### Type(s)

``

## a FileUtils object

    fileUtils :

### Type(s)

``

## Build listeneers

    listeners :

### Type(s)

``

## Keep going flag.

    keepGoingMode :

### Type(s)

``