Passed
Push — main ( 4ddaea...7c5fe7 )
by Thierry
04:58
created
jaxon-core/src/Di/Traits/ComponentTrait.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
         $xRegistry->updateHash(false); // Disable hash calculation.
152 152
 
153 153
         $sComponentId = str_replace('\\', '.', $sClassName);
154
-        if(!isset($this->aComponents[$sComponentId]))
154
+        if (!isset($this->aComponents[$sComponentId]))
155 155
         {
156 156
             $aOptions = $xRegistry->getNamespaceComponentOptions($sClassName);
157
-            if($aOptions !== null)
157
+            if ($aOptions !== null)
158 158
             {
159 159
                 $this->saveComponent($sClassName, $aOptions);
160 160
             }
161 161
         }
162
-        if(isset($this->aComponents[$sComponentId]))
162
+        if (isset($this->aComponents[$sComponentId]))
163 163
         {
164 164
             return; // The component is found.
165 165
         }
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
         // The component was not found in a registered namespace. We need to parse all
168 168
         // the directories to be able to find a component registered without a namespace.
169 169
         $sComponentId = str_replace('\\', '_', $sClassName);
170
-        if(!isset($this->aComponents[$sComponentId]))
170
+        if (!isset($this->aComponents[$sComponentId]))
171 171
         {
172 172
             $xRegistry->registerComponentsInDirectories();
173 173
         }
174
-        if(isset($this->aComponents[$sComponentId]))
174
+        if (isset($this->aComponents[$sComponentId]))
175 175
         {
176 176
             return; // The component is found.
177 177
         }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     public function getCallableObjects(): array
190 190
     {
191 191
         $aCallableObjects = [];
192
-        foreach($this->aComponents as $sComponentId => $_)
192
+        foreach ($this->aComponents as $sComponentId => $_)
193 193
         {
194 194
             $aCallableObjects[$sComponentId] = $this->makeCallableObject($sComponentId);
195 195
         }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     private function setComponentPublicMethods(string $sKey, string $sClass,
207 207
         array $aNeverExported): void
208 208
     {
209
-        if(isset($this->aComponentPublicMethods[$sKey]))
209
+        if (isset($this->aComponentPublicMethods[$sKey]))
210 210
         {
211 211
             return;
212 212
         }
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
     {
260 260
         /** @var Config|null */
261 261
         $xPackageConfig = $aOptions['config'] ?? null;
262
-        if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false))
262
+        if ($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false))
263 263
         {
264 264
             return null;
265 265
         }
266 266
         $sMetadataFormat = $xPackageConfig->getOption('metadata.format');
267
-        if(!in_array($sMetadataFormat, ['attributes', 'annotations']))
267
+        if (!in_array($sMetadataFormat, ['attributes', 'annotations']))
268 268
         {
269 269
             return null;
270 270
         }
@@ -274,23 +274,23 @@  discard block
 block discarded – undo
274 274
         $xMetadata = null;
275 275
         $xMetadataCache = null;
276 276
         $xConfig = $di->config();
277
-        if($xConfig->getAppOption('metadata.cache.enabled', false))
277
+        if ($xConfig->getAppOption('metadata.cache.enabled', false))
278 278
         {
279
-            if(!$di->h('jaxon_metadata_cache_dir'))
279
+            if (!$di->h('jaxon_metadata_cache_dir'))
280 280
             {
281 281
                 $sCacheDir = $xConfig->getAppOption('metadata.cache.dir');
282 282
                 $di->val('jaxon_metadata_cache_dir', $sCacheDir);
283 283
             }
284 284
             $xMetadataCache = $di->getMetadataCache();
285 285
             $xMetadata = $xMetadataCache->read($xReflectionClass->getName());
286
-            if($xMetadata !== null)
286
+            if ($xMetadata !== null)
287 287
             {
288 288
                 return $xMetadata;
289 289
             }
290 290
         }
291 291
 
292 292
         $aProperties = array_map(fn($xProperty) => $xProperty->getName(),
293
-            $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC |
293
+            $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC|
294 294
                 ReflectionProperty::IS_PROTECTED));
