fix(nullcache): make get compliant with the interface

The interface defines ICacheEntry|false, thus we should not return null.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
pull/53678/head
Daniel Kesselberg 2025-06-25 14:37:39 +07:00
parent 894f963804
commit 53fb05e2d0
No known key found for this signature in database
GPG Key ID: 4A81C29F63464E8F
3 changed files with 18 additions and 34 deletions

@ -4112,31 +4112,12 @@
</InvalidOperand>
</file>
<file src="lib/private/Lockdown/Filesystem/NullCache.php">
<InvalidNullableReturnType>
<code><![CDATA[get]]></code>
</InvalidNullableReturnType>
<InvalidReturnStatement>
<code><![CDATA[[]]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
<code><![CDATA[getIncomplete]]></code>
</InvalidReturnType>
<NullableReturnStatement>
<code><![CDATA[$file !== '' ? null :
new CacheEntry([
'fileid' => -1,
'parent' => -1,
'name' => '',
'path' => '',
'size' => '0',
'mtime' => time(),
'storage_mtime' => time(),
'etag' => '',
'mimetype' => FileInfo::MIMETYPE_FOLDER,
'mimepart' => 'httpd',
'permissions' => Constants::PERMISSION_READ
])]]></code>
</NullableReturnStatement>
</file>
<file src="lib/private/Lockdown/Filesystem/NullStorage.php">
<TooManyArguments>

@ -21,20 +21,23 @@ class NullCache implements ICache {
}
public function get($file) {
return $file !== '' ? null :
new CacheEntry([
'fileid' => -1,
'parent' => -1,
'name' => '',
'path' => '',
'size' => '0',
'mtime' => time(),
'storage_mtime' => time(),
'etag' => '',
'mimetype' => FileInfo::MIMETYPE_FOLDER,
'mimepart' => 'httpd',
'permissions' => Constants::PERMISSION_READ
]);
if ($file !== '') {
return false;
}
return new CacheEntry([
'fileid' => -1,
'parent' => -1,
'name' => '',
'path' => '',
'size' => '0',
'mtime' => time(),
'storage_mtime' => time(),
'etag' => '',
'mimetype' => FileInfo::MIMETYPE_FOLDER,
'mimepart' => 'httpd',
'permissions' => Constants::PERMISSION_READ
]);
}
public function getFolderContents($folder) {

@ -27,7 +27,7 @@ class NulLCacheTest extends \Test\TestCase {
}
public function testGetEmpty(): void {
$this->assertNull($this->cache->get('foo'));
$this->assertFalse($this->cache->get('foo'));
}
public function testGet(): void {