Passed
Push — master ( 348454...c8160a )
by Joas
15:07 queued 14s
created
core/Command/Status.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -33,55 +33,55 @@
 block discarded – undo
33 33
 use Symfony\Component\Console\Output\OutputInterface;
34 34
 
35 35
 class Status extends Base {
36
-	private IConfig $config;
37
-	private Defaults $themingDefaults;
36
+    private IConfig $config;
37
+    private Defaults $themingDefaults;
38 38
 
39
-	public function __construct(IConfig $config, Defaults $themingDefaults) {
40
-		parent::__construct('status');
39
+    public function __construct(IConfig $config, Defaults $themingDefaults) {
40
+        parent::__construct('status');
41 41
 
42
-		$this->config = $config;
43
-		$this->themingDefaults = $themingDefaults;
44
-	}
42
+        $this->config = $config;
43
+        $this->themingDefaults = $themingDefaults;
44
+    }
45 45
 
46
-	protected function configure() {
47
-		parent::configure();
46
+    protected function configure() {
47
+        parent::configure();
48 48
 
49
-		$this
50
-			->setDescription('show some status information')
51
-			->addOption(
52
-				'exit-code',
53
-				'e',
54
-				InputOption::VALUE_NONE,
55
-				'exit with 0 if running in normal mode, 1 when in maintenance mode, 2 when `./occ upgrade` is needed. Does not write any output to STDOUT.'
56
-			);
57
-	}
49
+        $this
50
+            ->setDescription('show some status information')
51
+            ->addOption(
52
+                'exit-code',
53
+                'e',
54
+                InputOption::VALUE_NONE,
55
+                'exit with 0 if running in normal mode, 1 when in maintenance mode, 2 when `./occ upgrade` is needed. Does not write any output to STDOUT.'
56
+            );
57
+    }
58 58
 
59
-	protected function execute(InputInterface $input, OutputInterface $output): int {
60
-		$maintenanceMode = $this->config->getSystemValueBool('maintenance', false);
61
-		$needUpgrade = Util::needUpgrade();
62
-		$values = [
63
-			'installed' => $this->config->getSystemValueBool('installed', false),
64
-			'version' => implode('.', Util::getVersion()),
65
-			'versionstring' => OC_Util::getVersionString(),
66
-			'edition' => '',
67
-			'maintenance' => $maintenanceMode,
68
-			'needsDbUpgrade' => $needUpgrade,
69
-			'productname' => $this->themingDefaults->getProductName(),
70
-			'extendedSupport' => Util::hasExtendedSupport()
71
-		];
59
+    protected function execute(InputInterface $input, OutputInterface $output): int {
60
+        $maintenanceMode = $this->config->getSystemValueBool('maintenance', false);
61
+        $needUpgrade = Util::needUpgrade();
62
+        $values = [
63
+            'installed' => $this->config->getSystemValueBool('installed', false),
64
+            'version' => implode('.', Util::getVersion()),
65
+            'versionstring' => OC_Util::getVersionString(),
66
+            'edition' => '',
67
+            'maintenance' => $maintenanceMode,
68
+            'needsDbUpgrade' => $needUpgrade,
69
+            'productname' => $this->themingDefaults->getProductName(),
70
+            'extendedSupport' => Util::hasExtendedSupport()
71
+        ];
72 72
 
73
-		if ($input->getOption('verbose') || !$input->getOption('exit-code')) {
74
-			$this->writeArrayInOutputFormat($input, $output, $values);
75
-		}
73
+        if ($input->getOption('verbose') || !$input->getOption('exit-code')) {
74
+            $this->writeArrayInOutputFormat($input, $output, $values);
75
+        }
76 76
 
77
-		if ($input->getOption('exit-code')) {
78
-			if ($maintenanceMode === true) {
79
-				return 1;
80
-			}
81
-			if ($needUpgrade === true) {
82
-				return 2;
83
-			}
84
-		}
85
-		return 0;
86
-	}
77
+        if ($input->getOption('exit-code')) {
78
+            if ($maintenanceMode === true) {
79
+                return 1;
80
+            }
81
+            if ($needUpgrade === true) {
82
+                return 2;
83
+            }
84
+        }
85
+        return 0;
86
+    }
87 87
 }
Please login to merge, or discard this patch.
lib/private/Console/Application.php 2 patches
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -47,190 +47,190 @@
 block discarded – undo
47 47
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
48 48
 
