@@ -44,7 +44,8 @@ |
||
44 | 44 | |
45 | 45 | $output = $this->getContainer()->get('output'); |
46 | 46 | |
47 | - if (extension_loaded('xdebug') && !getenv('STAKX_DISABLE_XDEBUG_WARN')) { |
|
47 | + if (extension_loaded('xdebug') && !getenv('STAKX_DISABLE_XDEBUG_WARN')) |
|
48 | + { |
|
48 | 49 | $output->writeln('<fg=black;bg=yellow>You are running Stakx with xdebug enabled. This has a major impact on runtime performance.</>'); |
49 | 50 | } |
50 | 51 |
@@ -30,7 +30,8 @@ discard block |
||
30 | 30 | |
31 | 31 | public function build() |
32 | 32 | { |
33 | - if (!$this->isPhar()) { |
|
33 | + if (!$this->isPhar()) |
|
34 | + { |
|
34 | 35 | $this->compileAndDump(); |
35 | 36 | } |
36 | 37 | |
@@ -49,7 +50,8 @@ discard block |
||
49 | 50 | ->addCompilerPass(new RegisterListenersPass()) |
50 | 51 | ; |
51 | 52 | |
52 | - foreach ($this->options['parameters'] as $key => $value) { |
|
53 | + foreach ($this->options['parameters'] as $key => $value) |
|
54 | + { |
|
53 | 55 | $container->setParameter($key, $value); |
54 | 56 | } |
55 | 57 |
@@ -44,7 +44,8 @@ discard block |
||
44 | 44 | |
45 | 45 | Service::setRuntimeFlag(RuntimeStatus::IN_SERVE_MODE); |
46 | 46 | |
47 | - try { |
|
47 | + try |
|
48 | + { |
|
48 | 49 | $output->writeln('The `serve` option is still an experimental feature and has a few known bugs.'); |
49 | 50 | |
50 | 51 | $this->configureConfigurationFile($input); |
@@ -71,7 +72,9 @@ discard block |
||
71 | 72 | $output->writeln('Listening on ' . str_replace('tcp:', 'http:', $socket->getAddress())); |
72 | 73 | |
73 | 74 | $loop->run(); |
74 | - } catch (FileAwareException $e) { |
|
75 | + } |
|
76 | + catch (FileAwareException $e) |
|
77 | + { |
|
75 | 78 | $output->writeln(StrUtils::interpolate( |
76 | 79 | "Your website failed to build with the following error in file '{file}'{line}: {message}", |
77 | 80 | [ |
@@ -80,7 +83,9 @@ discard block |
||
80 | 83 | 'message' => $e->getMessage(), |
81 | 84 | ] |
82 | 85 | )); |
83 | - } catch (Exception $e) { |
|
86 | + } |
|
87 | + catch (Exception $e) |
|
88 | + { |
|
84 | 89 | $output->writeln(sprintf( |
85 | 90 | 'Your website failed to build with the following error: %s', |
86 | 91 | $e->getMessage() |
@@ -62,7 +62,8 @@ discard block |
||
62 | 62 | $this->handleDeprecations($input, $output); |
63 | 63 | $this->setRunTimeOptions($input); |
64 | 64 | |
65 | - try { |
|
65 | + try |
|
66 | + { |
|
66 | 67 | $this->configureConfigurationFile($input); |
67 | 68 | |
68 | 69 | $website = $this->getContainer()->get(Website::class); |
@@ -74,7 +75,9 @@ discard block |
||
74 | 75 | )); |
75 | 76 | |
76 | 77 | return 0; |
77 | - } catch (FileAwareException $e) { |
|
78 | + } |
|
79 | + catch (FileAwareException $e) |
|
80 | + { |
|
78 | 81 | $output->writeln(StrUtils::interpolate( |
79 | 82 | "Your website failed to build with the following error in file '{file}'{line}: {message}", |
80 | 83 | [ |
@@ -83,7 +86,9 @@ discard block |
||
83 | 86 | 'message' => $e->getMessage(), |
84 | 87 | ] |
85 | 88 | )); |
86 | - } catch (Exception $e) { |
|
89 | + } |
|
90 | + catch (Exception $e) |
|
91 | + { |
|
87 | 92 | $output->writeln(sprintf( |
88 | 93 | 'Your website failed to build with the following error: %s', |
89 | 94 | $e->getMessage() |
@@ -111,33 +116,39 @@ discard block |
||
111 | 116 | |
112 | 117 | protected function setRunTimeOptions(InputInterface $input): void |
113 | 118 | { |
114 | - if ($input->getOption(self::NO_CLEAN)) { |
|
119 | + if ($input->getOption(self::NO_CLEAN)) |
|
120 | + { |
|
115 | 121 | Service::setRuntimeFlag(RuntimeStatus::BOOT_WITHOUT_CLEAN); |
116 | 122 | } |
117 | 123 | |
118 | - if ($input->getOption(self::USE_DRAFTS)) { |
|
124 | + if ($input->getOption(self::USE_DRAFTS)) |
|
125 | + { |
|
119 | 126 | Service::setRuntimeFlag(RuntimeStatus::USING_DRAFTS); |
120 | 127 | } |
121 | 128 | |
122 | - if ($input->getOption(self::USE_CACHE)) { |
|
129 | + if ($input->getOption(self::USE_CACHE)) |
|
130 | + { |
|
123 | 131 | Service::setRuntimeFlag(RuntimeStatus::USING_CACHE); |
124 | 132 | } |
125 | 133 | |
126 | - if ($input->getOption(self::SAFE_MODE)) { |
|
134 | + if ($input->getOption(self::SAFE_MODE)) |
|
135 | + { |
|
127 | 136 | // Caches could be maliciously manipulated so disable reading the cache in safe mode |
128 | 137 | Service::removeRuntimeFlag(RuntimeStatus::USING_CACHE); |
129 | 138 | |
130 | 139 | Service::setRuntimeFlag(RuntimeStatus::IN_SAFE_MODE); |
131 | 140 | } |
132 | 141 | |
133 | - if ($input->getOption(self::BUILD_PROFILE)) { |
|
142 | + if ($input->getOption(self::BUILD_PROFILE)) |
|
143 | + { |
|
134 | 144 | Service::setRuntimeFlag(RuntimeStatus::IN_PROFILE_MODE); |
135 | 145 | } |
136 | 146 | } |
137 | 147 | |
138 | 148 | protected function handleDeprecations(InputInterface $input, OutputInterface $output): void |
139 | 149 | { |
140 | - if ($input->getOption(self::NO_CONF)) { |
|
150 | + if ($input->getOption(self::NO_CONF)) |
|
151 | + { |
|
141 | 152 | $output->writeln('Deprecation: The "--no-conf" option is no longer supported. You must have a configuration file.'); |
142 | 153 | } |
143 | 154 | } |
@@ -17,11 +17,13 @@ |
||
17 | 17 | |
18 | 18 | public function getContainer() |
19 | 19 | { |
20 | - if ($this->container === null) { |
|
20 | + if ($this->container === null) |
|
21 | + { |
|
21 | 22 | /** @var Application $application */ |
22 | 23 | $application = $this->getApplication(); |
23 | 24 | |
24 | - if ($application === null) { |
|
25 | + if ($application === null) |
|
26 | + { |
|
25 | 27 | throw new LogicException('The container cannot be retrieved as the application instance is not yet set.'); |
26 | 28 | } |
27 | 29 |
@@ -20,7 +20,8 @@ |
||
20 | 20 | |
21 | 21 | public function filter($in, $out, &$consumed, $closing): int |
22 | 22 | { |
23 | - while ($bucket = stream_bucket_make_writeable($in)) { |
|
23 | + while ($bucket = stream_bucket_make_writeable($in)) |
|
24 | + { |
|
24 | 25 | self::$output .= $bucket->data; |
25 | 26 | $consumed += $bucket->datalen; |
26 | 27 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | private readonly FilesystemPath $folder; |
23 | 23 | |
24 | - public function __construct(string|FilesystemPath $folderPath) |
|
24 | + public function __construct(string | FilesystemPath $folderPath) |
|
25 | 25 | { |
26 | 26 | $this->frozen = false; |
27 | 27 | $this->folder = new FilesystemPath($folderPath); |
@@ -26,7 +26,8 @@ discard block |
||
26 | 26 | $this->frozen = false; |
27 | 27 | $this->folder = new FilesystemPath($folderPath); |
28 | 28 | |
29 | - if (!$this->folder->isDir()) { |
|
29 | + if (!$this->folder->isDir()) |
|
30 | + { |
|
30 | 31 | throw new FileNotFoundException(sprintf('The folder could not be found: %s', $folderPath)); |
31 | 32 | } |
32 | 33 | } |
@@ -71,11 +72,13 @@ discard block |
||
71 | 72 | */ |
72 | 73 | public function setTargetDirectory(string $folderName): void |
73 | 74 | { |
74 | - if ($this->isFrozen()) { |
|
75 | + if ($this->isFrozen()) |
|
76 | + { |
|
75 | 77 | throw new Exception('A frozen folder object cannot be modified.'); |
76 | 78 | } |
77 | 79 | |
78 | - if ($folderName === null || empty($folderName)) { |
|
80 | + if ($folderName === null || empty($folderName)) |
|
81 | + { |
|
79 | 82 | return; |
80 | 83 | } |
81 | 84 | |
@@ -110,7 +113,8 @@ discard block |
||
110 | 113 | $targetFile = $this->folder->generatePath($relativePath); |
111 | 114 | $targetFolderPath = (string)$targetFile->getParentDirectory(); |
112 | 115 | |
113 | - if (!file_exists($targetFolderPath)) { |
|
116 | + if (!file_exists($targetFolderPath)) |
|
117 | + { |
|
114 | 118 | mkdir($targetFolderPath, 0755, true); |
115 | 119 | } |
116 | 120 |
@@ -14,9 +14,12 @@ |
||
14 | 14 | */ |
15 | 15 | public static function transformData($content): array |
16 | 16 | { |
17 | - try { |
|
17 | + try |
|
18 | + { |
|
18 | 19 | return json_decode($content, true, 512, JSON_THROW_ON_ERROR); |
19 | - } catch (\JsonException) { |
|
20 | + } |
|
21 | + catch (\JsonException) |
|
22 | + { |
|
20 | 23 | return []; |
21 | 24 | } |
22 | 25 | } |
@@ -65,7 +65,8 @@ discard block |
||
65 | 65 | { |
66 | 66 | $Block = parent::blockHeader($Line); |
67 | 67 | |
68 | - if (isset($Block['element']['text'])) { |
|
68 | + if (isset($Block['element']['text'])) |
|
69 | + { |
|
69 | 70 | $Block['element']['attributes']['id'] = $this->slugifyHeader($Block); |
70 | 71 | } |
71 | 72 | |
@@ -79,10 +80,12 @@ discard block |
||
79 | 80 | // https://github.com/erusev/parsedown-extra/issues/134 |
80 | 81 | $Block = @parent::blockSetextHeader($Line, $Block); |
81 | 82 | |
82 | - if (isset($Block['element']['name'])) { |
|
83 | + if (isset($Block['element']['name'])) |
|
84 | + { |
|
83 | 85 | $element = $Block['element']['name']; |
84 | 86 | |
85 | - if (in_array($element, ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])) { |
|
87 | + if (in_array($element, ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])) |
|
88 | + { |
|
86 | 89 | $Block['element']['attributes']['id'] = $this->slugifyHeader($Block); |
87 | 90 | } |
88 | 91 | } |
@@ -93,7 +96,8 @@ discard block |
||
93 | 96 | protected function blockFencedCodeComplete($block) |
94 | 97 | { |
95 | 98 | // The class has a `language-` prefix, remove this to get the language |
96 | - if (isset($block['element']['text']['attributes']) && Service::hasRunTimeFlag(RuntimeStatus::USING_HIGHLIGHTER)) { |
|
99 | + if (isset($block['element']['text']['attributes']) && Service::hasRunTimeFlag(RuntimeStatus::USING_HIGHLIGHTER)) |
|
100 | + { |
|
97 | 101 | $cssClass = $block['element']['text']['attributes']['class']; |
98 | 102 | $block['markup'] = $this->highlightCode($cssClass, $block['element']['text']['text']); |
99 | 103 | |
@@ -107,7 +111,8 @@ discard block |
||
107 | 111 | { |
108 | 112 | $imageBlock = parent::inlineImage($Excerpt); |
109 | 113 | |
110 | - if ($imageBlock !== null) { |
|
114 | + if ($imageBlock !== null) |
|
115 | + { |
|
111 | 116 | $imageSrc = trim((string)$imageBlock['element']['attributes']['src']); |
112 | 117 | |
113 | 118 | $this->registerAsset($imageSrc); |