Completed
Pull Request — master (#3643)
by Christoph
12:28
created
lib/private/AppFramework/Core/API.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * class and add your methods
39 39
  * @deprecated
40 40
  */
41
-class API implements IApi{
41
+class API implements IApi {
42 42
 
43 43
 	private $appName;
44 44
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * constructor
47 47
 	 * @param string $appName the name of your application
48 48
 	 */
49
-	public function __construct($appName){
49
+	public function __construct($appName) {
50 50
 		$this->appName = $appName;
51 51
 	}
52 52
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @return string the user id of the current user
57 57
 	 * @deprecated Use \OC::$server->getUserSession()->getUser()->getUID()
58 58
 	 */
59
-	public function getUserId(){
59
+	public function getUserId() {
60 60
 		return \OCP\User::getUser();
61 61
 	}
62 62
 
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	 * @param string $scriptName the name of the javascript in js/ without the suffix
68 68
 	 * @param string $appName the name of the app, defaults to the current one
69 69
 	 */
70
-	public function addScript($scriptName, $appName=null){
71
-		if($appName === null){
70
+	public function addScript($scriptName, $appName = null) {
71
+		if ($appName === null) {
72 72
 			$appName = $this->appName;
73 73
 		}
74 74
 		\OCP\Util::addScript($appName, $scriptName);
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 	 * @param string $styleName the name of the css file in css/without the suffix
82 82
 	 * @param string $appName the name of the app, defaults to the current one
83 83
 	 */
84
-	public function addStyle($styleName, $appName=null){
85
-		if($appName === null){
84
+	public function addStyle($styleName, $appName = null) {
85
+		if ($appName === null) {
86 86
 			$appName = $this->appName;
87 87
 		}
88 88
 		\OCP\Util::addStyle($appName, $styleName);
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 	 * shorthand for addScript for files in the 3rdparty directory
95 95
 	 * @param string $name the name of the file without the suffix
96 96
 	 */
97
-	public function add3rdPartyScript($name){
98
-		\OCP\Util::addScript($this->appName . '/3rdparty', $name);
97
+	public function add3rdPartyScript($name) {
98
+		\OCP\Util::addScript($this->appName.'/3rdparty', $name);
99 99
 	}
100 100
 
101 101
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * shorthand for addStyle for files in the 3rdparty directory
105 105
 	 * @param string $name the name of the file without the suffix
106 106
 	 */
107
-	public function add3rdPartyStyle($name){
108
-		\OCP\Util::addStyle($this->appName . '/3rdparty', $name);
107
+	public function add3rdPartyStyle($name) {
108
+		\OCP\Util::addStyle($this->appName.'/3rdparty', $name);
109 109
 	}
110 110
 
111 111
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param string $appName the name of an app
118 118
 	 * @return bool true if app is enabled
119 119
 	 */
120
-	public function isAppEnabled($appName){
120
+	public function isAppEnabled($appName) {
121 121
 		return \OCP\App::isEnabled($appName);
122 122
 	}
123 123
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @return \OCP\IEventSource a new open EventSource class
128 128
 	 * @deprecated Use \OC::$server->createEventSource();
129 129
 	 */
130
-	public function openEventSource(){
130
+	public function openEventSource() {
131 131
 		return \OC::$server->createEventSource();
132 132
 	}
133 133
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * @param string $signalClass
165 165
 	 * @param string $signalName
166 166
 	 */
167
-	public function clearHook($signalClass=false, $signalName=false) {
167
+	public function clearHook($signalClass = false, $signalName = false) {
168 168
 		if ($signalClass) {
169 169
 			\OC_Hook::clear($signalClass, $signalName);
170 170
 		}
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 	 * suffix, relative to your apps directory! not the template directory
177 177
 	 * @param string $appName the name of the app, defaults to the current one
178 178
 	 */
179
-	public function registerAdmin($mainPath, $appName=null) {
180
-		if($appName === null){
179
+	public function registerAdmin($mainPath, $appName = null) {
180
+		if ($appName === null) {
181 181
 			$appName = $this->appName;
182 182
 		}
183 183
 
Please login to merge, or discard this patch.
lib/private/AppFramework/Http/Output.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@
 block discarded – undo
92 92
 	 * @param bool $httpOnly
93 93
 	 */
94 94
 	public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly) {
95
-		$path = $this->webRoot ? : '/';
95
+		$path = $this->webRoot ?: '/';
96 96
 		setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly);
97 97
 	}
98 98
 
Please login to merge, or discard this patch.
lib/private/AppFramework/Http/Dispatcher.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 			// exception and creates a response. If no response is created, it is
94 94
 			// assumed that theres no middleware who can handle it and the error is
95 95
 			// thrown again
96
-		} catch(\Exception $exception){
96
+		} catch (\Exception $exception) {
97 97
 			$response = $this->middlewareDispatcher->afterException(
98 98
 				$controller, $methodName, $exception);
99 99
 			if (is_null($response)) {
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		// valid types that will be casted
132 132
 		$types = array('int', 'integer', 'bool', 'boolean', 'float');
133 133
 
134
-		foreach($this->reflector->getParameters() as $param => $default) {
134
+		foreach ($this->reflector->getParameters() as $param => $default) {
135 135
 
136 136
 			// try to get the parameter from the request object and cast
137 137
 			// it to the type annotated in the @param annotation
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
 			// if this is submitted using GET or a POST form, 'false' should be
142 142
 			// converted to false
143
-			if(($type === 'bool' || $type === 'boolean') &&
143
+			if (($type === 'bool' || $type === 'boolean') &&
144 144
 				$value === 'false' &&
145 145
 				(
146 146
 					$this->request->method === 'GET' ||
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 			) {
151 151
 				$value = false;
152 152
 
153
-			} elseif($value !== null && in_array($type, $types)) {
153
+			} elseif ($value !== null && in_array($type, $types)) {
154 154
 				settype($value, $type);
155 155
 			}
156 156
 
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
 		$response = call_user_func_array(array($controller, $methodName), $arguments);
161 161
 
162 162
 		// format response
163
-		if($response instanceof DataResponse || !($response instanceof Response)) {
163
+		if ($response instanceof DataResponse || !($response instanceof Response)) {
164 164
 
165 165
 			// get format from the url format or request format parameter
166 166
 			$format = $this->request->getParam('format');
167 167
 
168 168
 			// if none is given try the first Accept header
169
-			if($format === null) {
169
+			if ($format === null) {
170 170
 				$headers = $this->request->getHeader('Accept');
171 171
 				$format = $controller->getResponderByHTTPHeader($headers, null);
172 172
 			}
Please login to merge, or discard this patch.
lib/private/AppFramework/Http/Request.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param string $stream
129 129
 	 * @see http://www.php.net/manual/en/reserved.variables.php
130 130
 	 */
131
-	public function __construct(array $vars=array(),
131
+	public function __construct(array $vars = array(),
132 132
 								ISecureRandom $secureRandom = null,
133 133
 								IConfig $config,
134 134
 								CsrfTokenManager $csrfTokenManager = null,
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 		$this->config = $config;
140 140
 		$this->csrfTokenManager = $csrfTokenManager;
141 141
 
142
-		if(!array_key_exists('method', $vars)) {
142
+		if (!array_key_exists('method', $vars)) {
143 143
 			$vars['method'] = 'GET';
144 144
 		}
145 145
 
146
-		foreach($this->allowedKeys as $name) {
146
+		foreach ($this->allowedKeys as $name) {
147 147
 			$this->items[$name] = isset($vars[$name])
148 148
 				? $vars[$name]
149 149
 				: array();
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
 	* @return mixed|null
249 249
 	*/
250 250
 	public function __get($name) {
251
-		switch($name) {
251
+		switch ($name) {
252 252
 			case 'put':
253 253
 			case 'patch':
254 254
 			case 'get':
255 255
 			case 'post':
256
-				if($this->method !== strtoupper($name)) {
256
+				if ($this->method !== strtoupper($name)) {
257 257
 					throw new \LogicException(sprintf('%s cannot be accessed in a %s request.', $name, $this->method));
258 258
 				}
259 259
 				return $this->getContent();
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
 	 */
305 305
 	public function getHeader($name) {
306 306
 
307
-		$name = strtoupper(str_replace(array('-'),array('_'),$name));
308
-		if (isset($this->server['HTTP_' . $name])) {
309
-			return $this->server['HTTP_' . $name];
307
+		$name = strtoupper(str_replace(array('-'), array('_'), $name));
308
+		if (isset($this->server['HTTP_'.$name])) {
309
+			return $this->server['HTTP_'.$name];
310 310
 		}
311 311
 
312 312
 		// There's a few headers that seem to end up in the top-level
313 313
 		// server array.
314
-		switch($name) {
314
+		switch ($name) {
315 315
 			case 'CONTENT_TYPE' :
316 316
 			case 'CONTENT_LENGTH' :
317 317
 				if (isset($this->server[$name])) {
@@ -430,21 +430,21 @@  discard block
 block discarded – undo
430 430
 		// 'application/json' must be decoded manually.
431 431
 		if (strpos($this->getHeader('Content-Type'), 'application/json') !== false) {
432 432
 			$params = json_decode(file_get_contents($this->inputStream), true);
433
-			if(count($params) > 0) {
433
+			if (count($params) > 0) {
434 434
 				$this->items['params'] = $params;
435
-				if($this->method === 'POST') {
435
+				if ($this->method === 'POST') {
436 436
 					$this->items['post'] = $params;
437 437
 				}
438 438
 			}
439 439
 
440 440
 		// Handle application/x-www-form-urlencoded for methods other than GET
441 441
 		// or post correctly
442
-		} elseif($this->method !== 'GET'
442
+		} elseif ($this->method !== 'GET'
443 443
 				&& $this->method !== 'POST'
444 444
 				&& strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') !== false) {
445 445
 
446 446
 			parse_str(file_get_contents($this->inputStream), $params);
447
-			if(is_array($params)) {
447
+			if (is_array($params)) {
448 448
 				$this->items['params'] = $params;
449 449
 			}
450 450
 		}
@@ -461,11 +461,11 @@  discard block
 block discarded – undo
461 461
 	 * @return bool true if CSRF check passed
462 462
 	 */
463 463
 	public function passesCSRFCheck() {
464
-		if($this->csrfTokenManager === null) {
464
+		if ($this->csrfTokenManager === null) {
465 465
 			return false;
466 466
 		}
467 467
 
468
-		if(!$this->passesStrictCookieCheck()) {
468
+		if (!$this->passesStrictCookieCheck()) {
469 469
 			return false;
470 470
 		}
471 471
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 	 * @return bool
491 491
 	 */
492 492
 	private function cookieCheckRequired() {
493
-		if($this->getCookie(session_name()) === null && $this->getCookie('nc_token') === null) {
493
+		if ($this->getCookie(session_name()) === null && $this->getCookie('nc_token') === null) {
494 494
 			return false;
495 495
 		}
496 496
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	protected function getProtectedCookieName($name) {
516 516
 		$cookieParams = $this->getCookieParams();
517 517
 		$prefix = '';
518
-		if($cookieParams['secure'] === true && $cookieParams['path'] === '/') {
518
+		if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') {
519 519
 			$prefix = '__Host-';
520 520
 		}
521 521
 
@@ -530,12 +530,12 @@  discard block
 block discarded – undo
530 530
 	 * @since 9.1.0
531 531
 	 */
532 532
 	public function passesStrictCookieCheck() {
533
-		if(!$this->cookieCheckRequired()) {
533
+		if (!$this->cookieCheckRequired()) {
534 534
 			return true;
535 535
 		}
536 536
 
537 537
 		$cookieName = $this->getProtectedCookieName('nc_sameSiteCookiestrict');
538
-		if($this->getCookie($cookieName) === 'true'
538
+		if ($this->getCookie($cookieName) === 'true'
539 539
 			&& $this->passesLaxCookieCheck()) {
540 540
 			return true;
541 541
 		}
@@ -550,12 +550,12 @@  discard block
 block discarded – undo
550 550
 	 * @since 9.1.0
551 551
 	 */
552 552
 	public function passesLaxCookieCheck() {
553
-		if(!$this->cookieCheckRequired()) {
553
+		if (!$this->cookieCheckRequired()) {
554 554
 			return true;
555 555
 		}
556 556
 
557 557
 		$cookieName = $this->getProtectedCookieName('nc_sameSiteCookielax');
558
-		if($this->getCookie($cookieName) === 'true') {
558
+		if ($this->getCookie($cookieName) === 'true') {
559 559
 			return true;
560 560
 		}
561 561
 		return false;
@@ -568,11 +568,11 @@  discard block
 block discarded – undo
568 568
 	 * @return string
569 569
 	 */
570 570
 	public function getId() {
571
-		if(isset($this->server['UNIQUE_ID'])) {
571
+		if (isset($this->server['UNIQUE_ID'])) {
572 572
 			return $this->server['UNIQUE_ID'];
573 573
 		}
574 574
 
575
-		if(empty($this->requestId)) {
575
+		if (empty($this->requestId)) {
576 576
 			$this->requestId = $this->secureRandom->generate(20);
577 577
 		}
578 578
 
@@ -590,15 +590,15 @@  discard block
 block discarded – undo
590 590
 		$remoteAddress = isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : '';
591 591
 		$trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
592 592
 
593
-		if(is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) {
593
+		if (is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) {
594 594
 			$forwardedForHeaders = $this->config->getSystemValue('forwarded_for_headers', [
595 595
 				'HTTP_X_FORWARDED_FOR'
596 596
 				// only have one default, so we cannot ship an insecure product out of the box
597 597
 			]);
598 598
 
599
-			foreach($forwardedForHeaders as $header) {
600
-				if(isset($this->server[$header])) {
601
-					foreach(explode(',', $this->server[$header]) as $IP) {
599
+			foreach ($forwardedForHeaders as $header) {
600
+				if (isset($this->server[$header])) {
601
+					foreach (explode(',', $this->server[$header]) as $IP) {
602 602
 						$IP = trim($IP);
603 603
 						if (filter_var($IP, FILTER_VALIDATE_IP) !== false) {
604 604
 							return $IP;
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
 	 * @return bool
618 618
 	 */
619 619
 	private function isOverwriteCondition($type = '') {
620
-		$regex = '/' . $this->config->getSystemValue('overwritecondaddr', '')  . '/';
620
+		$regex = '/'.$this->config->getSystemValue('overwritecondaddr', '').'/';
621 621
 		$remoteAddr = isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : '';
622 622
 		return $regex === '//' || preg_match($regex, $remoteAddr) === 1
623 623
 		|| $type !== 'protocol';
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 	 * @return string Server protocol (http or https)
630 630
 	 */
631 631
 	public function getServerProtocol() {
632
-		if($this->config->getSystemValue('overwriteprotocol') !== ''
632
+		if ($this->config->getSystemValue('overwriteprotocol') !== ''
633 633
 			&& $this->isOverwriteCondition('protocol')) {
634 634
 			return $this->config->getSystemValue('overwriteprotocol');
635 635
 		}
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 			'HTTP/2',
672 672
 		];
673 673
 
674
-		if(in_array($claimedProtocol, $validProtocols, true)) {
674
+		if (in_array($claimedProtocol, $validProtocols, true)) {
675 675
 			return $claimedProtocol;
676 676
 		}
677 677
 
@@ -685,8 +685,8 @@  discard block
 block discarded – undo
685 685
 	 */
686 686
 	public function getRequestUri() {
687 687
 		$uri = isset($this->server['REQUEST_URI']) ? $this->server['REQUEST_URI'] : '';
688
-		if($this->config->getSystemValue('overwritewebroot') !== '' && $this->isOverwriteCondition()) {
689
-			$uri = $this->getScriptName() . substr($uri, strlen($this->server['SCRIPT_NAME']));
688
+		if ($this->config->getSystemValue('overwritewebroot') !== '' && $this->isOverwriteCondition()) {
689
+			$uri = $this->getScriptName().substr($uri, strlen($this->server['SCRIPT_NAME']));
690 690
 		}
691 691
 		return $uri;
692 692
 	}
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		$requestUri = isset($this->server['REQUEST_URI']) ? $this->server['REQUEST_URI'] : '';
701 701
 		// remove too many leading slashes - can be caused by reverse proxy configuration
702 702
 		if (strpos($requestUri, '/') === 0) {
703
-			$requestUri = '/' . ltrim($requestUri, '/');
703
+			$requestUri = '/'.ltrim($requestUri, '/');
704 704
 		}
705 705
 
706 706
 		$requestUri = preg_replace('%/{2,}%', '/', $requestUri);
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 		// FIXME: Sabre does not really belong here
718 718
 		list($path, $name) = \Sabre\HTTP\URLUtil::splitPath($scriptName);
719 719
 		if (!empty($path)) {
720
-			if($path === $pathInfo || strpos($pathInfo, $path.'/') === 0) {
720
+			if ($path === $pathInfo || strpos($pathInfo, $path.'/') === 0) {
721 721
 				$pathInfo = substr($pathInfo, strlen($path));
722 722
 			} else {
723 723
 				throw new \Exception("The requested uri($requestUri) cannot be processed by the script '$scriptName')");
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 		if (strpos($pathInfo, $name) === 0) {
730 730
 			$pathInfo = substr($pathInfo, strlen($name));
731 731
 		}
732
-		if($pathInfo === false || $pathInfo === '/'){
732
+		if ($pathInfo === false || $pathInfo === '/') {
733 733
 			return '';
734 734
 		} else {
735 735
 			return $pathInfo;
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 		$pathInfo = rawurldecode($pathInfo);
748 748
 		$encoding = mb_detect_encoding($pathInfo, ['UTF-8', 'ISO-8859-1']);
749 749
 
750
-		switch($encoding) {
750
+		switch ($encoding) {
751 751
 			case 'ISO-8859-1' :
752 752
 				$pathInfo = utf8_encode($pathInfo);
753 753
 		}
@@ -763,12 +763,12 @@  discard block
 block discarded – undo
763 763
 	 */
764 764
 	public function getScriptName() {
765 765
 		$name = $this->server['SCRIPT_NAME'];
766
-		$overwriteWebRoot =  $this->config->getSystemValue('overwritewebroot');
766
+		$overwriteWebRoot = $this->config->getSystemValue('overwritewebroot');
767 767
 		if ($overwriteWebRoot !== '' && $this->isOverwriteCondition()) {
768 768
 			// FIXME: This code is untestable due to __DIR__, also that hardcoded path is really dangerous
769 769
 			$serverRoot = str_replace('\\', '/', substr(__DIR__, 0, -strlen('lib/private/appframework/http/')));
770 770
 			$suburi = str_replace('\\', '/', substr(realpath($this->server['SCRIPT_FILENAME']), strlen($serverRoot)));
771
-			$name = '/' . ltrim($overwriteWebRoot . $suburi, '/');
771
+			$name = '/'.ltrim($overwriteWebRoot.$suburi, '/');
772 772
 		}
773 773
 		return $name;
774 774
 	}
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 			return $host;
839 839
 		} else {
840 840
 			$trustedList = $this->config->getSystemValue('trusted_domains', []);
841
-			if(!empty($trustedList)) {
841
+			if (!empty($trustedList)) {
842 842
 				return $trustedList[0];
843 843
 			} else {
844 844
 				return '';
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 	 * isn't met
854 854
 	 */
855 855
 	private function getOverwriteHost() {
856
-		if($this->config->getSystemValue('overwritehost') !== '' && $this->isOverwriteCondition()) {
856
+		if ($this->config->getSystemValue('overwritehost') !== '' && $this->isOverwriteCondition()) {
857 857
 			return $this->config->getSystemValue('overwritehost');
858 858
 		}
859 859
 		return null;
Please login to merge, or discard this patch.
lib/private/AppFramework/App.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -53,20 +53,20 @@  discard block
 block discarded – undo
53 53
 	 * the transformed app id, defaults to OCA\
54 54
 	 * @return string the starting namespace for the app
55 55
 	 */
56
-	public static function buildAppNamespace($appId, $topNamespace='OCA\\') {
56
+	public static function buildAppNamespace($appId, $topNamespace = 'OCA\\') {
57 57
 		// Hit the cache!
58 58
 		if (isset(self::$nameSpaceCache[$appId])) {
59
-			return $topNamespace . self::$nameSpaceCache[$appId];
59
+			return $topNamespace.self::$nameSpaceCache[$appId];
60 60
 		}
61 61
 
62 62
 		$appInfo = \OC_App::getAppInfo($appId);
63 63
 		if (isset($appInfo['namespace'])) {
64
-			return $topNamespace . trim($appInfo['namespace']);
64
+			return $topNamespace.trim($appInfo['namespace']);
65 65
 		}
66 66
 
67 67
 		// if the tag is not found, fall back to uppercasing the first letter
68 68
 		self::$nameSpaceCache[$appId] = ucfirst($appId);
69
-		return $topNamespace . self::$nameSpaceCache[$appId];
69
+		return $topNamespace.self::$nameSpaceCache[$appId];
70 70
 	}
71 71
 
72 72
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		// first try $controllerName then go for \OCA\AppName\Controller\$controllerName
90 90
 		try {
91 91
 			$controller = $container->query($controllerName);
92
-		} catch(QueryException $e) {
92
+		} catch (QueryException $e) {
93 93
 			if ($appName === 'core') {
94 94
 				$appNameSpace = 'OC\\Core';
95 95
 			} else if ($appName === 'settings') {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			} else {
98 98
 				$appNameSpace = self::buildAppNamespace($appName);
99 99
 			}
100
-			$controllerName = $appNameSpace . '\\Controller\\' . $controllerName;
100
+			$controllerName = $appNameSpace.'\\Controller\\'.$controllerName;
101 101
 			$controller = $container->query($controllerName);
102 102
 		}
103 103
 
@@ -115,17 +115,17 @@  discard block
 block discarded – undo
115 115
 
116 116
 		$io = $container['OCP\\AppFramework\\Http\\IOutput'];
117 117
 
118
-		if(!is_null($httpHeaders)) {
118
+		if (!is_null($httpHeaders)) {
119 119
 			$io->setHeader($httpHeaders);
120 120
 		}
121 121
 
122
-		foreach($responseHeaders as $name => $value) {
123
-			$io->setHeader($name . ': ' . $value);
122
+		foreach ($responseHeaders as $name => $value) {
123
+			$io->setHeader($name.': '.$value);
124 124
 		}
125 125
 
126
-		foreach($responseCookies as $name => $value) {
126
+		foreach ($responseCookies as $name => $value) {
127 127
 			$expireDate = null;
128
-			if($value['expireDate'] instanceof \DateTime) {
128
+			if ($value['expireDate'] instanceof \DateTime) {
129 129
 				$expireDate = $value['expireDate']->getTimestamp();
130 130
 			}
131 131
 			$io->setCookie(
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 			if ($response instanceof ICallbackResponse) {
150 150
 				$response->callback($io);
151 151
 			} else if (!is_null($output)) {
152
-				$io->setHeader('Content-Length: ' . strlen($output));
152
+				$io->setHeader('Content-Length: '.strlen($output));
153 153
 				$io->setOutput($output);
154 154
 			}
155 155
 		}
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
 	 * @param DIContainer $container an instance of a pimple container.
170 170
 	 */
171 171
 	public static function part($controllerName, $methodName, array $urlParams,
172
-								DIContainer $container){
172
+								DIContainer $container) {
173 173
 
174 174
 		$container['urlParams'] = $urlParams;
175 175
 		$controller = $container[$controllerName];
176 176
 
177 177
 		$dispatcher = $container['Dispatcher'];
178 178
 
179
-		list(, , $output) =  $dispatcher->dispatch($controller, $methodName);
179
+		list(,, $output) = $dispatcher->dispatch($controller, $methodName);
180 180
 		return $output;
181 181
 	}
182 182
 
Please login to merge, or discard this patch.
lib/private/AppFramework/Http.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @param array $server $_SERVER
42 42
 	 * @param string $protocolVersion the http version to use defaults to HTTP/1.1
43 43
 	 */
44
-	public function __construct($server, $protocolVersion='HTTP/1.1') {
44
+	public function __construct($server, $protocolVersion = 'HTTP/1.1') {
45 45
 		$this->server = $server;
46 46
 		$this->protocolVersion = $protocolVersion;
47 47
 
@@ -116,16 +116,16 @@  discard block
 block discarded – undo
116 116
 	 * @param string $ETag the etag
117 117
 	 * @return string
118 118
 	 */
119
-	public function getStatusHeader($status, \DateTime $lastModified=null, 
120
-	                                $ETag=null) {
119
+	public function getStatusHeader($status, \DateTime $lastModified = null, 
120
+	                                $ETag = null) {
121 121
 
122
-		if(!is_null($lastModified)) {
122
+		if (!is_null($lastModified)) {
123 123
 			$lastModified = $lastModified->format(\DateTime::RFC2822);
124 124
 		}
125 125
 
126 126
 		// if etag or lastmodified have not changed, return a not modified
127 127
 		if ((isset($this->server['HTTP_IF_NONE_MATCH'])
128
-			&& trim(trim($this->server['HTTP_IF_NONE_MATCH']), '"') === (string)$ETag)
128
+			&& trim(trim($this->server['HTTP_IF_NONE_MATCH']), '"') === (string) $ETag)
129 129
 
130 130
 			||
131 131
 
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
 		// we have one change currently for the http 1.0 header that differs
140 140
 		// from 1.1: STATUS_TEMPORARY_REDIRECT should be STATUS_FOUND
141 141
 		// if this differs any more, we want to create childclasses for this
142
-		if($status === self::STATUS_TEMPORARY_REDIRECT 
142
+		if ($status === self::STATUS_TEMPORARY_REDIRECT 
143 143
 			&& $this->protocolVersion === 'HTTP/1.0') {
144 144
 
145 145
 			$status = self::STATUS_FOUND;
146 146
 		}
147 147
 
148
-		return $this->protocolVersion . ' ' . $status . ' ' . 
148
+		return $this->protocolVersion.' '.$status.' '. 
149 149
 			$this->headers[$status];
150 150
 	}
151 151
 
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/Security/CORSMiddleware.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	 * @throws SecurityException
81 81
 	 * @since 6.0.0
82 82
 	 */
83
-	public function beforeController($controller, $methodName){
83
+	public function beforeController($controller, $methodName) {
84 84
 		// ensure that @CORS annotated API routes are not used in conjunction
85 85
 		// with session authentication since this enables CSRF attack vectors
86 86
 		if ($this->reflector->hasAnnotation('CORS') &&
87
-			!$this->reflector->hasAnnotation('PublicPage'))  {
87
+			!$this->reflector->hasAnnotation('PublicPage')) {
88 88
 			$user = $this->request->server['PHP_AUTH_USER'];
89 89
 			$pass = $this->request->server['PHP_AUTH_PW'];
90 90
 
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
 	 * @return Response a Response object
111 111
 	 * @throws SecurityException
112 112
 	 */
113
-	public function afterController($controller, $methodName, Response $response){
113
+	public function afterController($controller, $methodName, Response $response) {
114 114
 		// only react if its a CORS request and if the request sends origin and
115 115
 
116
-		if(isset($this->request->server['HTTP_ORIGIN']) &&
116
+		if (isset($this->request->server['HTTP_ORIGIN']) &&
117 117
 			$this->reflector->hasAnnotation('CORS')) {
118 118
 
119 119
 			// allow credentials headers must not be true or CSRF is possible
120 120
 			// otherwise
121
-			foreach($response->getHeaders() as $header => $value) {
122
-				if(strtolower($header) === 'access-control-allow-credentials' &&
121
+			foreach ($response->getHeaders() as $header => $value) {
122
+				if (strtolower($header) === 'access-control-allow-credentials' &&
123 123
 				   strtolower(trim($value)) === 'true') {
124 124
 					$msg = 'Access-Control-Allow-Credentials must not be '.
125 125
 						   'set to true in order to prevent CSRF';
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 	 * @throws \Exception the passed in exception if it can't handle it
144 144
 	 * @return Response a Response object or null in case that the exception could not be handled
145 145
 	 */
146
-	public function afterException($controller, $methodName, \Exception $exception){
147
-		if($exception instanceof SecurityException){
148
-			$response =  new JSONResponse(['message' => $exception->getMessage()]);
149
-			if($exception->getCode() !== 0) {
146
+	public function afterException($controller, $methodName, \Exception $exception) {
147
+		if ($exception instanceof SecurityException) {
148
+			$response = new JSONResponse(['message' => $exception->getMessage()]);
149
+			if ($exception->getCode() !== 0) {
150 150
 				$response->setStatus($exception->getCode());
151 151
 			} else {
152 152
 				$response->setStatus(Http::STATUS_INTERNAL_SERVER_ERROR);
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
 
152 152
 		// security checks
153 153
 		$isPublicPage = $this->reflector->hasAnnotation('PublicPage');
154
-		if(!$isPublicPage) {
155
-			if(!$this->isLoggedIn) {
154
+		if (!$isPublicPage) {
155
+			if (!$this->isLoggedIn) {
156 156
 				throw new NotLoggedInException();
157 157
 			}
158 158
 
159
-			if(!$this->reflector->hasAnnotation('NoAdminRequired')) {
160
-				if(!$this->isAdminUser) {
159
+			if (!$this->reflector->hasAnnotation('NoAdminRequired')) {
160
+				if (!$this->isAdminUser) {
161 161
 					throw new NotAdminException();
162 162
 				}
163 163
 			}
@@ -171,27 +171,27 @@  discard block
 block discarded – undo
171 171
 		}
172 172
 
173 173
 		// Check for strict cookie requirement
174
-		if($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) {
175
-			if(!$this->request->passesStrictCookieCheck()) {
174
+		if ($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) {
175
+			if (!$this->request->passesStrictCookieCheck()) {
176 176
 				throw new StrictCookieMissingException();
177 177
 			}
178 178
 		}
179 179
 		// CSRF check - also registers the CSRF token since the session may be closed later
180 180
 		Util::callRegister();
181
-		if(!$this->reflector->hasAnnotation('NoCSRFRequired')) {
181
+		if (!$this->reflector->hasAnnotation('NoCSRFRequired')) {
182 182
 			/*
183 183
 			 * Only allow the CSRF check to fail on OCS Requests. This kind of
184 184
 			 * hacks around that we have no full token auth in place yet and we
185 185
 			 * do want to offer CSRF checks for web requests.
186 186
 			 */
187
-			if(!$this->request->passesCSRFCheck() && !(
187
+			if (!$this->request->passesCSRFCheck() && !(
188 188
 					$controller instanceof OCSController &&
189 189
 					$this->request->getHeader('OCS-APIREQUEST') === 'true')) {
190 190
 				throw new CrossSiteRequestForgeryException();
191 191
 			}
192 192
 		}
193 193
 
194
-		if($this->reflector->hasAnnotation('BruteForceProtection')) {
194
+		if ($this->reflector->hasAnnotation('BruteForceProtection')) {
195 195
 			$action = $this->reflector->getAnnotationParameter('BruteForceProtection');
196 196
 			$this->throttler->sleepDelay($this->request->getRemoteAddress(), $action);
197 197
 			$this->throttler->registerAttempt($action, $this->request->getRemoteAddress());
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		 * The getAppPath() check is here since components such as settings also use the AppFramework and
204 204
 		 * therefore won't pass this check.
205 205
 		 */
206
-		if(\OC_App::getAppPath($this->appName) !== false && !\OC_App::isEnabled($this->appName)) {
206
+		if (\OC_App::getAppPath($this->appName) !== false && !\OC_App::isEnabled($this->appName)) {
207 207
 			throw new AppNotEnabledException();
208 208
 		}
209 209
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 		$defaultPolicy = $this->contentSecurityPolicyManager->getDefaultPolicy();
229 229
 		$defaultPolicy = $this->contentSecurityPolicyManager->mergePolicies($defaultPolicy, $policy);
230 230
 
231
-		if($this->cspNonceManager->browserSupportsCspV3()) {
231
+		if ($this->cspNonceManager->browserSupportsCspV3()) {
232 232
 			$defaultPolicy->useJsNonce($this->csrfTokenManager->getToken()->getEncryptedValue());
233 233
 		}
234 234
 
@@ -248,17 +248,17 @@  discard block
 block discarded – undo
248 248
 	 * @return Response a Response object or null in case that the exception could not be handled
249 249
 	 */
250 250
 	public function afterException($controller, $methodName, \Exception $exception) {
251
-		if($exception instanceof SecurityException) {
252
-			if($exception instanceof StrictCookieMissingException) {
251
+		if ($exception instanceof SecurityException) {
252
+			if ($exception instanceof StrictCookieMissingException) {
253 253
 				return new RedirectResponse(\OC::$WEBROOT);
254 254
  			}
255
-			if (stripos($this->request->getHeader('Accept'),'html') === false) {
255
+			if (stripos($this->request->getHeader('Accept'), 'html') === false) {
256 256
 				$response = new JSONResponse(
257 257
 					array('message' => $exception->getMessage()),
258 258
 					$exception->getCode()
259 259
 				);
260 260
 			} else {
261
-				if($exception instanceof NotLoggedInException) {
261
+				if ($exception instanceof NotLoggedInException) {
262 262
 					$url = $this->urlGenerator->linkToRoute(
263 263
 						'core.login.showLoginForm',
264 264
 						[
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/OCSMiddleware.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
 		$format = $this->request->getParam('format');
144 144
 
145 145
 		// if none is given try the first Accept header
146
-		if($format === null) {
146
+		if ($format === null) {
147 147
 			$headers = $this->request->getHeader('Accept');
148 148
 			$format = $controller->getResponderByHTTPHeader($headers, 'xml');
149 149
 		}
Please login to merge, or discard this patch.