Path

Extends \DataType

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?

<sometask>
  <somepath>
    <pathelement location="/path/to/file" />
    <pathelement path="/path/to/class2;/path/to/class3" />
    <pathelement location="/path/to/file3" />
  </somepath>
</sometask>

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.

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

Methods

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

__clone() 

Constructor for internally instantiated objects sets project.

__construct(\Project $project = null, string $path = null) 

Arguments

$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

Response

string

A textual representation of the path.

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

addDirset(\DirSet $dset) 
throws

Arguments

$dset

\DirSet

Adds the components on the given path which exist to this Path. Components that don't exist, aren't added.

addExisting(\Path $source) 

Arguments

$source

\Path

  • Source path whose components are examined for existence.

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

addFileset(\FileSet $fs) 
throws

Arguments

$fs

\FileSet

Append the contents of the other Path instance to this.

append(\Path $other) 

Arguments

$other

\Path

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

circularReference() 
inherited

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

createPath() 
throws

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

createPathElement() 
throws

Check to see whether any DataType we hold references to is included in the Stack (which holds all DataType instances that directly or indirectly reference this instance, including this instance itself).

dieOnCircularReference( &$stk, \Project $p) 
inherited

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.

Arguments

$stk

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

getCheckedRef( $requiredClass,  $dataTypeName) 
inherited

Arguments

$requiredClass

$dataTypeName

Return the description for the current data type.

getDescription() 
inherited

Returns a reference to current project

getProject() : \Project
inherited

Response

\Project

Reference to current porject object

Has the refid attribute of this element been set?

isReference() 
inherited

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

listPaths() : array

Response

array

List of path elements.

Logs a message with the given priority.

log(string $msg, integer $level = \Project::MSG_INFO) 
inherited

Arguments

$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

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

parsingComplete() : void
inherited

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.

Arguments

$project

\Project

$relativeName

Sets a description of the current data type. It will be useful in commenting what we are doing.

setDescription( $desc) 
inherited

Arguments

$desc

Adds a element definition to the path.

setDir( $location) 
throws

Arguments

$location

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

Parses a path definition and creates single PathElements.

setPath( $path) 
throws

Arguments

$path

References the project to the current component.

setProject(\Project $project) 
inherited

Arguments

$project

\Project

The reference to the current project

Set the value of the refid attribute.

setRefid(\Reference $r) : void
inherited

Subclasses may need to check whether any other attributes have been set as well or child elements have been created and thus override this method. if they do they must call parent::setRefid()

Arguments

How many parts does this Path instance consist of.

size() : integer

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

Response

integer

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

tooManyAttributes() 
inherited

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

translateFile( $source) 
static

Arguments

$source

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

Arguments

$buffer

$pos

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

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

Arguments

$project

\Project

$source

string

Properties

elements

elements : 

Type(s)

The descriptin the user has set.

description : 
inherited

Type(s)

Value to the refid attribute. Type of Reference

ref : 
inherited

Type(s)

Are we sure we don't hold circular references?

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

var

Type(s)

boolean

Holds a reference to the project that a project component (a task, a target, etc.) belongs to

project : \Project
inherited
var

A reference to the current project instance

Type(s)

\Project