BeanContext/Inspector.php
\Conjoon_BeanContext_Inspector
Static class with utility methods for working on classes implementing the Conjoon_BeanContext-interface and overall introspection of classes/object-instances.
- Author
- Thorsten-Suckow-Homberg
- Category
- Conjoon
Constants
Properties
Methods

create(
string $className, array $properties, boolean $ignoreMissingSetter
=
false
)
:
ObjectTries to instantiate a class based on the passed arguments.
| Name | Type | Description |
|---|---|---|
| $className | string | The class that should be created. Must implement the interface Conjoon_BeanContext |
| $properties | array | An associative array with key/value-pairs, representing the object properties to set. The Constructor will search for appropriate getter/setter methods and call them, passing the values as arguments. |
| $ignoreMissingSetter | boolean | true to not throw an error if a property occures for which no setter is available |
| Type | Description |
|---|---|
| Object |
| Exception | Description |
|---|---|
| \Conjoon_BeanContext_Exception | if any error during object instantiating or class loading occured |

getAccessorForProperty(
Object $object, string $propertyName, string $accessorType
=
self::GETTER
)
:
mixedHelper for getting a getter-method based on the property passed as the argument.
| Name | Type | Description |
|---|---|---|
| $object | Object | The object in which the accessor should be looked up |
| $propertyName | string | The name of the property which accessor has to be looked up |
| $accessorType | string | Which accessor-method to look up, either 'set' or 'get' |
| Type | Description |
|---|---|
| mixed | <tt>null</tt>, if no appropriate getter method exists for the property, otherwise the method name. |

getProperties(
Object $object
)
:
ArrayWill return the properties as an associative array (key/value pairs) of the specified object based on the setter-methods it implements along with the properties it defines. A property will only be returned if it matches the definition for an Conjoon_BeanContext-property, though it must not neccessarily implement Conjoon_BeanContext.
| Name | Type | Description |
|---|---|---|
| $object | Object | An object instance of any type. |
| Type | Description |
|---|---|
| Array |
| Exception | Description |
|---|---|
| \Conjoon_BeanContext_Exception | A call to any of the getters of the passed object can throw an excepiton, which's message gets wrapped up in an exception of the type Conjoon_BeanContext_Exception |

getReflectionClass(
$object
)
:
\ReflectionClassReturns the reflection class for the object out of the cache.
| Name | Type | Description |
|---|---|---|
| $object | Object |
| Type | Description |
|---|---|
| \ReflectionClass |

getReflectionMethods(
$object
)
:
Array | \ReflectionMethodReturns reflection methods for the class the object represents out of the cache.
| Name | Type | Description |
|---|---|---|
| $object | Object |
| Type | Description |
|---|---|
| Array | \ReflectionMethod |

getReflectionProperties(
$object
)
:
Array | \ReflectionPropertyReturns reflection properties for the class the object represents out of the cache.
| Name | Type | Description |
|---|---|---|
| $object | Object |
| Type | Description |
|---|---|
| Array | \ReflectionProperty |

isTransient(
string $propertyName, Object $object
)
:
booleanChecks wether a property is transient. A property is transient, if an underscore is part of the property-name. This method will also check if a property with the same name is available that starts with an underscore.
| Name | Type | Description |
|---|---|---|
| $propertyName | string | |
| $object | Object |
| Type | Description |
|---|---|
| boolean | true, if the property is transient, otherwise false |

loadClass(
$className
)
:
voidHelper for loading a class.
| Name | Type | Description |
|---|---|---|
| $className |

setProperty(
Object $object, string $property, mixed $value, boolean $ignoreMissing
=
false
)
:
voidHelper for setting the properties of an Conjoon_BeanContext-object.
Will throw an exception if the method associated with the property was not found, or any exception that was thrown by the accessor-method of $object. The method assumes that property is already a valid property name according to Conjoon_BeanContext-conventions.
| Name | Type | Description |
|---|---|---|
| $object | Object | The instance to set the property for. Must be of type Conjoon_BeanContext |
| $property | string | The property name that is about to be set. |
| $value | mixed | The value to pass as the argument to the setter-method of $property |
| $ignoreMissing | boolean | when set to true, the method will not throw an error if the |
| Exception | Description |
|---|---|
| \Exception |