Skip to content

Commit

Permalink
Merge pull request #1522 from nextcloud/chore/1518
Browse files Browse the repository at this point in the history
chore: Add return types of storage wrapper
  • Loading branch information
max-nextcloud authored Oct 14, 2024
2 parents 99395c3 + df190af commit e804ce0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/behat-sqlite-encryption.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ jobs:

- name: Install composer dependencies
working-directory: apps/${{ env.APP_NAME }}
run: composer i
run: |
composer i
# remove as those dev dependencies pull in an outdated psr/log
composer remove --dev nextcloud/ocp
- name: Set up Nextcloud
env:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/behat-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ jobs:

- name: Install composer dependencies
working-directory: apps/${{ env.APP_NAME }}
run: composer i
run: |
composer i
# remove as those dev dependencies pull in an outdated psr/log
composer remove --dev nextcloud/ocp
- name: Set up Nextcloud
env:
Expand Down
24 changes: 12 additions & 12 deletions lib/ACL/ACLStorageWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
namespace OCA\Collectives\ACL;

use OC\Files\Cache\Cache;
use OC\Files\Cache\Scanner;
use OC\Files\Cache\Wrapper\CacheWrapper;
use OC\Files\Storage\Wrapper\Wrapper;
use OCP\Constants;
use OCP\Files\Cache\IScanner;
use Traversable;

class ACLStorageWrapper extends Wrapper {
Expand Down Expand Up @@ -60,7 +60,7 @@ public function isSharable($path): bool {
return $this->checkPermissions(Constants::PERMISSION_SHARE) && parent::isSharable($path);
}

public function getPermissions($path) {
public function getPermissions($path): int {
return $this->storage->getPermissions($path) & $this->permissions;
}

Expand Down Expand Up @@ -110,7 +110,7 @@ public function unlink($path): bool {
return $this->checkPermissions(Constants::PERMISSION_DELETE) && parent::unlink($path);
}

public function file_put_contents($path, $data) {
public function file_put_contents($path, $data): int|float|false {
$permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE;
return $this->checkPermissions($permissions) ? parent::file_put_contents($path, $data) : false;
}
Expand Down Expand Up @@ -147,7 +147,7 @@ public function getMetaData($path): ?array {
return $data;
}

public function getScanner($path = '', $storage = null): Scanner {
public function getScanner($path = '', $storage = null): IScanner {
if (!$storage) {
$storage = $this->storage;
}
Expand All @@ -164,14 +164,14 @@ public function is_file($path): bool {
parent::is_file($path);
}

public function stat($path) {
public function stat($path): array|false {
if (!$this->checkPermissions(Constants::PERMISSION_READ)) {
return false;
}
return parent::stat($path);
}

public function filetype($path) {
public function filetype($path): string|false {
if (!$this->checkPermissions(Constants::PERMISSION_READ)) {
return false;
}
Expand All @@ -182,42 +182,42 @@ public function file_exists($path): bool {
return $this->checkPermissions(Constants::PERMISSION_READ) && parent::file_exists($path);
}

public function filemtime($path) {
public function filemtime($path): int|false {
if (!$this->checkPermissions(Constants::PERMISSION_READ)) {
return false;
}
return parent::filemtime($path);
}

public function file_get_contents($path) {
public function file_get_contents($path): string|false {
if (!$this->checkPermissions(Constants::PERMISSION_READ)) {
return false;
}
return parent::file_get_contents($path);
}

public function getMimeType($path) {
public function getMimeType($path): string|false {
if (!$this->checkPermissions(Constants::PERMISSION_READ)) {
return false;
}
return parent::getMimeType($path);
}

public function hash($type, $path, $raw = false) {
public function hash($type, $path, $raw = false): string|false {
if (!$this->checkPermissions(Constants::PERMISSION_READ)) {
return false;
}
return parent::hash($type, $path, $raw);
}

public function getETag($path) {
public function getETag($path): string|false {
if (!$this->checkPermissions(Constants::PERMISSION_READ)) {
return false;
}
return parent::getETag($path);
}

public function getDirectDownload($path) {
public function getDirectDownload($path): array|false {
if (!$this->checkPermissions(Constants::PERMISSION_READ)) {
return false;
}
Expand Down

0 comments on commit e804ce0

Please sign in to comment.