Passed
Push — master ( 61a02b...010b07 )
by Roeland
19:08 queued 08:59
created
lib/private/App/CodeChecker/InfoChecker.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -29,82 +29,82 @@
 block discarded – undo
29 29
 
30 30
 class InfoChecker extends BasicEmitter {
31 31
 
32
-	/** @var string[] */
33
-	private $shippedApps;
32
+    /** @var string[] */
33
+    private $shippedApps;
34 34
 
35
-	/** @var string[] */
36
-	private $alwaysEnabled;
35
+    /** @var string[] */
36
+    private $alwaysEnabled;
37 37
 
38
-	/**
39
-	 * @param string $appId
40
-	 * @return array
41
-	 * @throws \RuntimeException
42
-	 */
43
-	public function analyse($appId): array {
44
-		$appPath = \OC_App::getAppPath($appId);
45
-		if ($appPath === false) {
46
-			throw new \RuntimeException("No app with given id <$appId> known.");
47
-		}
38
+    /**
39
+     * @param string $appId
40
+     * @return array
41
+     * @throws \RuntimeException
42
+     */
43
+    public function analyse($appId): array {
44
+        $appPath = \OC_App::getAppPath($appId);
45
+        if ($appPath === false) {
46
+            throw new \RuntimeException("No app with given id <$appId> known.");
47
+        }
48 48
 
49
-		$xml = new \DOMDocument();
50
-		$xml->load($appPath . '/appinfo/info.xml');
49
+        $xml = new \DOMDocument();
50
+        $xml->load($appPath . '/appinfo/info.xml');
51 51
 
52
-		$schema = \OC::$SERVERROOT . '/resources/app-info.xsd';
53
-		try {
54
-			if ($this->isShipped($appId)) {
55
-				// Shipped apps are allowed to have the public and default_enabled tags
56
-				$schema = \OC::$SERVERROOT . '/resources/app-info-shipped.xsd';
57
-			}
58
-		} catch (\Exception $e) {
59
-			// Assume it is not shipped
60
-		}
52
+        $schema = \OC::$SERVERROOT . '/resources/app-info.xsd';
53
+        try {
54
+            if ($this->isShipped($appId)) {
55
+                // Shipped apps are allowed to have the public and default_enabled tags
56
+                $schema = \OC::$SERVERROOT . '/resources/app-info-shipped.xsd';
57
+            }
58
+        } catch (\Exception $e) {
59
+            // Assume it is not shipped
60
+        }
61 61
 
62
-		$errors = [];
63
-		if (!$xml->schemaValidate($schema)) {
64
-			foreach (libxml_get_errors() as $error) {
65
-				$errors[] = [
66
-					'type' => 'parseError',
67
-					'field' => $error->message,
68
-				];
69
-				$this->emit('InfoChecker', 'parseError', [$error->message]);
70
-			}
71
-		}
62
+        $errors = [];
63
+        if (!$xml->schemaValidate($schema)) {
64
+            foreach (libxml_get_errors() as $error) {
65
+                $errors[] = [
66
+                    'type' => 'parseError',
67
+                    'field' => $error->message,
68
+                ];
69
+                $this->emit('InfoChecker', 'parseError', [$error->message]);
70
+            }
71
+        }
72 72
 
73
-		return $errors;
74
-	}
73
+        return $errors;
74
+    }
75 75
 
76
-	/**
77
-	 * This is a copy of \OC\App\AppManager::isShipped(), keep both in sync.
78
-	 * This method is copied, so the code checker works even when Nextcloud is
79
-	 * not installed yet. The AppManager requires a database connection, which
80
-	 * fails in that case.
81
-	 *
82
-	 * @param string $appId
83
-	 * @return bool
84
-	 * @throws \Exception
85
-	 */
86
-	protected function isShipped(string $appId): bool {
87
-		$this->loadShippedJson();
88
-		return \in_array($appId, $this->shippedApps, true);
89
-	}
76
+    /**
77
+     * This is a copy of \OC\App\AppManager::isShipped(), keep both in sync.
78
+     * This method is copied, so the code checker works even when Nextcloud is
79
+     * not installed yet. The AppManager requires a database connection, which
80
+     * fails in that case.
81
+     *
82
+     * @param string $appId
83
+     * @return bool
84
+     * @throws \Exception
85
+     */
86
+    protected function isShipped(string $appId): bool {
87
+        $this->loadShippedJson();
88
+        return \in_array($appId, $this->shippedApps, true);
89
+    }
90 90
 
91
-	/**
92
-	 * This is a copy of \OC\App\AppManager::loadShippedJson(), keep both in sync
93
-	 * This method is copied, so the code checker works even when Nextcloud is
94
-	 * not installed yet. The AppManager requires a database connection, which
95
-	 * fails in that case.
96
-	 *
97
-	 * @throws \Exception
98
-	 */
99
-	protected function loadShippedJson() {
100
-		if ($this->shippedApps === null) {
101
-			$shippedJson = \OC::$SERVERROOT . '/core/shipped.json';
102
-			if (!file_exists($shippedJson)) {
103
-				throw new \Exception("File not found: $shippedJson");
104
-			}
105
-			$content = json_decode(file_get_contents($shippedJson), true);
106
-			$this->shippedApps = $content['shippedApps'];
107
-			$this->alwaysEnabled = $content['alwaysEnabled'];
108
-		}
109
-	}
91
+    /**
92
+     * This is a copy of \OC\App\AppManager::loadShippedJson(), keep both in sync
93
+     * This method is copied, so the code checker works even when Nextcloud is
94
+     * not installed yet. The AppManager requires a database connection, which
95
+     * fails in that case.
96
+     *
97
+     * @throws \Exception
98
+     */
99
+    protected function loadShippedJson() {
100
+        if ($this->shippedApps === null) {
101
+            $shippedJson = \OC::$SERVERROOT . '/core/shipped.json';
102
+            if (!file_exists($shippedJson)) {
103
+                throw new \Exception("File not found: $shippedJson");
104
+            }
105
+            $content = json_decode(file_get_contents($shippedJson), true);
106
+            $this->shippedApps = $content['shippedApps'];
107
+            $this->alwaysEnabled = $content['alwaysEnabled'];
108
+        }
109
+    }
110 110
 }
