Merge pull request #53678 from nextcloud/debt/noid/wrong-return-type-nullcache

This commit is contained in:
John Molakvoæ 2025-06-26 12:44:40 +02:00 committed by GitHub
commit beae65ae39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 34 deletions

View file

@ -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>

View file

@ -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) {

View file

@ -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 {