295 295
 
296 296
         $xMetadataReader = $di->getMetadataReader($sMetadataFormat);
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         $xMetadata = $xMetadataReader->getAttributes($xInput);
299 299
 
300 300
         // Try to save the metadata in the cache
301
-        if($xMetadataCache !== null)
301
+        if ($xMetadataCache !== null)
302 302
         {
303 303
             $xMetadataCache->save($xReflectionClass->getName(), $xMetadata);
304 304
         }
Please login to merge, or discard this patch.
jaxon-core/src/Di/Container.php 1 patch
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -119,8 +119,7 @@  discard block
 block discarded – undo
119 119
     public function setLogger(LoggerInterface|Closure $xLogger)
120 120
     {
121 121
         is_a($xLogger, LoggerInterface::class) ?
122
-            $this->val(LoggerInterface::class, $xLogger) :
123
-            $this->set(LoggerInterface::class, $xLogger);
122
+            $this->val(LoggerInterface::class, $xLogger) : $this->set(LoggerInterface::class, $xLogger);
124 123
     }
125 124
 
126 125
     /**
@@ -199,7 +198,7 @@  discard block
 block discarded – undo
199 198
             return $this->xAppContainer != null && $this->xAppContainer->has($sClass) ?
200 199
                 $this->xAppContainer->get($sClass) : $this->xLibContainer->offsetGet($sClass);
201 200
         }
202
-        catch(Throwable $e)
201
+        catch (Throwable $e)
203 202
         {
204 203
             $xLogger = $this->g(LoggerInterface::class);
205 204
             $xTranslator = $this->g(Translator::class);
@@ -265,15 +264,15 @@  discard block
 block discarded – undo
265 264
     {
266 265
         $xType = $xParameter->getType();
267 266
         // Check the parameter class first.
268
-        if($xType instanceof ReflectionNamedType)
267
+        if ($xType instanceof ReflectionNamedType)
269 268
         {
270 269
             // Check the class + the name
271
-            if($this->has($xType->getName() . ' $' . $xParameter->getName()))
270
+            if ($this->has($xType->getName() . ' $' . $xParameter->getName()))
272 271
             {
273 272
                 return $this->get($xType->getName() . ' $' . $xParameter->getName());
274 273
             }
275 274
             // Check the class only
276
-            if($this->has($xType->getName()))
275
+            if ($this->has($xType->getName()))
277 276
             {
278 277
                 return $this->get($xType->getName());
279 278
             }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Code/CodeGenerator.php 1 patch
Spacing   +20 added lines, -22 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function addCodeGenerator(string $sClassName, int $nPriority): void
111 111
     {
112
-        while(isset($this->aCodeGenerators[$nPriority]))
112
+        while (isset($this->aCodeGenerators[$nPriority]))
113 113
         {
114 114
             $nPriority++;
115 115
         }
@@ -163,33 +163,33 @@  discard block
 block discarded – undo
163 163
      */
164 164
     private function generatePluginCodes(CodeGeneratorInterface $xGenerator): void
