Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add return types of storage wrapper #1522

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .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 All @@ -116,7 +119,9 @@ jobs:

- name: Behat integration
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/bin/behat --config=${{ env.BEHAT_CONFIG }} --profile ci
run: |
tail -f ../../data/nextcloud.log &
./vendor/bin/behat --config=${{ env.BEHAT_CONFIG }} --profile ci

summary:
permissions:
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
Loading