Passed
Push — master ( ba3204...969249 )
by Thierry
02:16
created
src/Request/Handler/ParameterReader.php 3 patches
Switch Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -196,19 +196,19 @@
 block discarded – undo
196 196
         $sValue = substr($sValue, 1);
197 197
         switch($cType)
198 198
         {
199
-        case 'S':
200
-            $value = !$sValue ? '' : $sValue;
201
-            break;
202
-        case 'B':
203
-            $value = $this->convertStringToBool($sValue);
204
-            break;
205
-        case 'N':
206
-            $value = ($sValue == floor($sValue) ? (int)$sValue : (float)$sValue);
207
-            break;
208
-        case '*':
209
-        default:
210
-            $value = null;
211
-            break;
199
+            case 'S':
200
+                $value = !$sValue ? '' : $sValue;
201
+                break;
202
+            case 'B':
203
+                $value = $this->convertStringToBool($sValue);
204
+                break;
205
+            case 'N':
206
+                $value = ($sValue == floor($sValue) ? (int)$sValue : (float)$sValue);
207
+                break;
208
+            case '*':
209
+            default:
210
+                $value = null;
211
+                break;
212 212
         }
213 213
         return $value;
214 214
     }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -107,16 +107,16 @@  discard block
 block discarded – undo
107 107
         // Parameters are url encoded when uploading files
108 108
         $aServerParams = $this->di->getRequest()->getServerParams();
109 109
         $sContentType = '';
110
-        if(isset($aServerParams['CONTENT_TYPE']))
110
+        if (isset($aServerParams['CONTENT_TYPE']))
111 111
         {
112 112
             $sContentType = $aServerParams['CONTENT_TYPE'];
113 113
         }
114
-        elseif(isset($aServerParams['HTTP_CONTENT_TYPE']))
114
+        elseif (isset($aServerParams['HTTP_CONTENT_TYPE']))
115 115
         {
116 116
             $sContentType = $aServerParams['HTTP_CONTENT_TYPE'];
117 117
         }
118 118
         $sType = 'multipart/form-data';
119
-        if(strncmp($sContentType, $sType, strlen($sType)) !== 0)
119
+        if (strncmp($sContentType, $sType, strlen($sType)) !== 0)
120 120
         {
121 121
             $this->cParamDecoder = function($sParam) { return $sParam; };
122 122
             return;
@@ -137,19 +137,19 @@  discard block
 block discarded – undo
137 137
             return $sStr;
138 138
         };
139 139
         $sEncoding = $this->xConfigManager->getOption('core.encoding', '');
140
-        if(function_exists('iconv'))
140
+        if (function_exists('iconv'))
141 141
         {
142 142
             $this->cUtf8Decoder = function($sStr) use($sEncoding) {
143 143
                 return iconv("UTF-8", $sEncoding . '//TRANSLIT', $sStr);
144 144
             };
145 145
         }
146
-        elseif(function_exists('mb_convert_encoding'))
146
+        elseif (function_exists('mb_convert_encoding'))
147 147
         {
148 148
             $this->cUtf8Decoder = function($sStr) use($sEncoding) {
149 149
                 return mb_convert_encoding($sStr, $sEncoding, "UTF-8");
150 150
             };
151 151
         }
