Passed
Push — main ( 18c043...2ebc4f )
by Thierry
05:47 queued 40s
created
src/Plugin/Request/CallableClass/CallableRepository.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
         // The methods of the CallableClass class must not be exported
112 112
         $xCallableClass = new ReflectionClass(CallableClass::class);
113
-        foreach($xCallableClass->getMethods(ReflectionMethod::IS_PUBLIC) as $xMethod)
113
+        foreach ($xCallableClass->getMethods(ReflectionMethod::IS_PUBLIC) as $xMethod)
114 114
         {
115 115
             $this->aProtectedMethods[] = $xMethod->getName();
116 116
         }
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
      */
182 182
     public function makeClassOptions(string $sClassName, array $aClassOptions, array $aDirectoryOptions): array
183 183
     {
184
-        foreach($this->aDefaultClassOptions as $sOption => $xValue)
184
+        foreach ($this->aDefaultClassOptions as $sOption => $xValue)
185 185
         {
186
-            if(!isset($aClassOptions[$sOption]))
186
+            if (!isset($aClassOptions[$sOption]))
187 187
             {
188 188
                 $aClassOptions[$sOption] = $xValue;
189 189
             }
190 190
         }
191
-        $aClassOptions['excluded'] = (bool)($aClassOptions['excluded'] ?? false); // Convert to bool.
192
-        if(is_string($aClassOptions['protected']))
191
+        $aClassOptions['excluded'] = (bool) ($aClassOptions['excluded'] ?? false); // Convert to bool.
192
+        if (is_string($aClassOptions['protected']))
193 193
         {
194 194
             $aClassOptions['protected'] = [$aClassOptions['protected']]; // Convert to array.
195 195
         }
@@ -200,25 +200,25 @@  discard block
 block discarded – undo
200 200
             $aDirectoryOptions['classes']['*'] ?? [], // Options for all classes
201 201
             $aDirectoryOptions['classes'][$sClassName] ?? [], // Options for this specific class
202 202
         ];
