Skip to content

Commit 53fb05e

Browse files
committed
fix(nullcache): make get compliant with the interface
The interface defines ICacheEntry|false, thus we should not return null. Signed-off-by: Daniel Kesselberg <[email protected]>
1 parent 894f963 commit 53fb05e

3 files changed

Lines changed: 18 additions & 34 deletions

File tree

build/psalm-baseline.xml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4112,31 +4112,12 @@
41124112
</InvalidOperand>
41134113
</file>
41144114
<file src="lib/private/Lockdown/Filesystem/NullCache.php">
4115-
<InvalidNullableReturnType>
4116-
<code><![CDATA[get]]></code>
4117-
</InvalidNullableReturnType>
41184115
<InvalidReturnStatement>
41194116
<code><![CDATA[[]]]></code>
41204117
</InvalidReturnStatement>
41214118
<InvalidReturnType>
41224119
<code><![CDATA[getIncomplete]]></code>
41234120
</InvalidReturnType>
4124-
<NullableReturnStatement>
4125-
<code><![CDATA[$file !== '' ? null :
4126-
new CacheEntry([
4127-
'fileid' => -1,
4128-
'parent' => -1,
4129-
'name' => '',
4130-
'path' => '',
4131-
'size' => '0',
4132-
'mtime' => time(),
4133-
'storage_mtime' => time(),
4134-
'etag' => '',
4135-
'mimetype' => FileInfo::MIMETYPE_FOLDER,
4136-
'mimepart' => 'httpd',
4137-
'permissions' => Constants::PERMISSION_READ
4138-
])]]></code>
4139-
</NullableReturnStatement>
41404121
</file>
41414122
<file src="lib/private/Lockdown/Filesystem/NullStorage.php">
41424123
<TooManyArguments>

lib/private/Lockdown/Filesystem/NullCache.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,23 @@ public function getNumericStorageId() {
2121
}
2222

2323
public function get($file) {
24-
return $file !== '' ? null :
25-
new CacheEntry([
26-
'fileid' => -1,
27-
'parent' => -1,
28-
'name' => '',
29-
'path' => '',
30-
'size' => '0',
31-
'mtime' => time(),
32-
'storage_mtime' => time(),
33-
'etag' => '',
34-
'mimetype' => FileInfo::MIMETYPE_FOLDER,
35-
'mimepart' => 'httpd',
36-
'permissions' => Constants::PERMISSION_READ
37-
]);
24+
if ($file !== '') {
25+
return false;
26+
}
27+
28+
return new CacheEntry([
29+
'fileid' => -1,
30+
'parent' => -1,
31+
'name' => '',
32+
'path' => '',
33+
'size' => '0',
34+
'mtime' => time(),
35+
'storage_mtime' => time(),
36+
'etag' => '',
37+
'mimetype' => FileInfo::MIMETYPE_FOLDER,
38+
'mimepart' => 'httpd',
39+
'permissions' => Constants::PERMISSION_READ
40+
]);
3841
}
3942

4043
public function getFolderContents($folder) {

tests/lib/Lockdown/Filesystem/NullCacheTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testGetNumericStorageId(): void {
2727
}
2828

2929
public function testGetEmpty(): void {
30-
$this->assertNull($this->cache->get('foo'));
30+
$this->assertFalse($this->cache->get('foo'));
3131
}
3232

3333
public function testGet(): void {

0 commit comments

Comments
 (0)