Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
chore(files): Use public API where possible
This is not fixing all issues in the helper,
but at least where possible use the public methods.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Sep 5, 2024
commit ede38709b5df0ede2542a3f62ee0a5e72243ba40
25 changes: 14 additions & 11 deletions apps/files/lib/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,18 @@ public static function compareSize(FileInfo $a, FileInfo $b) {
public static function formatFileInfo(FileInfo $i) {
$entry = [];

$entry['id'] = $i['fileid'];
$entry['parentId'] = $i['parent'];
$entry['mtime'] = $i['mtime'] * 1000;
$entry['id'] = $i->getId();
$entry['parentId'] = $i->getParentId();
$entry['mtime'] = $i->getMtime() * 1000;
// only pick out the needed attributes
$entry['name'] = $i->getName();
$entry['permissions'] = $i['permissions'];
$entry['mimetype'] = $i['mimetype'];
$entry['size'] = $i['size'];
$entry['type'] = $i['type'];
$entry['etag'] = $i['etag'];
$entry['permissions'] = $i->getPermissions();
$entry['mimetype'] = $i->getMimetype();
$entry['size'] = $i->getSize();
$entry['type'] = $i->getType();
$entry['etag'] = $i->getEtag();
// TODO: this is using the private implementation of FileInfo
// the array access is not part of the public interface
if (isset($i['tags'])) {
$entry['tags'] = $i['tags'];
}
Expand All @@ -138,6 +140,10 @@ public static function formatFileInfo(FileInfo $i) {
if (isset($i['is_share_mount_point'])) {
$entry['isShareMountPoint'] = $i['is_share_mount_point'];
}
if (isset($i['extraData'])) {

Check notice

Code scanning / Psalm

UndefinedInterfaceMethod

Method OCP\Files\FileInfo::offsetGet does not exist
$entry['extraData'] = $i['extraData'];
}

$mountType = null;
$mount = $i->getMountPoint();
$mountType = $mount->getMountType();
Expand All @@ -147,9 +153,6 @@ public static function formatFileInfo(FileInfo $i) {
}
$entry['mountType'] = $mountType;
}
if (isset($i['extraData'])) {
$entry['extraData'] = $i['extraData'];
}
return $entry;
}

Expand Down
8 changes: 0 additions & 8 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -802,14 +802,6 @@
<code><![CDATA[$i]]></code>
<code><![CDATA[$i]]></code>
<code><![CDATA[$i]]></code>
<code><![CDATA[$i]]></code>
<code><![CDATA[$i]]></code>
<code><![CDATA[$i]]></code>
<code><![CDATA[$i]]></code>
<code><![CDATA[$i]]></code>
<code><![CDATA[$i]]></code>
<code><![CDATA[$i]]></code>
<code><![CDATA[$i]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="apps/files/lib/Service/OwnershipTransferService.php">
Expand Down