Please login to merge, or discard this patch.
core/Command/App/CheckCode.php 1 patch
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -44,167 +44,167 @@
 block discarded – undo
44 44
 
45 45
 class CheckCode extends Command implements CompletionAwareInterface  {
46 46
 
47
-	protected $checkers = [
48
-		'private' => PrivateCheck::class,
49
-		'deprecation' => DeprecationCheck::class,
50
-		'strong-comparison' => StrongComparisonCheck::class,
51
-	];
52
-
53
-	protected function configure() {
54
-		$this
55
-			->setName('app:check-code')
56
-			->setDescription('check code to be compliant')
57
-			->addArgument(
58
-				'app-id',
59
-				InputArgument::REQUIRED,
60
-				'check the specified app'
61
-			)
62
-			->addOption(
63
-				'checker',
64
-				'c',
65
-				InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
66
-				'enable the specified checker(s)',
67
-				[ 'private', 'deprecation', 'strong-comparison' ]
68
-			)
69
-			->addOption(
70
-				'--skip-checkers',
71
-				null,
72
-				InputOption::VALUE_NONE,
73
-				'skips the the code checkers to only check info.xml, language and database schema'
74
-			)
75
-			->addOption(
76
-				'--skip-validate-info',
77
-				null,
78
-				InputOption::VALUE_NONE,
79
-				'skips the info.xml/version check'
80
-			);
81
-	}
82
-
83
-	protected function execute(InputInterface $input, OutputInterface $output) {
84
-		$appId = $input->getArgument('app-id');
85
-
86
-		$checkList = new EmptyCheck();
87
-		foreach ($input->getOption('checker') as $checker) {
88
-			if (!isset($this->checkers[$checker])) {
89
-				throw new \InvalidArgumentException('Invalid checker: '.$checker);
90
-			}
91
-			$checkerClass = $this->checkers[$checker];
92
-			$checkList = new $checkerClass($checkList);
93
-		}
94
-
95
-		$codeChecker = new CodeChecker($checkList, !$input->getOption('skip-validate-info'));
96
-
97
-		$codeChecker->listen('CodeChecker', 'analyseFileBegin', function($params) use ($output) {
98
-			if(OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
99
-				$output->writeln("<info>Analysing {$params}</info>");
100
-			}
101
-		});
102
-		$codeChecker->listen('CodeChecker', 'analyseFileFinished', function($filename, $errors) use ($output) {
103
-			$count = count($errors);
104
-
105
-			// show filename if the verbosity is low, but there are errors in a file
106
-			if($count > 0 && OutputInterface::VERBOSITY_VERBOSE > $output->getVerbosity()) {
107
-				$output->writeln("<info>Analysing {$filename}</info>");
108
-			}
109
-
110
-			// show error count if there are errors present or the verbosity is high
111
-			if($count > 0 || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
112
-				$output->writeln(" {$count} errors");
113
-			}
114
-			usort($errors, function($a, $b) {
115
-				return $a['line'] >$b['line'];
116
-			});
117
-
118
-			foreach($errors as $p) {
119
-				$line = sprintf("%' 4d", $p['line']);
120
-				$output->writeln("    <error>line $line: {$p['disallowedToken']} - {$p['reason']}</error>");
121
-			}
122
-		});
123
-		$errors = [];
124
-		if(!$input->getOption('skip-checkers')) {
125
-			$errors = $codeChecker->analyse($appId);
126
-		}
127
-
128
-		if(!$input->getOption('skip-validate-info')) {
129
-			$infoChecker = new InfoChecker();
130
-			$infoChecker->listen('InfoChecker', 'parseError', function($error) use ($output) {
131
-				$output->writeln("<error>Invalid appinfo.xml file found: $error</error>");
132
-			});
133
-
134
-			$infoErrors = $infoChecker->analyse($appId);
135
-
136
-			$errors = array_merge($errors, $infoErrors);
137
-
138
-			$languageParser = new LanguageParseChecker();
139
-			$languageErrors = $languageParser->analyse($appId);
140
-
141
-			foreach ($languageErrors as $languageError) {
142
-				$output->writeln("<error>$languageError</error>");
143
-			}
144
-
145
-			$errors = array_merge($errors, $languageErrors);
146
-
147
-			$databaseSchema = new DatabaseSchemaChecker();
148
-			$schemaErrors = $databaseSchema->analyse($appId);
149
-
150
-			foreach ($schemaErrors['errors'] as $schemaError) {
151
-				$output->writeln("<error>$schemaError</error>");
152
-			}
153
-			foreach ($schemaErrors['warnings'] as $schemaWarning) {
154
-				$output->writeln("<comment>$schemaWarning</comment>");
155
-			}
156
-
157
-			$errors = array_merge($errors, $schemaErrors['errors']);
158
-		}
159
-
160
-		$this->analyseUpdateFile($appId, $output);
161
-
162
-		if (empty($errors)) {
163
-			$output->writeln('<info>App is compliant - awesome job!</info>');
164
-			return 0;
165
-		} else {
166
-			$output->writeln('<error>App is not compliant</error>');
167
-			return 101;
168
-		}
169
-	}
170
-
171
-	/**
172
-	 * @param string $appId
173
-	 * @param $output
174
-	 */
175
-	private function analyseUpdateFile($appId, OutputInterface $output) {
176
-		$appPath = \OC_App::getAppPath($appId);
177
-		if ($appPath === false) {
178
-			throw new \RuntimeException("No app with given id <$appId> known.");
179
-		}
180
-
181
-		$updatePhp = $appPath . '/appinfo/update.php';
182
-		if (file_exists($updatePhp)) {
183
-			$output->writeln("<info>Deprecated file found: $updatePhp - please use repair steps</info>");
184
-		}
185
-	}
186
-
187
-	/**
188
-	 * @param string $optionName
189
-	 * @param CompletionContext $context
190
-	 * @return string[]
191
-	 */
192
-	public function completeOptionValues($optionName, CompletionContext $context) {
193
-		if ($optionName === 'checker') {
194
-			return ['private', 'deprecation', 'strong-comparison'];
195
-		}
196
-		return [];
197
-	}
198
-
199
-	/**
200
-	 * @param string $argumentName
201
-	 * @param CompletionContext $context
202
-	 * @return string[]
203
-	 */
204
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
205
-		if ($argumentName === 'app-id') {
206
-			return \OC_App::getAllApps();
207
-		}
208
-		return [];
209
-	}
47
+    protected $checkers = [
48
+        'private' => PrivateCheck::class,
49
+        'deprecation' => DeprecationCheck::class,
50
+        'strong-comparison' => StrongComparisonCheck::class,
51
+    ];
52
+
53
+    protected function configure() {
54
+        $this
55
+            ->setName('app:check-code')
56
+            ->setDescription('check code to be compliant')
57
+            ->addArgument(
58
+                'app-id',
59
+                InputArgument::REQUIRED,
60
+                'check the specified app'
61
+            )
62
+            ->addOption(
63
+                'checker',
64
+                'c',
65
+                InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
66
+                'enable the specified checker(s)',
67
+                [ 'private', 'deprecation', 'strong-comparison' ]
68
+            )
69
+            ->addOption(
70
+                '--skip-checkers',
71
+                null,
72
+                InputOption::VALUE_NONE,
73
+                'skips the the code checkers to only check info.xml, language and database schema'
74
+            )
75
+            ->addOption(
76
+                '--skip-validate-info',
77
+                null,
78
+                InputOption::VALUE_NONE,
79
+                'skips the info.xml/version check'
80
+            );
81
+    }
82
+
83
+    protected function execute(InputInterface $input, OutputInterface $output) {
84
+        $appId = $input->getArgument('app-id');
85
+
86
+        $checkList = new EmptyCheck();
87
+        foreach ($input->getOption('checker') as $checker) {
88
+            if (!isset($this->checkers[$checker])) {
89
+                throw new \InvalidArgumentException('Invalid checker: '.$checker);
90
+            }
91
+            $checkerClass = $this->checkers[$checker];
92
+            $checkList = new $checkerClass($checkList);
93
+        }
94
+
95
+        $codeChecker = new CodeChecker($checkList, !$input->getOption('skip-validate-info'));
96
+
97
+        $codeChecker->listen('CodeChecker', 'analyseFileBegin', function($params) use ($output) {
98
+            if(OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
99
+                $output->writeln("<info>Analysing {$params}</info>");
100
+            }
101
+        });
102
+        $codeChecker->listen('CodeChecker', 'analyseFileFinished', function($filename, $errors) use ($output) {
103
+            $count = count($errors);
104
+
105
+            // show filename if the verbosity is low, but there are errors in a file
106
+            if($count > 0 && OutputInterface::VERBOSITY_VERBOSE > $output->getVerbosity()) {
107
+                $output->writeln("<info>Analysing {$filename}</info>");
108
+            }
109
+
110
+            // show error count if there are errors present or the verbosity is high
111
+            if($count > 0 || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
112
+                $output->writeln(" {$count} errors");
113
+            }
114
+            usort($errors, function($a, $b) {
115
+                return $a['line'] >$b['line'];
116
+            });
117
+
118
+            foreach($errors as $p) {
119
+                $line = sprintf("%' 4d", $p['line']);
120
+                $output->writeln("    <error>line $line: {$p['disallowedToken']} - {$p['reason']}</error>");
121
+            }
122
+        });
123
+        $errors = [];
124
+        if(!$input->getOption('skip-checkers')) {
125
+            $errors = $codeChecker->analyse($appId);
126
+        }
127
+
128
+        if(!$input->getOption('skip-validate-info')) {
129
+            $infoChecker = new InfoChecker();
130
+            $infoChecker->listen('InfoChecker', 'parseError', function($error) use ($output) {
131
+                $output->writeln("<error>Invalid appinfo.xml file found: $error</error>");
132
+            });
133
+
134
+            $infoErrors = $infoChecker->analyse($appId);
135
+
136
+            $errors = array_merge($errors, $infoErrors);
137
+
138
+            $languageParser = new LanguageParseChecker();
139
+            $languageErrors = $languageParser->analyse($appId);
140
+
141
+            foreach ($languageErrors as $languageError) {
142
+                $output->writeln("<error>$languageError</error>");
143
+            }
144
+
145
+            $errors = array_merge($errors, $languageErrors);
146
+
147
+            $databaseSchema = new DatabaseSchemaChecker();
148
+            $schemaErrors = $databaseSchema->analyse($appId);
149
+
150
+            foreach ($schemaErrors['errors'] as $schemaError) {
151
+                $output->writeln("<error>$schemaError</error>");
152
+            }
153
+            foreach ($schemaErrors['warnings'] as $schemaWarning) {
154
+                $output->writeln("<comment>$schemaWarning</comment>");
155
+            }
156
+
157
+            $errors = array_merge($errors, $schemaErrors['errors']);
158
+        }
159
+
160
+        $this->analyseUpdateFile($appId, $output);
161
+
162
+        if (empty($errors)) {
163
+            $output->writeln('<info>App is compliant - awesome job!</info>');
164
+            return 0;
165
+        } else {
166
+            $output->writeln('<error>App is not compliant</error>');
167
+            return 101;
168
+        }
169
+    }
170
+
171
+    /**
172
+     * @param string $appId
173
+     * @param $output
174
+     */
175
+    private function analyseUpdateFile($appId, OutputInterface $output) {
176
+        $appPath = \OC_App::getAppPath($appId);
177
+        if ($appPath === false) {
178
+            throw new \RuntimeException("No app with given id <$appId> known.");
179
+        }
180
+
181
+        $updatePhp = $appPath . '/appinfo/update.php';
182
+        if (file_exists($updatePhp)) {
183
+            $output->writeln("<info>Deprecated file found: $updatePhp - please use repair steps</info>");
184
+        }
185
+    }
186
+
187
+    /**
188
+     * @param string $optionName
189
+     * @param CompletionContext $context
190
+     * @return string[]
191
+     */
192
+    public function completeOptionValues($optionName, CompletionContext $context) {
193
+        if ($optionName === 'checker') {
194
+            return ['private', 'deprecation', 'strong-comparison'];
195
+        }
196
+        return [];
197
+    }
198
+
199
+    /**
200
+     * @param string $argumentName
201
+     * @param CompletionContext $context
202
+     * @return string[]
203
+     */
204
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
205
+        if ($argumentName === 'app-id') {
206
+            return \OC_App::getAllApps();
207
+        }
208
+        return [];
209
+    }
210 210
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/PersonalMount.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -32,58 +32,58 @@
 block discarded – undo
