Completed
Push — chore/php-8-migration ( 0b97e4...588942 )
by Vladimir
09:24
created
tests/StakxTestCase.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     // Mock Objects
226 226
     //
227 227
 
228
-    protected function getMockAssetEngineManager(): MockBuilder|AssetEngineManager
228
+    protected function getMockAssetEngineManager(): MockBuilder | AssetEngineManager
229 229
     {
230 230
         return new AssetEngineManager();
231 231
     }
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         return new AssetManager($this->getMockEventDispatcher(), $this->getMockLogger());
236 236
     }
237 237
 
238
-    protected function getMockConfiguration(): MockObject|Configuration
238
+    protected function getMockConfiguration(): MockObject | Configuration
239 239
     {
240 240
         $stub = $this->getMockBuilder(Configuration::class)
241 241
             ->disableOriginalConstructor()
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
         return $stub;
249 249
     }
250 250
 
251
-    protected function getMockPageManager(): PageManager|MockObject
251
+    protected function getMockPageManager(): PageManager | MockObject
252 252
     {
253 253
         $stub = $this->getMockBuilder(PageManager::class)
254 254
             ->disableOriginalConstructor()
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
         return $stub;
261 261
     }
262 262
 
263
-    protected function getMockMenuManager(): MockObject|MenuManager
263
+    protected function getMockMenuManager(): MockObject | MenuManager
264 264
     {
265 265
         $stub = $this->getMockBuilder(MenuManager::class)
266 266
             ->disableOriginalConstructor()
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         return $stub;
273 273
     }
274 274
 
275
-    protected function getMockCollectionManager(): MockObject|CollectionManager
275
+    protected function getMockCollectionManager(): MockObject | CollectionManager
276 276
     {
277 277
         $stub = $this->getMockBuilder(CollectionManager::class)
278 278
             ->disableOriginalConstructor()
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
         return $stub;
285 285
     }
286 286
 
287
-    protected function getMockDataManager(): MockObject|DataManager
287
+    protected function getMockDataManager(): MockObject | DataManager
288 288
     {
289 289
         $stub = $this->getMockBuilder(DataManager::class)
290 290
             ->disableOriginalConstructor()
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
         return $markupEngine;
328 328
     }
329 329
 
