Completed
Push — master ( 08b58a...0efd05 )
by Daniel
30:08 queued 21s
created
apps/user_ldap/lib/Mapping/GroupMapping.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
29 29
  */
30 30
 class GroupMapping extends AbstractMapping {
31 31
 
32
-	/**
33
-	 * returns the DB table name which holds the mappings
34
-	 * @return string
35
-	 */
36
-	protected function getTableName(bool $includePrefix = true) {
37
-		$p = $includePrefix ? '*PREFIX*' : '';
38
-		return $p . 'ldap_group_mapping';
39
-	}
32
+    /**
33
+     * returns the DB table name which holds the mappings
34
+     * @return string
35
+     */
36
+    protected function getTableName(bool $includePrefix = true) {
37
+        $p = $includePrefix ? '*PREFIX*' : '';
38
+        return $p . 'ldap_group_mapping';
39
+    }
40 40
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,6 +35,6 @@
 block discarded – undo
35 35
 	 */
36 36
 	protected function getTableName(bool $includePrefix = true) {
37 37
 		$p = $includePrefix ? '*PREFIX*' : '';
38
-		return $p . 'ldap_group_mapping';
38
+		return $p.'ldap_group_mapping';
39 39
 	}
40 40
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Proxy.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @return string
108 108
 	 */
109 109
 	protected function getUserCacheKey($uid) {
110
-		return 'user-' . $uid . '-lastSeenOn';
110
+		return 'user-'.$uid.'-lastSeenOn';
111 111
 	}
112 112
 
113 113
 	/**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @return string
116 116
 	 */
117 117
 	protected function getGroupCacheKey($gid) {
118
-		return 'group-' . $gid . '-lastSeenOn';
118
+		return 'group-'.$gid.'-lastSeenOn';
119 119
 	}
120 120
 
121 121
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		if ($key === null) {
179 179
 			return $prefix;
180 180
 		}
181
-		return $prefix . hash('sha256', $key);
181
+		return $prefix.hash('sha256', $key);
182 182
 	}
183 183
 
184 184
 	/**
Please login to merge, or discard this patch.
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -17,191 +17,191 @@
 block discarded – undo
17 17
  * @template T
18 18
  */