32 32
  * Person mount points can be moved by the user
33 33
  */
34 34
 class PersonalMount extends ExternalMountPoint implements MoveableMount {
35
-	/** @var UserStoragesService */
36
-	protected $storagesService;
35
+    /** @var UserStoragesService */
36
+    protected $storagesService;
37 37
 
38
-	/** @var int */
39
-	protected $numericStorageId;
38
+    /** @var int */
39
+    protected $numericStorageId;
40 40
 
41
-	/**
42
-	 * @param UserStoragesService $storagesService
43
-	 * @param int $storageId
44
-	 * @param \OCP\Files\Storage $storage
45
-	 * @param string $mountpoint
46
-	 * @param array $arguments (optional) configuration for the storage backend
47
-	 * @param \OCP\Files\Storage\IStorageFactory $loader
48
-	 * @param array $mountOptions mount specific options
49
-	 */
50
-	public function __construct(
51
-		UserStoragesService $storagesService,
52
-		$storageId,
53
-		$storage,
54
-		$mountpoint,
55
-		$arguments = null,
56
-		$loader = null,
57
-		$mountOptions = null
58
-	) {
59
-		parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions);
60
-		$this->storagesService = $storagesService;
61
-		$this->numericStorageId = $storageId;
62
-	}
41
+    /**
42
+     * @param UserStoragesService $storagesService
43
+     * @param int $storageId
44
+     * @param \OCP\Files\Storage $storage
45
+     * @param string $mountpoint
46
+     * @param array $arguments (optional) configuration for the storage backend
47
+     * @param \OCP\Files\Storage\IStorageFactory $loader
48
+     * @param array $mountOptions mount specific options
49
+     */
50
+    public function __construct(
51
+        UserStoragesService $storagesService,
52
+        $storageId,
53
+        $storage,
54
+        $mountpoint,
55
+        $arguments = null,
56
+        $loader = null,
57
+        $mountOptions = null
58
+    ) {
59
+        parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions);
60
+        $this->storagesService = $storagesService;
61
+        $this->numericStorageId = $storageId;
62
+    }
63 63
 