165 165
     {
166
-        if(!is_subclass_of($xGenerator, AbstractPlugin::class) ||
166
+        if (!is_subclass_of($xGenerator, AbstractPlugin::class) ||
167 167
             $this->xAssetManager->shallIncludeAssets($xGenerator))
168 168
         {
169 169
             // HTML tags for CSS
170
-            if(($sCss = trim($xGenerator->getCss(), " \n")) !== '')
170
+            if (($sCss = trim($xGenerator->getCss(), " \n")) !== '')
171 171
             {
172 172
                 $this->aCss[] = $sCss;
173 173
             }
174 174
             // HTML tags for js
175
-            if(($sJs = trim($xGenerator->getJs(), " \n")) !== '')
175
+            if (($sJs = trim($xGenerator->getJs(), " \n")) !== '')
176 176
             {
177 177
                 $this->aJs[] = $sJs;
178 178
             }
179 179
         }
180 180
 
181 181
         // Additional js codes
182
-        if(($xJsCode = $xGenerator->getJsCode()) !== null)
182
+        if (($xJsCode = $xGenerator->getJsCode()) !== null)
183 183
         {
184
-            if(($sJs = trim($xJsCode->sJs, " \n")) !== '')
184
+            if (($sJs = trim($xJsCode->sJs, " \n")) !== '')
185 185
             {
186 186
                 $this->aCodeJs[] = $sJs;
187 187
             }
188
-            if(($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '')
188
+            if (($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '')
189 189
             {
190 190
                 $this->aCodeJsBefore[] = $sJsBefore;
191 191
             }
192
-            if(($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '')
192
+            if (($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '')
193 193
             {
194 194
                 $this->aCodeJsAfter[] = $sJsAfter;
195 195
             }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     private function generateCodes(): void
207 207
     {
208
-        if($this->bGenerated)
208
+        if ($this->bGenerated)
209 209
         {
210 210
             return;
211 211
         }
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         // Sort the code generators by ascending priority
217 217
         ksort($this->aCodeGenerators);
218 218
 
219
-        foreach($this->aCodeGenerators as $sClassName)
219
+        foreach ($this->aCodeGenerators as $sClassName)
220 220
         {
221 221
             $this->generatePluginCodes($this->getCodeGenerator($sClassName));
222 222
         }
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
     public function getJsScript(): string
263 263
     {
264 264
         $aJsScripts = [];
265
-        foreach($this->aCodeGenerators as $sClassName)
265
+        foreach ($this->aCodeGenerators as $sClassName)
266 266
         {
267 267
             $xGenerator = $this->getCodeGenerator($sClassName);
268 268
             // Javascript code
269
-            if(($sJsScript = trim($xGenerator->getScript(), " \n")) !== '')
269
+            if (($sJsScript = trim($xGenerator->getScript(), " \n")) !== '')
270 270
             {
271 271
                 $aJsScripts[] = $sJsScript;
272 272
             }
@@ -283,38 +283,36 @@  discard block
 block discarded – undo
283 283
     private function renderCodes(bool $bIncludeJs, bool $bIncludeCss): array
284 284
     {
285 285
         $aCodes = [];
286
-        if($bIncludeCss)
286
+        if ($bIncludeCss)
287 287
         {
288 288
             $aCodes[] = $this->getCss();
289 289
         }
290
-        if($bIncludeJs)
290
+        if ($bIncludeJs)
291 291
         {
292 292
             $aCodes[] = $this->getJs();
293 293
         }
294 294
 
295
-        $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' :
296
-            $this->xAssetManager->createJsFiles($this);
295
+        $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' : $this->xAssetManager->createJsFiles($this);
297 296
         // Wrap the js code into the corresponding HTML tag.
298 297
         $aCodes[] = $sUrl !== '' ?
299
-            $this->render('include.js', ['sUrl' => $sUrl]) :
300
-            $this->render('wrapper.js', ['sScript' => $this->getJsScript()]);
298
+            $this->render('include.js', ['sUrl' => $sUrl]) : $this->render('wrapper.js', ['sScript' => $this->getJsScript()]);
301 299
 
302 300
         // Wrap the js codes into HTML tags.
303
-        if(count($this->aCodeJsBefore) > 0)
301
+        if (count($this->aCodeJsBefore) > 0)
304 302
         {
305 303
             $sScript = implode("\n\n", $this->aCodeJsBefore);
306 304
             $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
307 305
         }
308
-        if(count($this->aCodeJs) > 0)
306
+        if (count($this->aCodeJs) > 0)
309 307
         {
310 308
             $sScript = implode("\n\n", $this->aCodeJs);
311 309
             $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
312 310
         }
313
-        if(count($this->aCodeJsFiles) > 0)
311
+        if (count($this->aCodeJsFiles) > 0)
314 312
         {
315 313
             $aCodes[] = $this->render('includes.js', ['aUrls' => $this->aCodeJsFiles]);
316 314
         }
317
-        if(count($this->aCodeJsAfter) > 0)
315
+        if (count($this->aCodeJsAfter) > 0)
318 316
         {
319 317
             $sScript = implode("\n\n", $this->aCodeJsAfter);
320 318
             $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
Please login to merge, or discard this patch.
jaxon-upload/src/Manager/UploadManager.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
         try
122 122
         {
123 123
             $xFilesystem->createDirectory($sUploadDir);
124
-            if(!$xFilesystem->directoryExists($sUploadDir))
124
+            if (!$xFilesystem->directoryExists($sUploadDir))
125 125
             {
126 126
                 throw new RequestException($this->xTranslator->trans('errors.upload.access'));
127 127
             }
128 128
             return $sUploadDir;
129 129
         }
130
-        catch(FilesystemException $e)
130
+        catch (FilesystemException $e)
131 131
         {
132 132
             $this->xLogger->error('Filesystem error.', ['message' => $e->getMessage()]);
133 133
             throw new RequestException($this->xTranslator->trans('errors.upload.access'));
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     {
163 163
         // Check the uploaded file validity
164 164
         $nErrorCode = $xHttpFile->getError();
165
-        if($nErrorCode !== UPLOAD_ERR_OK)
165
+        if ($nErrorCode !== UPLOAD_ERR_OK)
166 166
         {
167 167
             $this->xLogger->error('File upload error.', [
168 168
                 'code' => $nErrorCode,
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
         // Filename without the extension. Needs to be sanitized.
178 178
         $sName = pathinfo($xHttpFile->getClientFilename(), PATHINFO_FILENAME);
179
-        if($this->cNameSanitizer !== null)
179
+        if ($this->cNameSanitizer !== null)
180 180
         {
181 181
             $sName = (string)call_user_func($this->cNameSanitizer,
182 182
                 $sName, $sField, $this->sUploadFieldId);
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
         // Set the user file data
186 186
         $xFile = File::fromHttpFile($this->xFileStorage->filesystem($sField), $xHttpFile, $sUploadDir, $sName);
187 187
         // Verify file validity (format, size)
188
-        if(!$this->xValidator->validateUploadedFile($sField, $xFile))
188
+        if (!$this->xValidator->validateUploadedFile($sField, $xFile))
189 189
         {
190 190
             throw new RequestException($this->xValidator->getErrorMessage());
191 191
         }
@@ -209,16 +209,16 @@  discard block
 block discarded – undo
209 209
 
210 210
         $aUserFiles = [];
211 211
         $aAllFiles = []; // A flat list of all uploaded files
212
-        foreach($aTempFiles as $sField => $aFiles)
212
+        foreach ($aTempFiles as $sField => $aFiles)
213 213
         {
214 214
             $aUserFiles[$sField] = [];
215 215
             // Get the path to the upload dir
216 216
             $sUploadDir = $this->getUploadDir($sField);
217
-            if(!is_array($aFiles))
217
+            if (!is_array($aFiles))
218 218
             {
219 219
                 $aFiles = [$aFiles];
220 220
             }
221
-            foreach($aFiles as $xHttpFile)
221
+            foreach ($aFiles as $xHttpFile)
222 222
             {
223 223
                 $aFile = $this->makeUploadedFile($xHttpFile, $sUploadDir, $sField);
224 224
                 $aUserFiles[$sField][] = $aFile['user'];
@@ -229,14 +229,14 @@  discard block
 block discarded – undo
229 229
         // Copy the uploaded files from the temp dir to the user dir
230 230
         try
231 231
         {
232
-            foreach($aAllFiles as $aFiles)
232
+            foreach ($aAllFiles as $aFiles)
233 233
             {
234 234
                 $sPath = $aFiles['user']->path();
235 235
                 $xContent = $aFiles['temp']->getStream();
236 236
                 $aFiles['user']->filesystem()->write($sPath, $xContent);
237 237
             }
238 238
         }
239
-        catch(FilesystemException $e)
239
+        catch (FilesystemException $e)
240 240
         {
241 241
             $this->xLogger->error('Filesystem error.', ['message' => $e->getMessage()]);
242 242
             throw new RequestException($this->xTranslator->trans('errors.upload.access'));
Please login to merge, or discard this patch.