19 19
 abstract class Proxy {
20
-	/** @var array<string,Access> */
21
-	private static array $accesses = [];
22
-	private ?bool $isSingleBackend = null;
23
-	private ?ICache $cache = null;
24
-
25
-	/** @var T[] */
26
-	protected array $backends = [];
27
-	/** @var ?T */
28
-	protected $refBackend = null;
29
-
30
-	protected bool $isSetUp = false;
31
-
32
-	public function __construct(
33
-		private Helper $helper,
34
-		private ILDAPWrapper $ldap,
35
-		private AccessFactory $accessFactory,
36
-	) {
37
-		$memcache = Server::get(ICacheFactory::class);
38
-		if ($memcache->isAvailable()) {
39
-			$this->cache = $memcache->createDistributed();
40
-		}
41
-	}
42
-
43
-	protected function setup(): void {
44
-		if ($this->isSetUp) {
45
-			return;
46
-		}
47
-
48
-		$serverConfigPrefixes = $this->helper->getServerConfigurationPrefixes(true);
49
-		foreach ($serverConfigPrefixes as $configPrefix) {
50
-			$this->backends[$configPrefix] = $this->newInstance($configPrefix);
51
-
52
-			if (is_null($this->refBackend)) {
53
-				$this->refBackend = $this->backends[$configPrefix];
54
-			}
55
-		}
56
-
57
-		$this->isSetUp = true;
58
-	}
59
-
60
-	/**
61
-	 * @return T
62
-	 */
63
-	abstract protected function newInstance(string $configPrefix): object;
64
-
65
-	/**
66
-	 * @return T
67
-	 */
68
-	public function getBackend(string $configPrefix): object {
69
-		$this->setup();
70
-		return $this->backends[$configPrefix];
71
-	}
72
-
73
-	private function addAccess(string $configPrefix): void {
74
-		$userMap = Server::get(UserMapping::class);
75
-		$groupMap = Server::get(GroupMapping::class);
76
-
77
-		$connector = new Connection($this->ldap, $configPrefix);
78
-		$access = $this->accessFactory->get($connector);
79
-		$access->setUserMapper($userMap);
80
-		$access->setGroupMapper($groupMap);
81
-		self::$accesses[$configPrefix] = $access;
82
-	}
83
-
84
-	protected function getAccess(string $configPrefix): Access {
85
-		if (!isset(self::$accesses[$configPrefix])) {
86
-			$this->addAccess($configPrefix);
87
-		}
88
-		return self::$accesses[$configPrefix];
89
-	}
90
-
91
-	/**
92
-	 * @param string $uid
93
-	 * @return string
94
-	 */
95
-	protected function getUserCacheKey($uid) {
96
-		return 'user-' . $uid . '-lastSeenOn';
97
-	}
98
-
99
-	/**
100
-	 * @param string $gid
101
-	 * @return string
102
-	 */
103
-	protected function getGroupCacheKey($gid) {
104
-		return 'group-' . $gid . '-lastSeenOn';
105
-	}
106
-
107
-	/**
108
-	 * @param string $id
109
-	 * @param string $method
110
-	 * @param array $parameters
111
-	 * @param bool $passOnWhen
112
-	 * @return mixed
113
-	 */
114
-	abstract protected function callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
115
-
116
-	/**
117
-	 * @param string $id
118
-	 * @param string $method
119
-	 * @param array $parameters
120
-	 * @return mixed
121
-	 */
122
-	abstract protected function walkBackends($id, $method, $parameters);
123
-
124
-	/**
125
-	 * @param string $id
126
-	 * @return Access
127
-	 */
128
-	abstract public function getLDAPAccess($id);
129
-
130
-	abstract protected function activeBackends(): int;
131
-
132
-	protected function isSingleBackend(): bool {
133
-		if ($this->isSingleBackend === null) {
134
-			$this->isSingleBackend = $this->activeBackends() === 1;
135
-		}
136
-		return $this->isSingleBackend;
137
-	}
138
-
139
-	/**
140
-	 * Takes care of the request to the User backend
141
-	 *
142
-	 * @param string $id
143
-	 * @param string $method string, the method of the user backend that shall be called
144
-	 * @param array $parameters an array of parameters to be passed
145
-	 * @param bool $passOnWhen
146
-	 * @return mixed the result of the specified method
147
-	 */
148
-	protected function handleRequest($id, $method, $parameters, $passOnWhen = false) {
149
-		if (!$this->isSingleBackend()) {
150
-			$result = $this->callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
151
-		}
152
-		if (!isset($result) || $result === $passOnWhen) {
153
-			$result = $this->walkBackends($id, $method, $parameters);
154
-		}
155
-		return $result;
156
-	}
157
-
158
-	/**
159
-	 * @param string|null $key
160
-	 * @return string
161
-	 */
162
-	private function getCacheKey($key) {
163
-		$prefix = 'LDAP-Proxy-';
164
-		if ($key === null) {
165
-			return $prefix;
166
-		}
167
-		return $prefix . hash('sha256', $key);
168
-	}
169
-
170
-	/**
171
-	 * @param string $key
172
-	 * @return mixed|null
173
-	 */
174
-	public function getFromCache($key) {
175
-		if ($this->cache === null) {
176
-			return null;
177
-		}
178
-
179
-		$key = $this->getCacheKey($key);
180
-		$value = $this->cache->get($key);
181
-		if ($value === null) {
182
-			return null;
183
-		}
184
-
185
-		return json_decode(base64_decode($value));
186
-	}
187
-
188
-	/**
189
-	 * @param string $key
190
-	 * @param mixed $value
191
-	 */
192
-	public function writeToCache($key, $value) {
193
-		if ($this->cache === null) {
194
-			return;
195
-		}
196
-		$key = $this->getCacheKey($key);
197
-		$value = base64_encode(json_encode($value));
198
-		$this->cache->set($key, $value, 2592000);
199
-	}
200
-
201
-	public function clearCache() {
202
-		if ($this->cache === null) {
203
-			return;
204
-		}
205
-		$this->cache->clear($this->getCacheKey(null));
206
-	}
20
+    /** @var array<string,Access> */
21
+    private static array $accesses = [];
22
+    private ?bool $isSingleBackend = null;
23
+    private ?ICache $cache = null;
24
+
25
+    /** @var T[] */
26
+    protected array $backends = [];
27
+    /** @var ?T */
28
+    protected $refBackend = null;
29
+
30
+    protected bool $isSetUp = false;
31
+
32
+    public function __construct(
33
+        private Helper $helper,
34
+        private ILDAPWrapper $ldap,
35
+        private AccessFactory $accessFactory,
36
+    ) {
37
+        $memcache = Server::get(ICacheFactory::class);
38
+        if ($memcache->isAvailable()) {
39
+            $this->cache = $memcache->createDistributed();
40
+        }
41
+    }
42
+
43
+    protected function setup(): void {
44
+        if ($this->isSetUp) {
45
+            return;
46
+        }
47
+
48
+        $serverConfigPrefixes = $this->helper->getServerConfigurationPrefixes(true);
49
+        foreach ($serverConfigPrefixes as $configPrefix) {
50
+            $this->backends[$configPrefix] = $this->newInstance($configPrefix);
51
+
52
+            if (is_null($this->refBackend)) {
53
+                $this->refBackend = $this->backends[$configPrefix];
54
+            }
55
+        }
56
+
57
+        $this->isSetUp = true;
58
+    }
59
+
60
+    /**
61
+     * @return T
62
+     */
63
+    abstract protected function newInstance(string $configPrefix): object;
64
+
65
+    /**
66
+     * @return T
67
+     */
68
+    public function getBackend(string $configPrefix): object {
69
+        $this->setup();
70
+        return $this->backends[$configPrefix];
71
+    }
72
+
73
+    private function addAccess(string $configPrefix): void {
74
+        $userMap = Server::get(UserMapping::class);
75
+        $groupMap = Server::get(GroupMapping::class);
76
+
77
+        $connector = new Connection($this->ldap, $configPrefix);
78
+        $access = $this->accessFactory->get($connector);
79
+        $access->setUserMapper($userMap);
80
+        $access->setGroupMapper($groupMap);
81
+        self::$accesses[$configPrefix] = $access;
82
+    }
83
+
84
+    protected function getAccess(string $configPrefix): Access {
85
+        if (!isset(self::$accesses[$configPrefix])) {
86
+            $this->addAccess($configPrefix);
87
+        }
88
+        return self::$accesses[$configPrefix];
89
+    }
90
+
91
+    /**
92
+     * @param string $uid
93
+     * @return string
94
+     */
95
+    protected function getUserCacheKey($uid) {
96
+        return 'user-' . $uid . '-lastSeenOn';
97
+    }
98
+
99
+    /**
100
+     * @param string $gid
101
+     * @return string
102
+     */
103
+    protected function getGroupCacheKey($gid) {
104
+        return 'group-' . $gid . '-lastSeenOn';
105
+    }
106
+
107
+    /**
108
+     * @param string $id
109
+     * @param string $method
110
+     * @param array $parameters
111
+     * @param bool $passOnWhen
112
+     * @return mixed
113
+     */
114
+    abstract protected function callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
115
+
116
+    /**
117
+     * @param string $id
118
+     * @param string $method
119
+     * @param array $parameters
120
+     * @return mixed
121
+     */
122
+    abstract protected function walkBackends($id, $method, $parameters);
123
+
124
+    /**
125
+     * @param string $id
126
+     * @return Access
127
+     */
128
+    abstract public function getLDAPAccess($id);
129
+
130
+    abstract protected function activeBackends(): int;
131
+
132
+    protected function isSingleBackend(): bool {
133
+        if ($this->isSingleBackend === null) {
134
+            $this->isSingleBackend = $this->activeBackends() === 1;
135
+        }
136
+        return $this->isSingleBackend;
137
+    }
138
+
139
+    /**
140
+     * Takes care of the request to the User backend
141
+     *
142
+     * @param string $id
143
+     * @param string $method string, the method of the user backend that shall be called
144
+     * @param array $parameters an array of parameters to be passed
145
+     * @param bool $passOnWhen
146
+     * @return mixed the result of the specified method
147
+     */
148
+    protected function handleRequest($id, $method, $parameters, $passOnWhen = false) {
149
+        if (!$this->isSingleBackend()) {
150
+            $result = $this->callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
151
+        }
152
+        if (!isset($result) || $result === $passOnWhen) {
153
+            $result = $this->walkBackends($id, $method, $parameters);
154
+        }
155
+        return $result;
156
+    }
157
+
158
+    /**
159
+     * @param string|null $key
160
+     * @return string
161
+     */
162
+    private function getCacheKey($key) {
163
+        $prefix = 'LDAP-Proxy-';
164
+        if ($key === null) {
165
+            return $prefix;
166
+        }
167
+        return $prefix . hash('sha256', $key);
168
+    }
169
+
170
+    /**
171
+     * @param string $key
172
+     * @return mixed|null
173
+     */
174
+    public function getFromCache($key) {
175
+        if ($this->cache === null) {
176
+            return null;
177
+        }
178
+
179
+        $key = $this->getCacheKey($key);
180
+        $value = $this->cache->get($key);
181
+        if ($value === null) {
182
+            return null;
183
+        }
184
+
185
+        return json_decode(base64_decode($value));
186
+    }
187
+
188
+    /**
189
+     * @param string $key
190
+     * @param mixed $value
191
+     */
192
+    public function writeToCache($key, $value) {
193
+        if ($this->cache === null) {
194
+            return;
195
+        }
196
+        $key = $this->getCacheKey($key);
197
+        $value = base64_encode(json_encode($value));
198
+        $this->cache->set($key, $value, 2592000);
199
+    }
200
+
201
+    public function clearCache() {
202
+        if ($this->cache === null) {
203
+            return;
204
+        }
205
+        $this->cache->clear($this->getCacheKey(null));
206
+    }
207 207
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Services/InitialState.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@
 block discarded – undo
29 29
 use OCP\IInitialStateService;
30 30
 
31 31
 class InitialState implements IInitialState {
32
-	/** @var IInitialStateService */
33
-	private $state;
32
+    /** @var IInitialStateService */
33
+    private $state;
34 34
 
35
-	/** @var string */
36
-	private $appName;
35
+    /** @var string */
36
+    private $appName;
37 37
 
38
-	public function __construct(IInitialStateService $state, string $appName) {
39
-		$this->state = $state;
40
-		$this->appName = $appName;
41
-	}
38
+    public function __construct(IInitialStateService $state, string $appName) {
39
+        $this->state = $state;
40
+        $this->appName = $appName;
41
+    }
42 42
 
43
-	public function provideInitialState(string $key, $data): void {
44
-		$this->state->provideInitialState($this->appName, $key, $data);
45
-	}
43
+    public function provideInitialState(string $key, $data): void {
44
+        $this->state->provideInitialState($this->appName, $key, $data);
45
+    }
46 46
 
47
-	public function provideLazyInitialState(string $key, \Closure $closure): void {
48
-		$this->state->provideLazyInitialState($this->appName, $key, $closure);
49
-	}
47
+    public function provideLazyInitialState(string $key, \Closure $closure): void {
48
+        $this->state->provideLazyInitialState($this->appName, $key, $closure);
49
+    }
50 50
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/NotModifiedMiddleware.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 
41 41
 	public function afterController($controller, $methodName, Response $response) {
42 42
 		$etagHeader = $this->request->getHeader('IF_NONE_MATCH');
43
-		if ($etagHeader !== '' && $response->getETag() !== null && trim($etagHeader) === '"' . $response->getETag() . '"') {
43
+		if ($etagHeader !== '' && $response->getETag() !== null && trim($etagHeader) === '"'.$response->getETag().'"') {
44 44
 			$response->setStatus(Http::STATUS_NOT_MODIFIED);
45 45
 			return $response;
46 46
 		}
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -14,26 +14,26 @@
 block discarded – undo
14 14
 use OCP\IRequest;
15 15
 
16 16
 class NotModifiedMiddleware extends Middleware {
17
-	/** @var IRequest */
18
-	private $request;
19
-
20
-	public function __construct(IRequest $request) {
21
-		$this->request = $request;
22
-	}
23
-
24
-	public function afterController($controller, $methodName, Response $response) {
25
-		$etagHeader = $this->request->getHeader('IF_NONE_MATCH');
26
-		if ($etagHeader !== '' && $response->getETag() !== null && trim($etagHeader) === '"' . $response->getETag() . '"') {
27
-			$response->setStatus(Http::STATUS_NOT_MODIFIED);
28
-			return $response;
29
-		}
30
-
31
-		$modifiedSinceHeader = $this->request->getHeader('IF_MODIFIED_SINCE');
32
-		if ($modifiedSinceHeader !== '' && $response->getLastModified() !== null && trim($modifiedSinceHeader) === $response->getLastModified()->format(\DateTimeInterface::RFC7231)) {
33
-			$response->setStatus(Http::STATUS_NOT_MODIFIED);
34
-			return $response;
35
-		}
36
-
37
-		return $response;
38
-	}
17
+    /** @var IRequest */
18
+    private $request;
19
+
20
+    public function __construct(IRequest $request) {
21
+        $this->request = $request;
22
+    }
23
+
24
+    public function afterController($controller, $methodName, Response $response) {
25
+        $etagHeader = $this->request->getHeader('IF_NONE_MATCH');
26
+        if ($etagHeader !== '' && $response->getETag() !== null && trim($etagHeader) === '"' . $response->getETag() . '"') {
27
+            $response->setStatus(Http::STATUS_NOT_MODIFIED);
28
+            return $response;
29
+        }
30
+
31
+        $modifiedSinceHeader = $this->request->getHeader('IF_MODIFIED_SINCE');
32
+        if ($modifiedSinceHeader !== '' && $response->getLastModified() !== null && trim($modifiedSinceHeader) === $response->getLastModified()->format(\DateTimeInterface::RFC7231)) {
33
+            $response->setStatus(Http::STATUS_NOT_MODIFIED);
34
+            return $response;
35
+        }
36
+
37
+        return $response;
38
+    }
39 39
 }
Please login to merge, or discard this patch.
resources/update-locales.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,28 +25,28 @@
 block discarded – undo
25 25
  */
26 26
 
27 27
 if (!extension_loaded('intl')) {
28
-	echo 'Intl extension is required to run this script.';
29
-	exit(1);
28
+    echo 'Intl extension is required to run this script.';
29
+    exit(1);
30 30
 }
31 31
 
32 32
 require '../3rdparty/autoload.php';
33 33
 
34 34
 $locales = array_map(static function (string $localeCode) {
35
-	return [
36
-		'code' => $localeCode,
37
-		'name' => Locale::getDisplayName($localeCode, 'en')
38
-	];
35
+    return [
36
+        'code' => $localeCode,
37
+        'name' => Locale::getDisplayName($localeCode, 'en')
38
+    ];
39 39
 }, ResourceBundle::getLocales(''));
40 40
 
41 41
 $locales = array_filter($locales, static function (array $locale) {
42
-	return is_array(Punic\Data::explodeLocale($locale['code']));
42
+    return is_array(Punic\Data::explodeLocale($locale['code']));
43 43
 });
44 44
 
45 45
 $locales = array_values($locales);
46 46
 
47 47
 if (file_put_contents(__DIR__ . '/locales.json', json_encode($locales, JSON_PRETTY_PRINT)) === false) {
48
-	echo 'Failed to update locales.json';
49
-	exit(1);
48
+    echo 'Failed to update locales.json';
49
+    exit(1);
50 50
 }
51 51
 
52 52
 echo 'Updated locales.json. Don\'t forget to commit the result.';
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,20 +31,20 @@
 block discarded – undo
31 31
 
32 32
 require '../3rdparty/autoload.php';
33 33
 
34
-$locales = array_map(static function (string $localeCode) {
34
+$locales = array_map(static function(string $localeCode) {
35 35
 	return [
36 36
 		'code' => $localeCode,
37 37
 		'name' => Locale::getDisplayName($localeCode, 'en')
38 38
 	];
39 39
 }, ResourceBundle::getLocales(''));
40 40
 
41
-$locales = array_filter($locales, static function (array $locale) {
41
+$locales = array_filter($locales, static function(array $locale) {
42 42
 	return is_array(Punic\Data::explodeLocale($locale['code']));
43 43
 });
44 44
 
45 45
 $locales = array_values($locales);
46 46
 
47
-if (file_put_contents(__DIR__ . '/locales.json', json_encode($locales, JSON_PRETTY_PRINT)) === false) {
47
+if (file_put_contents(__DIR__.'/locales.json', json_encode($locales, JSON_PRETTY_PRINT)) === false) {
48 48
 	echo 'Failed to update locales.json';
49 49
 	exit(1);
50 50
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Storage/SFTPWriteStream.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		if (isset($context[$name])) {
71 71
 			$context = $context[$name];
72 72
 		} else {
73
-			throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set');
73
+			throw new \BadMethodCallException('Invalid context, "'.$name.'" options not set');
74 74
 		}
75 75
 		if (isset($context['session']) and $context['session'] instanceof \phpseclib\Net\SFTP) {
76 76
 			$this->sftp = $context['session'];
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
 	public function stream_open($path, $mode, $options, &$opened_path) {
84 84
 		[, $path] = explode('://', $path);
85
-		$path = '/' . ltrim($path);
85
+		$path = '/'.ltrim($path);
86 86
 		$path = str_replace('//', '/', $path);
87 87
 
88 88
 		$this->loadContext('sftp');
Please login to merge, or discard this patch.
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -12,154 +12,154 @@
 block discarded – undo
12 12
 use phpseclib\Net\SSH2;
13 13
 
14 14
 class SFTPWriteStream implements File {
15
-	/** @var resource */
16
-	public $context;
17
-
18
-	/** @var \phpseclib\Net\SFTP */
19
-	private $sftp;
20
-
21
-	/** @var string */
22
-	private $handle;
23
-
24
-	/** @var int */
25
-	private $internalPosition = 0;
26
-
27
-	/** @var int */
28
-	private $writePosition = 0;
29
-
30
-	/** @var bool */
31
-	private $eof = false;
32
-
33
-	private $buffer = '';
34
-
35
-	public static function register($protocol = 'sftpwrite') {
36
-		if (in_array($protocol, stream_get_wrappers(), true)) {
37
-			return false;
38
-		}
39
-		return stream_wrapper_register($protocol, get_called_class());
40
-	}
41
-
42
-	/**
43
-	 * Load the source from the stream context and return the context options
44
-	 *
45
-	 * @throws \BadMethodCallException
46
-	 */
47
-	protected function loadContext(string $name) {
48
-		$context = stream_context_get_options($this->context);
49
-		if (isset($context[$name])) {
50
-			$context = $context[$name];
51
-		} else {
52
-			throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set');
53
-		}
54
-		if (isset($context['session']) and $context['session'] instanceof \phpseclib\Net\SFTP) {
55
-			$this->sftp = $context['session'];
56
-		} else {
57
-			throw new \BadMethodCallException('Invalid context, session not set');
58
-		}
59
-		return $context;
60
-	}
61
-
62
-	public function stream_open($path, $mode, $options, &$opened_path) {
63
-		[, $path] = explode('://', $path);
64
-		$path = '/' . ltrim($path);
65
-		$path = str_replace('//', '/', $path);
66
-
67
-		$this->loadContext('sftp');
68
-
69
-		if (!($this->sftp->bitmap & SSH2::MASK_LOGIN)) {
70
-			return false;
71
-		}
72
-
73
-		$remote_file = $this->sftp->_realpath($path);
74
-		if ($remote_file === false) {
75
-			return false;
76
-		}
77
-
78
-		$packet = pack('Na*N2', strlen($remote_file), $remote_file, NET_SFTP_OPEN_WRITE | NET_SFTP_OPEN_CREATE | NET_SFTP_OPEN_TRUNCATE, 0);
79
-		if (!$this->sftp->_send_sftp_packet(NET_SFTP_OPEN, $packet)) {
80
-			return false;
81
-		}
82
-
83
-		$response = $this->sftp->_get_sftp_packet();
84
-		switch ($this->sftp->packet_type) {
85
-			case NET_SFTP_HANDLE:
86
-				$this->handle = substr($response, 4);
87
-				break;
88
-			case NET_SFTP_STATUS: // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
89
-				$this->sftp->_logError($response);
90
-				return false;
91
-			default:
92
-				user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS');
93
-				return false;
94
-		}
95
-
96
-		return true;
97
-	}
98
-
99
-	public function stream_seek($offset, $whence = SEEK_SET) {
100
-		return false;
101
-	}
102
-
103
-	public function stream_tell() {
104
-		return $this->writePosition;
105
-	}
106
-
107
-	public function stream_read($count) {
108
-		return false;
109
-	}
110
-
111
-	public function stream_write($data) {
112
-		$written = strlen($data);
113
-		$this->writePosition += $written;
114
-
115
-		$this->buffer .= $data;
116
-
117
-		if (strlen($this->buffer) > 64 * 1024) {
118
-			if (!$this->stream_flush()) {
119
-				return false;
120
-			}
121
-		}
122
-
123
-		return $written;
124
-	}
125
-
126
-	public function stream_set_option($option, $arg1, $arg2) {
127
-		return false;
128
-	}
129
-
130
-	public function stream_truncate($size) {
131
-		return false;
132
-	}
133
-
134
-	public function stream_stat() {
135
-		return false;
136
-	}
137
-
138
-	public function stream_lock($operation) {
139
-		return false;
140
-	}
141
-
142
-	public function stream_flush() {
143
-		$size = strlen($this->buffer);
144
-		$packet = pack('Na*N3a*', strlen($this->handle), $this->handle, $this->internalPosition / 4294967296, $this->internalPosition, $size, $this->buffer);
145
-		if (!$this->sftp->_send_sftp_packet(NET_SFTP_WRITE, $packet)) {
146
-			return false;
147
-		}
148
-		$this->internalPosition += $size;
149
-		$this->buffer = '';
150
-
151
-		return $this->sftp->_read_put_responses(1);
152
-	}
153
-
154
-	public function stream_eof() {
155
-		return $this->eof;
156
-	}
157
-
158
-	public function stream_close() {
159
-		$this->stream_flush();
160
-		if (!$this->sftp->_close_handle($this->handle)) {
161
-			return false;
162
-		}
163
-		return true;
164
-	}
15
+    /** @var resource */
16
+    public $context;
17
+
18
+    /** @var \phpseclib\Net\SFTP */
19
+    private $sftp;
20
+
21
+    /** @var string */
22
+    private $handle;
23
+
24
+    /** @var int */
25
+    private $internalPosition = 0;
26
+
27
+    /** @var int */
28
+    private $writePosition = 0;
29
+
30
+    /** @var bool */
31
+    private $eof = false;
32
+
33
+    private $buffer = '';
34
+
35
+    public static function register($protocol = 'sftpwrite') {
36
+        if (in_array($protocol, stream_get_wrappers(), true)) {
37
+            return false;
38
+        }
39
+        return stream_wrapper_register($protocol, get_called_class());
40
+    }
41
+
42
+    /**
43
+     * Load the source from the stream context and return the context options
44
+     *
45
+     * @throws \BadMethodCallException
46
+     */
47
+    protected function loadContext(string $name) {
48
+        $context = stream_context_get_options($this->context);
49
+        if (isset($context[$name])) {
50
+            $context = $context[$name];
51
+        } else {
52
+            throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set');
53
+        }
54
+        if (isset($context['session']) and $context['session'] instanceof \phpseclib\Net\SFTP) {
55
+            $this->sftp = $context['session'];
56
+        } else {
57
+            throw new \BadMethodCallException('Invalid context, session not set');
58
+        }
59
+        return $context;
60
+    }
61
+
62
+    public function stream_open($path, $mode, $options, &$opened_path) {
63
+        [, $path] = explode('://', $path);
64
+        $path = '/' . ltrim($path);
65
+        $path = str_replace('//', '/', $path);
66
+
67
+        $this->loadContext('sftp');
68
+
69
+        if (!($this->sftp->bitmap & SSH2::MASK_LOGIN)) {
70
+            return false;
71
+        }
72
+
73
+        $remote_file = $this->sftp->_realpath($path);
74
+        if ($remote_file === false) {
75
+            return false;
76
+        }
77
+
78
+        $packet = pack('Na*N2', strlen($remote_file), $remote_file, NET_SFTP_OPEN_WRITE | NET_SFTP_OPEN_CREATE | NET_SFTP_OPEN_TRUNCATE, 0);
79
+        if (!$this->sftp->_send_sftp_packet(NET_SFTP_OPEN, $packet)) {
80
+            return false;
81
+        }
82
+
83
+        $response = $this->sftp->_get_sftp_packet();
84
+        switch ($this->sftp->packet_type) {
85
+            case NET_SFTP_HANDLE:
86
+                $this->handle = substr($response, 4);
87
+                break;
88
+            case NET_SFTP_STATUS: // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
89
+                $this->sftp->_logError($response);
90
+                return false;
91
+            default:
92
+                user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS');
93
+                return false;
94
+        }
95
+
96
+        return true;
97
+    }
98
+
99
+    public function stream_seek($offset, $whence = SEEK_SET) {
100
+        return false;
101
+    }
102
+
103
+    public function stream_tell() {
104
+        return $this->writePosition;
105
+    }
106
+
107
+    public function stream_read($count) {
108
+        return false;
109
+    }
110
+
111
+    public function stream_write($data) {
112
+        $written = strlen($data);
113
+        $this->writePosition += $written;
114
+
115
+        $this->buffer .= $data;
116
+
117
+        if (strlen($this->buffer) > 64 * 1024) {
118
+            if (!$this->stream_flush()) {
119
+                return false;
120
+            }
121
+        }
122
+
123
+        return $written;
124
+    }
125
+
126
+    public function stream_set_option($option, $arg1, $arg2) {
127
+        return false;
128
+    }
129
+
130
+    public function stream_truncate($size) {
131
+        return false;
132
+    }
133
+
134
+    public function stream_stat() {
135
+        return false;
136
+    }
137
+
138
+    public function stream_lock($operation) {
139
+        return false;
140
+    }
141
+
142
+    public function stream_flush() {
143
+        $size = strlen($this->buffer);
144
+        $packet = pack('Na*N3a*', strlen($this->handle), $this->handle, $this->internalPosition / 4294967296, $this->internalPosition, $size, $this->buffer);
145
+        if (!$this->sftp->_send_sftp_packet(NET_SFTP_WRITE, $packet)) {
146
+            return false;
147
+        }
148
+        $this->internalPosition += $size;
149
+        $this->buffer = '';
150
+
151
+        return $this->sftp->_read_put_responses(1);
152
+    }
153
+
154
+    public function stream_eof() {
155
+        return $this->eof;
156
+    }
157
+
158
+    public function stream_close() {
159
+        $this->stream_flush();
160
+        if (!$this->sftp->_close_handle($this->handle)) {
161
+            return false;
162
+        }
163
+        return true;
164
+    }
165 165
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Storage/SFTPReadStream.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		if (isset($context[$name])) {
71 71
 			$context = $context[$name];
72 72
 		} else {
73
-			throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set');
73
+			throw new \BadMethodCallException('Invalid context, "'.$name.'" options not set');
74 74
 		}
75 75
 		if (isset($context['session']) and $context['session'] instanceof \phpseclib\Net\SFTP) {
76 76
 			$this->sftp = $context['session'];
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
 	public function stream_open($path, $mode, $options, &$opened_path) {
84 84
 		[, $path] = explode('://', $path);
85
-		$path = '/' . ltrim($path);
85
+		$path = '/'.ltrim($path);
86 86
 		$path = str_replace('//', '/', $path);
87 87
 
88 88
 		$this->loadContext('sftp');
Please login to merge, or discard this patch.
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -12,206 +12,206 @@
 block discarded – undo
12 12
 use phpseclib\Net\SSH2;
13 13
 
14 14
 class SFTPReadStream implements File {
15
-	/** @var resource */
16
-	public $context;
17
-
18
-	/** @var \phpseclib\Net\SFTP */
19
-	private $sftp;
20
-
21
-	/** @var string */
22
-	private $handle;
23
-
24
-	/** @var int */
25
-	private $internalPosition = 0;
26
-
27
-	/** @var int */
28
-	private $readPosition = 0;
29
-
30
-	/** @var bool */
31
-	private $eof = false;
32
-
33
-	private $buffer = '';
34
-	private bool $pendingRead = false;
35
-	private int $size = 0;
36
-
37
-	public static function register($protocol = 'sftpread') {
38
-		if (in_array($protocol, stream_get_wrappers(), true)) {
39
-			return false;
40
-		}
41
-		return stream_wrapper_register($protocol, get_called_class());
42
-	}
43
-
44
-	/**
45
-	 * Load the source from the stream context and return the context options
46
-	 *
47
-	 * @throws \BadMethodCallException
48
-	 */
49
-	protected function loadContext(string $name) {
50
-		$context = stream_context_get_options($this->context);
51
-		if (isset($context[$name])) {
52
-			$context = $context[$name];
53
-		} else {
54
-			throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set');
55
-		}
56
-		if (isset($context['session']) and $context['session'] instanceof \phpseclib\Net\SFTP) {
57
-			$this->sftp = $context['session'];
58
-		} else {
59
-			throw new \BadMethodCallException('Invalid context, session not set');
60
-		}
61
-		if (isset($context['size'])) {
62
-			$this->size = $context['size'];
63
-		}
64
-		return $context;
65
-	}
66
-
67
-	public function stream_open($path, $mode, $options, &$opened_path) {
68
-		[, $path] = explode('://', $path);
69
-		$path = '/' . ltrim($path);
70
-		$path = str_replace('//', '/', $path);
71
-
72
-		$this->loadContext('sftp');
73
-
74
-		if (!($this->sftp->bitmap & SSH2::MASK_LOGIN)) {
75
-			return false;
76
-		}
77
-
78
-		$remote_file = $this->sftp->_realpath($path);
79
-		if ($remote_file === false) {
80
-			return false;
81
-		}
82
-
83
-		$packet = pack('Na*N2', strlen($remote_file), $remote_file, NET_SFTP_OPEN_READ, 0);
84
-		if (!$this->sftp->_send_sftp_packet(NET_SFTP_OPEN, $packet)) {
85
-			return false;
86
-		}
87
-
88
-		$response = $this->sftp->_get_sftp_packet();
89
-		switch ($this->sftp->packet_type) {
90
-			case NET_SFTP_HANDLE:
91
-				$this->handle = substr($response, 4);
92
-				break;
93
-			case NET_SFTP_STATUS: // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
94
-				$this->sftp->_logError($response);
95
-				return false;
96
-			default:
97
-				user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS');
98
-				return false;
99
-		}
100
-
101
-		$this->request_chunk(256 * 1024);
102
-
103
-		return true;
104
-	}
105
-
106
-	public function stream_seek($offset, $whence = SEEK_SET) {
107
-		switch ($whence) {
108
-			case SEEK_SET:
109
-				$this->seekTo($offset);
110
-				break;
111
-			case SEEK_CUR:
112
-				$this->seekTo($this->readPosition + $offset);
113
-				break;
114
-			case SEEK_END:
115
-				$this->seekTo($this->size + $offset);
116
-				break;
117
-		}
118
-		return true;
119
-	}
120
-
121
-	private function seekTo(int $offset): void {
122
-		$this->internalPosition = $offset;
123
-		$this->readPosition = $offset;
124
-		$this->buffer = '';
125
-		$this->request_chunk(256 * 1024);
126
-	}
127
-
128
-	public function stream_tell() {
129
-		return $this->readPosition;
130
-	}
131
-
132
-	public function stream_read($count) {
133
-		if (!$this->eof && strlen($this->buffer) < $count) {
134
-			$chunk = $this->read_chunk();
135
-			$this->buffer .= $chunk;
136
-			if (!$this->eof) {
137
-				$this->request_chunk(256 * 1024);
138
-			}
139
-		}
140
-
141
-		$data = substr($this->buffer, 0, $count);
142
-		$this->buffer = substr($this->buffer, $count);
143
-		$this->readPosition += strlen($data);
144
-
145
-		return $data;
146
-	}
147
-
148
-	private function request_chunk(int $size) {
149
-		if ($this->pendingRead) {
150
-			$this->sftp->_get_sftp_packet();
151
-		}
152
-
153
-		$packet = pack('Na*N3', strlen($this->handle), $this->handle, $this->internalPosition / 4294967296, $this->internalPosition, $size);
154
-		$this->pendingRead = true;
155
-		return $this->sftp->_send_sftp_packet(NET_SFTP_READ, $packet);
156
-	}
157
-
158
-	private function read_chunk() {
159
-		$this->pendingRead = false;
160
-		$response = $this->sftp->_get_sftp_packet();
161
-
162
-		switch ($this->sftp->packet_type) {
163
-			case NET_SFTP_DATA:
164
-				$temp = substr($response, 4);
165
-				$len = strlen($temp);
166
-				$this->internalPosition += $len;
167
-				return $temp;
168
-			case NET_SFTP_STATUS:
169
-				[1 => $status] = unpack('N', substr($response, 0, 4));
170
-				if ($status == NET_SFTP_STATUS_EOF) {
171
-					$this->eof = true;
172
-				}
173
-				return '';
174
-			default:
175
-				return '';
176
-		}
177
-	}
178
-
179
-	public function stream_write($data) {
180
-		return false;
181
-	}
182
-
183
-	public function stream_set_option($option, $arg1, $arg2) {
184
-		return false;
185
-	}
186
-
187
-	public function stream_truncate($size) {
188
-		return false;
189
-	}
190
-
191
-	public function stream_stat() {
192
-		return false;
193
-	}
194
-
195
-	public function stream_lock($operation) {
196
-		return false;
197
-	}
198
-
199
-	public function stream_flush() {
200
-		return false;
201
-	}
202
-
203
-	public function stream_eof() {
204
-		return $this->eof;
205
-	}
206
-
207
-	public function stream_close() {
208
-		// we still have a read request incoming that needs to be handled before we can close
209
-		if ($this->pendingRead) {
210
-			$this->sftp->_get_sftp_packet();
211
-		}
212
-		if (!$this->sftp->_close_handle($this->handle)) {
213
-			return false;
214
-		}
215
-		return true;
216
-	}
15
+    /** @var resource */
16
+    public $context;
17
+
18
+    /** @var \phpseclib\Net\SFTP */
19
+    private $sftp;
20
+
21
+    /** @var string */
22
+    private $handle;
23
+
24
+    /** @var int */
25
+    private $internalPosition = 0;
26
+
27
+    /** @var int */
28
+    private $readPosition = 0;
29
+
30
+    /** @var bool */
31
+    private $eof = false;
32
+
33
+    private $buffer = '';
34
+    private bool $pendingRead = false;
35
+    private int $size = 0;
36
+
37
+    public static function register($protocol = 'sftpread') {
38
+        if (in_array($protocol, stream_get_wrappers(), true)) {
39
+            return false;
40
+        }
41
+        return stream_wrapper_register($protocol, get_called_class());
42
+    }
43
+
44
+    /**
45
+     * Load the source from the stream context and return the context options
46
+     *
47
+     * @throws \BadMethodCallException
48
+     */
49
+    protected function loadContext(string $name) {
50
+        $context = stream_context_get_options($this->context);
51
+        if (isset($context[$name])) {
52
+            $context = $context[$name];
53
+        } else {
54
+            throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set');
55
+        }
56
+        if (isset($context['session']) and $context['session'] instanceof \phpseclib\Net\SFTP) {
57
+            $this->sftp = $context['session'];
58
+        } else {
59
+            throw new \BadMethodCallException('Invalid context, session not set');
60
+        }
61
+        if (isset($context['size'])) {
62
+            $this->size = $context['size'];
63
+        }
64
+        return $context;
65
+    }
66
+
67
+    public function stream_open($path, $mode, $options, &$opened_path) {
68
+        [, $path] = explode('://', $path);
69
+        $path = '/' . ltrim($path);
70
+        $path = str_replace('//', '/', $path);
71
+
72
+        $this->loadContext('sftp');
73
+
74
+        if (!($this->sftp->bitmap & SSH2::MASK_LOGIN)) {
75
+            return false;
76
+        }
77
+
78
+        $remote_file = $this->sftp->_realpath($path);
79
+        if ($remote_file === false) {
80
+            return false;
81
+        }
82
+
83
+        $packet = pack('Na*N2', strlen($remote_file), $remote_file, NET_SFTP_OPEN_READ, 0);
84
+        if (!$this->sftp->_send_sftp_packet(NET_SFTP_OPEN, $packet)) {
85
+            return false;
86
+        }
87
+
88
+        $response = $this->sftp->_get_sftp_packet();
89
+        switch ($this->sftp->packet_type) {
90
+            case NET_SFTP_HANDLE:
91
+                $this->handle = substr($response, 4);
92
+                break;
93
+            case NET_SFTP_STATUS: // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
94
+                $this->sftp->_logError($response);
95
+                return false;
96
+            default:
97
+                user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS');
98
+                return false;
99
+        }
100
+
101
+        $this->request_chunk(256 * 1024);
102
+
103
+        return true;
104
+    }
105
+
106
+    public function stream_seek($offset, $whence = SEEK_SET) {
107
+        switch ($whence) {
108
+            case SEEK_SET:
109
+                $this->seekTo($offset);
110
+                break;
111
+            case SEEK_CUR:
112
+                $this->seekTo($this->readPosition + $offset);
113
+                break;
114
+            case SEEK_END:
115
+                $this->seekTo($this->size + $offset);
116
+                break;
117
+        }
118
+        return true;
119
+    }
120
+
121
+    private function seekTo(int $offset): void {
122
+        $this->internalPosition = $offset;
123
+        $this->readPosition = $offset;
124
+        $this->buffer = '';
125
+        $this->request_chunk(256 * 1024);
126
+    }
127
+
128
+    public function stream_tell() {
129
+        return $this->readPosition;
130
+    }
131
+
132
+    public function stream_read($count) {
133
+        if (!$this->eof && strlen($this->buffer) < $count) {
134
+            $chunk = $this->read_chunk();
135
+            $this->buffer .= $chunk;
136
+            if (!$this->eof) {
137
+                $this->request_chunk(256 * 1024);
138
+            }
139
+        }
140
+
141
+        $data = substr($this->buffer, 0, $count);
142
+        $this->buffer = substr($this->buffer, $count);
143
+        $this->readPosition += strlen($data);
144
+
145
+        return $data;
146
+    }
147
+
148
+    private function request_chunk(int $size) {
149
+        if ($this->pendingRead) {
150
+            $this->sftp->_get_sftp_packet();
151
+        }
152
+
153
+        $packet = pack('Na*N3', strlen($this->handle), $this->handle, $this->internalPosition / 4294967296, $this->internalPosition, $size);
154
+        $this->pendingRead = true;
155
+        return $this->sftp->_send_sftp_packet(NET_SFTP_READ, $packet);
156
+    }
157
+
158
+    private function read_chunk() {
159
+        $this->pendingRead = false;
160
+        $response = $this->sftp->_get_sftp_packet();
161
+
162
+        switch ($this->sftp->packet_type) {
163
+            case NET_SFTP_DATA:
164
+                $temp = substr($response, 4);
165
+                $len = strlen($temp);
166
+                $this->internalPosition += $len;
167
+                return $temp;
168
+            case NET_SFTP_STATUS:
169
+                [1 => $status] = unpack('N', substr($response, 0, 4));
170
+                if ($status == NET_SFTP_STATUS_EOF) {
171
+                    $this->eof = true;
172
+                }
173
+                return '';
174
+            default:
175
+                return '';
176
+        }
177
+    }
178
+
179
+    public function stream_write($data) {
180
+        return false;
181
+    }
182
+
183
+    public function stream_set_option($option, $arg1, $arg2) {
184
+        return false;
185
+    }
186
+
187
+    public function stream_truncate($size) {
188
+        return false;
189
+    }
190
+
191
+    public function stream_stat() {
192
+        return false;
193
+    }
194
+
195
+    public function stream_lock($operation) {
196
+        return false;
197
+    }
198
+
199
+    public function stream_flush() {
200
+        return false;
201
+    }
202
+
203
+    public function stream_eof() {
204
+        return $this->eof;
205
+    }
206
+
207
+    public function stream_close() {
208
+        // we still have a read request incoming that needs to be handled before we can close
209
+        if ($this->pendingRead) {
210
+            $this->sftp->_get_sftp_packet();
211
+        }
212
+        if (!$this->sftp->_close_handle($this->handle)) {
213
+            return false;
214
+        }
215
+        return true;
216
+    }
217 217
 }
Please login to merge, or discard this patch.
core/Command/Db/Migrations/StatusCommand.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,10 +62,10 @@
 block discarded – undo
62 62
 			if (is_array($value)) {
63 63
 				$output->writeln("    <comment>>></comment> $key:");
64 64
 				foreach ($value as $subKey => $subValue) {
65
-					$output->writeln("        <comment>>></comment> $subKey: " . str_repeat(' ', 46 - strlen($subKey)) . $subValue);
65
+					$output->writeln("        <comment>>></comment> $subKey: ".str_repeat(' ', 46 - strlen($subKey)).$subValue);
66 66
 				}
67 67
 			} else {
68
-				$output->writeln("    <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value);
68
+				$output->writeln("    <comment>>></comment> $key: ".str_repeat(' ', 50 - strlen($key)).$value);
69 69
 			}
70 70
 		}
71 71
 		return 0;
Please login to merge, or discard this patch.
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -34,109 +34,109 @@
 block discarded – undo
34 34
 use Symfony\Component\Console\Output\OutputInterface;
35 35
 
36 36
 class StatusCommand extends Command implements CompletionAwareInterface {
37
-	public function __construct(
38
-		private Connection $connection,
39
-	) {
40
-		parent::__construct();
41
-	}
37
+    public function __construct(
38
+        private Connection $connection,
39
+    ) {
40
+        parent::__construct();
41
+    }
42 42
 
43
-	protected function configure() {
44
-		$this
45
-			->setName('migrations:status')
46
-			->setDescription('View the status of a set of migrations.')
47
-			->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on');
48
-	}
43
+    protected function configure() {
44
+        $this
45
+            ->setName('migrations:status')
46
+            ->setDescription('View the status of a set of migrations.')
47
+            ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on');
48
+    }
49 49
 
50
-	public function execute(InputInterface $input, OutputInterface $output): int {
51
-		$appName = $input->getArgument('app');
52
-		$ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
50
+    public function execute(InputInterface $input, OutputInterface $output): int {
51
+        $appName = $input->getArgument('app');
52
+        $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
53 53
 
54
-		$infos = $this->getMigrationsInfos($ms);
55
-		foreach ($infos as $key => $value) {
56
-			if (is_array($value)) {
57
-				$output->writeln("    <comment>>></comment> $key:");
58
-				foreach ($value as $subKey => $subValue) {
59
-					$output->writeln("        <comment>>></comment> $subKey: " . str_repeat(' ', 46 - strlen($subKey)) . $subValue);
60
-				}
61
-			} else {
62
-				$output->writeln("    <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value);
63
-			}
64
-		}
65
-		return 0;
66
-	}
54
+        $infos = $this->getMigrationsInfos($ms);
55
+        foreach ($infos as $key => $value) {
56
+            if (is_array($value)) {
57
+                $output->writeln("    <comment>>></comment> $key:");
58
+                foreach ($value as $subKey => $subValue) {
59
+                    $output->writeln("        <comment>>></comment> $subKey: " . str_repeat(' ', 46 - strlen($subKey)) . $subValue);
60
+                }
61
+            } else {
62
+                $output->writeln("    <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value);
63
+            }
64
+        }
65
+        return 0;
66
+    }
67 67
 
68
-	/**
69
-	 * @param string $optionName
70
-	 * @param CompletionContext $context
71
-	 * @return string[]
72
-	 */
73
-	public function completeOptionValues($optionName, CompletionContext $context) {
74
-		return [];
75
-	}
68
+    /**
69
+     * @param string $optionName
70
+     * @param CompletionContext $context
71
+     * @return string[]
72
+     */
73
+    public function completeOptionValues($optionName, CompletionContext $context) {
74
+        return [];
75
+    }
76 76
 
77
-	/**
78
-	 * @param string $argumentName
79
-	 * @param CompletionContext $context
80
-	 * @return string[]
81
-	 */
82
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
83
-		if ($argumentName === 'app') {
84
-			$allApps = \OC_App::getAllApps();
85
-			return array_diff($allApps, \OC_App::getEnabledApps(true, true));
86
-		}
87
-		return [];
88
-	}
77
+    /**
78
+     * @param string $argumentName
79
+     * @param CompletionContext $context
80
+     * @return string[]
81
+     */
82
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
83
+        if ($argumentName === 'app') {
84
+            $allApps = \OC_App::getAllApps();
85
+            return array_diff($allApps, \OC_App::getEnabledApps(true, true));
86
+        }
87
+        return [];
88
+    }
89 89
 
90
-	/**
91
-	 * @param MigrationService $ms
92
-	 * @return array associative array of human readable info name as key and the actual information as value
93
-	 */
94
-	public function getMigrationsInfos(MigrationService $ms) {
95
-		$executedMigrations = $ms->getMigratedVersions();
96
-		$availableMigrations = $ms->getAvailableVersions();
97
-		$executedUnavailableMigrations = array_diff($executedMigrations, array_keys($availableMigrations));
90
+    /**
91
+     * @param MigrationService $ms
92
+     * @return array associative array of human readable info name as key and the actual information as value
93
+     */
94
+    public function getMigrationsInfos(MigrationService $ms) {
95
+        $executedMigrations = $ms->getMigratedVersions();
96
+        $availableMigrations = $ms->getAvailableVersions();
97
+        $executedUnavailableMigrations = array_diff($executedMigrations, array_keys($availableMigrations));
98 98
 
99
-		$numExecutedUnavailableMigrations = count($executedUnavailableMigrations);
100
-		$numNewMigrations = count(array_diff(array_keys($availableMigrations), $executedMigrations));
101
-		$pending = $ms->describeMigrationStep('lastest');
99
+        $numExecutedUnavailableMigrations = count($executedUnavailableMigrations);
100
+        $numNewMigrations = count(array_diff(array_keys($availableMigrations), $executedMigrations));
101
+        $pending = $ms->describeMigrationStep('lastest');
102 102
 
103
-		$infos = [
104
-			'App' => $ms->getApp(),
105
-			'Version Table Name' => $ms->getMigrationsTableName(),
106
-			'Migrations Namespace' => $ms->getMigrationsNamespace(),
107
-			'Migrations Directory' => $ms->getMigrationsDirectory(),
108
-			'Previous Version' => $this->getFormattedVersionAlias($ms, 'prev'),
109
-			'Current Version' => $this->getFormattedVersionAlias($ms, 'current'),
110
-			'Next Version' => $this->getFormattedVersionAlias($ms, 'next'),
111
-			'Latest Version' => $this->getFormattedVersionAlias($ms, 'latest'),
112
-			'Executed Migrations' => count($executedMigrations),
113
-			'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations,
114
-			'Available Migrations' => count($availableMigrations),
115
-			'New Migrations' => $numNewMigrations,
116
-			'Pending Migrations' => count($pending) ? $pending : 'None'
117
-		];
103
+        $infos = [
104
+            'App' => $ms->getApp(),
105
+            'Version Table Name' => $ms->getMigrationsTableName(),
106
+            'Migrations Namespace' => $ms->getMigrationsNamespace(),
107
+            'Migrations Directory' => $ms->getMigrationsDirectory(),
108
+            'Previous Version' => $this->getFormattedVersionAlias($ms, 'prev'),
109
+            'Current Version' => $this->getFormattedVersionAlias($ms, 'current'),
110
+            'Next Version' => $this->getFormattedVersionAlias($ms, 'next'),
111
+            'Latest Version' => $this->getFormattedVersionAlias($ms, 'latest'),
112
+            'Executed Migrations' => count($executedMigrations),
113
+            'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations,
114
+            'Available Migrations' => count($availableMigrations),
115
+            'New Migrations' => $numNewMigrations,
116
+            'Pending Migrations' => count($pending) ? $pending : 'None'
117
+        ];
118 118
 
119
-		return $infos;
120
-	}
119
+        return $infos;
120
+    }
121 121
 
122
-	/**
123
-	 * @param MigrationService $migrationService
124
-	 * @param string $alias
125
-	 * @return mixed|null|string
126
-	 */
127
-	private function getFormattedVersionAlias(MigrationService $migrationService, $alias) {
128
-		$migration = $migrationService->getMigration($alias);
129
-		//No version found
130
-		if ($migration === null) {
131
-			if ($alias === 'next') {
132
-				return 'Already at latest migration step';
133
-			}
122
+    /**
123
+     * @param MigrationService $migrationService
124
+     * @param string $alias
125
+     * @return mixed|null|string
126
+     */
127
+    private function getFormattedVersionAlias(MigrationService $migrationService, $alias) {
128
+        $migration = $migrationService->getMigration($alias);
129
+        //No version found
130
+        if ($migration === null) {
131
+            if ($alias === 'next') {
132
+                return 'Already at latest migration step';
133
+            }
134 134
 
135
-			if ($alias === 'prev') {
136
-				return 'Already at first migration step';
137
-			}
138
-		}
135
+            if ($alias === 'prev') {
136
+                return 'Already at first migration step';
137
+            }
138
+        }
139 139
 
140
-		return $migration;
141
-	}
140
+        return $migration;
141
+    }
142 142
 }
Please login to merge, or discard this patch.
core/Command/Security/ListCertificates.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	protected function execute(InputInterface $input, OutputInterface $output): int {
54 54
 		$outputType = $input->getOption('output');
55 55
 		if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) {
56
-			$certificates = array_map(function (ICertificate $certificate) {
56
+			$certificates = array_map(function(ICertificate $certificate) {
57 57
 				return [
58 58
 					'name' => $certificate->getName(),
59 59
 					'common_name' => $certificate->getCommonName(),
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 				'Issued By'
80 80
 			]);
81 81
 
82
-			$rows = array_map(function (ICertificate $certificate) {
82
+			$rows = array_map(function(ICertificate $certificate) {
83 83
 				return [
84 84
 					$certificate->getName(),
85 85
 					$certificate->getCommonName(),
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -17,64 +17,64 @@
 block discarded – undo
17 17
 use Symfony\Component\Console\Output\OutputInterface;
18 18
 
19 19
 class ListCertificates extends Base {
20
-	protected IL10N $l;
20
+    protected IL10N $l;
21 21
 
22
-	public function __construct(
23
-		protected ICertificateManager $certificateManager,
24
-		IL10NFactory $l10nFactory,
25
-	) {
26
-		parent::__construct();
27
-		$this->l = $l10nFactory->get('core');
28
-	}
22
+    public function __construct(
23
+        protected ICertificateManager $certificateManager,
24
+        IL10NFactory $l10nFactory,
25
+    ) {
26
+        parent::__construct();
27
+        $this->l = $l10nFactory->get('core');
28
+    }
29 29
 
30
-	protected function configure() {
31
-		$this
32
-			->setName('security:certificates')
33
-			->setDescription('list trusted certificates');
34
-		parent::configure();
35
-	}
30
+    protected function configure() {
31
+        $this
32
+            ->setName('security:certificates')
33
+            ->setDescription('list trusted certificates');
34
+        parent::configure();
35
+    }
36 36
 
37
-	protected function execute(InputInterface $input, OutputInterface $output): int {
38
-		$outputType = $input->getOption('output');
39
-		if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) {
40
-			$certificates = array_map(function (ICertificate $certificate) {
41
-				return [
42
-					'name' => $certificate->getName(),
43
-					'common_name' => $certificate->getCommonName(),
44
-					'organization' => $certificate->getOrganization(),
45
-					'expire' => $certificate->getExpireDate()->format(\DateTimeInterface::ATOM),
46
-					'issuer' => $certificate->getIssuerName(),
47
-					'issuer_organization' => $certificate->getIssuerOrganization(),
48
-					'issue_date' => $certificate->getIssueDate()->format(\DateTimeInterface::ATOM)
49
-				];
50
-			}, $this->certificateManager->listCertificates());
51
-			if ($outputType === self::OUTPUT_FORMAT_JSON) {
52
-				$output->writeln(json_encode(array_values($certificates)));
53
-			} else {
54
-				$output->writeln(json_encode(array_values($certificates), JSON_PRETTY_PRINT));
55
-			}
56
-		} else {
57
-			$table = new Table($output);
58
-			$table->setHeaders([
59
-				'File Name',
60
-				'Common Name',
61
-				'Organization',
62
-				'Valid Until',
63
-				'Issued By'
64
-			]);
37
+    protected function execute(InputInterface $input, OutputInterface $output): int {
38
+        $outputType = $input->getOption('output');
39
+        if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) {
40
+            $certificates = array_map(function (ICertificate $certificate) {
41
+                return [
42
+                    'name' => $certificate->getName(),
43
+                    'common_name' => $certificate->getCommonName(),
44
+                    'organization' => $certificate->getOrganization(),
45
+                    'expire' => $certificate->getExpireDate()->format(\DateTimeInterface::ATOM),
46
+                    'issuer' => $certificate->getIssuerName(),
47
+                    'issuer_organization' => $certificate->getIssuerOrganization(),
48
+                    'issue_date' => $certificate->getIssueDate()->format(\DateTimeInterface::ATOM)
49
+                ];
50
+            }, $this->certificateManager->listCertificates());
51
+            if ($outputType === self::OUTPUT_FORMAT_JSON) {
52
+                $output->writeln(json_encode(array_values($certificates)));
53
+            } else {
54
+                $output->writeln(json_encode(array_values($certificates), JSON_PRETTY_PRINT));
55
+            }
56
+        } else {
57
+            $table = new Table($output);
58
+            $table->setHeaders([
59
+                'File Name',
60
+                'Common Name',
61
+                'Organization',
62
+                'Valid Until',
63
+                'Issued By'
64
+            ]);
65 65
 
66
-			$rows = array_map(function (ICertificate $certificate) {
67
-				return [
68
-					$certificate->getName(),
69
-					$certificate->getCommonName(),
70
-					$certificate->getOrganization(),
71
-					$this->l->l('date', $certificate->getExpireDate()),
72
-					$certificate->getIssuerName()
73
-				];
74
-			}, $this->certificateManager->listCertificates());
75
-			$table->setRows($rows);
76
-			$table->render();
77
-		}
78
-		return 0;
79
-	}
66
+            $rows = array_map(function (ICertificate $certificate) {
67
+                return [
68
+                    $certificate->getName(),
69
+                    $certificate->getCommonName(),
70
+                    $certificate->getOrganization(),
71
+                    $this->l->l('date', $certificate->getExpireDate()),
72
+                    $certificate->getIssuerName()
73
+                ];
74
+            }, $this->certificateManager->listCertificates());
75
+            $table->setRows($rows);
76
+            $table->render();
77
+        }
78
+        return 0;
79
+    }
80 80
 }
Please login to merge, or discard this patch.