Completed
Pull Request — master (#3643)
by Christoph
12:28
created
lib/private/AppFramework/Middleware/MiddlewareDispatcher.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * Constructor
54 54
 	 */
55
-	public function __construct(){
55
+	public function __construct() {
56 56
 		$this->middlewares = array();
57 57
 		$this->middlewareCounter = 0;
58 58
 	}
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * Adds a new middleware
63 63
 	 * @param Middleware $middleWare the middleware which will be added
64 64
 	 */
65
-	public function registerMiddleware(Middleware $middleWare){
65
+	public function registerMiddleware(Middleware $middleWare) {
66 66
 		array_push($this->middlewares, $middleWare);
67 67
 	}
68 68
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * returns an array with all middleware elements
72 72
 	 * @return array the middlewares
73 73
 	 */
74
-	public function getMiddlewares(){
74
+	public function getMiddlewares() {
75 75
 		return $this->middlewares;
76 76
 	}
77 77
 
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 	 * @param string $methodName the name of the method that will be called on
85 85
 	 *                           the controller
86 86
 	 */
87
-	public function beforeController(Controller $controller, $methodName){
87
+	public function beforeController(Controller $controller, $methodName) {
88 88
 		// we need to count so that we know which middlewares we have to ask in
89 89
 		// case there is an exception
90 90
 		$middlewareCount = count($this->middlewares);
91
-		for($i = 0; $i < $middlewareCount; $i++){
91
+		for ($i = 0; $i < $middlewareCount; $i++) {
92 92
 			$this->middlewareCounter++;
93 93
 			$middleware = $this->middlewares[$i];
94 94
 			$middleware->beforeController($controller, $methodName);
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
 	 * exception
112 112
 	 * @throws \Exception the passed in exception if it can't handle it
113 113
 	 */
114
-	public function afterException(Controller $controller, $methodName, \Exception $exception){
115
-		for($i=$this->middlewareCounter-1; $i>=0; $i--){
114
+	public function afterException(Controller $controller, $methodName, \Exception $exception) {
115
+		for ($i = $this->middlewareCounter - 1; $i >= 0; $i--) {
116 116
 			$middleware = $this->middlewares[$i];
117 117
 			try {
118 118
 				return $middleware->afterException($controller, $methodName, $exception);
119
-			} catch(\Exception $exception){
119
+			} catch (\Exception $exception) {
120 120
 				continue;
121 121
 			}
122 122
 		}
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 * @param Response $response the generated response from the controller
135 135
 	 * @return Response a Response object
136 136
 	 */
137
-	public function afterController(Controller $controller, $methodName, Response $response){
138
-		for($i=count($this->middlewares)-1; $i>=0; $i--){
137
+	public function afterController(Controller $controller, $methodName, Response $response) {
138
+		for ($i = count($this->middlewares) - 1; $i >= 0; $i--) {
139 139
 			$middleware = $this->middlewares[$i];
140 140
 			$response = $middleware->afterController($controller, $methodName, $response);
141 141
 		}
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 	 * @param string $output the generated output from a response
154 154
 	 * @return string the output that should be printed
155 155
 	 */
156
-	public function beforeOutput(Controller $controller, $methodName, $output){
157
-		for($i=count($this->middlewares)-1; $i>=0; $i--){
156
+	public function beforeOutput(Controller $controller, $methodName, $output) {
157
+		for ($i = count($this->middlewares) - 1; $i >= 0; $i--) {
158 158
 			$middleware = $this->middlewares[$i];
159 159
 			$output = $middleware->beforeOutput($controller, $methodName, $output);
160 160
 		}
Please login to merge, or discard this patch.
lib/private/AppFramework/OCS/BaseResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 use OCP\AppFramework\Http\EmptyContentSecurityPolicy;
27 27
 use OCP\AppFramework\Http\Response;
28 28
 
29
-abstract class BaseResponse extends Response   {
29
+abstract class BaseResponse extends Response {
30 30
 	/** @var array */
31 31
 	protected $data;
32 32
 
Please login to merge, or discard this patch.
lib/private/AppFramework/OCS/V2Response.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 	 */
36 36
 	public function getStatus() {
37 37
 
38
-		$status  = parent::getStatus();
38
+		$status = parent::getStatus();
39 39
 		if ($status === API::RESPOND_UNAUTHORISED) {
40 40
 			return Http::STATUS_UNAUTHORIZED;
41 41
 		} else if ($status === API::RESPOND_NOT_FOUND) {
Please login to merge, or discard this patch.
lib/private/AppFramework/OCS/V1Response.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @return int
35 35
 	 */
36 36
 	public function getStatus() {
37
-		$status  = parent::getStatus();
37
+		$status = parent::getStatus();
38 38
 		if ($status === Http::STATUS_FORBIDDEN || $status === API::RESPOND_UNAUTHORISED) {
39 39
 			return Http::STATUS_UNAUTHORIZED;
40 40
 		}
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 			'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage,
71 71
 		];
72 72
 
73
-		$meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : '';
74
-		$meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: '';
73
+		$meta['totalitems'] = $this->itemsCount !== null ? (string) $this->itemsCount : '';
74
+		$meta['itemsperpage'] = $this->itemsPerPage !== null ? (string) $this->itemsPerPage : '';
75 75
 
76 76
 		return $this->renderResult($meta);
77 77
 	}
Please login to merge, or discard this patch.
lib/private/AppFramework/Routing/RouteConfig.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 				$root = '/apps/'.$this->appName;
104 104
 			}
105 105
 
106
-			$url = $root . $ocsRoute['url'];
106
+			$url = $root.$ocsRoute['url'];
107 107
 			$verb = isset($ocsRoute['verb']) ? strtoupper($ocsRoute['verb']) : 'GET';
108 108
 
109 109
 			$split = explode('#', $name, 2);
@@ -119,19 +119,19 @@  discard block
 block discarded – undo
119 119
 			// register the route
120 120
 			$handler = new RouteActionHandler($this->container, $controllerName, $actionName);
121 121
 
122
-			$router = $this->router->create('ocs.'.$this->appName.'.'.$controller.'.'.$action . $postfix, $url)
122
+			$router = $this->router->create('ocs.'.$this->appName.'.'.$controller.'.'.$action.$postfix, $url)
123 123
 				->method($verb)
124 124
 				->action($handler);
125 125
 
126 126
 			// optionally register requirements for route. This is used to
127 127
 			// tell the route parser how url parameters should be matched
128
-			if(array_key_exists('requirements', $ocsRoute)) {
128
+			if (array_key_exists('requirements', $ocsRoute)) {
129 129
 				$router->requirements($ocsRoute['requirements']);
130 130
 			}
131 131
 
132 132
 			// optionally register defaults for route. This is used to
133 133
 			// tell the route parser how url parameters should be default valued
134
-			if(array_key_exists('defaults', $ocsRoute)) {
134
+			if (array_key_exists('defaults', $ocsRoute)) {
135 135
 				$router->defaults($ocsRoute['defaults']);
136 136
 			}
137 137
 		}
@@ -168,19 +168,19 @@  discard block
 block discarded – undo
168 168
 
169 169
 			// register the route
170 170
 			$handler = new RouteActionHandler($this->container, $controllerName, $actionName);
171
-			$router = $this->router->create($this->appName.'.'.$controller.'.'.$action . $postfix, $url)
171
+			$router = $this->router->create($this->appName.'.'.$controller.'.'.$action.$postfix, $url)
172 172
 							->method($verb)
173 173
 							->action($handler);
174 174
 
175 175
 			// optionally register requirements for route. This is used to
176 176
 			// tell the route parser how url parameters should be matched
177
-			if(array_key_exists('requirements', $simpleRoute)) {
177
+			if (array_key_exists('requirements', $simpleRoute)) {
178 178
 				$router->requirements($simpleRoute['requirements']);
179 179
 			}
180 180
 
181 181
 			// optionally register defaults for route. This is used to
182 182
 			// tell the route parser how url parameters should be default valued
183
-			if(array_key_exists('defaults', $simpleRoute)) {
183
+			if (array_key_exists('defaults', $simpleRoute)) {
184 184
 				$router->defaults($simpleRoute['defaults']);
185 185
 			}
186 186
 		}
@@ -212,16 +212,16 @@  discard block
 block discarded – undo
212 212
 		foreach ($resources as $resource => $config) {
213 213
 
214 214
 			// the url parameter used as id to the resource
215
-			foreach($actions as $action) {
215
+			foreach ($actions as $action) {
216 216
 				$url = $config['url'];
217 217
 				$method = $action['name'];
218 218
 				$verb = isset($action['verb']) ? strtoupper($action['verb']) : 'GET';
219 219
 				$collectionAction = isset($action['on-collection']) ? $action['on-collection'] : false;
220 220
 				if (!$collectionAction) {
221
-					$url = $url . '/{id}';
221
+					$url = $url.'/{id}';
222 222
 				}
223 223
 				if (isset($action['url-postfix'])) {
224
-					$url = $url . '/' . $action['url-postfix'];
224
+					$url = $url.'/'.$action['url-postfix'];
225 225
 				}
226 226
 
227 227
 				$controller = $resource;
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 				$controllerName = $this->buildControllerName($controller);
230 230
 				$actionName = $this->buildActionName($method);
231 231
 
232
-				$routeName = $this->appName . '.' . strtolower($resource) . '.' . strtolower($method);
232
+				$routeName = $this->appName.'.'.strtolower($resource).'.'.strtolower($method);
233 233
 
234 234
 				$this->router->create($routeName, $url)->method($verb)->action(
235 235
 					new RouteActionHandler($this->container, $controllerName, $actionName)
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	private function buildControllerName($controller)
247 247
 	{
248 248
 		if (!isset($this->controllerNameCache[$controller])) {
249
-			$this->controllerNameCache[$controller] = $this->underScoreToCamelCase(ucfirst($controller)) . 'Controller';
249
+			$this->controllerNameCache[$controller] = $this->underScoreToCamelCase(ucfirst($controller)).'Controller';
250 250
 		}
251 251
 		return $this->controllerNameCache[$controller];
252 252
 	}
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		$pattern = "/_[a-z]?/";
270 270
 		return preg_replace_callback(
271 271
 			$pattern,
272
-			function ($matches) {
272
+			function($matches) {
273 273
 				return strtoupper(ltrim($matches[0], "_"));
274 274
 			},
275 275
 			$str);
Please login to merge, or discard this patch.
lib/private/AppFramework/DependencyInjection/DIContainer.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * Put your class dependencies in here
66 66
 	 * @param string $appName the name of the app
67 67
 	 */
68
-	public function __construct($appName, $urlParams = array()){
68
+	public function __construct($appName, $urlParams = array()) {
69 69
 		parent::__construct();
70 70
 		$this['AppName'] = $appName;
71 71
 		$this['urlParams'] = $urlParams;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 			return $this->getServer()->getAppManager();
91 91
 		});
92 92
 
93
-		$this->registerService('OCP\\AppFramework\\Http\\IOutput', function($c){
93
+		$this->registerService('OCP\\AppFramework\\Http\\IOutput', function($c) {
94 94
 			return new Output($this->getServer()->getWebRoot());
95 95
 		});
96 96
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			return $this->getServer()->getHTTPClientService();
182 182
 		});
183 183
 
184
-		$this->registerService(IAppData::class, function (SimpleContainer $c) {
184
+		$this->registerService(IAppData::class, function(SimpleContainer $c) {
185 185
 			return $this->getServer()->getAppDataDir($c->query('AppName'));
186 186
 		});
187 187
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			return $this->getServer()->getPreviewManager();
233 233
 		});
234 234
 
235
-		$this->registerService('OCP\\IRequest', function () {
235
+		$this->registerService('OCP\\IRequest', function() {
236 236
 			return $this->getServer()->getRequest();
237 237
 		});
238 238
 		$this->registerAlias('Request', 'OCP\\IRequest');
@@ -310,36 +310,36 @@  discard block
 block discarded – undo
310 310
 			return $this->getServer()->getContentSecurityPolicyManager();
311 311
 		});
312 312
 
313
-		$this->registerService('ServerContainer', function ($c) {
313
+		$this->registerService('ServerContainer', function($c) {
314 314
 			return $this->getServer();
315 315
 		});
316 316
 		$this->registerAlias('OCP\\IServerContainer', 'ServerContainer');
317 317
 
318
-		$this->registerService('Symfony\Component\EventDispatcher\EventDispatcherInterface', function ($c) {
318
+		$this->registerService('Symfony\Component\EventDispatcher\EventDispatcherInterface', function($c) {
319 319
 			return $this->getServer()->getEventDispatcher();
320 320
 		});
321 321
 
322
-		$this->registerService('OCP\WorkflowEngine\IManager', function ($c) {
322
+		$this->registerService('OCP\WorkflowEngine\IManager', function($c) {
323 323
 			return $c->query('OCA\WorkflowEngine\Manager');
324 324
 		});
325 325
 
326
-		$this->registerService('OCP\\AppFramework\\IAppContainer', function ($c) {
326
+		$this->registerService('OCP\\AppFramework\\IAppContainer', function($c) {
327 327
 			return $c;
328 328
 		});
329
-		$this->registerService(IMountManager::class, function () {
329
+		$this->registerService(IMountManager::class, function() {
330 330
 			return $this->getServer()->getMountManager();
331 331
 		});
332 332
 
333 333
 		// commonly used attributes
334
-		$this->registerService('UserId', function ($c) {
334
+		$this->registerService('UserId', function($c) {
335 335
 			return $c->query('OCP\\IUserSession')->getSession()->get('user_id');
336 336
 		});
337 337
 
338
-		$this->registerService('WebRoot', function ($c) {
338
+		$this->registerService('WebRoot', function($c) {
339 339
 			return $c->query('ServerContainer')->getWebRoot();
340 340
 		});
341 341
 
342
-		$this->registerService('OCP\Encryption\IManager', function ($c) {
342
+		$this->registerService('OCP\Encryption\IManager', function($c) {
343 343
 			return $this->getServer()->getEncryptionManager();
344 344
 		});
345 345
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 			return $c->query(Validator::class);
348 348
 		});
349 349
 
350
-		$this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) {
350
+		$this->registerService(\OC\Security\IdentityProof\Manager::class, function($c) {
351 351
 			return new \OC\Security\IdentityProof\Manager(
352 352
 				$this->getServer()->getAppDataDir('identityproof'),
353 353
 				$this->getServer()->getCrypto()
@@ -358,15 +358,15 @@  discard block
 block discarded – undo
358 358
 		/**
359 359
 		 * App Framework APIs
360 360
 		 */
361
-		$this->registerService('API', function($c){
361
+		$this->registerService('API', function($c) {
362 362
 			$c->query('OCP\\ILogger')->debug(
363
-				'Accessing the API class is deprecated! Use the appropriate ' .
363
+				'Accessing the API class is deprecated! Use the appropriate '.
364 364
 				'services instead!'
365 365
 			);
366 366
 			return new API($c['AppName']);
367 367
 		});
368 368
 
369
-		$this->registerService('Protocol', function($c){
369
+		$this->registerService('Protocol', function($c) {
370 370
 			/** @var \OC\Server $server */
371 371
 			$server = $c->query('ServerContainer');
372 372
 			$protocol = $server->getRequest()->getHttpProtocol();
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 			);
433 433
 		});
434 434
 
435
-		$this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) {
435
+		$this->registerService('TwoFactorMiddleware', function(SimpleContainer $c) use ($app) {
436 436
 			$twoFactorManager = $c->getServer()->getTwoFactorAuthManager();
437 437
 			$userSession = $app->getServer()->getUserSession();
438 438
 			$session = $app->getServer()->getSession();
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 			return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request);
443 443
 		});
444 444
 
445
-		$this->registerService('OCSMiddleware', function (SimpleContainer $c) {
445
+		$this->registerService('OCSMiddleware', function(SimpleContainer $c) {
446 446
 			return new OCSMiddleware(
447 447
 				$c['Request']
448 448
 			);
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 			$dispatcher->registerMiddleware($c['SecurityMiddleware']);
457 457
 			$dispatcher->registerMiddleWare($c['TwoFactorMiddleware']);
458 458
 
459
-			foreach($middleWares as $middleWare) {
459
+			foreach ($middleWares as $middleWare) {
460 460
 				$dispatcher->registerMiddleware($c[$middleWare]);
461 461
 			}
462 462
 
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 	 * @return mixed
529 529
 	 */
530 530
 	function log($message, $level) {
531
-		switch($level){
531
+		switch ($level) {
532 532
 			case 'debug':
533 533
 				$level = \OCP\Util::DEBUG;
534 534
 				break;
Please login to merge, or discard this patch.
lib/private/Mail/Message.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,8 @@
 block discarded – undo
55 55
 
56 56
 		$convertedAddresses = array();
57 57
 
58
-		foreach($addresses as $email => $readableName) {
59
-			if(!is_numeric($email)) {
58
+		foreach ($addresses as $email => $readableName) {
59
+			if (!is_numeric($email)) {
60 60
 				list($name, $domain) = explode('@', $email, 2);
61 61
 				$domain = idn_to_ascii($domain);
62 62
 				$convertedAddresses[$name.'@'.$domain] = $readableName;
Please login to merge, or discard this patch.
lib/private/Mail/Mailer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		$mailer = $this->getInstance();
99 99
 
100 100
 		// Enable logger if debug mode is enabled
101
-		if($debugMode) {
101
+		if ($debugMode) {
102 102
 			$mailLogger = new \Swift_Plugins_Loggers_ArrayLogger();
103 103
 			$mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger));
104 104
 		}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		// Debugging logging
109 109
 		$logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject());
110 110
 		$this->logger->debug($logMessage, ['app' => 'core']);
111
-		if($debugMode && isset($mailLogger)) {
111
+		if ($debugMode && isset($mailLogger)) {
112 112
 			$this->logger->debug($mailLogger->dump(), ['app' => 'core']);
113 113
 		}
114 114
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 				break;
210 210
 		}
211 211
 
212
-		return \Swift_SendmailTransport::newInstance($binaryPath . ' -bs');
212
+		return \Swift_SendmailTransport::newInstance($binaryPath.' -bs');
213 213
 	}
214 214
 
215 215
 	/**
Please login to merge, or discard this patch.
lib/private/CapabilitiesManager.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function getCapabilities() {
48 48
 		$capabilities = [];
49
-		foreach($this->capabilities as $capability) {
49
+		foreach ($this->capabilities as $capability) {
50 50
 			try {
51 51
 				$c = $capability();
52 52
 			} catch (QueryException $e) {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 			if ($c instanceof ICapability) {
58 58
 				$capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
59 59
 			} else {
60
-				throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
60
+				throw new \InvalidArgumentException('The given Capability ('.get_class($c).') does not implement the ICapability interface');
61 61
 			}
62 62
 		}
63 63
 
Please login to merge, or discard this patch.