# Project.php

## \Project
jump to top

Package: phing

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
  $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
  n/a

`$defaultTarget= ''all''`

the default target name

Default value`'all'`Details

Type
  n/a

`$description= ''`

project description

Details

Type
  n/a

`$fileUtils= ''`

a FileUtils object

Details

Type
  n/a

`$globalFilterSet= 'array()'`

global filterset (future use)

Default value `array()`Details

Type
  n/a

`$globalFilters= 'array()'`

all globals filters (future use)

Default value `array()`Details

Type
  n/a

`$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
  n/a

`$inputHandler= ''`

The InputHandler being used by this project.

Details

Type
  n/a

`$listeners= 'array()'`

Build listeneers

Default value `array()`Details

Type
  n/a

`$name= ''`

project name (required)

Details

Type
  n/a

`$phingVersion= ''`

require phing version

Details

Type
  n/a

`$properties= 'array()'`

Project properties map (usually String to String).

Default value `array()`Details

Type
  n/a

`$references= 'array()'`

holds ref names and a reference to the referred object

Default value `array()`Details

Type
  n/a

`$targets= 'array()'`

contains the targets

Default value `array()`Details

Type
  n/a

`$taskdefs= 'array()'`

task definitions for this project

Default value `array()`Details

Type
  n/a

`$typedefs= 'array()'`

type definitions for this project

Default value `array()`Details

Type
  n/a

`$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
  n/a

### Methods

`__construct( ) : void`

Constructor, sets any default vars.

`_makeCircularException( $end, $stk ) : void`

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 | array of Strings with the names of the targets in sorted order.

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

Parameters

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

`addBuildListener( $listener ) : void`

Parameters

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

`addDataTypeDefinition( $typeName, $typeClass, string $classpath = null ) : void`

Adds a data type definition.

Parameters

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

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

Parameters

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

`addReference( $name, $object ) : void`

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 ) : void`

add a new target to the project

Parameters

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

`addTaskDefinition( string $name, string $class, string $classpath = null ) : void`

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 ) : void`

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 | A datatype object

Throws

Exception | Description
--- | ---
\BuildException | 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 | A task object

Throws

Exception | Description
--- | ---
\BuildException | Exception

`executeTarget( string $targetName ) : void`

Executes a target

Parameters

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

Throws

Exception | Description
--- | ---
\BuildException |

`executeTargets( array $targetNames ) : void`

Executes a list of targets

Parameters

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

Throws

Exception | Description
--- | ---
\BuildException |

`fireBuildFinished( $exception ) : void`

Parameters

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

`fireBuildStarted( ) : void`

`fireMessageLogged( $object, $message, $priority ) : void`

Parameters

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

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

Parameters

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

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

Parameters

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

`fireTargetStarted( $target ) : void`

Parameters

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

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

Parameters

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

`fireTaskStarted( $task ) : void`

Parameters

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

`getBasedir( ) : \PhingFile`

Returns the basedir of this project

Returns

Type | Description
--- | ---
\PhingFile | Basedir PhingFile object

Throws

Exception | Description
--- | ---
\BuildException |

Details

Access
  public
Author
  Andreas Aderhold, andi@binarycloud.com

`getBuildListeners( ) : void`

`getDataTypeDefinitions( ) : void`

`getDefaultTarget( ) : void`

`getDescription( ) : void`

return the description, null otherwise

`getGlobalFilterSet( ) : void`

returns the global filterset (future use)

`getInputHandler( ) : void`

Retrieves the current input handler.

`getName( ) : string`

Returns the name of this project

Returns

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

Details

Access
  public
Author
  Andreas Aderhold, andi@binarycloud.com

`getPhingVersion( ) : void`

Get the minimum required phing version *

`getProperties( ) : array`

Returns a copy of the properties table.

Returns

Type | Description
--- | ---
array | A hashtable containing all properties (including user properties).

`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 | The property value, or <code>null</code> for no match or if a <code>null</code> name is provided.

`getReference( string $key ) : \Reference`

Returns a specific reference.

Parameters

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

Returns

Type | Description
--- | ---
\Reference | or null if not defined

`getReferences( ) : array`

Returns the references array.

Returns

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

`getTargets( ) : void`

`getTaskDefinitions( ) : void`

`getUserProperties( ) : \a`

Returns a copy of the user property hashtable

Returns

Type | Description
--- | ---
\a | hashtable containing just the user properties

`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 | The property value, or <code>null</code> for no match or if a <code>null</code> name is provided.

`init( ) : void`

inits the project, called from main app

`log( $msg, $level = Project::MSG_INFO ) : void`

Abstracting and simplifyling Logger calls for project messages

Parameters

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

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

Parameters

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

`removeBuildListener( $listener ) : void`

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 | given string with embedded property names replaced by values, or <code>null</code> if the given string is <code>null</code>.

Details

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

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

Parameters

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

`setBasedir( $dir ) : void`

Set basedir object from xml

Parameters

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

`setDefaultTarget( $targetName ) : void`

Parameters

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

`setDescription( $description ) : void`

Set the projects description

Parameters

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

`setInheritedProperty( string $name, string $value ) : void`

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 ) : void`

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 ) : void`

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 ) : void`

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 ) : void`

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 ) : void`

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.17.1.