Project.php
\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
- Author
- Hans Lellelid
- Version
- $Id: 7e67218e8e616860f9c746f9ab600f523089ea2e $
Constants
Properties

$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.
array()Details- Type
- n/a

$properties= 'array()'
Project properties map (usually String to String).
array()Details- Type
- n/a

$references= 'array()'
holds ref names and a reference to the referred object
array()Details- Type
- n/a
Methods

_topoSort(
string $root, array $targets
)
:
\AnTopologically sort a set of Targets.
| Name | Type | Description |
|---|---|---|
| $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 |
| Type | Description |
|---|---|
| \An | array of Strings with the names of the targets in sorted order. |

_tsort(
$root, $targets, $state, $visiting, $ret
)
:
void| Name | Type | Description |
|---|---|---|
| $root | ||
| $targets | ||
| $state | ||
| $visiting | ||
| $ret |

addDataTypeDefinition(
string $typeName, string $typeClass, string $classpath
=
null
)
:
voidAdds a data type definition.
| Name | Type | Description |
|---|---|---|
| $typeName | string | Name of the type. |
| $typeClass | string | The class to use. |
| $classpath | string | The classpath to use. |

addOrReplaceTarget(
string $targetName, \Target $target
)
:
voidAdds or replaces a target in the project
| Name | Type | Description |
|---|---|---|
| $targetName | string | |
| $target | \Target |

addReference(
string $name, object $object
)
:
voidAdds 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
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $object | object |

addTarget(
string $targetName, \Target $target
)
:
voidAdd a new target to the project
| Name | Type | Description |
|---|---|---|
| $targetName | string | |
| $target | \Target |

addTaskDefinition(
string $name, string $class, string $classpath
=
null
)
:
voidAdds a task definition.
| Name | Type | Description |
|---|---|---|
| $name | string | Name of tag. |
| $class | string | The class path to use. |
| $classpath | string | The classpat to use. |

copyInheritedProperties(
\Project $other
)
:
voidCopies 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}.
| Name | Type | Description |
|---|---|---|
| $other | \Project | the project to copy the properties to. Must not be null. |
- Since
- phing 2.0

copyUserProperties(
\Project $other
)
:
voidCopies 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}.
| Name | Type | Description |
|---|---|---|
| $other | \Project | the project to copy the properties to. Must not be null. |
- Since
- phing 2.0

createDataType(
string $typeName
)
:
objectCreate a datatype instance and return reference to it See createTask() for explanation how this works
| Name | Type | Description |
|---|---|---|
| $typeName | string | Type name |
| Type | Description |
|---|---|
| object | A datatype object |
| Exception | Description |
|---|---|
| \BuildException | Exception |

createTask(
string $taskType
)
:
\TaskCreate 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.
| Name | Type | Description |
|---|---|---|
| $taskType | string | Task name |
| Type | Description |
|---|---|
| \Task | A task object |
| Exception | Description |
|---|---|
| \BuildException | Exception |

executeTarget(
string $targetName
)
:
voidExecutes a target
| Name | Type | Description |
|---|---|---|
| $targetName | string | Name of Target to execute |
| Exception | Description |
|---|---|
| \BuildException |

executeTargets(
array $targetNames
)
:
voidExecutes a list of targets
| Name | Type | Description |
|---|---|---|
| $targetNames | array | List of target names to execute |
| Exception | Description |
|---|---|
| \BuildException |

fireMessageLogged(
$object, $message, $priority
)
:
void| Name | Type | Description |
|---|---|---|
| $object | ||
| $message | ||
| $priority |

fireMessageLoggedEvent(
$event, $message, $priority
)
:
void| Name | Type | Description |
|---|---|---|
| $event | ||
| $message | ||
| $priority |

fireTargetFinished(
$target, $exception
)
:
void| Name | Type | Description |
|---|---|---|
| $target | ||
| $exception |

getBasedir(
)
:
\PhingFileReturns the basedir of this project
| Type | Description |
|---|---|
| \PhingFile | Basedir PhingFile object |
| Exception | Description |
|---|---|
| \BuildException |
- Access
- public
- Author
- Andreas Aderhold, andi@binarycloud.com

getDescription(
)
:
string | nullreturn the description, null otherwise
| Type | Description |
|---|---|
| string | null |

getInputHandler(
)
:
\InputHandlerRetrieves the current input handler.
| Type | Description |
|---|---|
| \InputHandler |

