@@ -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 | } |
@@ -50,11 +50,11 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | public function setMethods(array $aMethods): void |
| 52 | 52 | { |
| 53 | - foreach(['base', 'only', 'except'] as $sKey) |
|
| 53 | + foreach (['base', 'only', 'except'] as $sKey) |
|
| 54 | 54 | { |
| 55 | - foreach($aMethods[$sKey] ?? [] as $sMethod) |
|
| 55 | + foreach ($aMethods[$sKey] ?? [] as $sMethod) |
|
| 56 | 56 | { |
| 57 | - if(!is_string($sMethod) || !$this->validateMethod($sMethod)) |
|
| 57 | + if (!is_string($sMethod) || !$this->validateMethod($sMethod)) |
|
| 58 | 58 | { |
| 59 | 59 | throw new SetupException("'$sMethod' is not a valid method name."); |
| 60 | 60 | } |
@@ -106,18 +106,18 @@ discard block |
||
| 106 | 106 | $sSeparator = $aOptions['separator'] ?? '.'; |
| 107 | 107 | $this->sSeparator = $sSeparator === '_' ? '_' : '.'; |
| 108 | 108 | $this->addProtectedMethods($aOptions['protected'] ?? []); |
| 109 | - foreach($aOptions['functions'] ?? [] as $sNames => $aFunctionOptions) |
|
| 109 | + foreach ($aOptions['functions'] ?? [] as $sNames => $aFunctionOptions) |
|
| 110 | 110 | { |
| 111 | 111 | // Names are in a comma-separated list. |
| 112 | 112 | $aFunctionNames = explode(',', $sNames); |
| 113 | - foreach($aFunctionNames as $sFunctionName) |
|
| 113 | + foreach ($aFunctionNames as $sFunctionName) |
|
| 114 | 114 | { |
| 115 | 115 | $this->addFunctionOptions($sFunctionName, $aFunctionOptions); |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Options from the attributes or annotations. |
| 120 | - if($xMetadata !== null) |
|
| 120 | + if ($xMetadata !== null) |
|
| 121 | 121 | { |
| 122 | 122 | $this->readMetadataOptions($xMetadata); |
| 123 | 123 | } |
@@ -133,8 +133,7 @@ discard block |
||
| 133 | 133 | private function addProtectedMethods(array|string $xMethods): void |
| 134 | 134 | { |
| 135 | 135 | $this->aExportMethods['except'] = array_merge($this->aExportMethods['except'], |
| 136 | - !is_array($xMethods) ? [trim((string)$xMethods)] : |
|
| 137 | - array_map(fn($sMethod) => trim((string)$sMethod), $xMethods)); |
|
| 136 | + !is_array($xMethods) ? [trim((string)$xMethods)] : array_map(fn($sMethod) => trim((string)$sMethod), $xMethods)); |
|
| 138 | 137 | } |
| 139 | 138 | |
| 140 | 139 | /** |
@@ -149,7 +148,7 @@ discard block |
||
| 149 | 148 | $aExportMethods['except'] = array_unique(array_merge( |
| 150 | 149 | $aExportMethods['except'] ?? [], $this->aExportMethods['except'])); |
| 151 | 150 | $this->aExportMethods = $aExportMethods; |
| 152 | - foreach($xMetadata->getProperties() as $sFunctionName => $aFunctionOptions) |
|
| 151 | + foreach ($xMetadata->getProperties() as $sFunctionName => $aFunctionOptions) |
|
| 153 | 152 | { |
| 154 | 153 | $this->addFunctionOptions($sFunctionName, $aFunctionOptions); |
| 155 | 154 | } |
@@ -162,7 +161,7 @@ discard block |
||
| 162 | 161 | */ |
| 163 | 162 | private function filterPublicMethods(array $aMethods): array |
| 164 | 163 | { |
| 165 | - if($this->bExcluded || in_array('*', $this->aExportMethods['except'])) |
|
| 164 | + if ($this->bExcluded || in_array('*', $this->aExportMethods['except'])) |
|
| 166 | 165 | { |
| 167 | 166 | return []; |
| 168 | 167 | } |
@@ -170,12 +169,12 @@ discard block |
||
| 170 | 169 | $aBaseMethods = $aMethods[1]; |
| 171 | 170 | $aNoMethods = $aMethods[2]; |
| 172 | 171 | $aMethods = $aMethods[0]; |
| 173 | - if(isset($this->aExportMethods['only'])) |
|
| 172 | + if (isset($this->aExportMethods['only'])) |
|
| 174 | 173 | { |
| 175 | 174 | $aMethods = array_intersect($aMethods, $this->aExportMethods['only']); |
| 176 | 175 | } |
| 177 | 176 | $aMethods = array_diff($aMethods, $this->aExportMethods['except']); |
| 178 | - if(count($aBaseMethods) > 0 && isset($this->aExportMethods['base'])) |
|
| 177 | + if (count($aBaseMethods) > 0 && isset($this->aExportMethods['base'])) |
|
| 179 | 178 | { |
| 180 | 179 | $aBaseMethods = array_diff($aBaseMethods, $this->aExportMethods['base']); |
| 181 | 180 | } |
@@ -261,19 +260,19 @@ discard block |
||
| 261 | 260 | */ |
| 262 | 261 | private function setHookMethods(array &$aHookMethods, $xValue): void |
| 263 | 262 | { |
| 264 | - foreach($xValue as $sCalledMethod => $xMethodToCall) |
|
| 263 | + foreach ($xValue as $sCalledMethod => $xMethodToCall) |
|
| 265 | 264 | { |
| 266 | - if(!isset($aHookMethods[$sCalledMethod])) |
|
| 265 | + if (!isset($aHookMethods[$sCalledMethod])) |
|
| 267 | 266 | { |
| 268 | 267 | $aHookMethods[$sCalledMethod] = []; |
| 269 | 268 | } |
| 270 | - if(is_array($xMethodToCall)) |
|
| 269 | + if (is_array($xMethodToCall)) |
|
| 271 | 270 | { |
| 272 | 271 | $aHookMethods[$sCalledMethod] = |
| 273 | 272 | array_merge($aHookMethods[$sCalledMethod], $xMethodToCall); |
| 274 | 273 | continue; |
| 275 | 274 | } |
| 276 | - if(is_string($xMethodToCall)) |
|
| 275 | + if (is_string($xMethodToCall)) |
|
| 277 | 276 | { |
| 278 | 277 | $aHookMethods[$sCalledMethod][] = $xMethodToCall; |
| 279 | 278 | } |
@@ -298,7 +297,7 @@ discard block |
||
| 298 | 297 | */ |
| 299 | 298 | private function addOption(string $sName, $xValue): void |
| 300 | 299 | { |
| 301 | - switch($sName) |
|
| 300 | + switch ($sName) |
|
| 302 | 301 | { |
| 303 | 302 | // Set the methods to call before processing the request |
| 304 | 303 | case '__before': |
@@ -326,11 +325,11 @@ discard block |
||
| 326 | 325 | */ |
| 327 | 326 | private function _addJsArrayOption(string $sFunctionName, string $sOptionName, $xOptionValue): void |
| 328 | 327 | { |
| 329 | - if(is_string($xOptionValue)) |
|
| 328 | + if (is_string($xOptionValue)) |
|
| 330 | 329 | { |
| 331 | 330 | $xOptionValue = [$xOptionValue]; |
| 332 | 331 | } |
| 333 | - if(!is_array($xOptionValue)) |
|
| 332 | + if (!is_array($xOptionValue)) |
|
| 334 | 333 | { |
| 335 | 334 | return; // Do not save. |
| 336 | 335 | } |
@@ -360,10 +359,10 @@ discard block |
||
| 360 | 359 | */ |
| 361 | 360 | private function addJsOption(string $sFunctionName, string $sOptionName, $xOptionValue): void |
| 362 | 361 | { |
| 363 | - switch($sOptionName) |
|
| 362 | + switch ($sOptionName) |
|
| 364 | 363 | { |
| 365 | 364 | case 'excluded': |
| 366 | - if((bool)$xOptionValue) |
|
| 365 | + if ((bool)$xOptionValue) |
|
| 367 | 366 | { |
| 368 | 367 | $this->addProtectedMethods($sFunctionName); |
| 369 | 368 | } |
@@ -387,12 +386,11 @@ discard block |
||
| 387 | 386 | */ |
| 388 | 387 | private function addFunctionOptions(string $sFunctionName, array $aFunctionOptions): void |
| 389 | 388 | { |
| 390 | - foreach($aFunctionOptions as $sOptionName => $xOptionValue) |
|
| 389 | + foreach ($aFunctionOptions as $sOptionName => $xOptionValue) |
|
| 391 | 390 | { |
| 392 | 391 | substr($sOptionName, 0, 2) === '__' ? |
| 393 | 392 | // Options for PHP classes. They start with "__". |
| 394 | - $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : |
|
| 395 | - // Options for javascript code. |
|
| 393 | + $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : // Options for javascript code. |
|
| 396 | 394 | $this->addJsOption($sFunctionName, $sOptionName, $xOptionValue); |
| 397 | 395 | } |
| 398 | 396 | } |
@@ -408,16 +406,15 @@ discard block |
||
| 408 | 406 | $aOptions = array_merge($this->aJsOptions['*'] ?? []); // Clone the array |
| 409 | 407 | // Then add the method options. |
| 410 | 408 | $aMethodOptions = $this->aJsOptions[$sMethodName] ?? []; |
| 411 | - foreach($aMethodOptions as $sOptionName => $xOptionValue) |
|
| 409 | + foreach ($aMethodOptions as $sOptionName => $xOptionValue) |
|
| 412 | 410 | { |
| 413 | 411 | // For databags and callbacks, merge the values in a single array. |
| 414 | 412 | // For all the other options, keep the last value. |
| 415 | 413 | $aOptions[$sOptionName] = !in_array($sOptionName, ['bags', 'callback']) ? |
| 416 | - $xOptionValue : |
|
| 417 | - array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue)); |
|
| 414 | + $xOptionValue : array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue)); |
|
| 418 | 415 | } |
| 419 | 416 | // Since callbacks are js object names, they need a special formatting. |
| 420 | - if(isset($aOptions['callback'])) |
|
| 417 | + if (isset($aOptions['callback'])) |
|
| 421 | 418 | { |
| 422 | 419 | $aOptions['callback'] = str_replace('"', '', json_encode($aOptions['callback'])); |
| 423 | 420 | } |
@@ -34,224 +34,224 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | class ComponentOptions |
| 36 | 36 | { |
| 37 | - /** |
|
| 37 | +/** |
|
| 38 | 38 | * Check if the js code for this object must be generated |
| 39 | 39 | * |
| 40 | 40 | * @var bool |
| 41 | 41 | */ |
| 42 | - private $bExcluded = false; |
|
| 42 | +private $bExcluded = false; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 44 | +/** |
|
| 45 | 45 | * The character to use as separator in javascript class names |
| 46 | 46 | * |
| 47 | 47 | * @var string |
| 48 | 48 | */ |
| 49 | - private $sSeparator = '.'; |
|
| 49 | +private $sSeparator = '.'; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 51 | +/** |
|
| 52 | 52 | * A list of methods of the user registered callable object the library can export to javascript |
| 53 | 53 | * |
| 54 | 54 | * @var array |
| 55 | 55 | */ |
| 56 | - private $aPublicMethods = []; |
|
| 56 | +private $aPublicMethods = []; |
|
| 57 | 57 | |
| 58 | - /** |
|
| 58 | +/** |
|
| 59 | 59 | * The methods in the export attributes |
| 60 | 60 | * |
| 61 | 61 | * @var array |
| 62 | 62 | */ |
| 63 | - private $aExportMethods = ['except' => []]; |
|
| 63 | +private $aExportMethods = ['except' => []]; |
|
| 64 | 64 | |
| 65 | - /** |
|
| 65 | +/** |
|
| 66 | 66 | * A list of methods to call before processing the request |
| 67 | 67 | * |
| 68 | 68 | * @var array |
| 69 | 69 | */ |
| 70 | - private $aBeforeMethods = []; |
|
| 70 | +private $aBeforeMethods = []; |
|
| 71 | 71 | |
| 72 | - /** |
|
| 72 | +/** |
|
| 73 | 73 | * A list of methods to call after processing the request |
| 74 | 74 | * |
| 75 | 75 | * @var array |
| 76 | 76 | */ |
| 77 | - private $aAfterMethods = []; |
|
| 77 | +private $aAfterMethods = []; |
|
| 78 | 78 | |
| 79 | - /** |
|
| 79 | +/** |
|
| 80 | 80 | * The javascript class options |
| 81 | 81 | * |
| 82 | 82 | * @var array |
| 83 | 83 | */ |
| 84 | - private $aJsOptions = []; |
|
| 84 | +private $aJsOptions = []; |
|
| 85 | 85 | |
| 86 | - /** |
|
| 86 | +/** |
|
| 87 | 87 | * The DI options |
| 88 | 88 | * |
| 89 | 89 | * @var array |
| 90 | 90 | */ |
| 91 | - private $aDiOptions = []; |
|
| 91 | +private $aDiOptions = []; |
|
| 92 | 92 | |
| 93 | - /** |
|
| 93 | +/** |
|
| 94 | 94 | * The constructor |
| 95 | 95 | * |
| 96 | 96 | * @param array $aMethods |
| 97 | 97 | * @param array $aOptions |
| 98 | 98 | * @param Metadata|null $xMetadata |
| 99 | 99 | */ |
| 100 | - public function __construct(array $aMethods, array $aOptions, Metadata|null $xMetadata) |
|
| 101 | - { |
|
| 102 | - $this->bExcluded = ($xMetadata?->isExcluded() ?? false) || |
|
| 103 | - (bool)($aOptions['excluded'] ?? false); |
|
| 104 | - |
|
| 105 | - // Options from the config. |
|
| 106 | - $sSeparator = $aOptions['separator'] ?? '.'; |
|
| 107 | - $this->sSeparator = $sSeparator === '_' ? '_' : '.'; |
|
| 108 | - $this->addProtectedMethods($aOptions['protected'] ?? []); |
|
| 109 | - foreach($aOptions['functions'] ?? [] as $sNames => $aFunctionOptions) |
|
| 110 | - { |
|
| 111 | - // Names are in a comma-separated list. |
|
| 112 | - $aFunctionNames = explode(',', $sNames); |
|
| 113 | - foreach($aFunctionNames as $sFunctionName) |
|
| 114 | - { |
|
| 115 | - $this->addFunctionOptions($sFunctionName, $aFunctionOptions); |
|
| 116 | - } |
|
| 117 | - } |
|
| 100 | +public function __construct(array $aMethods, array $aOptions, Metadata|null $xMetadata) |
|
| 101 | +{ |
|
| 102 | +$this->bExcluded = ($xMetadata?->isExcluded() ?? false) || |
|
| 103 | +(bool)($aOptions['excluded'] ?? false); |
|
| 104 | + |
|
| 105 | +// Options from the config. |
|
| 106 | +$sSeparator = $aOptions['separator'] ?? '.'; |
|
| 107 | +$this->sSeparator = $sSeparator === '_' ? '_' : '.'; |
|
| 108 | +$this->addProtectedMethods($aOptions['protected'] ?? []); |
|
| 109 | +foreach($aOptions['functions'] ?? [] as $sNames => $aFunctionOptions) |
|
| 110 | +{ |
|
| 111 | +// Names are in a comma-separated list. |
|
| 112 | +$aFunctionNames = explode(',', $sNames); |
|
| 113 | +foreach($aFunctionNames as $sFunctionName) |
|
| 114 | +{ |
|
| 115 | + $this->addFunctionOptions($sFunctionName, $aFunctionOptions); |
|
| 116 | +} |
|
| 117 | +} |
|
| 118 | 118 | |
| 119 | - // Options from the attributes or annotations. |
|
| 120 | - if($xMetadata !== null) |
|
| 121 | - { |
|
| 122 | - $this->readMetadataOptions($xMetadata); |
|
| 123 | - } |
|
| 119 | +// Options from the attributes or annotations. |
|
| 120 | +if($xMetadata !== null) |
|
| 121 | +{ |
|
| 122 | +$this->readMetadataOptions($xMetadata); |
|
| 123 | +} |
|
| 124 | 124 | |
| 125 | - $this->aPublicMethods = $this->filterPublicMethods($aMethods); |
|
| 126 | - } |
|
| 125 | +$this->aPublicMethods = $this->filterPublicMethods($aMethods); |
|
| 126 | +} |
|
| 127 | 127 | |
| 128 | - /** |
|
| 128 | +/** |
|
| 129 | 129 | * @param array|string $xMethods |
| 130 | 130 | * |
| 131 | 131 | * @return void |
| 132 | 132 | */ |
| 133 | - private function addProtectedMethods(array|string $xMethods): void |
|
| 134 | - { |
|
| 135 | - $this->aExportMethods['except'] = array_merge($this->aExportMethods['except'], |
|
| 136 | - !is_array($xMethods) ? [trim((string)$xMethods)] : |
|
| 137 | - array_map(fn($sMethod) => trim((string)$sMethod), $xMethods)); |
|
| 138 | - } |
|
| 133 | +private function addProtectedMethods(array|string $xMethods): void |
|
| 134 | +{ |
|
| 135 | +$this->aExportMethods['except'] = array_merge($this->aExportMethods['except'], |
|
| 136 | +!is_array($xMethods) ? [trim((string)$xMethods)] : |
|
| 137 | +array_map(fn($sMethod) => trim((string)$sMethod), $xMethods)); |
|
| 138 | +} |
|
| 139 | 139 | |
| 140 | - /** |
|
| 140 | +/** |
|
| 141 | 141 | * @param Metadata $xMetadata |
| 142 | 142 | * |
| 143 | 143 | * @return void |
| 144 | 144 | */ |
| 145 | - private function readMetadataOptions(Metadata $xMetadata): void |
|
| 146 | - { |
|
| 147 | - // Excluded methods must be merged with the existing ones. |
|
| 148 | - $aExportMethods = $xMetadata->getExportMethods(); |
|
| 149 | - $aExportMethods['except'] = array_unique(array_merge( |
|
| 150 | - $aExportMethods['except'] ?? [], $this->aExportMethods['except'])); |
|
| 151 | - $this->aExportMethods = $aExportMethods; |
|
| 152 | - foreach($xMetadata->getProperties() as $sFunctionName => $aFunctionOptions) |
|
| 153 | - { |
|
| 154 | - $this->addFunctionOptions($sFunctionName, $aFunctionOptions); |
|
| 155 | - } |
|
| 156 | - } |
|
| 145 | +private function readMetadataOptions(Metadata $xMetadata): void |
|
| 146 | +{ |
|
| 147 | +// Excluded methods must be merged with the existing ones. |
|
| 148 | +$aExportMethods = $xMetadata->getExportMethods(); |
|
| 149 | +$aExportMethods['except'] = array_unique(array_merge( |
|
| 150 | +$aExportMethods['except'] ?? [], $this->aExportMethods['except'])); |
|
| 151 | +$this->aExportMethods = $aExportMethods; |
|
| 152 | +foreach($xMetadata->getProperties() as $sFunctionName => $aFunctionOptions) |
|
| 153 | +{ |
|
| 154 | +$this->addFunctionOptions($sFunctionName, $aFunctionOptions); |
|
| 155 | +} |
|
| 156 | +} |
|
| 157 | 157 | |
| 158 | - /** |
|
| 158 | +/** |
|
| 159 | 159 | * @param array $aMethods |
| 160 | 160 | * |
| 161 | 161 | * @return array |
| 162 | 162 | */ |
| 163 | - private function filterPublicMethods(array $aMethods): array |
|
| 164 | - { |
|
| 165 | - if($this->bExcluded || in_array('*', $this->aExportMethods['except'])) |
|
| 166 | - { |
|
| 167 | - return []; |
|
| 168 | - } |
|
| 163 | +private function filterPublicMethods(array $aMethods): array |
|
| 164 | +{ |
|
| 165 | +if($this->bExcluded || in_array('*', $this->aExportMethods['except'])) |
|
| 166 | +{ |
|
| 167 | +return []; |
|
| 168 | +} |
|
| 169 | 169 | |
| 170 | - $aBaseMethods = $aMethods[1]; |
|
| 171 | - $aNoMethods = $aMethods[2]; |
|
| 172 | - $aMethods = $aMethods[0]; |
|
| 173 | - if(isset($this->aExportMethods['only'])) |
|
| 174 | - { |
|
| 175 | - $aMethods = array_intersect($aMethods, $this->aExportMethods['only']); |
|
| 176 | - } |
|
| 177 | - $aMethods = array_diff($aMethods, $this->aExportMethods['except']); |
|
| 178 | - if(count($aBaseMethods) > 0 && isset($this->aExportMethods['base'])) |
|
| 179 | - { |
|
| 180 | - $aBaseMethods = array_diff($aBaseMethods, $this->aExportMethods['base']); |
|
| 181 | - } |
|
| 170 | +$aBaseMethods = $aMethods[1]; |
|
| 171 | +$aNoMethods = $aMethods[2]; |
|
| 172 | +$aMethods = $aMethods[0]; |
|
| 173 | +if(isset($this->aExportMethods['only'])) |
|
| 174 | +{ |
|
| 175 | +$aMethods = array_intersect($aMethods, $this->aExportMethods['only']); |
|
| 176 | +} |
|
| 177 | +$aMethods = array_diff($aMethods, $this->aExportMethods['except']); |
|
| 178 | +if(count($aBaseMethods) > 0 && isset($this->aExportMethods['base'])) |
|
| 179 | +{ |
|
| 180 | +$aBaseMethods = array_diff($aBaseMethods, $this->aExportMethods['base']); |
|
| 181 | +} |
|
| 182 | 182 | |
| 183 | - return array_values(array_diff($aMethods, $aBaseMethods, $aNoMethods)); |
|
| 184 | - } |
|
| 183 | +return array_values(array_diff($aMethods, $aBaseMethods, $aNoMethods)); |
|
| 184 | +} |
|
| 185 | 185 | |
| 186 | - /** |
|
| 186 | +/** |
|
| 187 | 187 | * @return array |
| 188 | 188 | */ |
| 189 | - public function getPublicMethods(): array |
|
| 190 | - { |
|
| 191 | - return $this->aPublicMethods; |
|
| 192 | - } |
|
| 189 | +public function getPublicMethods(): array |
|
| 190 | +{ |
|
| 191 | +return $this->aPublicMethods; |
|
| 192 | +} |
|
| 193 | 193 | |
| 194 | - /** |
|
| 194 | +/** |
|
| 195 | 195 | * @param string $sMethodName |
| 196 | 196 | * |
| 197 | 197 | * @return bool |
| 198 | 198 | */ |
| 199 | - public function isPublicMethod(string $sMethodName): bool |
|
| 200 | - { |
|
| 201 | - return in_array($sMethodName, $this->aPublicMethods); |
|
| 202 | - } |
|
| 199 | +public function isPublicMethod(string $sMethodName): bool |
|
| 200 | +{ |
|
| 201 | +return in_array($sMethodName, $this->aPublicMethods); |
|
| 202 | +} |
|
| 203 | 203 | |
| 204 | - /** |
|
| 204 | +/** |
|
| 205 | 205 | * Check if the js code for this object must be generated |
| 206 | 206 | * |
| 207 | 207 | * @return bool |
| 208 | 208 | */ |
| 209 | - public function excluded(): bool |
|
| 210 | - { |
|
| 211 | - return $this->bExcluded; |
|
| 212 | - } |
|
| 209 | +public function excluded(): bool |
|
| 210 | +{ |
|
| 211 | +return $this->bExcluded; |
|
| 212 | +} |
|
| 213 | 213 | |
| 214 | - /** |
|
| 214 | +/** |
|
| 215 | 215 | * @return string |
| 216 | 216 | */ |
| 217 | - public function separator(): string |
|
| 218 | - { |
|
| 219 | - return $this->sSeparator; |
|
| 220 | - } |
|
| 217 | +public function separator(): string |
|
| 218 | +{ |
|
| 219 | +return $this->sSeparator; |
|
| 220 | +} |
|
| 221 | 221 | |
| 222 | - /** |
|
| 222 | +/** |
|
| 223 | 223 | * @return array |
| 224 | 224 | */ |
| 225 | - public function beforeMethods(): array |
|
| 226 | - { |
|
| 227 | - return $this->aBeforeMethods; |
|
| 228 | - } |
|
| 225 | +public function beforeMethods(): array |
|
| 226 | +{ |
|
| 227 | +return $this->aBeforeMethods; |
|
| 228 | +} |
|
| 229 | 229 | |
| 230 | - /** |
|
| 230 | +/** |
|
| 231 | 231 | * @return array |
| 232 | 232 | */ |
| 233 | - public function afterMethods(): array |
|
| 234 | - { |
|
| 235 | - return $this->aAfterMethods; |
|
| 236 | - } |
|
| 233 | +public function afterMethods(): array |
|
| 234 | +{ |
|
| 235 | +return $this->aAfterMethods; |
|
| 236 | +} |
|
| 237 | 237 | |
| 238 | - /** |
|
| 238 | +/** |
|
| 239 | 239 | * @return array |
| 240 | 240 | */ |
| 241 | - public function diOptions(): array |
|
| 242 | - { |
|
| 243 | - return $this->aDiOptions; |
|
| 244 | - } |
|
| 241 | +public function diOptions(): array |
|
| 242 | +{ |
|
| 243 | +return $this->aDiOptions; |
|
| 244 | +} |
|
| 245 | 245 | |
| 246 | - /** |
|
| 246 | +/** |
|
| 247 | 247 | * @return array |
| 248 | 248 | */ |
| 249 | - public function jsOptions(): array |
|
| 250 | - { |
|
| 251 | - return $this->aJsOptions; |
|
| 252 | - } |
|
| 249 | +public function jsOptions(): array |
|
| 250 | +{ |
|
| 251 | +return $this->aJsOptions; |
|
| 252 | +} |
|
| 253 | 253 | |
| 254 | - /** |
|
| 254 | +/** |
|
| 255 | 255 | * Set hook methods |
| 256 | 256 | * |
| 257 | 257 | * @param array $aHookMethods The array of hook methods |
@@ -259,36 +259,36 @@ discard block |
||
| 259 | 259 | * |
| 260 | 260 | * @return void |
| 261 | 261 | */ |
| 262 | - private function setHookMethods(array &$aHookMethods, $xValue): void |
|
| 263 | - { |
|
| 264 | - foreach($xValue as $sCalledMethod => $xMethodToCall) |
|
| 265 | - { |
|
| 266 | - if(!isset($aHookMethods[$sCalledMethod])) |
|
| 267 | - { |
|
| 268 | - $aHookMethods[$sCalledMethod] = []; |
|
| 269 | - } |
|
| 270 | - if(is_array($xMethodToCall)) |
|
| 271 | - { |
|
| 272 | - $aHookMethods[$sCalledMethod] = |
|
| 273 | - array_merge($aHookMethods[$sCalledMethod], $xMethodToCall); |
|
| 274 | - continue; |
|
| 275 | - } |
|
| 276 | - if(is_string($xMethodToCall)) |
|
| 277 | - { |
|
| 278 | - $aHookMethods[$sCalledMethod][] = $xMethodToCall; |
|
| 279 | - } |
|
| 280 | - } |
|
| 281 | - } |
|
| 262 | +private function setHookMethods(array &$aHookMethods, $xValue): void |
|
| 263 | +{ |
|
| 264 | +foreach($xValue as $sCalledMethod => $xMethodToCall) |
|
| 265 | +{ |
|
| 266 | +if(!isset($aHookMethods[$sCalledMethod])) |
|
| 267 | +{ |
|
| 268 | + $aHookMethods[$sCalledMethod] = []; |
|
| 269 | +} |
|
| 270 | +if(is_array($xMethodToCall)) |
|
| 271 | +{ |
|
| 272 | + $aHookMethods[$sCalledMethod] = |
|
| 273 | + array_merge($aHookMethods[$sCalledMethod], $xMethodToCall); |
|
| 274 | + continue; |
|
| 275 | +} |
|
| 276 | +if(is_string($xMethodToCall)) |
|
| 277 | +{ |
|
| 278 | + $aHookMethods[$sCalledMethod][] = $xMethodToCall; |
|
| 279 | +} |
|
| 280 | +} |
|
| 281 | +} |
|
| 282 | 282 | |
| 283 | - /** |
|
| 283 | +/** |
|
| 284 | 284 | * @param array $aDiOptions |
| 285 | 285 | */ |
| 286 | - private function addDiOption(array $aDiOptions): void |
|
| 287 | - { |
|
| 288 | - $this->aDiOptions = array_merge($this->aDiOptions, $aDiOptions); |
|
| 289 | - } |
|
| 286 | +private function addDiOption(array $aDiOptions): void |
|
| 287 | +{ |
|
| 288 | +$this->aDiOptions = array_merge($this->aDiOptions, $aDiOptions); |
|
| 289 | +} |
|
| 290 | 290 | |
| 291 | - /** |
|
| 291 | +/** |
|
| 292 | 292 | * Set configuration options / call options for each method |
| 293 | 293 | * |
| 294 | 294 | * @param string $sName The name of the configuration option |
@@ -296,25 +296,25 @@ discard block |
||
| 296 | 296 | * |
| 297 | 297 | * @return void |
| 298 | 298 | */ |
| 299 | - private function addOption(string $sName, $xValue): void |
|
| 300 | - { |
|
| 301 | - switch($sName) |
|
| 302 | - { |
|
| 303 | - // Set the methods to call before processing the request |
|
| 304 | - case '__before': |
|
| 305 | - $this->setHookMethods($this->aBeforeMethods, $xValue); |
|
| 306 | - break; |
|
| 307 | - // Set the methods to call after processing the request |
|
| 308 | - case '__after': |
|
| 309 | - $this->setHookMethods($this->aAfterMethods, $xValue); |
|
| 310 | - break; |
|
| 311 | - // Set the attributes to inject in the callable object |
|
| 312 | - case '__di': |
|
| 313 | - $this->addDiOption($xValue); |
|
| 314 | - break; |
|
| 315 | - default: |
|
| 316 | - break; |
|
| 317 | - } |
|
| 299 | +private function addOption(string $sName, $xValue): void |
|
| 300 | +{ |
|
| 301 | +switch($sName) |
|
| 302 | +{ |
|
| 303 | +// Set the methods to call before processing the request |
|
| 304 | +case '__before': |
|
| 305 | +$this->setHookMethods($this->aBeforeMethods, $xValue); |
|
| 306 | +break; |
|
| 307 | +// Set the methods to call after processing the request |
|
| 308 | +case '__after': |
|
| 309 | +$this->setHookMethods($this->aAfterMethods, $xValue); |
|
| 310 | +break; |
|
| 311 | +// Set the attributes to inject in the callable object |
|
| 312 | +case '__di': |
|
| 313 | +$this->addDiOption($xValue); |
|
| 314 | +break; |
|
| 315 | +default: |
|
| 316 | +break; |
|
| 317 | +} |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | use function ltrim; |
| 23 | 23 | |
| 24 | -#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PROPERTY | |
|
| 25 | - Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] |
|
| 24 | +#[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_PROPERTY| |
|
| 25 | + Attribute::TARGET_METHOD|Attribute::IS_REPEATABLE)] |
|
| 26 | 26 | class Inject extends AbstractAttribute |
| 27 | 27 | { |
| 28 | 28 | /** |
@@ -78,17 +78,17 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function validate(): void |
| 80 | 80 | { |
| 81 | - if($this->nTarget === Attribute::TARGET_CLASS) |
|
| 81 | + if ($this->nTarget === Attribute::TARGET_CLASS) |
|
| 82 | 82 | { |
| 83 | - if(!$this->attr || !$this->type) |
|
| 83 | + if (!$this->attr || !$this->type) |
|
| 84 | 84 | { |
| 85 | 85 | throw new SetupException('When applied to a class, the Inject attribute requires two arguments.'); |
| 86 | 86 | } |
| 87 | 87 | return; |
| 88 | 88 | } |
| 89 | - if($this->nTarget === Attribute::TARGET_METHOD) |
|
| 89 | + if ($this->nTarget === Attribute::TARGET_METHOD) |
|
| 90 | 90 | { |
| 91 | - if(!$this->attr) |
|
| 91 | + if (!$this->attr) |
|
| 92 | 92 | { |
| 93 | 93 | throw new SetupException('When applied to a method, the Inject attribute requires the "attr" argument.'); |
| 94 | 94 | } |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | private function getFullClassName(): void |
| 102 | 102 | { |
| 103 | - if(!$this->type) |
|
| 103 | + if (!$this->type) |
|
| 104 | 104 | { |
| 105 | 105 | // If no type is provided, take the attribute type. |
| 106 | 106 | $this->type = $this->aTypes[$this->attr] ?? ''; |
| 107 | 107 | return; |
| 108 | 108 | } |
| 109 | - if($this->type[0] === '\\') |
|
| 109 | + if ($this->type[0] === '\\') |
|
| 110 | 110 | { |
| 111 | 111 | $this->type = ltrim($this->type, '\\'); |
| 112 | 112 | } |
@@ -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 | } |
@@ -241,83 +241,83 @@ |
||
| 241 | 241 | $this->aComponentPublicMethods['node'], |
| 242 | 242 | $xReflectionClass->isSubclassOf(FuncComponent::class) => |
| 243 | 243 | $this->aComponentPublicMethods['func'], |
| 244 | - default => [[], []], |
|
| 245 | - }; |
|
| 244 | +default => [[], []], |
|
| 245 | +}; |
|
| 246 | 246 | |
| 247 | - return [$aMethods, ...$aBaseMethods]; |
|
| 248 | - } |
|
| 247 | +return [$aMethods, ...$aBaseMethods]; |
|
| 248 | +} |
|
| 249 | 249 | |
| 250 | - /** |
|
| 250 | +/** |
|
| 251 | 251 | * @param ReflectionClass $xReflectionClass |
| 252 | 252 | * @param array $aMethods |
| 253 | 253 | * @param array $aOptions |
| 254 | 254 | * |
| 255 | 255 | * @return Metadata|null |
| 256 | 256 | */ |
| 257 | - private function getComponentMetadata(ReflectionClass $xReflectionClass, |
|
| 258 | - array $aMethods, array $aOptions): Metadata|null |
|
| 259 | - { |
|
| 260 | - /** @var Config|null */ |
|
| 261 | - $xPackageConfig = $aOptions['config'] ?? null; |
|
| 262 | - if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 263 | - { |
|
| 264 | - return null; |
|
| 265 | - } |
|
| 266 | - $sMetadataFormat = $xPackageConfig->getOption('metadata.format'); |
|
| 267 | - if(!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 268 | - { |
|
| 269 | - return null; |
|
| 270 | - } |
|
| 257 | +private function getComponentMetadata(ReflectionClass $xReflectionClass, |
|
| 258 | +array $aMethods, array $aOptions): Metadata|null |
|
| 259 | +{ |
|
| 260 | +/** @var Config|null */ |
|
| 261 | +$xPackageConfig = $aOptions['config'] ?? null; |
|
| 262 | +if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 263 | +{ |
|
| 264 | +return null; |
|
| 265 | +} |
|
| 266 | +$sMetadataFormat = $xPackageConfig->getOption('metadata.format'); |
|
| 267 | +if(!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 268 | +{ |
|
| 269 | +return null; |
|
| 270 | +} |
|
| 271 | 271 | |
| 272 | - // Try to get the class metadata from the cache. |
|
| 273 | - $di = $this->cn(); |
|
| 274 | - $xMetadata = null; |
|
| 275 | - $xMetadataCache = null; |
|
| 276 | - $xConfig = $di->config(); |
|
| 277 | - if($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 278 | - { |
|
| 279 | - if(!$di->h('jaxon_metadata_cache_dir')) |
|
| 280 | - { |
|
| 281 | - $sCacheDir = $xConfig->getAppOption('metadata.cache.dir'); |
|
| 282 | - $di->val('jaxon_metadata_cache_dir', $sCacheDir); |
|
| 283 | - } |
|
| 284 | - $xMetadataCache = $di->getMetadataCache(); |
|
| 285 | - $xMetadata = $xMetadataCache->read($xReflectionClass->getName()); |
|
| 286 | - if($xMetadata !== null) |
|
| 287 | - { |
|
| 288 | - return $xMetadata; |
|
| 289 | - } |
|
| 290 | - } |
|
| 272 | +// Try to get the class metadata from the cache. |
|
| 273 | +$di = $this->cn(); |
|
| 274 | +$xMetadata = null; |
|
| 275 | +$xMetadataCache = null; |
|
| 276 | +$xConfig = $di->config(); |
|
| 277 | +if($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 278 | +{ |
|
| 279 | +if(!$di->h('jaxon_metadata_cache_dir')) |
|
| 280 | +{ |
|
| 281 | + $sCacheDir = $xConfig->getAppOption('metadata.cache.dir'); |
|
| 282 | + $di->val('jaxon_metadata_cache_dir', $sCacheDir); |
|
| 283 | +} |
|
| 284 | +$xMetadataCache = $di->getMetadataCache(); |
|
| 285 | +$xMetadata = $xMetadataCache->read($xReflectionClass->getName()); |
|
| 286 | +if($xMetadata !== null) |
|
| 287 | +{ |
|
| 288 | + return $xMetadata; |
|
| 289 | +} |
|
| 290 | +} |
|
| 291 | 291 | |
| 292 | - $aProperties = array_map(fn($xProperty) => $xProperty->getName(), |
|
| 293 | - $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC | |
|
| 294 | - ReflectionProperty::IS_PROTECTED)); |
|
| 292 | +$aProperties = array_map(fn($xProperty) => $xProperty->getName(), |
|
| 293 | +$xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC | |
|
| 294 | + ReflectionProperty::IS_PROTECTED)); |
|
| 295 | 295 | |
| 296 | - $xMetadataReader = $di->getMetadataReader($sMetadataFormat); |
|
| 297 | - $xInput = new InputData($xReflectionClass, $aMethods, $aProperties); |
|
| 298 | - $xMetadata = $xMetadataReader->getAttributes($xInput); |
|
| 296 | +$xMetadataReader = $di->getMetadataReader($sMetadataFormat); |
|
| 297 | +$xInput = new InputData($xReflectionClass, $aMethods, $aProperties); |
|
| 298 | +$xMetadata = $xMetadataReader->getAttributes($xInput); |
|
| 299 | 299 | |
| 300 | - // Try to save the metadata in the cache |
|
| 301 | - if($xMetadataCache !== null) |
|
| 302 | - { |
|
| 303 | - $xMetadataCache->save($xReflectionClass->getName(), $xMetadata); |
|
| 304 | - } |
|
| 300 | +// Try to save the metadata in the cache |
|
| 301 | +if($xMetadataCache !== null) |
|
| 302 | +{ |
|
| 303 | +$xMetadataCache->save($xReflectionClass->getName(), $xMetadata); |
|
| 304 | +} |
|
| 305 | 305 | |
| 306 | - return $xMetadata; |
|
| 307 | - } |
|
| 306 | +return $xMetadata; |
|
| 307 | +} |
|
| 308 | 308 | |
| 309 | - /** |
|
| 309 | +/** |
|
| 310 | 310 | * @param ReflectionClass $xReflectionClass |
| 311 | 311 | * @param array $aOptions |
| 312 | 312 | * |
| 313 | 313 | * @return ComponentOptions |
| 314 | 314 | */ |
| 315 | - public function getComponentOptions(ReflectionClass $xReflectionClass, |
|
| 316 | - array $aOptions): ComponentOptions |
|
| 317 | - { |
|
| 318 | - $aMethods = $this->getPublicMethods($xReflectionClass); |
|
| 319 | - $xMetadata = $this->getComponentMetadata($xReflectionClass, $aMethods[0], $aOptions); |
|
| 315 | +public function getComponentOptions(ReflectionClass $xReflectionClass, |
|
| 316 | +array $aOptions): ComponentOptions |
|
| 317 | +{ |
|
| 318 | +$aMethods = $this->getPublicMethods($xReflectionClass); |
|
| 319 | +$xMetadata = $this->getComponentMetadata($xReflectionClass, $aMethods[0], $aOptions); |
|
| 320 | 320 | |
| 321 | - return new ComponentOptions($aMethods, $aOptions, $xMetadata); |
|
| 322 | - } |
|
| 321 | +return new ComponentOptions($aMethods, $aOptions, $xMetadata); |
|
| 322 | +} |
|
| 323 | 323 | } |
@@ -151,15 +151,15 @@ discard block |
||
| 151 | 151 | $xRegistry->updateHash(false); // Disable hash calculation. |
| 152 | 152 | |
| 153 | 153 | $sComponentId = str_replace('\\', '.', $sClassName); |
| 154 | - if(!isset($this->aComponents[$sComponentId])) |
|
| 154 | + if (!isset($this->aComponents[$sComponentId])) |
|
| 155 | 155 | { |
| 156 | 156 | $aOptions = $xRegistry->getNamespaceComponentOptions($sClassName); |
| 157 | - if($aOptions !== null) |
|
| 157 | + if ($aOptions !== null) |
|
| 158 | 158 | { |
| 159 | 159 | $this->saveComponent($sClassName, $aOptions); |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | - if(isset($this->aComponents[$sComponentId])) |
|
| 162 | + if (isset($this->aComponents[$sComponentId])) |
|
| 163 | 163 | { |
| 164 | 164 | return; // The component is found. |
| 165 | 165 | } |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | // The component was not found in a registered namespace. We need to parse all |
| 168 | 168 | // the directories to be able to find a component registered without a namespace. |
| 169 | 169 | $sComponentId = str_replace('\\', '_', $sClassName); |
| 170 | - if(!isset($this->aComponents[$sComponentId])) |
|
| 170 | + if (!isset($this->aComponents[$sComponentId])) |
|
| 171 | 171 | { |
| 172 | 172 | $xRegistry->registerComponentsInDirectories(); |
| 173 | 173 | } |
| 174 | - if(isset($this->aComponents[$sComponentId])) |
|
| 174 | + if (isset($this->aComponents[$sComponentId])) |
|
| 175 | 175 | { |
| 176 | 176 | return; // The component is found. |
| 177 | 177 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | public function getCallableObjects(): array |
| 190 | 190 | { |
| 191 | 191 | $aCallableObjects = []; |
| 192 | - foreach($this->aComponents as $sComponentId => $_) |
|
| 192 | + foreach ($this->aComponents as $sComponentId => $_) |
|
| 193 | 193 | { |
| 194 | 194 | $aCallableObjects[$sComponentId] = $this->makeCallableObject($sComponentId); |
| 195 | 195 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | private function setComponentPublicMethods(string $sKey, string $sClass, |
| 207 | 207 | array $aNeverExported): void |
| 208 | 208 | { |
| 209 | - if(isset($this->aComponentPublicMethods[$sKey])) |
|
| 209 | + if (isset($this->aComponentPublicMethods[$sKey])) |
|
| 210 | 210 | { |
| 211 | 211 | return; |
| 212 | 212 | } |
@@ -259,12 +259,12 @@ discard block |
||
| 259 | 259 | { |
| 260 | 260 | /** @var Config|null */ |
| 261 | 261 | $xPackageConfig = $aOptions['config'] ?? null; |
| 262 | - if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 262 | + if ($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 263 | 263 | { |
| 264 | 264 | return null; |
| 265 | 265 | } |
| 266 | 266 | $sMetadataFormat = $xPackageConfig->getOption('metadata.format'); |
| 267 | - if(!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 267 | + if (!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 268 | 268 | { |
| 269 | 269 | return null; |
| 270 | 270 | } |
@@ -274,23 +274,23 @@ discard block |
||
| 274 | 274 | $xMetadata = null; |
| 275 | 275 | $xMetadataCache = null; |
| 276 | 276 | $xConfig = $di->config(); |
| 277 | - if($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 277 | + if ($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 278 | 278 | { |
| 279 | - if(!$di->h('jaxon_metadata_cache_dir')) |
|
| 279 | + if (!$di->h('jaxon_metadata_cache_dir')) |
|
| 280 | 280 | { |
| 281 | 281 | $sCacheDir = $xConfig->getAppOption('metadata.cache.dir'); |
| 282 | 282 | $di->val('jaxon_metadata_cache_dir', $sCacheDir); |
| 283 | 283 | } |
| 284 | 284 | $xMetadataCache = $di->getMetadataCache(); |
| 285 | 285 | $xMetadata = $xMetadataCache->read($xReflectionClass->getName()); |
| 286 | - if($xMetadata !== null) |
|
| 286 | + if ($xMetadata !== null) |
|
| 287 | 287 | { |
| 288 | 288 | return $xMetadata; |
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | $aProperties = array_map(fn($xProperty) => $xProperty->getName(), |
| 293 | - $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC | |
|
| 293 | + $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC| |
|
| 294 | 294 | ReflectionProperty::IS_PROTECTED)); |
| 295 | 295 | |
| 296 | 296 | $xMetadataReader = $di->getMetadataReader($sMetadataFormat); |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | $xMetadata = $xMetadataReader->getAttributes($xInput); |
| 299 | 299 | |
| 300 | 300 | // Try to save the metadata in the cache |
| 301 | - if($xMetadataCache !== null) |
|
| 301 | + if ($xMetadataCache !== null) |
|
| 302 | 302 | { |
| 303 | 303 | $xMetadataCache->save($xReflectionClass->getName(), $xMetadata); |
| 304 | 304 | } |