1 | <?php namespace BuildR\TestTools\Traits; |
||
20 | trait ReflectionUtilities { |
||
21 | |||
22 | /** |
||
23 | * Read a property value from a given class or concrete object. This function can handle automatic creation |
||
24 | * of new instances of the given class. |
||
25 | * |
||
26 | * If no concrete object provided and the 'callConstructor' option is FALSE reads the property default value |
||
27 | * from the class. |
||
28 | * |
||
29 | * If a concrete object is provided returns the property value from the given concrete object. |
||
30 | * |
||
31 | * If the 'callConstructor' is TRUE and concrete object is not provided this method try to instantiate a |
||
32 | * new object from thi given class using the 'constructorParams' option. |
||
33 | * |
||
34 | * options: |
||
35 | * 'callConstructor' => bool |
||
36 | * 'constructorParams' => array (key is variable name, value is the value of the variable) |
||
37 | * |
||
38 | * @param string $className The FQCN |
||
39 | * @param string $propertyName The property name |
||
40 | * @param object|NULL $concreteClass Optionally concrete class |
||
41 | * @param array $options Options defined as an array |
||
42 | * |
||
43 | * @return NULL|mixed |
||
44 | */ |
||
45 | 2 | public function getPropertyValue($className, $propertyName, $concreteClass = NULL, $options = []) { |
|
82 | |||
83 | /** |
||
84 | * Returns a static property from the given class. You can pass this function an object or |
||
85 | * a FQCN as string. |
||
86 | * |
||
87 | * @param object|string $object A concrete class or a FQCN |
||
88 | * @param string $propertyName The property name |
||
89 | * |
||
90 | * @return NULL|mixed |
||
91 | */ |
||
92 | 2 | public function getStaticPropertyValue($object, $propertyName) { |
|
104 | |||
105 | /** |
||
106 | * Set a property value on the given object. If the property is not found in the given object |
||
107 | * an Exception will be thrown. |
||
108 | * |
||
109 | * @param object $object A concrete object |
||
110 | * @param string $property The property name |
||
111 | * @param mixed $value The property new value |
||
112 | * |
||
113 | * @return bool |
||
114 | * |
||
115 | * @throws \BuildR\Foundation\Exception\Exception |
||
116 | */ |
||
117 | 1 | public function setProperty($object, $property, $value) { |
|
130 | |||
131 | /** |
||
132 | * @param $className |
||
133 | * @param $methodName |
||
134 | * @param null $concreteClass |
||
135 | * @param array $options |
||
136 | * |
||
137 | * options: |
||
138 | * 'callConstructor' => bool |
||
139 | * 'constructorParams' => array (key is variable name, value is the value of the variable) |
||
140 | * 'methodParams' => array (key is variable name, value is the value of the variable) |
||
141 | * |
||
142 | * @return mixed |
||
143 | * |
||
144 | * @throws \BuildR\Foundation\Exception\Exception |
||
145 | */ |
||
146 | 1 | public function invokeMethod($className, $methodName, $concreteClass = NULL, array $options = []) { |
|
176 | |||
177 | } |
||
178 |