Completed
Push — chore/php-8-migration ( 83422f...0b97e4 )
by Vladimir
07:07
created
src/MarkupEngine/MarkupEngineManager.php 1 patch
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,7 +18,8 @@  discard block
 block discarded – undo
18 18
 
19 19
     public function addMarkupEngines(/* iterable */ $markupEngines): void
20 20
     {
21
-        foreach ($markupEngines as $markupEngine) {
21
+        foreach ($markupEngines as $markupEngine)
22
+        {
22 23
             $this->addMarkupEngine($markupEngine);
23 24
         }
24 25
     }
@@ -28,10 +29,14 @@  discard block
 block discarded – undo
28 29
         $extensions = $markupEngine->getExtensions();
29 30
         $primaryExt = __::first($extensions);
30 31
 
31
-        foreach ($extensions as $k => $extension) {
32
-            if ($k === 0) {
32
+        foreach ($extensions as $k => $extension)
33
+        {
34
+            if ($k === 0)
35
+            {
33 36
                 $this->enginesByExtension[$extension] = $markupEngine;
34
-            } else {
37
+            }
38
+            else
39
+            {
35 40
                 $this->enginesByExtension[$extension] = &$this->enginesByExtension[$primaryExt];
36 41
             }
37 42
         }
@@ -41,7 +46,8 @@  discard block
 block discarded – undo
41 46
 
42 47
     public function getEngineByTag($tag)
43 48
     {
44
-        if (isset($this->enginesByTags[$tag])) {
49
+        if (isset($this->enginesByTags[$tag]))
50
+        {
45 51
             return $this->enginesByTags[$tag];
46 52
         }
47 53
 
@@ -50,7 +56,8 @@  discard block
 block discarded – undo
50 56
 
51 57
     public function getEngineByExtension($extension)
52 58
     {
53
-        if (isset($this->enginesByExtension[$extension])) {
59
+        if (isset($this->enginesByExtension[$extension]))
60
+        {
54 61
             return $this->enginesByExtension[$extension];
55 62
         }
56 63
 
Please login to merge, or discard this patch.
src/Configuration.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@
 block discarded – undo
171 171
         return __::get($this->configuration, 'twig.autoescape');
172 172
     }
173 173
 
174
-    public function getRedirectTemplate(): false|string
174
+    public function getRedirectTemplate(): false | string
175 175
     {
176 176
         return __::get($this->configuration, 'templates.redirect');
177 177
     }
Please login to merge, or discard this patch.
Braces   +46 added lines, -20 removed lines patch added patch discarded remove patch
@@ -210,18 +210,21 @@  discard block
 block discarded – undo
210 210
      */
211 211
     private function parseConfig(File $configFile = null): array
212 212
     {
213
-        if ($configFile === null) {
213
+        if ($configFile === null)
214
+        {
214 215
             return [];
215 216
         }
216 217
 
217 218
         $this->currentFile = $configFile;
218 219
 
219
-        try {
220
+        try
221
+        {
220 222
             $this->isRecursiveImport($configFile);
221 223
 
222 224
             $parsedConfig = Yaml::parse($configFile->getContents());
223 225
 
224
-            if ($parsedConfig === null) {
226
+            if ($parsedConfig === null)
227
+            {
225 228
                 $parsedConfig = [];
226 229
             }
227 230
 
@@ -230,13 +233,17 @@  discard block
 block discarded – undo
230 233
             unset($parsedConfig[self::IMPORT_KEYWORD]);
231 234
 
232 235
             return $parsedConfig;
233
-        } catch (ParseException $e) {
236
+        }
237
+        catch (ParseException $e)
238
+        {
234 239
             $this->logger->error('{file}: parsing failed... {message}', [
235 240
                 'message' => $e->getMessage(),
236 241
                 'file' => $configFile,
237 242
             ]);
238 243
             $this->logger->error('Using default configuration...');
239
-        } catch (RecursiveConfigurationException $e) {
244
+        }
245
+        catch (RecursiveConfigurationException $e)
246
+        {
240 247
             $this->logger->error("{file}: you can't recursively import a file that's already been imported: {import}", [
241 248
                 'file' => $configFile,
242 249
                 'import' => $e->getRecursiveImport(),
@@ -297,7 +304,8 @@  discard block
 block discarded – undo
297 304
      */
298 305
     private function handleImports(array &$configuration): void
299 306
     {
300
-        if (!isset($configuration[self::IMPORT_KEYWORD])) {
307
+        if (!isset($configuration[self::IMPORT_KEYWORD]))
308
+        {
301 309
             $this->logger->debug('{file}: does not import any other files', [
302 310
                 'file' => $this->currentFile->getRelativeFilePath(),
303 311
             ]);
@@ -305,13 +313,15 @@  discard block
 block discarded – undo
305 313
             return;
306 314
         }
307 315
 
308
-        if (!is_array($imports = $configuration[self::IMPORT_KEYWORD])) {
316
+        if (!is_array($imports = $configuration[self::IMPORT_KEYWORD]))
317
+        {
309 318
             $this->logger->error('{file}: the reserved "import" keyword can only be an array');
310 319
 
311 320
             return;
312 321
         }
313 322
 
314
-        foreach ($imports as $import) {
323
+        foreach ($imports as $import)
324
+        {
315 325
             $this->handleImport($import, $configuration);
316 326
         }
317 327
     }
@@ -325,7 +335,8 @@  discard block
 block discarded – undo
325 335
      */
326 336
     private function handleImport($importDef, array &$configuration): void
327 337
     {
328
-        if (!is_string($importDef)) {
338
+        if (!is_string($importDef))
339
+        {
329 340
             $this->logger->error('{file}: invalid import: {message}', [
330 341
                 'file' => $this->configFile->getRelativeFilePath(),
331 342
                 'message' => $importDef,
@@ -336,7 +347,8 @@  discard block
 block discarded – undo
336 347
 
337 348
         $import = $this->configFile->createFileForRelativePath($importDef);
338 349
 
339
-        if (!$this->isValidImport($import)) {
350
+        if (!$this->isValidImport($import))
351
+        {
340 352
             return;
341 353
         }
342 354
 
@@ -345,10 +357,13 @@  discard block
 block discarded – undo
345 357
             'import' => $import->getRelativeFilePath(),
346 358
         ]);
347 359
 
348
-        try {
360
+        try
361
+        {
349 362
             $importedConfig = $this->parseConfig($import);
350 363
             $configuration = $this->mergeImports($importedConfig, $configuration);
351
-        } catch (FileNotFoundException) {
364
+        }
365
+        catch (FileNotFoundException)
366
+        {
352 367
             $this->logger->warning('{file}: could not find file to import: {import}', [
353 368
                 'file' => $this->configFile->getRelativeFilePath(),
354 369
                 'import' => $import,
@@ -363,17 +378,25 @@  discard block
 block discarded – undo
363 378
     {
364 379
         $errorMsg = '';
365 380
 
366
-        if ($filePath->isDir()) {
381
+        if ($filePath->isDir())
382
+        {
367 383
             $errorMsg = 'a directory';
368
-        } elseif ($filePath->isLink()) {
384
+        }
385
+        elseif ($filePath->isLink())
386
+        {
369 387
             $errorMsg = 'a symbolically linked file';
370
-        } elseif ($this->currentFile->getAbsolutePath() == $filePath->getAbsolutePath()) {
388
+        }
389
+        elseif ($this->currentFile->getAbsolutePath() == $filePath->getAbsolutePath())
390
+        {
371 391
             $errorMsg = 'yourself';
372
-        } elseif (($ext = $filePath->getExtension()) != 'yml' && $ext != 'yaml') {
392
+        }
393
+        elseif (($ext = $filePath->getExtension()) != 'yml' && $ext != 'yaml')
394
+        {
373 395
             $errorMsg = 'a non-YAML configuration';
374 396
         }
375 397
 
376
-        if (!($noErrors = empty($errorMsg))) {
398
+        if (!($noErrors = empty($errorMsg)))
399
+        {
377 400
             $this->logger->error("{file}: you can't import {message}: {import}", [
378 401
                 'file' => $this->configFile->getRelativeFilePath(),
379 402
                 'message' => $errorMsg,
@@ -389,7 +412,8 @@  discard block
 block discarded – undo
389 412
      */
390 413
     private function isRecursiveImport(File $filePath): void
391 414
     {
392
-        if (in_array($filePath->getRelativeFilePath(), self::$configImports)) {
415
+        if (in_array($filePath->getRelativeFilePath(), self::$configImports))
416
+        {
393 417
             throw new RecursiveConfigurationException($filePath, sprintf(
394 418
                 'The %s file has already been imported',
395 419
                 $filePath->getRelativeFilePath()
@@ -412,11 +436,13 @@  discard block
 block discarded – undo
412 436
 
413 437
     private function handleDefaultOperations(): void
414 438
     {
415
-        if (substr($this->getTargetFolder(), 0, 1) != '_') {
439
+        if (substr($this->getTargetFolder(), 0, 1) != '_')
440
+        {
416 441
             $this->configuration['exclude'][] = $this->getTargetFolder();
417 442
         }
418 443
 
419
-        if ($this->configuration['build']['preserveCase']) {
444
+        if ($this->configuration['build']['preserveCase'])
445
+        {
420 446
             Service::setRuntimeFlag(RuntimeStatus::COMPILER_PRESERVE_CASE);
421 447
         }
422 448
     }
Please login to merge, or discard this patch.
src/DataTransformer/CsvTransformer.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,8 @@
 block discarded – undo
18 18
         $columns = array_shift($rows);
19 19
         $csv = [];
20 20
 
21
-        foreach ($rows as $row) {
21
+        foreach ($rows as $row)
22
+        {
22 23
             $csv[] = array_combine($columns, $row);
23 24
         }
24 25
 
Please login to merge, or discard this patch.
src/DataTransformer/XmlTransformer.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,14 +16,16 @@
 block discarded – undo
16 16
      */
17 17
     public static function transformData($content): array
18 18
     {
19
-        if (!function_exists('simplexml_load_string')) {
19
+        if (!function_exists('simplexml_load_string'))
20
+        {
20 21
             throw new DependencyMissingException('XML', 'XML support is not available with the current PHP installation.');
21 22
         }
22 23
 
23 24
         libxml_use_internal_errors(true);
24 25
         $data = json_decode(json_encode(simplexml_load_string($content), JSON_THROW_ON_ERROR), true, 512, JSON_THROW_ON_ERROR);
25 26
 
26
-        if ($data === false || $data === null) {
27
+        if ($data === false || $data === null)
28
+        {
27 29
             return [];
28 30
         }
29 31
 
Please login to merge, or discard this patch.
src/DataTransformer/YamlTransformer.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,13 +17,17 @@
 block discarded – undo
17 17
      */
18 18
     public static function transformData($content): array
19 19
     {
20
-        try {
20
+        try
21
+        {
21 22
             $data = Yaml::parse($content, Yaml::PARSE_DATETIME);
22
-        } catch (Exception) {
23
+        }
24
+        catch (Exception)
25
+        {
23 26
             return [];
24 27
         }
25 28
 
26
-        if ($data === null) {
29
+        if ($data === null)
30
+        {
27 31
             return [];
28 32
         }
29 33
 
Please login to merge, or discard this patch.
src/DataTransformer/DataTransformerManager.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,21 +20,24 @@
 block discarded – undo
20 20
 
21 21
     public function addDataTransformers(/* iterable */ $dataTransformers): void
22 22
     {
23
-        foreach ($dataTransformers as $dataTransformer) {
23
+        foreach ($dataTransformers as $dataTransformer)
24
+        {
24 25
             $this->addDataTransformer($dataTransformer);
25 26
         }
26 27
     }
27 28
 
28 29
     public function addDataTransformer(DataTransformerInterface $transformer): void
29 30
     {
30
-        foreach ($transformer->getExtensions() as $extension) {
31
+        foreach ($transformer->getExtensions() as $extension)
32
+        {
31 33
             $this->transformers[$extension] = $transformer;
32 34
         }
33 35
     }
34 36
 
35 37
     public function getTransformer($extension)
36 38
     {
37
-        if (isset($this->transformers[$extension])) {
39
+        if (isset($this->transformers[$extension]))
40
+        {
38 41
             return $this->transformers[$extension];
39 42
         }
40 43
 
Please login to merge, or discard this patch.
src/Utilities/HtmlUtils.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 
14 14
 abstract class HtmlUtils
15 15
 {
16
-    public static function htmlXPath(DOMDocument &$DOMDocument, $html, $xpathQuery)
16
+    public static function htmlXPath(DOMDocument & $DOMDocument, $html, $xpathQuery)
17 17
     {
18 18
         $html = self::normalizeHTML($html);
19 19
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,10 +27,12 @@  discard block
 block discarded – undo
27 27
         $xmlErrors = libxml_get_errors();
28 28
 
29 29
         /** @var LibXMLError $error */
30
-        foreach ($xmlErrors as $error) {
30
+        foreach ($xmlErrors as $error)
31
+        {
31 32
             // Ignore errors about invalid tags
32 33
             //   http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors
33
-            if ($error->code === 801) {
34
+            if ($error->code === 801)
35
+            {
34 36
                 continue;
35 37
             }
36 38
 
@@ -46,7 +48,8 @@  discard block
 block discarded – undo
46 48
 
47 49
     private static function normalizeHTML($html)
48 50
     {
49
-        if (!str_contains((string)$html, '<body>') || !str_contains((string)$html, '</body>')) {
51
+        if (!str_contains((string)$html, '<body>') || !str_contains((string)$html, '</body>'))
52
+        {
50 53
             return sprintf('<body>%s</body>', $html);
51 54
         }
52 55
 
Please login to merge, or discard this patch.
src/Utilities/ArrayUtilities.php 1 patch
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,8 +11,10 @@  discard block
 block discarded – undo
11 11
 {
12 12
     public static function is_multidimensional(array &$array): bool
13 13
     {
14
-        foreach ($array as &$element) {
15
-            if (is_array($element)) {
14
+        foreach ($array as &$element)
15
+        {
16
+            if (is_array($element))
17
+            {
16 18
                 return true;
17 19
             }
18 20
         }
@@ -37,8 +39,10 @@  discard block
 block discarded – undo
37 39
      */
38 40
     public static function array_can_be_indexed(array &$arr, $indexKey): bool
39 41
     {
40
-        foreach ($arr as &$value) {
41
-            if (isset($value[$indexKey]) && is_scalar($value[$indexKey])) {
42
+        foreach ($arr as &$value)
43
+        {
44
+            if (isset($value[$indexKey]) && is_scalar($value[$indexKey]))
45
+            {
42 46
                 return true;
43 47
             }
44 48
         }
@@ -69,8 +73,10 @@  discard block
 block discarded – undo
69 73
     {
70 74
         $result = [];
71 75
 
72
-        foreach ($arr as &$value) {
73
-            if (isset($value[$indexKey]) && is_scalar($value[$indexKey])) {
76
+        foreach ($arr as &$value)
77
+        {
78
+            if (isset($value[$indexKey]) && is_scalar($value[$indexKey]))
79
+            {
74 80
                 $result[$value[$indexKey]] = $value;
75 81
             }
76 82
         }
@@ -91,13 +97,18 @@  discard block
 block discarded – undo
91 97
     {
92 98
         $merged = $arr1;
93 99
 
94
-        foreach ($arr2 as $key => &$value) {
95
-            if (is_array($value) && isset($arr1[$key])) {
96
-                if (self::array_can_be_indexed($value, $indexKey)) {
100
+        foreach ($arr2 as $key => &$value)
101
+        {
102
+            if (is_array($value) && isset($arr1[$key]))
103
+            {
104
+                if (self::array_can_be_indexed($value, $indexKey))
105
+                {
97 106
                     $indexedArr1 = self::array_index_by_key($arr1[$key], $indexKey);
98 107
                     $indexedArr2 = self::array_index_by_key($value, $indexKey);
99 108
                     $merged[$key] = array_merge($indexedArr1, $indexedArr2);
100
-                } else {
109
+                }
110
+                else
111
+                {
101 112
                     $merged[$key] = array_merge($arr1[$key], $value);
102 113
                 }
103 114
 
Please login to merge, or discard this patch.
src/Utilities/NullableArray.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,8 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function offsetGet($offset): mixed
30 30
     {
31
-        if (isset($this->data[$offset])) {
31
+        if (isset($this->data[$offset]))
32
+        {
32 33
             return $this->data[$offset];
33 34
         }
34 35
 
@@ -40,7 +41,8 @@  discard block
 block discarded – undo
40 41
      */
41 42
     public function offsetSet($offset, $value): void
42 43
     {
43
-        if ($offset === null) {
44
+        if ($offset === null)
45
+        {
44 46
             return;
45 47
         }
46 48
 
@@ -52,7 +54,8 @@  discard block
 block discarded – undo
52 54
      */
53 55
     public function offsetUnset($offset): void
54 56
     {
55
-        if (isset($this->data[$offset])) {
57
+        if (isset($this->data[$offset]))
58
+        {
56 59
             unset($this->data[$offset]);
57 60
         }
58 61
     }
Please login to merge, or discard this patch.