49 49
 class Application {
50
-	/** @var IConfig */
51
-	private $config;
52
-	/** @var EventDispatcherInterface */
53
-	private $dispatcher;
54
-	/** @var IRequest */
55
-	private $request;
56
-	/** @var LoggerInterface */
57
-	private $logger;
58
-	/** @var MemoryInfo */
59
-	private $memoryInfo;
50
+    /** @var IConfig */
51
+    private $config;
52
+    /** @var EventDispatcherInterface */
53
+    private $dispatcher;
54
+    /** @var IRequest */
55
+    private $request;
56
+    /** @var LoggerInterface */
57
+    private $logger;
58
+    /** @var MemoryInfo */
59
+    private $memoryInfo;
60 60
 
61
-	public function __construct(IConfig $config,
62
-								EventDispatcherInterface $dispatcher,
63
-								IRequest $request,
64
-								LoggerInterface $logger,
65
-								MemoryInfo $memoryInfo) {
66
-		$defaults = \OC::$server->getThemingDefaults();
67
-		$this->config = $config;
68
-		$this->application = new SymfonyApplication($defaults->getName(), \OC_Util::getVersionString());
69
-		$this->dispatcher = $dispatcher;
70
-		$this->request = $request;
71
-		$this->logger = $logger;
72
-		$this->memoryInfo = $memoryInfo;
73
-	}
61
+    public function __construct(IConfig $config,
62
+                                EventDispatcherInterface $dispatcher,
63
+                                IRequest $request,
64
+                                LoggerInterface $logger,
65
+                                MemoryInfo $memoryInfo) {
66
+        $defaults = \OC::$server->getThemingDefaults();
67
+        $this->config = $config;
68
+        $this->application = new SymfonyApplication($defaults->getName(), \OC_Util::getVersionString());
69
+        $this->dispatcher = $dispatcher;
70
+        $this->request = $request;
71
+        $this->logger = $logger;
72
+        $this->memoryInfo = $memoryInfo;
73
+    }
74 74
 
75
-	/**
76
-	 * @param InputInterface $input
77
-	 * @param ConsoleOutputInterface $output
78
-	 * @throws \Exception
79
-	 */
80
-	public function loadCommands(
81
-		InputInterface $input,
82
-		ConsoleOutputInterface $output
83
-	) {
84
-		// $application is required to be defined in the register_command scripts
85
-		$application = $this->application;
86
-		$inputDefinition = $application->getDefinition();
87
-		$inputDefinition->addOption(
88
-			new InputOption(
89
-				'no-warnings',
90
-				null,
91
-				InputOption::VALUE_NONE,
92
-				'Skip global warnings, show command output only',
93
-				null
94
-			)
95
-		);
96
-		try {
97
-			$input->bind($inputDefinition);
98
-		} catch (\RuntimeException $e) {
99
-			//expected if there are extra options
100
-		}
101
-		if ($input->getOption('no-warnings')) {
102
-			$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
103
-		}
75
+    /**
76
+     * @param InputInterface $input
77
+     * @param ConsoleOutputInterface $output
78
+     * @throws \Exception
79
+     */
80
+    public function loadCommands(
81
+        InputInterface $input,
82
+        ConsoleOutputInterface $output
83
+    ) {
84
+        // $application is required to be defined in the register_command scripts
85
+        $application = $this->application;
86
+        $inputDefinition = $application->getDefinition();
87
+        $inputDefinition->addOption(
88
+            new InputOption(
89
+                'no-warnings',
90
+                null,
91
+                InputOption::VALUE_NONE,
92
+                'Skip global warnings, show command output only',
93
+                null
94
+            )
95
+        );
96
+        try {
97
+            $input->bind($inputDefinition);
98
+        } catch (\RuntimeException $e) {
99
+            //expected if there are extra options
100
+        }
101
+        if ($input->getOption('no-warnings')) {
102
+            $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
103
+        }
104 104
 
105
-		if ($this->memoryInfo->isMemoryLimitSufficient() === false) {
106
-			$output->getErrorOutput()->writeln(
107
-				'<comment>The current PHP memory limit ' .
108
-				'is below the recommended value of 512MB.</comment>'
109
-			);
110
-		}
105
+        if ($this->memoryInfo->isMemoryLimitSufficient() === false) {
106
+            $output->getErrorOutput()->writeln(
107
+                '<comment>The current PHP memory limit ' .
108
+                'is below the recommended value of 512MB.</comment>'
109
+            );
110
+        }
111 111
 
112
-		try {
113
-			require_once __DIR__ . '/../../../core/register_command.php';
114
-			if ($this->config->getSystemValue('installed', false)) {
115
-				if (\OCP\Util::needUpgrade()) {
116
-					throw new NeedsUpdateException();
117
-				} elseif ($this->config->getSystemValueBool('maintenance')) {
118
-					$this->writeMaintenanceModeInfo($input, $output);
119
-				} else {
120
-					OC_App::loadApps();
121
-					$appManager = \OCP\Server::get(IAppManager::class);
122
-					foreach ($appManager->getInstalledApps() as $app) {
123
-						$appPath = \OC_App::getAppPath($app);
124
-						if ($appPath === false) {
125
-							continue;
126
-						}
127
-						// load commands using info.xml
128
-						$info = $appManager->getAppInfo($app);
129
-						if (isset($info['commands'])) {
130
-							$this->loadCommandsFromInfoXml($info['commands']);
131
-						}
132
-						// load from register_command.php
133
-						\OC_App::registerAutoloading($app, $appPath);
134
-						$file = $appPath . '/appinfo/register_command.php';
135
-						if (file_exists($file)) {
136
-							try {
137
-								require $file;
138
-							} catch (\Exception $e) {
139
-								$this->logger->error($e->getMessage(), [
140
-									'exception' => $e,
141
-								]);
142
-							}
143
-						}
144
-					}
145
-				}
146
-			} elseif ($input->getArgument('command') !== '_completion' && $input->getArgument('command') !== 'maintenance:install') {
147
-				$errorOutput = $output->getErrorOutput();
148
-				$errorOutput->writeln("Nextcloud is not installed - only a limited number of commands are available");
149
-			}
150
-		} catch (NeedsUpdateException $e) {
151
-			if ($input->getArgument('command') !== '_completion') {
152
-				$errorOutput = $output->getErrorOutput();
153
-				$errorOutput->writeln("Nextcloud or one of the apps require upgrade - only a limited number of commands are available");
154
-				$errorOutput->writeln("You may use your browser or the occ upgrade command to do the upgrade");
155
-			}
156
-		}
112
+        try {
113
+            require_once __DIR__ . '/../../../core/register_command.php';
114
+            if ($this->config->getSystemValue('installed', false)) {
115
+                if (\OCP\Util::needUpgrade()) {
116
+                    throw new NeedsUpdateException();
117
+                } elseif ($this->config->getSystemValueBool('maintenance')) {
118
+                    $this->writeMaintenanceModeInfo($input, $output);
119
+                } else {
120
+                    OC_App::loadApps();
121
+                    $appManager = \OCP\Server::get(IAppManager::class);
122
+                    foreach ($appManager->getInstalledApps() as $app) {
123
+                        $appPath = \OC_App::getAppPath($app);
124
+                        if ($appPath === false) {
125
+                            continue;
126
+                        }
127
+                        // load commands using info.xml
128
+                        $info = $appManager->getAppInfo($app);
129
+                        if (isset($info['commands'])) {
130
+                            $this->loadCommandsFromInfoXml($info['commands']);
131
+                        }
132
+                        // load from register_command.php
133
+                        \OC_App::registerAutoloading($app, $appPath);
134
+                        $file = $appPath . '/appinfo/register_command.php';
135
+                        if (file_exists($file)) {
136
+                            try {
137
+                                require $file;
138
+                            } catch (\Exception $e) {
139
+                                $this->logger->error($e->getMessage(), [
140
+                                    'exception' => $e,
141
+                                ]);
142
+                            }
143
+                        }
144
+                    }
145
+                }
146
+            } elseif ($input->getArgument('command') !== '_completion' && $input->getArgument('command') !== 'maintenance:install') {
147
+                $errorOutput = $output->getErrorOutput();
148
+                $errorOutput->writeln("Nextcloud is not installed - only a limited number of commands are available");
149
+            }
150
+        } catch (NeedsUpdateException $e) {
151
+            if ($input->getArgument('command') !== '_completion') {
152
+                $errorOutput = $output->getErrorOutput();
153
+                $errorOutput->writeln("Nextcloud or one of the apps require upgrade - only a limited number of commands are available");
154
+                $errorOutput->writeln("You may use your browser or the occ upgrade command to do the upgrade");
155
+            }
156
+        }
157 157
 
158
-		if ($input->getFirstArgument() !== 'check') {
159
-			$errors = \OC_Util::checkServer(\OC::$server->getSystemConfig());
160
-			if (!empty($errors)) {
161
-				foreach ($errors as $error) {
162
-					$output->writeln((string)$error['error']);
163
-					$output->writeln((string)$error['hint']);
164
-					$output->writeln('');
165
-				}
166
-				throw new \Exception("Environment not properly prepared.");
167
-			}
168
-		}
169
-	}
158
+        if ($input->getFirstArgument() !== 'check') {
159
+            $errors = \OC_Util::checkServer(\OC::$server->getSystemConfig());
160
+            if (!empty($errors)) {
161
+                foreach ($errors as $error) {
162
+                    $output->writeln((string)$error['error']);
163
+                    $output->writeln((string)$error['hint']);
164
+                    $output->writeln('');
165
+                }
166
+                throw new \Exception("Environment not properly prepared.");
167
+            }
168
+        }
169
+    }
170 170
 
171
-	/**
172
-	 * Write a maintenance mode info.
173
-	 * The commands "_completion" and "maintenance:mode" are excluded.
174
-	 *
175
-	 * @param InputInterface $input The input implementation for reading inputs.
176
-	 * @param ConsoleOutputInterface $output The output implementation
177
-	 * for writing outputs.
178
-	 * @return void
179
-	 */
180
-	private function writeMaintenanceModeInfo(
181
-		InputInterface $input, ConsoleOutputInterface $output
182
-	) {
183
-		if ($input->getArgument('command') !== '_completion'
184
-			&& $input->getArgument('command') !== 'maintenance:mode'
185
-			&& $input->getArgument('command') !== 'status') {
186
-			$errOutput = $output->getErrorOutput();
187
-			$errOutput->writeln(
188
-				'<comment>Nextcloud is in maintenance mode, hence the database isn\'t accessible.' . PHP_EOL .
189
-				'Cannot perform any command except \'maintenance:mode --off\'</comment>' . PHP_EOL
190
-			);
191
-		}
192
-	}
171
+    /**
172
+     * Write a maintenance mode info.
173
+     * The commands "_completion" and "maintenance:mode" are excluded.
174
+     *
175
+     * @param InputInterface $input The input implementation for reading inputs.
176
+     * @param ConsoleOutputInterface $output The output implementation
177
+     * for writing outputs.
178
+     * @return void
179
+     */
180
+    private function writeMaintenanceModeInfo(
181
+        InputInterface $input, ConsoleOutputInterface $output
182
+    ) {
183
+        if ($input->getArgument('command') !== '_completion'
184
+            && $input->getArgument('command') !== 'maintenance:mode'
185
+            && $input->getArgument('command') !== 'status') {
186
+            $errOutput = $output->getErrorOutput();
187
+            $errOutput->writeln(
188
+                '<comment>Nextcloud is in maintenance mode, hence the database isn\'t accessible.' . PHP_EOL .
189
+                'Cannot perform any command except \'maintenance:mode --off\'</comment>' . PHP_EOL
190
+            );
191
+        }
192
+    }
193 193
 
194
-	/**
195
-	 * Sets whether to automatically exit after a command execution or not.
196
-	 *
197
-	 * @param bool $boolean Whether to automatically exit after a command execution or not
198
-	 */
199
-	public function setAutoExit($boolean) {
200
-		$this->application->setAutoExit($boolean);
201
-	}
194
+    /**
195
+     * Sets whether to automatically exit after a command execution or not.
196
+     *
197
+     * @param bool $boolean Whether to automatically exit after a command execution or not
198
+     */
199
+    public function setAutoExit($boolean) {
200
+        $this->application->setAutoExit($boolean);
201
+    }
202 202
 
203
-	/**
204
-	 * @param InputInterface $input
205
-	 * @param OutputInterface $output
206
-	 * @return int
207
-	 * @throws \Exception
208
-	 */
209
-	public function run(InputInterface $input = null, OutputInterface $output = null) {
210
-		$this->dispatcher->dispatch(ConsoleEvent::EVENT_RUN, new ConsoleEvent(
211
-			ConsoleEvent::EVENT_RUN,
212
-			$this->request->server['argv']
213
-		));
214
-		return $this->application->run($input, $output);
215
-	}
203
+    /**
204
+     * @param InputInterface $input
205
+     * @param OutputInterface $output
206
+     * @return int
207
+     * @throws \Exception
208
+     */
209
+    public function run(InputInterface $input = null, OutputInterface $output = null) {
210
+        $this->dispatcher->dispatch(ConsoleEvent::EVENT_RUN, new ConsoleEvent(
211
+            ConsoleEvent::EVENT_RUN,
212
+            $this->request->server['argv']
213
+        ));
214
+        return $this->application->run($input, $output);
215
+    }
216 216
 
217
-	private function loadCommandsFromInfoXml($commands) {
218
-		foreach ($commands as $command) {
219
-			try {
220
-				$c = \OC::$server->query($command);
221
-			} catch (QueryException $e) {
222
-				if (class_exists($command)) {
223
-					try {
224
-						$c = new $command();
225
-					} catch (\ArgumentCountError $e2) {
226
-						throw new \Exception("Failed to construct console command '$command': " . $e->getMessage(), 0, $e);
227
-					}
228
-				} else {
229
-					throw new \Exception("Console command '$command' is unknown and could not be loaded");
230
-				}
231
-			}
217
+    private function loadCommandsFromInfoXml($commands) {
218
+        foreach ($commands as $command) {
219
+            try {
220
+                $c = \OC::$server->query($command);
221
+            } catch (QueryException $e) {
222
+                if (class_exists($command)) {
223
+                    try {
224
+                        $c = new $command();
225
+                    } catch (\ArgumentCountError $e2) {
226
+                        throw new \Exception("Failed to construct console command '$command': " . $e->getMessage(), 0, $e);
227
+                    }
228
+                } else {
229
+                    throw new \Exception("Console command '$command' is unknown and could not be loaded");
230
+                }
231
+            }
232 232
 
233
-			$this->application->add($c);
234
-		}
235
-	}
233
+            $this->application->add($c);
234
+        }
235
+    }
236 236
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 
105 105
 		if ($this->memoryInfo->isMemoryLimitSufficient() === false) {
106 106
 			$output->getErrorOutput()->writeln(
107
-				'<comment>The current PHP memory limit ' .
107
+				'<comment>The current PHP memory limit '.
108 108
 				'is below the recommended value of 512MB.</comment>'
109 109
 			);
110 110
 		}
111 111
 
112 112
 		try {
113
-			require_once __DIR__ . '/../../../core/register_command.php';
113
+			require_once __DIR__.'/../../../core/register_command.php';
114 114
 			if ($this->config->getSystemValue('installed', false)) {
115 115
 				if (\OCP\Util::needUpgrade()) {
116 116
 					throw new NeedsUpdateException();
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 						}
132 132
 						// load from register_command.php
133 133
 						\OC_App::registerAutoloading($app, $appPath);
134
-						$file = $appPath . '/appinfo/register_command.php';
134
+						$file = $appPath.'/appinfo/register_command.php';
135 135
 						if (file_exists($file)) {
136 136
 							try {
137 137
 								require $file;
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 			$errors = \OC_Util::checkServer(\OC::$server->getSystemConfig());
160 160
 			if (!empty($errors)) {
161 161
 				foreach ($errors as $error) {
162
-					$output->writeln((string)$error['error']);
163
-					$output->writeln((string)$error['hint']);
162
+					$output->writeln((string) $error['error']);
163
+					$output->writeln((string) $error['hint']);
164 164
 					$output->writeln('');
165 165
 				}
166 166
 				throw new \Exception("Environment not properly prepared.");
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 			&& $input->getArgument('command') !== 'status') {
186 186
 			$errOutput = $output->getErrorOutput();
187 187
 			$errOutput->writeln(
188
-				'<comment>Nextcloud is in maintenance mode, hence the database isn\'t accessible.' . PHP_EOL .
189
-				'Cannot perform any command except \'maintenance:mode --off\'</comment>' . PHP_EOL
188
+				'<comment>Nextcloud is in maintenance mode, hence the database isn\'t accessible.'.PHP_EOL.
189
+				'Cannot perform any command except \'maintenance:mode --off\'</comment>'.PHP_EOL
190 190
 			);
191 191
 		}
192 192
 	}
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 					try {
224 224
 						$c = new $command();
225 225
 					} catch (\ArgumentCountError $e2) {
226
-						throw new \Exception("Failed to construct console command '$command': " . $e->getMessage(), 0, $e);
226
+						throw new \Exception("Failed to construct console command '$command': ".$e->getMessage(), 0, $e);
227 227
 					}
228 228
 				} else {
229 229
 					throw new \Exception("Console command '$command' is unknown and could not be loaded");
Please login to merge, or discard this patch.