Passed
Push — main ( 652a21...525366 )
by Thierry
03:56
created
jaxon-core/src/Script/CallFactory.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,8 +50,7 @@
 block discarded – undo
50 50
     public function rq(string $sClassName = ''): ?JxnCall
51 51
     {
52 52
         $sClassName = trim($sClassName);
53
-        return $sClassName === '' ? $this->cdi->getFunctionRequestFactory() :
54
-            $this->cdi->getComponentRequestFactory($sClassName);
53
+        return $sClassName === '' ? $this->cdi->getFunctionRequestFactory() : $this->cdi->getComponentRequestFactory($sClassName);
55 54
     }
56 55
 
57 56
     /**
Please login to merge, or discard this patch.
jaxon-core/src/Di/Traits/ComponentTrait.php 2 patches
Spacing   +12 added lines, -13 removed lines patch added patch discarded remove patch
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
      */
137 137
     private function discoverComponent(string $sClassName)
138 138
     {
139
-        if(!isset($this->aComponents[$sClassName]))
139
+        if (!isset($this->aComponents[$sClassName]))
140 140
         {
141 141
             $xRegistry = $this->cn()->g(ComponentRegistry::class);
142 142
             $xRegistry->updateHash(false); // Disable hash calculation.
143 143
             $aOptions = $xRegistry->getNamespaceComponentOptions($sClassName);
144
-            if($aOptions !== null)
144
+            if ($aOptions !== null)
145 145
             {
146 146
                 $this->registerComponent($sClassName, $aOptions);
147 147
             }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
                 $xRegistry->registerComponentsInDirectories();
153 153
             }
154 154
         }
155
-        if(!isset($this->aComponents[$sClassName]))
155
+        if (!isset($this->aComponents[$sClassName]))
156 156
         {
157 157
             throw new SetupException($this->cn()->g(Translator::class)
158 158
                 ->trans('errors.class.invalid', ['name' => $sClassName]));
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     public function getCallableObjects(): array
169 169
     {
170 170
         $aCallableObjects = [];
171
-        foreach($this->aComponents as $sClassName => $_)
171
+        foreach ($this->aComponents as $sClassName => $_)
172 172
         {
173 173
             $aCallableObjects[$sClassName] = $this->makeCallableObject($sClassName);
174 174
         }
@@ -219,12 +219,12 @@  discard block
 block discarded – undo
219 219
     {
220 220
         /** @var Config|null */
221 221
         $xPackageConfig = $aOptions['config'] ?? null;
222
-        if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false))
222
+        if ($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false))
223 223
         {
224 224
             return null;
225 225
         }
226 226
         $sReaderId = $xPackageConfig->getOption('metadata.reader');
227
-        if(!in_array($sReaderId, ['attributes', 'annotations']))
227
+        if (!in_array($sReaderId, ['attributes', 'annotations']))
228 228
         {
229 229
             return null;
230 230
         }
@@ -234,23 +234,23 @@  discard block
 block discarded – undo
234 234
         $xMetadata = null;
235 235
         $xMetadataCache = null;
236 236
         $xConfig = $di->config();
237
-        if($xConfig->getAppOption('metadata.cache.enabled', false))
237
+        if ($xConfig->getAppOption('metadata.cache.enabled', false))
238 238
         {
239
-            if(!$di->h('jaxon_metadata_cache_dir'))
239
+            if (!$di->h('jaxon_metadata_cache_dir'))
240 240
             {
241 241
                 $sCacheDir = $xConfig->getAppOption('metadata.cache.dir');
242 242
                 $di->val('jaxon_metadata_cache_dir', $sCacheDir);
243 243
             }
244 244
             $xMetadataCache = $di->getMetadataCache();
245 245
             $xMetadata = $xMetadataCache->read($xReflectionClass->getName());
246
-            if($xMetadata !== null)
246
+            if ($xMetadata !== null)
247 247
             {
248 248
                 return $xMetadata;
249 249
             }
250 250
         }
251 251
 
252 252
         $aProperties = array_map(fn($xProperty) => $xProperty->getName(),
253
-            $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC |
253
+            $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC|
254 254
                 ReflectionProperty::IS_PROTECTED));
255 255
         $aMethods = $this->getPublicMethods($xReflectionClass);
