# types/Path.php

## \Path
jump to top

Package: phing\types

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
  $Revision: 526 $

### Properties

`boolean $checked= 'true'`
inherited

Are we sure we don't hold circular references?

Inherited from: \DataType::$checked

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

Default value `true` Details

Type
  boolean
Inherited_from
  \DataType::$checked

`$description= 'null'`
inherited

The descriptin the user has set.

Inherited from: \DataType::$description
Default value `null` Details

Type
Inherited_from
  \DataType::$description

`$elements= 'array()'`
Default value `array()`Details

Type

`\Project $project= 'null'`
inherited

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
Default value `null` Details

Type
  \Project
Inherited_from
  \ProjectComponent::$project

`$ref= 'null'`
inherited

Value to the refid attribute. Type of Reference

Inherited from: \DataType::$ref
Default value `null` Details

Type
Inherited_from
  \DataType::$ref

### Methods

`__clone( ) : void`

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

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

Constructor for internally instantiated objects sets project.

Parameters

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.

Returns

Type | Description
--- | ---
string | A textual representation of the path.

`addDirset( $dset ) : void`

Adds a nested `<dirset>` element.

Parameters

Name | Type | Description
--- | --- | ---
$dset |  |

Throws

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.

Parameters

Name | Type | Description
--- | --- | ---
$source | \Path | Source path whose components are examined for existence.

`addFileset( $fs ) : void`

Adds a nested `<fileset>` element.

Parameters

Name | Type | Description
--- | --- | ---
$fs |  |

Throws

Exception | Description
--- | ---
\BuildException |

`append( $other ) : void`

Append the contents of the other Path instance to this.

Parameters

Name | Type | Description
--- | --- | ---
$other |  |

`circularReference( ) : void`
inherited

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

Inherited from: \DataType::circularReference()
`createPath( ) : void`

Creates a nested `<path>` element.

Throws

Exception | Description
--- | ---
\BuildException |

`createPathElement( ) : void`

Creates the nested `<pathelement>` element.

Throws

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.

Parameters

Name | Type | Description
--- | --- | ---
$stk |  |
$p |  |

Throws

Exception | Description
--- | ---
\BuildException |

`getCheckedRef( $requiredClass, $dataTypeName ) : void`
inherited

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

Inherited from: \DataType::getCheckedRef()
Parameters

Name | Type | Description
--- | --- | ---
$requiredClass |  |
$dataTypeName |  |

`getDescription( ) : void`
inherited

Return the description for the current data type.

Inherited from: \DataType::getDescription()
`getProject( ) : \Project`
inherited

Returns a reference to current project

Inherited from: \ProjectComponent::getProject()
Returns

Type | Description
--- | ---
\Project | Reference to current porject object

`isReference( ) : void`
inherited

Has the refid attribute of this element been set?

Inherited from: \DataType::isReference()
`listPaths( ) : array`

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

Returns

Type | Description
--- | ---
array | List of path elements.

`log( $msg, integer $level = Project::MSG_INFO ) : void`
inherited

Logs a message with the given priority.

Inherited from: \ProjectComponent::log()

@param string $msg The message to be logged.

Parameters

Name | Type | Description
--- | --- | ---
$msg |  |
$level | integer | The message's priority at this message should have

`noChildrenAllowed( ) : void`
inherited

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

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

Inherited from: \DataType::parsingComplete()
`resolveFile( $project, $relativeName ) : void`
static

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

Assume the filename is absolute if project is null.

Parameters

Name | Type | Description
--- | --- | ---
$project |  |
$relativeName |  |

`setDescription( $desc ) : void`
inherited

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

Inherited from: \DataType::setDescription()
Parameters

Name | Type | Description
--- | --- | ---
$desc |  |

`setDir( \$location $location ) : void`

Adds a element definition to the path.

Parameters

Name | Type | Description
--- | --- | ---
$location | \$location | the location of the element to add (must not be `null` nor empty.

Throws

Exception | Description
--- | ---
\BuildException |

`setPath( \path $path ) : void`

Parses a path definition and creates single PathElements.

Parameters

Name | Type | Description
--- | --- | ---
$path | \path | the path definition.

Throws

Exception | Description
--- | ---
\BuildException |

`setProject( \Project $project ) : void`
inherited

References the project to the current component.

Inherited from: \ProjectComponent::setProject()
Parameters

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.

Parameters

Name | Type | Description
--- | --- | ---
$r | \Reference |

Throws

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.

Returns

Type | Description
--- | ---
int |

`tooManyAttributes( ) : void`
inherited

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

Inherited from: \DataType::tooManyAttributes()
`translateFile( $source ) : void`
static

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

Parameters

Name | Type | Description
--- | --- | ---
$source |  |

`translateFileSep( $buffer, $pos ) : void`
static

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

Parameters

Name | Type | Description
--- | --- | ---
$buffer |  |
$pos |  |

`translatePath( \Project $project, string $source ) : void`
static

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

Parameters

Name | Type | Description
--- | --- | ---
$project | \Project |
$source | string |

## \PathElement
jump to top

Package: phing\types

Helper class, holds the nested <code>&lt;pathelement&gt;</code> values.

### Properties

`$outer= ''`
Details

Type

`$parts= 'array()'`
Default value `array()`Details

Type

### Methods

`__construct( $outer ) : void`

Parameters

Name | Type | Description
--- | --- | ---
$outer |  |

`getParts( ) : void`

`setDir( $loc ) : void`

Parameters

Name | Type | Description
--- | --- | ---
$loc |  |

`setPath( $path ) : void`

Parameters

Name | Type | Description
--- | --- | ---
$path |  |

Documentation was generated by DocBlox 0.15.1.