64
-	/**
65
-	 * Move the mount point to $target
66
-	 *
67
-	 * @param string $target the target mount point
68
-	 * @return bool
69
-	 */
70
-	public function moveMount($target) {
71
-		$storage = $this->storagesService->getStorage($this->numericStorageId);
72
-		// remove "/$user/files" prefix
73
-		$targetParts = explode('/', trim($target, '/'), 3);
74
-		$storage->setMountPoint($targetParts[2]);
75
-		$this->storagesService->updateStorage($storage);
76
-		$this->setMountPoint($target);
77
-		return true;
78
-	}
64
+    /**
65
+     * Move the mount point to $target
66
+     *
67
+     * @param string $target the target mount point
68
+     * @return bool
69
+     */
70
+    public function moveMount($target) {
71
+        $storage = $this->storagesService->getStorage($this->numericStorageId);
72
+        // remove "/$user/files" prefix
73
+        $targetParts = explode('/', trim($target, '/'), 3);
74
+        $storage->setMountPoint($targetParts[2]);
75
+        $this->storagesService->updateStorage($storage);
76
+        $this->setMountPoint($target);
77
+        return true;
78
+    }
79 79
 
80
-	/**
81
-	 * Remove the mount points
82
-	 *
83
-	 * @return bool
84
-	 */
85
-	public function removeMount() {
86
-		$this->storagesService->removeStorage($this->numericStorageId);
87
-		return true;
88
-	}
80
+    /**
81
+     * Remove the mount points
82
+     *
83
+     * @return bool
84
+     */
85
+    public function removeMount() {
86
+        $this->storagesService->removeStorage($this->numericStorageId);
87
+        return true;
88
+    }
89 89
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/MiddlewareDispatcher.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -38,128 +38,128 @@
 block discarded – undo
