@@ -16,23 +16,23 @@ |
||
| 16 | 16 | |
| 17 | 17 | class Jaxon |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @const string |
| 21 | 21 | */ |
| 22 | - public const VERSION = 'Jaxon 5.x'; |
|
| 22 | +public const VERSION = 'Jaxon 5.x'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @const string |
| 26 | 26 | */ |
| 27 | - public const CALLABLE_CLASS = 'CallableClass'; |
|
| 27 | +public const CALLABLE_CLASS = 'CallableClass'; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * @const string |
| 31 | 31 | */ |
| 32 | - public const CALLABLE_DIR = 'CallableDir'; |
|
| 32 | +public const CALLABLE_DIR = 'CallableDir'; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * @const string |
| 36 | 36 | */ |
| 37 | - public const CALLABLE_FUNCTION = 'CallableFunction'; |
|
| 37 | +public const CALLABLE_FUNCTION = 'CallableFunction'; |
|
| 38 | 38 | } |
@@ -17,56 +17,56 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | class Target implements TargetInterface |
| 19 | 19 | { |
| 20 | - /** |
|
| 20 | +/** |
|
| 21 | 21 | * The target type for function. |
| 22 | 22 | * |
| 23 | 23 | * @var string |
| 24 | 24 | */ |
| 25 | - const TYPE_FUNCTION = 'TargetFunction'; |
|
| 25 | +const TYPE_FUNCTION = 'TargetFunction'; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 27 | +/** |
|
| 28 | 28 | * The target type for class. |
| 29 | 29 | * |
| 30 | 30 | * @var string |
| 31 | 31 | */ |
| 32 | - const TYPE_CLASS = 'TargetClass'; |
|
| 32 | +const TYPE_CLASS = 'TargetClass'; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * The target type. |
| 36 | 36 | * |
| 37 | 37 | * @var string |
| 38 | 38 | */ |
| 39 | - private $sType = ''; |
|
| 39 | +private $sType = ''; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 41 | +/** |
|
| 42 | 42 | * The target function name. |
| 43 | 43 | * |
| 44 | 44 | * @var string |
| 45 | 45 | */ |
| 46 | - private $sFunctionName = ''; |
|
| 46 | +private $sFunctionName = ''; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 48 | +/** |
|
| 49 | 49 | * The target class name. |
| 50 | 50 | * |
| 51 | 51 | * @var string |
| 52 | 52 | */ |
| 53 | - private $sClassName = ''; |
|
| 53 | +private $sClassName = ''; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 55 | +/** |
|
| 56 | 56 | * The target method name. |
| 57 | 57 | * |
| 58 | 58 | * @var string |
| 59 | 59 | */ |
| 60 | - private $sMethodName = ''; |
|
| 60 | +private $sMethodName = ''; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 62 | +/** |
|
| 63 | 63 | * The target method args. |
| 64 | 64 | * |
| 65 | 65 | * @var array |
| 66 | 66 | */ |
| 67 | - private $aMethodArgs = []; |
|
| 67 | +private $aMethodArgs = []; |
|
| 68 | 68 | |
| 69 | - /** |
|
| 69 | +/** |
|
| 70 | 70 | * The constructor |
| 71 | 71 | * |
| 72 | 72 | * @param string $sType The target type |
@@ -75,116 +75,116 @@ discard block |
||
| 75 | 75 | * @param string $sMethodName The method name |
| 76 | 76 | * @param array $aMethodArgs The method args |
| 77 | 77 | */ |
| 78 | - private function __construct(string $sType, string $sFunctionName, string $sClassName, string $sMethodName, array $aMethodArgs = []) |
|
| 79 | - { |
|
| 80 | - $this->sType = $sType; |
|
| 81 | - $this->sFunctionName = $sFunctionName; |
|
| 82 | - $this->sClassName = $sClassName; |
|
| 83 | - $this->sMethodName = $sMethodName; |
|
| 84 | - $this->aMethodArgs = $aMethodArgs; |
|
| 85 | - } |
|
| 78 | +private function __construct(string $sType, string $sFunctionName, string $sClassName, string $sMethodName, array $aMethodArgs = []) |
|
| 79 | +{ |
|
| 80 | +$this->sType = $sType; |
|
| 81 | +$this->sFunctionName = $sFunctionName; |
|
| 82 | +$this->sClassName = $sClassName; |
|
| 83 | +$this->sMethodName = $sMethodName; |
|
| 84 | +$this->aMethodArgs = $aMethodArgs; |
|
| 85 | +} |
|
| 86 | 86 | |
| 87 | - /** |
|
| 87 | +/** |
|
| 88 | 88 | * Create a target of type Function |
| 89 | 89 | * |
| 90 | 90 | * @param string $sFunctionName The function name |
| 91 | 91 | * |
| 92 | 92 | * @return Target |
| 93 | 93 | */ |
| 94 | - public static function makeFunction(string $sFunctionName): Target |
|
| 95 | - { |
|
| 96 | - return new Target(self::TYPE_FUNCTION, $sFunctionName, '', ''); |
|
| 97 | - } |
|
| 94 | +public static function makeFunction(string $sFunctionName): Target |
|
| 95 | +{ |
|
| 96 | +return new Target(self::TYPE_FUNCTION, $sFunctionName, '', ''); |
|
| 97 | +} |
|
| 98 | 98 | |
| 99 | - /** |
|
| 99 | +/** |
|
| 100 | 100 | * Create a target of type Class |
| 101 | 101 | * |
| 102 | 102 | * @param array $aCall |
| 103 | 103 | * |
| 104 | 104 | * @return Target |
| 105 | 105 | */ |
| 106 | - public static function makeClass(array $aCall): Target |
|
| 107 | - { |
|
| 108 | - return new Target(self::TYPE_CLASS, '', trim($aCall['name']), trim($aCall['method'])); |
|
| 109 | - } |
|
| 106 | +public static function makeClass(array $aCall): Target |
|
| 107 | +{ |
|
| 108 | +return new Target(self::TYPE_CLASS, '', trim($aCall['name']), trim($aCall['method'])); |
|
| 109 | +} |
|
| 110 | 110 | |
| 111 | - /** |
|
| 111 | +/** |
|
| 112 | 112 | * Check if the target type is Function. |
| 113 | 113 | * |
| 114 | 114 | * @return bool |
| 115 | 115 | */ |
| 116 | - public function isFunction(): bool |
|
| 117 | - { |
|
| 118 | - return $this->sType === self::TYPE_FUNCTION; |
|
| 119 | - } |
|
| 116 | +public function isFunction(): bool |
|
| 117 | +{ |
|
| 118 | +return $this->sType === self::TYPE_FUNCTION; |
|
| 119 | +} |
|
| 120 | 120 | |
| 121 | - /** |
|
| 121 | +/** |
|
| 122 | 122 | * Check if the target type is Class. |
| 123 | 123 | * |
| 124 | 124 | * @return bool |
| 125 | 125 | */ |
| 126 | - public function isClass(): bool |
|
| 127 | - { |
|
| 128 | - return $this->sType === self::TYPE_CLASS; |
|
| 129 | - } |
|
| 126 | +public function isClass(): bool |
|
| 127 | +{ |
|
| 128 | +return $this->sType === self::TYPE_CLASS; |
|
| 129 | +} |
|
| 130 | 130 | |
| 131 | - /** |
|
| 131 | +/** |
|
| 132 | 132 | * The target function name. |
| 133 | 133 | * |
| 134 | 134 | * @return string |
| 135 | 135 | */ |
| 136 | - public function getFunctionName(): string |
|
| 137 | - { |
|
| 138 | - return $this->sFunctionName; |
|
| 139 | - } |
|
| 136 | +public function getFunctionName(): string |
|
| 137 | +{ |
|
| 138 | +return $this->sFunctionName; |
|
| 139 | +} |
|
| 140 | 140 | |
| 141 | - /** |
|
| 141 | +/** |
|
| 142 | 142 | * The target class name. |
| 143 | 143 | * |
| 144 | 144 | * @return string |
| 145 | 145 | */ |
| 146 | - public function getClassName(): string |
|
| 147 | - { |
|
| 148 | - return $this->sClassName; |
|
| 149 | - } |
|
| 146 | +public function getClassName(): string |
|
| 147 | +{ |
|
| 148 | +return $this->sClassName; |
|
| 149 | +} |
|
| 150 | 150 | |
| 151 | - /** |
|
| 151 | +/** |
|
| 152 | 152 | * The target method name. |
| 153 | 153 | * |
| 154 | 154 | * @return string |
| 155 | 155 | */ |
| 156 | - public function getMethodName(): string |
|
| 157 | - { |
|
| 158 | - return $this->sMethodName; |
|
| 159 | - } |
|
| 156 | +public function getMethodName(): string |
|
| 157 | +{ |
|
| 158 | +return $this->sMethodName; |
|
| 159 | +} |
|
| 160 | 160 | |
| 161 | - /** |
|
| 161 | +/** |
|
| 162 | 162 | * Set the target method name. |
| 163 | 163 | * |
| 164 | 164 | * @param array $aMethodArgs |
| 165 | 165 | */ |
| 166 | - public function setMethodArgs(array $aMethodArgs): void |
|
| 167 | - { |
|
| 168 | - $this->aMethodArgs = $aMethodArgs; |
|
| 169 | - } |
|
| 166 | +public function setMethodArgs(array $aMethodArgs): void |
|
| 167 | +{ |
|
| 168 | +$this->aMethodArgs = $aMethodArgs; |
|
| 169 | +} |
|
| 170 | 170 | |
| 171 | - /** |
|
| 171 | +/** |
|
| 172 | 172 | * The target method name. |
| 173 | 173 | * |
| 174 | 174 | * @return string |
| 175 | 175 | */ |
| 176 | - public function method(): string |
|
| 177 | - { |
|
| 178 | - return $this->sMethodName; |
|
| 179 | - } |
|
| 176 | +public function method(): string |
|
| 177 | +{ |
|
| 178 | +return $this->sMethodName; |
|
| 179 | +} |
|
| 180 | 180 | |
| 181 | - /** |
|
| 181 | +/** |
|
| 182 | 182 | * The target method args. |
| 183 | 183 | * |
| 184 | 184 | * @return array |
| 185 | 185 | */ |
| 186 | - public function args(): array |
|
| 187 | - { |
|
| 188 | - return $this->aMethodArgs; |
|
| 189 | - } |
|
| 186 | +public function args(): array |
|
| 187 | +{ |
|
| 188 | +return $this->aMethodArgs; |
|
| 189 | +} |
|
| 190 | 190 | } |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | class RequestHandler |
| 32 | 32 | { |
| 33 | - /** |
|
| 33 | +/** |
|
| 34 | 34 | * The request plugin that is able to process the current request |
| 35 | 35 | * |
| 36 | 36 | * @var RequestHandlerInterface |
| 37 | 37 | */ |
| 38 | - private $xRequestPlugin = null; |
|
| 38 | +private $xRequestPlugin = null; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * The constructor |
| 42 | 42 | * |
| 43 | 43 | * @param Container $di |
@@ -46,110 +46,110 @@ discard block |
||
| 46 | 46 | * @param CallbackManager $xCallbackManager |
| 47 | 47 | * @param DatabagPlugin $xDatabagPlugin |
| 48 | 48 | */ |
| 49 | - public function __construct(private Container $di, private PluginManager $xPluginManager, |
|
| 50 | - private ResponseManager $xResponseManager, private CallbackManager $xCallbackManager, |
|
| 51 | - private DatabagPlugin $xDatabagPlugin) |
|
| 52 | - {} |
|
| 49 | +public function __construct(private Container $di, private PluginManager $xPluginManager, |
|
| 50 | +private ResponseManager $xResponseManager, private CallbackManager $xCallbackManager, |
|
| 51 | +private DatabagPlugin $xDatabagPlugin) |
|
| 52 | +{} |
|
| 53 | 53 | |
| 54 | - /** |
|
| 54 | +/** |
|
| 55 | 55 | * Check if the current request can be processed |
| 56 | 56 | * |
| 57 | 57 | * Calls each of the request plugins and determines if the current request can be processed by one of them. |
| 58 | 58 | * |
| 59 | 59 | * @return bool |
| 60 | 60 | */ |
| 61 | - public function canProcessRequest(): bool |
|
| 62 | - { |
|
| 63 | - // Return true if the request plugin was already found |
|
| 64 | - if($this->xRequestPlugin !== null) |
|
| 65 | - { |
|
| 66 | - return true; |
|
| 67 | - } |
|
| 61 | +public function canProcessRequest(): bool |
|
| 62 | +{ |
|
| 63 | +// Return true if the request plugin was already found |
|
| 64 | +if($this->xRequestPlugin !== null) |
|
| 65 | +{ |
|
| 66 | +return true; |
|
| 67 | +} |
|
| 68 | 68 | |
| 69 | - // The HTTP request |
|
| 70 | - $xRequest = $this->di->getRequest(); |
|
| 69 | +// The HTTP request |
|
| 70 | +$xRequest = $this->di->getRequest(); |
|
| 71 | 71 | |
| 72 | - // Find a plugin to process the request |
|
| 73 | - foreach($this->xPluginManager->getRequestHandlers() as $sClassName) |
|
| 74 | - { |
|
| 75 | - if($sClassName::canProcessRequest($xRequest)) |
|
| 76 | - { |
|
| 77 | - $this->xRequestPlugin = $this->di->g($sClassName); |
|
| 78 | - $xTarget = $this->xRequestPlugin->setTarget($xRequest); |
|
| 79 | - $xTarget->setMethodArgs($this->di->getRequestArguments()); |
|
| 80 | - return true; |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - return false; |
|
| 84 | - } |
|
| 72 | +// Find a plugin to process the request |
|
| 73 | +foreach($this->xPluginManager->getRequestHandlers() as $sClassName) |
|
| 74 | +{ |
|
| 75 | +if($sClassName::canProcessRequest($xRequest)) |
|
| 76 | +{ |
|
| 77 | + $this->xRequestPlugin = $this->di->g($sClassName); |
|
| 78 | + $xTarget = $this->xRequestPlugin->setTarget($xRequest); |
|
| 79 | + $xTarget->setMethodArgs($this->di->getRequestArguments()); |
|
| 80 | + return true; |
|
| 81 | +} |
|
| 82 | +} |
|
| 83 | +return false; |
|
| 84 | +} |
|
| 85 | 85 | |
| 86 | - /** |
|
| 86 | +/** |
|
| 87 | 87 | * Process the current request and handle errors and exceptions. |
| 88 | 88 | * |
| 89 | 89 | * @return void |
| 90 | 90 | * @throws RequestException |
| 91 | 91 | */ |
| 92 | - private function _processRequest(): void |
|
| 93 | - { |
|
| 94 | - // Process the request |
|
| 95 | - if($this->xRequestPlugin !== null) |
|
| 96 | - { |
|
| 97 | - $this->xRequestPlugin->processRequest(); |
|
| 98 | - // Process the databag |
|
| 99 | - $this->xDatabagPlugin->writeCommand(); |
|
| 100 | - } |
|
| 101 | - } |
|
| 92 | +private function _processRequest(): void |
|
| 93 | +{ |
|
| 94 | +// Process the request |
|
| 95 | +if($this->xRequestPlugin !== null) |
|
| 96 | +{ |
|
| 97 | +$this->xRequestPlugin->processRequest(); |
|
| 98 | +// Process the databag |
|
| 99 | +$this->xDatabagPlugin->writeCommand(); |
|
| 100 | +} |
|
| 101 | +} |
|
| 102 | 102 | |
| 103 | - /** |
|
| 103 | +/** |
|
| 104 | 104 | * Process the current request. |
| 105 | 105 | * |
| 106 | 106 | * @return void |
| 107 | 107 | * @throws RequestException |
| 108 | 108 | */ |
| 109 | - public function processRequest(): void |
|
| 110 | - { |
|
| 111 | - // Check if there is a plugin to process this request |
|
| 112 | - if(!$this->canProcessRequest()) |
|
| 113 | - { |
|
| 114 | - return; |
|
| 115 | - } |
|
| 109 | +public function processRequest(): void |
|
| 110 | +{ |
|
| 111 | +// Check if there is a plugin to process this request |
|
| 112 | +if(!$this->canProcessRequest()) |
|
| 113 | +{ |
|
| 114 | +return; |
|
| 115 | +} |
|
| 116 | 116 | |
| 117 | - try |
|
| 118 | - { |
|
| 119 | - $bEndRequest = false; |
|
| 120 | - // Handle before processing event |
|
| 121 | - if($this->xRequestPlugin !== null) |
|
| 122 | - { |
|
| 123 | - $this->xCallbackManager->onBefore($this->xRequestPlugin->getTarget(), $bEndRequest); |
|
| 124 | - } |
|
| 125 | - if($bEndRequest) |
|
| 126 | - { |
|
| 127 | - return; |
|
| 128 | - } |
|
| 117 | +try |
|
| 118 | +{ |
|
| 119 | +$bEndRequest = false; |
|
| 120 | +// Handle before processing event |
|
| 121 | +if($this->xRequestPlugin !== null) |
|
| 122 | +{ |
|
| 123 | + $this->xCallbackManager->onBefore($this->xRequestPlugin->getTarget(), $bEndRequest); |
|
| 124 | +} |
|
| 125 | +if($bEndRequest) |
|
| 126 | +{ |
|
| 127 | + return; |
|
| 128 | +} |
|
| 129 | 129 | |
| 130 | - $this->_processRequest(); |
|
| 130 | +$this->_processRequest(); |
|
| 131 | 131 | |
| 132 | - // Handle after processing event |
|
| 133 | - if($this->xRequestPlugin !== null) |
|
| 134 | - { |
|
| 135 | - $this->xCallbackManager->onAfter($this->xRequestPlugin->getTarget(), $bEndRequest); |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - // An exception was thrown while processing the request. |
|
| 139 | - // The request missed the corresponding handler function, |
|
| 140 | - // or an error occurred while attempting to execute the handler. |
|
| 141 | - catch(RequestException $e) |
|
| 142 | - { |
|
| 143 | - $this->xResponseManager->error($e->getMessage()); |
|
| 144 | - $this->xCallbackManager->onInvalid($e); |
|
| 145 | - } |
|
| 146 | - catch(Exception $e) |
|
| 147 | - { |
|
| 148 | - $this->xResponseManager->error($e->getMessage()); |
|
| 149 | - $this->xCallbackManager->onError($e); |
|
| 150 | - } |
|
| 132 | +// Handle after processing event |
|
| 133 | +if($this->xRequestPlugin !== null) |
|
| 134 | +{ |
|
| 135 | + $this->xCallbackManager->onAfter($this->xRequestPlugin->getTarget(), $bEndRequest); |
|
| 136 | +} |
|
| 137 | +} |
|
| 138 | +// An exception was thrown while processing the request. |
|
| 139 | +// The request missed the corresponding handler function, |
|
| 140 | +// or an error occurred while attempting to execute the handler. |
|
| 141 | +catch(RequestException $e) |
|
| 142 | +{ |
|
| 143 | +$this->xResponseManager->error($e->getMessage()); |
|
| 144 | +$this->xCallbackManager->onInvalid($e); |
|
| 145 | +} |
|
| 146 | +catch(Exception $e) |
|
| 147 | +{ |
|
| 148 | +$this->xResponseManager->error($e->getMessage()); |
|
| 149 | +$this->xCallbackManager->onError($e); |
|
| 150 | +} |
|
| 151 | 151 | |
| 152 | - // Print the debug messages |
|
| 153 | - $this->xResponseManager->printDebug(); |
|
| 154 | - } |
|
| 152 | +// Print the debug messages |
|
| 153 | +$this->xResponseManager->printDebug(); |
|
| 154 | +} |
|
| 155 | 155 | } |
@@ -28,40 +28,40 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class DatabagAnnotation extends AbstractAnnotation |
| 30 | 30 | { |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * The data bag name |
| 33 | 33 | * |
| 34 | 34 | * @var string |
| 35 | 35 | */ |
| 36 | - protected $sName = ''; |
|
| 36 | +protected $sName = ''; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * @inheritDoc |
| 40 | 40 | */ |
| 41 | - public static function parseAnnotation($value) |
|
| 42 | - { |
|
| 43 | - $aParams = preg_split('/[\s]+/', $value, 2); |
|
| 44 | - return count($aParams) === 1 ? ['name' => $aParams[0]] : ['name' => $aParams[0], 'extra' => $aParams[1]]; |
|
| 45 | - } |
|
| 41 | +public static function parseAnnotation($value) |
|
| 42 | +{ |
|
| 43 | +$aParams = preg_split('/[\s]+/', $value, 2); |
|
| 44 | +return count($aParams) === 1 ? ['name' => $aParams[0]] : ['name' => $aParams[0], 'extra' => $aParams[1]]; |
|
| 45 | +} |
|
| 46 | 46 | |
| 47 | - /** |
|
| 47 | +/** |
|
| 48 | 48 | * @inheritDoc |
| 49 | 49 | * @throws AnnotationException |
| 50 | 50 | */ |
| 51 | - public function initAnnotation(array $properties) |
|
| 52 | - { |
|
| 53 | - if(count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name'])) |
|
| 54 | - { |
|
| 55 | - throw new AnnotationException('The @databag annotation requires a property "name" of type string'); |
|
| 56 | - } |
|
| 57 | - $this->sName = $properties['name']; |
|
| 58 | - } |
|
| 51 | +public function initAnnotation(array $properties) |
|
| 52 | +{ |
|
| 53 | +if(count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name'])) |
|
| 54 | +{ |
|
| 55 | +throw new AnnotationException('The @databag annotation requires a property "name" of type string'); |
|
| 56 | +} |
|
| 57 | +$this->sName = $properties['name']; |
|
| 58 | +} |
|
| 59 | 59 | |
| 60 | - /** |
|
| 60 | +/** |
|
| 61 | 61 | * @inheritDoc |
| 62 | 62 | */ |
| 63 | - public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 64 | - { |
|
| 65 | - $xMetadata->databag($sMethod)->addValue($this->sName); |
|
| 66 | - } |
|
| 63 | +public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 64 | +{ |
|
| 65 | +$xMetadata->databag($sMethod)->addValue($this->sName); |
|
| 66 | +} |
|
| 67 | 67 | } |
@@ -4,58 +4,58 @@ |
||
| 4 | 4 | |
| 5 | 5 | class DatabagContext |
| 6 | 6 | { |
| 7 | - /** |
|
| 7 | +/** |
|
| 8 | 8 | * @var Databag |
| 9 | 9 | */ |
| 10 | - protected $xDatabag; |
|
| 10 | +protected $xDatabag; |
|
| 11 | 11 | |
| 12 | - /** |
|
| 12 | +/** |
|
| 13 | 13 | * @var string |
| 14 | 14 | */ |
| 15 | - protected $sName; |
|
| 15 | +protected $sName; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | +/** |
|
| 18 | 18 | * The constructor |
| 19 | 19 | * |
| 20 | 20 | * @param Databag $xDatabag |
| 21 | 21 | * @param string $sName |
| 22 | 22 | */ |
| 23 | - public function __construct(Databag $xDatabag, string $sName) |
|
| 24 | - { |
|
| 25 | - $this->xDatabag = $xDatabag; |
|
| 26 | - $this->sName = $sName; |
|
| 27 | - } |
|
| 23 | +public function __construct(Databag $xDatabag, string $sName) |
|
| 24 | +{ |
|
| 25 | +$this->xDatabag = $xDatabag; |
|
| 26 | +$this->sName = $sName; |
|
| 27 | +} |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * @param string $sKey |
| 31 | 31 | * @param mixed $xValue |
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | - public function set(string $sKey, $xValue): void |
|
| 36 | - { |
|
| 37 | - $this->xDatabag->set($this->sName, $sKey, $xValue); |
|
| 38 | - } |
|
| 35 | +public function set(string $sKey, $xValue): void |
|
| 36 | +{ |
|
| 37 | +$this->xDatabag->set($this->sName, $sKey, $xValue); |
|
| 38 | +} |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * @param string $sKey |
| 42 | 42 | * @param mixed $xValue |
| 43 | 43 | * |
| 44 | 44 | * @return void |
| 45 | 45 | */ |
| 46 | - public function new(string $sKey, $xValue): void |
|
| 47 | - { |
|
| 48 | - $this->xDatabag->new($this->sName, $sKey, $xValue); |
|
| 49 | - } |
|
| 46 | +public function new(string $sKey, $xValue): void |
|
| 47 | +{ |
|
| 48 | +$this->xDatabag->new($this->sName, $sKey, $xValue); |
|
| 49 | +} |
|
| 50 | 50 | |
| 51 | - /** |
|
| 51 | +/** |
|
| 52 | 52 | * @param string $sKey |
| 53 | 53 | * @param mixed $xValue |
| 54 | 54 | * |
| 55 | 55 | * @return mixed |
| 56 | 56 | */ |
| 57 | - public function get(string $sKey, $xValue = null): mixed |
|
| 58 | - { |
|
| 59 | - return $this->xDatabag->get($this->sName, $sKey, $xValue); |
|
| 60 | - } |
|
| 57 | +public function get(string $sKey, $xValue = null): mixed |
|
| 58 | +{ |
|
| 59 | +return $this->xDatabag->get($this->sName, $sKey, $xValue); |
|
| 60 | +} |
|
| 61 | 61 | } |
@@ -11,110 +11,110 @@ |
||
| 11 | 11 | |
| 12 | 12 | class Databag implements JsonSerializable |
| 13 | 13 | { |
| 14 | - /** |
|
| 14 | +/** |
|
| 15 | 15 | * @var DatabagPlugin |
| 16 | 16 | */ |
| 17 | - protected $xPlugin; |
|
| 17 | +protected $xPlugin; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @var array |
| 21 | 21 | */ |
| 22 | - protected $aData = []; |
|
| 22 | +protected $aData = []; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @var bool |
| 26 | 26 | */ |
| 27 | - protected $bTouched = false; |
|
| 27 | +protected $bTouched = false; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * The constructor |
| 31 | 31 | * |
| 32 | 32 | * @param array $aData |
| 33 | 33 | */ |
| 34 | - public function __construct(DatabagPlugin $xPlugin, array $aData) |
|
| 35 | - { |
|
| 36 | - $this->xPlugin = $xPlugin; |
|
| 37 | - // Ensure all contents are arrays. |
|
| 38 | - $this->aData = array_map(function($aValue) { |
|
| 39 | - return is_array($aValue) ? $aValue : []; |
|
| 40 | - }, $aData); |
|
| 41 | - } |
|
| 34 | +public function __construct(DatabagPlugin $xPlugin, array $aData) |
|
| 35 | +{ |
|
| 36 | +$this->xPlugin = $xPlugin; |
|
| 37 | +// Ensure all contents are arrays. |
|
| 38 | +$this->aData = array_map(function($aValue) { |
|
| 39 | +return is_array($aValue) ? $aValue : []; |
|
| 40 | +}, $aData); |
|
| 41 | +} |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | +/** |
|
| 44 | 44 | * @return bool |
| 45 | 45 | */ |
| 46 | - public function touched(): bool |
|
| 47 | - { |
|
| 48 | - return $this->bTouched; |
|
| 49 | - } |
|
| 46 | +public function touched(): bool |
|
| 47 | +{ |
|
| 48 | +return $this->bTouched; |
|
| 49 | +} |
|
| 50 | 50 | |
| 51 | - /** |
|
| 51 | +/** |
|
| 52 | 52 | * @return array |
| 53 | 53 | */ |
| 54 | - public function getAll(): array |
|
| 55 | - { |
|
| 56 | - return $this->aData; |
|
| 57 | - } |
|
| 54 | +public function getAll(): array |
|
| 55 | +{ |
|
| 56 | +return $this->aData; |
|
| 57 | +} |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * @param string $sBag |
| 61 | 61 | * |
| 62 | 62 | * @return void |
| 63 | 63 | */ |
| 64 | - public function clear(string $sBag): void |
|
| 65 | - { |
|
| 66 | - $this->aData[$sBag] = []; |
|
| 67 | - $this->xPlugin->addCommand('databag.clear', ['bag' => $sBag]); |
|
| 68 | - } |
|
| 64 | +public function clear(string $sBag): void |
|
| 65 | +{ |
|
| 66 | +$this->aData[$sBag] = []; |
|
| 67 | +$this->xPlugin->addCommand('databag.clear', ['bag' => $sBag]); |
|
| 68 | +} |
|
| 69 | 69 | |
| 70 | - /** |
|
| 70 | +/** |
|
| 71 | 71 | * @param string $sBag |
| 72 | 72 | * @param string $sKey |
| 73 | 73 | * @param mixed $xValue |
| 74 | 74 | * |
| 75 | 75 | * @return void |
| 76 | 76 | */ |
| 77 | - public function set(string $sBag, string $sKey, $xValue): void |
|
| 78 | - { |
|
| 79 | - $this->bTouched = true; |
|
| 80 | - $this->aData[$sBag][$sKey] = $xValue; |
|
| 81 | - } |
|
| 77 | +public function set(string $sBag, string $sKey, $xValue): void |
|
| 78 | +{ |
|
| 79 | +$this->bTouched = true; |
|
| 80 | +$this->aData[$sBag][$sKey] = $xValue; |
|
| 81 | +} |
|
| 82 | 82 | |
| 83 | - /** |
|
| 83 | +/** |
|
| 84 | 84 | * @param string $sBag |
| 85 | 85 | * @param string $sKey |
| 86 | 86 | * @param mixed $xValue |
| 87 | 87 | * |
| 88 | 88 | * @return void |
| 89 | 89 | */ |
| 90 | - public function new(string $sBag, string $sKey, $xValue): void |
|
| 91 | - { |
|
| 92 | - // Set the value only if it doesn't already exist. |
|
| 93 | - if(!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag])) |
|
| 94 | - { |
|
| 95 | - $this->set($sBag, $sKey, $xValue); |
|
| 96 | - } |
|
| 97 | - } |
|
| 90 | +public function new(string $sBag, string $sKey, $xValue): void |
|
| 91 | +{ |
|
| 92 | +// Set the value only if it doesn't already exist. |
|
| 93 | +if(!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag])) |
|
| 94 | +{ |
|
| 95 | +$this->set($sBag, $sKey, $xValue); |
|
| 96 | +} |
|
| 97 | +} |
|
| 98 | 98 | |
| 99 | - /** |
|
| 99 | +/** |
|
| 100 | 100 | * @param string $sBag |
| 101 | 101 | * @param string $sKey |
| 102 | 102 | * @param mixed $xValue |
| 103 | 103 | * |
| 104 | 104 | * @return mixed |
| 105 | 105 | */ |
| 106 | - public function get(string $sBag, string $sKey, $xValue = null): mixed |
|
| 107 | - { |
|
| 108 | - return $this->aData[$sBag][$sKey] ?? $xValue; |
|
| 109 | - } |
|
| 106 | +public function get(string $sBag, string $sKey, $xValue = null): mixed |
|
| 107 | +{ |
|
| 108 | +return $this->aData[$sBag][$sKey] ?? $xValue; |
|
| 109 | +} |
|
| 110 | 110 | |
| 111 | - /** |
|
| 111 | +/** |
|
| 112 | 112 | * Convert this call to array, when converting the response into json. |
| 113 | 113 | * |
| 114 | 114 | * @return array |
| 115 | 115 | */ |
| 116 | - public function jsonSerialize(): array |
|
| 117 | - { |
|
| 118 | - return $this->aData; |
|
| 119 | - } |
|
| 116 | +public function jsonSerialize(): array |
|
| 117 | +{ |
|
| 118 | +return $this->aData; |
|
| 119 | +} |
|
| 120 | 120 | } |
@@ -36,206 +36,206 @@ |
||
| 36 | 36 | |
| 37 | 37 | class AnnotationReader implements MetadataReaderInterface |
| 38 | 38 | { |
| 39 | - /** |
|
| 39 | +/** |
|
| 40 | 40 | * @var AnnotationManager |
| 41 | 41 | */ |
| 42 | - protected $xManager; |
|
| 42 | +protected $xManager; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 44 | +/** |
|
| 45 | 45 | * @var Metadata |
| 46 | 46 | */ |
| 47 | - protected $xMetadata; |
|
| 47 | +protected $xMetadata; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 49 | +/** |
|
| 50 | 50 | * Properties types, read from the "var" annotations. |
| 51 | 51 | * |
| 52 | 52 | * @var array |
| 53 | 53 | */ |
| 54 | - protected $aPropTypes; |
|
| 54 | +protected $aPropTypes; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 56 | +/** |
|
| 57 | 57 | * The type of the class member being currently processed. |
| 58 | 58 | * |
| 59 | 59 | * @var string |
| 60 | 60 | */ |
| 61 | - protected $sCurrMemberType; |
|
| 61 | +protected $sCurrMemberType; |
|
| 62 | 62 | |
| 63 | - /** |
|
| 63 | +/** |
|
| 64 | 64 | * The constructor |
| 65 | 65 | * |
| 66 | 66 | * @param AnnotationManager $xManager |
| 67 | 67 | */ |
| 68 | - public function __construct(AnnotationManager $xManager) |
|
| 69 | - { |
|
| 70 | - $this->xManager = $xManager; |
|
| 71 | - $this->xManager->registry['upload'] = UploadAnnotation::class; |
|
| 72 | - $this->xManager->registry['databag'] = DatabagAnnotation::class; |
|
| 73 | - $this->xManager->registry['exclude'] = ExcludeAnnotation::class; |
|
| 74 | - $this->xManager->registry['before'] = BeforeAnnotation::class; |
|
| 75 | - $this->xManager->registry['after'] = AfterAnnotation::class; |
|
| 76 | - $this->xManager->registry['di'] = ContainerAnnotation::class; |
|
| 77 | - $this->xManager->registry['callback'] = CallbackAnnotation::class; |
|
| 78 | - // Missing standard annotations. |
|
| 79 | - // We need to define this, otherwise they throw an exception, and make the whole processing fail. |
|
| 80 | - $this->xManager->registry['const'] = false; |
|
| 81 | - $this->xManager->registry['inheritDoc'] = false; |
|
| 82 | - $this->xManager->registry['template'] = false; |
|
| 83 | - $this->xManager->registry['param-closure-this'] = false; |
|
| 84 | - } |
|
| 68 | +public function __construct(AnnotationManager $xManager) |
|
| 69 | +{ |
|
| 70 | +$this->xManager = $xManager; |
|
| 71 | +$this->xManager->registry['upload'] = UploadAnnotation::class; |
|
| 72 | +$this->xManager->registry['databag'] = DatabagAnnotation::class; |
|
| 73 | +$this->xManager->registry['exclude'] = ExcludeAnnotation::class; |
|
| 74 | +$this->xManager->registry['before'] = BeforeAnnotation::class; |
|
| 75 | +$this->xManager->registry['after'] = AfterAnnotation::class; |
|
| 76 | +$this->xManager->registry['di'] = ContainerAnnotation::class; |
|
| 77 | +$this->xManager->registry['callback'] = CallbackAnnotation::class; |
|
| 78 | +// Missing standard annotations. |
|
| 79 | +// We need to define this, otherwise they throw an exception, and make the whole processing fail. |
|
| 80 | +$this->xManager->registry['const'] = false; |
|
| 81 | +$this->xManager->registry['inheritDoc'] = false; |
|
| 82 | +$this->xManager->registry['template'] = false; |
|
| 83 | +$this->xManager->registry['param-closure-this'] = false; |
|
| 84 | +} |
|
| 85 | 85 | |
| 86 | - /** |
|
| 86 | +/** |
|
| 87 | 87 | * @return array |
| 88 | 88 | */ |
| 89 | - public function getPropTypes(): array |
|
| 90 | - { |
|
| 91 | - return $this->aPropTypes; |
|
| 92 | - } |
|
| 89 | +public function getPropTypes(): array |
|
| 90 | +{ |
|
| 91 | +return $this->aPropTypes; |
|
| 92 | +} |
|
| 93 | 93 | |
| 94 | - /** |
|
| 94 | +/** |
|
| 95 | 95 | * @return bool |
| 96 | 96 | */ |
| 97 | - public function annotationIsOnProperty(): bool |
|
| 98 | - { |
|
| 99 | - return $this->sCurrMemberType === AnnotationManager::MEMBER_PROPERTY; |
|
| 100 | - } |
|
| 97 | +public function annotationIsOnProperty(): bool |
|
| 98 | +{ |
|
| 99 | +return $this->sCurrMemberType === AnnotationManager::MEMBER_PROPERTY; |
|
| 100 | +} |
|
| 101 | 101 | |
| 102 | - /** |
|
| 102 | +/** |
|
| 103 | 103 | * @param string $sClass |
| 104 | 104 | * |
| 105 | 105 | * @return void |
| 106 | 106 | * @throws AnnotationException |
| 107 | 107 | */ |
| 108 | - private function getClassAttrs(string $sClass): void |
|
| 109 | - { |
|
| 110 | - // Only keep the annotations declared in this package. |
|
| 111 | - /** @var array<AbstractAnnotation> */ |
|
| 112 | - $aAnnotations = array_filter( |
|
| 113 | - $this->xManager->getClassAnnotations($sClass), |
|
| 114 | - fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class) |
|
| 115 | - ); |
|
| 116 | - // First check if the class is excluded. |
|
| 117 | - foreach($aAnnotations as $xAnnotation) |
|
| 118 | - { |
|
| 119 | - if(is_a($xAnnotation, ExcludeAnnotation::class)) |
|
| 120 | - { |
|
| 121 | - $xAnnotation->saveValue($this->xMetadata); |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - if($this->xMetadata->isExcluded()) |
|
| 125 | - { |
|
| 126 | - return; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - foreach($aAnnotations as $xAnnotation) |
|
| 130 | - { |
|
| 131 | - if(!is_a($xAnnotation, ExcludeAnnotation::class)) |
|
| 132 | - { |
|
| 133 | - $xAnnotation->saveValue($this->xMetadata); |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - } |
|
| 108 | +private function getClassAttrs(string $sClass): void |
|
| 109 | +{ |
|
| 110 | +// Only keep the annotations declared in this package. |
|
| 111 | +/** @var array<AbstractAnnotation> */ |
|
| 112 | +$aAnnotations = array_filter( |
|
| 113 | +$this->xManager->getClassAnnotations($sClass), |
|
| 114 | +fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class) |
|
| 115 | +); |
|
| 116 | +// First check if the class is excluded. |
|
| 117 | +foreach($aAnnotations as $xAnnotation) |
|
| 118 | +{ |
|
| 119 | +if(is_a($xAnnotation, ExcludeAnnotation::class)) |
|
| 120 | +{ |
|
| 121 | + $xAnnotation->saveValue($this->xMetadata); |
|
| 122 | +} |
|
| 123 | +} |
|
| 124 | +if($this->xMetadata->isExcluded()) |
|
| 125 | +{ |
|
| 126 | +return; |
|
| 127 | +} |
|
| 137 | 128 | |
| 138 | - /** |
|
| 129 | +foreach($aAnnotations as $xAnnotation) |
|
| 130 | +{ |
|
| 131 | +if(!is_a($xAnnotation, ExcludeAnnotation::class)) |
|
| 132 | +{ |
|
| 133 | + $xAnnotation->saveValue($this->xMetadata); |
|
| 134 | +} |
|
| 135 | +} |
|
| 136 | +} |
|
| 137 | + |
|
| 138 | +/** |
|
| 139 | 139 | * @param string $sClass |
| 140 | 140 | * @param string $sProperty |
| 141 | 141 | * |
| 142 | 142 | * @return void |
| 143 | 143 | * @throws AnnotationException |
| 144 | 144 | */ |
| 145 | - private function getPropertyAttrs(string $sClass, string $sProperty): void |
|
| 145 | +private function getPropertyAttrs(string $sClass, string $sProperty): void |
|
| 146 | +{ |
|
| 147 | +/** @var array<ContainerAnnotation> */ |
|
| 148 | +// Only keep the annotations declared in this package. |
|
| 149 | +$aAnnotations = array_filter( |
|
| 150 | +$this->xManager->getPropertyAnnotations($sClass, $sProperty), |
|
| 151 | +function($xAnnotation) use($sProperty) { |
|
| 152 | + // Save the property type |
|
| 153 | + if(is_a($xAnnotation, VarAnnotation::class)) |
|
| 146 | 154 | { |
| 147 | - /** @var array<ContainerAnnotation> */ |
|
| 148 | - // Only keep the annotations declared in this package. |
|
| 149 | - $aAnnotations = array_filter( |
|
| 150 | - $this->xManager->getPropertyAnnotations($sClass, $sProperty), |
|
| 151 | - function($xAnnotation) use($sProperty) { |
|
| 152 | - // Save the property type |
|
| 153 | - if(is_a($xAnnotation, VarAnnotation::class)) |
|
| 154 | - { |
|
| 155 | - $this->aPropTypes[$sProperty] = $xAnnotation->type; |
|
| 156 | - } |
|
| 157 | - // Only container annotations are allowed on properties |
|
| 158 | - return is_a($xAnnotation, ContainerAnnotation::class); |
|
| 159 | - } |
|
| 160 | - ); |
|
| 161 | - if(count($aAnnotations) > 1) |
|
| 162 | - { |
|
| 163 | - throw new AnnotationException('Only one @di annotation is allowed on a property'); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - foreach($aAnnotations as $xAnnotation) |
|
| 167 | - { |
|
| 168 | - $xAnnotation->setAttr($sProperty); |
|
| 169 | - $xAnnotation->saveValue($this->xMetadata); |
|
| 170 | - } |
|
| 155 | + $this->aPropTypes[$sProperty] = $xAnnotation->type; |
|
| 171 | 156 | } |
| 157 | + // Only container annotations are allowed on properties |
|
| 158 | + return is_a($xAnnotation, ContainerAnnotation::class); |
|
| 159 | +} |
|
| 160 | +); |
|
| 161 | +if(count($aAnnotations) > 1) |
|
| 162 | +{ |
|
| 163 | +throw new AnnotationException('Only one @di annotation is allowed on a property'); |
|
| 164 | +} |
|
| 172 | 165 | |
| 173 | - /** |
|
| 166 | +foreach($aAnnotations as $xAnnotation) |
|
| 167 | +{ |
|
| 168 | +$xAnnotation->setAttr($sProperty); |
|
| 169 | +$xAnnotation->saveValue($this->xMetadata); |
|
| 170 | +} |
|
| 171 | +} |
|
| 172 | + |
|
| 173 | +/** |
|
| 174 | 174 | * @param string $sClass |
| 175 | 175 | * @param string $sMethod |
| 176 | 176 | * |
| 177 | 177 | * @return void |
| 178 | 178 | * @throws AnnotationException |
| 179 | 179 | */ |
| 180 | - private function getMethodAttrs(string $sClass, string $sMethod): void |
|
| 181 | - { |
|
| 182 | - // Only keep the annotations declared in this package. |
|
| 183 | - /** @var array<AbstractAnnotation> */ |
|
| 184 | - $aAnnotations = array_filter( |
|
| 185 | - $this->xManager->getMethodAnnotations($sClass, $sMethod), |
|
| 186 | - fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class) |
|
| 187 | - ); |
|
| 188 | - foreach($aAnnotations as $xAnnotation) |
|
| 189 | - { |
|
| 190 | - $xAnnotation->saveValue($this->xMetadata, $sMethod); |
|
| 191 | - } |
|
| 192 | - } |
|
| 180 | +private function getMethodAttrs(string $sClass, string $sMethod): void |
|
| 181 | +{ |
|
| 182 | +// Only keep the annotations declared in this package. |
|
| 183 | +/** @var array<AbstractAnnotation> */ |
|
| 184 | +$aAnnotations = array_filter( |
|
| 185 | +$this->xManager->getMethodAnnotations($sClass, $sMethod), |
|
| 186 | +fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class) |
|
| 187 | +); |
|
| 188 | +foreach($aAnnotations as $xAnnotation) |
|
| 189 | +{ |
|
| 190 | +$xAnnotation->saveValue($this->xMetadata, $sMethod); |
|
| 191 | +} |
|
| 192 | +} |
|
| 193 | 193 | |
| 194 | - /** |
|
| 194 | +/** |
|
| 195 | 195 | * @inheritDoc |
| 196 | 196 | * @throws SetupException |
| 197 | 197 | */ |
| 198 | - public function getAttributes(InputData $xInput): Metadata |
|
| 199 | - { |
|
| 200 | - ContainerAnnotation::$xReader = $this; |
|
| 201 | - $this->aPropTypes = []; |
|
| 202 | - $this->xMetadata = new Metadata(); |
|
| 203 | - $sClass = $xInput->getReflectionClass()->getName(); |
|
| 204 | - |
|
| 205 | - try |
|
| 206 | - { |
|
| 207 | - // Processing class annotations |
|
| 208 | - $this->sCurrMemberType = AnnotationManager::MEMBER_CLASS; |
|
| 209 | - |
|
| 210 | - $this->getClassAttrs($sClass); |
|
| 211 | - if($this->xMetadata->isExcluded()) |
|
| 212 | - { |
|
| 213 | - // The entire class is not to be exported. |
|
| 214 | - return $this->xMetadata; |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - // Processing properties annotations |
|
| 218 | - $this->sCurrMemberType = AnnotationManager::MEMBER_PROPERTY; |
|
| 219 | - |
|
| 220 | - // Properties annotations |
|
| 221 | - foreach($xInput->getProperties() as $sProperty) |
|
| 222 | - { |
|
| 223 | - $this->getPropertyAttrs($sClass, $sProperty); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - // Processing methods annotations |
|
| 227 | - $this->sCurrMemberType = AnnotationManager::MEMBER_METHOD; |
|
| 228 | - |
|
| 229 | - foreach($xInput->getMethods() as $sMethod) |
|
| 230 | - { |
|
| 231 | - $this->getMethodAttrs($sClass, $sMethod); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - return $this->xMetadata; |
|
| 235 | - } |
|
| 236 | - catch(AnnotationException $e) |
|
| 237 | - { |
|
| 238 | - throw new SetupException($e->getMessage()); |
|
| 239 | - } |
|
| 240 | - } |
|
| 198 | +public function getAttributes(InputData $xInput): Metadata |
|
| 199 | +{ |
|
| 200 | +ContainerAnnotation::$xReader = $this; |
|
| 201 | +$this->aPropTypes = []; |
|
| 202 | +$this->xMetadata = new Metadata(); |
|
| 203 | +$sClass = $xInput->getReflectionClass()->getName(); |
|
| 204 | + |
|
| 205 | +try |
|
| 206 | +{ |
|
| 207 | +// Processing class annotations |
|
| 208 | +$this->sCurrMemberType = AnnotationManager::MEMBER_CLASS; |
|
| 209 | + |
|
| 210 | +$this->getClassAttrs($sClass); |
|
| 211 | +if($this->xMetadata->isExcluded()) |
|
| 212 | +{ |
|
| 213 | + // The entire class is not to be exported. |
|
| 214 | + return $this->xMetadata; |
|
| 215 | +} |
|
| 216 | + |
|
| 217 | +// Processing properties annotations |
|
| 218 | +$this->sCurrMemberType = AnnotationManager::MEMBER_PROPERTY; |
|
| 219 | + |
|
| 220 | +// Properties annotations |
|
| 221 | +foreach($xInput->getProperties() as $sProperty) |
|
| 222 | +{ |
|
| 223 | + $this->getPropertyAttrs($sClass, $sProperty); |
|
| 224 | +} |
|
| 225 | + |
|
| 226 | +// Processing methods annotations |
|
| 227 | +$this->sCurrMemberType = AnnotationManager::MEMBER_METHOD; |
|
| 228 | + |
|
| 229 | +foreach($xInput->getMethods() as $sMethod) |
|
| 230 | +{ |
|
| 231 | + $this->getMethodAttrs($sClass, $sMethod); |
|
| 232 | +} |
|
| 233 | + |
|
| 234 | +return $this->xMetadata; |
|
| 235 | +} |
|
| 236 | +catch(AnnotationException $e) |
|
| 237 | +{ |
|
| 238 | +throw new SetupException($e->getMessage()); |
|
| 239 | +} |
|
| 240 | +} |
|
| 241 | 241 | } |