@@ -17,13 +17,17 @@ |
||
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 |
@@ -20,21 +20,24 @@ |
||
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 |
@@ -13,7 +13,7 @@ |
||
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 |
@@ -27,10 +27,12 @@ discard block |
||
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 |
||
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 |
@@ -11,8 +11,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -28,7 +28,8 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -21,8 +21,10 @@ discard block |
||
21 | 21 | // build a replacement array with braces around the context keys |
22 | 22 | $replace = []; |
23 | 23 | |
24 | - foreach ($context as $key => $val) { |
|
25 | - if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { |
|
24 | + foreach ($context as $key => $val) |
|
25 | + { |
|
26 | + if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) |
|
27 | + { |
|
26 | 28 | $replace[sprintf('{%s}', $key)] = $val; |
27 | 29 | } |
28 | 30 | } |
@@ -38,7 +40,8 @@ discard block |
||
38 | 40 | */ |
39 | 41 | public static function canBeCastedToString(mixed $mixed): bool |
40 | 42 | { |
41 | - if (is_string($mixed)) { |
|
43 | + if (is_string($mixed)) |
|
44 | + { |
|
42 | 45 | return true; |
43 | 46 | } |
44 | 47 |
@@ -108,7 +108,7 @@ |
||
108 | 108 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
109 | 109 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
110 | 110 | */ |
111 | - public function writeln(string|array $messages, $options = 0) |
|
111 | + public function writeln(string | array $messages, $options = 0) |
|
112 | 112 | { |
113 | 113 | $this->output->writeln($messages, $options); |
114 | 114 | } |
@@ -24,17 +24,23 @@ |
||
24 | 24 | { |
25 | 25 | $pageView = $event->getPageView(); |
26 | 26 | |
27 | - if ($pageView instanceof StaticPageView || $pageView instanceof DynamicPageView) { |
|
27 | + if ($pageView instanceof StaticPageView || $pageView instanceof DynamicPageView) |
|
28 | + { |
|
28 | 29 | $redirects = $pageView->getRedirects(); |
29 | 30 | |
30 | - foreach ($redirects as $redirect) { |
|
31 | + foreach ($redirects as $redirect) |
|
32 | + { |
|
31 | 33 | $this->redirectMapper->registerRedirect($redirect, $pageView->getPermalink()); |
32 | 34 | } |
33 | - } elseif ($pageView instanceof RepeaterPageView) { |
|
35 | + } |
|
36 | + elseif ($pageView instanceof RepeaterPageView) |
|
37 | + { |
|
34 | 38 | $permalinks = $pageView->getRepeaterPermalinks(); |
35 | 39 | |
36 | - foreach ($pageView->getRepeaterRedirects() as $repeaterRedirect) { |
|
37 | - foreach ($repeaterRedirect as $index => $redirect) { |
|
40 | + foreach ($pageView->getRepeaterRedirects() as $repeaterRedirect) |
|
41 | + { |
|
42 | + foreach ($repeaterRedirect as $index => $redirect) |
|
43 | + { |
|
38 | 44 | $this->redirectMapper->registerRedirect( |
39 | 45 | $redirect->getEvaluated(), |
40 | 46 | $permalinks[$index]->getEvaluated() |
@@ -41,7 +41,8 @@ discard block |
||
41 | 41 | $configuration = $event->getConfiguration()->getConfiguration(); |
42 | 42 | |
43 | 43 | /** @var AssetEngineInterface $engine */ |
44 | - foreach ($this->assetEngineManager->getEngines() as $engine) { |
|
44 | + foreach ($this->assetEngineManager->getEngines() as $engine) |
|
45 | + { |
|
45 | 46 | $defaults = __::get($configuration, $engine->getConfigurationNamespace(), []); |
46 | 47 | $options = array_merge($engine->getDefaultConfiguration(), $defaults); |
47 | 48 | |
@@ -55,17 +56,20 @@ discard block |
||
55 | 56 | * @var string $folder |
56 | 57 | * @var AssetEngineInterface $engine |
57 | 58 | */ |
58 | - foreach ($this->assetEngineManager->getFoldersToWatch() as $folder => $engine) { |
|
59 | + foreach ($this->assetEngineManager->getFoldersToWatch() as $folder => $engine) |
|
60 | + { |
|
59 | 61 | $assetFolder = fs::absolutePath($folder); |
60 | 62 | |
61 | - if (!fs::exists($assetFolder)) { |
|
63 | + if (!fs::exists($assetFolder)) |
|
64 | + { |
|
62 | 65 | continue; |
63 | 66 | } |
64 | 67 | |
65 | 68 | $engine->setPageManager($event->getPageManager()); |
66 | 69 | $extensions = []; |
67 | 70 | |
68 | - foreach ($engine->getExtensions() as $extension) { |
|
71 | + foreach ($engine->getExtensions() as $extension) |
|
72 | + { |
|
69 | 73 | $extensions[] = "/.{$extension}.twig$/"; |
70 | 74 | } |
71 | 75 | |
@@ -75,15 +79,19 @@ discard block |
||
75 | 79 | $definition->flags = FileExplorer::INCLUDE_ONLY_FILES | FileExplorer::IGNORE_DIRECTORIES; |
76 | 80 | $explorer = FileExplorer::createFromDefinition($definition); |
77 | 81 | |
78 | - foreach ($explorer as $file) { |
|
82 | + foreach ($explorer as $file) |
|
83 | + { |
|
79 | 84 | $assetPageView = new StaticPageView($file); |
80 | 85 | |
81 | - try { |
|
86 | + try |
|
87 | + { |
|
82 | 88 | $event->getPageManager()->trackNewPageView($assetPageView); |
83 | 89 | $this->assetPageViews[$assetPageView->getRelativeFilePath()] = [ |
84 | 90 | 'engine' => $engine, |
85 | 91 | ]; |
86 | - } catch (Exception $e) { |
|
92 | + } |
|
93 | + catch (Exception $e) |
|
94 | + { |
|
87 | 95 | $this->logger->error('An exception occurred while creating a Static PageView for an AssetEngine'); |
88 | 96 | $this->logger->error(' {message}', [ |
89 | 97 | 'message' => $e->getMessage(), |
@@ -98,12 +106,14 @@ discard block |
||
98 | 106 | $pageView = $event->getPageView(); |
99 | 107 | $filePath = $pageView->getRelativeFilePath(); |
100 | 108 | |
101 | - if (isset($this->assetPageViews[$filePath])) { |
|
109 | + if (isset($this->assetPageViews[$filePath])) |
|
110 | + { |
|
102 | 111 | /** @var AssetEngineInterface $engine */ |
103 | 112 | $engine = $this->assetPageViews[$filePath]['engine']; |
104 | 113 | $cacheDir = $this->buildCacheFolder($engine); |
105 | 114 | |
106 | - if (Service::hasRunTimeFlag(RuntimeStatus::USING_CACHE)) { |
|
115 | + if (Service::hasRunTimeFlag(RuntimeStatus::USING_CACHE)) |
|
116 | + { |
|
107 | 117 | $engine->loadCache($cacheDir); |
108 | 118 | } |
109 | 119 |