# classes/phing/Project.php

## \Project
jump to top

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
package
  phing
version
  $Revision: 1097 $

### Constants

`MSG_DEBUG = '4'`

`MSG_VERBOSE = '3'`

`MSG_INFO = '2'`

`MSG_WARN = '1'`

`MSG_ERR = '0'`

### Properties

`$basedir= ''`

basedir (PhingFile object)

Details

Type

`$defaultTarget= 'all'`

the default target name

Default value `all` Details

Type

`$description= ''`

project description

Details

Type

`$fileUtils= ''`

a FileUtils object

Details

Type

`$globalFilterSet= 'array'`

global filterset (future use)

Default value `array` Details

Type

`$globalFilters= 'array'`

all globals filters (future use)

Default value `array` Details

Type

`$inheritedProperties= 'array'`

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.

Mapping is String to String.

Default value `array` Details

Type

`$inputHandler= ''`

The InputHandler being used by this project.

Details

Type

`$listeners= 'array'`

Build listeneers

Default value `array` Details

Type

`$name= ''`

project name (required)

Details

Type

`$phingVersion= ''`

require phing version

Details

Type

`$properties= 'array'`

Project properties map (usually String to String).

Default value `array` Details

Type

`$references= 'array'`

holds ref names and a reference to the referred object

Default value `array` Details

Type

`$targets= 'array'`

contains the targets

Default value `array` Details

Type

`$taskdefs= 'array'`

task definitions for this project

Default value `array` Details

Type

`$typedefs= 'array'`

type definitions for this project

Default value `array` Details

Type

`$userProperties= 'array'`

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

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.

Default value `array` Details

Type

### Methods

`__construct( ) :`
Constructor, sets any default vars.
`_makeCircularException( $end, $stk ) :`
Parameters

Name | Type | Description
--- | --- | ---
$end |  |
$stk |  |

`_topoSort( \$root $root, \$targets $targets ) : \An`
Topologically sort a set of Targets.
Parameters

Name | Type | Description
--- | --- | ---
$root | \$root | 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 | \$targets | is a array representing a "name to Target" mapping

Returns

Type | Description
--- | ---
\An |

`_tsort( $root, $targets, $state, $visiting, $ret ) :`
Parameters

Name | Type | Description
--- | --- | ---
$root |  |
$targets |  |
$state |  |
$visiting |  |
$ret |  |

`addBuildListener( $listener ) :`
Parameters

Name | Type | Description
--- | --- | ---
$listener |  |

`addDataTypeDefinition( $typeName, $typeClass, string $classpath = null ) :`
Adds a data type definition.
Parameters

Name | Type | Description
--- | --- | ---
$typeName |  |
$typeClass |  |
$classpath | string | The classpat to use.

`addOrReplaceTarget( $targetName, $target ) :`
Parameters

Name | Type | Description
--- | --- | ---
$targetName |  |
$target |  |

`addReference( $name, $object ) :`
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
Parameters

Name | Type | Description
--- | --- | ---
$name |  |
$object |  |

`addTarget( $targetName, $target ) :`
add a new target to the project
Parameters

Name | Type | Description
--- | --- | ---
$targetName |  |
$target |  |

`addTaskDefinition( string $name, string $class, string $classpath = null ) :`
Adds a task definition.
Parameters

Name | Type | Description
--- | --- | ---
$name | string | Name of tag.
$class | string | The class path to use.
$classpath | string | The classpat to use.

`copyInheritedProperties( \other $other ) :`
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.

