# IntrospectionHelper.php

## \IntrospectionHelper
jump to top

Package: phing

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
Author
  Hans Lellelid
Copyright
  2001,2002 THYRELL. All rights reserved
Version
  $Revision: 930 $

### Properties

`array $attributeSetters= 'array()'`

Holds the attribute setter methods.

string[]
Default value `array()`Details

Type
  array

`object $bean= ''`

The Class that's been introspected.

Details

Type
  object
Access
  private

`array $helpers= 'array()'`
static

The cache of IntrospectionHelper classes instantiated by getHelper().

IntrospectionHelpers[]
Default value `array()`Details

Type
  array

`string $methodAddText= 'null'`

The method to add PCDATA stuff.

Method name of the addText (redundant?) method, if class supports it :)
Default value `null` Details

Type
  string

`array $nestedCreators= 'array()'`

Holds methods to create nested elements.

string[]
Default value `array()`Details

Type
  array

`array $nestedStorers= 'array()'`

Holds methods to store configured nested elements.

string[]
Default value `array()`Details

Type
  array

`$nestedTypes= 'array()'`

Map from attribute names to nested types.

Default value `array()`Details

Type
  n/a

`array $slotListeners= 'array()'`

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) {}

string[]
Default value `array()`Details

Type
  array

### Methods

`__construct( $class ) : void`

This function constructs a new introspection helper for a specific 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.

Parameters

Name | Type | Description
--- | --- | ---
$class |  |

`addText( $project, $element, $text ) : void`

Adds PCDATA areas.

Parameters

Name | Type | Description
--- | --- | ---
$project |  |
$element |  |
$text |  |

`createElement( $project, $element, $elementName ) : object`

Creates a named nested element.

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

Parameters

Name | Type | Description
--- | --- | ---
$project |  |
$element |  |
$elementName |  |

Returns

Type | Description
--- | ---
object | Returns the nested element.

Throws

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

`getAttributes( ) : void`

Return all attribues supported by the introspected class.

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

Get the the name for an element.

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.

Parameters

Name | Type | Description
--- | --- | ---
$project | \Project |
$element | object | The Task or type element.

Returns

Type | Description
--- | ---
string | Fully qualified class name of element when possible.

`getHelper( string $class ) : void`
static

Factory method for helper objects.

Parameters

Name | Type | Description
--- | --- | ---
$class | string | The class to create a Helper for

`getNestedElements( ) : void`

Return all nested elements supported by the introspected class.

`getPropertyName( $methodName, $prefix ) : void`

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

Parameters

Name | Type | Description
--- | --- | ---
$methodName |  |
$prefix |  |

`setAttribute( $project, $element, $attributeName, $value ) : void`

Sets the named attribute.

Parameters

Name | Type | Description
--- | --- | ---
$project |  |
$element |  |
$attributeName |  |
$value |  |

`storeElement( $project, $element, $child, $elementName = null ) : void`

Creates a named nested element.

Parameters

Name | Type | Description
--- | --- | ---
$project |  |
$element |  |
$child |  |
$elementName |  |

Throws

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

`supportsCharacters( ) : void`

Does the introspected class support PCDATA?

`warn( $msg ) : void`

Prints warning message to screen if -debug was used.

Parameters

Name | Type | Description
--- | --- | ---
$msg |  |

Documentation was generated by DocBlox 0.17.1.