38 38
  */
39 39
 class MiddlewareDispatcher {
40 40
 
41
-	/**
42
-	 * @var array array containing all the middlewares
43
-	 */
44
-	private $middlewares;
45
-
46
-	/**
47
-	 * @var int counter which tells us what middlware was executed once an
48
-	 *                  exception occurs
49
-	 */
50
-	private $middlewareCounter;
51
-
52
-
53
-	/**
54
-	 * Constructor
55
-	 */
56
-	public function __construct(){
57
-		$this->middlewares = [];
58
-		$this->middlewareCounter = 0;
59
-	}
60
-
61
-
62
-	/**
63
-	 * Adds a new middleware
64
-	 * @param Middleware $middleWare the middleware which will be added
65
-	 */
66
-	public function registerMiddleware(Middleware $middleWare){
67
-		$this->middlewares[] = $middleWare;
68
-	}
69
-
70
-
71
-	/**
72
-	 * returns an array with all middleware elements
73
-	 * @return array the middlewares
74
-	 */
75
-	public function getMiddlewares(): array {
76
-		return $this->middlewares;
77
-	}
78
-
79
-
80
-	/**
81
-	 * This is being run in normal order before the controller is being
82
-	 * called which allows several modifications and checks
83
-	 *
84
-	 * @param Controller $controller the controller that is being called
85
-	 * @param string $methodName the name of the method that will be called on
86
-	 *                           the controller
87
-	 */
88
-	public function beforeController(Controller $controller, string $methodName){
89
-		// we need to count so that we know which middlewares we have to ask in
90
-		// case there is an exception
91
-		$middlewareCount = \count($this->middlewares);
92
-		for($i = 0; $i < $middlewareCount; $i++){
93
-			$this->middlewareCounter++;
94
-			$middleware = $this->middlewares[$i];
95
-			$middleware->beforeController($controller, $methodName);
96
-		}
97
-	}
98
-
99
-
100
-	/**
101
-	 * This is being run when either the beforeController method or the
102
-	 * controller method itself is throwing an exception. The middleware is asked
103
-	 * in reverse order to handle the exception and to return a response.
104
-	 * If the response is null, it is assumed that the exception could not be
105
-	 * handled and the error will be thrown again
106
-	 *
107
-	 * @param Controller $controller the controller that is being called
108
-	 * @param string $methodName the name of the method that will be called on
109
-	 *                            the controller
110
-	 * @param \Exception $exception the thrown exception
111
-	 * @return Response a Response object if the middleware can handle the
112
-	 * exception
113
-	 * @throws \Exception the passed in exception if it can't handle it
114
-	 */
115
-	public function afterException(Controller $controller, string $methodName, \Exception $exception): Response {
116
-		for($i=$this->middlewareCounter-1; $i>=0; $i--){
117
-			$middleware = $this->middlewares[$i];
118
-			try {
119
-				return $middleware->afterException($controller, $methodName, $exception);
120
-			} catch(\Exception $exception){
121
-				continue;
122
-			}
123
-		}
124
-		throw $exception;
125
-	}
126
-
127
-
128
-	/**
129
-	 * This is being run after a successful controllermethod call and allows
130
-	 * the manipulation of a Response object. The middleware is run in reverse order
131
-	 *
132
-	 * @param Controller $controller the controller that is being called
133
-	 * @param string $methodName the name of the method that will be called on
134
-	 *                            the controller
135
-	 * @param Response $response the generated response from the controller
136
-	 * @return Response a Response object
137
-	 */
138
-	public function afterController(Controller $controller, string $methodName, Response $response): Response {
139
-		for($i= \count($this->middlewares)-1; $i>=0; $i--){
140
-			$middleware = $this->middlewares[$i];
141
-			$response = $middleware->afterController($controller, $methodName, $response);
142
-		}
143
-		return $response;
144
-	}
145
-
146
-
147
-	/**
148
-	 * This is being run after the response object has been rendered and
149
-	 * allows the manipulation of the output. The middleware is run in reverse order
150
-	 *
151
-	 * @param Controller $controller the controller that is being called
152
-	 * @param string $methodName the name of the method that will be called on
153
-	 *                           the controller
154
-	 * @param string $output the generated output from a response
155
-	 * @return string the output that should be printed
156
-	 */
157
-	public function beforeOutput(Controller $controller, string $methodName, string $output): string {
158
-		for($i= \count($this->middlewares)-1; $i>=0; $i--){
159
-			$middleware = $this->middlewares[$i];
160
-			$output = $middleware->beforeOutput($controller, $methodName, $output);
161
-		}
162
-		return $output;
163
-	}
41
+    /**
42
+     * @var array array containing all the middlewares
43
+     */
44
+    private $middlewares;
45
+
46
+    /**
47
+     * @var int counter which tells us what middlware was executed once an
48
+     *                  exception occurs
49
+     */
50
+    private $middlewareCounter;
51
+
52
+
53
+    /**
54
+     * Constructor
55
+     */
56
+    public function __construct(){
57
+        $this->middlewares = [];
58
+        $this->middlewareCounter = 0;
59
+    }
60
+
61
+
62
+    /**
63
+     * Adds a new middleware
64
+     * @param Middleware $middleWare the middleware which will be added
65
+     */
66
+    public function registerMiddleware(Middleware $middleWare){
67
+        $this->middlewares[] = $middleWare;
68
+    }
69
+
70
+
71
+    /**
72
+     * returns an array with all middleware elements
73
+     * @return array the middlewares
74
+     */
75
+    public function getMiddlewares(): array {
76
+        return $this->middlewares;
77
+    }
78
+
79
+
80
+    /**
81
+     * This is being run in normal order before the controller is being
82
+     * called which allows several modifications and checks
83
+     *
84
+     * @param Controller $controller the controller that is being called
85
+     * @param string $methodName the name of the method that will be called on
86
+     *                           the controller
87
+     */
88
+    public function beforeController(Controller $controller, string $methodName){
89
+        // we need to count so that we know which middlewares we have to ask in
90
+        // case there is an exception
91
+        $middlewareCount = \count($this->middlewares);
92
+        for($i = 0; $i < $middlewareCount; $i++){
93
+            $this->middlewareCounter++;
94
+            $middleware = $this->middlewares[$i];
95
+            $middleware->beforeController($controller, $methodName);
96
+        }
97
+    }
98
+
99
+
100
+    /**
101
+     * This is being run when either the beforeController method or the
102
+     * controller method itself is throwing an exception. The middleware is asked
103
+     * in reverse order to handle the exception and to return a response.
104
+     * If the response is null, it is assumed that the exception could not be
105
+     * handled and the error will be thrown again
106
+     *
107
+     * @param Controller $controller the controller that is being called
108
+     * @param string $methodName the name of the method that will be called on
109
+     *                            the controller
110
+     * @param \Exception $exception the thrown exception
111
+     * @return Response a Response object if the middleware can handle the
112
+     * exception
113
+     * @throws \Exception the passed in exception if it can't handle it
114
+     */
115
+    public function afterException(Controller $controller, string $methodName, \Exception $exception): Response {
116
+        for($i=$this->middlewareCounter-1; $i>=0; $i--){
117
+            $middleware = $this->middlewares[$i];
118
+            try {
119
+                return $middleware->afterException($controller, $methodName, $exception);
120
+            } catch(\Exception $exception){
121
+                continue;
122
+            }
123
+        }
124
+        throw $exception;
125
+    }
126
+
127
+
128
+    /**
129
+     * This is being run after a successful controllermethod call and allows
130
+     * the manipulation of a Response object. The middleware is run in reverse order
131
+     *
132
+     * @param Controller $controller the controller that is being called
133
+     * @param string $methodName the name of the method that will be called on
134
+     *                            the controller
135
+     * @param Response $response the generated response from the controller
136
+     * @return Response a Response object
137
+     */
138
+    public function afterController(Controller $controller, string $methodName, Response $response): Response {
139
+        for($i= \count($this->middlewares)-1; $i>=0; $i--){
140
+            $middleware = $this->middlewares[$i];
141
+            $response = $middleware->afterController($controller, $methodName, $response);
142
+        }
143
+        return $response;
144
+    }
145
+
146
+
147
+    /**
148
+     * This is being run after the response object has been rendered and
149
+     * allows the manipulation of the output. The middleware is run in reverse order
150
+     *
151
+     * @param Controller $controller the controller that is being called
152
+     * @param string $methodName the name of the method that will be called on
153
+     *                           the controller
154
+     * @param string $output the generated output from a response
155
+     * @return string the output that should be printed
156
+     */
157
+    public function beforeOutput(Controller $controller, string $methodName, string $output): string {
158
+        for($i= \count($this->middlewares)-1; $i>=0; $i--){
159
+            $middleware = $this->middlewares[$i];
160
+            $output = $middleware->beforeOutput($controller, $methodName, $output);
161
+        }
162
+        return $output;
163
+    }
164 164
 
165 165
 }