256 256
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         $xMetadata = $xMetadataReader->getAttributes($xInput);
260 260
 
261 261
         // Try to save the metadata in the cache
262
-        if($xMetadataCache !== null && $xMetadata !== null)
262
+        if ($xMetadataCache !== null && $xMetadata !== null)
263 263
         {
264 264
             $xMetadataCache->save($xReflectionClass->getName(), $xMetadata);
265 265
         }
@@ -277,8 +277,7 @@  discard block
 block discarded – undo
277 277
         array $aOptions): ComponentOptions
278 278
     {
279 279
         $xMetadata = $this->getComponentMetadata($xReflectionClass, $aOptions);
280
-        return !$xMetadata ? new ComponentOptions($aOptions) :
281
-            new ComponentOptions($aOptions, $xMetadata->isExcluded(),
280
+        return !$xMetadata ? new ComponentOptions($aOptions) : new ComponentOptions($aOptions, $xMetadata->isExcluded(),
282 281
             $xMetadata->getProtectedMethods(), $xMetadata->getProperties());
283 282
     }
284 283
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -144,8 +144,7 @@
 block discarded – undo
144 144
             if($aOptions !== null)
145 145
             {
146 146
                 $this->registerComponent($sClassName, $aOptions);
147
-            }
148
-            else // if(!isset($this->aComponents[$sClassName]))
147
+            } else // if(!isset($this->aComponents[$sClassName]))
149 148
             {
150 149
                 // The component was not found in a registered namespace. We need to parse all
151 150
                 // the directories to be able to find a component registered without a namespace.
Please login to merge, or discard this patch.
jaxon-core/src/Di/ComponentContainer.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@
 block discarded – undo
138 138
      */
139 139
     public function val(string $sKey, $xValue)
140 140
     {
141
-       $this->xContainer->offsetSet($sKey, $xValue);
141
+        $this->xContainer->offsetSet($sKey, $xValue);
142 142
     }
143 143
 
144 144
     /**
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -186,13 +186,13 @@  discard block
 block discarded – undo
186 186
         try
187 187
         {
188 188
             // Make sure the registered class exists
189
-            if(isset($aOptions['include']))
189
+            if (isset($aOptions['include']))
190 190
             {
191 191
                 require_once $aOptions['include'];
192 192
             }
193 193
             $xReflectionClass = new ReflectionClass($sClassName);
194 194
             // Check if the class is registrable
195
-            if(!$xReflectionClass->isInstantiable())
195
+            if (!$xReflectionClass->isInstantiable())
196 196
             {
197 197
                 return;
198 198
             }
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
             $this->_saveClassOptions($sClassName, $aOptions);
201 201
             $this->val($this->getReflectionClassKey($sClassName), $xReflectionClass);
202 202
             // Register the user class, but only if the user didn't already.
203
-            if(!$this->has($sClassName))
203
+            if (!$this->has($sClassName))
204 204
             {
205 205
                 $this->set($sClassName, function() use($sClassName) {
206 206
                     return $this->make($this->get($this->getReflectionClassKey($sClassName)));
207 207
                 });
208 208
             }
209 209
         }
210
-        catch(ReflectionException $e)
210
+        catch (ReflectionException $e)
211 211
         {
212 212
             throw new SetupException($this->cn()->g(Translator::class)
213 213
                 ->trans('errors.class.invalid', ['name' => $sClassName]));
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     {
227 227
         $sComponentObject = $this->getCallableObjectKey($sClassName);
228 228
         // Prevent duplication. It's important not to use the class name here.
229
-        if($this->has($sComponentObject))
229
+        if ($this->has($sComponentObject))
230 230
         {
231 231
             return;
232 232
         }
@@ -252,14 +252,14 @@  discard block
 block discarded – undo
252 252
 
253 253
         // Initialize the user class instance
254 254
         $this->xContainer->extend($sClassName, function($xClassInstance) use($sClassName) {
255
-            if($xClassInstance instanceof AbstractComponent)
255
+            if ($xClassInstance instanceof AbstractComponent)
256 256
             {
257 257
                 $xHelper = $this->get($this->getCallableHelperKey($sClassName));
258 258
                 $xHelper->xTarget = $this->xTarget;
259 259
 
260 260
                 // Call the protected "initComponent()" method of the Component class.
261 261
                 $cSetter = function($di, $xHelper) {
262
-                    $this->initComponent($di, $xHelper);  // "$this" here refers to the Component class.
262
+                    $this->initComponent($di, $xHelper); // "$this" here refers to the Component class.
263 263
                 };
264 264
                 $cSetter = $cSetter->bindTo($xClassInstance, $xClassInstance);
265 265
                 call_user_func($cSetter, $this->di, $xHelper);
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
             /** @var CallableObject */
275 275
             $xCallableObject = $this->get($this->getCallableObjectKey($sClassName));
276 276
             $xCallableObject->setDiClassAttributes($xClassInstance);
277
-            if($this->xTarget !== null)
277
+            if ($this->xTarget !== null)
278 278
             {
279 279
                 $sMethodName = $this->xTarget->getMethodName();
280 280
                 $xCallableObject->setDiMethodAttributes($xClassInstance, $sMethodName);
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     private function registerRequestFactory(string $sClassName, string $sFactoryKey)
351 351
     {
352 352
         $this->xContainer->offsetSet($sFactoryKey, function() use($sClassName) {
353
-            if(!($xCallable = $this->makeCallableObject($sClassName)))
353
+            if (!($xCallable = $this->makeCallableObject($sClassName)))
354 354
             {
355 355
                 return null;
356 356
             }
@@ -380,13 +380,13 @@  discard block
 block discarded – undo
380 380
     public function getComponentRequestFactory(string $sClassName): ?JxnCall
381 381
     {
382 382
         $sClassName = trim($sClassName, " \t");
383
-        if($sClassName === '')
383
+        if ($sClassName === '')
384 384
         {
385 385
             return null;
386 386
         }
387 387
 
388 388
         $sFactoryKey = $this->getRequestFactoryKey($sClassName);
389
-        if(!$this->has($sFactoryKey))
389
+        if (!$this->has($sFactoryKey))
390 390
         {
391 391
             $this->registerRequestFactory($sClassName, $sFactoryKey);
392 392
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -206,8 +206,7 @@
 block discarded – undo
206 206
                     return $this->make($this->get($this->getReflectionClassKey($sClassName)));
207 207
                 });
208 208
             }
209
-        }
210
-        catch(ReflectionException $e)
209
+        } catch(ReflectionException $e)
211 210
         {
212 211
             throw new SetupException($this->cn()->g(Translator::class)
213 212
                 ->trans('errors.class.invalid', ['name' => $sClassName]));
Please login to merge, or discard this patch.
jaxon-core/src/App/Metadata/MetadataCache.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@
 block discarded – undo
51 51
         $sMetadataVar = '$xMetadata';
52 52
         $sDataVar = '$xData';
53 53
         $aCalls = ["$sMetadataVar = new " . Metadata::class . '();'];
54
-        foreach($xMetadata->getAttributes() as $sType => $aValues)
54
+        foreach ($xMetadata->getAttributes() as $sType => $aValues)
55 55
         {
56
-            foreach($aValues as $sMethod => $xData)
56
+            foreach ($aValues as $sMethod => $xData)
57 57
             {
58 58
                 $aCalls[] = "$sDataVar = {$sMetadataVar}->{$sType}('{$sMethod}');";
59
-                foreach($xData->encode($sDataVar) as $sCall)
59
+                foreach ($xData->encode($sDataVar) as $sCall)
60 60
                 {
61 61
                     $aCalls[] = $sCall;
62 62
                 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Metadata/Data/ContainerData.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Request/CallableClass/ComponentOptions.php 1 patch
Spacing   +21 added lines, -23 removed lines patch added patch discarded remove patch
@@ -88,29 +88,29 @@  discard block
 block discarded – undo
88 88
         array $aProtectedMethods = [], array $aProperties = [])
89 89
     {
90 90
         $this->bExcluded = $bExcluded || (bool)($aOptions['excluded'] ?? false);
91
-        if($this->bExcluded)
91
+        if ($this->bExcluded)
92 92
         {
93 93
             return;
94 94
         }
95 95
 
96 96
         $sSeparator = $aOptions['separator'];
97
-        if($sSeparator === '_' || $sSeparator === '.')
97
+        if ($sSeparator === '_' || $sSeparator === '.')
98 98
         {
99 99
             $this->sSeparator = $sSeparator;
100 100
         }
101 101
         $this->addProtectedMethods($aOptions['protected']);
102 102
         $this->addProtectedMethods($aProtectedMethods);
103 103
 
104
-        foreach($aOptions['functions'] as $sNames => $aFunctionOptions)
104
+        foreach ($aOptions['functions'] as $sNames => $aFunctionOptions)
105 105
         {
106 106
             // Names are in a comma-separated list.
107 107
             $aFunctionNames = explode(',', $sNames);
108
-            foreach($aFunctionNames as $sFunctionName)
108
+            foreach ($aFunctionNames as $sFunctionName)
109 109
             {
110 110
                 $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
111 111
             }
112 112
         }
113
-        foreach($aProperties as $sFunctionName => $aFunctionOptions)
113
+        foreach ($aProperties as $sFunctionName => $aFunctionOptions)
114 114
         {
115 115
             $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
116 116
         }
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
      */
124 124
     private function addProtectedMethods(array|string $xMethods): void
125 125
     {
126
-        if(!is_array($xMethods))
126
+        if (!is_array($xMethods))
127 127
         {
128 128
             $this->aProtectedMethods[trim((string)$xMethods)] = true;
129 129
             return;
130 130
         }
131 131
 
132
-        foreach($xMethods as $sMethod)
132
+        foreach ($xMethods as $sMethod)
133 133
         {
134 134
             $this->aProtectedMethods[trim((string)$sMethod)] = true;
135 135
         }
@@ -206,17 +206,17 @@  discard block
 block discarded – undo
206 206
      */
207 207
     private function setHookMethods(array &$aHookMethods, $xValue): void
208 208
     {
209
-        foreach($xValue as $sCalledMethod => $xMethodToCall)
209
+        foreach ($xValue as $sCalledMethod => $xMethodToCall)
210 210
         {
211
-            if(!isset($aHookMethods[$sCalledMethod]))
211
+            if (!isset($aHookMethods[$sCalledMethod]))
212 212
             {
213 213
                 $aHookMethods[$sCalledMethod] = [];
214 214
             }
215
-            if(is_array($xMethodToCall))
215
+            if (is_array($xMethodToCall))
216 216
             {
217 217
                 $aHookMethods[$sCalledMethod] = array_merge($aHookMethods[$sCalledMethod], $xMethodToCall);
218 218
             }
219
-            elseif(is_string($xMethodToCall))
219
+            elseif (is_string($xMethodToCall))
220 220
             {
221 221
                 $aHookMethods[$sCalledMethod][] = $xMethodToCall;
222 222
             }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      */
242 242
     private function addOption(string $sName, $xValue): void
243 243
     {
244
-        switch($sName)
244
+        switch ($sName)
245 245
         {
246 246
         // Set the methods to call before processing the request
247 247
         case '__before':
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
      */
270 270
     private function _addJsArrayOption(string $sFunctionName, string $sOptionName, $xOptionValue): void
271 271
     {
272
-        if(is_string($xOptionValue))
272
+        if (is_string($xOptionValue))
273 273
         {
274 274
             $xOptionValue = [$xOptionValue];
275 275
         }
276
-        if(!is_array($xOptionValue))
276
+        if (!is_array($xOptionValue))
277 277
         {
278 278
             return; // Do not save.
279 279
         }
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
      */
304 304
     private function addJsOption(string $sFunctionName, string $sOptionName, $xOptionValue): void
305 305
     {
306
-        switch($sOptionName)
306
+        switch ($sOptionName)
307 307
         {
308 308
         case 'excluded':
309
-            if((bool)$xOptionValue)
309
+            if ((bool)$xOptionValue)
310 310
             {
311 311
                 $this->addProtectedMethods($sFunctionName);
312 312
             }
@@ -330,12 +330,11 @@  discard block
 block discarded – undo
330 330
      */
331 331
     private function addFunctionOptions(string $sFunctionName, array $aFunctionOptions): void
332 332
     {
333
-        foreach($aFunctionOptions as $sOptionName => $xOptionValue)
333
+        foreach ($aFunctionOptions as $sOptionName => $xOptionValue)
334 334
         {
335 335
             substr($sOptionName, 0, 2) === '__' ?
336 336
                 // Options for PHP classes. They start with "__".
337
-                $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) :
338
-                // Options for javascript code.
337
+                $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : // Options for javascript code.
339 338
                 $this->addJsOption($sFunctionName, $sOptionName, $xOptionValue);
340 339
         }
341 340
     }
@@ -351,16 +350,15 @@  discard block
 block discarded – undo
351 350
         $aOptions = array_merge($this->aJsOptions['*'] ?? []); // Clone the array
352 351
         // Then add the method options.
353 352
         $aMethodOptions = $this->aJsOptions[$sMethodName] ?? [];
354
-        foreach($aMethodOptions as $sOptionName => $xOptionValue)
353
+        foreach ($aMethodOptions as $sOptionName => $xOptionValue)
355 354
         {
356 355
             // For databags and callbacks, merge the values in a single array.
357 356
             // For all the other options, keep the last value.
358 357
             $aOptions[$sOptionName] = !in_array($sOptionName, ['bags', 'callback']) ?
359
-                $xOptionValue :
360
-                array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue));
358
+                $xOptionValue : array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue));
361 359
         }
362 360
         // Since callbacks are js object names, they need a special formatting.
363
-        if(isset($aOptions['callback']))
361
+        if (isset($aOptions['callback']))
364 362
         {
365 363
             $aOptions['callback'] = str_replace('"', '', json_encode($aOptions['callback']));
366 364
         }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Request/CallableClass/CallableClassPlugin.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,8 +85,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Manager/PackageManager.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -62,25 +62,25 @@  discard block
 block discarded – undo
62 62
     private function updateContainer(Config $xConfig): void
63 63
     {
64 64
         $aOptions = $xConfig->getOption('container.set', []);
65
-        foreach($aOptions as $xKey => $xValue)
65
+        foreach ($aOptions as $xKey => $xValue)
66 66
         {
67 67
             // The key is the class name. It must be a string.
68 68
             $this->di->set((string)$xKey, $xValue);
69 69
         }
70 70
         $aOptions = $xConfig->getOption('container.val', []);
71
-        foreach($aOptions as $xKey => $xValue)
71
+        foreach ($aOptions as $xKey => $xValue)
72 72
         {
73 73
             // The key is the class name. It must be a string.
74 74
             $this->di->val((string)$xKey, $xValue);
75 75
         }
76 76
         $aOptions = $xConfig->getOption('container.auto', []);
77
-        foreach($aOptions as $xValue)
77
+        foreach ($aOptions as $xValue)
78 78
         {
79 79
             // The key is the class name. It must be a string.
80 80
             $this->di->auto((string)$xValue);
81 81
         }
82 82
         $aOptions = $xConfig->getOption('container.alias', []);
83
-        foreach($aOptions as $xKey => $xValue)
83
+        foreach ($aOptions as $xKey => $xValue)
84 84
         {
85 85
             // The key is the class name. It must be a string.
86 86
             $this->di->alias((string)$xKey, (string)$xValue);
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
      */
99 99
     private function registerCallables(array $aOptions, string $sCallableType): void
100 100
     {
101
-        foreach($aOptions as $xKey => $xValue)
101
+        foreach ($aOptions as $xKey => $xValue)
102 102
         {
103
-            if(is_integer($xKey) && is_string($xValue))
103
+            if (is_integer($xKey) && is_string($xValue))
104 104
             {
105 105
                 // Register a function without options
106 106
                 $this->xPluginManager->registerCallable($sCallableType, $xValue);
107 107
                 continue;
108 108
             }
109 109
 
110
-            if(is_string($xKey) && (is_array($xValue) || is_string($xValue)))
110
+            if (is_string($xKey) && (is_array($xValue) || is_string($xValue)))
111 111
             {
112 112
                 // Register a function with options
113 113
                 $this->xPluginManager->registerCallable($sCallableType, $xKey, $xValue);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     private function registerExceptionHandlers(Config $xConfig): void
126 126
     {
127
-        foreach($xConfig->getOption('exceptions', []) as $sExClass => $xExHandler)
127
+        foreach ($xConfig->getOption('exceptions', []) as $sExClass => $xExHandler)
128 128
         {
129 129
             $this->xCallbackManager->error($xExHandler, is_string($sExClass) ? $sExClass : '');
130 130
         }
@@ -147,20 +147,20 @@  discard block
 block discarded – undo
147 147
         // key of the array item, a string as the value of an entry without a key,
148 148
         // or set with the key $sOptionKey in an array entry without a key.
149 149
         $aCallables = [];
150
-        foreach($xConfig->getOption($sOptionName, []) as $xKey => $xValue)
150
+        foreach ($xConfig->getOption($sOptionName, []) as $xKey => $xValue)
151 151
         {
152
-            if(is_string($xKey))
152
+            if (is_string($xKey))
153 153
             {
154 154
                 $aCallables[$xKey] = $xValue;
155 155
                 continue;
156 156
             }
157
-            if(is_string($xValue))
157
+            if (is_string($xValue))
158 158
             {
159 159
                 $aCallables[] = $xValue;
160 160
                 continue;
161 161
             }
162 162
 
163
-            if(is_array($xValue) && isset($xValue[$sOptionKey]))
163
+            if (is_array($xValue) && isset($xValue[$sOptionKey]))
164 164
             {
165 165
                 $aCallables[$xValue[$sOptionKey]] = $xValue;
166 166
             }
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
     {
216 216
         // $this->aPackages contains packages config file paths.
217 217
         $aLibOptions = $sClassName::config();
218
-        if(is_string($aLibOptions))
218
+        if (is_string($aLibOptions))
219 219
         {
220 220
             // A string is supposed to be the path to a config file.
221 221
             $aLibOptions = $this->xConfigManager->read($aLibOptions);
222 222
         }
223
-        elseif(!is_array($aLibOptions))
223
+        elseif (!is_array($aLibOptions))
224 224
         {
225 225
             // Otherwise, anything else than an array is not accepted.
226 226
             $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]);
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     public function registerPackage(string $sClassName, array $aUserOptions = []): void
244 244
     {
245 245
         $sClassName = trim($sClassName, '\\ ');
246
-        if(!is_subclass_of($sClassName, AbstractPackage::class))
246
+        if (!is_subclass_of($sClassName, AbstractPackage::class))
247 247
         {
248 248
             $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]);
249 249
             throw new SetupException($sMessage);
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 
288 288
         // Register packages
289 289
         $aPackageConfig = $xAppConfig->getOption('packages', []);
290
-        foreach($aPackageConfig as $xKey => $xValue)
290
+        foreach ($aPackageConfig as $xKey => $xValue)
291 291
         {
292
-            if(is_integer($xKey) && is_string($xValue))
292
+            if (is_integer($xKey) && is_string($xValue))
293 293
             {
294 294
                 // Register a package without options
295 295
                 $sClassName = $xValue;
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
                 continue;
298 298
             }
299 299
 
300
-            if(is_string($xKey) && is_array($xValue))
300
+            if (is_string($xKey) && is_array($xValue))
301 301
             {
302 302
                 // Register a package with options
303 303
                 $sClassName = $xKey;
Please login to merge, or discard this patch.
jaxon-core/templates/callables/object.js.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,18 +2,18 @@
 block discarded – undo
2 2
 <?php
3 3
 // An exported PHP class can have the same name as a subdir in the same parent dir.
4 4
 // So, we must make sure that embedded js objects do not already exist, before we create them.
5
-if(strpos($sJsClass, '.') !== false): ?>
5
+if (strpos($sJsClass, '.') !== false): ?>
6 6
 if(<?php echo $sJsClass ?> === undefined) {
7 7
     <?php echo $sJsClass ?> = {};
8 8
 }
9 9
 <?php else: ?>
10 10
 <?php echo $sJsClass ?> = {};
11 11
 <?php endif ?>
12
-<?php foreach($this->aMethods as $aMethod): ?>
12
+<?php foreach ($this->aMethods as $aMethod): ?>
13 13
 <?php echo $sJsClass ?>.<?php echo $aMethod['name'] ?> = function() {
14 14
     return jaxon.request({ type: 'class', name: '<?php echo $this->sClass ?>', method: '<?php
15 15
         echo $aMethod['name'] ?>' }, { parameters: arguments<?php
16
-        foreach($aMethod['options'] as $sKey => $sValue): ?>, <?php
16
+        foreach ($aMethod['options'] as $sKey => $sValue): ?>, <?php
17 17
         echo $sKey ?>: <?php echo $sValue ?><?php endforeach ?> });
18 18
 };
19 19
 <?php endforeach;
Please login to merge, or discard this patch.