types/Path.php

Show: inherited
Table of Contents

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 (Phing)  
Author
Thomas.Haas@softwired-inc.com (Ant)  
Author
Stefan Bodewig (Ant)  
Package
phing.types  

\Path

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
$Id$  

Properties

Propertyprotectedboolean  $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 valuetrueDetails
Type
boolean
Inherited_from
\DataType::$$checked  
Propertypublic  $description= 'null'
inherited

The descriptin the user has set.

Inherited from: \DataType::$$description
Default valuenullDetails
Type
n/a
Inherited_from
\DataType::$$description  
Propertyprivate  $elements= 'array()'
Default valuearray()Details
Type
n/a
Propertyprotected\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\DataType::$$project
Default valuenullDetails
Type
\Project
Inherited_from
\ProjectComponent::$$project  
Inherited_from
\DataType::$$project  
Propertypublic  $ref= 'null'
inherited

Value to the refid attribute. Type of Reference

Inherited from: \DataType::$$ref
Default valuenullDetails
Type
n/a
Inherited_from
\DataType::$$ref  

Methods

methodpublic__clone( ) : void

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

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

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 A textual representation of the path.
methodpublicaddDirset(  $dset ) : void

Adds a nested <dirset> element.

Parameters
Name Type Description
$dset
Throws
Exception Description
\BuildException
methodpublicaddExisting( \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.
methodpublicaddFileset(  $fs ) : void

Adds a nested <fileset> element.

Parameters
Name Type Description
$fs
Throws
Exception Description
\BuildException
methodpublicappend(  $other ) : void

Append the contents of the other Path instance to this.

Parameters
Name Type Description
$other
methodpubliccircularReference( ) : void
inherited

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

Inherited from: \DataType::circularReference()
methodpubliccreatePath( ) : void

Creates a nested <path> element.

Throws
Exception Description
\BuildException
methodpubliccreatePathElement( ) : void

Creates the nested <pathelement> element.

Throws
Exception Description
\BuildException
methodpublicdieOnCircularReference(  $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
methodpublicgetCheckedRef(  $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
methodpublicgetDescription( ) : void
inherited

Return the description for the current data type.

Inherited from: \DataType::getDescription()
methodpublicgetProject( ) : \Project
inherited

Returns a reference to current project

Inherited from: \ProjectComponent::getProject()\DataType::getProject()
Returns
Type Description
\Project Reference to current porject object
methodpublicisReference( ) : void
inherited

Has the refid attribute of this element been set?

Inherited from: \DataType::isReference()
methodpubliclistPaths( ) : array

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

Returns
Type Description
array List of path elements.
methodpubliclog( string $msg, integer $level = Project::MSG_INFO ) : void
inherited

Logs a message with the given priority.

Inherited from: \ProjectComponent::log()\DataType::log()
Parameters
Name Type Description
$msg string

The message to be logged.

$level integer

The message's priority at this message should have

methodpublicnoChildrenAllowed( ) : 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()
methodpublicparsingComplete( ) : void
inherited

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

Inherited from: \DataType::parsingComplete()
methodprivateresolveFile(  $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
methodpublicsetDescription(  $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
methodpublicsetDir( \$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
methodpublicsetPath( \path $path ) : void

Parses a path definition and creates single PathElements.

Parameters
Name Type Description
$path \path

the path definition.

Throws
Exception Description
\BuildException
methodpublicsetProject( \Project $project ) : void
inherited

References the project to the current component.

Inherited from: \ProjectComponent::setProject()\DataType::setProject()
Parameters
Name Type Description
$project \Project

The reference to the current project

methodpublicsetRefid( \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
methodpublicsize( ) : 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
methodpublictooManyAttributes( ) : void
inherited

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

Inherited from: \DataType::tooManyAttributes()
methodpublictranslateFile(  $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
methodprotectedtranslateFileSep(  $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
methodpublictranslatePath( \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

Package: phing\types

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

Properties

Propertyprivate  $outer= ''
Details
Type
n/a
Propertyprivate  $parts= 'array()'
Default valuearray()Details
Type
n/a

Methods

methodpublic__construct(  $outer ) : void

Parameters
Name Type Description
$outer
methodpublicgetParts( ) : void

methodpublicsetDir(  $loc ) : void

Parameters
Name Type Description
$loc
methodpublicsetPath(  $path ) : void

Parameters
Name Type Description
$path
Documentation was generated by DocBlox 0.18.1.