@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function getExplicitAsset($permalink): ?File |
57 | 57 | { |
58 | - if (isset($this->explicitAssets[$permalink])) { |
|
58 | + if (isset($this->explicitAssets[$permalink])) |
|
59 | + { |
|
59 | 60 | return $this->explicitAssets[$permalink]; |
60 | 61 | } |
61 | 62 | |
@@ -85,7 +86,8 @@ discard block |
||
85 | 86 | { |
86 | 87 | $this->logger->notice('Copying manual assets...'); |
87 | 88 | |
88 | - foreach ($this->explicitAssets as $targetPath => $manualAsset) { |
|
89 | + foreach ($this->explicitAssets as $targetPath => $manualAsset) |
|
90 | + { |
|
89 | 91 | $this->handleTrackableItem($manualAsset, [ |
90 | 92 | 'prefix' => '', |
91 | 93 | 'siteTargetPath' => $targetPath, |
@@ -140,20 +142,25 @@ discard block |
||
140 | 142 | */ |
141 | 143 | protected function handleTrackableItem(File $file, array $options = []): mixed |
142 | 144 | { |
143 | - if (!$file->exists()) { |
|
145 | + if (!$file->exists()) |
|
146 | + { |
|
144 | 147 | return null; |
145 | 148 | } |
146 | 149 | |
147 | 150 | $filePath = $file->getRealPath(); |
148 | 151 | $pathToStrip = fs::appendPath(Service::getWorkingDirectory(), $options['prefix']); |
149 | 152 | |
150 | - if (isset($options['siteTargetPath'])) { |
|
153 | + if (isset($options['siteTargetPath'])) |
|
154 | + { |
|
151 | 155 | $siteTargetPath = $options['siteTargetPath']; |
152 | - } else { |
|
156 | + } |
|
157 | + else |
|
158 | + { |
|
153 | 159 | $siteTargetPath = ltrim(str_replace($pathToStrip, '', $filePath), DIRECTORY_SEPARATOR); |
154 | 160 | } |
155 | 161 | |
156 | - try { |
|
162 | + try |
|
163 | + { |
|
157 | 164 | $this->addFileToTracker($file); |
158 | 165 | $this->saveTrackerOptions($file->getRelativeFilePath(), $options); |
159 | 166 | |
@@ -161,7 +168,9 @@ discard block |
||
161 | 168 | $this->logger->info('Copying file: {file}...', [ |
162 | 169 | 'file' => $file->getRelativeFilePath(), |
163 | 170 | ]); |
164 | - } catch (Exception $e) { |
|
171 | + } |
|
172 | + catch (Exception $e) |
|
173 | + { |
|
165 | 174 | $this->logger->error($e->getMessage()); |
166 | 175 | } |
167 | 176 |
@@ -42,7 +42,8 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function compileManager(): void |
44 | 44 | { |
45 | - if (!$this->configuration->hasCollections()) { |
|
45 | + if (!$this->configuration->hasCollections()) |
|
46 | + { |
|
46 | 47 | $this->logger->notice('No Collections defined... Ignoring'); |
47 | 48 | |
48 | 49 | return; |
@@ -79,7 +80,8 @@ discard block |
||
79 | 80 | */ |
80 | 81 | public function &getContentItem($filePath): ContentItem |
81 | 82 | { |
82 | - if (!isset($this->trackedItemsFlattened[$filePath])) { |
|
83 | + if (!isset($this->trackedItemsFlattened[$filePath])) |
|
84 | + { |
|
83 | 85 | throw new TrackedItemNotFoundException("The ContentItem at '{$filePath}' was not found."); |
84 | 86 | } |
85 | 87 | |
@@ -103,7 +105,8 @@ discard block |
||
103 | 105 | */ |
104 | 106 | public function parseCollections($collections): void |
105 | 107 | { |
106 | - if ($collections == null || empty($collections)) { |
|
108 | + if ($collections == null || empty($collections)) |
|
109 | + { |
|
107 | 110 | $this->logger->debug('No collections found, nothing to parse.'); |
108 | 111 | |
109 | 112 | return; |
@@ -117,7 +120,8 @@ discard block |
||
117 | 120 | * $collection['name'] string The name of the collection |
118 | 121 | * ['folder'] string The folder where this collection has its ContentItems |
119 | 122 | */ |
120 | - foreach ($collections as $collection) { |
|
123 | + foreach ($collections as $collection) |
|
124 | + { |
|
121 | 125 | $this->logger->notice('Loading "{name}" collection...', [ |
122 | 126 | 'name' => $collection['name'], |
123 | 127 | ]); |
@@ -197,7 +201,8 @@ discard block |
||
197 | 201 | $folders = array_column($this->collectionDefinitions, 'folder'); |
198 | 202 | $index = array_search($file->getRelativeParentFolder(), $folders); |
199 | 203 | |
200 | - if (isset($this->collectionDefinitions[$index]['name'])) { |
|
204 | + if (isset($this->collectionDefinitions[$index]['name'])) |
|
205 | + { |
|
201 | 206 | return $this->collectionDefinitions[$index]['name']; |
202 | 207 | } |
203 | 208 |
@@ -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 |