To copy all "user" properties, you will also have to call {@link #copyUserProperties copyUserProperties}.

Parameters

Name | Type | Description
--- | --- | ---
$other | \other | the project to copy the properties to. Must not be null.

Details

since
  phing 2.0

`copyUserProperties( \Project $other ) : void`
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.

To copy all "user" properties, you will also have to call {@link #copyInheritedProperties copyInheritedProperties}.

Parameters

Name | Type | Description
--- | --- | ---
$other | \Project | the project to copy the properties to. Must not be null.

Details

since
  phing 2.0

`createDataType( string $typeName ) : object`
Create a datatype instance and return reference to it See createTask() for explanation how this works
Parameters

Name | Type | Description
--- | --- | ---
$typeName | string | Type name

Returns

Type | Description
--- | ---
object |

Details

throws
  Exception

`createTask( string $taskType ) : \Task`
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.

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

Name | Type | Description
--- | --- | ---
$taskType | string | Task name

Returns

Type | Description
--- | ---
\Task |

Details

throws
  Exception

`executeTarget( string $targetName ) : void`
Executes a target
Parameters

Name | Type | Description
--- | --- | ---
$targetName | string | Name of Target to execute

Details

throws

`executeTargets( array $targetNames ) : void`
Executes a list of targets
Parameters

Name | Type | Description
--- | --- | ---
$targetNames | array | List of target names to execute

Details

throws

`fireBuildFinished( $exception ) :`
Parameters

Name | Type | Description
--- | --- | ---
$exception |  |

`fireBuildStarted( ) :`
`fireMessageLogged( $object, $message, $priority ) :`
Parameters

Name | Type | Description
--- | --- | ---
$object |  |
$message |  |
$priority |  |

`fireMessageLoggedEvent( $event, $message, $priority ) :`
Parameters

Name | Type | Description
--- | --- | ---
$event |  |
$message |  |
$priority |  |

`fireTargetFinished( $target, $exception ) :`
Parameters

Name | Type | Description
--- | --- | ---
$target |  |
$exception |  |

`fireTargetStarted( $target ) :`
Parameters

Name | Type | Description
--- | --- | ---
$target |  |

`fireTaskFinished( $task, $exception ) :`
Parameters

Name | Type | Description
--- | --- | ---
$task |  |
$exception |  |

`fireTaskStarted( $task ) :`
Parameters

Name | Type | Description
--- | --- | ---
$task |  |

`getBasedir( ) : \PhingFile`
Returns the basedir of this project
Returns

Type | Description
--- | ---
\PhingFile |

Details

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

`getBuildListeners( ) :`
`getDataTypeDefinitions( ) :`
`getDefaultTarget( ) :`
`getDescription( ) :`
return the description, null otherwise
`getGlobalFilterSet( ) :`
returns the global filterset (future use)
`getInputHandler( ) :`
Retrieves the current input handler.
`getName( ) : string`
Returns the name of this project
Returns

Type | Description
--- | ---
string |

Details

access
  public
author
  Andreas Aderhold, andi@binarycloud.com

`getPhingVersion( ) :`
Get the minimum required phing version *
`getProperties( ) : array`
Returns a copy of the properties table.
Returns

Type | Description
--- | ---
array |

`getProperty( string $name ) : string`
Returns the value of a property, if it is set.
Parameters

Name | Type | Description
--- | --- | ---
$name | string | The name of the property. May be `null`, in which case the return value is also `null`.

Returns

Type | Description
--- | ---
string |

`getReference( string $key ) : \Reference`
Returns a specific reference.
Parameters

Name | Type | Description
--- | --- | ---
$key | string | The reference id/key.

Returns

Type | Description
--- | ---
\Reference |

`getReferences( ) : array`
Returns the references array.
Returns

Type | Description
--- | ---
array |

`getTargets( ) :`
`getTaskDefinitions( ) :`
`getUserProperties( ) : \a`
Returns a copy of the user property hashtable
Returns

Type | Description
--- | ---
\a |

`getUserProperty( string $name ) : string`
Returns the value of a user property, if it is set.
Parameters

Name | Type | Description
--- | --- | ---
$name | string | The name of the property. May be `null`, in which case the return value is also `null`.

Returns

Type | Description
--- | ---
string |

`init( ) :`
inits the project, called from main app
`log( $msg, $level = Project ) :`
Abstracting and simplifyling Logger calls for project messages
Parameters

Name | Type | Description
--- | --- | ---
$msg |  |
$level |  |

`logObject( $obj, $msg, $level ) :`
Parameters

Name | Type | Description
--- | --- | ---
$obj |  |
$msg |  |
$level |  |

`removeBuildListener( $listener ) :`
Parameters

Name | Type | Description
--- | --- | ---
$listener |  |

`replaceProperties( \value $value ) : \the`
Replaces ${} style constructions in the given value with the string value of the corresponding data types.
Parameters

Name | Type | Description
--- | --- | ---
$value | \value | The string to be scanned for property references. May be `null`.

Returns

Type | Description
--- | ---
\the |

Details

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

`resolveFile( $fileName, $rootDir = null ) :`
Parameters

Name | Type | Description
--- | --- | ---
$fileName |  |
$rootDir |  |

`setBasedir( $dir ) :`
Set basedir object from xml
Parameters

Name | Type | Description
--- | --- | ---
$dir |  |

`setDefaultTarget( $targetName ) :`
Parameters

Name | Type | Description
--- | --- | ---
$targetName |  |

`setDescription( $description ) :`
Set the projects description
Parameters

Name | Type | Description
--- | --- | ---
$description |  |

`setInheritedProperty( string $name, string $value ) :`
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.
Parameters

Name | Type | Description
--- | --- | ---
$name | string | The name of property to set. Must not be `null`.
$value | string | The new value of the property. Must not be `null`.

Details

see
  \#setProperty()

`setInputHandler( $handler ) :`
Sets the input handler
Parameters

Name | Type | Description
--- | --- | ---
$handler |  |

`setName( string $name ) : void`
Sets the name of the current project
Parameters

Name | Type | Description
--- | --- | ---
$name | string | name of project

Details

access
  public
author
  Andreas Aderhold, andi@binarycloud.com

`setNewProperty( string $name, string $value ) :`
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.
Parameters

Name | Type | Description
--- | --- | ---
$name | string | The name of property to set. Must not be `null`.
$value | string | The new value of the property. Must not be `null`.

Details

since
  2.0

`setPhingVersion( $version ) :`
Set the minimum required phing version *
Parameters

Name | Type | Description
--- | --- | ---
$version |  |

`setProperty( string $name, string $value ) : void`
Sets a property. Any existing property of the same name is overwritten, unless it is a user property.
Parameters

Name | Type | Description
--- | --- | ---
$name | string | The name of property to set. Must not be `null`.
$value | string | The new value of the property. Must not be `null`.

`setPropertyInternal( \name $name, \value $value ) :`
Sets a property unless it is already defined as a user property (in which case the method returns silently).
Parameters

Name | Type | Description
--- | --- | ---
$name | \name | The name of the property. Must not be `null`.
$value | \value | The property value. Must not be `null`.

`setSystemProperties( ) : void`
Sets system properties and the environment variables for this project.
`setUserProperty( string $name, string $value ) :`
Sets a user property, which cannot be overwritten by set/unset property calls. Any previous value is overwritten.
Parameters

Name | Type | Description
--- | --- | ---
$name | string | The name of property to set. Must not be `null`.
$value | string | The new value of the property. Must not be `null`.

Details

see
  \#setProperty()

Documentation was generated by DocBlox 0.13.1.