Completed
Push — chore/php-8-migration ( 83422f )
by Vladimir
09:57
created
src/Templating/Twig/TwigStakxBridge.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,9 +54,12 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function createTemplate($templateContent): TemplateInterface
56 56
     {
57
-        try {
57
+        try
58
+        {
58 59
             $template = $this->twig->createTemplate($templateContent);
59
-        } catch (Error $e) {
60
+        }
61
+        catch (Error $e)
62
+        {
60 63
             throw new TwigError($e);
61 64
         }
62 65
 
@@ -89,7 +92,8 @@  discard block
 block discarded – undo
89 92
 
90 93
         preg_match_all($regex, $bodyContent, $results);
91 94
 
92
-        if (empty($results[1])) {
95
+        if (empty($results[1]))
96
+        {
93 97
             return [];
94 98
         }
95 99
 
Please login to merge, or discard this patch.
src/Templating/Twig/TwigStakxBridgeFactory.php 1 patch
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,10 +32,14 @@  discard block
 block discarded – undo
32 32
         $theme = $configuration->getTheme();
33 33
 
34 34
         // Only load a theme if one is specified and actually exists
35
-        if ($theme !== null) {
36
-            try {
35
+        if ($theme !== null)
36
+        {
37
+            try
38
+            {
37 39
                 $loader->addPath(fs::absolutePath('_themes', $theme), 'theme');
38
-            } catch (LoaderError $e) {
40
+            }
41
+            catch (LoaderError $e)
42
+            {
39 43
                 $logger->error('The following theme could not be loaded: {theme}', [
40 44
                     'theme' => $theme,
41 45
                 ]);
@@ -53,12 +57,14 @@  discard block
 block discarded – undo
53 57
 
54 58
         $profiler = null;
55 59
 
56
-        if (Service::hasRunTimeFlag(RuntimeStatus::IN_PROFILE_MODE)) {
60
+        if (Service::hasRunTimeFlag(RuntimeStatus::IN_PROFILE_MODE))
61
+        {
57 62
             $profiler = new Profile();
58 63
             $twig->addExtension(new ProfilerExtension($profiler));
59 64
         }
60 65
 
61
-        if ($configuration->isDebug()) {
66
+        if ($configuration->isDebug())
67
+        {
62 68
             $twig->addExtension(new DebugExtension());
63 69
             $twig->enableDebug();
64 70
         }
Please login to merge, or discard this patch.
src/Templating/Twig/TwigExtension.php 1 patch
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,7 +32,8 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $tag = lcfirst(str_replace('parseMarkup', '', (string)$name));
34 34
 
35
-        if (!$tag) {
35
+        if (!$tag)
36
+        {
36 37
             throw new BadMethodCallException("No method {$name} found in this class.");
37 38
         }
38 39
 
@@ -47,8 +48,10 @@  discard block
 block discarded – undo
47 48
     public function addFilters(/* iterable */ $filters): void
48 49
     {
49 50
         /** @var AbstractTwigExtension|TwigFilterInterface $filter */
50
-        foreach ($filters as $filter) {
51
-            if (Service::hasRunTimeFlag(RuntimeStatus::IN_SAFE_MODE) && $filter::disableInSafeMode()) {
51
+        foreach ($filters as $filter)
52
+        {
53
+            if (Service::hasRunTimeFlag(RuntimeStatus::IN_SAFE_MODE) && $filter::disableInSafeMode())
54
+            {
52 55
                 continue;
53 56
             }
54 57
 
@@ -59,8 +62,10 @@  discard block
 block discarded – undo
59 62
     public function addFunctions(/* iterable */ $functions): void
60 63
     {
61 64
         /** @var AbstractTwigExtension|TwigFunctionInterface $fxn */
62
-        foreach ($functions as $fxn) {
63
-            if (Service::hasRunTimeFlag(RuntimeStatus::IN_SAFE_MODE) && $fxn::disableInSafeMode()) {
65
+        foreach ($functions as $fxn)
66
+        {
67
+            if (Service::hasRunTimeFlag(RuntimeStatus::IN_SAFE_MODE) && $fxn::disableInSafeMode())
68
+            {
64 69
                 continue;
65 70
             }
66 71
 
@@ -72,7 +77,8 @@  discard block
 block discarded – undo
72 77
     {
73 78
         $filters = $this->filters;
74 79
 
75
-        foreach ($this->markupManager->getTemplateTags() as $tag) {
80
+        foreach ($this->markupManager->getTemplateTags() as $tag)
81
+        {
76 82
             // Since we can't pass what tag/markup language we're using to the callable, let's make the callable to a
77 83
             // non-existent method that will be handled by __call()
78 84
             $filters[] = new TwigFilter(
@@ -94,7 +100,8 @@  discard block
 block discarded – undo
94 100
     {
95 101
         $tokenParsers = [];
96 102
 
97
-        foreach ($this->markupManager->getTemplateTags() as $tag) {
103
+        foreach ($this->markupManager->getTemplateTags() as $tag)
104
+        {
98 105
             $tokenParsers[] = new TokenParser($tag);
99 106
         }
100 107
 
Please login to merge, or discard this patch.
src/Templating/Twig/TwigFileLoader.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,8 @@
 block discarded – undo
17 17
     {
18 18
         $template = $this->findTemplate($name);
19 19
 
20
-        if (Service::hasRunTimeFlag(RuntimeStatus::IN_SERVE_MODE)) {
20
+        if (Service::hasRunTimeFlag(RuntimeStatus::IN_SERVE_MODE))
21
+        {
21 22
             return sprintf('%s_%s', $template, filemtime($template));
22 23
         }
23 24
 
Please login to merge, or discard this patch.
src/Templating/Twig/TwigTemplate.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@
 block discarded – undo
31 31
     {
32 32
         $parent = $this->template->getParent([]);
33 33
 
34
-        if ($parent === false) {
34
+        if ($parent === false)
35
+        {
35 36
             return false;
36 37
         }
37 38
 
Please login to merge, or discard this patch.
src/FrontMatter/ExpandedValue.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@
 block discarded – undo
86 86
      *
87 87
      * @param string $variableName
88 88
      */
89
-    public function setIterator($variableName, int|string $variableValue): void
89
+    public function setIterator($variableName, int | string $variableValue): void
90 90
     {
91 91
         $this->iterators[$variableName] = $variableValue;
92 92
     }
Please login to merge, or discard this patch.
src/FrontMatter/FrontMatterParser.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
     // Utility functions
406 406
     //
407 407
 
408
-    private function castDateTimeTimezone(int|string $epochTime): bool|DateTime
408
+    private function castDateTimeTimezone(int | string $epochTime): bool | DateTime
409 409
     {
410 410
         $timezone = new DateTimeZone(date_default_timezone_get());
411 411
         $value = DateTime::createFromFormat('U', (string)$epochTime);
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
         return $value;
415 415
     }
416 416
 
417
-    private function guessDateTime(mixed $guess): bool|DateTime
417
+    private function guessDateTime(mixed $guess): bool | DateTime
418 418
     {
419 419
         if ($guess instanceof DateTime) {
420 420
             return $guess;
Please login to merge, or discard this patch.
Braces   +55 added lines, -25 removed lines patch added patch discarded remove patch
@@ -179,14 +179,16 @@  discard block
 block discarded – undo
179 179
      */
180 180
     private function handleDateField(): void
181 181
     {
182
-        if (!isset($this->frontMatter['date'])) {
182
+        if (!isset($this->frontMatter['date']))
183
+        {
183 184
             return;
184 185
         }
185 186
 
186 187
         $date = &$this->frontMatter['date'];
187 188
         $itemDate = $this->guessDateTime($date);
188 189
 
189
-        if (!$itemDate === false) {
190
+        if (!$itemDate === false)
191
+        {
190 192
             $this->frontMatter['date'] = $itemDate->format('U');
191 193
             $this->frontMatter['year'] = $itemDate->format('Y');
192 194
             $this->frontMatter['month'] = $itemDate->format('m');
@@ -207,17 +209,25 @@  discard block
 block discarded – undo
207 209
     {
208 210
         ++$this->nestingLevel;
209 211
 
210
-        foreach ($yaml as $key => &$value) {
212
+        foreach ($yaml as $key => &$value)
213
+        {
211 214
             $this->yamlKeys[$this->nestingLevel] = $key;
212 215
             $keys = implode('.', $this->yamlKeys);
213 216
 
214
-            if (in_array($key, self::$expandableFields, true)) {
217
+            if (in_array($key, self::$expandableFields, true))
218
+            {
215 219
                 $value = $this->evaluateExpandableField($keys, $value);
216
-            } elseif (is_array($value)) {
220
+            }
221
+            elseif (is_array($value))
222
+            {
217 223
                 $this->evaluateBlock($value);
218
-            } elseif (is_string($value)) {
224
+            }
225
+            elseif (is_string($value))
226
+            {
219 227
                 $value = $this->evaluateBasicType($keys, $value);
220
-            } elseif ($value instanceof DateTime) {
228
+            }
229
+            elseif ($value instanceof DateTime)
230
+            {
221 231
                 $value = $this->castDateTimeTimezone($value->format('U'));
222 232
             }
223 233
         }
@@ -234,19 +244,22 @@  discard block
 block discarded – undo
234 244
      */
235 245
     private function evaluateExpandableField($key, $fmStatement): array
236 246
     {
237
-        if (!is_array($fmStatement)) {
247
+        if (!is_array($fmStatement))
248
+        {
238 249
             $fmStatement = [$fmStatement];
239 250
         }
240 251
 
241 252
         $wip = [];
242 253
 
243
-        foreach ($fmStatement as $statement) {
254
+        foreach ($fmStatement as $statement)
255
+        {
244 256
             $value = $this->evaluateBasicType($key, $statement, true);
245 257
 
246 258
             // Only continue expansion if there are Front Matter variables remain in the string, this means there'll be
247 259
             // Front Matter variables referencing arrays
248 260
             $expandingVars = $this->findFrontMatterVariables($value);
249
-            if (!empty($expandingVars)) {
261
+            if (!empty($expandingVars))
262
+            {
250 263
                 $value = $this->evaluateArrayType($key, $value, $expandingVars);
251 264
             }
252 265
 
@@ -267,23 +280,28 @@  discard block
 block discarded – undo
267 280
      */
268 281
     private function evaluateArrayType($frontMatterKey, $expandableValue, $arrayVariableNames): array
269 282
     {
270
-        if (!is_array($expandableValue)) {
283
+        if (!is_array($expandableValue))
284
+        {
271 285
             $expandableValue = [$expandableValue];
272 286
         }
273 287
 
274 288
         $this->expansionUsed = true;
275 289
 
276
-        foreach ($arrayVariableNames as $variable) {
290
+        foreach ($arrayVariableNames as $variable)
291
+        {
277 292
             $variableValue = $this->getVariableValue($frontMatterKey, $variable);
278 293
 
279
-            if (ArrayUtilities::is_multidimensional($variableValue)) {
294
+            if (ArrayUtilities::is_multidimensional($variableValue))
295
+            {
280 296
                 throw new YamlUnsupportedVariableException("Yaml array expansion is not supported with multidimensional arrays with `{$variable}` for key `{$frontMatterKey}`");
281 297
             }
282 298
 
283 299
             $wip = [];
284 300
 
285
-            foreach ($expandableValue as &$statement) {
286
-                foreach ($variableValue as $value) {
301
+            foreach ($expandableValue as &$statement)
302
+            {
303
+                foreach ($variableValue as $value)
304
+                {
287 305
                     $evaluatedValue = ($statement instanceof ExpandedValue) ? clone $statement : new ExpandedValue($statement);
288 306
 
289 307
                     $varTemplate = $this->getVariableTemplate($variable);
@@ -317,11 +335,14 @@  discard block
 block discarded – undo
317 335
     {
318 336
         $variables = $this->findFrontMatterVariables($string);
319 337
 
320
-        foreach ($variables as $variable) {
338
+        foreach ($variables as $variable)
339
+        {
321 340
             $value = $this->getVariableValue($key, $variable);
322 341
 
323
-            if (is_array($value) || is_bool($value)) {
324
-                if ($ignoreArrays) {
342
+            if (is_array($value) || is_bool($value))
343
+            {
344
+                if ($ignoreArrays)
345
+                {
325 346
                     continue;
326 347
                 }
327 348
 
@@ -373,13 +394,17 @@  discard block
 block discarded – undo
373 394
         $isPrimitive = !str_contains($varName, '.');
374 395
         $variableVal = null;
375 396
 
376
-        if ($isPrimitive) {
397
+        if ($isPrimitive)
398
+        {
377 399
             $variableVal = __::get($this->frontMatter, $varName);
378
-        } else {
400
+        }
401
+        else
402
+        {
379 403
             $variableVal = __::get($this->complexVariables, $varName);
380 404
         }
381 405
 
382
-        if ($variableVal === null) {
406
+        if ($variableVal === null)
407
+        {
383 408
             throw new YamlVariableUndefinedException("Yaml variable `{$varName}` is not defined for: {$key}");
384 409
         }
385 410
 
@@ -416,16 +441,21 @@  discard block
 block discarded – undo
416 441
 
417 442
     private function guessDateTime(mixed $guess): bool|DateTime
418 443
     {
419
-        if ($guess instanceof DateTime) {
444
+        if ($guess instanceof DateTime)
445
+        {
420 446
             return $guess;
421 447
         }
422
-        if (is_numeric($guess)) {
448
+        if (is_numeric($guess))
449
+        {
423 450
             return $this->castDateTimeTimezone($guess);
424 451
         }
425 452
 
426
-        try {
453
+        try
454
+        {
427 455
             return new DateTime($guess);
428
-        } catch (Exception) {
456
+        }
457
+        catch (Exception)
458
+        {
429 459
             return false;
430 460
         }
431 461
     }
Please login to merge, or discard this patch.
src/Service.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@
 block discarded – undo
47 47
 
48 48
     public static function getWorkingDirectory()
49 49
     {
50
-        if (!self::$workingDirectory) {
50
+        if (!self::$workingDirectory)
51
+        {
51 52
             return getcwd();
52 53
         }
53 54
 
Please login to merge, or discard this patch.
src/Markup/SyntaxHighlighterTrait.php 2 patches
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -35,15 +35,18 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $langDef = $this->parseInfoString($infoString);
37 37
 
38
-        try {
38
+        try
39
+        {
39 40
             $highlighted = $this->highlighter->highlight($langDef['language'], $rawCode);
40 41
             $value = $highlighted->value;
41 42
 
42
-            if (Service::hasRunTimeFlag(RuntimeStatus::USING_LINE_NUMBERS) || count($langDef['selectedLines']) > 0) {
43
+            if (Service::hasRunTimeFlag(RuntimeStatus::USING_LINE_NUMBERS) || count($langDef['selectedLines']) > 0)
44
+            {
43 45
                 $lines = splitCodeIntoArray($value);
44 46
                 $value = '';
45 47
 
46
-                foreach ($lines as $i => $line) {
48
+                foreach ($lines as $i => $line)
49
+                {
47 50
                     // `$i + 1` since our line numbers are indexed starting at 1
48 51
                     $value .= vsprintf("<div class=\"loc%s\"><span>%s</span></div>\n", [
49 52
                         isset($langDef['selectedLines'][$i + 1]) ? ' highlighted' : '',
@@ -58,9 +61,12 @@  discard block
 block discarded – undo
58 61
             ]);
59 62
         }
60 63
         // Exception thrown when language not supported
61
-        catch (DomainException) {
64
+        catch (DomainException)
65
+        {
62 66
             trigger_error("An unsupported language (${langDef['language']}) was detected in a code block", E_USER_WARNING);
63
-        } catch (Exception) {
67
+        }
68
+        catch (Exception)
69
+        {
64 70
             trigger_error('An error has occurred in the highlight.php language definition files', E_USER_WARNING);
65 71
         }
66 72
 
@@ -82,7 +88,8 @@  discard block
 block discarded – undo
82 88
 
83 89
         $bracePos = strpos($infoString, '{');
84 90
 
85
-        if ($bracePos === false) {
91
+        if ($bracePos === false)
92
+        {
86 93
             return $definition;
87 94
         }
88 95
 
@@ -90,8 +97,10 @@  discard block
 block discarded – undo
90 97
         $lineDefinition = substr($infoString, $bracePos + 1, -1);
91 98
         $lineNumbers = explode(',', $lineDefinition);
92 99
 
93
-        foreach ($lineNumbers as $lineNumber) {
94
-            if (!str_contains($lineNumber, '-')) {
100
+        foreach ($lineNumbers as $lineNumber)
101
+        {
102
+            if (!str_contains($lineNumber, '-'))
103
+            {
95 104
                 $definition['selectedLines'][intval($lineNumber)] = true;
96 105
 
97 106
                 continue;
@@ -99,14 +108,16 @@  discard block
 block discarded – undo
99 108
 
100 109
             $extremes = explode('-', $lineNumber);
101 110
 
102
-            if (count($extremes) !== 2) {
111
+            if (count($extremes) !== 2)
112
+            {
103 113
                 continue;
104 114
             }
105 115
 
106 116
             $start = intval($extremes[0]);
107 117
             $end = intval($extremes[1]);
108 118
 
109
-            for ($i = $start; $i <= $end; ++$i) {
119
+            for ($i = $start; $i <= $end; ++$i)
120
+            {
110 121
                 $definition['selectedLines'][$i] = true;
111 122
             }
112 123
         }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
         }
60 60
         // Exception thrown when language not supported
61 61
         catch (DomainException) {
62
-            trigger_error("An unsupported language (${langDef['language']}) was detected in a code block", E_USER_WARNING);
62
+            trigger_error("An unsupported language (${langdef['language']}) was detected in a code block", E_USER_WARNING);
63 63
         } catch (Exception) {
64 64
             trigger_error('An error has occurred in the highlight.php language definition files', E_USER_WARNING);
65 65
         }
Please login to merge, or discard this patch.