# IntrospectionHelper

Helper class that collects the methods that a task or nested element holds to set attributes, create nested elements or hold PCDATA elements.

- SMART-UP INLINE DOCS
- POLISH-UP THIS CLASS

author | Andreas Aderhold andi@binarycloud.com
author | Hans Lellelid hans@xmpl.org
copyright | 2001,2002 THYRELL. All rights reserved
version | $Id: de242cfb0dd71d9eddf7306105b8eb06e9d5c5c7 $
package | phing

### Methods

## This function constructs a new introspection helper for a specific class.

    __construct(string $class)

This method loads all methods for the specified class and categorizes them as setters, creators, slot listeners, etc. This way, the setAttribue() doesn't need to perform any introspection -- either the requested attribute setter/creator exists or it does not & a BuildException is thrown.

throws |

### Arguments

#### $class

`string`

The classname for this IH.

## Adds PCDATA areas.

    addText(\Project $project, string $element, string $text)

throws |

### Arguments

#### $project

`\Project`

#### $element

`string`

#### $text

`string`

## Creates a named nested element.

    createElement(\Project $project, object $element, string $elementName) : object

Valid creators can be in the form createFoo() or addFoo(Bar).

throws |

### Arguments

#### $project

`\Project`

#### $element

`object`

Object the XML tag is child of. Often a task object.

#### $elementName

`string`

XML tag name

### Response

`object`

Returns the nested element.

## Return all attribues supported by the introspected class.

    getAttributes() : array<mixed,string>

### Response

`array<mixed,string>`

## Get the name for an element.

    getElementName(\Project $project, object $element) : string

When possible the full classnam (phing.tasks.system.PropertyTask) will be returned. If not available (loaded in taskdefs or typedefs) then the XML element name will be returned.

### Arguments

#### $project

`\Project`

#### $element

`object`

The Task or type element.

### Response

`string`

Fully qualified class name of element when possible.

## Factory method for helper objects.

    getHelper(string $class)

static

### Arguments

#### $class

`string`

The class to create a Helper for

## Return all nested elements supported by the introspected class.

    getNestedElements() : array<mixed,string>

### Response

`array<mixed,string>`

## Extract the name of a property from a method name - subtracting a given prefix.

    getPropertyName(string $methodName, string $prefix) : string

### Arguments

#### $methodName

`string`

#### $prefix

`string`

### Response

`string`

## Sets the named attribute.

    setAttribute(\Project $project, string $element, string $attributeName, mixed &$value)

throws |

### Arguments

#### $project

`\Project`

#### $element

`string`

#### $attributeName

`string`

#### $value

`mixed`

## Creates a named nested element.

    storeElement(\Project $project, string $element, string $child, string|null $elementName = null) : void

throws |

### Arguments

#### $project

`\Project`

#### $element

`string`

#### $child

`string`

#### $elementName

`string|null`

## Does the introspected class support PCDATA?

    supportsCharacters() : boolean

### Response

`boolean`

## Prints warning message to screen if -debug was used.

    warn(string $msg)

### Arguments

#### $msg

`string`

### Properties

## Holds the attribute setter methods.

    attributeSetters : array

var | string[]

### Type(s)

`array`

## Holds methods to create nested elements.

    nestedCreators : array

var | string[]

### Type(s)

`array`

## Holds methods to store configured nested elements.

    nestedStorers : array

var | string[]

### Type(s)

`array`

## Map from attribute names to nested types.

    nestedTypes :

### Type(s)

``

## New idea in phing: any class can register certain keys -- e.g. "task.current_file" -- which can be used in task attributes, if supported. In the build XML these are referred to like this: <regexp pattern="\n" replace="%{task.current_file}"/> In the type/task a listener method must be defined: function setListeningReplace($slot) {}

    slotListeners : array

var | string[]

### Type(s)

`array`

## The method to add PCDATA stuff.

    methodAddText : string

var | Method name of the addText (redundant?) method, if class supports it :)

### Type(s)

`string`

## The Class that's been introspected.

    bean : object

var |

### Type(s)

`object`

## The cache of IntrospectionHelper classes instantiated by getHelper().

    helpers : array

static

var | IntrospectionHelpers[]

### Type(s)

`array`