@@ -90,7 +90,7 @@ |
||
| 90 | 90 | public function new(string $sBag, string $sKey, $xValue): void |
| 91 | 91 | { |
| 92 | 92 | // Set the value only if it doesn't already exist. |
| 93 | - if(!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag])) |
|
| 93 | + if (!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag])) |
|
| 94 | 94 | { |
| 95 | 95 | $this->set($sBag, $sKey, $xValue); |
| 96 | 96 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | private function initDatabag(): void |
| 36 | 36 | { |
| 37 | - if($this->xDatabag !== null) |
|
| 37 | + if ($this->xDatabag !== null) |
|
| 38 | 38 | { |
| 39 | 39 | return; |
| 40 | 40 | } |
@@ -44,8 +44,7 @@ discard block |
||
| 44 | 44 | $aBody = $xRequest->getParsedBody(); |
| 45 | 45 | $aParams = $xRequest->getQueryParams(); |
| 46 | 46 | $aData = is_array($aBody) ? |
| 47 | - $this->readData($aBody['jxnbags'] ?? []) : |
|
| 48 | - $this->readData($aParams['jxnbags'] ?? []); |
|
| 47 | + $this->readData($aBody['jxnbags'] ?? []) : $this->readData($aParams['jxnbags'] ?? []); |
|
| 49 | 48 | $this->xDatabag = new Databag($this, $aData); |
| 50 | 49 | } |
| 51 | 50 | |
@@ -67,8 +66,7 @@ discard block |
||
| 67 | 66 | // Todo: clean input data. |
| 68 | 67 | // Todo: verify the checksums. |
| 69 | 68 | return is_string($xData) ? |
| 70 | - (json_decode($xData, true) ?: []) : |
|
| 71 | - (is_array($xData) ? $xData : []); |
|
| 69 | + (json_decode($xData, true) ?: []) : (is_array($xData) ? $xData : []); |
|
| 72 | 70 | } |
| 73 | 71 | |
| 74 | 72 | /** |
@@ -86,7 +84,7 @@ discard block |
||
| 86 | 84 | public function writeCommand(): void |
| 87 | 85 | { |
| 88 | 86 | $this->initDatabag(); |
| 89 | - if($this->xDatabag->touched()) |
|
| 87 | + if ($this->xDatabag->touched()) |
|
| 90 | 88 | { |
| 91 | 89 | // Todo: calculate the checksums. |
| 92 | 90 | $this->addCommand('databag.set', ['values' => $this->xDatabag]); |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | use Jaxon\App\Metadata\Metadata; |
| 19 | 19 | use Attribute; |
| 20 | 20 | |
| 21 | -#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] |
|
| 21 | +#[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_METHOD|Attribute::IS_REPEATABLE)] |
|
| 22 | 22 | class Databag extends AbstractAttribute |
| 23 | 23 | { |
| 24 | 24 | /** |
@@ -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 @databag annotation requires a property "name" of type string'); |
| 56 | 56 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function addCall(string $sMethod, array $aParams): void |
| 57 | 57 | { |
| 58 | - if(!$this->validateMethod($sMethod)) |
|
| 58 | + if (!$this->validateMethod($sMethod)) |
|
| 59 | 59 | { |
| 60 | 60 | $sType = $this->getType(); |
| 61 | 61 | throw new SetupException("'$sMethod' is not a valid \"call\" value for $sType."); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | public function encode(string $sVarName): array |
| 70 | 70 | { |
| 71 | 71 | $aCalls = []; |
| 72 | - foreach($this->aCalls as $sMethod => $aParams) |
|
| 72 | + foreach ($this->aCalls as $sMethod => $aParams) |
|
| 73 | 73 | { |
| 74 | 74 | $sParams = addslashes(json_encode($aParams)); |
| 75 | 75 | $aCalls[] = "{$sVarName}->addCall('$sMethod', json_decode(\"$sParams\", true));"; |
@@ -73,8 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function excluded(?string $sMethodName = null): bool |
| 75 | 75 | { |
| 76 | - return $sMethodName === null ? $this->xOptions->excluded() : |
|
| 77 | - !$this->xOptions->isPublicMethod($sMethodName); |
|
| 76 | + return $sMethodName === null ? $this->xOptions->excluded() : !$this->xOptions->isPublicMethod($sMethodName); |
|
| 78 | 77 | } |
| 79 | 78 | |
| 80 | 79 | /** |
@@ -160,11 +159,11 @@ discard block |
||
| 160 | 159 | $sMethod = $this->xTarget->getMethodName(); |
| 161 | 160 | // The hooks defined at method level are merged with those defined at class level. |
| 162 | 161 | $aMethods = array_merge($aHookMethods['*'] ?? [], $aHookMethods[$sMethod] ?? []); |
| 163 | - foreach($aMethods as $xKey => $xValue) |
|
| 162 | + foreach ($aMethods as $xKey => $xValue) |
|
| 164 | 163 | { |
| 165 | 164 | $sHookName = $xValue; |
| 166 | 165 | $aHookArgs = []; |
| 167 | - if(is_string($xKey)) |
|
| 166 | + if (is_string($xKey)) |
|
| 168 | 167 | { |
| 169 | 168 | $sHookName = $xKey; |
| 170 | 169 | $aHookArgs = is_array($xValue) ? $xValue : [$xValue]; |
@@ -202,7 +201,7 @@ discard block |
||
| 202 | 201 | // Warning: dynamic properties will be deprecated in PHP8.2. |
| 203 | 202 | $this->$sAttr = $xDiValue; |
| 204 | 203 | }; |
| 205 | - foreach($aDiOptions as $sAttr => $sClass) |
|
| 204 | + foreach ($aDiOptions as $sAttr => $sClass) |
|
| 206 | 205 | { |
| 207 | 206 | $this->setDiAttribute($xComponent, $sAttr, $this->di->get($sClass), $cSetter); |
| 208 | 207 | } |
@@ -38,9 +38,9 @@ |
||
| 38 | 38 | public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
| 39 | 39 | { |
| 40 | 40 | $aMethods = []; |
| 41 | - foreach(['base', 'only', 'except'] as $key) |
|
| 41 | + foreach (['base', 'only', 'except'] as $key) |
|
| 42 | 42 | { |
| 43 | - if($this->$key !== null && count($this->$key) > 0) |
|
| 43 | + if ($this->$key !== null && count($this->$key) > 0) |
|
| 44 | 44 | { |
| 45 | 45 | $aMethods[$key] = $this->$key; |
| 46 | 46 | } |
@@ -46,9 +46,9 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function initAnnotation(array $properties) |
| 48 | 48 | { |
| 49 | - foreach(['base', 'only', 'except'] as $key) |
|
| 49 | + foreach (['base', 'only', 'except'] as $key) |
|
| 50 | 50 | { |
| 51 | - if(isset($properties[$key]) && is_array($properties[$key]) && |
|
| 51 | + if (isset($properties[$key]) && is_array($properties[$key]) && |
|
| 52 | 52 | count($properties[$key]) > 0) |
| 53 | 53 | { |
| 54 | 54 | $this->aMethods[$key] = $properties[$key]; |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | $aFiles = scandir($this->sCacheDir); |
| 46 | 46 | foreach ($aFiles as $sFile) |
| 47 | 47 | { |
| 48 | - if($sFile !== '.' && $sFile !== '..') |
|
| 48 | + if ($sFile !== '.' && $sFile !== '..') |
|
| 49 | 49 | { |
| 50 | 50 | @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile); |
| 51 | 51 | } |