@@ -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 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | private function setComponentPublicMethods(string $sKey, string $sClass): void |
| 206 | 206 | { |
| 207 | - if(isset($this->aComponentPublicMethods[$sKey])) |
|
| 207 | + if (isset($this->aComponentPublicMethods[$sKey])) |
|
| 208 | 208 | { |
| 209 | 209 | return; |
| 210 | 210 | } |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | { |
| 254 | 254 | /** @var Config|null */ |
| 255 | 255 | $xPackageConfig = $aOptions['config'] ?? null; |
| 256 | - if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 256 | + if ($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 257 | 257 | { |
| 258 | 258 | return null; |
| 259 | 259 | } |
| 260 | 260 | $sMetadataFormat = $xPackageConfig->getOption('metadata.format'); |
| 261 | - if(!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 261 | + if (!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 262 | 262 | { |
| 263 | 263 | return null; |
| 264 | 264 | } |
@@ -268,23 +268,23 @@ discard block |
||
| 268 | 268 | $xMetadata = null; |
| 269 | 269 | $xMetadataCache = null; |
| 270 | 270 | $xConfig = $di->config(); |
| 271 | - if($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 271 | + if ($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 272 | 272 | { |
| 273 | - if(!$di->h('jaxon_metadata_cache_dir')) |
|
| 273 | + if (!$di->h('jaxon_metadata_cache_dir')) |
|
| 274 | 274 | { |
| 275 | 275 | $sCacheDir = $xConfig->getAppOption('metadata.cache.dir'); |
| 276 | 276 | $di->val('jaxon_metadata_cache_dir', $sCacheDir); |
| 277 | 277 | } |
| 278 | 278 | $xMetadataCache = $di->getMetadataCache(); |
| 279 | 279 | $xMetadata = $xMetadataCache->read($xReflectionClass->getName()); |
| 280 | - if($xMetadata !== null) |
|
| 280 | + if ($xMetadata !== null) |
|
| 281 | 281 | { |
| 282 | 282 | return $xMetadata; |
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | $aProperties = array_map(fn($xProperty) => $xProperty->getName(), |
| 287 | - $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC | |
|
| 287 | + $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC| |
|
| 288 | 288 | ReflectionProperty::IS_PROTECTED)); |
| 289 | 289 | |
| 290 | 290 | $xMetadataReader = $di->getMetadataReader($sMetadataFormat); |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | $xMetadata = $xMetadataReader->getAttributes($xInput); |
| 293 | 293 | |
| 294 | 294 | // Try to save the metadata in the cache |
| 295 | - if($xMetadataCache !== null && $xMetadata !== null) |
|
| 295 | + if ($xMetadataCache !== null && $xMetadata !== null) |
|
| 296 | 296 | { |
| 297 | 297 | $xMetadataCache->save($xReflectionClass->getName(), $xMetadata); |
| 298 | 298 | } |
@@ -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));"; |
@@ -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 | } |
@@ -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 | } |
@@ -107,33 +107,33 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | $this->bExcluded = ($xMetadata?->isExcluded() ?? false) || |
| 109 | 109 | (bool)($aOptions['excluded'] ?? false); |
| 110 | - if($this->bExcluded) |
|
| 110 | + if ($this->bExcluded) |
|
| 111 | 111 | { |
| 112 | 112 | return; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $sSeparator = $aOptions['separator']; |
| 116 | - if($sSeparator === '_' || $sSeparator === '.') |
|
| 116 | + if ($sSeparator === '_' || $sSeparator === '.') |
|
| 117 | 117 | { |
| 118 | 118 | $this->sSeparator = $sSeparator; |
| 119 | 119 | } |
| 120 | 120 | $this->addProtectedMethods($aOptions['protected']); |
| 121 | 121 | |
| 122 | - foreach($aOptions['functions'] as $sNames => $aFunctionOptions) |
|
| 122 | + foreach ($aOptions['functions'] as $sNames => $aFunctionOptions) |
|
| 123 | 123 | { |
| 124 | 124 | // Names are in a comma-separated list. |
| 125 | 125 | $aFunctionNames = explode(',', $sNames); |
| 126 | - foreach($aFunctionNames as $sFunctionName) |
|
| 126 | + foreach ($aFunctionNames as $sFunctionName) |
|
| 127 | 127 | { |
| 128 | 128 | $this->addFunctionOptions($sFunctionName, $aFunctionOptions); |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if($xMetadata !== null) |
|
| 132 | + if ($xMetadata !== null) |
|
| 133 | 133 | { |
| 134 | 134 | $this->aExportMethods = $xMetadata->getExportMethods(); |
| 135 | 135 | $this->addProtectedMethods($xMetadata->getProtectedMethods()); |
| 136 | - foreach($xMetadata->getProperties() as $sFunctionName => $aFunctionOptions) |
|
| 136 | + foreach ($xMetadata->getProperties() as $sFunctionName => $aFunctionOptions) |
|
| 137 | 137 | { |
| 138 | 138 | $this->addFunctionOptions($sFunctionName, $aFunctionOptions); |
| 139 | 139 | } |
@@ -150,8 +150,7 @@ discard block |
||
| 150 | 150 | private function addProtectedMethods(array|string $xMethods): void |
| 151 | 151 | { |
| 152 | 152 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, |
| 153 | - !is_array($xMethods) ? [trim((string)$xMethods)] : |
|
| 154 | - array_map(fn($sMethod) => trim((string)$sMethod), $xMethods)); |
|
| 153 | + !is_array($xMethods) ? [trim((string)$xMethods)] : array_map(fn($sMethod) => trim((string)$sMethod), $xMethods)); |
|
| 155 | 154 | } |
| 156 | 155 | |
| 157 | 156 | /** |
@@ -161,7 +160,7 @@ discard block |
||
| 161 | 160 | */ |
| 162 | 161 | private function filterPublicMethods(array $aMethods): array |
| 163 | 162 | { |
| 164 | - if($this->bExcluded || in_array('*', $this->aProtectedMethods)) |
|
| 163 | + if ($this->bExcluded || in_array('*', $this->aProtectedMethods)) |
|
| 165 | 164 | { |
| 166 | 165 | return []; |
| 167 | 166 | } |
@@ -169,13 +168,13 @@ discard block |
||
| 169 | 168 | $aBaseMethods = $aMethods[1]; |
| 170 | 169 | $aMethods = $aMethods[0]; |
| 171 | 170 | |
| 172 | - if(isset($this->aExportMethods['only'])) |
|
| 171 | + if (isset($this->aExportMethods['only'])) |
|
| 173 | 172 | { |
| 174 | 173 | $aMethods = array_intersect($aMethods, $this->aExportMethods['only']); |
| 175 | 174 | } |
| 176 | 175 | $aMethods = array_diff($aMethods, $this->aProtectedMethods, |
| 177 | 176 | $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 | } |
@@ -253,17 +252,17 @@ discard block |
||
| 253 | 252 | */ |
| 254 | 253 | private function setHookMethods(array &$aHookMethods, $xValue): void |
| 255 | 254 | { |
| 256 | - foreach($xValue as $sCalledMethod => $xMethodToCall) |
|
| 255 | + foreach ($xValue as $sCalledMethod => $xMethodToCall) |
|
| 257 | 256 | { |
| 258 | - if(!isset($aHookMethods[$sCalledMethod])) |
|
| 257 | + if (!isset($aHookMethods[$sCalledMethod])) |
|
| 259 | 258 | { |
| 260 | 259 | $aHookMethods[$sCalledMethod] = []; |
| 261 | 260 | } |
| 262 | - if(is_array($xMethodToCall)) |
|
| 261 | + if (is_array($xMethodToCall)) |
|
| 263 | 262 | { |
| 264 | 263 | $aHookMethods[$sCalledMethod] = array_merge($aHookMethods[$sCalledMethod], $xMethodToCall); |
| 265 | 264 | } |
| 266 | - elseif(is_string($xMethodToCall)) |
|
| 265 | + elseif (is_string($xMethodToCall)) |
|
| 267 | 266 | { |
| 268 | 267 | $aHookMethods[$sCalledMethod][] = $xMethodToCall; |
| 269 | 268 | } |
@@ -288,7 +287,7 @@ discard block |
||
| 288 | 287 | */ |
| 289 | 288 | private function addOption(string $sName, $xValue): void |
| 290 | 289 | { |
| 291 | - switch($sName) |
|
| 290 | + switch ($sName) |
|
| 292 | 291 | { |
| 293 | 292 | // Set the methods to call before processing the request |
| 294 | 293 | case '__before': |
@@ -316,11 +315,11 @@ discard block |
||
| 316 | 315 | */ |
| 317 | 316 | private function _addJsArrayOption(string $sFunctionName, string $sOptionName, $xOptionValue): void |
| 318 | 317 | { |
| 319 | - if(is_string($xOptionValue)) |
|
| 318 | + if (is_string($xOptionValue)) |
|
| 320 | 319 | { |
| 321 | 320 | $xOptionValue = [$xOptionValue]; |
| 322 | 321 | } |
| 323 | - if(!is_array($xOptionValue)) |
|
| 322 | + if (!is_array($xOptionValue)) |
|
| 324 | 323 | { |
| 325 | 324 | return; // Do not save. |
| 326 | 325 | } |
@@ -350,10 +349,10 @@ discard block |
||
| 350 | 349 | */ |
| 351 | 350 | private function addJsOption(string $sFunctionName, string $sOptionName, $xOptionValue): void |
| 352 | 351 | { |
| 353 | - switch($sOptionName) |
|
| 352 | + switch ($sOptionName) |
|
| 354 | 353 | { |
| 355 | 354 | case 'excluded': |
| 356 | - if((bool)$xOptionValue) |
|
| 355 | + if ((bool)$xOptionValue) |
|
| 357 | 356 | { |
| 358 | 357 | $this->addProtectedMethods($sFunctionName); |
| 359 | 358 | } |
@@ -377,12 +376,11 @@ discard block |
||
| 377 | 376 | */ |
| 378 | 377 | private function addFunctionOptions(string $sFunctionName, array $aFunctionOptions): void |
| 379 | 378 | { |
| 380 | - foreach($aFunctionOptions as $sOptionName => $xOptionValue) |
|
| 379 | + foreach ($aFunctionOptions as $sOptionName => $xOptionValue) |
|
| 381 | 380 | { |
| 382 | 381 | substr($sOptionName, 0, 2) === '__' ? |
| 383 | 382 | // Options for PHP classes. They start with "__". |
| 384 | - $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : |
|
| 385 | - // Options for javascript code. |
|
| 383 | + $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : // Options for javascript code. |
|
| 386 | 384 | $this->addJsOption($sFunctionName, $sOptionName, $xOptionValue); |
| 387 | 385 | } |
| 388 | 386 | } |
@@ -398,16 +396,15 @@ discard block |
||
| 398 | 396 | $aOptions = array_merge($this->aJsOptions['*'] ?? []); // Clone the array |
| 399 | 397 | // Then add the method options. |
| 400 | 398 | $aMethodOptions = $this->aJsOptions[$sMethodName] ?? []; |
| 401 | - foreach($aMethodOptions as $sOptionName => $xOptionValue) |
|
| 399 | + foreach ($aMethodOptions as $sOptionName => $xOptionValue) |
|
| 402 | 400 | { |
| 403 | 401 | // For databags and callbacks, merge the values in a single array. |
| 404 | 402 | // For all the other options, keep the last value. |
| 405 | 403 | $aOptions[$sOptionName] = !in_array($sOptionName, ['bags', 'callback']) ? |
| 406 | - $xOptionValue : |
|
| 407 | - array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue)); |
|
| 404 | + $xOptionValue : array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue)); |
|
| 408 | 405 | } |
| 409 | 406 | // Since callbacks are js object names, they need a special formatting. |
| 410 | - if(isset($aOptions['callback'])) |
|
| 407 | + if (isset($aOptions['callback'])) |
|
| 411 | 408 | { |
| 412 | 409 | $aOptions['callback'] = str_replace('"', '', json_encode($aOptions['callback'])); |
| 413 | 410 | } |
@@ -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 | } |
@@ -69,19 +69,19 @@ discard block |
||
| 69 | 69 | private function readTypes(ReflectionClass $xClass) |
| 70 | 70 | { |
| 71 | 71 | $sClass = $xClass->getName(); |
| 72 | - if(isset($this->aTypes[$sClass])) |
|
| 72 | + if (isset($this->aTypes[$sClass])) |
|
| 73 | 73 | { |
| 74 | 74 | return; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $this->aTypes[$sClass] = []; |
| 78 | - $aProperties = $xClass->getProperties(ReflectionProperty::IS_PUBLIC | |
|
| 78 | + $aProperties = $xClass->getProperties(ReflectionProperty::IS_PUBLIC| |
|
| 79 | 79 | ReflectionProperty::IS_PROTECTED); |
| 80 | - foreach($aProperties as $xReflectionProperty) |
|
| 80 | + foreach ($aProperties as $xReflectionProperty) |
|
| 81 | 81 | { |
| 82 | 82 | $xType = $xReflectionProperty->getType(); |
| 83 | 83 | // Check that the property has a valid type defined |
| 84 | - if(is_a($xType, ReflectionNamedType::class) && |
|
| 84 | + if (is_a($xType, ReflectionNamedType::class) && |
|
| 85 | 85 | ($sType = $xType->getName()) !== '') |
| 86 | 86 | { |
| 87 | 87 | $this->aTypes[$sClass][$xReflectionProperty->getName()] = $sType; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | private function initAttribute(AbstractAttribute $xAttribute, |
| 100 | 100 | ReflectionClass $xClass, ReflectionAttribute $xReflectionAttribute): void |
| 101 | 101 | { |
| 102 | - if(is_a($xAttribute, InjectAttribute::class)) |
|
| 102 | + if (is_a($xAttribute, InjectAttribute::class)) |
|
| 103 | 103 | { |
| 104 | 104 | $this->readTypes($xClass); |
| 105 | 105 | $xAttribute->setTarget($xReflectionAttribute->getTarget()); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $aClassAttributes = $xClass->getAttributes(); |
| 118 | 118 | $aAttributes = array_filter($aClassAttributes, fn($xAttribute) => |
| 119 | 119 | is_a($xAttribute->getName(), ExcludeAttribute::class, true)); |
| 120 | - foreach($aAttributes as $xReflectionAttribute) |
|
| 120 | + foreach ($aAttributes as $xReflectionAttribute) |
|
| 121 | 121 | { |
| 122 | 122 | $xReflectionAttribute->newInstance()->saveValue($this->xMetadata); |
| 123 | 123 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | $aClassAttributes = $xClass->getAttributes(); |
| 136 | 136 | $aAttributes = array_filter($aClassAttributes, fn($xAttribute) => |
| 137 | 137 | is_a($xAttribute->getName(), ExportAttribute::class, true)); |
| 138 | - foreach($aAttributes as $xReflectionAttribute) |
|
| 138 | + foreach ($aAttributes as $xReflectionAttribute) |
|
| 139 | 139 | { |
| 140 | 140 | $xReflectionAttribute->newInstance()->saveValue($this->xMetadata); |
| 141 | 141 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | is_a($xAttribute->getName(), AbstractAttribute::class, true) && |
| 154 | 154 | !is_a($xAttribute->getName(), ExcludeAttribute::class, true) && |
| 155 | 155 | !is_a($xAttribute->getName(), ExportAttribute::class, true)); |
| 156 | - foreach($aAttributes as $xReflectionAttribute) |
|
| 156 | + foreach ($aAttributes as $xReflectionAttribute) |
|
| 157 | 157 | { |
| 158 | 158 | $xAttribute = $xReflectionAttribute->newInstance(); |
| 159 | 159 | $this->initAttribute($xAttribute, $xClass, $xReflectionAttribute); |
@@ -172,16 +172,15 @@ discard block |
||
| 172 | 172 | private function getPropertyAttrs(ReflectionClass $xClass, string $sProperty): void |
| 173 | 173 | { |
| 174 | 174 | // Only Inject attributes are allowed on properties |
| 175 | - $aAttributes = !$xClass->hasProperty($sProperty) ? [] : |
|
| 176 | - $xClass->getProperty($sProperty)->getAttributes(); |
|
| 175 | + $aAttributes = !$xClass->hasProperty($sProperty) ? [] : $xClass->getProperty($sProperty)->getAttributes(); |
|
| 177 | 176 | $aAttributes = array_filter($aAttributes, fn($xAttribute) => |
| 178 | 177 | is_a($xAttribute->getName(), InjectAttribute::class, true)); |
| 179 | - if(count($aAttributes) > 1) |
|
| 178 | + if (count($aAttributes) > 1) |
|
| 180 | 179 | { |
| 181 | 180 | throw new SetupException('Only one Inject attribute is allowed on a property'); |
| 182 | 181 | } |
| 183 | 182 | |
| 184 | - foreach($aAttributes as $xReflectionAttribute) |
|
| 183 | + foreach ($aAttributes as $xReflectionAttribute) |
|
| 185 | 184 | { |
| 186 | 185 | /** @var InjectAttribute */ |
| 187 | 186 | $xAttribute = $xReflectionAttribute->newInstance(); |
@@ -200,11 +199,10 @@ discard block |
||
| 200 | 199 | */ |
| 201 | 200 | private function getMethodAttrs(ReflectionClass $xClass, string $sMethod): void |
| 202 | 201 | { |
| 203 | - $aAttributes = !$xClass->hasMethod($sMethod) ? [] : |
|
| 204 | - $xClass->getMethod($sMethod)->getAttributes(); |
|
| 202 | + $aAttributes = !$xClass->hasMethod($sMethod) ? [] : $xClass->getMethod($sMethod)->getAttributes(); |
|
| 205 | 203 | $aAttributes = array_filter($aAttributes, fn($xAttribute) => |
| 206 | 204 | is_a($xAttribute->getName(), AbstractAttribute::class, true)); |
| 207 | - foreach($aAttributes as $xReflectionAttribute) |
|
| 205 | + foreach ($aAttributes as $xReflectionAttribute) |
|
| 208 | 206 | { |
| 209 | 207 | $xAttribute = $xReflectionAttribute->newInstance(); |
| 210 | 208 | $this->initAttribute($xAttribute, $xClass, $xReflectionAttribute); |
@@ -238,7 +236,7 @@ discard block |
||
| 238 | 236 | $xClass = $xInput->getReflectionClass(); |
| 239 | 237 | // First check if the class is exluded. |
| 240 | 238 | $this->getClassExcludeAttr($xClass); |
| 241 | - if($this->xMetadata->isExcluded()) |
|
| 239 | + if ($this->xMetadata->isExcluded()) |
|
| 242 | 240 | { |
| 243 | 241 | return $this->xMetadata; |
| 244 | 242 | } |
@@ -247,25 +245,25 @@ discard block |
||
| 247 | 245 | $this->getBaseClassAttrs($xClass); |
| 248 | 246 | |
| 249 | 247 | $aClasses = [$xClass]; |
| 250 | - while(($xClass = $this->getParentClass($xClass)) !== null) |
|
| 248 | + while (($xClass = $this->getParentClass($xClass)) !== null) |
|
| 251 | 249 | { |
| 252 | 250 | $aClasses[] = $xClass; |
| 253 | 251 | } |
| 254 | 252 | $aClasses = array_reverse($aClasses); |
| 255 | 253 | |
| 256 | - foreach($aClasses as $xClass) |
|
| 254 | + foreach ($aClasses as $xClass) |
|
| 257 | 255 | { |
| 258 | 256 | // Processing class attributes |
| 259 | 257 | $this->getClassAttrs($xClass); |
| 260 | 258 | |
| 261 | 259 | // Processing properties attributes |
| 262 | - foreach($xInput->getProperties() as $sProperty) |
|
| 260 | + foreach ($xInput->getProperties() as $sProperty) |
|
| 263 | 261 | { |
| 264 | 262 | $this->getPropertyAttrs($xClass, $sProperty); |
| 265 | 263 | } |
| 266 | 264 | |
| 267 | 265 | // Processing methods attributes |
| 268 | - foreach($xInput->getMethods() as $sMethod) |
|
| 266 | + foreach ($xInput->getMethods() as $sMethod) |
|
| 269 | 267 | { |
| 270 | 268 | $this->getMethodAttrs($xClass, $sMethod); |
| 271 | 269 | } |
@@ -273,7 +271,7 @@ discard block |
||
| 273 | 271 | |
| 274 | 272 | return $this->xMetadata; |
| 275 | 273 | } |
| 276 | - catch(Exception|Error $e) |
|
| 274 | + catch (Exception|Error $e) |
|
| 277 | 275 | { |
| 278 | 276 | throw new SetupException($e->getMessage()); |
| 279 | 277 | } |
@@ -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 | } |