| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
stubClassLoader::load('net::stubbles::reflection::annotations::stubAnnotation'); |
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
abstract class stubAbstractAnnotation extends stubSerializableObject implements stubAnnotation |
|---|
| 17 |
{ |
|---|
| 18 |
|
|---|
| 19 |
* The name of the annotation |
|---|
| 20 |
* |
|---|
| 21 |
* @var string |
|---|
| 22 |
*/ |
|---|
| 23 |
protected $annotationName; |
|---|
| 24 |
|
|---|
| 25 |
* a list of reflected class instances used in the annotation |
|---|
| 26 |
* |
|---|
| 27 |
* This property should only be used by this class. We can not make this |
|---|
| 28 |
* property private because the serializung mechanism will not work then. |
|---|
| 29 |
* |
|---|
| 30 |
* @var array<string,string> |
|---|
| 31 |
*/ |
|---|
| 32 |
protected $reflectedClasses = array(); |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
* Sets the name under which the annotation is stored. |
|---|
| 36 |
* |
|---|
| 37 |
* @param string $name |
|---|
| 38 |
*/ |
|---|
| 39 |
public function setAnnotationName($name) |
|---|
| 40 |
{ |
|---|
| 41 |
$this->annotationName = $name; |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
* Returns the name under which the annotation is stored. |
|---|
| 46 |
* |
|---|
| 47 |
* @return string |
|---|
| 48 |
*/ |
|---|
| 49 |
public function getAnnotationName() |
|---|
| 50 |
{ |
|---|
| 51 |
return $this->annotationName; |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
* do some last operations after all values have been set |
|---|
| 56 |
* |
|---|
| 57 |
* This method may check if all required values have been set and throw |
|---|
| 58 |
* an exception if values are missing. |
|---|
| 59 |
* |
|---|
| 60 |
* @throws ReflectionException |
|---|
| 61 |
*/ |
|---|
| 62 |
public function finish() |
|---|
| 63 |
{ |
|---|
| 64 |
|
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
* assure that a clone clones all properties of type object as well |
|---|
| 69 |
*/ |
|---|
| 70 |
public function __clone() |
|---|
| 71 |
{ |
|---|
| 72 |
foreach (get_object_vars($this) as $name => $value) { |
|---|
| 73 |
if ($value instanceof stubClonable) { |
|---|
| 74 |
$this->$name = clone $this->$name; |
|---|
| 75 |
} |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
* template method to hook into __sleep() |
|---|
| 81 |
* |
|---|
| 82 |
* @return array<string> list of property names that should not be serialized |
|---|
| 83 |
*/ |
|---|
| 84 |
protected function __doSleep() |
|---|
| 85 |
{ |
|---|
| 86 |
$this->reflectedClasses = array(); |
|---|
| 87 |
return array(); |
|---|
| 88 |
} |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
* takes care of serializing the value |
|---|
| 92 |
* |
|---|
| 93 |
* @param array &$propertiesToSerialize list of properties to serialize |
|---|
| 94 |
* @param string $name name of the property to serialize |
|---|
| 95 |
* @param mixed $value value to serialize |
|---|
| 96 |
*/ |
|---|
| 97 |
protected function __doSerialize(&$propertiesToSerialize, $name, $value) |
|---|
| 98 |
{ |
|---|
| 99 |
if ($value instanceof stubReflectionClass) { |
|---|
| 100 |
$this->reflectedClasses[$name] = $value->getFullQualifiedClassName(); |
|---|
| 101 |
return; |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
parent::__doSerialize($propertiesToSerialize, $name, $value); |
|---|
| 105 |
} |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
* template method to hook into __wakeup() |
|---|
| 109 |
*/ |
|---|
| 110 |
protected function __doWakeUp() |
|---|
| 111 |
{ |
|---|
| 112 |
foreach ($this->reflectedClasses as $propertyName => $reflectedClasses) { |
|---|
| 113 |
$this->$propertyName = new stubReflectionClass($reflectedClasses); |
|---|
| 114 |
} |
|---|
| 115 |
|
|---|
| 116 |
$this->reflectedClasses = array(); |
|---|
| 117 |
} |
|---|
| 118 |
} |
|---|
| 119 |
?> |
|---|