152
-        elseif($sEncoding === "ISO-8859-1")
152
+        elseif ($sEncoding === "ISO-8859-1")
153 153
         {
154 154
             $this->cUtf8Decoder = function($sStr) {
155 155
                 return utf8_decode($sStr);
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
      */
171 171
     private function convertStringToBool(string $sValue): bool
172 172
     {
173
-        if(strcasecmp($sValue, 'true') === 0)
173
+        if (strcasecmp($sValue, 'true') === 0)
174 174
         {
175 175
             return true;
176 176
         }
177
-        if(strcasecmp($sValue, 'false') === 0)
177
+        if (strcasecmp($sValue, 'false') === 0)
178 178
         {
179 179
             return false;
180 180
         }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
     {
195 195
         $cType = substr($sValue, 0, 1);
196 196
         $sValue = substr($sValue, 1);
197
-        switch($cType)
197
+        switch ($cType)
198 198
         {
199 199
         case 'S':
200 200
             $value = !$sValue ? '' : $sValue;
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
             $value = $this->convertStringToBool($sValue);
204 204
             break;
205 205
         case 'N':
206
-            $value = ($sValue == floor($sValue) ? (int)$sValue : (float)$sValue);
206
+            $value = ($sValue == floor($sValue) ? (int) $sValue : (float) $sValue);
207 207
             break;
208 208
         case '*':
209 209
         default:
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      */
223 223
     private function decodeRequestParameter(string $sParam)
224 224
     {
225
-        if($sParam === '')
225
+        if ($sParam === '')
226 226
         {
227 227
             return $sParam;
228 228
         }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
         $sParam = call_user_func($this->cParamDecoder, $sParam);
231 231
 
232 232
         $xJson = json_decode($sParam, true);
233
-        if($xJson !== null && $sParam != $xJson)
233
+        if ($xJson !== null && $sParam != $xJson)
234 234
         {
235 235
             return $xJson;
236 236
         }
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
         $aParams = [];
246 246
         $xRequest = $this->di->getRequest();
247 247
         $aBody = $xRequest->getParsedBody();
248
-        if(is_array($aBody))
248
+        if (is_array($aBody))
249 249
         {
250
-            if(isset($aBody['jxnargs']))
250
+            if (isset($aBody['jxnargs']))
251 251
             {
252 252
                 $aParams = $aBody['jxnargs'];
253 253
             }
@@ -255,13 +255,13 @@  discard block
 block discarded – undo
255 255
         else
256 256
         {
257 257
             $aParams = $xRequest->getQueryParams();
258
-            if(isset($aParams['jxnargs']))
258
+            if (isset($aParams['jxnargs']))
259 259
             {
260 260
                 $aParams = $aParams['jxnargs'];
261 261
             }
262 262
         }
263 263
         return array_map(function($sParam) {
264
-            return $this->decodeRequestParameter((string)$sParam);
264
+            return $this->decodeRequestParameter((string) $sParam);
265 265
         }, $aParams);
266 266
     }
267 267
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
      */
275 275
     private function decodeUtf8Parameter($xValue)
276 276
     {
277
-        if(is_string($xValue))
277
+        if (is_string($xValue))
278 278
         {
279 279
             return call_user_func($this->cUtf8Decoder, $xValue);
280 280
         }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
     private function decodeUtf8Parameters(array $aParams): array
295 295
     {
296 296
         $aValues = [];
297
-        foreach($aParams as $sKey => $xValue)
297
+        foreach ($aParams as $sKey => $xValue)
298 298
         {
299 299
             // Decode the key
300 300
             $sKey = call_user_func($this->cUtf8Decoder, $sKey);
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
     {
316 316
         $this->setParamDecoder();
317 317
         $aParams = $this->getRequestParameters();
318
-        if(!$this->xConfigManager->getOption('core.decode_utf8'))
318
+        if (!$this->xConfigManager->getOption('core.decode_utf8'))
319 319
         {
320 320
             return $aParams;
321 321
         }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -110,8 +110,7 @@  discard block
 block discarded – undo
110 110
         if(isset($aServerParams['CONTENT_TYPE']))
111 111
         {
112 112
             $sContentType = $aServerParams['CONTENT_TYPE'];
113
-        }
114
-        elseif(isset($aServerParams['HTTP_CONTENT_TYPE']))
113
+        } elseif(isset($aServerParams['HTTP_CONTENT_TYPE']))
115 114
         {
116 115
             $sContentType = $aServerParams['HTTP_CONTENT_TYPE'];
117 116
         }
@@ -142,20 +141,17 @@  discard block
 block discarded – undo
142 141
             $this->cUtf8Decoder = function($sStr) use($sEncoding) {
143 142
                 return iconv("UTF-8", $sEncoding . '//TRANSLIT', $sStr);
144 143
             };
145
-        }
146
-        elseif(function_exists('mb_convert_encoding'))
144
+        } elseif(function_exists('mb_convert_encoding'))
147 145
         {
148 146
             $this->cUtf8Decoder = function($sStr) use($sEncoding) {
149 147
                 return mb_convert_encoding($sStr, $sEncoding, "UTF-8");
150 148
             };
151
-        }
152
-        elseif($sEncoding === "ISO-8859-1")
149
+        } elseif($sEncoding === "ISO-8859-1")
153 150
         {
154 151
             $this->cUtf8Decoder = function($sStr) {
155 152
                 return utf8_decode($sStr);
156 153
             };
157
-        }
158
-        else
154
+        } else
159 155
         {
160 156
             throw new RequestException($this->xTranslator->trans('errors.request.conversion'));
161 157
         }
@@ -251,8 +247,7 @@  discard block
 block discarded – undo
251 247
             {
252 248
                 $aParams = $aBody['jxnargs'];
253 249
             }
254
-        }
255
-        else
250
+        } else
256 251
         {
257 252
             $aParams = $xRequest->getQueryParams();
258 253
             if(isset($aParams['jxnargs']))
Please login to merge, or discard this patch.
src/Response/Response.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function getOutput(): string
90 90
     {
91
-        if($this->getCommandCount() === 0)
91
+        if ($this->getCommandCount() === 0)
92 92
         {
93 93
             return '';
94 94
         }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function bag(string $sName): DataBagContext
149 149
     {
150
-        return $this->plugin('bags')->bag($sName);;
150
+        return $this->plugin('bags')->bag($sName); ;
151 151
     }
152 152
 
153 153
     /**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     public function addCommand(array $aAttributes, $mData): Response
162 162
     {
163 163
         $aAttributes = array_map(function($xAttribute) {
164
-            return is_integer($xAttribute) ? $xAttribute : trim((string)$xAttribute, " \t");
164
+            return is_integer($xAttribute) ? $xAttribute : trim((string) $xAttribute, " \t");
165 165
         }, $aAttributes);
166 166
         $aAttributes['data'] = $mData;
167 167
         $this->aCommands[] = $aAttributes;
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
     protected function _addCommand(string $sName, array $aAttributes, $mData, bool $bRemoveEmpty = false): Response
182 182
     {
183 183
         $mData = is_array($mData) ? array_map(function($sData) {
184
-            return trim((string)$sData, " \t\n");
185
-        }, $mData) : trim((string)$mData, " \t\n");
186
-        if($bRemoveEmpty)
184
+            return trim((string) $sData, " \t\n");
185
+        }, $mData) : trim((string) $mData, " \t\n");
186
+        if ($bRemoveEmpty)
187 187
         {
188 188
             $aAttributes = array_filter($aAttributes, function($xValue) {
189 189
                 return $xValue === '';
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     public function toPsr(): PsrResponseInterface
217 217
     {
218 218
         $xPsrResponse = $this->xPsr17Factory->createResponse(200);
219
-        if($this->di->getRequest()->getMethod() === 'GET')
219
+        if ($this->di->getRequest()->getMethod() === 'GET')
220 220
         {
221 221
             $xPsrResponse = $xPsrResponse
222 222
                 ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT')
Please login to merge, or discard this patch.
src/Response/Traits/JsTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@
 block discarded – undo
94 94
     public function redirect(string $sURL, int $nDelay = 0): Response
95 95
     {
96 96
         $sURL = $this->di->getParameterReader()->parseUrl($sURL);
97
-        if($nDelay <= 0)
97
+        if ($nDelay <= 0)
98 98
         {
99 99
             return $this->script("window.location = '$sURL';");
100 100
         }
Please login to merge, or discard this patch.
src/Response/Manager/ResponseManager.php 1 patch
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -108,17 +108,17 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function append(ResponseInterface $xResponse)
110 110
     {
111
-        if($this->xResponse->getCommandCount() === 0)
111
+        if ($this->xResponse->getCommandCount() === 0)
112 112
         {
113 113
             $this->xResponse = $xResponse;
114 114
             return;
115 115
         }
116
-        if(get_class($this->xResponse) !== get_class($xResponse))
116
+        if (get_class($this->xResponse) !== get_class($xResponse))
117 117
         {
118 118
             throw new RequestException($this->xTranslator->trans('errors.mismatch.types',
119 119
                 ['class' => get_class($xResponse)]));
120 120
         }
121
-        if($this->xResponse !== $xResponse)
121
+        if ($this->xResponse !== $xResponse)
122 122
         {
123 123
             $this->xResponse->appendResponse($xResponse);
124 124
         }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public function printDebug()
161 161
     {
162
-        foreach($this->aDebugMessages as $sMessage)
162
+        foreach ($this->aDebugMessages as $sMessage)
163 163
         {
164 164
             $this->xResponse->debug($sMessage);
165 165
         }
@@ -173,8 +173,7 @@  discard block
 block discarded – undo
173 173
      */
174 174
     public function getContentType(): string
175 175
     {
176
-        return empty($this->sCharacterEncoding) ? $this->xResponse->getContentType() :
177
-            $this->xResponse->getContentType() . '; charset="' . $this->sCharacterEncoding . '"';
176
+        return empty($this->sCharacterEncoding) ? $this->xResponse->getContentType() : $this->xResponse->getContentType() . '; charset="' . $this->sCharacterEncoding . '"';
178 177
     }
179 178
 
180 179
     /**
Please login to merge, or discard this patch.
src/Plugin/Request/CallableFunction/CallableFunctionPlugin.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
      */
119 119
     public function checkOptions(string $sCallable, $xOptions): array
120 120
     {
121
-        if(!$this->xValidator->validateFunction(trim($sCallable)))
121
+        if (!$this->xValidator->validateFunction(trim($sCallable)))
122 122
         {
123 123
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
124 124
         }
125
-        if(is_string($xOptions))
125
+        if (is_string($xOptions))
126 126
         {
127 127
             $xOptions = ['include' => $xOptions];
128 128
         }
129
-        elseif(!is_array($xOptions))
129
+        elseif (!is_array($xOptions))
130 130
         {
131 131
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
132 132
         }
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
         $sPhpFunction = trim($sCallable);
148 148
         $sFunction = $sPhpFunction;
149 149
         // Check if an alias is defined
150
-        if(isset($aOptions['alias']))
150
+        if (isset($aOptions['alias']))
151 151
         {
152
-            $sFunction = (string)$aOptions['alias'];
152
+            $sFunction = (string) $aOptions['alias'];
153 153
             unset($aOptions['alias']);
154 154
         }
155 155
         $this->aFunctions[$sFunction] = $sPhpFunction;
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
     public function getCallable(string $sCallable)
172 172
     {
173 173
         $sFunction = trim($sCallable);
174
-        if(!isset($this->aFunctions[$sFunction]))
174
+        if (!isset($this->aFunctions[$sFunction]))
175 175
         {
176 176
             return null;
177 177
         }
178 178
         $xCallable = new CallableFunction($sFunction, $this->sPrefix . $sFunction, $this->aFunctions[$sFunction]);
179
-        foreach($this->aOptions[$sFunction] as $sName => $sValue)
179
+        foreach ($this->aOptions[$sFunction] as $sName => $sValue)
180 180
         {
181 181
             $xCallable->configure($sName, $sValue);
182 182
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     public function getScript(): string
206 206
     {
207 207
         $code = '';
208
-        foreach(array_keys($this->aFunctions) as $sFunction)
208
+        foreach (array_keys($this->aFunctions) as $sFunction)
209 209
         {
210 210
             $xFunction = $this->getCallable($sFunction);
211 211
             $code .= $this->getCallableScript($xFunction);
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
     public static function canProcessRequest(ServerRequestInterface $xRequest): bool
220 220
     {
221 221
         $aBody = $xRequest->getParsedBody();
222
-        if(is_array($aBody))
222
+        if (is_array($aBody))
223 223
         {
224 224
             return isset($aBody['jxnfun']);
225 225
         }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     public function setTarget(ServerRequestInterface $xRequest)
234 234
     {
235 235
         $aBody = $xRequest->getParsedBody();
236
-        if(is_array($aBody))
236
+        if (is_array($aBody))
237 237
         {
238 238
             $this->xTarget = Target::makeFunction(trim($aBody['jxnfun']));
239 239
             return;
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         $sRequestedFunction = $this->xTarget->getFunctionName();
252 252
 
253 253
         // Security check: make sure the requested function was registered.
254
-        if(!$this->xValidator->validateFunction($sRequestedFunction) ||
254
+        if (!$this->xValidator->validateFunction($sRequestedFunction) ||
255 255
             !isset($this->aFunctions[$sRequestedFunction]))
256 256
         {
257 257
             // Unable to find the requested function
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -125,8 +125,7 @@
 block discarded – undo
125 125
         if(is_string($xOptions))
126 126
         {
127 127
             $xOptions = ['include' => $xOptions];
128
-        }
129
-        elseif(!is_array($xOptions))
128
+        } elseif(!is_array($xOptions))
130 129
         {
131 130
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
132 131
         }
Please login to merge, or discard this patch.
src/Plugin/Request/CallableFunction/CallableFunction.php 2 patches
Switch Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -114,15 +114,15 @@
 block discarded – undo
114 114
     {
115 115
         switch($sName)
116 116
         {
117
-        case 'class': // The user function is a method in the given class
118
-            $this->xPhpFunction = [$sValue, $this->xPhpFunction];
119
-            break;
120
-        case 'include':
121
-            $this->sInclude = $sValue;
122
-            break;
123
-        default:
124
-            $this->aOptions[$sName] = $sValue;
125
-            break;
117
+            case 'class': // The user function is a method in the given class
118
+                $this->xPhpFunction = [$sValue, $this->xPhpFunction];
119
+                break;
120
+            case 'include':
121
+                $this->sInclude = $sValue;
122
+                break;
123
+            default:
124
+                $this->aOptions[$sName] = $sValue;
125
+                break;
126 126
         }
127 127
     }
128 128
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      */
113 113
     public function configure(string $sName, string $sValue)
114 114
     {
115
-        switch($sName)
115
+        switch ($sName)
116 116
         {
117 117
         case 'class': // The user function is a method in the given class
118 118
             $this->xPhpFunction = [$sValue, $this->xPhpFunction];
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function call(array $aArgs = [])
138 138
     {
139
-        if(($this->sInclude))
139
+        if (($this->sInclude))
140 140
         {
141 141
             require_once $this->sInclude;
142 142
         }
143 143
         // If the function is an alias for a class method, then instantiate the class
144
-        if(is_array($this->xPhpFunction) && is_string($this->xPhpFunction[0]))
144
+        if (is_array($this->xPhpFunction) && is_string($this->xPhpFunction[0]))
145 145
         {
146 146
             $sClassName = $this->xPhpFunction[0];
147 147
             $this->xPhpFunction[0] = new $sClassName;
Please login to merge, or discard this patch.
src/Plugin/Request/CallableDir/CallableDirPlugin.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     private function checkDirectory(string $sDirectory): string
81 81
     {
82 82
         $sDirectory = rtrim(trim($sDirectory), '/\\');
83
-        if(!is_dir($sDirectory))
83
+        if (!is_dir($sDirectory))
84 84
         {
85 85
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
86 86
         }
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function checkOptions(string $sCallable, $xOptions): array
95 95
     {
96
-        if(is_string($xOptions))
96
+        if (is_string($xOptions))
97 97
         {
98 98
             $xOptions = ['namespace' => $xOptions];
99 99
         }
100
-        if(!is_array($xOptions))
100
+        if (!is_array($xOptions))
101 101
         {
102 102
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
103 103
         }
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
         $xOptions['directory'] = $this->checkDirectory($sCallable);
106 106
         // Check the namespace
107 107
         $sNamespace = $xOptions['namespace'] ?? '';
108
-        if(!($xOptions['namespace'] = trim($sNamespace, ' \\')))
108
+        if (!($xOptions['namespace'] = trim($sNamespace, ' \\')))
109 109
         {
110 110
             $xOptions['namespace'] = '';
111 111
         }
112 112
 
113 113
         // Change the keys in $xOptions to have "\" as separator
114 114
         $_aOptions = [];
115
-        foreach($xOptions as $sName => $aOption)
115
+        foreach ($xOptions as $sName => $aOption)
116 116
         {
117 117
             $sName = trim(str_replace('.', '\\', $sName), ' \\');
118 118
             $_aOptions[$sName] = $aOption;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function register(string $sType, string $sCallable, array $aOptions): bool
127 127
     {
128
-        if(($aOptions['namespace']))
128
+        if (($aOptions['namespace']))
129 129
         {
130 130
             $this->xRegistry->addNamespace($aOptions['namespace'], $aOptions);
131 131
             return true;
Please login to merge, or discard this patch.
src/Plugin/Request/CallableClass/CallableRegistry.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         $this->xRepository = $xRepository;
90 90
 
91 91
         // Set the composer autoloader
92
-        if(file_exists(($sAutoloadFile = __DIR__ . '/../../../../../../autoload.php')) ||
92
+        if (file_exists(($sAutoloadFile = __DIR__ . '/../../../../../../autoload.php')) ||
93 93
             file_exists(($sAutoloadFile = __DIR__ . '/../../../../vendor/autoload.php')))
94 94
         {
95 95
             $this->xAutoloader = require($sAutoloadFile);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     public function addDirectory(string $sDirectory, array $aOptions)
107 107
     {
108 108
         // Set the autoload option default value
109
-        if(!isset($aOptions['autoload']))
109
+        if (!isset($aOptions['autoload']))
110 110
         {
111 111
             $aOptions['autoload'] = true;
112 112
         }
@@ -123,26 +123,26 @@  discard block
 block discarded – undo
123 123
     public function addNamespace(string $sNamespace, array $aOptions)
124 124
     {
125 125
         // Separator default value
126
-        if(!isset($aOptions['separator']))
126
+        if (!isset($aOptions['separator']))
127 127
         {
128 128
             $aOptions['separator'] = '.';
129 129
         }
130 130
         $aOptions['separator'] = trim($aOptions['separator']);
131
-        if(!in_array($aOptions['separator'], ['.', '_']))
131
+        if (!in_array($aOptions['separator'], ['.', '_']))
132 132
         {
133 133
             $aOptions['separator'] = '.';
134 134
         }
135
-        if($aOptions['separator'] === '_')
135
+        if ($aOptions['separator'] === '_')
136 136
         {
137 137
             $this->bUsingUnderscore = true;
138 138
         }
139 139
         // Set the autoload option default value
140
-        if(!isset($aOptions['autoload']))
140
+        if (!isset($aOptions['autoload']))
141 141
         {
142 142
             $aOptions['autoload'] = true;
143 143
         }
144 144
         // Register the dir with PSR4 autoloading
145
-        if(($aOptions['autoload']) && $this->xAutoloader != null)
145
+        if (($aOptions['autoload']) && $this->xAutoloader != null)
146 146
         {
147 147
             $this->xAutoloader->setPsr4($sNamespace . '\\', $aOptions['directory']);
148 148
         }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     public function parseDirectories()
158 158
     {
159 159
         // This is to be done only once.
160
-        if($this->bDirectoriesParsed)
160
+        if ($this->bDirectoriesParsed)
161 161
         {
162 162
             return;
163 163
         }
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
 
166 166
         // Browse directories without namespaces and read all the files.
167 167
         $aClassMap = [];
168
-        foreach($this->xRepository->getDirectoryOptions() as $sDirectory => $aOptions)
168
+        foreach ($this->xRepository->getDirectoryOptions() as $sDirectory => $aOptions)
169 169
         {
170 170
             $itFile = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sDirectory));
171 171
             // Iterate on dir content
172
-            foreach($itFile as $xFile)
172
+            foreach ($itFile as $xFile)
173 173
             {
174 174
                 // Skip everything except PHP files
175
-                if(!$xFile->isFile() || $xFile->getExtension() != 'php')
175
+                if (!$xFile->isFile() || $xFile->getExtension() != 'php')
176 176
                 {
177 177
                     continue;
178 178
                 }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
                 $sClassName = $xFile->getBasename('.php');
181 181
                 $aClassOptions = ['timestamp' => $xFile->getMTime()];
182 182
                 // No more classmap autoloading. The file will be included when needed.
183
-                if(($aOptions['autoload']))
183
+                if (($aOptions['autoload']))
184 184
                 {
185 185
                     $aClassMap[$sClassName] = $xFile->getPathname();
186 186
                 }
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
             }
189 189
         }
190 190
         // Set classmap autoloading
191
-        if(($aClassMap) && $this->xAutoloader !== null)
191
+        if (($aClassMap) && $this->xAutoloader !== null)
192 192
         {
193 193
             $this->xAutoloader->addClassMap($aClassMap);
194 194
         }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     public function parseNamespaces()
203 203
     {
204 204
         // This is to be done only once.
205
-        if($this->bNamespacesParsed)
205
+        if ($this->bNamespacesParsed)
206 206
         {
207 207
             return;
208 208
         }
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
 
211 211
         // Browse directories with namespaces and read all the files.
212 212
         $sDS = DIRECTORY_SEPARATOR;
213
-        foreach($this->xRepository->getNamespaceOptions() as $sNamespace => $aOptions)
213
+        foreach ($this->xRepository->getNamespaceOptions() as $sNamespace => $aOptions)
214 214
         {
215 215
             $this->xRepository->addNamespace($sNamespace, ['separator' => $aOptions['separator']]);
216 216
 
217 217
             // Iterate on dir content
218 218
             $sDirectory = $aOptions['directory'];
219 219
             $itFile = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sDirectory));
220
-            foreach($itFile as $xFile)
220
+            foreach ($itFile as $xFile)
221 221
             {
222 222
                 // skip everything except PHP files
223
-                if(!$xFile->isFile() || $xFile->getExtension() != 'php')
223
+                if (!$xFile->isFile() || $xFile->getExtension() != 'php')
224 224
                 {
225 225
                     continue;
226 226
                 }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
                 $sClassPath = $sNamespace;
230 230
                 $sRelativePath = substr($xFile->getPath(), strlen($sDirectory));
231 231
                 $sRelativePath = trim(str_replace($sDS, '\\', $sRelativePath), '\\');
232
-                if($sRelativePath !== '')
232
+                if ($sRelativePath !== '')
233 233
                 {
234 234
                     $sClassPath .= '\\' . $sRelativePath;
235 235
                 }
@@ -256,12 +256,12 @@  discard block
 block discarded – undo
256 256
         // Replace all separators ('.' and '_') with antislashes, and remove the antislashes
257 257
         // at the beginning and the end of the class name.
258 258
         $sClassName = trim(str_replace('.', '\\', $sClassName), '\\');
259
-        if($this->bUsingUnderscore)
259
+        if ($this->bUsingUnderscore)
260 260
         {
261 261
             $sClassName = trim(str_replace('_', '\\', $sClassName), '\\');
262 262
         }
263 263
         // Register the class, if it wasn't already.
264
-        if(!$this->di->h($sClassName))
264
+        if (!$this->di->h($sClassName))
265 265
         {
266 266
             $this->di->registerCallableClass($sClassName, $this->xRepository->getClassOptions($sClassName));
267 267
         }
Please login to merge, or discard this patch.
src/Plugin/Request/CallableClass/CallableRepository.php 1 patch
Spacing   +16 added lines, -16 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,14 +181,14 @@  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
-        if(is_string($aClassOptions['protected']))
191
+        if (is_string($aClassOptions['protected']))
192 192
         {
193 193
             $aClassOptions['protected'] = [$aClassOptions['protected']]; // Convert to array.
194 194
         }
@@ -199,21 +199,21 @@  discard block
 block discarded – undo
199 199
             $aDirectoryOptions['classes']['*'] ?? [], // Options for all classes
200 200
             $aDirectoryOptions['classes'][$sClassName] ?? [], // Options for this specific class
201 201
         ];
202
-        foreach($aOptionGroups as $aOptionGroup)
202
+        foreach ($aOptionGroups as $aOptionGroup)
203 203
         {
204
-            if(isset($aOptionGroup['separator']))
204
+            if (isset($aOptionGroup['separator']))
205 205
             {
206 206
                 $aClassOptions['separator'] = $aOptionGroup['separator'];
207 207
             }
208
-            if(isset($aOptionGroup['protected']))
208
+            if (isset($aOptionGroup['protected']))
209 209
             {
210
-                if(is_string($aOptionGroup['protected']))
210
+                if (is_string($aOptionGroup['protected']))
211 211
                 {
212 212
                     $aOptionGroup['protected'] = [$aOptionGroup['protected']]; // Convert to array.
213 213
                 }
214 214
                 $aClassOptions['protected'] = array_merge($aClassOptions['protected'], $aOptionGroup['protected']);
215 215
             }
216
-            if(isset($aOptionGroup['functions']))
216
+            if (isset($aOptionGroup['functions']))
217 217
             {
218 218
                 $aClassOptions['functions'] = array_merge($aClassOptions['functions'], $aOptionGroup['functions']);
219 219
             }
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
     private function getNamespaceClassOptions(string $sClassName)
260 260
     {
261 261
         // Find the corresponding namespace
262
-        foreach($this->aNamespaceOptions as $sNamespace => $aOptions)
262
+        foreach ($this->aNamespaceOptions as $sNamespace => $aOptions)
263 263
         {
264 264
             // Check if the namespace matches the class.
265
-            if(strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0)
265
+            if (strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0)
266 266
             {
267 267
                 // Save the class options
268 268
                 $this->aClasses[$sClassName] = $this->makeClassOptions($sClassName,
@@ -283,17 +283,17 @@  discard block
 block discarded – undo
283 283
     public function getClassOptions(string $sClassName): array
284 284
     {
285 285
         // Find options for a class registered with namespace.
286
-        if(!isset($this->aClasses[$sClassName]))
286
+        if (!isset($this->aClasses[$sClassName]))
287 287
         {
288 288
             $this->getNamespaceClassOptions($sClassName);
289
-            if(!isset($this->aClasses[$sClassName]))
289
+            if (!isset($this->aClasses[$sClassName]))
290 290
             {
291 291
                 // Find options for a class registered without namespace.
292 292
                 // We then need to parse all classes to be able to find one.
293 293
                 $this->di->getCallableRegistry()->parseDirectories();
294 294
             }
295 295
         }
296
-        if(isset($this->aClasses[$sClassName]))
296
+        if (isset($this->aClasses[$sClassName]))
297 297
         {
298 298
             return $this->aClasses[$sClassName];
299 299
         }
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
     public function getCallableObjects(): array
323 323
     {
324 324
         $aCallableObjects = [];
325
-        foreach($this->aClasses as $sClassName => $aOptions)
325
+        foreach ($this->aClasses as $sClassName => $aOptions)
326 326
         {
327
-            if(!$this->di->h($sClassName))
327
+            if (!$this->di->h($sClassName))
328 328
             {
329 329
                 $this->di->registerCallableClass($sClassName, $aOptions);
330 330
             }
Please login to merge, or discard this patch.