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 <hans@xmpl.org> (Phing)
author Thomas.Haas@softwired-inc.com (Ant)
author Stefan Bodewig <stefan.bodewig@epost.de> (Ant)
package phing.types
version $Id$

 Methods

Return a Path that holds the same elements as this instance.

__clone() 

Constructor for internally instantiated objects sets project.

__construct(\Project $project, string $path) 

Parameters

$project

\Project

$path

string

(for use by IntrospectionHelper)

Returns a textual representation of the path, which can be used as CLASSPATH or PATH environment variable definition.

__toString() : string

Returns

stringA textual representation of the path.

Adds a nested <code>&lt;dirset&gt;</code> element.

addDirset(\DirSet $dset) 

Parameters

$dset

Exceptions

\BuildException

Adds the components on the given path which exist to this Path.

addExisting(\Path $source) 

Components that don't exist, aren't added.

Parameters

$source

\Path
  • Source path whose components are examined for existence.

Adds a nested <code>&lt;fileset&gt;</code> element.

addFileset(\FileSet $fs) 

Parameters

$fs

Exceptions

\BuildException

Append the contents of the other Path instance to this.

append(\Path $other) 

Parameters

$other

Creates an exception that indicates the user has generated a loop of data types referencing each other.

circularReference() 
Inherited
inherited_from \DataType::circularReference()

Creates a nested <code>&lt;path&gt;</code> element.

createPath() 

Exceptions

\BuildException

Creates the nested <code>&lt;pathelement&gt;</code> element.

createPathElement() 

Exceptions

\BuildException

Overrides the version of DataType to recurse on all DataType child elements that may have been added.

dieOnCircularReference($stk, \Project $p) 

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.

Parameters

$stk

$p

Exceptions

\BuildException

Performs the check for circular references and returns the referenced object.

getCheckedRef($requiredClass, $dataTypeName) 
Inherited
inherited_from \DataType::getCheckedRef()

Parameters

$requiredClass

$dataTypeName

Return the description for the current data type.

getDescription() 
Inherited
inherited_from \DataType::getDescription()

Returns a reference to current project

getProject() : \Project
Inherited
inherited_from \ProjectComponent::getProject()
inherited_from \DataType::getProject()

Returns

\ProjectReference to current porject object

Has the refid attribute of this element been set?

isReference() 
Inherited
inherited_from \DataType::isReference()

Returns all path elements defined by this and nested path objects.

listPaths() : array

Returns

arrayList of path elements.

Logs a message with the given priority.

log(string $msg, integer $level) 
Inherited
inherited_from \ProjectComponent::log()
inherited_from \DataType::log()

Parameters

$msg

string

The message to be logged.

$level

integer

The message's priority at this message should have

Creates an exception that indicates that this XML element must not have child elements if the refid attribute is set.

noChildrenAllowed() 
Inherited
inherited_from \DataType::noChildrenAllowed()

Template method being called when the data type has been parsed completely.

parsingComplete() : void
Inherited
inherited_from \DataType::parsingComplete()

Sets a description of the current data type.

setDescription($desc) 
Inherited

It will be useful in commenting what we are doing.

inherited_from \DataType::setDescription()

Parameters

$desc

Adds a element definition to the path.

setDir(\PhingFile $location) 

Parameters

$location

the location of the element to add (must not be null nor empty.

Exceptions

\BuildException

Parses a path definition and creates single PathElements.

setPath(\path $path) 

Parameters

$path

\path

the path definition.

Exceptions

\BuildException

References the project to the current component.

setProject(\Project $project) 
Inherited
inherited_from \ProjectComponent::setProject()
inherited_from \DataType::setProject()

Parameters

$project

\Project

The reference to the current project

Makes this instance in effect a reference to another Path instance.

setRefid(\Reference $r) : void

You must not set another attribute or nest elements inside this element if you make it a reference.

Parameters

Exceptions

\BuildException

How many parts does this Path instance consist of.

size() : int

DEV NOTE: expensive call! list is generated, counted, and then discareded.

Returns

int

Creates an exception that indicates that refid has to be the only attribute if it is set.

tooManyAttributes() 
Inherited
inherited_from \DataType::tooManyAttributes()

Returns its argument with all file separator characters replaced so that they match the local OS conventions.

translateFile($source) 
Static

Parameters

$source

Splits a PATH (with : or ; as separators) into its parts.

translatePath(\Project $project, string $source) 
Static

Parameters

$project

\Project

$source

string

Translates all occurrences of / or \ to correct separator of the current platform and returns whether it had to do any replacements.

translateFileSep($buffer, $pos) 
Static

Parameters

$buffer

$pos

Resolve a filename with Project's help - if we know one that is.

resolveFile(\Project $project, $relativeName) 
Static

Assume the filename is absolute if project is null.

Parameters

$project

$relativeName

 Properties

 

$description 
Inherited
inherited_from \DataType::$$description
 

$ref 
Inherited

Type of Reference

inherited_from \DataType::$$ref
 

$checked : boolean
Inherited

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

inherited_from \DataType::$$checked
 

$project : \Project
Inherited
inherited_from \ProjectComponent::$$project
inherited_from \DataType::$$project
 

$elements