Please login to merge, or discard this patch.
lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -25,45 +25,45 @@
 block discarded – undo
25 25
 namespace OC\IntegrityCheck\Iterator;
26 26
 
27 27
 class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator {
28
-	private $excludedFolders;
28
+    private $excludedFolders;
29 29
 
30
-	public function __construct(\RecursiveIterator $iterator, $root = '') {
31
-		parent::__construct($iterator);
30
+    public function __construct(\RecursiveIterator $iterator, $root = '') {
31
+        parent::__construct($iterator);
32 32
 
33
-		$appFolders = \OC::$APPSROOTS;
34
-		foreach($appFolders as $key => $appFolder) {
35
-			$appFolders[$key] = rtrim($appFolder['path'], '/');
36
-		}
33
+        $appFolders = \OC::$APPSROOTS;
34
+        foreach($appFolders as $key => $appFolder) {
35
+            $appFolders[$key] = rtrim($appFolder['path'], '/');
36
+        }
37 37
 
38
-		$excludedFolders = [
39
-			rtrim($root . '/data', '/'),
40
-			rtrim($root . '/themes', '/'),
41
-			rtrim($root . '/config', '/'),
42
-			rtrim($root . '/apps', '/'),
43
-			rtrim($root . '/assets', '/'),
44
-			rtrim($root . '/lost+found', '/'),
45
-			// Ignore folders generated by updater since the updater is replaced
46
-			// after the integrity check is run.
47
-			// See https://github.com/owncloud/updater/issues/318#issuecomment-212497846
48
-			rtrim($root . '/updater', '/'),
49
-			rtrim($root . '/_oc_upgrade', '/'),
50
-		];
51
-		$customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', '');
52
-		if($customDataDir !== '') {
53
-			$excludedFolders[] = rtrim($customDataDir, '/');
54
-		}
38
+        $excludedFolders = [
39
+            rtrim($root . '/data', '/'),
40
+            rtrim($root . '/themes', '/'),
41
+            rtrim($root . '/config', '/'),
42
+            rtrim($root . '/apps', '/'),
43
+            rtrim($root . '/assets', '/'),
44
+            rtrim($root . '/lost+found', '/'),
45
+            // Ignore folders generated by updater since the updater is replaced
46
+            // after the integrity check is run.
47
+            // See https://github.com/owncloud/updater/issues/318#issuecomment-212497846
48
+            rtrim($root . '/updater', '/'),
49
+            rtrim($root . '/_oc_upgrade', '/'),
50
+        ];
51
+        $customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', '');
52
+        if($customDataDir !== '') {
53
+            $excludedFolders[] = rtrim($customDataDir, '/');
54
+        }
55 55
 
56
-		$this->excludedFolders = array_merge($excludedFolders, $appFolders);
57
-	}
56
+        $this->excludedFolders = array_merge($excludedFolders, $appFolders);
57
+    }
58 58
 
59
-	/**
60
-	 * @return bool
61
-	 */
62
-	public function accept() {
63
-		return !\in_array(
64
-			$this->current()->getPathName(),
65
-			$this->excludedFolders,
66
-			true
67
-		);
68
-	}
59
+    /**
60
+     * @return bool
61
+     */
62
+    public function accept() {
63
+        return !\in_array(
64
+            $this->current()->getPathName(),
65
+            $this->excludedFolders,
66
+            true
67
+        );
68
+    }
69 69
 }
