Completed
Push — chore/php-8-migration ( 83422f...0b97e4 )
by Vladimir
07:07
created
src/Manager/MenuManager.php 1 patch
Braces   +29 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function compileManager(): void
27 27
     {
28
-        if ($this->pageManager === null) {
28
+        if ($this->pageManager === null)
29
+        {
29 30
             return;
30 31
         }
31 32
 
@@ -41,9 +42,11 @@  discard block
 block discarded – undo
41 42
     {
42 43
         $jailedMenu = [];
43 44
 
44
-        foreach ($this->siteMenu as $key => $value) {
45
+        foreach ($this->siteMenu as $key => $value)
46
+        {
45 47
             // If it's an array, it means the parent is hidden from the site menu therefore its children should be too
46
-            if (is_array($this->siteMenu[$key])) {
48
+            if (is_array($this->siteMenu[$key]))
49
+            {
47 50
                 continue;
48 51
             }
49 52
 
@@ -58,7 +61,8 @@  discard block
 block discarded – undo
58 61
      */
59 62
     public function buildFromPageViews($pageViews): void
60 63
     {
61
-        foreach ($pageViews as $pageView) {
64
+        foreach ($pageViews as $pageView)
65
+        {
62 66
             $this->addToSiteMenu($pageView);
63 67
         }
64 68
     }
@@ -70,38 +74,50 @@  discard block
 block discarded – undo
70 74
     {
71 75
         $frontMatter = $pageView->getFrontMatter();
72 76
 
73
-        if (isset($frontMatter['menu']) && !$frontMatter['menu']) {
77
+        if (isset($frontMatter['menu']) && !$frontMatter['menu'])
78
+        {
74 79
             return;
75 80
         }
76 81
 
77 82
         $url = trim((string)$pageView->getPermalink(), '/');
78 83
 
79 84
         // @TODO in the next breaking release, remove this check and allow the homepage to be indexed as '.'
80
-        if (empty($url)) {
85
+        if (empty($url))
86
+        {
81 87
             return;
82 88
         }
83 89
 
84 90
         $root = &$this->siteMenu;
85 91
         $dirs = explode('/', $url);
86 92
 
87
-        while (count($dirs) > 0) {
93
+        while (count($dirs) > 0)
94
+        {
88 95
             $name = array_shift($dirs);
89 96
             $name = (!empty($name)) ? $name : '.';
90 97
 
91
-            if (!is_null($name) && count($dirs) == 0) {
92
-                if (isset($root[$name]) && is_array($root[$name])) {
98
+            if (!is_null($name) && count($dirs) == 0)
99
+            {
100
+                if (isset($root[$name]) && is_array($root[$name]))
101
+                {
93 102
                     $children = &$pageView->getChildren();
94 103
                     $children = $root[$name]['children'];
95 104
                 }
96 105
 
97 106
                 $root[$name] = &$pageView;
98
-            } else {
99
-                if (!isset($root[$name])) {
107
+            }
108
+            else
109
+            {
110
+                if (!isset($root[$name]))
111
+                {
100 112
                     $root[$name]['children'] = [];
101 113
                     $root = &$root[$name]['children'];
102
-                } elseif (isset($root[$name]) && is_array($root[$name])) {
114
+                }
115
+                elseif (isset($root[$name]) && is_array($root[$name]))
116
+                {
103 117
                     $root = &$root[$name]['children'];
104
-                } else {
118
+                }
119
+                else
120
+                {
105 121
                     $root = &$root[$name]->getChildren();
106 122
                 }
107 123
             }
Please login to merge, or discard this patch.
src/Manager/ThemeManager.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,17 +47,20 @@
 block discarded – undo
47 47
             'include' => [],
48 48
         ];
49 49
 
50
-        if (!fs::exists($this->themeFolder)) {
50
+        if (!fs::exists($this->themeFolder))
51
+        {
51 52
             throw new FileNotFoundException("The '{$themeName}' theme folder could not be found.'");
52 53
         }
53 54
 
54
-        if (fs::exists($this->themeFile)) {
55
+        if (fs::exists($this->themeFile))
56
+        {
55 57
             $themeData = Yaml::parse(file_get_contents($this->themeFile));
56 58
 
57 59
             $this->themeData = array_merge_recursive($this->themeData, $themeData);
58 60
         }
59 61
 
60
-        foreach ($this->themeData['include'] as &$include) {
62
+        foreach ($this->themeData['include'] as &$include)
63
+        {
61 64
             $include = fs::appendPath($this->themeFolder, $include);
62 65
         }
63 66
     }
Please login to merge, or discard this patch.
src/Manager/AssetManager.php 1 patch
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -55,7 +55,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Manager/CollectionManager.php 1 patch
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Console/Application.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Console/ContainerBuilder.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Console/Command/ServeCommand.php 1 patch
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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()
Please login to merge, or discard this patch.
src/Console/Command/BuildCommand.php 1 patch
Braces   +20 added lines, -9 removed lines patch added patch discarded remove patch
@@ -62,7 +62,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Console/Command/ContainerAwareCommand.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,11 +17,13 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.