Skip to content

Commit eb1af0a

Browse files
committed
FilesPlugin/SymlinkPlugin/SymlinkManager: Fix some style guide violations and warnings
1 parent 46e67a0 commit eb1af0a

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

apps/dav/lib/Connector/Sabre/FilesPlugin.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,12 @@ public function handleDownloadToken(RequestInterface $request, ResponseInterface
229229
}
230230
}
231231

232-
public function httpGet(RequestInterface $request, ResponseInterface $response) {
232+
public function httpGet(RequestInterface $request, ResponseInterface $response): bool {
233233
// only handle symlinks
234234
$node = $this->tree->getNodeForPath($request->getPath());
235-
if (!($node instanceof \OCA\DAV\Connector\Sabre\File && $this->symlinkManager->isSymlink($node->getFileInfo()))) {
236-
return;
235+
if (!($node instanceof \OCA\DAV\Connector\Sabre\File
236+
&& $this->symlinkManager->isSymlink($node->getFileInfo()))) {
237+
return true;
237238
}
238239

239240
$date = \DateTime::createFromFormat('U', $node->getLastModified());
@@ -255,7 +256,7 @@ public function httpGet(RequestInterface $request, ResponseInterface $response)
255256
* @param RequestInterface $request
256257
* @param ResponseInterface $response
257258
*/
258-
public function afterHttpGet(RequestInterface $request, ResponseInterface $response) {
259+
public function afterHttpGet(RequestInterface $request, ResponseInterface $response): void {
259260
// Only handle valid files
260261
$node = $this->tree->getNodeForPath($request->getPath());
261262
if (!($node instanceof IFile)) {

apps/dav/lib/Upload/SymlinkPlugin.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232
use Sabre\HTTP\ResponseInterface;
3333

3434
class SymlinkPlugin extends ServerPlugin {
35-
/** @var Server */
35+
/**
36+
* @var Server
37+
*
38+
* @psalm-suppress PropertyNotSetInConstructor
39+
*/
3640
private $server;
3741
/** @var SymlinkManager */
3842
private $symlinkManager;
@@ -44,7 +48,7 @@ public function __construct() {
4448
/**
4549
* @inheritdoc
4650
*/
47-
public function initialize(Server $server) {
51+
public function initialize(Server $server): void {
4852
$server->on('method:PUT', [$this, 'httpPut']);
4953
$server->on('method:DELETE', [$this, 'httpDelete']);
5054
$server->on('afterMove', [$this, 'afterMove']);
@@ -70,7 +74,9 @@ public function httpPut(RequestInterface $request, ResponseInterface $response):
7074
$symlinkNode->put($symlinkTarget);
7175
$this->symlinkManager->storeSymlink($symlinkNode->getFileInfo());
7276

73-
$response->setHeader("OC-ETag", $etag);
77+
if ($etag) {
78+
$response->setHeader('OC-ETag', $etag);
79+
}
7480
$response->setStatus(201);
7581
return false; // this request was handled already
7682
} else {

lib/private/Files/SymlinkManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private function updateSymlink($node) {
146146
->set('storage', $query->createNamedParameter($storageId))
147147
->set('path', $query->createNamedParameter($path));
148148
if ($query->executeStatement() != 1) {
149-
throw new \OCP\DB\Exception("Invalid number of rows changed while updating symlink!");
149+
throw new \OCP\DB\Exception('Invalid number of rows changed while updating symlink!');
150150
}
151151
}
152152

@@ -164,7 +164,7 @@ private function insertSymlink($node) {
164164
->setValue('storage', $query->createNamedParameter($storageId))
165165
->setValue('path', $query->createNamedParameter($path));
166166
if ($query->executeStatement() != 1) {
167-
throw new \OCP\DB\Exception("Invalid number of rows changed while inserting symlink!");
167+
throw new \OCP\DB\Exception('Invalid number of rows changed while inserting symlink!');
168168
}
169169
}
170170

@@ -179,7 +179,7 @@ private function deleteSymlinkById($id) {
179179
->where($query->expr()->eq('id', $query->createNamedParameter($id)));
180180
$rowsChanged = $query->executeStatement();
181181
if ($rowsChanged > 1) {
182-
throw new \OCP\DB\Exception("Too many symlink rows deleted!");
182+
throw new \OCP\DB\Exception('Too many symlink rows deleted!');
183183
}
184184
return $rowsChanged == 1;
185185
}

0 commit comments

Comments
 (0)