types/Path.php
This object represents a path as used by include_path or PATH environment variable.
This class has been adopted from the Java Ant equivalent. The ability have path structures in Phing is important; however, because of how PHP classes interact the ability to specify CLASSPATHs makes less sense than Java.Rather than providing CLASSPATH for any tasks that take classes as parameters, perhaps a better solution in PHP is to have an IncludePath task, which prepends paths to PHP's include_path INI variable. This gets around the problem that simply using a path to load the initial PHP class is not enough (in most cases the loaded class may assume that it is on the global PHP include_path, and will try to load dependent classes accordingly). The other option is to provide a way for this class to add paths to the include path, if desired -- or to create an IncludePath subclass. Once added, though, when would a path be removed from the include path?
<
p>
<sometask>
<somepath>
<pathelement location="/path/to/file" />
<pathelement path="/path/to/class2;/path/to/class3" />
<pathelement location="/path/to/file3" />
</somepath>
</sometask>
<
p> The object implemention
sometask
must provide a method called
createSomepath
which returns an instance of
Path
. Nested path definitions are handled by the Path object and must be labeled
pathelement
.
<
p>
The path element takes a parameter
path
which will be parsed and split into single elements. It will usually be used to define a path from an environment variable.
- Author
- Hans Lellelid
(Phing) - Author
- Thomas.Haas@softwired-inc.com (Ant)
- Author
- Stefan Bodewig
(Ant) - Package
- phing.types
\Path
This object represents a path as used by include_path or PATH environment variable.
This class has been adopted from the Java Ant equivalent. The ability have path structures in Phing is important; however, because of how PHP classes interact the ability to specify CLASSPATHs makes less sense than Java.Rather than providing CLASSPATH for any tasks that take classes as parameters, perhaps a better solution in PHP is to have an IncludePath task, which prepends paths to PHP's include_path INI variable. This gets around the problem that simply using a path to load the initial PHP class is not enough (in most cases the loaded class may assume that it is on the global PHP include_path, and will try to load dependent classes accordingly). The other option is to provide a way for this class to add paths to the include path, if desired -- or to create an IncludePath subclass. Once added, though, when would a path be removed from the include path?
<
p>
<sometask>
<somepath>
<pathelement location="/path/to/file" />
<pathelement path="/path/to/class2;/path/to/class3" />
<pathelement location="/path/to/file3" />
</somepath>
</sometask>
<
p> The object implemention
sometask
must provide a method called
createSomepath
which returns an instance of
Path
. Nested path definitions are handled by the Path object and must be labeled
pathelement
.
<
p>
The path element takes a parameter
path
which will be parsed and split into single elements. It will usually be used to define a path from an environment variable.
- Parent(s)
- \DataType < \ProjectComponent
- Author
- Hans Lellelid
(Phing) - Author
- Thomas.Haas@softwired-inc.com (Ant)
- Author
- Stefan Bodewig
(Ant) - Version
- $Id$
Properties


boolean
$checked= 'true'
Subclasses are responsible for setting this value to false if we'd need to investigate this condition (usually because a child element has been added that is a subclass of DataType).
true
Details- Type
- boolean
- Inherited_from
- \DataType::$$checked


\Project
$project= 'null'
Holds a reference to the project that a project component (a task, a target, etc.) belongs to
A reference to the current project instanceInherited from: \ProjectComponent::$$project\DataType::$$projectnull
Details- Type
- \Project
- Inherited_from
- \ProjectComponent::$$project
- Inherited_from
- \DataType::$$project
Methods


__construct(
\Project $project
=
null, string $path
=
null
)
:
void
Constructor for internally instantiated objects sets project.
Name | Type | Description |
---|---|---|
$project | \Project | |
$path | string | (for use by IntrospectionHelper) |


__toString(
)
:
string
Returns a textual representation of the path, which can be used as CLASSPATH or PATH environment variable definition.
Type | Description |
---|---|
string | A textual representation of the path. |


addDirset(
$dset
)
:
void
Adds a nested <dirset>
element.
Name | Type | Description |
---|---|---|
$dset |
Exception | Description |
---|---|
\BuildException |


addExisting(
\Path $source
)
:
void
Adds the components on the given path which exist to this Path. Components that don't exist, aren't added.
Name | Type | Description |
---|---|---|
$source | \Path |
|