203
-        foreach($aOptionGroups as $aOptionGroup)
203
+        foreach ($aOptionGroups as $aOptionGroup)
204 204
         {
205
-            if(isset($aOptionGroup['separator']))
205
+            if (isset($aOptionGroup['separator']))
206 206
             {
207
-                $aClassOptions['separator'] = (string)$aOptionGroup['separator'];
207
+                $aClassOptions['separator'] = (string) $aOptionGroup['separator'];
208 208
             }
209
-            if(isset($aOptionGroup['excluded']))
209
+            if (isset($aOptionGroup['excluded']))
210 210
             {
211
-                $aClassOptions['excluded'] = (bool)$aOptionGroup['excluded'];
211
+                $aClassOptions['excluded'] = (bool) $aOptionGroup['excluded'];
212 212
             }
213
-            if(isset($aOptionGroup['protected']))
213
+            if (isset($aOptionGroup['protected']))
214 214
             {
215
-                if(is_string($aOptionGroup['protected']))
215
+                if (is_string($aOptionGroup['protected']))
216 216
                 {
217 217
                     $aOptionGroup['protected'] = [$aOptionGroup['protected']]; // Convert to array.
218 218
                 }
219 219
                 $aClassOptions['protected'] = array_merge($aClassOptions['protected'], $aOptionGroup['protected']);
220 220
             }
221
-            if(isset($aOptionGroup['functions']))
221
+            if (isset($aOptionGroup['functions']))
222 222
             {
223 223
                 $aClassOptions['functions'] = array_merge($aClassOptions['functions'], $aOptionGroup['functions']);
224 224
             }
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
     private function getNamespaceClassOptions(string $sClassName)
265 265
     {
266 266
         // Find the corresponding namespace
267
-        foreach($this->aNamespaceOptions as $sNamespace => $aOptions)
267
+        foreach ($this->aNamespaceOptions as $sNamespace => $aOptions)
268 268
         {
269 269
             // Check if the namespace matches the class.
270
-            if(strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0)
270
+            if (strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0)
271 271
             {
272 272
                 // Save the class options
273 273
                 $this->aClasses[$sClassName] = $this->makeClassOptions($sClassName,
@@ -288,17 +288,17 @@  discard block
 block discarded – undo
288 288
     public function getClassOptions(string $sClassName): array
289 289
     {
290 290
         // Find options for a class registered with namespace.
291
-        if(!isset($this->aClasses[$sClassName]))
291
+        if (!isset($this->aClasses[$sClassName]))
292 292
         {
293 293
             $this->getNamespaceClassOptions($sClassName);
294
-            if(!isset($this->aClasses[$sClassName]))
294
+            if (!isset($this->aClasses[$sClassName]))
295 295
             {
296 296
                 // Find options for a class registered without namespace.
297 297
                 // We then need to parse all classes to be able to find one.
298 298
                 $this->di->getCallableRegistry()->parseDirectories();
299 299
             }
300 300
         }
301
-        if(isset($this->aClasses[$sClassName]))
301
+        if (isset($this->aClasses[$sClassName]))
302 302
         {
303 303
             return $this->aClasses[$sClassName];
304 304
         }
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
     public function getCallableObjects(): array
328 328
     {
329 329
         $aCallableObjects = [];
330
-        foreach($this->aClasses as $sClassName => $aOptions)
330
+        foreach ($this->aClasses as $sClassName => $aOptions)
331 331
         {
332 332
             $this->di->registerCallableClass($sClassName, $aOptions);
333 333
             $aCallableObjects[$sClassName] = $this->di->getCallableObject($sClassName);
Please login to merge, or discard this patch.
src/Plugin/Request/CallableClass/CallableObjectOptions.php 2 patches
Switch Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -240,30 +240,30 @@  discard block
 block discarded – undo
240 240
         switch($sName)
241 241
         {
242 242
         // Set the separator
243
-        case 'separator':
244
-            $this->setSeparator((string)$xValue);
245
-            break;
246
-        case 'excluded':
247
-            $this->bExcluded = (bool)$xValue;
248
-            break;
249
-        // Set the protected methods
250
-        case 'protected':
251
-            $this->addProtectedMethods($xValue);
252
-            break;
253
-        // Set the methods to call before processing the request
254
-        case '__before':
255
-            $this->setHookMethods($this->aBeforeMethods, $xValue);
256
-            break;
257
-        // Set the methods to call after processing the request
258
-        case '__after':
259
-            $this->setHookMethods($this->aAfterMethods, $xValue);
260
-            break;
261
-        // Set the attributes to inject in the callable object
262
-        case '__di':
263
-            $this->addDiOption($xValue);
264
-            break;
265
-        default:
266
-            break;
243
+            case 'separator':
244
+                $this->setSeparator((string)$xValue);
245
+                break;
246
+            case 'excluded':
247
+                $this->bExcluded = (bool)$xValue;
248
+                break;
249
+            // Set the protected methods
250
+            case 'protected':
251
+                $this->addProtectedMethods($xValue);
252
+                break;
253
+            // Set the methods to call before processing the request
254
+            case '__before':
255
+                $this->setHookMethods($this->aBeforeMethods, $xValue);
256
+                break;
257
+            // Set the methods to call after processing the request
258
+            case '__after':
259
+                $this->setHookMethods($this->aAfterMethods, $xValue);
260
+                break;
261
+            // Set the attributes to inject in the callable object
262
+            case '__di':
263
+                $this->addDiOption($xValue);
264
+                break;
265
+            default:
266
+                break;
267 267
         }
268 268
     }
269 269
 
@@ -311,20 +311,20 @@  discard block
 block discarded – undo
311 311
     {
312 312
         switch($sOptionName)
313 313
         {
314
-        case 'excluded':
315
-            if((bool)$xOptionValue)
316
-            {
317
-                $this->addProtectedMethods($sFunctionName);
318
-            }
319
-            break;
320
-        // For databags, all the value are merged in a single array.
321
-        case 'bags':
322
-            $this->_addJsArrayOption($sFunctionName, $sOptionName, $xOptionValue);
323
-            return;
324
-        // For all the other options, including callback, only the last value is kept.
325
-        case 'callback':
326
-        default:
327
-            $this->_setJsOption($sFunctionName, $sOptionName, $xOptionValue);
314
+            case 'excluded':
315
+                if((bool)$xOptionValue)
316
+                {
317
+                    $this->addProtectedMethods($sFunctionName);
318
+                }
319
+                break;
320
+            // For databags, all the value are merged in a single array.
321
+            case 'bags':
322
+                $this->_addJsArrayOption($sFunctionName, $sOptionName, $xOptionValue);
323
+                return;
324
+            // For all the other options, including callback, only the last value is kept.
325
+            case 'callback':
326
+            default:
327
+                $this->_setJsOption($sFunctionName, $sOptionName, $xOptionValue);
328 328
         }
329 329
     }
330 330
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -26 removed lines patch added patch discarded remove patch
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     public function __construct(array $aOptions, array $aAnnotations)
82 82
     {
83 83
         [$bExcluded, $aAnnotationOptions, $aAnnotationProtected] = $aAnnotations;
84
-        $this->bExcluded = $bExcluded || (bool)($aOptions['excluded'] ?? false);
85
-        if($this->bExcluded)
84
+        $this->bExcluded = $bExcluded || (bool) ($aOptions['excluded'] ?? false);
85
+        if ($this->bExcluded)
86 86
         {
87 87
             return;
88 88
         }
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
         $this->addProtectedMethods($aOptions['protected']);
92 92
         $this->addProtectedMethods($aAnnotationProtected);
93 93
 
94
-        foreach($aOptions['functions'] as $sNames => $aFunctionOptions)
94
+        foreach ($aOptions['functions'] as $sNames => $aFunctionOptions)
95 95
         {
96 96
             $aFunctionNames = explode(',', $sNames); // Names are in comma-separated list.
97
-            foreach($aFunctionNames as $sFunctionName)
97
+            foreach ($aFunctionNames as $sFunctionName)
98 98
             {
99 99
                 $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
100 100
             }
101 101
         }
102
-        foreach($aAnnotationOptions as $sFunctionName => $aFunctionOptions)
102
+        foreach ($aAnnotationOptions as $sFunctionName => $aFunctionOptions)
103 103
         {
104 104
             $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
105 105
         }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      */
113 113
     private function setSeparator(string $sSeparator)
114 114
     {
115
-        if($sSeparator === '_' || $sSeparator === '.')
115
+        if ($sSeparator === '_' || $sSeparator === '.')
116 116
         {
117 117
             $this->sSeparator = $sSeparator;
118 118
         }
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
      */
126 126
     private function addProtectedMethods($xMethods)
127 127
     {
128
-        if(!is_array($xMethods))
128
+        if (!is_array($xMethods))
129 129
         {
130
-            $this->aProtectedMethods[trim((string)$xMethods)] = true;
130
+            $this->aProtectedMethods[trim((string) $xMethods)] = true;
131 131
             return;
132 132
         }
133
-        foreach($xMethods as $sMethod)
133
+        foreach ($xMethods as $sMethod)
134 134
         {
135
-            $this->aProtectedMethods[trim((string)$sMethod)] = true;
135
+            $this->aProtectedMethods[trim((string) $sMethod)] = true;
136 136
         }
137 137
     }
138 138
 
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
      */
207 207
     private function setHookMethods(array &$aHookMethods, $xValue)
208 208
     {
209
-        foreach($xValue as $sCalledMethod => $xMethodToCall)
209
+        foreach ($xValue as $sCalledMethod => $xMethodToCall)
210 210
         {
211
-            if(is_array($xMethodToCall))
211
+            if (is_array($xMethodToCall))
212 212
             {
213 213
                 $aHookMethods[$sCalledMethod] = $xMethodToCall;
214 214
             }
215
-            elseif(is_string($xMethodToCall))
215
+            elseif (is_string($xMethodToCall))
216 216
             {
217 217
                 $aHookMethods[$sCalledMethod] = [$xMethodToCall];
218 218
             }
@@ -237,14 +237,14 @@  discard block
 block discarded – undo
237 237
      */
238 238
     public function addOption(string $sName, $xValue)
239 239
     {
240
-        switch($sName)
240
+        switch ($sName)
241 241
         {
242 242
         // Set the separator
243 243
         case 'separator':
244
-            $this->setSeparator((string)$xValue);
244
+            $this->setSeparator((string) $xValue);
245 245
             break;
246 246
         case 'excluded':
247
-            $this->bExcluded = (bool)$xValue;
247
+            $this->bExcluded = (bool) $xValue;
248 248
             break;
249 249
         // Set the protected methods
250 250
         case 'protected':
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
      */
277 277
     private function _addJsArrayOption(string $sFunctionName, string $sOptionName, $xOptionValue)
278 278
     {
279
-        if(is_string($xOptionValue))
279
+        if (is_string($xOptionValue))
280 280
         {
281 281
             $xOptionValue = [$xOptionValue];
282 282
         }
283
-        if(!is_array($xOptionValue))
283
+        if (!is_array($xOptionValue))
284 284
         {
285 285
             return; // Do not save.
286 286
         }
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
      */
310 310
     private function addJsOption(string $sFunctionName, string $sOptionName, $xOptionValue)
311 311
     {
312
-        switch($sOptionName)
312
+        switch ($sOptionName)
313 313
         {
314 314
         case 'excluded':
315
-            if((bool)$xOptionValue)
315
+            if ((bool) $xOptionValue)
316 316
             {
317 317
                 $this->addProtectedMethods($sFunctionName);
318 318
             }
@@ -336,12 +336,11 @@  discard block
 block discarded – undo
336 336
      */
337 337
     private function addFunctionOptions(string $sFunctionName, array $aFunctionOptions)
338 338
     {
339
-        foreach($aFunctionOptions as $sOptionName => $xOptionValue)
339
+        foreach ($aFunctionOptions as $sOptionName => $xOptionValue)
340 340
         {
341 341
             substr($sOptionName, 0, 2) === '__' ?
342 342
                 // Options for PHP classes. They start with "__".
343
-                $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) :
344
-                // Options for javascript code.
343
+                $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : // Options for javascript code.
345 344
                 $this->addJsOption($sFunctionName, $sOptionName, $xOptionValue);
346 345
         }
347 346
     }
@@ -357,12 +356,11 @@  discard block
 block discarded – undo
357 356
         $aOptions = array_merge($this->aJsOptions['*'] ?? []); // Clone the array
358 357
         // Then add the method options.
359 358
         $aMethodOptions = $this->aJsOptions[$sMethodName] ?? [];
360
-        foreach($aMethodOptions as $sOptionName => $xOptionValue)
359
+        foreach ($aMethodOptions as $sOptionName => $xOptionValue)
361 360
         {
362 361
             // For databags, merge the values in a single array.
363 362
             // For all the other options, including callback, keep the last value.
364
-            $aOptions[$sOptionName] = $sOptionName !== 'bags' ? $xOptionValue :
365
-                array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue));
363
+            $aOptions[$sOptionName] = $sOptionName !== 'bags' ? $xOptionValue : array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue));
366 364
         }
367 365
         return $aOptions;
368 366
     }
Please login to merge, or discard this patch.