@@ -175,62 +175,62 @@ |
||
| 175 | 175 | 0 => true, |
| 176 | 176 | 1 => isset($this->properties['attr']) || isset($this->properties['class']), |
| 177 | 177 | 2 => isset($this->properties['attr']) && isset($this->properties['class']), |
| 178 | - default => false, |
|
| 179 | - }; |
|
| 180 | - } |
|
| 178 | +default => false, |
|
| 179 | +}; |
|
| 180 | +} |
|
| 181 | 181 | |
| 182 | - /** |
|
| 182 | +/** |
|
| 183 | 183 | * @return void |
| 184 | 184 | * @throws AnnotationException |
| 185 | 185 | */ |
| 186 | - private function parseProperties() |
|
| 187 | - { |
|
| 188 | - if(!$this->checkPropertiesNames()) |
|
| 189 | - { |
|
| 190 | - throw new AnnotationException('The @di annotation accepts only "attr" or "class" as properties'); |
|
| 191 | - } |
|
| 186 | +private function parseProperties() |
|
| 187 | +{ |
|
| 188 | +if(!$this->checkPropertiesNames()) |
|
| 189 | +{ |
|
| 190 | +throw new AnnotationException('The @di annotation accepts only "attr" or "class" as properties'); |
|
| 191 | +} |
|
| 192 | 192 | |
| 193 | - if(isset($this->properties['attr'])) |
|
| 194 | - { |
|
| 195 | - if(self::$xReader->annotationIsOnProperty()) |
|
| 196 | - { |
|
| 197 | - throw new AnnotationException('The @di annotation does not allow the "attr" property on class attributes'); |
|
| 198 | - } |
|
| 199 | - if(!is_string($this->properties['attr'])) |
|
| 200 | - { |
|
| 201 | - throw new AnnotationException('The @di annotation requires a property "attr" of type string'); |
|
| 202 | - } |
|
| 203 | - $this->sAttr = $this->properties['attr']; |
|
| 204 | - } |
|
| 205 | - if(isset($this->properties['class'])) |
|
| 206 | - { |
|
| 207 | - if(!is_string($this->properties['class'])) |
|
| 208 | - { |
|
| 209 | - throw new AnnotationException('The @di annotation requires a property "class" of type string'); |
|
| 210 | - } |
|
| 211 | - $this->sClass = $this->getFullClassName($this->properties['class']); |
|
| 212 | - } |
|
| 213 | - } |
|
| 193 | +if(isset($this->properties['attr'])) |
|
| 194 | +{ |
|
| 195 | +if(self::$xReader->annotationIsOnProperty()) |
|
| 196 | +{ |
|
| 197 | + throw new AnnotationException('The @di annotation does not allow the "attr" property on class attributes'); |
|
| 198 | +} |
|
| 199 | +if(!is_string($this->properties['attr'])) |
|
| 200 | +{ |
|
| 201 | + throw new AnnotationException('The @di annotation requires a property "attr" of type string'); |
|
| 202 | +} |
|
| 203 | +$this->sAttr = $this->properties['attr']; |
|
| 204 | +} |
|
| 205 | +if(isset($this->properties['class'])) |
|
| 206 | +{ |
|
| 207 | +if(!is_string($this->properties['class'])) |
|
| 208 | +{ |
|
| 209 | + throw new AnnotationException('The @di annotation requires a property "class" of type string'); |
|
| 210 | +} |
|
| 211 | +$this->sClass = $this->getFullClassName($this->properties['class']); |
|
| 212 | +} |
|
| 213 | +} |
|
| 214 | 214 | |
| 215 | - /** |
|
| 215 | +/** |
|
| 216 | 216 | * @inheritDoc |
| 217 | 217 | */ |
| 218 | - public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 219 | - { |
|
| 220 | - isset($this->properties['__value__']) ? $this->parseValue() : $this->parseProperties(); |
|
| 218 | +public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 219 | +{ |
|
| 220 | +isset($this->properties['__value__']) ? $this->parseValue() : $this->parseProperties(); |
|
| 221 | 221 | |
| 222 | - // The type in the @di annotations can be set from the values in the @var annotations |
|
| 223 | - $aPropTypes = self::$xReader->getPropTypes(); |
|
| 224 | - if($this->sClass === '') |
|
| 225 | - { |
|
| 226 | - if(!isset($aPropTypes[$this->sAttr])) |
|
| 227 | - { |
|
| 228 | - throw new AnnotationException('No class defined for @di on attribute "' . |
|
| 229 | - $this->sAttr . '".'); |
|
| 230 | - } |
|
| 231 | - $this->sClass = ltrim($aPropTypes[$this->sAttr], '\\'); |
|
| 232 | - } |
|
| 222 | +// The type in the @di annotations can be set from the values in the @var annotations |
|
| 223 | +$aPropTypes = self::$xReader->getPropTypes(); |
|
| 224 | +if($this->sClass === '') |
|
| 225 | +{ |
|
| 226 | +if(!isset($aPropTypes[$this->sAttr])) |
|
| 227 | +{ |
|
| 228 | + throw new AnnotationException('No class defined for @di on attribute "' . |
|
| 229 | + $this->sAttr . '".'); |
|
| 230 | +} |
|
| 231 | +$this->sClass = ltrim($aPropTypes[$this->sAttr], '\\'); |
|
| 232 | +} |
|
| 233 | 233 | |
| 234 | - $xMetadata->container($sMethod)->addValue($this->sAttr, $this->sClass); |
|
| 235 | - } |
|
| 234 | +$xMetadata->container($sMethod)->addValue($this->sAttr, $this->sClass); |
|
| 235 | +} |
|
| 236 | 236 | } |
@@ -122,38 +122,38 @@ discard block |
||
| 122 | 122 | $value = $this->properties['__value__']; |
| 123 | 123 | $aParams = preg_split('/[\s]+/', $value, 3); |
| 124 | 124 | $nParamCount = count($aParams); |
| 125 | - if($nParamCount === 1) |
|
| 125 | + if ($nParamCount === 1) |
|
| 126 | 126 | { |
| 127 | 127 | // For a property, the only parameter is the class. Otherwise, it is the attribute. |
| 128 | - if(self::$xReader->annotationIsOnProperty()) |
|
| 128 | + if (self::$xReader->annotationIsOnProperty()) |
|
| 129 | 129 | { |
| 130 | - if(substr($aParams[0], 0, 1) === '$') |
|
| 130 | + if (substr($aParams[0], 0, 1) === '$') |
|
| 131 | 131 | { |
| 132 | 132 | throw new AnnotationException('The only property of the @di annotation must be a class name'); |
| 133 | 133 | } |
| 134 | 134 | $this->sClass = $this->getFullClassName($aParams[0]); |
| 135 | 135 | return; |
| 136 | 136 | } |
| 137 | - if(substr($aParams[0], 0, 1) !== '$') |
|
| 137 | + if (substr($aParams[0], 0, 1) !== '$') |
|
| 138 | 138 | { |
| 139 | 139 | throw new AnnotationException('The only property of the @di annotation must be a var name'); |
| 140 | 140 | } |
| 141 | 141 | $this->sAttr = substr($aParams[0], 1); |
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | - if($nParamCount === 2) |
|
| 144 | + if ($nParamCount === 2) |
|
| 145 | 145 | { |
| 146 | 146 | // For a property, having 2 parameters is not allowed. |
| 147 | - if(self::$xReader->annotationIsOnProperty()) |
|
| 147 | + if (self::$xReader->annotationIsOnProperty()) |
|
| 148 | 148 | { |
| 149 | 149 | throw new AnnotationException('The @di annotation accepts only one property on a class attribute'); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - if(substr($aParams[0], 0, 1) !== '$') |
|
| 152 | + if (substr($aParams[0], 0, 1) !== '$') |
|
| 153 | 153 | { |
| 154 | 154 | throw new AnnotationException('The only property of the @di annotation must be a var name'); |
| 155 | 155 | } |
| 156 | - if(substr($aParams[1], 0, 1) === '$') |
|
| 156 | + if (substr($aParams[1], 0, 1) === '$') |
|
| 157 | 157 | { |
| 158 | 158 | throw new AnnotationException('The first property of the @di annotation must be a class name'); |
| 159 | 159 | } |
@@ -185,26 +185,26 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | private function parseProperties() |
| 187 | 187 | { |
| 188 | - if(!$this->checkPropertiesNames()) |
|
| 188 | + if (!$this->checkPropertiesNames()) |
|
| 189 | 189 | { |
| 190 | 190 | throw new AnnotationException('The @di annotation accepts only "attr" or "class" as properties'); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if(isset($this->properties['attr'])) |
|
| 193 | + if (isset($this->properties['attr'])) |
|
| 194 | 194 | { |
| 195 | - if(self::$xReader->annotationIsOnProperty()) |
|
| 195 | + if (self::$xReader->annotationIsOnProperty()) |
|
| 196 | 196 | { |
| 197 | 197 | throw new AnnotationException('The @di annotation does not allow the "attr" property on class attributes'); |
| 198 | 198 | } |
| 199 | - if(!is_string($this->properties['attr'])) |
|
| 199 | + if (!is_string($this->properties['attr'])) |
|
| 200 | 200 | { |
| 201 | 201 | throw new AnnotationException('The @di annotation requires a property "attr" of type string'); |
| 202 | 202 | } |
| 203 | 203 | $this->sAttr = $this->properties['attr']; |
| 204 | 204 | } |
| 205 | - if(isset($this->properties['class'])) |
|
| 205 | + if (isset($this->properties['class'])) |
|
| 206 | 206 | { |
| 207 | - if(!is_string($this->properties['class'])) |
|
| 207 | + if (!is_string($this->properties['class'])) |
|
| 208 | 208 | { |
| 209 | 209 | throw new AnnotationException('The @di annotation requires a property "class" of type string'); |
| 210 | 210 | } |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | // The type in the @di annotations can be set from the values in the @var annotations |
| 223 | 223 | $aPropTypes = self::$xReader->getPropTypes(); |
| 224 | - if($this->sClass === '') |
|
| 224 | + if ($this->sClass === '') |
|
| 225 | 225 | { |
| 226 | - if(!isset($aPropTypes[$this->sAttr])) |
|
| 226 | + if (!isset($aPropTypes[$this->sAttr])) |
|
| 227 | 227 | { |
| 228 | 228 | throw new AnnotationException('No class defined for @di on attribute "' . |
| 229 | 229 | $this->sAttr . '".'); |
@@ -23,19 +23,19 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class AfterAnnotation extends HookAnnotation |
| 25 | 25 | { |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * @inheritDoc |
| 28 | 28 | */ |
| 29 | - protected static function getType(): string |
|
| 30 | - { |
|
| 31 | - return 'after'; |
|
| 32 | - } |
|
| 29 | +protected static function getType(): string |
|
| 30 | +{ |
|
| 31 | +return 'after'; |
|
| 32 | +} |
|
| 33 | 33 | |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * @inheritDoc |
| 36 | 36 | */ |
| 37 | - public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 38 | - { |
|
| 39 | - $xMetadata->after($sMethod)->addCall($this->sMethod, $this->aParams); |
|
| 40 | - } |
|
| 37 | +public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 38 | +{ |
|
| 39 | +$xMetadata->after($sMethod)->addCall($this->sMethod, $this->aParams); |
|
| 40 | +} |
|
| 41 | 41 | } |
@@ -28,40 +28,40 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class CallbackAnnotation extends AbstractAnnotation |
| 30 | 30 | { |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * The javascript object name |
| 33 | 33 | * |
| 34 | 34 | * @var string |
| 35 | 35 | */ |
| 36 | - protected $sJsObject; |
|
| 36 | +protected $sJsObject; |
|
| 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 @callback annotation requires a single string as property'); |
|
| 56 | - } |
|
| 57 | - $this->sJsObject = $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 @callback annotation requires a single string as property'); |
|
| 56 | +} |
|
| 57 | +$this->sJsObject = $properties['name']; |
|
| 58 | +} |
|
| 59 | 59 | |
| 60 | - /** |
|
| 60 | +/** |
|
| 61 | 61 | * @inheritDoc |
| 62 | 62 | */ |
| 63 | - public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 64 | - { |
|
| 65 | - $xMetadata->callback($sMethod)->addValue($this->sJsObject); |
|
| 66 | - } |
|
| 63 | +public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 64 | +{ |
|
| 65 | +$xMetadata->callback($sMethod)->addValue($this->sJsObject); |
|
| 66 | +} |
|
| 67 | 67 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | public function initAnnotation(array $properties) |
| 52 | 52 | { |
| 53 | - if(count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name'])) |
|
| 53 | + if (count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name'])) |
|
| 54 | 54 | { |
| 55 | 55 | throw new AnnotationException('the @callback annotation requires a single string as property'); |
| 56 | 56 | } |
@@ -23,19 +23,19 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class BeforeAnnotation extends HookAnnotation |
| 25 | 25 | { |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * @inheritDoc |
| 28 | 28 | */ |
| 29 | - protected static function getType(): string |
|
| 30 | - { |
|
| 31 | - return 'before'; |
|
| 32 | - } |
|
| 29 | +protected static function getType(): string |
|
| 30 | +{ |
|
| 31 | +return 'before'; |
|
| 32 | +} |
|
| 33 | 33 | |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * @inheritDoc |
| 36 | 36 | */ |
| 37 | - public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 38 | - { |
|
| 39 | - $xMetadata->before($sMethod)->addCall($this->sMethod, $this->aParams); |
|
| 40 | - } |
|
| 37 | +public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 38 | +{ |
|
| 39 | +$xMetadata->before($sMethod)->addCall($this->sMethod, $this->aParams); |
|
| 40 | +} |
|
| 41 | 41 | } |
@@ -27,38 +27,38 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class ExcludeAnnotation extends AbstractAnnotation |
| 29 | 29 | { |
| 30 | - /** |
|
| 30 | +/** |
|
| 31 | 31 | * @var bool |
| 32 | 32 | */ |
| 33 | - protected $bValue; |
|
| 33 | +protected $bValue; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 35 | +/** |
|
| 36 | 36 | * @inheritDoc |
| 37 | 37 | */ |
| 38 | - public static function parseAnnotation($value) |
|
| 39 | - { |
|
| 40 | - return [$value === 'true' ? true : ($value === 'false' ? false : $value)]; |
|
| 41 | - } |
|
| 38 | +public static function parseAnnotation($value) |
|
| 39 | +{ |
|
| 40 | +return [$value === 'true' ? true : ($value === 'false' ? false : $value)]; |
|
| 41 | +} |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | +/** |
|
| 44 | 44 | * @inheritDoc |
| 45 | 45 | * @throws AnnotationException |
| 46 | 46 | */ |
| 47 | - public function initAnnotation(array $properties) |
|
| 48 | - { |
|
| 49 | - if(count($properties) !== 0 && (count($properties) !== 1 |
|
| 50 | - || !isset($properties[0]) || !is_bool($properties[0]))) |
|
| 51 | - { |
|
| 52 | - throw new AnnotationException('the @exclude annotation requires a single boolean or no property'); |
|
| 53 | - } |
|
| 54 | - $this->bValue = $properties[0] ?? true; |
|
| 55 | - } |
|
| 47 | +public function initAnnotation(array $properties) |
|
| 48 | +{ |
|
| 49 | +if(count($properties) !== 0 && (count($properties) !== 1 |
|
| 50 | +|| !isset($properties[0]) || !is_bool($properties[0]))) |
|
| 51 | +{ |
|
| 52 | +throw new AnnotationException('the @exclude annotation requires a single boolean or no property'); |
|
| 53 | +} |
|
| 54 | +$this->bValue = $properties[0] ?? true; |
|
| 55 | +} |
|
| 56 | 56 | |
| 57 | - /** |
|
| 57 | +/** |
|
| 58 | 58 | * @inheritDoc |
| 59 | 59 | */ |
| 60 | - public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 61 | - { |
|
| 62 | - $xMetadata->exclude($sMethod)->setValue($this->bValue); |
|
| 63 | - } |
|
| 60 | +public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 61 | +{ |
|
| 62 | +$xMetadata->exclude($sMethod)->setValue($this->bValue); |
|
| 63 | +} |
|
| 64 | 64 | } |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function initAnnotation(array $properties) |
| 48 | 48 | { |
| 49 | - if(count($properties) !== 0 && (count($properties) !== 1 |
|
| 49 | + if (count($properties) !== 0 && (count($properties) !== 1 |
|
| 50 | 50 | || !isset($properties[0]) || !is_bool($properties[0]))) |
| 51 | 51 | { |
| 52 | 52 | throw new AnnotationException('the @exclude annotation requires a single boolean or no property'); |
@@ -28,42 +28,42 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class UploadAnnotation extends AbstractAnnotation |
| 30 | 30 | { |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * The name of the upload field |
| 33 | 33 | * |
| 34 | 34 | * @var string |
| 35 | 35 | */ |
| 36 | - protected $sField = ''; |
|
| 36 | +protected $sField = ''; |
|
| 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 ? ['field' => $aParams[0]] : |
|
| 45 | - ['field' => $aParams[0], 'extra' => $aParams[1]]; |
|
| 46 | - } |
|
| 41 | +public static function parseAnnotation($value) |
|
| 42 | +{ |
|
| 43 | +$aParams = preg_split('/[\s]+/', $value, 2); |
|
| 44 | +return count($aParams) === 1 ? ['field' => $aParams[0]] : |
|
| 45 | +['field' => $aParams[0], 'extra' => $aParams[1]]; |
|
| 46 | +} |
|
| 47 | 47 | |
| 48 | - /** |
|
| 48 | +/** |
|
| 49 | 49 | * @inheritDoc |
| 50 | 50 | * @throws AnnotationException |
| 51 | 51 | */ |
| 52 | - public function initAnnotation(array $properties) |
|
| 53 | - { |
|
| 54 | - if(count($properties) != 1 || !isset($properties['field']) || |
|
| 55 | - !is_string($properties['field'])) |
|
| 56 | - { |
|
| 57 | - throw new AnnotationException('The @upload annotation requires a property "field" of type string'); |
|
| 58 | - } |
|
| 59 | - $this->sField = $properties['field']; |
|
| 60 | - } |
|
| 52 | +public function initAnnotation(array $properties) |
|
| 53 | +{ |
|
| 54 | +if(count($properties) != 1 || !isset($properties['field']) || |
|
| 55 | +!is_string($properties['field'])) |
|
| 56 | +{ |
|
| 57 | +throw new AnnotationException('The @upload annotation requires a property "field" of type string'); |
|
| 58 | +} |
|
| 59 | +$this->sField = $properties['field']; |
|
| 60 | +} |
|
| 61 | 61 | |
| 62 | - /** |
|
| 62 | +/** |
|
| 63 | 63 | * @inheritDoc |
| 64 | 64 | */ |
| 65 | - public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 66 | - { |
|
| 67 | - $xMetadata->upload($sMethod)->setValue($this->sField); |
|
| 68 | - } |
|
| 65 | +public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 66 | +{ |
|
| 67 | +$xMetadata->upload($sMethod)->setValue($this->sField); |
|
| 68 | +} |
|
| 69 | 69 | } |
@@ -41,8 +41,7 @@ discard block |
||
| 41 | 41 | public static function parseAnnotation($value) |
| 42 | 42 | { |
| 43 | 43 | $aParams = preg_split('/[\s]+/', $value, 2); |
| 44 | - return count($aParams) === 1 ? ['field' => $aParams[0]] : |
|
| 45 | - ['field' => $aParams[0], 'extra' => $aParams[1]]; |
|
| 44 | + return count($aParams) === 1 ? ['field' => $aParams[0]] : ['field' => $aParams[0], 'extra' => $aParams[1]]; |
|
| 46 | 45 | } |
| 47 | 46 | |
| 48 | 47 | /** |
@@ -51,7 +50,7 @@ discard block |
||
| 51 | 50 | */ |
| 52 | 51 | public function initAnnotation(array $properties) |
| 53 | 52 | { |
| 54 | - if(count($properties) != 1 || !isset($properties['field']) || |
|
| 53 | + if (count($properties) != 1 || !isset($properties['field']) || |
|
| 55 | 54 | !is_string($properties['field'])) |
| 56 | 55 | { |
| 57 | 56 | throw new AnnotationException('The @upload annotation requires a property "field" of type string'); |
@@ -27,64 +27,64 @@ |
||
| 27 | 27 | |
| 28 | 28 | abstract class HookAnnotation extends AbstractAnnotation |
| 29 | 29 | { |
| 30 | - /** |
|
| 30 | +/** |
|
| 31 | 31 | * @var string |
| 32 | 32 | */ |
| 33 | - protected $sMethod = ''; |
|
| 33 | +protected $sMethod = ''; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 35 | +/** |
|
| 36 | 36 | * @var array |
| 37 | 37 | */ |
| 38 | - protected $aParams = []; |
|
| 38 | +protected $aParams = []; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * |
| 42 | 42 | */ |
| 43 | - abstract protected static function getType(): string; |
|
| 43 | +abstract protected static function getType(): string; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | +/** |
|
| 46 | 46 | * @inheritDoc |
| 47 | 47 | */ |
| 48 | - public static function parseAnnotation($value) |
|
| 49 | - { |
|
| 50 | - $aParams = preg_split('/[\s]+/', $value, 2); |
|
| 51 | - if(count($aParams) === 1) |
|
| 52 | - { |
|
| 53 | - return ['call' => rtrim($aParams[0])]; |
|
| 54 | - } |
|
| 55 | - // The second parameter must be an array of callback parameter in json format. |
|
| 56 | - return ['call' => rtrim($aParams[0]), 'with' => json_decode($aParams[1], false)]; |
|
| 57 | - } |
|
| 48 | +public static function parseAnnotation($value) |
|
| 49 | +{ |
|
| 50 | +$aParams = preg_split('/[\s]+/', $value, 2); |
|
| 51 | +if(count($aParams) === 1) |
|
| 52 | +{ |
|
| 53 | +return ['call' => rtrim($aParams[0])]; |
|
| 54 | +} |
|
| 55 | +// The second parameter must be an array of callback parameter in json format. |
|
| 56 | +return ['call' => rtrim($aParams[0]), 'with' => json_decode($aParams[1], false)]; |
|
| 57 | +} |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * @inheritDoc |
| 61 | 61 | * @throws AnnotationException |
| 62 | 62 | */ |
| 63 | - public function initAnnotation(array $properties) |
|
| 64 | - { |
|
| 65 | - if(!isset($properties['call']) || !is_string($properties['call'])) |
|
| 66 | - { |
|
| 67 | - throw new AnnotationException('The @' . $this->getType() . |
|
| 68 | - ' annotation requires a property "call" of type string'); |
|
| 69 | - } |
|
| 70 | - foreach(array_keys($properties) as $propName) |
|
| 71 | - { |
|
| 72 | - if($propName !== 'call' && $propName !== 'with') |
|
| 73 | - { |
|
| 74 | - throw new AnnotationException('Unknown property "' . $propName . |
|
| 75 | - '" in the @' . $this->getType() . ' annotation'); |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - // Cannot use isset here, because it will return false in case $properties['with'] === null |
|
| 79 | - if(array_key_exists('with', $properties)) |
|
| 80 | - { |
|
| 81 | - if(!is_array($properties['with'])) |
|
| 82 | - { |
|
| 83 | - throw new AnnotationException('The "with" property of the @' . |
|
| 84 | - $this->getType() . ' annotation must be of type array'); |
|
| 85 | - } |
|
| 86 | - $this->aParams = $properties['with']; |
|
| 87 | - } |
|
| 88 | - $this->sMethod = $properties['call']; |
|
| 89 | - } |
|
| 63 | +public function initAnnotation(array $properties) |
|
| 64 | +{ |
|
| 65 | +if(!isset($properties['call']) || !is_string($properties['call'])) |
|
| 66 | +{ |
|
| 67 | +throw new AnnotationException('The @' . $this->getType() . |
|
| 68 | + ' annotation requires a property "call" of type string'); |
|
| 69 | +} |
|
| 70 | +foreach(array_keys($properties) as $propName) |
|
| 71 | +{ |
|
| 72 | +if($propName !== 'call' && $propName !== 'with') |
|
| 73 | +{ |
|
| 74 | + throw new AnnotationException('Unknown property "' . $propName . |
|
| 75 | + '" in the @' . $this->getType() . ' annotation'); |
|
| 76 | +} |
|
| 77 | +} |
|
| 78 | +// Cannot use isset here, because it will return false in case $properties['with'] === null |
|
| 79 | +if(array_key_exists('with', $properties)) |
|
| 80 | +{ |
|
| 81 | +if(!is_array($properties['with'])) |
|
| 82 | +{ |
|
| 83 | + throw new AnnotationException('The "with" property of the @' . |
|
| 84 | + $this->getType() . ' annotation must be of type array'); |
|
| 85 | +} |
|
| 86 | +$this->aParams = $properties['with']; |
|
| 87 | +} |
|
| 88 | +$this->sMethod = $properties['call']; |
|
| 89 | +} |
|
| 90 | 90 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | public static function parseAnnotation($value) |
| 49 | 49 | { |
| 50 | 50 | $aParams = preg_split('/[\s]+/', $value, 2); |
| 51 | - if(count($aParams) === 1) |
|
| 51 | + if (count($aParams) === 1) |
|
| 52 | 52 | { |
| 53 | 53 | return ['call' => rtrim($aParams[0])]; |
| 54 | 54 | } |
@@ -62,23 +62,23 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function initAnnotation(array $properties) |
| 64 | 64 | { |
| 65 | - if(!isset($properties['call']) || !is_string($properties['call'])) |
|
| 65 | + if (!isset($properties['call']) || !is_string($properties['call'])) |
|
| 66 | 66 | { |
| 67 | 67 | throw new AnnotationException('The @' . $this->getType() . |
| 68 | 68 | ' annotation requires a property "call" of type string'); |
| 69 | 69 | } |
| 70 | - foreach(array_keys($properties) as $propName) |
|
| 70 | + foreach (array_keys($properties) as $propName) |
|
| 71 | 71 | { |
| 72 | - if($propName !== 'call' && $propName !== 'with') |
|
| 72 | + if ($propName !== 'call' && $propName !== 'with') |
|
| 73 | 73 | { |
| 74 | 74 | throw new AnnotationException('Unknown property "' . $propName . |
| 75 | 75 | '" in the @' . $this->getType() . ' annotation'); |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | // Cannot use isset here, because it will return false in case $properties['with'] === null |
| 79 | - if(array_key_exists('with', $properties)) |
|
| 79 | + if (array_key_exists('with', $properties)) |
|
| 80 | 80 | { |
| 81 | - if(!is_array($properties['with'])) |
|
| 81 | + if (!is_array($properties['with'])) |
|
| 82 | 82 | { |
| 83 | 83 | throw new AnnotationException('The "with" property of the @' . |
| 84 | 84 | $this->getType() . ' annotation must be of type array'); |
@@ -232,8 +232,7 @@ |
||
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | return $this->xMetadata; |
| 235 | - } |
|
| 236 | - catch(AnnotationException $e) |
|
| 235 | + } catch(AnnotationException $e) |
|
| 237 | 236 | { |
| 238 | 237 | throw new SetupException($e->getMessage()); |
| 239 | 238 | } |
@@ -116,21 +116,21 @@ discard block |
||
| 116 | 116 | fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class) |
| 117 | 117 | ); |
| 118 | 118 | // First check if the class is excluded. |
| 119 | - foreach($aAnnotations as $xAnnotation) |
|
| 119 | + foreach ($aAnnotations as $xAnnotation) |
|
| 120 | 120 | { |
| 121 | - if(is_a($xAnnotation, ExcludeAnnotation::class)) |
|
| 121 | + if (is_a($xAnnotation, ExcludeAnnotation::class)) |
|
| 122 | 122 | { |
| 123 | 123 | $xAnnotation->saveValue($this->xMetadata); |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | - if($this->xMetadata->isExcluded()) |
|
| 126 | + if ($this->xMetadata->isExcluded()) |
|
| 127 | 127 | { |
| 128 | 128 | return; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - foreach($aAnnotations as $xAnnotation) |
|
| 131 | + foreach ($aAnnotations as $xAnnotation) |
|
| 132 | 132 | { |
| 133 | - if(!is_a($xAnnotation, ExcludeAnnotation::class)) |
|
| 133 | + if (!is_a($xAnnotation, ExcludeAnnotation::class)) |
|
| 134 | 134 | { |
| 135 | 135 | $xAnnotation->saveValue($this->xMetadata); |
| 136 | 136 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $this->xManager->getPropertyAnnotations($sClass, $sProperty), |
| 153 | 153 | function($xAnnotation) use($sProperty) { |
| 154 | 154 | // Save the property type |
| 155 | - if(is_a($xAnnotation, VarAnnotation::class)) |
|
| 155 | + if (is_a($xAnnotation, VarAnnotation::class)) |
|
| 156 | 156 | { |
| 157 | 157 | $this->aPropTypes[$sProperty] = $xAnnotation->type; |
| 158 | 158 | } |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | return is_a($xAnnotation, ContainerAnnotation::class); |
| 161 | 161 | } |
| 162 | 162 | ); |
| 163 | - if(count($aAnnotations) > 1) |
|
| 163 | + if (count($aAnnotations) > 1) |
|
| 164 | 164 | { |
| 165 | 165 | throw new AnnotationException('Only one @di annotation is allowed on a property'); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - foreach($aAnnotations as $xAnnotation) |
|
| 168 | + foreach ($aAnnotations as $xAnnotation) |
|
| 169 | 169 | { |
| 170 | 170 | $xAnnotation->setAttr($sProperty); |
| 171 | 171 | $xAnnotation->saveValue($this->xMetadata); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $this->xManager->getMethodAnnotations($sClass, $sMethod), |
| 188 | 188 | fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class) |
| 189 | 189 | ); |
| 190 | - foreach($aAnnotations as $xAnnotation) |
|
| 190 | + foreach ($aAnnotations as $xAnnotation) |
|
| 191 | 191 | { |
| 192 | 192 | $xAnnotation->saveValue($this->xMetadata, $sMethod); |
| 193 | 193 | } |
@@ -214,13 +214,13 @@ discard block |
||
| 214 | 214 | $this->sCurrMemberType = AnnotationManager::MEMBER_PROPERTY; |
| 215 | 215 | |
| 216 | 216 | // Properties annotations |
| 217 | - foreach($xInput->getProperties() as $sProperty) |
|
| 217 | + foreach ($xInput->getProperties() as $sProperty) |
|
| 218 | 218 | { |
| 219 | 219 | $this->readPropertyAnnotations($sClass, $sProperty); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | // The methods annotations are not taken for excluded classes. |
| 223 | - if($this->xMetadata->isExcluded()) |
|
| 223 | + if ($this->xMetadata->isExcluded()) |
|
| 224 | 224 | { |
| 225 | 225 | return $this->xMetadata; |
| 226 | 226 | } |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | // Processing methods annotations |
| 229 | 229 | $this->sCurrMemberType = AnnotationManager::MEMBER_METHOD; |
| 230 | 230 | |
| 231 | - foreach($xInput->getMethods() as $sMethod) |
|
| 231 | + foreach ($xInput->getMethods() as $sMethod) |
|
| 232 | 232 | { |
| 233 | 233 | $this->readMethodAnnotations($sClass, $sMethod); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | return $this->xMetadata; |
| 237 | 237 | } |
| 238 | - catch(AnnotationException $e) |
|
| 238 | + catch (AnnotationException $e) |
|
| 239 | 239 | { |
| 240 | 240 | throw new SetupException($e->getMessage()); |
| 241 | 241 | } |
@@ -37,207 +37,207 @@ |
||
| 37 | 37 | |
| 38 | 38 | class AnnotationReader implements MetadataReaderInterface |
| 39 | 39 | { |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * @var AnnotationManager |
| 42 | 42 | */ |
| 43 | - protected $xManager; |
|
| 43 | +protected $xManager; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | +/** |
|
| 46 | 46 | * @var Metadata |
| 47 | 47 | */ |
| 48 | - protected $xMetadata; |
|
| 48 | +protected $xMetadata; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | +/** |
|
| 51 | 51 | * Properties types, read from the "var" annotations. |
| 52 | 52 | * |
| 53 | 53 | * @var array |
| 54 | 54 | */ |
| 55 | - protected $aPropTypes; |
|
| 55 | +protected $aPropTypes; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 57 | +/** |
|
| 58 | 58 | * The type of the class member being currently processed. |
| 59 | 59 | * |
| 60 | 60 | * @var string |
| 61 | 61 | */ |
| 62 | - protected $sCurrMemberType; |
|
| 62 | +protected $sCurrMemberType; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 64 | +/** |
|
| 65 | 65 | * The constructor |
| 66 | 66 | * |
| 67 | 67 | * @param AnnotationManager $xManager |
| 68 | 68 | */ |
| 69 | - public function __construct(AnnotationManager $xManager) |
|
| 70 | - { |
|
| 71 | - $this->xManager = $xManager; |
|
| 72 | - $this->xManager->registry['upload'] = UploadAnnotation::class; |
|
| 73 | - $this->xManager->registry['databag'] = DatabagAnnotation::class; |
|
| 74 | - $this->xManager->registry['exclude'] = ExcludeAnnotation::class; |
|
| 75 | - $this->xManager->registry['export'] = ExportAnnotation::class; |
|
| 76 | - $this->xManager->registry['before'] = BeforeAnnotation::class; |
|
| 77 | - $this->xManager->registry['after'] = AfterAnnotation::class; |
|
| 78 | - $this->xManager->registry['di'] = ContainerAnnotation::class; |
|
| 79 | - $this->xManager->registry['callback'] = CallbackAnnotation::class; |
|
| 80 | - // Missing standard annotations. |
|
| 81 | - // We need to define this, otherwise they throw an exception, and make the whole processing fail. |
|
| 82 | - $this->xManager->registry['const'] = false; |
|
| 83 | - $this->xManager->registry['inheritDoc'] = false; |
|
| 84 | - $this->xManager->registry['template'] = false; |
|
| 85 | - $this->xManager->registry['param-closure-this'] = false; |
|
| 86 | - } |
|
| 69 | +public function __construct(AnnotationManager $xManager) |
|
| 70 | +{ |
|
| 71 | +$this->xManager = $xManager; |
|
| 72 | +$this->xManager->registry['upload'] = UploadAnnotation::class; |
|
| 73 | +$this->xManager->registry['databag'] = DatabagAnnotation::class; |
|
| 74 | +$this->xManager->registry['exclude'] = ExcludeAnnotation::class; |
|
| 75 | +$this->xManager->registry['export'] = ExportAnnotation::class; |
|
| 76 | +$this->xManager->registry['before'] = BeforeAnnotation::class; |
|
| 77 | +$this->xManager->registry['after'] = AfterAnnotation::class; |
|
| 78 | +$this->xManager->registry['di'] = ContainerAnnotation::class; |
|
| 79 | +$this->xManager->registry['callback'] = CallbackAnnotation::class; |
|
| 80 | +// Missing standard annotations. |
|
| 81 | +// We need to define this, otherwise they throw an exception, and make the whole processing fail. |
|
| 82 | +$this->xManager->registry['const'] = false; |
|
| 83 | +$this->xManager->registry['inheritDoc'] = false; |
|
| 84 | +$this->xManager->registry['template'] = false; |
|
| 85 | +$this->xManager->registry['param-closure-this'] = false; |
|
| 86 | +} |
|
| 87 | 87 | |
| 88 | - /** |
|
| 88 | +/** |
|
| 89 | 89 | * @return array |
| 90 | 90 | */ |
| 91 | - public function getPropTypes(): array |
|
| 92 | - { |
|
| 93 | - return $this->aPropTypes; |
|
| 94 | - } |
|
| 91 | +public function getPropTypes(): array |
|
| 92 | +{ |
|
| 93 | +return $this->aPropTypes; |
|
| 94 | +} |
|
| 95 | 95 | |
| 96 | - /** |
|
| 96 | +/** |
|
| 97 | 97 | * @return bool |
| 98 | 98 | */ |
| 99 | - public function annotationIsOnProperty(): bool |
|
| 100 | - { |
|
| 101 | - return $this->sCurrMemberType === AnnotationManager::MEMBER_PROPERTY; |
|
| 102 | - } |
|
| 99 | +public function annotationIsOnProperty(): bool |
|
| 100 | +{ |
|
| 101 | +return $this->sCurrMemberType === AnnotationManager::MEMBER_PROPERTY; |
|
| 102 | +} |
|
| 103 | 103 | |
| 104 | - /** |
|
| 104 | +/** |
|
| 105 | 105 | * @param string $sClass |
| 106 | 106 | * |
| 107 | 107 | * @return void |
| 108 | 108 | * @throws AnnotationException |
| 109 | 109 | */ |
| 110 | - private function readClassAnnotations(string $sClass): void |
|
| 111 | - { |
|
| 112 | - // Only keep the annotations declared in this package. |
|
| 113 | - /** @var array<AbstractAnnotation> */ |
|
| 114 | - $aAnnotations = array_filter( |
|
| 115 | - $this->xManager->getClassAnnotations($sClass), |
|
| 116 | - fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class) |
|
| 117 | - ); |
|
| 118 | - // First check if the class is excluded. |
|
| 119 | - foreach($aAnnotations as $xAnnotation) |
|
| 120 | - { |
|
| 121 | - if(is_a($xAnnotation, ExcludeAnnotation::class)) |
|
| 122 | - { |
|
| 123 | - $xAnnotation->saveValue($this->xMetadata); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - if($this->xMetadata->isExcluded()) |
|
| 127 | - { |
|
| 128 | - return; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - foreach($aAnnotations as $xAnnotation) |
|
| 132 | - { |
|
| 133 | - if(!is_a($xAnnotation, ExcludeAnnotation::class)) |
|
| 134 | - { |
|
| 135 | - $xAnnotation->saveValue($this->xMetadata); |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - } |
|
| 110 | +private function readClassAnnotations(string $sClass): void |
|
| 111 | +{ |
|
| 112 | +// Only keep the annotations declared in this package. |
|
| 113 | +/** @var array<AbstractAnnotation> */ |
|
| 114 | +$aAnnotations = array_filter( |
|
| 115 | +$this->xManager->getClassAnnotations($sClass), |
|
| 116 | +fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class) |
|
| 117 | +); |
|
| 118 | +// First check if the class is excluded. |
|
| 119 | +foreach($aAnnotations as $xAnnotation) |
|
| 120 | +{ |
|
| 121 | +if(is_a($xAnnotation, ExcludeAnnotation::class)) |
|
| 122 | +{ |
|
| 123 | + $xAnnotation->saveValue($this->xMetadata); |
|
| 124 | +} |
|
| 125 | +} |
|
| 126 | +if($this->xMetadata->isExcluded()) |
|
| 127 | +{ |
|
| 128 | +return; |
|
| 129 | +} |
|
| 139 | 130 | |
| 140 | - /** |
|
| 131 | +foreach($aAnnotations as $xAnnotation) |
|
| 132 | +{ |
|
| 133 | +if(!is_a($xAnnotation, ExcludeAnnotation::class)) |
|
| 134 | +{ |
|
| 135 | + $xAnnotation->saveValue($this->xMetadata); |
|
| 136 | +} |
|
| 137 | +} |
|
| 138 | +} |
|
| 139 | + |
|
| 140 | +/** |
|
| 141 | 141 | * @param string $sClass |
| 142 | 142 | * @param string $sProperty |
| 143 | 143 | * |
| 144 | 144 | * @return void |
| 145 | 145 | * @throws AnnotationException |
| 146 | 146 | */ |
| 147 | - private function readPropertyAnnotations(string $sClass, string $sProperty): void |
|
| 147 | +private function readPropertyAnnotations(string $sClass, string $sProperty): void |
|
| 148 | +{ |
|
| 149 | +/** @var array<ContainerAnnotation> */ |
|
| 150 | +// Only keep the annotations declared in this package. |
|
| 151 | +$aAnnotations = array_filter( |
|
| 152 | +$this->xManager->getPropertyAnnotations($sClass, $sProperty), |
|
| 153 | +function($xAnnotation) use($sProperty) { |
|
| 154 | + // Save the property type |
|
| 155 | + if(is_a($xAnnotation, VarAnnotation::class)) |
|
| 148 | 156 | { |
| 149 | - /** @var array<ContainerAnnotation> */ |
|
| 150 | - // Only keep the annotations declared in this package. |
|
| 151 | - $aAnnotations = array_filter( |
|
| 152 | - $this->xManager->getPropertyAnnotations($sClass, $sProperty), |
|
| 153 | - function($xAnnotation) use($sProperty) { |
|
| 154 | - // Save the property type |
|
| 155 | - if(is_a($xAnnotation, VarAnnotation::class)) |
|
| 156 | - { |
|
| 157 | - $this->aPropTypes[$sProperty] = $xAnnotation->type; |
|
| 158 | - } |
|
| 159 | - // Only container annotations are allowed on properties |
|
| 160 | - return is_a($xAnnotation, ContainerAnnotation::class); |
|
| 161 | - } |
|
| 162 | - ); |
|
| 163 | - if(count($aAnnotations) > 1) |
|
| 164 | - { |
|
| 165 | - throw new AnnotationException('Only one @di annotation is allowed on a property'); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - foreach($aAnnotations as $xAnnotation) |
|
| 169 | - { |
|
| 170 | - $xAnnotation->setAttr($sProperty); |
|
| 171 | - $xAnnotation->saveValue($this->xMetadata); |
|
| 172 | - } |
|
| 157 | + $this->aPropTypes[$sProperty] = $xAnnotation->type; |
|
| 173 | 158 | } |
| 159 | + // Only container annotations are allowed on properties |
|
| 160 | + return is_a($xAnnotation, ContainerAnnotation::class); |
|
| 161 | +} |
|
| 162 | +); |
|
| 163 | +if(count($aAnnotations) > 1) |
|
| 164 | +{ |
|
| 165 | +throw new AnnotationException('Only one @di annotation is allowed on a property'); |
|
| 166 | +} |
|
| 167 | + |
|
| 168 | +foreach($aAnnotations as $xAnnotation) |
|
| 169 | +{ |
|
| 170 | +$xAnnotation->setAttr($sProperty); |
|
| 171 | +$xAnnotation->saveValue($this->xMetadata); |
|
| 172 | +} |
|
| 173 | +} |
|
| 174 | 174 | |
| 175 | - /** |
|
| 175 | +/** |
|
| 176 | 176 | * @param string $sClass |
| 177 | 177 | * @param string $sMethod |
| 178 | 178 | * |
| 179 | 179 | * @return void |
| 180 | 180 | * @throws AnnotationException |
| 181 | 181 | */ |
| 182 | - private function readMethodAnnotations(string $sClass, string $sMethod): void |
|
| 183 | - { |
|
| 184 | - // Only keep the annotations declared in this package. |
|
| 185 | - /** @var array<AbstractAnnotation> */ |
|
| 186 | - $aAnnotations = array_filter( |
|
| 187 | - $this->xManager->getMethodAnnotations($sClass, $sMethod), |
|
| 188 | - fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class) |
|
| 189 | - ); |
|
| 190 | - foreach($aAnnotations as $xAnnotation) |
|
| 191 | - { |
|
| 192 | - $xAnnotation->saveValue($this->xMetadata, $sMethod); |
|
| 193 | - } |
|
| 194 | - } |
|
| 182 | +private function readMethodAnnotations(string $sClass, string $sMethod): void |
|
| 183 | +{ |
|
| 184 | +// Only keep the annotations declared in this package. |
|
| 185 | +/** @var array<AbstractAnnotation> */ |
|
| 186 | +$aAnnotations = array_filter( |
|
| 187 | +$this->xManager->getMethodAnnotations($sClass, $sMethod), |
|
| 188 | +fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class) |
|
| 189 | +); |
|
| 190 | +foreach($aAnnotations as $xAnnotation) |
|
| 191 | +{ |
|
| 192 | +$xAnnotation->saveValue($this->xMetadata, $sMethod); |
|
| 193 | +} |
|
| 194 | +} |
|
| 195 | 195 | |
| 196 | - /** |
|
| 196 | +/** |
|
| 197 | 197 | * @throws SetupException |
| 198 | 198 | */ |
| 199 | - public function getAttributes(InputData $xInput): Metadata |
|
| 200 | - { |
|
| 201 | - ContainerAnnotation::$xReader = $this; |
|
| 202 | - $this->aPropTypes = []; |
|
| 203 | - $this->xMetadata = new Metadata(); |
|
| 204 | - $sClass = $xInput->getReflectionClass()->getName(); |
|
| 205 | - |
|
| 206 | - try |
|
| 207 | - { |
|
| 208 | - // Processing class annotations |
|
| 209 | - $this->sCurrMemberType = AnnotationManager::MEMBER_CLASS; |
|
| 210 | - |
|
| 211 | - $this->readClassAnnotations($sClass); |
|
| 212 | - |
|
| 213 | - // Processing properties annotations |
|
| 214 | - $this->sCurrMemberType = AnnotationManager::MEMBER_PROPERTY; |
|
| 215 | - |
|
| 216 | - // Properties annotations |
|
| 217 | - foreach($xInput->getProperties() as $sProperty) |
|
| 218 | - { |
|
| 219 | - $this->readPropertyAnnotations($sClass, $sProperty); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - // The methods annotations are not taken for excluded classes. |
|
| 223 | - if($this->xMetadata->isExcluded()) |
|
| 224 | - { |
|
| 225 | - return $this->xMetadata; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // Processing methods annotations |
|
| 229 | - $this->sCurrMemberType = AnnotationManager::MEMBER_METHOD; |
|
| 230 | - |
|
| 231 | - foreach($xInput->getMethods() as $sMethod) |
|
| 232 | - { |
|
| 233 | - $this->readMethodAnnotations($sClass, $sMethod); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - return $this->xMetadata; |
|
| 237 | - } |
|
| 238 | - catch(AnnotationException $e) |
|
| 239 | - { |
|
| 240 | - throw new SetupException($e->getMessage()); |
|
| 241 | - } |
|
| 242 | - } |
|
| 199 | +public function getAttributes(InputData $xInput): Metadata |
|
| 200 | +{ |
|
| 201 | +ContainerAnnotation::$xReader = $this; |
|
| 202 | +$this->aPropTypes = []; |
|
| 203 | +$this->xMetadata = new Metadata(); |
|
| 204 | +$sClass = $xInput->getReflectionClass()->getName(); |
|
| 205 | + |
|
| 206 | +try |
|
| 207 | +{ |
|
| 208 | +// Processing class annotations |
|
| 209 | +$this->sCurrMemberType = AnnotationManager::MEMBER_CLASS; |
|
| 210 | + |
|
| 211 | +$this->readClassAnnotations($sClass); |
|
| 212 | + |
|
| 213 | +// Processing properties annotations |
|
| 214 | +$this->sCurrMemberType = AnnotationManager::MEMBER_PROPERTY; |
|
| 215 | + |
|
| 216 | +// Properties annotations |
|
| 217 | +foreach($xInput->getProperties() as $sProperty) |
|
| 218 | +{ |
|
| 219 | + $this->readPropertyAnnotations($sClass, $sProperty); |
|
| 220 | +} |
|
| 221 | + |
|
| 222 | +// The methods annotations are not taken for excluded classes. |
|
| 223 | +if($this->xMetadata->isExcluded()) |
|
| 224 | +{ |
|
| 225 | + return $this->xMetadata; |
|
| 226 | +} |
|
| 227 | + |
|
| 228 | +// Processing methods annotations |
|
| 229 | +$this->sCurrMemberType = AnnotationManager::MEMBER_METHOD; |
|
| 230 | + |
|
| 231 | +foreach($xInput->getMethods() as $sMethod) |
|
| 232 | +{ |
|
| 233 | + $this->readMethodAnnotations($sClass, $sMethod); |
|
| 234 | +} |
|
| 235 | + |
|
| 236 | +return $this->xMetadata; |
|
| 237 | +} |
|
| 238 | +catch(AnnotationException $e) |
|
| 239 | +{ |
|
| 240 | +throw new SetupException($e->getMessage()); |
|
| 241 | +} |
|
| 242 | +} |
|
| 243 | 243 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | $jaxon = jaxon(); |
| 26 | 26 | $di = $jaxon->di(); |
| 27 | - if($di->h(UploadHandler::class)) |
|
| 27 | + if ($di->h(UploadHandler::class)) |
|
| 28 | 28 | { |
| 29 | 29 | return; |
| 30 | 30 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $xUploadHandler = $di->g(UploadHandler::class); |
| 77 | 77 | // The HTTP request |
| 78 | 78 | $xRequest = $di->getRequest(); |
| 79 | - if($xUploadHandler->canProcessRequest($xRequest)) |
|
| 79 | + if ($xUploadHandler->canProcessRequest($xRequest)) |
|
| 80 | 80 | { |
| 81 | 81 | $xUploadHandler->processRequest($xRequest); |
| 82 | 82 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | $jaxon = jaxon(); |
| 94 | 94 | $jaxon->callback()->boot(function() use($jaxon) { |
| 95 | - if($jaxon->getOption('core.upload.enabled')) |
|
| 95 | + if ($jaxon->getOption('core.upload.enabled')) |
|
| 96 | 96 | { |
| 97 | 97 | registerUpload(); |
| 98 | 98 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | function register() |
| 103 | 103 | { |
| 104 | 104 | // Do nothing if running in cli. |
| 105 | - if(php_sapi_name() !== 'cli') |
|
| 105 | + if (php_sapi_name() !== 'cli') |
|
| 106 | 106 | { |
| 107 | 107 | _register(); |
| 108 | 108 | }; |