addFileset(
$fs
)
:
void
Adds a nested <fileset>
element.
Name | Type | Description |
---|---|---|
$fs |
Exception | Description |
---|---|
\BuildException |


append(
$other
)
:
void
Append the contents of the other Path instance to this.
Name | Type | Description |
---|---|---|
$other |


circularReference(
)
:
void
Creates an exception that indicates the user has generated a loop of data types referencing each other.
Inherited from: \DataType::circularReference()

createPathElement(
)
:
void
Creates the nested <pathelement>
element.
Exception | Description |
---|---|
\BuildException |


dieOnCircularReference(
$stk, $p
)
:
void
Overrides the version of DataType to recurse on all DataType child elements that may have been added.
If one is included, throw a BuildException created by circularReference
This implementation is appropriate only for a DataType that cannot hold other DataTypes as children.
The general contract of this method is that it shouldn't do anything if checked is true and set it to true on exit.
Name | Type | Description |
---|---|---|
$stk | ||
$p |
Exception | Description |
---|---|
\BuildException |


getCheckedRef(
$requiredClass, $dataTypeName
)
:
void
Performs the check for circular references and returns the referenced object.
Inherited from: \DataType::getCheckedRef()Name | Type | Description |
---|---|---|
$requiredClass | ||
$dataTypeName |


getDescription(
)
:
void
Return the description for the current data type.
Inherited from: \DataType::getDescription()

getProject(
)
:
\Project
Returns a reference to current project
Inherited from: \ProjectComponent::getProject()\DataType::getProject()Type | Description |
---|---|
\Project | Reference to current porject object |


listPaths(
)
:
array
Returns all path elements defined by this and nested path objects.
Type | Description |
---|---|
array | List of path elements. |


log(
string $msg, integer $level
=
Project::MSG_INFO
)
:
void
Logs a message with the given priority.
Inherited from: \ProjectComponent::log()\DataType::log()Name | Type | Description |
---|---|---|
$msg | string | The message to be logged. |
$level | integer | The message's priority at this message should have |


noChildrenAllowed(
)
:
void
Creates an exception that indicates that this XML element must not have child elements if the refid attribute is set.
Inherited from: \DataType::noChildrenAllowed()

parsingComplete(
)
:
void
Template method being called when the data type has been parsed completely.
Inherited from: \DataType::parsingComplete()

resolveFile(
$project, $relativeName
)
:
void
Resolve a filename with Project's help - if we know one that is.
Assume the filename is absolute if project is null.
Name | Type | Description |
---|---|---|
$project | ||
$relativeName |


setDescription(
$desc
)
:
void
Sets a description of the current data type. It will be useful in commenting what we are doing.
Inherited from: \DataType::setDescription()Name | Type | Description |
---|---|---|
$desc |


setDir(
\$location $location
)
:
void
Adds a element definition to the path.
Name | Type | Description |
---|---|---|
$location | \$location | the location of the element to add (must not be |
Exception | Description |
---|---|
\BuildException |


setPath(
\path $path
)
:
void
Parses a path definition and creates single PathElements.
Name | Type | Description |
---|---|---|
$path | \path | the path definition. |
Exception | Description |
---|---|
\BuildException |


setProject(
\Project $project
)
:
void
References the project to the current component.
Inherited from: \ProjectComponent::setProject()\DataType::setProject()Name | Type | Description |
---|---|---|
$project | \Project | The reference to the current project |


setRefid(
\Reference $r
)
:
void
Makes this instance in effect a reference to another Path instance.
You must not set another attribute or nest elements inside this element if you make it a reference.
Name | Type | Description |
---|---|---|
$r | \Reference |
Exception | Description |
---|---|
\BuildException |


size(
)
:
int
How many parts does this Path instance consist of.
DEV NOTE: expensive call! list is generated, counted, and then discareded.
Type | Description |
---|---|
int |


tooManyAttributes(
)
:
void
Creates an exception that indicates that refid has to be the only attribute if it is set.
Inherited from: \DataType::tooManyAttributes()

translateFile(
$source
)
:
void
Returns its argument with all file separator characters replaced so that they match the local OS conventions.
Name | Type | Description |
---|---|---|
$source |


translateFileSep(
$buffer, $pos
)
:
void
Translates all occurrences of / or \ to correct separator of the current platform and returns whether it had to do any replacements.
Name | Type | Description |
---|---|---|
$buffer | ||
$pos |
\PathElement
Helper class, holds the nested <code><pathelement></code> values.