Please login to merge, or discard this patch.
lib/private/IntegrityCheck/Helpers/EnvironmentHelper.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -30,21 +30,21 @@
 block discarded – undo
30 30
  * @package OC\IntegrityCheck\Helpers
31 31
  */
32 32
 class EnvironmentHelper {
33
-	/**
34
-	 * Provides \OC::$SERVERROOT
35
-	 *
36
-	 * @return string
37
-	 */
38
-	public function getServerRoot(): string {
39
-		return rtrim(\OC::$SERVERROOT, '/');
40
-	}
33
+    /**
34
+     * Provides \OC::$SERVERROOT
35
+     *
36
+     * @return string
37
+     */
38
+    public function getServerRoot(): string {
39
+        return rtrim(\OC::$SERVERROOT, '/');
40
+    }
41 41
 
42
-	/**
43
-	 * Provides \OC_Util::getChannel()
44
-	 *
45
-	 * @return string
46
-	 */
47
-	public function getChannel(): string {
48
-		return \OC_Util::getChannel();
49
-	}
42
+    /**
43
+     * Provides \OC_Util::getChannel()
44
+     *
45
+     * @return string
46
+     */
47
+    public function getChannel(): string {
48
+        return \OC_Util::getChannel();
49
+    }
50 50
 }
Please login to merge, or discard this patch.
lib/private/IntegrityCheck/Helpers/FileAccessHelper.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -31,57 +31,57 @@
 block discarded – undo
31 31
  * @package OC\IntegrityCheck\Helpers
32 32
  */
33 33
 class FileAccessHelper {
34
-	/**
35
-	 * Wrapper around file_get_contents($filename, $data)
36
-	 *
37
-	 * @param string $filename
38
-	 * @return string|false
39
-	 */
40
-	public function file_get_contents(string $filename) {
41
-		return file_get_contents($filename);
42
-	}
34
+    /**
35
+     * Wrapper around file_get_contents($filename, $data)
36
+     *
37
+     * @param string $filename
38
+     * @return string|false
39
+     */
40
+    public function file_get_contents(string $filename) {
41
+        return file_get_contents($filename);
42
+    }
43 43
 
44
-	/**
45
-	 * Wrapper around file_exists($filename)
46
-	 *
47
-	 * @param string $filename
48
-	 * @return bool
49
-	 */
50
-	public function file_exists(string $filename): bool {
51
-		return file_exists($filename);
52
-	}
44
+    /**
45
+     * Wrapper around file_exists($filename)
46
+     *
47
+     * @param string $filename
48
+     * @return bool
49
+     */
50
+    public function file_exists(string $filename): bool {
51
+        return file_exists($filename);
52
+    }
53 53
 
54
-	/**
55
-	 * Wrapper around file_put_contents($filename, $data)
56
-	 *
57
-	 * @param string $filename
58
-	 * @param string $data
59
-	 * @return int
60
-	 * @throws \Exception
61
-	 */
62
-	public function file_put_contents(string $filename, string $data): int {
63
-		$bytesWritten = @file_put_contents($filename, $data);
64
-		if ($bytesWritten === false || $bytesWritten !== \strlen($data)){
65
-			throw new \Exception('Failed to write into ' . $filename);
66
-		}
67
-		return $bytesWritten;
68
-	}
54
+    /**
55
+     * Wrapper around file_put_contents($filename, $data)
56
+     *
57
+     * @param string $filename
58
+     * @param string $data
59
+     * @return int
60
+     * @throws \Exception
61
+     */
62
+    public function file_put_contents(string $filename, string $data): int {
63
+        $bytesWritten = @file_put_contents($filename, $data);
64
+        if ($bytesWritten === false || $bytesWritten !== \strlen($data)){
65
+            throw new \Exception('Failed to write into ' . $filename);
66
+        }
67
+        return $bytesWritten;
68
+    }
69 69
 
70
-	/**
71
-	 * @param string $path
72
-	 * @return bool
73
-	 */
74
-	public function is_writable(string $path): bool {
75
-		return is_writable($path);
76
-	}
70
+    /**
71
+     * @param string $path
72
+     * @return bool
73
+     */
74
+    public function is_writable(string $path): bool {
75
+        return is_writable($path);
76
+    }
77 77
 
78
-	/**
79
-	 * @param string $path
80
-	 * @throws \Exception
81
-	 */
82
-	public function assertDirectoryExists(string $path) {
83
-		if (!is_dir($path)) {
84
-			throw new \Exception('Directory ' . $path . ' does not exist.');
85
-		}
86
-	}
78
+    /**
79
+     * @param string $path
80
+     * @throws \Exception
81
+     */
82
+    public function assertDirectoryExists(string $path) {
83
+        if (!is_dir($path)) {
84
+            throw new \Exception('Directory ' . $path . ' does not exist.');
85
+        }
86
+    }
87 87
 }
