classes/phing/types/Path.php

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

Extends from
\DataType
author
Hans Lellelid (Phing)
author
Thomas.Haas@softwired-inc.com (Ant)
author
Stefan Bodewig (Ant)
package
phing.types
version
$Revision: 526 $

Properties

Propertyprivate  $elements= 'array'
Default valuearrayDetails
Type

Methods

methodpublic  __clone( ) :
Return a Path that holds the same elements as this instance.
methodpublic  __construct( \Project $project = null, string $path = null ) :
Constructor for internally instantiated objects sets project.
Parameters
Name Type Description
$project \Project
$path string

(for use by IntrospectionHelper)

methodpublic  __toString( ) : string
Returns a textual representation of the path, which can be used as CLASSPATH or PATH environment variable definition.
Returns
Type Description
string
methodpublic  addDirset(  $dset ) :
Adds a nested <dirset> element.
Parameters
Name Type Description
$dset
Details
throws
methodpublic  addExisting( \Path $source ) :
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.
methodpublic  addFileset(  $fs ) :
Adds a nested <fileset> element.
Parameters
Name Type Description
$fs
Details
throws
methodpublic  append(  $other ) :
Append the contents of the other Path instance to this.
Parameters
Name Type Description
$other
methodpublic  createPath( ) :
Creates a nested <path> element.
Details
throws
methodpublic  createPathElement( ) :
Creates the nested <pathelement> element.
Details
throws
methodpublic  dieOnCircularReference(  $stk,  $p ) :
Overrides the version of DataType to recurse on all DataType child elements that may have been added.
Parameters
Name Type Description
$stk
$p
Details
throws
methodpublic  listPaths( ) : array
Returns all path elements defined by this and nested path objects.
Returns
Type Description
array
methodprivate  resolveFile(  $project,  $relativeName ) :
staticResolve 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
methodpublic  setDir( \$location $location ) :
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.

Details
throws
methodpublic  setPath( \path $path ) :
Parses a path definition and creates single PathElements.
Parameters
Name Type Description
$path \path the path definition.
Details
throws
methodpublic  setRefid(  $r ) :
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
Details
throws
methodpublic  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
methodpublic  translateFile(  $source ) :
staticReturns its argument with all file separator characters replaced so that they match the local OS conventions.
Parameters
Name Type Description
$source
methodprotected  translateFileSep(  $buffer,  $pos ) :
staticTranslates 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
methodpublic  translatePath( \Project $project, string $source ) :
staticSplits a PATH (with : or ; as separators) into its parts.
Parameters
Name Type Description
$project \Project
$source string

\PathElement

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

package
phing.types

Properties

Propertyprivate  $outer= ''
Details
Type
Propertyprivate  $parts= 'array'
Default valuearrayDetails
Type

Methods

methodpublic  __construct(  $outer ) :
Parameters
Name Type Description
$outer
methodpublic  getParts( ) :
methodpublic  setDir(  $loc ) :
Parameters
Name Type Description
$loc
methodpublic  setPath(  $path ) :
Parameters
Name Type Description
$path
Documentation was generated by DocBlox 0.13.1.