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
)
:
\An
Topologically 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
)
:
void
Adds 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
)
:
void
Adds or replaces a target in the project
Name | Type | Description |
---|---|---|
$targetName | string | |
$target | \Target |


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


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


addTaskDefinition(
string $name, string $class, string $classpath
=
null
)
:
void
Adds 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
)
:
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}.
Name | Type | Description |
---|---|---|
$other | \Project | the project to copy the properties to. Must not be null. |
- 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}.
Name | Type | Description |
---|---|---|
$other | \Project | the project to copy the properties to. Must not be null. |
- Since
- phing 2.0


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


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


executeTargets(
array $targetNames
)
:
void
Executes 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(
)
:
\PhingFile
Returns the basedir of this project
Type | Description |
---|---|
\PhingFile | Basedir PhingFile object |
Exception | Description |
---|---|
\BuildException |
- Access
- public
- Author
- Andreas Aderhold, andi@binarycloud.com


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


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


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


getProperties(
)
:
array
Returns a copy of the properties table.
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.
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
)
:
object
Returns a specific reference.
Name | Type | Description |
---|---|---|
$key | string | The reference id/key. |
Type | Description |
---|---|
object | Reference or null if not defined |


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


getUserProperty(
string $name
)
:
string
Returns 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
)
:
void
Abstracting and simplifyling Logger calls for project messages
Name | Type | Description |
---|---|---|
$msg | string | |
$level | int |


replaceProperties(
\value $value
)
:
\the
Replaces ${} 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
)
:
void
Helper function
Name | Type | Description |
---|---|---|
$fileName | ||
$rootDir |


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


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


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


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.
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
)
:
void
Sets the input handler
Name | Type | Description |
---|---|---|
$handler | \InputHandler |


setName(
string $name
)
:
void
Sets 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
)
:
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.
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
)
:
void
Set the minimum required phing version
Name | Type | Description |
---|---|---|
$version | string |


setProperty(
string $name, string $value
)
:
void
Sets 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
)
:
void
Sets 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
)
:
void
Sets 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()