Skip to content

Commit a21dac1

Browse files
committed
fix: Fix all property, param and return types
Signed-off-by: provokateurin <[email protected]>
1 parent c96c883 commit a21dac1

File tree

69 files changed

+400
-722
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+400
-722
lines changed

β€Žlib/ACL/ACLCacheWrapper.php

+16-17
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@
1515
use OCP\Files\Search\ISearchQuery;
1616

1717
class ACLCacheWrapper extends CacheWrapper {
18-
private ACLManager $aclManager;
19-
private bool $inShare;
18+
public function __construct(
19+
ICache $cache,
20+
private ACLManager $aclManager,
21+
private bool $inShare,
22+
) {
23+
parent::__construct($cache);
24+
}
2025

21-
private function getACLPermissionsForPath(string $path, array $rules = []) {
26+
private function getACLPermissionsForPath(string $path, array $rules = []): int {
2227
if ($rules) {
2328
$permissions = $this->aclManager->getPermissionsForPathFromRules($path, $rules);
2429
} else {
@@ -37,13 +42,7 @@ private function getACLPermissionsForPath(string $path, array $rules = []) {
3742
return $canRead ? $permissions : 0;
3843
}
3944

40-
public function __construct(ICache $cache, ACLManager $aclManager, bool $inShare) {
41-
parent::__construct($cache);
42-
$this->aclManager = $aclManager;
43-
$this->inShare = $inShare;
44-
}
45-
46-
protected function formatCacheEntry($entry, array $rules = []) {
45+
protected function formatCacheEntry($entry, array $rules = []): ICacheEntry|false {
4746
if (isset($entry['permissions'])) {
4847
$entry['scan_permissions'] = $entry['permissions'];
4948
$entry['permissions'] &= $this->getACLPermissionsForPath($entry['path'], $rules);
@@ -55,30 +54,30 @@ protected function formatCacheEntry($entry, array $rules = []) {
5554
return $entry;
5655
}
5756

58-
public function getFolderContentsById($fileId) {
57+
public function getFolderContentsById($fileId): array {
5958
$results = $this->getCache()->getFolderContentsById($fileId);
6059
$rules = $this->preloadEntries($results);
6160

62-
return array_filter(array_map(function ($entry) use ($rules) {
61+
return array_filter(array_map(function (ICacheEntry $entry) use ($rules): ICacheEntry|false {
6362
return $this->formatCacheEntry($entry, $rules);
6463
}, $results));
6564
}
6665

67-
public function search($pattern) {
66+
public function search($pattern): array {
6867
$results = $this->getCache()->search($pattern);
6968
$this->preloadEntries($results);
7069

7170
return array_filter(array_map($this->formatCacheEntry(...), $results));
7271
}
7372

74-
public function searchByMime($mimetype) {
73+
public function searchByMime($mimetype): array {
7574
$results = $this->getCache()->searchByMime($mimetype);
7675
$this->preloadEntries($results);
7776

7877
return array_filter(array_map($this->formatCacheEntry(...), $results));
7978
}
8079

81-
public function searchQuery(ISearchQuery $query) {
80+
public function searchQuery(ISearchQuery $query): array {
8281
$results = $this->getCache()->searchQuery($query);
8382
$this->preloadEntries($results);
8483

@@ -87,10 +86,10 @@ public function searchQuery(ISearchQuery $query) {
8786

8887
/**
8988
* @param ICacheEntry[] $entries
90-
* @return Rule[][]
89+
* @return array<string, Rule[]>
9190
*/
9291
private function preloadEntries(array $entries): array {
93-
$paths = array_map(function (ICacheEntry $entry) {
92+
$paths = array_map(function (ICacheEntry $entry): string {
9493
return $entry->getPath();
9594
}, $entries);
9695

β€Žlib/ACL/ACLManager.php

+5-15
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,17 @@
1717

1818
class ACLManager {
1919
private CappedMemoryCache $ruleCache;
20-
/** @var callable */
21-
private $rootFolderProvider;
2220

2321
public function __construct(
24-
private RuleManager $ruleManager,
22+
private RuleManager $ruleManager,
2523
private TrashManager $trashManager,
2624
private LoggerInterface $logger,
27-
private IUser $user,
28-
callable $rootFolderProvider,
29-
private ?int $rootStorageId = null,
30-
private bool $inheritMergePerUser = false,
25+
private IUser $user,
26+
private \Closure $rootFolderProvider,
27+
private ?int $rootStorageId = null,
28+
private bool $inheritMergePerUser = false,
3129
) {
3230
$this->ruleCache = new CappedMemoryCache();
33-
$this->rootFolderProvider = $rootFolderProvider;
3431
}
3532

3633
private function getRootStorageId(): int {
@@ -84,7 +81,6 @@ private function getRules(array $paths, bool $cache = true): array {
8481
*
8582
* This contains the $path itself and any parent folder
8683
*
87-
* @param string $path
8884
* @return string[]
8985
*/
9086
private function getRelevantPaths(string $path): array {
@@ -147,9 +143,7 @@ public function getACLPermissionsForPath(string $path): int {
147143
}
148144

149145
/**
150-
* @param string $path
151146
* @param array<string, Rule[]> $rules list of rules per path
152-
* @return int
153147
*/
154148
public function getPermissionsForPathFromRules(string $path, array $rules): int {
155149
$path = ltrim($path, '/');
@@ -161,7 +155,6 @@ public function getPermissionsForPathFromRules(string $path, array $rules): int
161155

162156
/**
163157
* @param array<string, Rule[]> $rules list of rules per path, sorted parent first
164-
* @return int
165158
*/
166159
private function calculatePermissionsForPath(array $rules): int {
167160
// given the following rules
@@ -212,9 +205,6 @@ private function calculatePermissionsForPath(array $rules): int {
212205

213206
/**
214207
* Get the combined "lowest" permissions for an entire directory tree
215-
*
216-
* @param string $path
217-
* @return int
218208
*/
219209
public function getPermissionsForTree(string $path): int {
220210
$path = ltrim($path, '/');

β€Žlib/ACL/ACLManagerFactory.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@
1414
use Psr\Log\LoggerInterface;
1515

1616
class ACLManagerFactory {
17-
private $rootFolderProvider;
18-
1917
public function __construct(
2018
private RuleManager $ruleManager,
2119
private TrashManager $trashManager,
2220
private IConfig $config,
2321
private LoggerInterface $logger,
24-
callable $rootFolderProvider,
22+
private \Closure $rootFolderProvider,
2523
) {
26-
$this->rootFolderProvider = $rootFolderProvider;
2724
}
2825

2926
public function getACLManager(IUser $user, ?int $rootStorageId = null): ACLManager {

0 commit comments

Comments
Β (0)