@@ -94,28 +94,28 @@ discard block |
||
| 94 | 94 | private function updateContainer(Config $xConfig) |
| 95 | 95 | { |
| 96 | 96 | $aOptions = $xConfig->getOption('container.set', []); |
| 97 | - foreach($aOptions as $xKey => $xValue) |
|
| 97 | + foreach ($aOptions as $xKey => $xValue) |
|
| 98 | 98 | { |
| 99 | 99 | // The key is the class name. It must be a string. |
| 100 | - $this->di->set((string)$xKey, $xValue); |
|
| 100 | + $this->di->set((string) $xKey, $xValue); |
|
| 101 | 101 | } |
| 102 | 102 | $aOptions = $xConfig->getOption('container.val', []); |
| 103 | - foreach($aOptions as $xKey => $xValue) |
|
| 103 | + foreach ($aOptions as $xKey => $xValue) |
|
| 104 | 104 | { |
| 105 | 105 | // The key is the class name. It must be a string. |
| 106 | - $this->di->val((string)$xKey, $xValue); |
|
| 106 | + $this->di->val((string) $xKey, $xValue); |
|
| 107 | 107 | } |
| 108 | 108 | $aOptions = $xConfig->getOption('container.auto', []); |
| 109 | - foreach($aOptions as $xValue) |
|
| 109 | + foreach ($aOptions as $xValue) |
|
| 110 | 110 | { |
| 111 | 111 | // The key is the class name. It must be a string. |
| 112 | - $this->di->auto((string)$xValue); |
|
| 112 | + $this->di->auto((string) $xValue); |
|
| 113 | 113 | } |
| 114 | 114 | $aOptions = $xConfig->getOption('container.alias', []); |
| 115 | - foreach($aOptions as $xKey => $xValue) |
|
| 115 | + foreach ($aOptions as $xKey => $xValue) |
|
| 116 | 116 | { |
| 117 | 117 | // The key is the class name. It must be a string. |
| 118 | - $this->di->alias((string)$xKey, (string)$xValue); |
|
| 118 | + $this->di->alias((string) $xKey, (string) $xValue); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
@@ -130,14 +130,14 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | private function registerCallables(array $aOptions, string $sCallableType) |
| 132 | 132 | { |
| 133 | - foreach($aOptions as $xKey => $xValue) |
|
| 133 | + foreach ($aOptions as $xKey => $xValue) |
|
| 134 | 134 | { |
| 135 | - if(is_integer($xKey) && is_string($xValue)) |
|
| 135 | + if (is_integer($xKey) && is_string($xValue)) |
|
| 136 | 136 | { |
| 137 | 137 | // Register a function without options |
| 138 | 138 | $this->xPluginManager->registerCallable($sCallableType, $xValue); |
| 139 | 139 | } |
| 140 | - elseif(is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
| 140 | + elseif (is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
| 141 | 141 | { |
| 142 | 142 | // Register a function with options |
| 143 | 143 | $this->xPluginManager->registerCallable($sCallableType, $xKey, $xValue); |
@@ -180,12 +180,12 @@ discard block |
||
| 180 | 180 | { |
| 181 | 181 | // $this->aPackages contains packages config file paths. |
| 182 | 182 | $aLibOptions = $sClassName::config(); |
| 183 | - if(is_string($aLibOptions)) |
|
| 183 | + if (is_string($aLibOptions)) |
|
| 184 | 184 | { |
| 185 | 185 | // A string is supposed to be the path to a config file. |
| 186 | 186 | $aLibOptions = $this->xConfigManager->read($aLibOptions); |
| 187 | 187 | } |
| 188 | - elseif(!is_array($aLibOptions)) |
|
| 188 | + elseif (!is_array($aLibOptions)) |
|
| 189 | 189 | { |
| 190 | 190 | // Otherwise, anything else than an array is not accepted. |
| 191 | 191 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | $xOptionsProvider = $aUserOptions['provider'] ?? null; |
| 210 | 210 | // The user can provide a callable that returns the package options. |
| 211 | - if(is_callable($xOptionsProvider)) |
|
| 211 | + if (is_callable($xOptionsProvider)) |
|
| 212 | 212 | { |
| 213 | 213 | $aUserOptions = $xOptionsProvider($aUserOptions); |
| 214 | 214 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | public function registerPackage(string $sClassName, array $aUserOptions) |
| 228 | 228 | { |
| 229 | 229 | $sClassName = trim($sClassName, '\\ '); |
| 230 | - if(!is_subclass_of($sClassName, Package::class)) |
|
| 230 | + if (!is_subclass_of($sClassName, Package::class)) |
|
| 231 | 231 | { |
| 232 | 232 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
| 233 | 233 | throw new SetupException($sMessage); |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | // Register packages |
| 273 | 273 | $aPackageConfig = $xAppConfig->getOption('packages', []); |
| 274 | - foreach($aPackageConfig as $sClassName => $aPkgOptions) |
|
| 274 | + foreach ($aPackageConfig as $sClassName => $aPkgOptions) |
|
| 275 | 275 | { |
| 276 | 276 | $this->registerPackage($sClassName, $aPkgOptions); |
| 277 | 277 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | private function setDiAttributes($xRegisteredObject, array $aDiOptions) |
| 35 | 35 | { |
| 36 | - foreach($aDiOptions as $sName => $sClass) |
|
| 36 | + foreach ($aDiOptions as $sName => $sClass) |
|
| 37 | 37 | { |
| 38 | 38 | // Set the protected attributes of the object |
| 39 | 39 | $cSetter = function($xInjectedObject) use($sName) { |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $this->setDiAttributes($xRegisteredObject, $aDiOptions); |
| 64 | 64 | |
| 65 | 65 | // Set the Jaxon request target in the helper |
| 66 | - if($xRegisteredObject instanceof CallableClass) |
|
| 66 | + if ($xRegisteredObject instanceof CallableClass) |
|
| 67 | 67 | { |
| 68 | 68 | // Set the protected attributes of the object |
| 69 | 69 | $cSetter = function() use($xTarget) { |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | $sReflectionClass = $sClassName . '_ReflectionClass'; |
| 92 | 92 | |
| 93 | 93 | // Prevent duplication |
| 94 | - if($this->h($sReflectionClass)) // It's important not to use the class name here. |
|
| 94 | + if ($this->h($sReflectionClass)) // It's important not to use the class name here. |
|
| 95 | 95 | { |
| 96 | 96 | return; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Make sure the registered class exists |
| 100 | - if(isset($aOptions['include'])) |
|
| 100 | + if (isset($aOptions['include'])) |
|
| 101 | 101 | { |
| 102 | 102 | require_once($aOptions['include']); |
| 103 | 103 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | $this->val($sReflectionClass, new ReflectionClass($sClassName)); |
| 108 | 108 | } |
| 109 | - catch(ReflectionException $e) |
|
| 109 | + catch (ReflectionException $e) |
|
| 110 | 110 | { |
| 111 | 111 | $xTranslator = $this->g(Translator::class); |
| 112 | 112 | $sMessage = $xTranslator->trans('errors.class.invalid', ['name' => $sClassName]); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | }); |
| 131 | 131 | |
| 132 | 132 | // Register the user class, but only if the user didn't already. |
| 133 | - if(!$this->h($sClassName)) |
|
| 133 | + if (!$this->h($sClassName)) |
|
| 134 | 134 | { |
| 135 | 135 | $this->set($sClassName, function($di) use($sReflectionClass) { |
| 136 | 136 | return $this->make($di->g($sReflectionClass)); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | // Initialize the user class instance |
| 140 | 140 | $this->xLibContainer->extend($sClassName, function($xRegisteredObject) |
| 141 | 141 | use($sCallableObject, $sClassName) { |
| 142 | - if($xRegisteredObject instanceof CallableClass) |
|
| 142 | + if ($xRegisteredObject instanceof CallableClass) |
|
| 143 | 143 | { |
| 144 | 144 | $cSetter = function($di) use($sClassName) { |
| 145 | 145 | // Set the protected attributes of the object |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | // Run the callbacks for class initialisation |
| 154 | 154 | $aCallbacks = $this->g(CallbackManager::class)->getInitCallbacks(); |
| 155 | - foreach($aCallbacks as $xCallback) |
|
| 155 | + foreach ($aCallbacks as $xCallback) |
|
| 156 | 156 | { |
| 157 | 157 | call_user_func($xCallback, $xRegisteredObject); |
| 158 | 158 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | public function registerPackage(string $sClassName, Config $xPkgConfig) |
| 205 | 205 | { |
| 206 | 206 | // Register the user class, but only if the user didn't already. |
| 207 | - if(!$this->h($sClassName)) |
|
| 207 | + if (!$this->h($sClassName)) |
|
| 208 | 208 | { |
| 209 | 209 | $this->set($sClassName, function() use($sClassName) { |
| 210 | 210 | return $this->make($sClassName); |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | public function set(string $sClass, Closure $xClosure) |
| 216 | 216 | { |
| 217 | - $this->xLibContainer->offsetSet($sClass, function() use($xClosure) { |
|
| 217 | + $this->xLibContainer->offsetSet($sClass, function() use($xClosure) { |
|
| 218 | 218 | return $xClosure($this); |
| 219 | 219 | }); |
| 220 | 220 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function val(string $sKey, $xValue) |
| 231 | 231 | { |
| 232 | - $this->xLibContainer->offsetSet($sKey, $xValue); |
|
| 232 | + $this->xLibContainer->offsetSet($sKey, $xValue); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function has(string $sClass): bool |
| 159 | 159 | { |
| 160 | - if($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
| 160 | + if ($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
| 161 | 161 | { |
| 162 | 162 | return true; |
| 163 | 163 | } |
@@ -188,13 +188,13 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | try |
| 190 | 190 | { |
| 191 | - if($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
| 191 | + if ($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
| 192 | 192 | { |
| 193 | 193 | return $this->xAppContainer->get($sClass); |
| 194 | 194 | } |
| 195 | 195 | return $this->xLibContainer->offsetGet($sClass); |
| 196 | 196 | } |
| 197 | - catch(Exception|Throwable $e) |
|
| 197 | + catch (Exception | Throwable $e) |
|
| 198 | 198 | { |
| 199 | 199 | $xLogger = $this->g(LoggerInterface::class); |
| 200 | 200 | $xTranslator = $this->g(Translator::class); |
@@ -258,15 +258,15 @@ discard block |
||
| 258 | 258 | { |
| 259 | 259 | $xType = $xParameter->getType(); |
| 260 | 260 | // Check the parameter class first. |
| 261 | - if($xType instanceof ReflectionNamedType) |
|
| 261 | + if ($xType instanceof ReflectionNamedType) |
|
| 262 | 262 | { |
| 263 | 263 | // Check the class + the name |
| 264 | - if($this->has($xType->getName() . ' $' . $xParameter->getName())) |
|
| 264 | + if ($this->has($xType->getName() . ' $' . $xParameter->getName())) |
|
| 265 | 265 | { |
| 266 | 266 | return $this->get($xType->getName() . ' $' . $xParameter->getName()); |
| 267 | 267 | } |
| 268 | 268 | // Check the class only |
| 269 | - if($this->get($xType->getName())) |
|
| 269 | + if ($this->get($xType->getName())) |
|
| 270 | 270 | { |
| 271 | 271 | return $this->get($xType->getName()); |
| 272 | 272 | } |
@@ -286,16 +286,16 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | public function make($xClass) |
| 288 | 288 | { |
| 289 | - if(is_string($xClass)) |
|
| 289 | + if (is_string($xClass)) |
|
| 290 | 290 | { |
| 291 | 291 | $xClass = new ReflectionClass($xClass); // Create the reflection class instance |
| 292 | 292 | } |
| 293 | - if(!($xClass instanceof ReflectionClass)) |
|
| 293 | + if (!($xClass instanceof ReflectionClass)) |
|
| 294 | 294 | { |
| 295 | 295 | return null; |
| 296 | 296 | } |
| 297 | 297 | // Use the Reflection class to get the parameters of the constructor |
| 298 | - if(($constructor = $xClass->getConstructor()) === null) |
|
| 298 | + if (($constructor = $xClass->getConstructor()) === null) |
|
| 299 | 299 | { |
| 300 | 300 | return $xClass->newInstance(); |
| 301 | 301 | } |
@@ -193,8 +193,7 @@ |
||
| 193 | 193 | return $this->xAppContainer->get($sClass); |
| 194 | 194 | } |
| 195 | 195 | return $this->xLibContainer->offsetGet($sClass); |
| 196 | - } |
|
| 197 | - catch(Exception|Throwable $e) |
|
| 196 | + } catch(Exception|Throwable $e) |
|
| 198 | 197 | { |
| 199 | 198 | $xLogger = $this->g(LoggerInterface::class); |
| 200 | 199 | $xTranslator = $this->g(Translator::class); |