15
15
use OCP \Files \Search \ISearchQuery ;
16
16
17
17
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
+ }
20
25
21
- private function getACLPermissionsForPath (string $ path , array $ rules = []) {
26
+ private function getACLPermissionsForPath (string $ path , array $ rules = []): int {
22
27
if ($ rules ) {
23
28
$ permissions = $ this ->aclManager ->getPermissionsForPathFromRules ($ path , $ rules );
24
29
} else {
@@ -37,13 +42,7 @@ private function getACLPermissionsForPath(string $path, array $rules = []) {
37
42
return $ canRead ? $ permissions : 0 ;
38
43
}
39
44
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 {
47
46
if (isset ($ entry ['permissions ' ])) {
48
47
$ entry ['scan_permissions ' ] = $ entry ['permissions ' ];
49
48
$ entry ['permissions ' ] &= $ this ->getACLPermissionsForPath ($ entry ['path ' ], $ rules );
@@ -55,30 +54,30 @@ protected function formatCacheEntry($entry, array $rules = []) {
55
54
return $ entry ;
56
55
}
57
56
58
- public function getFolderContentsById ($ fileId ) {
57
+ public function getFolderContentsById ($ fileId ): array {
59
58
$ results = $ this ->getCache ()->getFolderContentsById ($ fileId );
60
59
$ rules = $ this ->preloadEntries ($ results );
61
60
62
- return array_filter (array_map (function ($ entry ) use ($ rules ) {
61
+ return array_filter (array_map (function (ICacheEntry $ entry ) use ($ rules ): ICacheEntry | false {
63
62
return $ this ->formatCacheEntry ($ entry , $ rules );
64
63
}, $ results ));
65
64
}
66
65
67
- public function search ($ pattern ) {
66
+ public function search ($ pattern ): array {
68
67
$ results = $ this ->getCache ()->search ($ pattern );
69
68
$ this ->preloadEntries ($ results );
70
69
71
70
return array_filter (array_map ($ this ->formatCacheEntry (...), $ results ));
72
71
}
73
72
74
- public function searchByMime ($ mimetype ) {
73
+ public function searchByMime ($ mimetype ): array {
75
74
$ results = $ this ->getCache ()->searchByMime ($ mimetype );
76
75
$ this ->preloadEntries ($ results );
77
76
78
77
return array_filter (array_map ($ this ->formatCacheEntry (...), $ results ));
79
78
}
80
79
81
- public function searchQuery (ISearchQuery $ query ) {
80
+ public function searchQuery (ISearchQuery $ query ): array {
82
81
$ results = $ this ->getCache ()->searchQuery ($ query );
83
82
$ this ->preloadEntries ($ results );
84
83
@@ -87,10 +86,10 @@ public function searchQuery(ISearchQuery $query) {
87
86
88
87
/**
89
88
* @param ICacheEntry[] $entries
90
- * @return Rule[][]
89
+ * @return array<string, Rule[]>
91
90
*/
92
91
private function preloadEntries (array $ entries ): array {
93
- $ paths = array_map (function (ICacheEntry $ entry ) {
92
+ $ paths = array_map (function (ICacheEntry $ entry ): string {
94
93
return $ entry ->getPath ();
95
94
}, $ entries );
96
95
0 commit comments