Please login to merge, or discard this patch.
lib/private/IntegrityCheck/Helpers/AppLocator.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -31,28 +31,28 @@
 block discarded – undo
31 31
  * @package OC\IntegrityCheck\Helpers
32 32
  */
33 33
 class AppLocator {
34
-	/**
35
-	 * Provides \OC_App::getAppPath($appId)
36
-	 *
37
-	 * @param string $appId
38
-	 * @return string
39
-	 * @throws \Exception If the app cannot be found
40
-	 */
41
-	public function getAppPath(string $appId): string {
42
-		$path = \OC_App::getAppPath($appId);
43
-		if($path === false) {
34
+    /**
35
+     * Provides \OC_App::getAppPath($appId)
36
+     *
37
+     * @param string $appId
38
+     * @return string
39
+     * @throws \Exception If the app cannot be found
40
+     */
41
+    public function getAppPath(string $appId): string {
42
+        $path = \OC_App::getAppPath($appId);
43
+        if($path === false) {
44 44
 
45
-			throw new \Exception('App not found');
46
-		}
47
-		return $path;
48
-	}
45
+            throw new \Exception('App not found');
46
+        }
47
+        return $path;
48
+    }
49 49
 
50
-	/**
51
-	 * Providers \OC_App::getAllApps()
52
-	 *
53
-	 * @return array
54
-	 */
55
-	public function getAllApps(): array {
56
-		return \OC_App::getAllApps();
57
-	}
50
+    /**
51
+     * Providers \OC_App::getAllApps()
52
+     *
53
+     * @return array
54
+     */
55
+    public function getAllApps(): array {
56
+        return \OC_App::getAllApps();
57
+    }
58 58
 }
Please login to merge, or discard this patch.
lib/public/SystemTag/MapperEvent.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -33,63 +33,63 @@
 block discarded – undo
33 33
  */
34 34
 class MapperEvent extends Event {
35 35
 
36
-	const EVENT_ASSIGN = 'OCP\SystemTag\ISystemTagObjectMapper::assignTags';
37
-	const EVENT_UNASSIGN = 'OCP\SystemTag\ISystemTagObjectMapper::unassignTags';
36
+    const EVENT_ASSIGN = 'OCP\SystemTag\ISystemTagObjectMapper::assignTags';
37
+    const EVENT_UNASSIGN = 'OCP\SystemTag\ISystemTagObjectMapper::unassignTags';
38 38
 
39
-	/** @var string */
40
-	protected $event;
41
-	/** @var string */
42
-	protected $objectType;
43
-	/** @var string */
44
-	protected $objectId;
45
-	/** @var int[] */
46
-	protected $tags;
39
+    /** @var string */
40
+    protected $event;
41
+    /** @var string */
42
+    protected $objectType;
43
+    /** @var string */
44
+    protected $objectId;
45
+    /** @var int[] */
46
+    protected $tags;
47 47
 
48
-	/**
49
-	 * DispatcherEvent constructor.
50
-	 *
51
-	 * @param string $event
52
-	 * @param string $objectType
53
-	 * @param string $objectId
54
-	 * @param int[] $tags
55
-	 * @since 9.0.0
56
-	 */
57
-	public function __construct(string $event, string $objectType, string $objectId, array $tags) {
58
-		$this->event = $event;
59
-		$this->objectType = $objectType;
60
-		$this->objectId = $objectId;
61
-		$this->tags = $tags;
62
-	}
48
+    /**
49
+     * DispatcherEvent constructor.
50
+     *
51
+     * @param string $event
52
+     * @param string $objectType
53
+     * @param string $objectId
54
+     * @param int[] $tags
55
+     * @since 9.0.0
56
+     */
57
+    public function __construct(string $event, string $objectType, string $objectId, array $tags) {
58
+        $this->event = $event;
59
+        $this->objectType = $objectType;
60
+        $this->objectId = $objectId;
61
+        $this->tags = $tags;
62
+    }
63 63
 
64
-	/**
65
-	 * @return string
66
-	 * @since 9.0.0
67
-	 */
68
-	public function getEvent(): string {
69
-		return $this->event;
70
-	}
64
+    /**
65
+     * @return string
66
+     * @since 9.0.0
67
+     */
68
+    public function getEvent(): string {
69
+        return $this->event;
70
+    }
71 71
 
72
-	/**
73
-	 * @return string
74
-	 * @since 9.0.0
75
-	 */
76
-	public function getObjectType(): string {
77
-		return $this->objectType;
78
-	}
72
+    /**
73
+     * @return string
74
+     * @since 9.0.0
75
+     */
76
+    public function getObjectType(): string {
77
+        return $this->objectType;
78
+    }
79 79
 
80
-	/**
81
-	 * @return string
82
-	 * @since 9.0.0
83
-	 */
84
-	public function getObjectId(): string {
85
-		return $this->objectId;
86
-	}
80
+    /**
81
+     * @return string
82
+     * @since 9.0.0
83
+     */
84
+    public function getObjectId(): string {
85
+        return $this->objectId;
86
+    }
87 87
 
88
-	/**
89
-	 * @return int[]
90
-	 * @since 9.0.0
91
-	 */
92
-	public function getTags(): array {
93
-		return $this->tags;
94
-	}
88
+    /**
89
+     * @return int[]
90
+     * @since 9.0.0
91
+     */
92
+    public function getTags(): array {
93
+        return $this->tags;
94
+    }
95 95
 }
Please login to merge, or discard this patch.