330
-    protected function getMockRedirectMapper(): RedirectMapper|MockObject
330
+    protected function getMockRedirectMapper(): RedirectMapper | MockObject
331 331
     {
332 332
         $stub = $this->getMockBuilder(RedirectMapper::class)
333 333
             ->getMock()
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
     /**
342 342
      * Get a mock EventDispatcher.
343 343
      */
344
-    protected function getMockEventDispatcher(): MockObject|EventDispatcherInterface
344
+    protected function getMockEventDispatcher(): MockObject | EventDispatcherInterface
345 345
     {
346 346
         return $this->getMockBuilder(EventDispatcherInterface::class)->getMock();
347 347
     }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
     /**
350 350
      * Get a mock logger.
351 351
      */
352
-    protected function getMockLogger(): MockObject|LoggerInterface
352
+    protected function getMockLogger(): MockObject | LoggerInterface
353 353
     {
354 354
         return $this->getMockBuilder(LoggerInterface::class)->getMock();
355 355
     }
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -72,7 +72,8 @@  discard block
 block discarded – undo
72 72
 
73 73
     public function tearDown(): void
74 74
     {
75
-        if ($this->assetFolder !== null) {
75
+        if ($this->assetFolder !== null)
76
+        {
76 77
             fs::remove($this->assetFolder);
77 78
         }
78 79
     }
@@ -167,7 +168,8 @@  discard block
 block discarded – undo
167 168
     {
168 169
         $body = $this->buildFrontMatterTemplate($frontMatter, $content);
169 170
 
170
-        if (!$filename) {
171
+        if (!$filename)
172
+        {
171 173
             $filename = hash('sha256', (string)random_int(0, mt_getrandmax()));
172 174
         }
173 175
 
@@ -194,7 +196,8 @@  discard block
 block discarded – undo
194 196
     {
195 197
         $results = [];
196 198
 
197
-        foreach ($elements as $element) {
199
+        foreach ($elements as $element)
200
+        {
198 201
             $filename = $element['filename'] ?? null;
199 202
             $frontMatter = (!isset($element['frontmatter']) || empty($element['frontmatter'])) ? [] : $element['frontmatter'];
200 203
             $body = $element['body'] ?? 'Body Text';
@@ -405,7 +408,8 @@  discard block
 block discarded – undo
405 408
             ->value()
406 409
         ;
407 410
 
408
-        if ($fxnToCall === null) {
411
+        if ($fxnToCall === null)
412
+        {
409 413
             throw new BadFunctionCallException(sprintf('No function by the name of "%s" in this class', $method));
410 414
         }
411 415
 
@@ -413,10 +417,14 @@  discard block
 block discarded – undo
413 417
         $callUserFuncArray = [];
414 418
 
415 419
         /** @var ReflectionParameter $argument */
416
-        foreach ($arguments as $argument) {
417
-            if (isset($namedParams[$argument->getName()])) {
420
+        foreach ($arguments as $argument)
421
+        {
422
+            if (isset($namedParams[$argument->getName()]))
423
+            {
418 424
                 $callUserFuncArray[] = $namedParams[$argument->getName()];
419
-            } else {
425
+            }
426
+            else
427
+            {
420 428
                 $callUserFuncArray[] = $argument->getDefaultValue();
421 429
             }
422 430
         }
Please login to merge, or discard this patch.
src/Compiler.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      *
192 192
      * @since 0.1.1
193 193
      */
194
-    public function compilePageView(DynamicPageView|RepeaterPageView|StaticPageView &$pageView): void
194
+    public function compilePageView(DynamicPageView | RepeaterPageView | StaticPageView & $pageView): void
195 195
     {
196 196
         Service::setOption('currentTemplate', $pageView->getAbsoluteFilePath());
197 197
         $this->logger->debug('Compiling {type} PageView: {pageview}', [
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      *
238 238
      * @throws TemplateErrorInterface
239 239
      */
240
-    private function compileStaticPageView(StaticPageView &$pageView): void
240
+    private function compileStaticPageView(StaticPageView & $pageView): void
241 241
     {
242 242
         $this->writeToFilesystem(
243 243
             $pageView->getTargetFile(),
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
      *
254 254
      * @throws TemplateErrorInterface
255 255
      */
256
-    private function compileDynamicPageView(DynamicPageView &$pageView): void
256
+    private function compileDynamicPageView(DynamicPageView & $pageView): void
257 257
     {
258 258
         $contentItems = $pageView->getCollectableItems();
259 259
         $template = $this->createTwigTemplate($pageView);
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      *
285 285
      * @throws TemplateErrorInterface
286 286
      */
287
-    private function compileRepeaterPageView(RepeaterPageView &$pageView): void
287
+    private function compileRepeaterPageView(RepeaterPageView & $pageView): void
288 288
     {
289 289
         $template = $this->createTwigTemplate($pageView);
290 290
         $permalinks = $pageView->getRepeaterPermalinks();
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
      *
326 326
      * @since 0.1.1
327 327
      */
328
-    private function compileStandardRedirects(PermalinkDocument &$pageView): void
328
+    private function compileStandardRedirects(PermalinkDocument & $pageView): void
329 329
     {
330 330
         $redirects = $pageView->getRedirects();
331 331
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
      *
357 357
      * @since 0.1.1
358 358
      */
359
-    private function compileExpandedRedirects(RepeaterPageView &$pageView): void
359
+    private function compileExpandedRedirects(RepeaterPageView & $pageView): void
360 360
     {
361 361
         $permalinks = $pageView->getRepeaterPermalinks();
362 362
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
      *
396 396
      * @since  0.1.1
397 397
      */
398
-    private function buildRepeaterPageViewHTML(TemplateInterface &$template, RepeaterPageView &$pageView, ExpandedValue &$expandedValue): string
398
+    private function buildRepeaterPageViewHTML(TemplateInterface & $template, RepeaterPageView & $pageView, ExpandedValue & $expandedValue): string
399 399
     {
400 400
         $defaultContext = [
401 401
             'this' => $pageView->createJail(),
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
      *
426 426
      * @since  0.1.1
427 427
      */
428
-    private function buildDynamicPageViewHTML(TemplateInterface &$template, CollectableItem|TemplateReadyDocument &$twigItem): string
428
+    private function buildDynamicPageViewHTML(TemplateInterface & $template, CollectableItem | TemplateReadyDocument & $twigItem): string
429 429
     {
430 430
         $defaultContext = [
431 431
             'this' => $twigItem->createJail(),
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
      *
453 453
      * @throws TemplateErrorInterface
454 454
      */
455
-    private function buildStaticPageViewHTML(StaticPageView &$pageView): string
455
+    private function buildStaticPageViewHTML(StaticPageView & $pageView): string
456 456
     {
457 457
         $defaultContext = [
458 458
             'this' => $pageView->createJail(),
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
      *
481 481
      * @throws TemplateErrorInterface
482 482
      */
483
-    private function createTwigTemplate(BasePageView &$pageView): TemplateInterface
483
+    private function createTwigTemplate(BasePageView & $pageView): TemplateInterface
484 484
     {
485 485
         try {
486 486
             $template = $this->templateBridge->createTemplate($pageView->getContent());
Please login to merge, or discard this patch.
Braces   +26 added lines, -12 removed lines patch added patch discarded remove patch
@@ -176,7 +176,8 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function compileAll(): void
178 178
     {
179
-        foreach ($this->pageViewsFlattened as &$pageView) {
179
+        foreach ($this->pageViewsFlattened as &$pageView)
180
+        {
180 181
             $this->compilePageView($pageView);
181 182
         }
182 183
     }
@@ -199,8 +200,10 @@  discard block
 block discarded – undo
199 200
             'type' => $pageView->getType(),
200 201
         ]);
201 202
 
202
-        try {
203
-            switch ($pageView->getType()) {
203
+        try
204
+        {
205
+            switch ($pageView->getType())
206
+            {
204 207
                 case BasePageView::STATIC_TYPE:
205 208
                     $this->compileStaticPageView($pageView);
206 209
                     $this->compileStandardRedirects($pageView);
@@ -219,7 +222,9 @@  discard block
 block discarded – undo
219 222
 
220 223
                     break;
221 224
             }
222
-        } catch (TemplateErrorInterface $e) {
225
+        }
226
+        catch (TemplateErrorInterface $e)
227
+        {
223 228
             throw new FileAwareException(
224 229
                 $e->getMessage(),
225 230
                 $e->getCode(),
@@ -258,8 +263,10 @@  discard block
 block discarded – undo
258 263
         $contentItems = $pageView->getCollectableItems();
259 264
         $template = $this->createTwigTemplate($pageView);
260 265
 
261
-        foreach ($contentItems as &$contentItem) {
262
-            if ($contentItem->isDraft() && !Service::hasRunTimeFlag(RuntimeStatus::USING_DRAFTS)) {
266
+        foreach ($contentItems as &$contentItem)
267
+        {
268
+            if ($contentItem->isDraft() && !Service::hasRunTimeFlag(RuntimeStatus::USING_DRAFTS))
269
+            {
263 270
                 $this->logger->debug('{file}: marked as a draft', [
264 271
                     'file' => $contentItem->getRelativeFilePath(),
265 272
                 ]);
@@ -289,7 +296,8 @@  discard block
 block discarded – undo
289 296
         $template = $this->createTwigTemplate($pageView);
290 297
         $permalinks = $pageView->getRepeaterPermalinks();
291 298
 
292
-        foreach ($permalinks as $permalink) {
299
+        foreach ($permalinks as $permalink)
300
+        {
293 301
             $this->writeToFilesystem(
294 302
                 $pageView->getTargetFile($permalink->getEvaluated()),
295 303
                 $this->buildRepeaterPageViewHTML($template, $pageView, $permalink),
@@ -329,7 +337,8 @@  discard block
 block discarded – undo
329 337
     {
330 338
         $redirects = $pageView->getRedirects();
331 339
 
332
-        foreach ($redirects as $redirect) {
340
+        foreach ($redirects as $redirect)
341
+        {
333 342
             $redirectPageView = BasePageView::createRedirect(
334 343
                 $redirect,
335 344
                 $pageView->getPermalink(),
@@ -361,9 +370,11 @@  discard block
 block discarded – undo
361 370
         $permalinks = $pageView->getRepeaterPermalinks();
362 371
 
363 372
         /** @var ExpandedValue[] $repeaterRedirect */
364
-        foreach ($pageView->getRepeaterRedirects() as $repeaterRedirect) {
373
+        foreach ($pageView->getRepeaterRedirects() as $repeaterRedirect)
374
+        {
365 375
             /** @var ExpandedValue $redirect */
366
-            foreach ($repeaterRedirect as $index => $redirect) {
376
+            foreach ($repeaterRedirect as $index => $redirect)
377
+            {
367 378
                 $redirectPageView = BasePageView::createRedirect(
368 379
                     $redirect->getEvaluated(),
369 380
                     $permalinks[$index]->getEvaluated(),
@@ -482,7 +493,8 @@  discard block
 block discarded – undo
482 493
      */
483 494
     private function createTwigTemplate(BasePageView &$pageView): TemplateInterface
484 495
     {
485
-        try {
496
+        try
497
+        {
486 498
             $template = $this->templateBridge->createTemplate($pageView->getContent());
487 499
 
488 500
             $this->templateMapping[$template->getTemplateName()] = $pageView->getRelativeFilePath();
@@ -491,7 +503,9 @@  discard block
 block discarded – undo
491 503
             $this->eventDispatcher->dispatch($event, CompilerTemplateCreation::NAME);
492 504
 
493 505
             return $template;
494
-        } catch (TemplateErrorInterface $e) {
506
+        }
507
+        catch (TemplateErrorInterface $e)
508
+        {
495 509
             $e
496 510
                 ->setTemplateLine($e->getTemplateLine() + $pageView->getLineOffset())
497 511
                 ->setContent($pageView->getContent())
Please login to merge, or discard this patch.
src/AssetEngine/AssetEngineManager.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@  discard block
 block discarded – undo
19 19
 
20 20
     public function addAssetEngines(/* iterable */ $assetEngines): void
21 21
     {
22
-        foreach ($assetEngines as $assetEngine) {
22
+        foreach ($assetEngines as $assetEngine)
23
+        {
23 24
             $this->addAssetEngine($assetEngine);
24 25
         }
25 26
     }
@@ -30,7 +31,8 @@  discard block
 block discarded – undo
30 31
 
31 32
         $e = $this->engines[] = $assetEngine;
32 33
 
33
-        foreach ($extensions as $extension) {
34
+        foreach ($extensions as $extension)
35
+        {
34 36
             $this->enginesByExtension[$extension] = $e;
35 37
         }
36 38
 
@@ -44,7 +46,8 @@  discard block
 block discarded – undo
44 46
 
45 47
     public function getEngineByExtension($extension)
46 48
     {
47
-        if (isset($this->enginesByExtension[$extension])) {
49
+        if (isset($this->enginesByExtension[$extension]))
50
+        {
48 51
             return $this->enginesByExtension[$extension];
49 52
         }
50 53
 
Please login to merge, or discard this patch.
src/AssetEngine/Sass/SassEngine.php 1 patch
Braces   +22 added lines, -10 removed lines patch added patch discarded remove patch
@@ -84,7 +84,8 @@  discard block
 block discarded – undo
84 84
         $this->handleThemeImports($content);
85 85
 
86 86
         // We don't need to write the source map to a file
87
-        if (!$this->fileSourceMap) {
87
+        if (!$this->fileSourceMap)
88
+        {
88 89
             $this->compiler->setSourceMapOptions($sourceMapOptions);
89 90
 
90 91
             return $this->compiler->compile($content);
@@ -138,13 +139,16 @@  discard block
 block discarded – undo
138 139
 
139 140
     public static function stringToFormatter($format)
140 141
     {
141
-        if ($format === 'nested') {
142
+        if ($format === 'nested')
143
+        {
142 144
             return Nested::class;
143 145
         }
144
-        if ($format === 'expanded') {
146
+        if ($format === 'expanded')
147
+        {
145 148
             return Expanded::class;
146 149
         }
147
-        if ($format === 'compact') {
150
+        if ($format === 'compact')
151
+        {
148 152
             return Compact::class;
149 153
         }
150 154
 
@@ -167,12 +171,17 @@  discard block
 block discarded – undo
167 171
     {
168 172
         $sourceMap = __::get($this->options, 'sourcemap');
169 173
 
170
-        if ($sourceMap === 'inline') {
174
+        if ($sourceMap === 'inline')
175
+        {
171 176
             $this->compiler->setSourceMap(Compiler::SOURCE_MAP_INLINE);
172
-        } elseif ($sourceMap === true) {
177
+        }
178
+        elseif ($sourceMap === true)
179
+        {
173 180
             $this->compiler->setSourceMap(Compiler::SOURCE_MAP_FILE);
174 181
             $this->fileSourceMap = true;
175
-        } else {
182
+        }
183
+        else
184
+        {
176 185
             $this->compiler->setSourceMap(Compiler::SOURCE_MAP_NONE);
177 186
         }
178 187
     }
@@ -187,14 +196,16 @@  discard block
 block discarded – undo
187 196
 
188 197
     private function initializeCompiler(): void
189 198
     {
190
-        if ($this->compiler) {
199
+        if ($this->compiler)
200
+        {
191 201
             return;
192 202
         }
193 203
 
194 204
         $cacheOptions = [];
195 205
 
196 206
         // If we have a cache directory set, use it.
197
-        if ($this->cacheDirectory) {
207
+        if ($this->cacheDirectory)
208
+        {
198 209
             $cacheOptions = [
199 210
                 'cacheDir' => (string)$this->cacheDirectory->getFilesystemPath(),
200 211
                 'forceRefresh' => false,
@@ -210,7 +221,8 @@  discard block
 block discarded – undo
210 221
 
211 222
     private function handleThemeImports(&$content): void
212 223
     {
213
-        if ($themeName = $this->configuration->getTheme()) {
224
+        if ($themeName = $this->configuration->getTheme())
225
+        {
214 226
             $themePath = "../_themes/{$themeName}/_sass";
215 227
             $content = preg_replace("/(@import ['\"])(@theme)(.+)/", "$1{$themePath}$3", $content);
216 228
         }
Please login to merge, or discard this patch.
src/Server/RouteMapper.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,11 +46,13 @@
 block discarded – undo
46 46
      */
47 47
     public function registerPageView(BasePageView $pageView): void
48 48
     {
49
-        switch ($pageView->getType()) {
49
+        switch ($pageView->getType())
50
+        {
50 51
             case BasePageView::STATIC_TYPE:
51 52
                 $this->mapping[$pageView->getPermalink()] = $pageView;
52 53
 
53
-                foreach ($pageView->getRedirects() as $redirect) {
54
+                foreach ($pageView->getRedirects() as $redirect)
55
+                {
54 56
                     $this->redirects[$redirect] = $pageView->getPermalink();
55 57
                 }
56 58
 
Please login to merge, or discard this patch.
src/Server/ExceptionRenderer.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@
 block discarded – undo
20 20
         $source = fs::getInternalResource('error.html.twig');
21 21
         $template = $compiler->getTemplateBridge()->createTemplate($source);
22 22
 
23
-        if ($exception instanceof TemplateErrorInterface) {
23
+        if ($exception instanceof TemplateErrorInterface)
24
+        {
24 25
             $message = [
25 26
                 sprintf('File: %s:%d', $exception->getRelativeFilePath(), $exception->getTemplateLine()),
26 27
             ];
Please login to merge, or discard this patch.
src/Server/WebServer.php 1 patch
Braces   +25 added lines, -11 removed lines patch added patch discarded remove patch
@@ -51,29 +51,36 @@  discard block
 block discarded – undo
51 51
     {
52 52
         $routes = Controller::create($routeMapper, $compiler);
53 53
 
54
-        return new Server(function (ServerRequestInterface $request) use ($routes, $compiler, $assetManager) {
54
+        return new Server(function (ServerRequestInterface $request) use ($routes, $compiler, $assetManager)
55
+        {
55 56
             $httpMethod = $request->getMethod();
56 57
             $urlPath = Controller::normalizeUrl($request->getUri()->getPath());
57 58
 
58 59
             // We're a static website, we should never support anything other than GET requests
59
-            if ($httpMethod !== 'GET') {
60
+            if ($httpMethod !== 'GET')
61
+            {
60 62
                 return new Response(406, ['Content-Type' => 'text/plain'], 'Method not allowed');
61 63
             }
62 64
 
63 65
             $context = new RequestContext($urlPath);
64 66
             $matcher = new UrlMatcher($routes, $context);
65 67
 
66
-            try {
68
+            try
69
+            {
67 70
                 $parameters = $matcher->match($urlPath);
68 71
 
69
-                if (isset($parameters['_controller'])) {
72
+                if (isset($parameters['_controller']))
73
+                {
70 74
                     $controller = $parameters['_controller'];
71 75
 
72 76
                     return $controller($request, ...array_values($parameters));
73 77
                 }
74
-            } catch (ResourceNotFoundException $e) {
78
+            }
79
+            catch (ResourceNotFoundException $e)
80
+            {
75 81
                 // If we have a "manual" asset, let's serve from it
76
-                if (($file = $assetManager->getExplicitAsset(self::normalizePath($urlPath))) !== null) {
82
+                if (($file = $assetManager->getExplicitAsset(self::normalizePath($urlPath))) !== null)
83
+                {
77 84
                     return self::makeResponse($file);
78 85
                 }
79 86
 
@@ -82,10 +89,13 @@  discard block
 block discarded – undo
82 89
                 // reason, we manually look through the filesystem and load from there.
83 90
                 //
84 91
                 // @TODO this should be fixed to make the AssetManager the authority on assets.
85
-                if (($asset = self::searchAsset($urlPath)) !== null) {
92
+                if (($asset = self::searchAsset($urlPath)) !== null)
93
+                {
86 94
                     return $asset;
87 95
                 }
88
-            } catch (Exception $e) {
96
+            }
97
+            catch (Exception $e)
98
+            {
89 99
                 $response = ExceptionRenderer::render($e, $compiler);
90 100
 
91 101
                 return new Response(500, ['Content-Type' => 'text/html'], $response);
@@ -103,12 +113,16 @@  discard block
 block discarded – undo
103 113
      */
104 114
     private static function searchAsset($url, $continueNesting = true): ?Response
105 115
     {
106
-        try {
116
+        try
117
+        {
107 118
             $file = new File(self::normalizePath($url));
108 119
 
109 120
             return self::makeResponse($file);
110
-        } catch (FileNotFoundException) {
111
-            if (!$continueNesting) {
121
+        }
122
+        catch (FileNotFoundException)
123
+        {
124
+            if (!$continueNesting)
125
+            {
112 126
                 // This will evaluate to true if we've searched inside the themes folder and it still doesn't exist
113 127
                 return null;
114 128
             }
Please login to merge, or discard this patch.
src/Server/Controller.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@
 block discarded – undo
183 183
     /**
184 184
      * Return the appropriate action based on a PageView's type.
185 185
      */
186
-    private function createAction(BasePageView|DynamicPageView|RepeaterPageView|StaticPageView $pageView, Compiler $compiler): Closure
186
+    private function createAction(BasePageView | DynamicPageView | RepeaterPageView | StaticPageView $pageView, Compiler $compiler): Closure
187 187
     {
188 188
         return match ($pageView->getType()) {
189 189
             BasePageView::STATIC_TYPE => $this->staticPageViewAction($pageView, $compiler),
Please login to merge, or discard this patch.
Braces   +36 added lines, -18 removed lines patch added patch discarded remove patch
@@ -51,7 +51,8 @@  discard block
 block discarded – undo
51 51
          * @var string $from
52 52
          * @var string $to
53 53
          */
54
-        foreach ($routeMapper->getRedirectMapping() as $from => $to) {
54
+        foreach ($routeMapper->getRedirectMapping() as $from => $to)
55
+        {
55 56
             $routeName = preg_replace('/[\/\.]/', '_', $from);
56 57
             $routeName = 'redirect_' . $routeName;
57 58
 
@@ -64,7 +65,8 @@  discard block
 block discarded – undo
64 65
          * @var string       $routeUrl
65 66
          * @var BasePageView $pageView
66 67
          */
67
-        foreach ($routeMapper->getRouteMapping() as $routeUrl => $pageView) {
68
+        foreach ($routeMapper->getRouteMapping() as $routeUrl => $pageView)
69
+        {
68 70
             $routeName = $pageView->getRelativeFilePath();
69 71
             $routeName = preg_replace('/[\/\.]/', '_', $routeName);
70 72
 
@@ -75,7 +77,8 @@  discard block
 block discarded – undo
75 77
             // Allow the last route parameter to have `/` in the permalink that's not part of the route itself
76 78
             //   see https://github.com/stakx-io/stakx/issues/98
77 79
             $requirements = [];
78
-            if (count($results) >= 2) {
80
+            if (count($results) >= 2)
81
+            {
79 82
                 $requirements[$results[1]] = '.*';
80 83
             }
81 84
 
@@ -109,12 +112,14 @@  discard block
 block discarded – undo
109 112
      */
110 113
     private function staticPageViewAction(StaticPageView $pageView, Compiler $compiler): Closure
111 114
     {
112
-        return function () use ($pageView, $compiler) {
115
+        return function () use ($pageView, $compiler)
116
+        {
113 117
             Service::setOption('currentTemplate', $pageView->getAbsoluteFilePath());
114 118
 
115 119
             $compiler->getTemplateBridge()->clearTemplateCache();
116 120
 
117
-            if ($this->hasBeenTouched($pageView)) {
121
+            if ($this->hasBeenTouched($pageView))
122
+            {
118 123
                 $pageView->readContent();
119 124
             }
120 125
 
@@ -133,22 +138,26 @@  discard block
 block discarded – undo
133 138
      */
134 139
     private function dynamicPageViewAction(DynamicPageView $pageView, Compiler $compiler): Closure
135 140
     {
136
-        return function (ServerRequestInterface $request) use ($pageView, $compiler) {
141
+        return function (ServerRequestInterface $request) use ($pageView, $compiler)
142
+        {
137 143
             Service::setOption('currentTemplate', $pageView->getAbsoluteFilePath());
138 144
 
139 145
             $compiler->getTemplateBridge()->clearTemplateCache();
140 146
 
141 147
             $contentItem = self::getContentItem($pageView, $request->getUri()->getPath());
142 148
 
143
-            if ($contentItem === null) {
149
+            if ($contentItem === null)
150
+            {
144 151
                 return WebServer::return404();
145 152
             }
146 153
 
147
-            if ($this->hasBeenTouched($pageView)) {
154
+            if ($this->hasBeenTouched($pageView))
155
+            {
148 156
                 $pageView->readContent();
149 157
             }
150 158
 
151
-            if ($this->hasBeenTouched($contentItem)) {
159
+            if ($this->hasBeenTouched($contentItem))
160
+            {
152 161
                 $contentItem->readContent();
153 162
             }
154 163
 
@@ -161,18 +170,21 @@  discard block
 block discarded – undo
161 170
      */
162 171
     private function repeaterPageViewAction(RepeaterPageView $pageView, Compiler $compiler): Closure
163 172
     {
164
-        return function (ServerRequestInterface $request) use ($pageView, $compiler) {
173
+        return function (ServerRequestInterface $request) use ($pageView, $compiler)
174
+        {
165 175
             Service::setOption('currentTemplate', $pageView->getAbsoluteFilePath());
166 176
 
167 177
             $compiler->getTemplateBridge()->clearTemplateCache();
168 178
 
169 179
             $expandedValue = self::getExpandedValue($pageView, $request->getUri()->getPath());
170 180
 
171
-            if ($expandedValue === null) {
181
+            if ($expandedValue === null)
182
+            {
172 183
                 return WebServer::return404();
173 184
             }
174 185
 
175
-            if ($this->hasBeenTouched($pageView)) {
186
+            if ($this->hasBeenTouched($pageView))
187
+            {
176 188
                 $pageView->readContent();
177 189
             }
178 190
 
@@ -189,7 +201,8 @@  discard block
 block discarded – undo
189 201
             BasePageView::STATIC_TYPE => $this->staticPageViewAction($pageView, $compiler),
190 202
             BasePageView::DYNAMIC_TYPE => $this->dynamicPageViewAction($pageView, $compiler),
191 203
             BasePageView::REPEATER_TYPE => $this->repeaterPageViewAction($pageView, $compiler),
192
-            default => function () {
204
+            default => function ()
205
+            {
193 206
                 $errMsg = 'This URL type has not yet been implemented.';
194 207
 
195 208
                 return new Response(501, ['Content-Type' => 'text/plain'], $errMsg);
@@ -218,7 +231,8 @@  discard block
 block discarded – undo
218 231
     {
219 232
         $rPath = $document->getRelativeFilePath();
220 233
 
221
-        if (!isset($this->lastModified[$rPath])) {
234
+        if (!isset($this->lastModified[$rPath]))
235
+        {
222 236
             $this->lastModified[$rPath] = $document->getLastModified();
223 237
 
224 238
             return true;
@@ -236,8 +250,10 @@  discard block
 block discarded – undo
236 250
     {
237 251
         $permalink = self::normalizeUrl($permalink);
238 252
 
239
-        foreach ($pageView->getCollectableItems() as $collectableItem) {
240
-            if ($collectableItem['permalink'] === $permalink) {
253
+        foreach ($pageView->getCollectableItems() as $collectableItem)
254
+        {
255
+            if ($collectableItem['permalink'] === $permalink)
256
+            {
241 257
                 return $collectableItem;
242 258
             }
243 259
         }
@@ -253,8 +269,10 @@  discard block
 block discarded – undo
253 269
         $url = self::normalizeUrl($permalink);
254 270
         $repeaterPermalinks = $pageView->getRepeaterPermalinks();
255 271
 
256
-        foreach ($repeaterPermalinks as $expandedValue) {
257
-            if ($expandedValue->getEvaluated() === $url) {
272
+        foreach ($repeaterPermalinks as $expandedValue)
273
+        {
274
+            if ($expandedValue->getEvaluated() === $url)
275
+            {
258 276
                 return $expandedValue;
259 277
             }
260 278
         }
Please login to merge, or discard this patch.
src/Website.php 1 patch
Braces   +23 added lines, -11 removed lines patch added patch discarded remove patch
@@ -43,7 +43,8 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function build(): bool
45 45
     {
46
-        if (empty($this->getConfiguration()->getPageViewFolders())) {
46
+        if (empty($this->getConfiguration()->getPageViewFolders()))
47
+        {
47 48
             $this->logger->error('No PageViews were configured for this site. Check the `pageviews` key in your _config.yml.');
48 49
 
49 50
             return false;
@@ -63,10 +64,14 @@  discard block
 block discarded – undo
63 64
         $this->compiler->setThemeName($theme);
64 65
         $this->compiler->compileAll();
65 66
 
66
-        if (Service::hasRunTimeFlag(RuntimeStatus::IN_PROFILE_MODE)) {
67
-            if (!$this->templateBridge->hasProfiler()) {
67
+        if (Service::hasRunTimeFlag(RuntimeStatus::IN_PROFILE_MODE))
68
+        {
69
+            if (!$this->templateBridge->hasProfiler())
70
+            {
68 71
                 $this->logger->writeln('This template engine currently does not support a profiler.');
69
-            } else {
72
+            }
73
+            else
74
+            {
70 75
                 $profilerText = $this->templateBridge->getProfilerOutput($this->compiler);
71 76
                 $this->logger->writeln($profilerText);
72 77
             }
@@ -82,7 +87,8 @@  discard block
 block discarded – undo
82 87
         //
83 88
         // Theme Management
84 89
         //
85
-        if ($theme !== null) {
90
+        if ($theme !== null)
91
+        {
86 92
             $this->logger->notice("Looking for '{$theme}' theme...");
87 93
 
88 94
             $tm = new ThemeManager($theme, $this->eventDispatcher, $this->logger);
@@ -113,11 +119,13 @@  discard block
 block discarded – undo
113 119
     {
114 120
         $targetDir = fs::absolutePath($this->getConfiguration()->getTargetFolder());
115 121
 
116
-        if (!Service::hasRunTimeFlag(RuntimeStatus::BOOT_WITHOUT_CLEAN)) {
122
+        if (!Service::hasRunTimeFlag(RuntimeStatus::BOOT_WITHOUT_CLEAN))
123
+        {
117 124
             fs::remove($targetDir);
118 125
         }
119 126
 
120
-        if (!Service::hasRunTimeFlag(RuntimeStatus::USING_CACHE)) {
127
+        if (!Service::hasRunTimeFlag(RuntimeStatus::USING_CACHE))
128
+        {
121 129
             fs::remove(fs::absolutePath(Configuration::CACHE_FOLDER, 'twig'));
122 130
             fs::mkdir(fs::absolutePath(fs::appendPath(Configuration::CACHE_FOLDER, 'twig')));
123 131
         }
@@ -132,20 +140,24 @@  discard block
 block discarded – undo
132 140
     {
133 141
         $enabled = $this->getConfiguration()->isHighlighterEnabled();
134 142
 
135
-        if (!$enabled) {
143
+        if (!$enabled)
144
+        {
136 145
             return;
137 146
         }
138 147
 
139 148
         Service::setRuntimeFlag(RuntimeStatus::USING_HIGHLIGHTER);
140 149
 
141
-        if ($this->getConfiguration()->isHighlighterUsingLineNumbers()) {
150
+        if ($this->getConfiguration()->isHighlighterUsingLineNumbers())
151
+        {
142 152
             Service::setRuntimeFlag(RuntimeStatus::USING_LINE_NUMBERS);
143 153
         }
144 154
 
145
-        foreach ($this->getConfiguration()->getHighlighterCustomLanguages() as $lang => $path) {
155
+        foreach ($this->getConfiguration()->getHighlighterCustomLanguages() as $lang => $path)
156
+        {
146 157
             $fullPath = fs::absolutePath($path);
147 158
 
148
-            if (!fs::exists($fullPath)) {
159
+            if (!fs::exists($fullPath))
160
+            {
149 161
                 $this->logger->warning('The following language definition could not be found: {lang}', [
150 162
                     'lang' => $path,
151 163
                 ]);
Please login to merge, or discard this patch.