Passed
Push — master ( 07b9db...e81cb6 )
by Julius
14:23 queued 13s
created
lib/public/AppFramework/Controller.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		// default responders
80 80
 		$this->responders = [
81
-			'json' => function ($data) {
81
+			'json' => function($data) {
82 82
 				if ($data instanceof DataResponse) {
83 83
 					$response = new JSONResponse(
84 84
 						$data->getData(),
@@ -153,6 +153,6 @@  discard block
 block discarded – undo
153 153
 			return $responder($response);
154 154
 		}
155 155
 		throw new \DomainException('No responder registered for format '.
156
-			$format . '!');
156
+			$format.'!');
157 157
 	}
158 158
 }
Please login to merge, or discard this patch.
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -38,122 +38,122 @@
 block discarded – undo
38 38
  * @since 6.0.0
39 39
  */
40 40
 abstract class Controller {
41
-	/**
42
-	 * app name
43
-	 * @var string
44
-	 * @since 7.0.0
45
-	 */
46
-	protected $appName;
47
-
48
-	/**
49
-	 * current request
50
-	 * @var \OCP\IRequest
51
-	 * @since 6.0.0
52
-	 */
53
-	protected $request;
54
-
55
-	/**
56
-	 * @var array
57
-	 * @since 7.0.0
58
-	 */
59
-	private $responders;
60
-
61
-	/**
62
-	 * constructor of the controller
63
-	 * @param string $appName the name of the app
64
-	 * @param IRequest $request an instance of the request
65
-	 * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
66
-	 */
67
-	public function __construct($appName,
68
-								IRequest $request) {
69
-		$this->appName = $appName;
70
-		$this->request = $request;
71
-
72
-		// default responders
73
-		$this->responders = [
74
-			'json' => function ($data) {
75
-				if ($data instanceof DataResponse) {
76
-					$response = new JSONResponse(
77
-						$data->getData(),
78
-						$data->getStatus()
79
-					);
80
-					$dataHeaders = $data->getHeaders();
81
-					$headers = $response->getHeaders();
82
-					// do not overwrite Content-Type if it already exists
83
-					if (isset($dataHeaders['Content-Type'])) {
84
-						unset($headers['Content-Type']);
85
-					}
86
-					$response->setHeaders(array_merge($dataHeaders, $headers));
87
-
88
-					if ($data->getETag() !== null) {
89
-						$response->setETag($data->getETag());
90
-					}
91
-					if ($data->getLastModified() !== null) {
92
-						$response->setLastModified($data->getLastModified());
93
-					}
94
-
95
-					return $response;
96
-				}
97
-				return new JSONResponse($data);
98
-			}
99
-		];
100
-	}
101
-
102
-
103
-	/**
104
-	 * Parses an HTTP accept header and returns the supported responder type
105
-	 * @param string $acceptHeader
106
-	 * @param string $default
107
-	 * @return string the responder type
108
-	 * @since 7.0.0
109
-	 * @since 9.1.0 Added default parameter
110
-	 */
111
-	public function getResponderByHTTPHeader($acceptHeader, $default = 'json') {
112
-		$headers = explode(',', $acceptHeader);
113
-
114
-		// return the first matching responder
115
-		foreach ($headers as $header) {
116
-			$header = strtolower(trim($header));
117
-
118
-			$responder = str_replace('application/', '', $header);
119
-
120
-			if (array_key_exists($responder, $this->responders)) {
121
-				return $responder;
122
-			}
123
-		}
124
-
125
-		// no matching header return default
126
-		return $default;
127
-	}
128
-
129
-
130
-	/**
131
-	 * Registers a formatter for a type
132
-	 * @param string $format
133
-	 * @param \Closure $responder
134
-	 * @since 7.0.0
135
-	 */
136
-	protected function registerResponder($format, \Closure $responder) {
137
-		$this->responders[$format] = $responder;
138
-	}
139
-
140
-
141
-	/**
142
-	 * Serializes and formats a response
143
-	 * @param mixed $response the value that was returned from a controller and
144
-	 * is not a Response instance
145
-	 * @param string $format the format for which a formatter has been registered
146
-	 * @throws \DomainException if format does not match a registered formatter
147
-	 * @return Response
148
-	 * @since 7.0.0
149
-	 */
150
-	public function buildResponse($response, $format = 'json') {
151
-		if (array_key_exists($format, $this->responders)) {
152
-			$responder = $this->responders[$format];
153
-
154
-			return $responder($response);
155
-		}
156
-		throw new \DomainException('No responder registered for format '.
157
-			$format . '!');
158
-	}
41
+    /**
42
+     * app name
43
+     * @var string
44
+     * @since 7.0.0
45
+     */
46
+    protected $appName;
47
+
48
+    /**
49
+     * current request
50
+     * @var \OCP\IRequest
51
+     * @since 6.0.0
52
+     */
53
+    protected $request;
54
+
55
+    /**
56
+     * @var array
57
+     * @since 7.0.0
58
+     */
59
+    private $responders;
60
+
61
+    /**
62
+     * constructor of the controller
63
+     * @param string $appName the name of the app
64
+     * @param IRequest $request an instance of the request
65
+     * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
66
+     */
67
+    public function __construct($appName,
68
+                                IRequest $request) {
69
+        $this->appName = $appName;
70
+        $this->request = $request;
71
+
72
+        // default responders
73
+        $this->responders = [
74
+            'json' => function ($data) {
75
+                if ($data instanceof DataResponse) {
76
+                    $response = new JSONResponse(
77
+                        $data->getData(),
78
+                        $data->getStatus()
79
+                    );
80
+                    $dataHeaders = $data->getHeaders();
81
+                    $headers = $response->getHeaders();
82
+                    // do not overwrite Content-Type if it already exists
83
+                    if (isset($dataHeaders['Content-Type'])) {
84
+                        unset($headers['Content-Type']);
85
+                    }
86
+                    $response->setHeaders(array_merge($dataHeaders, $headers));
87
+
88
+                    if ($data->getETag() !== null) {
89
+                        $response->setETag($data->getETag());
90
+                    }
91
+                    if ($data->getLastModified() !== null) {
92
+                        $response->setLastModified($data->getLastModified());
93
+                    }
94
+
95
+                    return $response;
96
+                }
97
+                return new JSONResponse($data);
98
+            }
99
+        ];
100
+    }
101
+
102
+
103
+    /**
104
+     * Parses an HTTP accept header and returns the supported responder type
105
+     * @param string $acceptHeader
106
+     * @param string $default
107
+     * @return string the responder type
108
+     * @since 7.0.0
109
+     * @since 9.1.0 Added default parameter
110
+     */
111
+    public function getResponderByHTTPHeader($acceptHeader, $default = 'json') {
112
+        $headers = explode(',', $acceptHeader);
113
+
114
+        // return the first matching responder
115
+        foreach ($headers as $header) {
116
+            $header = strtolower(trim($header));
117
+
118
+            $responder = str_replace('application/', '', $header);
119
+
120
+            if (array_key_exists($responder, $this->responders)) {
121
+                return $responder;
122
+            }
123
+        }
124
+
125
+        // no matching header return default
126
+        return $default;
127
+    }
128
+
129
+
130
+    /**
131
+     * Registers a formatter for a type
132
+     * @param string $format
133
+     * @param \Closure $responder
134
+     * @since 7.0.0
135
+     */
136
+    protected function registerResponder($format, \Closure $responder) {
137
+        $this->responders[$format] = $responder;
138
+    }
139
+
140
+
141
+    /**
142
+     * Serializes and formats a response
143
+     * @param mixed $response the value that was returned from a controller and
144
+     * is not a Response instance
145
+     * @param string $format the format for which a formatter has been registered
146
+     * @throws \DomainException if format does not match a registered formatter
147
+     * @return Response
148
+     * @since 7.0.0
149
+     */
150
+    public function buildResponse($response, $format = 'json') {
151
+        if (array_key_exists($format, $this->responders)) {
152
+            $responder = $this->responders[$format];
153
+
154
+            return $responder($response);
155
+        }
156
+        throw new \DomainException('No responder registered for format '.
157
+            $format . '!');
158
+    }
159 159
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/OCS/OCSNotFoundException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @since 9.1.0
33 33
  */
34 34
 class OCSNotFoundException extends OCSException {
35
-	/**
36
-	 * OCSNotFoundException constructor.
37
-	 *
38
-	 * @param string $message
39
-	 * @param Exception|null $previous
40
-	 * @since 9.1.0
41
-	 */
42
-	public function __construct($message = '', Exception $previous = null) {
43
-		parent::__construct($message, Http::STATUS_NOT_FOUND, $previous);
44
-	}
35
+    /**
36
+     * OCSNotFoundException constructor.
37
+     *
38
+     * @param string $message
39
+     * @param Exception|null $previous
40
+     * @since 9.1.0
41
+     */
42
+    public function __construct($message = '', Exception $previous = null) {
43
+        parent::__construct($message, Http::STATUS_NOT_FOUND, $previous);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/OCS/OCSForbiddenException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @since 9.1.0
33 33
  */
34 34
 class OCSForbiddenException extends OCSException {
35
-	/**
36
-	 * OCSForbiddenException constructor.
37
-	 *
38
-	 * @param string $message
39
-	 * @param Exception|null $previous
40
-	 * @since 9.1.0
41
-	 */
42
-	public function __construct($message = '', Exception $previous = null) {
43
-		parent::__construct($message, Http::STATUS_FORBIDDEN, $previous);
44
-	}
35
+    /**
36
+     * OCSForbiddenException constructor.
37
+     *
38
+     * @param string $message
39
+     * @param Exception|null $previous
40
+     * @since 9.1.0
41
+     */
42
+    public function __construct($message = '', Exception $previous = null) {
43
+        parent::__construct($message, Http::STATUS_FORBIDDEN, $previous);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/OCS/OCSBadRequestException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @since 9.1.0
33 33
  */
34 34
 class OCSBadRequestException extends OCSException {
35
-	/**
36
-	 * OCSBadRequestException constructor.
37
-	 *
38
-	 * @param string $message
39
-	 * @param Exception|null $previous
40
-	 * @since 9.1.0
41
-	 */
42
-	public function __construct($message = '', Exception $previous = null) {
43
-		parent::__construct($message, Http::STATUS_BAD_REQUEST, $previous);
44
-	}
35
+    /**
36
+     * OCSBadRequestException constructor.
37
+     *
38
+     * @param string $message
39
+     * @param Exception|null $previous
40
+     * @since 9.1.0
41
+     */
42
+    public function __construct($message = '', Exception $previous = null) {
43
+        parent::__construct($message, Http::STATUS_BAD_REQUEST, $previous);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Http/FileDisplayResponse.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		$this->file = $file;
52 52
 		$this->setStatus($statusCode);
53 53
 		$this->setHeaders(array_merge($this->getHeaders(), $headers));
54
-		$this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"');
54
+		$this->addHeader('Content-Disposition', 'inline; filename="'.rawurldecode($file->getName()).'"');
55 55
 
56 56
 		$this->setETag($file->getEtag());
57 57
 		$lastModified = new \DateTime();
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function callback(IOutput $output) {
67 67
 		if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) {
68
-			$output->setHeader('Content-Length: ' . $this->file->getSize());
68
+			$output->setHeader('Content-Length: '.$this->file->getSize());
69 69
 			$output->setOutput($this->file->getContent());
70 70
 		}
71 71
 	}
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -31,40 +31,40 @@
 block discarded – undo
31 31
  * @since 11.0.0
32 32
  */
33 33
 class FileDisplayResponse extends Response implements ICallbackResponse {
34
-	/** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */
35
-	private $file;
34
+    /** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */
35
+    private $file;
36 36
 
37
-	/**
38
-	 * FileDisplayResponse constructor.
39
-	 *
40
-	 * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file
41
-	 * @param int $statusCode
42
-	 * @param array $headers
43
-	 * @since 11.0.0
44
-	 */
45
-	public function __construct($file, $statusCode = Http::STATUS_OK,
46
-								$headers = []) {
47
-		parent::__construct();
37
+    /**
38
+     * FileDisplayResponse constructor.
39
+     *
40
+     * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file
41
+     * @param int $statusCode
42
+     * @param array $headers
43
+     * @since 11.0.0
44
+     */
45
+    public function __construct($file, $statusCode = Http::STATUS_OK,
46
+                                $headers = []) {
47
+        parent::__construct();
48 48
 
49
-		$this->file = $file;
50
-		$this->setStatus($statusCode);
51
-		$this->setHeaders(array_merge($this->getHeaders(), $headers));
52
-		$this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"');
49
+        $this->file = $file;
50
+        $this->setStatus($statusCode);
51
+        $this->setHeaders(array_merge($this->getHeaders(), $headers));
52
+        $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"');
53 53
 
54
-		$this->setETag($file->getEtag());
55
-		$lastModified = new \DateTime();
56
-		$lastModified->setTimestamp($file->getMTime());
57
-		$this->setLastModified($lastModified);
58
-	}
54
+        $this->setETag($file->getEtag());
55
+        $lastModified = new \DateTime();
56
+        $lastModified->setTimestamp($file->getMTime());
57
+        $this->setLastModified($lastModified);
58
+    }
59 59
 
60
-	/**
61
-	 * @param IOutput $output
62
-	 * @since 11.0.0
63
-	 */
64
-	public function callback(IOutput $output) {
65
-		if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) {
66
-			$output->setHeader('Content-Length: ' . $this->file->getSize());
67
-			$output->setOutput($this->file->getContent());
68
-		}
69
-	}
60
+    /**
61
+     * @param IOutput $output
62
+     * @since 11.0.0
63
+     */
64
+    public function callback(IOutput $output) {
65
+        if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) {
66
+            $output->setHeader('Content-Length: ' . $this->file->getSize());
67
+            $output->setOutput($this->file->getContent());
68
+        }
69
+    }
70 70
 }
Please login to merge, or discard this patch.
lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,17 +35,17 @@
 block discarded – undo
35 35
 		}
36 36
 
37 37
 		$excludedFolders = [
38
-			rtrim($root . '/data', '/'),
39
-			rtrim($root . '/themes', '/'),
40
-			rtrim($root . '/config', '/'),
41
-			rtrim($root . '/apps', '/'),
42
-			rtrim($root . '/assets', '/'),
43
-			rtrim($root . '/lost+found', '/'),
38
+			rtrim($root.'/data', '/'),
39
+			rtrim($root.'/themes', '/'),
40
+			rtrim($root.'/config', '/'),
41
+			rtrim($root.'/apps', '/'),
42
+			rtrim($root.'/assets', '/'),
43
+			rtrim($root.'/lost+found', '/'),
44 44
 			// Ignore folders generated by updater since the updater is replaced
45 45
 			// after the integrity check is run.
46 46
 			// See https://github.com/owncloud/updater/issues/318#issuecomment-212497846
47
-			rtrim($root . '/updater', '/'),
48
-			rtrim($root . '/_oc_upgrade', '/'),
47
+			rtrim($root.'/updater', '/'),
48
+			rtrim($root.'/_oc_upgrade', '/'),
49 49
 		];
50 50
 		$customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', '');
51 51
 		if ($customDataDir !== '') {
Please login to merge, or discard this patch.
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -28,42 +28,42 @@
 block discarded – undo
28 28
 namespace OC\IntegrityCheck\Iterator;
29 29
 
30 30
 class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator {
31
-	private $excludedFolders;
31
+    private $excludedFolders;
32 32
 
33
-	public function __construct(\RecursiveIterator $iterator, $root = '') {
34
-		parent::__construct($iterator);
33
+    public function __construct(\RecursiveIterator $iterator, $root = '') {
34
+        parent::__construct($iterator);
35 35
 
36
-		$appFolders = \OC::$APPSROOTS;
37
-		foreach ($appFolders as $key => $appFolder) {
38
-			$appFolders[$key] = rtrim($appFolder['path'], '/');
39
-		}
36
+        $appFolders = \OC::$APPSROOTS;
37
+        foreach ($appFolders as $key => $appFolder) {
38
+            $appFolders[$key] = rtrim($appFolder['path'], '/');
39
+        }
40 40
 
41
-		$excludedFolders = [
42
-			rtrim($root . '/data', '/'),
43
-			rtrim($root . '/themes', '/'),
44
-			rtrim($root . '/config', '/'),
45
-			rtrim($root . '/apps', '/'),
46
-			rtrim($root . '/assets', '/'),
47
-			rtrim($root . '/lost+found', '/'),
48
-			// Ignore folders generated by updater since the updater is replaced
49
-			// after the integrity check is run.
50
-			// See https://github.com/owncloud/updater/issues/318#issuecomment-212497846
51
-			rtrim($root . '/updater', '/'),
52
-			rtrim($root . '/_oc_upgrade', '/'),
53
-		];
54
-		$customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', '');
55
-		if ($customDataDir !== '') {
56
-			$excludedFolders[] = rtrim($customDataDir, '/');
57
-		}
41
+        $excludedFolders = [
42
+            rtrim($root . '/data', '/'),
43
+            rtrim($root . '/themes', '/'),
44
+            rtrim($root . '/config', '/'),
45
+            rtrim($root . '/apps', '/'),
46
+            rtrim($root . '/assets', '/'),
47
+            rtrim($root . '/lost+found', '/'),
48
+            // Ignore folders generated by updater since the updater is replaced
49
+            // after the integrity check is run.
50
+            // See https://github.com/owncloud/updater/issues/318#issuecomment-212497846
51
+            rtrim($root . '/updater', '/'),
52
+            rtrim($root . '/_oc_upgrade', '/'),
53
+        ];
54
+        $customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', '');
55
+        if ($customDataDir !== '') {
56
+            $excludedFolders[] = rtrim($customDataDir, '/');
57
+        }
58 58
 
59
-		$this->excludedFolders = array_merge($excludedFolders, $appFolders);
60
-	}
59
+        $this->excludedFolders = array_merge($excludedFolders, $appFolders);
60
+    }
61 61
 
62
-	public function accept(): bool {
63
-		return !\in_array(
64
-			$this->current()->getPathName(),
65
-			$this->excludedFolders,
66
-			true
67
-		);
68
-	}
62
+    public function accept(): bool {
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/App/AppStore/Version/VersionParser.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
 	 * @return bool
33 33
 	 */
34 34
 	private function isValidVersionString($versionString) {
35
-		return (bool)preg_match('/^[0-9.]+$/', $versionString);
35
+		return (bool) preg_match('/^[0-9.]+$/', $versionString);
36 36
 	}
37 37
 
38 38
 	/**
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -30,56 +30,56 @@
 block discarded – undo
30 30
  * @package OC\App\AppStore
31 31
  */
32 32
 class VersionParser {
33
-	/**
34
-	 * @param string $versionString
35
-	 * @return bool
36
-	 */
37
-	private function isValidVersionString($versionString) {
38
-		return (bool)preg_match('/^[0-9.]+$/', $versionString);
39
-	}
33
+    /**
34
+     * @param string $versionString
35
+     * @return bool
36
+     */
37
+    private function isValidVersionString($versionString) {
38
+        return (bool)preg_match('/^[0-9.]+$/', $versionString);
39
+    }
40 40
 
41
-	/**
42
-	 * Returns the version for a version string
43
-	 *
44
-	 * @param string $versionSpec
45
-	 * @return Version
46
-	 * @throws \Exception If the version cannot be parsed
47
-	 */
48
-	public function getVersion($versionSpec) {
49
-		// * indicates that the version is compatible with all versions
50
-		if ($versionSpec === '*') {
51
-			return new Version('', '');
52
-		}
41
+    /**
42
+     * Returns the version for a version string
43
+     *
44
+     * @param string $versionSpec
45
+     * @return Version
46
+     * @throws \Exception If the version cannot be parsed
47
+     */
48
+    public function getVersion($versionSpec) {
49
+        // * indicates that the version is compatible with all versions
50
+        if ($versionSpec === '*') {
51
+            return new Version('', '');
52
+        }
53 53
 
54
-		// Count the amount of =, if it is one then it's either maximum or minimum
55
-		// version. If it is two then it is maximum and minimum.
56
-		$versionElements = explode(' ', $versionSpec);
57
-		$firstVersion = isset($versionElements[0]) ? $versionElements[0] : '';
58
-		$firstVersionNumber = substr($firstVersion, 2);
59
-		$secondVersion = isset($versionElements[1]) ? $versionElements[1] : '';
60
-		$secondVersionNumber = substr($secondVersion, 2);
54
+        // Count the amount of =, if it is one then it's either maximum or minimum
55
+        // version. If it is two then it is maximum and minimum.
56
+        $versionElements = explode(' ', $versionSpec);
57
+        $firstVersion = isset($versionElements[0]) ? $versionElements[0] : '';
58
+        $firstVersionNumber = substr($firstVersion, 2);
59
+        $secondVersion = isset($versionElements[1]) ? $versionElements[1] : '';
60
+        $secondVersionNumber = substr($secondVersion, 2);
61 61
 
62
-		switch (count($versionElements)) {
63
-			case 1:
64
-				if (!$this->isValidVersionString($firstVersionNumber)) {
65
-					break;
66
-				}
67
-				if (strpos($firstVersion, '>') === 0) {
68
-					return new Version($firstVersionNumber, '');
69
-				}
70
-				return new Version('', $firstVersionNumber);
71
-			case 2:
72
-				if (!$this->isValidVersionString($firstVersionNumber) || !$this->isValidVersionString($secondVersionNumber)) {
73
-					break;
74
-				}
75
-				return new Version($firstVersionNumber, $secondVersionNumber);
76
-		}
62
+        switch (count($versionElements)) {
63
+            case 1:
64
+                if (!$this->isValidVersionString($firstVersionNumber)) {
65
+                    break;
66
+                }
67
+                if (strpos($firstVersion, '>') === 0) {
68
+                    return new Version($firstVersionNumber, '');
69
+                }
70
+                return new Version('', $firstVersionNumber);
71
+            case 2:
72
+                if (!$this->isValidVersionString($firstVersionNumber) || !$this->isValidVersionString($secondVersionNumber)) {
73
+                    break;
74
+                }
75
+                return new Version($firstVersionNumber, $secondVersionNumber);
76
+        }
77 77
 
78
-		throw new \Exception(
79
-			sprintf(
80
-				'Version cannot be parsed: %s',
81
-				$versionSpec
82
-			)
83
-		);
84
-	}
78
+        throw new \Exception(
79
+            sprintf(
80
+                'Version cannot be parsed: %s',
81
+                $versionSpec
82
+            )
83
+        );
84
+    }
85 85
 }
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/Bundle.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -24,36 +24,36 @@
 block discarded – undo
24 24
 use OCP\IL10N;
25 25
 
26 26
 abstract class Bundle {
27
-	/** @var IL10N */
28
-	protected $l10n;
27
+    /** @var IL10N */
28
+    protected $l10n;
29 29
 
30
-	/**
31
-	 * @param IL10N $l10n
32
-	 */
33
-	public function __construct(IL10N $l10n) {
34
-		$this->l10n = $l10n;
35
-	}
30
+    /**
31
+     * @param IL10N $l10n
32
+     */
33
+    public function __construct(IL10N $l10n) {
34
+        $this->l10n = $l10n;
35
+    }
36 36
 
37
-	/**
38
-	 * Get the identifier of the bundle
39
-	 *
40
-	 * @return string
41
-	 */
42
-	final public function getIdentifier() {
43
-		return substr(strrchr(get_class($this), '\\'), 1);
44
-	}
37
+    /**
38
+     * Get the identifier of the bundle
39
+     *
40
+     * @return string
41
+     */
42
+    final public function getIdentifier() {
43
+        return substr(strrchr(get_class($this), '\\'), 1);
44
+    }
45 45
 
46
-	/**
47
-	 * Get the name of the bundle
48
-	 *
49
-	 * @return string
50
-	 */
51
-	abstract public function getName();
46
+    /**
47
+     * Get the name of the bundle
48
+     *
49
+     * @return string
50
+     */
51
+    abstract public function getName();
52 52
 
53
-	/**
54
-	 * Get the list of app identifiers in the bundle
55
-	 *
56
-	 * @return array
57
-	 */
58
-	abstract public function getAppIdentifiers();
53
+    /**
54
+     * Get the list of app identifiers in the bundle
55
+     *
56
+     * @return array
57
+     */
58
+    abstract public function getAppIdentifiers();
59 59
 }
Please login to merge, or discard this patch.
lib/private/Share20/LegacyHooks.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
 		/** @var IShare[] $deletedShares */
67 67
 		$deletedShares = $e->getArgument('deletedShares');
68 68
 
69
-		$formattedDeletedShares = array_map(function ($share) {
69
+		$formattedDeletedShares = array_map(function($share) {
70 70
 			return $this->formatHookParams($share);
71 71
 		}, $deletedShares);
72 72
 
Please login to merge, or discard this patch.
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -33,145 +33,145 @@
 block discarded – undo
33 33
 use Symfony\Component\EventDispatcher\GenericEvent;
34 34
 
35 35
 class LegacyHooks {
36
-	/** @var EventDispatcherInterface */
37
-	private $eventDispatcher;
38
-
39
-	/**
40
-	 * LegacyHooks constructor.
41
-	 *
42
-	 * @param EventDispatcherInterface $eventDispatcher
43
-	 */
44
-	public function __construct(EventDispatcherInterface $eventDispatcher) {
45
-		$this->eventDispatcher = $eventDispatcher;
46
-
47
-		$this->eventDispatcher->addListener('OCP\Share::preUnshare', [$this, 'preUnshare']);
48
-		$this->eventDispatcher->addListener('OCP\Share::postUnshare', [$this, 'postUnshare']);
49
-		$this->eventDispatcher->addListener('OCP\Share::postUnshareFromSelf', [$this, 'postUnshareFromSelf']);
50
-		$this->eventDispatcher->addListener('OCP\Share::preShare', [$this, 'preShare']);
51
-		$this->eventDispatcher->addListener('OCP\Share::postShare', [$this, 'postShare']);
52
-	}
53
-
54
-	/**
55
-	 * @param GenericEvent $e
56
-	 */
57
-	public function preUnshare(GenericEvent $e) {
58
-		/** @var IShare $share */
59
-		$share = $e->getSubject();
60
-
61
-		$formatted = $this->formatHookParams($share);
62
-		\OC_Hook::emit(Share::class, 'pre_unshare', $formatted);
63
-	}
64
-
65
-	/**
66
-	 * @param GenericEvent $e
67
-	 */
68
-	public function postUnshare(GenericEvent $e) {
69
-		/** @var IShare $share */
70
-		$share = $e->getSubject();
71
-
72
-		$formatted = $this->formatHookParams($share);
73
-
74
-		/** @var IShare[] $deletedShares */
75
-		$deletedShares = $e->getArgument('deletedShares');
76
-
77
-		$formattedDeletedShares = array_map(function ($share) {
78
-			return $this->formatHookParams($share);
79
-		}, $deletedShares);
80
-
81
-		$formatted['deletedShares'] = $formattedDeletedShares;
82
-
83
-		\OC_Hook::emit(Share::class, 'post_unshare', $formatted);
84
-	}
85
-
86
-	/**
87
-	 * @param GenericEvent $e
88
-	 */
89
-	public function postUnshareFromSelf(GenericEvent $e) {
90
-		/** @var IShare $share */
91
-		$share = $e->getSubject();
92
-
93
-		$formatted = $this->formatHookParams($share);
94
-		$formatted['itemTarget'] = $formatted['fileTarget'];
95
-		$formatted['unsharedItems'] = [$formatted];
96
-
97
-		\OC_Hook::emit(Share::class, 'post_unshareFromSelf', $formatted);
98
-	}
99
-
100
-	private function formatHookParams(IShare $share) {
101
-		// Prepare hook
102
-		$shareType = $share->getShareType();
103
-		$sharedWith = '';
104
-		if ($shareType === IShare::TYPE_USER ||
105
-			$shareType === IShare::TYPE_GROUP ||
106
-			$shareType === IShare::TYPE_REMOTE) {
107
-			$sharedWith = $share->getSharedWith();
108
-		}
109
-
110
-		$hookParams = [
111
-			'id' => $share->getId(),
112
-			'itemType' => $share->getNodeType(),
113
-			'itemSource' => $share->getNodeId(),
114
-			'shareType' => $shareType,
115
-			'shareWith' => $sharedWith,
116
-			'itemparent' => method_exists($share, 'getParent') ? $share->getParent() : '',
117
-			'uidOwner' => $share->getSharedBy(),
118
-			'fileSource' => $share->getNodeId(),
119
-			'fileTarget' => $share->getTarget()
120
-		];
121
-		return $hookParams;
122
-	}
123
-
124
-	public function preShare(GenericEvent $e) {
125
-		/** @var IShare $share */
126
-		$share = $e->getSubject();
127
-
128
-		// Pre share hook
129
-		$run = true;
130
-		$error = '';
131
-		$preHookData = [
132
-			'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
133
-			'itemSource' => $share->getNode()->getId(),
134
-			'shareType' => $share->getShareType(),
135
-			'uidOwner' => $share->getSharedBy(),
136
-			'permissions' => $share->getPermissions(),
137
-			'fileSource' => $share->getNode()->getId(),
138
-			'expiration' => $share->getExpirationDate(),
139
-			'token' => $share->getToken(),
140
-			'itemTarget' => $share->getTarget(),
141
-			'shareWith' => $share->getSharedWith(),
142
-			'run' => &$run,
143
-			'error' => &$error,
144
-		];
145
-		\OC_Hook::emit(Share::class, 'pre_shared', $preHookData);
146
-
147
-		if ($run === false) {
148
-			$e->setArgument('error', $error);
149
-			$e->stopPropagation();
150
-		}
151
-
152
-		return $e;
153
-	}
154
-
155
-	public function postShare(GenericEvent $e) {
156
-		/** @var IShare $share */
157
-		$share = $e->getSubject();
158
-
159
-		$postHookData = [
160
-			'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
161
-			'itemSource' => $share->getNode()->getId(),
162
-			'shareType' => $share->getShareType(),
163
-			'uidOwner' => $share->getSharedBy(),
164
-			'permissions' => $share->getPermissions(),
165
-			'fileSource' => $share->getNode()->getId(),
166
-			'expiration' => $share->getExpirationDate(),
167
-			'token' => $share->getToken(),
168
-			'id' => $share->getId(),
169
-			'shareWith' => $share->getSharedWith(),
170
-			'itemTarget' => $share->getTarget(),
171
-			'fileTarget' => $share->getTarget(),
172
-			'path' => $share->getNode()->getPath(),
173
-		];
174
-
175
-		\OC_Hook::emit(Share::class, 'post_shared', $postHookData);
176
-	}
36
+    /** @var EventDispatcherInterface */
37
+    private $eventDispatcher;
38
+
39
+    /**
40
+     * LegacyHooks constructor.
41
+     *
42
+     * @param EventDispatcherInterface $eventDispatcher
43
+     */
44
+    public function __construct(EventDispatcherInterface $eventDispatcher) {
45
+        $this->eventDispatcher = $eventDispatcher;
46
+
47
+        $this->eventDispatcher->addListener('OCP\Share::preUnshare', [$this, 'preUnshare']);
48
+        $this->eventDispatcher->addListener('OCP\Share::postUnshare', [$this, 'postUnshare']);
49
+        $this->eventDispatcher->addListener('OCP\Share::postUnshareFromSelf', [$this, 'postUnshareFromSelf']);
50
+        $this->eventDispatcher->addListener('OCP\Share::preShare', [$this, 'preShare']);
51
+        $this->eventDispatcher->addListener('OCP\Share::postShare', [$this, 'postShare']);
52
+    }
53
+
54
+    /**
55
+     * @param GenericEvent $e
56
+     */
57
+    public function preUnshare(GenericEvent $e) {
58
+        /** @var IShare $share */
59
+        $share = $e->getSubject();
60
+
61
+        $formatted = $this->formatHookParams($share);
62
+        \OC_Hook::emit(Share::class, 'pre_unshare', $formatted);
63
+    }
64
+
65
+    /**
66
+     * @param GenericEvent $e
67
+     */
68
+    public function postUnshare(GenericEvent $e) {
69
+        /** @var IShare $share */
70
+        $share = $e->getSubject();
71
+
72
+        $formatted = $this->formatHookParams($share);
73
+
74
+        /** @var IShare[] $deletedShares */
75
+        $deletedShares = $e->getArgument('deletedShares');
76
+
77
+        $formattedDeletedShares = array_map(function ($share) {
78
+            return $this->formatHookParams($share);
79
+        }, $deletedShares);
80
+
81
+        $formatted['deletedShares'] = $formattedDeletedShares;
82
+
83
+        \OC_Hook::emit(Share::class, 'post_unshare', $formatted);
84
+    }
85
+
86
+    /**
87
+     * @param GenericEvent $e
88
+     */
89
+    public function postUnshareFromSelf(GenericEvent $e) {
90
+        /** @var IShare $share */
91
+        $share = $e->getSubject();
92
+
93
+        $formatted = $this->formatHookParams($share);
94
+        $formatted['itemTarget'] = $formatted['fileTarget'];
95
+        $formatted['unsharedItems'] = [$formatted];
96
+
97
+        \OC_Hook::emit(Share::class, 'post_unshareFromSelf', $formatted);
98
+    }
99
+
100
+    private function formatHookParams(IShare $share) {
101
+        // Prepare hook
102
+        $shareType = $share->getShareType();
103
+        $sharedWith = '';
104
+        if ($shareType === IShare::TYPE_USER ||
105
+            $shareType === IShare::TYPE_GROUP ||
106
+            $shareType === IShare::TYPE_REMOTE) {
107
+            $sharedWith = $share->getSharedWith();
108
+        }
109
+
110
+        $hookParams = [
111
+            'id' => $share->getId(),
112
+            'itemType' => $share->getNodeType(),
113
+            'itemSource' => $share->getNodeId(),
114
+            'shareType' => $shareType,
115
+            'shareWith' => $sharedWith,
116
+            'itemparent' => method_exists($share, 'getParent') ? $share->getParent() : '',
117
+            'uidOwner' => $share->getSharedBy(),
118
+            'fileSource' => $share->getNodeId(),
119
+            'fileTarget' => $share->getTarget()
120
+        ];
121
+        return $hookParams;
122
+    }
123
+
124
+    public function preShare(GenericEvent $e) {
125
+        /** @var IShare $share */
126
+        $share = $e->getSubject();
127
+
128
+        // Pre share hook
129
+        $run = true;
130
+        $error = '';
131
+        $preHookData = [
132
+            'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
133
+            'itemSource' => $share->getNode()->getId(),
134
+            'shareType' => $share->getShareType(),
135
+            'uidOwner' => $share->getSharedBy(),
136
+            'permissions' => $share->getPermissions(),
137
+            'fileSource' => $share->getNode()->getId(),
138
+            'expiration' => $share->getExpirationDate(),
139
+            'token' => $share->getToken(),
140
+            'itemTarget' => $share->getTarget(),
141
+            'shareWith' => $share->getSharedWith(),
142
+            'run' => &$run,
143
+            'error' => &$error,
144
+        ];
145
+        \OC_Hook::emit(Share::class, 'pre_shared', $preHookData);
146
+
147
+        if ($run === false) {
148
+            $e->setArgument('error', $error);
149
+            $e->stopPropagation();
150
+        }
151
+
152
+        return $e;
153
+    }
154
+
155
+    public function postShare(GenericEvent $e) {
156
+        /** @var IShare $share */
157
+        $share = $e->getSubject();
158
+
159
+        $postHookData = [
160
+            'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
161
+            'itemSource' => $share->getNode()->getId(),
162
+            'shareType' => $share->getShareType(),
163
+            'uidOwner' => $share->getSharedBy(),
164
+            'permissions' => $share->getPermissions(),
165
+            'fileSource' => $share->getNode()->getId(),
166
+            'expiration' => $share->getExpirationDate(),
167
+            'token' => $share->getToken(),
168
+            'id' => $share->getId(),
169
+            'shareWith' => $share->getSharedWith(),
170
+            'itemTarget' => $share->getTarget(),
171
+            'fileTarget' => $share->getTarget(),
172
+            'path' => $share->getNode()->getPath(),
173
+        ];
174
+
175
+        \OC_Hook::emit(Share::class, 'post_shared', $postHookData);
176
+    }
177 177
 }
Please login to merge, or discard this patch.