@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | protected function validateAttr(string $sAttr): void |
| 53 | 53 | { |
| 54 | - if(preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sAttr) > 0) |
|
| 54 | + if (preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sAttr) > 0) |
|
| 55 | 55 | { |
| 56 | 56 | return; |
| 57 | 57 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | protected function validateClass(string $sClass): void |
| 67 | 67 | { |
| 68 | - if(preg_match('/^(\\\)?([a-zA-Z][a-zA-Z0-9_]*)(\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sClass) > 0) |
|
| 68 | + if (preg_match('/^(\\\)?([a-zA-Z][a-zA-Z0-9_]*)(\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sClass) > 0) |
|
| 69 | 69 | { |
| 70 | 70 | return; |
| 71 | 71 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | public function encode(string $sVarName): array |
| 93 | 93 | { |
| 94 | 94 | $aCalls = []; |
| 95 | - foreach($this->aProperties as $sAttr => $sClass) |
|
| 95 | + foreach ($this->aProperties as $sAttr => $sClass) |
|
| 96 | 96 | { |
| 97 | 97 | $aCalls[] = "{$sVarName}->addValue('$sAttr', '" . addslashes($sClass) . "');"; |
| 98 | 98 | } |
@@ -21,81 +21,81 @@ |
||
| 21 | 21 | |
| 22 | 22 | class ContainerData extends AbstractData |
| 23 | 23 | { |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * The properties to get from the container |
| 26 | 26 | * |
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - protected $aProperties = []; |
|
| 29 | +protected $aProperties = []; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | - public function getName(): string |
|
| 35 | - { |
|
| 36 | - return '__di'; |
|
| 37 | - } |
|
| 34 | +public function getName(): string |
|
| 35 | +{ |
|
| 36 | +return '__di'; |
|
| 37 | +} |
|
| 38 | 38 | |
| 39 | - /** |
|
| 39 | +/** |
|
| 40 | 40 | * @return mixed |
| 41 | 41 | */ |
| 42 | - public function getValue(): mixed |
|
| 43 | - { |
|
| 44 | - return $this->aProperties; |
|
| 45 | - } |
|
| 42 | +public function getValue(): mixed |
|
| 43 | +{ |
|
| 44 | +return $this->aProperties; |
|
| 45 | +} |
|
| 46 | 46 | |
| 47 | - /** |
|
| 47 | +/** |
|
| 48 | 48 | * @param string $sAttr |
| 49 | 49 | * |
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | - protected function validateAttr(string $sAttr): void |
|
| 53 | - { |
|
| 54 | - if(preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sAttr) > 0) |
|
| 55 | - { |
|
| 56 | - return; |
|
| 57 | - } |
|
| 58 | - throw new SetupException("$sAttr is not a valid \"attr\" value for di"); |
|
| 59 | - } |
|
| 52 | +protected function validateAttr(string $sAttr): void |
|
| 53 | +{ |
|
| 54 | +if(preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sAttr) > 0) |
|
| 55 | +{ |
|
| 56 | +return; |
|
| 57 | +} |
|
| 58 | +throw new SetupException("$sAttr is not a valid \"attr\" value for di"); |
|
| 59 | +} |
|
| 60 | 60 | |
| 61 | - /** |
|
| 61 | +/** |
|
| 62 | 62 | * @param string $sClass |
| 63 | 63 | * |
| 64 | 64 | * @return void |
| 65 | 65 | */ |
| 66 | - protected function validateClass(string $sClass): void |
|
| 67 | - { |
|
| 68 | - if(preg_match('/^(\\\)?([a-zA-Z][a-zA-Z0-9_]*)(\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sClass) > 0) |
|
| 69 | - { |
|
| 70 | - return; |
|
| 71 | - } |
|
| 72 | - throw new SetupException("$sClass is not a valid \"class\" value for di"); |
|
| 73 | - } |
|
| 66 | +protected function validateClass(string $sClass): void |
|
| 67 | +{ |
|
| 68 | +if(preg_match('/^(\\\)?([a-zA-Z][a-zA-Z0-9_]*)(\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sClass) > 0) |
|
| 69 | +{ |
|
| 70 | +return; |
|
| 71 | +} |
|
| 72 | +throw new SetupException("$sClass is not a valid \"class\" value for di"); |
|
| 73 | +} |
|
| 74 | 74 | |
| 75 | - /** |
|
| 75 | +/** |
|
| 76 | 76 | * @param string $sAttr |
| 77 | 77 | * @param string $sClass |
| 78 | 78 | * |
| 79 | 79 | * @return void |
| 80 | 80 | */ |
| 81 | - public function addValue(string $sAttr, string $sClass): void |
|
| 82 | - { |
|
| 83 | - $this->validateAttr($sAttr); |
|
| 84 | - $this->validateClass($sClass); |
|
| 81 | +public function addValue(string $sAttr, string $sClass): void |
|
| 82 | +{ |
|
| 83 | +$this->validateAttr($sAttr); |
|
| 84 | +$this->validateClass($sClass); |
|
| 85 | 85 | |
| 86 | - $this->aProperties[$sAttr] = $sClass; |
|
| 87 | - } |
|
| 86 | +$this->aProperties[$sAttr] = $sClass; |
|
| 87 | +} |
|
| 88 | 88 | |
| 89 | - /** |
|
| 89 | +/** |
|
| 90 | 90 | * @inheritDoc |
| 91 | 91 | */ |
| 92 | - public function encode(string $sVarName): array |
|
| 93 | - { |
|
| 94 | - $aCalls = []; |
|
| 95 | - foreach($this->aProperties as $sAttr => $sClass) |
|
| 96 | - { |
|
| 97 | - $aCalls[] = "{$sVarName}->addValue('$sAttr', '" . addslashes($sClass) . "');"; |
|
| 98 | - } |
|
| 99 | - return $aCalls; |
|
| 100 | - } |
|
| 92 | +public function encode(string $sVarName): array |
|
| 93 | +{ |
|
| 94 | +$aCalls = []; |
|
| 95 | +foreach($this->aProperties as $sAttr => $sClass) |
|
| 96 | +{ |
|
| 97 | +$aCalls[] = "{$sVarName}->addValue('$sAttr', '" . addslashes($sClass) . "');"; |
|
| 98 | +} |
|
| 99 | +return $aCalls; |
|
| 100 | +} |
|
| 101 | 101 | } |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function checkOptions(string $sCallable, $xOptions): array |
| 80 | 80 | { |
| 81 | - if(!$this->xValidator->validateClass(trim($sCallable))) |
|
| 81 | + if (!$this->xValidator->validateClass(trim($sCallable))) |
|
| 82 | 82 | { |
| 83 | 83 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
| 84 | 84 | } |
| 85 | - if(is_string($xOptions)) |
|
| 85 | + if (is_string($xOptions)) |
|
| 86 | 86 | { |
| 87 | 87 | $xOptions = ['include' => $xOptions]; |
| 88 | 88 | } |
| 89 | - elseif(!is_array($xOptions)) |
|
| 89 | + elseif (!is_array($xOptions)) |
|
| 90 | 90 | { |
| 91 | 91 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
| 92 | 92 | } |
@@ -130,16 +130,16 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | $sCode = ''; |
| 132 | 132 | $aJsClasses = []; |
| 133 | - foreach($this->xRegistry->getNamespaces() as $sNamespace) |
|
| 133 | + foreach ($this->xRegistry->getNamespaces() as $sNamespace) |
|
| 134 | 134 | { |
| 135 | 135 | $offset = 0; |
| 136 | 136 | $sJsNamespace = str_replace('\\', '.', $sNamespace); |
| 137 | 137 | $sJsNamespace .= '.Null'; // This is a sentinel. The last token is not processed in the while loop. |
| 138 | - while(($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false) |
|
| 138 | + while (($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false) |
|
| 139 | 139 | { |
| 140 | 140 | $sJsClass = substr($sJsNamespace, 0, $dotPosition); |
| 141 | 141 | // Generate code for this object |
| 142 | - if(!isset($aJsClasses[$sJsClass])) |
|
| 142 | + if (!isset($aJsClasses[$sJsClass])) |
|
| 143 | 143 | { |
| 144 | 144 | $sCode .= $this->sPrefix . "$sJsClass = {};\n"; |
| 145 | 145 | $aJsClasses[$sJsClass] = $sJsClass; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | private function getCallableScript(CallableObject $xCallableObject): string |
| 161 | 161 | { |
| 162 | - if($xCallableObject->excluded()) |
|
| 162 | + if ($xCallableObject->excluded()) |
|
| 163 | 163 | { |
| 164 | 164 | return ''; |
| 165 | 165 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | // Will be used to print a translated error message. |
| 240 | 240 | $aErrorParams = ['class' => $sClassName, 'method' => $sMethodName]; |
| 241 | 241 | |
| 242 | - if(!$this->xValidator->validateJsObject($sClassName) || |
|
| 242 | + if (!$this->xValidator->validateJsObject($sClassName) || |
|
| 243 | 243 | !$this->xValidator->validateMethod($sMethodName)) |
| 244 | 244 | { |
| 245 | 245 | // Unable to find the requested object or method |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | /** @var CallableObject */ |
| 254 | 254 | $xCallableObject = $this->getCallable($sClassName); |
| 255 | 255 | |
| 256 | - if($xCallableObject->excluded($sMethodName)) |
|
| 256 | + if ($xCallableObject->excluded($sMethodName)) |
|
| 257 | 257 | { |
| 258 | 258 | // Unable to find the requested class or method |
| 259 | 259 | $this->throwException('', 'errors.objects.excluded', $aErrorParams); |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $sError = 'errors.objects.call'; |
| 263 | 263 | $xCallableObject->call($this->xTarget); |
| 264 | 264 | } |
| 265 | - catch(ReflectionException|SetupException $e) |
|
| 265 | + catch (ReflectionException|SetupException $e) |
|
| 266 | 266 | { |
| 267 | 267 | // Unable to execute the requested class or method |
| 268 | 268 | $this->throwException($e->getMessage(), $sError, $aErrorParams); |
@@ -85,8 +85,7 @@ discard block |
||
| 85 | 85 | if(is_string($xOptions)) |
| 86 | 86 | { |
| 87 | 87 | $xOptions = ['include' => $xOptions]; |
| 88 | - } |
|
| 89 | - elseif(!is_array($xOptions)) |
|
| 88 | + } elseif(!is_array($xOptions)) |
|
| 90 | 89 | { |
| 91 | 90 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
| 92 | 91 | } |
@@ -261,8 +260,7 @@ discard block |
||
| 261 | 260 | |
| 262 | 261 | $sError = 'errors.objects.call'; |
| 263 | 262 | $xCallableObject->call($this->xTarget); |
| 264 | - } |
|
| 265 | - catch(ReflectionException|SetupException $e) |
|
| 263 | + } catch(ReflectionException|SetupException $e) |
|
| 266 | 264 | { |
| 267 | 265 | // Unable to execute the requested class or method |
| 268 | 266 | $this->throwException($e->getMessage(), $sError, $aErrorParams); |
@@ -16,12 +16,12 @@ |
||
| 16 | 16 | |
| 17 | 17 | interface MetadataReaderInterface |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * Get the component metadata |
| 21 | 21 | * |
| 22 | 22 | * @param InputData $xInput |
| 23 | 23 | * |
| 24 | 24 | * @return Metadata|null |
| 25 | 25 | */ |
| 26 | - public function getAttributes(InputData $xInput): ?Metadata; |
|
| 26 | +public function getAttributes(InputData $xInput): ?Metadata; |
|
| 27 | 27 | } |
@@ -20,50 +20,50 @@ |
||
| 20 | 20 | |
| 21 | 21 | class InputData |
| 22 | 22 | { |
| 23 | - /** |
|
| 23 | +/** |
|
| 24 | 24 | * @var ReflectionClass |
| 25 | 25 | */ |
| 26 | - private $xReflectionClass; |
|
| 26 | +private $xReflectionClass; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 28 | +/** |
|
| 29 | 29 | * @param ReflectionClass|string $xClass |
| 30 | 30 | * @param array $aMethods |
| 31 | 31 | * @param array $aProperties |
| 32 | 32 | */ |
| 33 | - public function __construct(ReflectionClass|string $xClass, |
|
| 34 | - private array $aMethods = [], private array $aProperties = []) |
|
| 35 | - { |
|
| 36 | - $this->xReflectionClass = is_string($xClass) ? |
|
| 37 | - new ReflectionClass($xClass) : $xClass; |
|
| 38 | - } |
|
| 33 | +public function __construct(ReflectionClass|string $xClass, |
|
| 34 | +private array $aMethods = [], private array $aProperties = []) |
|
| 35 | +{ |
|
| 36 | +$this->xReflectionClass = is_string($xClass) ? |
|
| 37 | +new ReflectionClass($xClass) : $xClass; |
|
| 38 | +} |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * Get the reflection class |
| 42 | 42 | * |
| 43 | 43 | * @return ReflectionClass |
| 44 | 44 | */ |
| 45 | - public function getReflectionClass(): ReflectionClass |
|
| 46 | - { |
|
| 47 | - return $this->xReflectionClass; |
|
| 48 | - } |
|
| 45 | +public function getReflectionClass(): ReflectionClass |
|
| 46 | +{ |
|
| 47 | +return $this->xReflectionClass; |
|
| 48 | +} |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | +/** |
|
| 51 | 51 | * The methods to check for metadata |
| 52 | 52 | * |
| 53 | 53 | * @return array |
| 54 | 54 | */ |
| 55 | - public function getMethods(): array |
|
| 56 | - { |
|
| 57 | - return $this->aMethods; |
|
| 58 | - } |
|
| 55 | +public function getMethods(): array |
|
| 56 | +{ |
|
| 57 | +return $this->aMethods; |
|
| 58 | +} |
|
| 59 | 59 | |
| 60 | - /** |
|
| 60 | +/** |
|
| 61 | 61 | * The properties to check for metadata |
| 62 | 62 | * |
| 63 | 63 | * @return array |
| 64 | 64 | */ |
| 65 | - public function getProperties(): array |
|
| 66 | - { |
|
| 67 | - return $this->aProperties; |
|
| 68 | - } |
|
| 65 | +public function getProperties(): array |
|
| 66 | +{ |
|
| 67 | +return $this->aProperties; |
|
| 68 | +} |
|
| 69 | 69 | } |
@@ -16,42 +16,42 @@ |
||
| 16 | 16 | |
| 17 | 17 | class ExcludeData extends AbstractData |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @var bool |
| 21 | 21 | */ |
| 22 | - private bool $bValue = true; |
|
| 22 | +private bool $bValue = true; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | - public function getName(): string |
|
| 28 | - { |
|
| 29 | - return 'protected'; |
|
| 30 | - } |
|
| 27 | +public function getName(): string |
|
| 28 | +{ |
|
| 29 | +return 'protected'; |
|
| 30 | +} |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * @return mixed |
| 34 | 34 | */ |
| 35 | - public function getValue(): mixed |
|
| 36 | - { |
|
| 37 | - return $this->bValue; |
|
| 38 | - } |
|
| 35 | +public function getValue(): mixed |
|
| 36 | +{ |
|
| 37 | +return $this->bValue; |
|
| 38 | +} |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * @param bool $bValue |
| 42 | 42 | * |
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | - public function setValue(bool $bValue): void |
|
| 46 | - { |
|
| 47 | - $this->bValue = $bValue; |
|
| 48 | - } |
|
| 45 | +public function setValue(bool $bValue): void |
|
| 46 | +{ |
|
| 47 | +$this->bValue = $bValue; |
|
| 48 | +} |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | +/** |
|
| 51 | 51 | * @inheritDoc |
| 52 | 52 | */ |
| 53 | - public function encode(string $sVarName): array |
|
| 54 | - { |
|
| 55 | - return ["{$sVarName}->setValue(" . ($this->bValue ? 'true' : 'false') . ");"]; |
|
| 56 | - } |
|
| 53 | +public function encode(string $sVarName): array |
|
| 54 | +{ |
|
| 55 | +return ["{$sVarName}->setValue(" . ($this->bValue ? 'true' : 'false') . ");"]; |
|
| 56 | +} |
|
| 57 | 57 | } |