# 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() : \Path

### Response

`\Path`

## 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) : void

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) : void

### Arguments

#### $source

`\Path`

- Source path whose components are examined for existence.

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

    addFileset(\FileSet $fs) : void

throws |

### Arguments

#### $fs

`\FileSet`

## Append the contents of the other Path instance to this.

    append(\Path $other) : void

throws |

### Arguments

#### $other

`\Path`

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

    circularReference() : \BuildException

inherited

### Response

`\BuildException`

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

    createPath() : \Path

throws |

### Response

`\Path`

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

    createPathElement() : void

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) : void

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.

throws |

### Arguments

#### $stk

``

#### $p

`\Project`

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

    getCheckedRef( $requiredClass,  $dataTypeName) : mixed

inherited

throws |

### Arguments

#### $requiredClass

``

#### $dataTypeName

``

### Response

`mixed`

## Return the description for the current data type.

    getDescription()

inherited

retujrn | string

## 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() : boolean

inherited

### Response

`boolean`

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

    listPaths() : array

throws |

### Response

`array`

List of path elements.

## Logs a message with the given priority.

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

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() : \BuildException

inherited

### Response

`\BuildException`

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

    parsingComplete() : void

inherited

{@inheritdoc}

## pushAndInvokeCircularReferenceCheck

    pushAndInvokeCircularReferenceCheck(\DataType $dt,  &$stk, \Project $p)

inherited static

### Arguments

#### $dt

`\DataType`

#### $stk

``

#### $p

`\Project`

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

    resolveFile(\Project $project,  $relativeName) : string

static

Assume the filename is absolute if project is null.

### Arguments

#### $project

`\Project`

#### $relativeName

``

### Response

`string`

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

    setDescription(string $desc) : void

inherited

### Arguments

#### $desc

`string`

## Adds a element definition to the path.

    setDir(\PhingFile $location) : void

throws |

### Arguments

#### $location

`\PhingFile`

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

``

the path definition.

## References the project to the current component.

    setProject(\Project $project) : void

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

#### $r

`\Reference`

## 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() : \BuildException

inherited

### Response

`\BuildException`

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

    translateFile(string $source) : string

static

### Arguments

#### $source

`string`

### Response

`string`

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

    translateFileSep(string &$buffer, integer $pos) : boolean

static

### Arguments

#### $buffer

`string`

#### $pos

`integer`

### Response

`boolean`

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

    translatePath(\Project $project, string $source) : array

static

### Arguments

#### $project

`\Project`

#### $source

`string`

### Response

`array`

### Properties

## elements

    elements :

### Type(s)

``

## The descriptin the user has set.

    description : string

inherited

var |

### Type(s)

`string`

## Value to the refid attribute.

    ref : \Reference

inherited

var |

### Type(s)

`\Reference`

## 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`