getName(
)
:
stringReturns the name of this project
| Type | Description |
|---|---|
| string | projectname |
- Access
- public
- Author
- Andreas Aderhold, andi@binarycloud.com

getProperties(
)
:
arrayReturns a copy of the properties table.
| Type | Description |
|---|---|
| array | A hashtable containing all properties (including user properties). |

getProperty(
string $name
)
:
stringReturns the value of a property, if it is set.
| Name | Type | Description |
|---|---|---|
| $name | string | The name of the property. May be |
| 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
)
:
objectReturns a specific reference.
| Name | Type | Description |
|---|---|---|
| $key | string | The reference id/key. |
| Type | Description |
|---|---|
| object | Reference or null if not defined |

getUserProperties(
)
:
\aReturns a copy of the user property hashtable
| Type | Description |
|---|---|
| \a | hashtable containing just the user properties |

getUserProperty(
string $name
)
:
stringReturns the value of a user property, if it is set.
| Name | Type | Description |
|---|---|---|
| $name | string | The name of the property. May be |
| Type | Description |
|---|---|
| string | The property value, or <code>null</code> for no match or if a <code>null</code> name is provided. |

log(
string $msg, int $level
=
Project::MSG_INFO
)
:
voidAbstracting and simplifyling Logger calls for project messages
| Name | Type | Description |
|---|---|---|
| $msg | string | |
| $level | int |

replaceProperties(
\value $value
)
:
\theReplaces ${} style constructions in the given value with the string value of the corresponding data types.
| Name | Type | Description |
|---|---|---|
| $value | \value | The string to be scanned for property references. May be |
| Type | Description |
|---|---|
| \the | given string with embedded property names replaced by values, or <code>null</code> if the given string is <code>null</code>. |
- Exception
- BuildException if the given value has an unclosed
property name, e.g.
${xxx

resolveFile(
$fileName, $rootDir
=
null
)
:
voidHelper function
| Name | Type | Description |
|---|---|---|
| $fileName | ||
| $rootDir |

setBasedir(
\PhingFile | string $dir
)
:
voidSet basedir object from xm
| Name | Type | Description |
|---|---|---|
| $dir | \PhingFile | string |

setDefaultTarget(
string $targetName
)
:
voidSets default target
| Name | Type | Description |
|---|---|---|
| $targetName | string |

setDescription(
string $description
)
:
voidSet the projects description
| Name | Type | Description |
|---|---|---|
| $description | string |

setInheritedProperty(
string $name, string $value
)
:
voidSets 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.
| Name | Type | Description |
|---|---|---|
| $name | string | The name of property to set. Must not be |
| $value | string | The new value of the property. Must not be |
- See
- \#setProperty()

setInputHandler(
\InputHandler $handler
)
:
voidSets the input handler
| Name | Type | Description |
|---|---|---|
| $handler | \InputHandler |

setName(
string $name
)
:
voidSets the name of the current project
| Name | Type | Description |
|---|---|---|
| $name | string | name of project |
- Access
- public
- Author
- Andreas Aderhold, andi@binarycloud.com

setNewProperty(
string $name, string $value
)
:
voidSets a property if no value currently exists. If the property exists already, a message is logged and the method returns with no other effect.
| Name | Type | Description |
|---|---|---|
| $name | string | The name of property to set. Must not be |
| $value | string | The new value of the property. Must not be |
- Since
- 2.0

setPhingVersion(
string $version
)
:
voidSet the minimum required phing version
| Name | Type | Description |
|---|---|---|
| $version | string |

setProperty(
string $name, string $value
)
:
voidSets a property. Any existing property of the same name is overwritten, unless it is a user property.
| Name | Type | Description |
|---|---|---|
| $name | string | The name of property to set. Must not be |
| $value | string | The new value of the property. Must not be |

setPropertyInternal(
\name $name, \value $value
)
:
voidSets a property unless it is already defined as a user property (in which case the method returns silently).
| Name | Type | Description |
|---|---|---|
| $name | \name | The name of the property. Must not be |
| $value | \value | The property value. Must not be |

setUserProperty(
string $name, string $value
)
:
voidSets a user property, which cannot be overwritten by set/unset property calls. Any previous value is overwritten.
| Name | Type | Description |
|---|---|---|
| $name | string | The name of property to set. Must not be |
| $value | string | The new value of the property. Must not be |
- See
- \#setProperty()