Merge pull request #4001 from nextcloud/backport-27389

Ensure that FileInfo return values as required by its phpdoc.
This commit is contained in:
Morris Jobke 2017-03-23 13:00:49 -06:00 committed by GitHub
commit eee7e97a6e
2 changed files with 9 additions and 7 deletions

View File

@ -148,10 +148,12 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
}
/**
* @return int
* Get FileInfo ID or null in case of part file
*
* @return int|null
*/
public function getId() {
return $this->data['fileid'];
return isset($this->data['fileid']) ? (int) $this->data['fileid'] : null;
}
/**
@ -193,7 +195,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
*/
public function getSize() {
$this->updateEntryfromSubMounts();
return isset($this->data['size']) ? $this->data['size'] : 0;
return isset($this->data['size']) ? (int) $this->data['size'] : 0;
}
/**
@ -201,7 +203,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
*/
public function getMTime() {
$this->updateEntryfromSubMounts();
return $this->data['mtime'];
return (int) $this->data['mtime'];
}
/**
@ -224,11 +226,11 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
* @return int
*/
public function getPermissions() {
$perms = $this->data['permissions'];
$perms = (int) $this->data['permissions'];
if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) {
$perms = $perms & ~\OCP\Constants::PERMISSION_SHARE;
}
return $perms;
return (int) $perms;
}
/**

View File

@ -144,7 +144,7 @@ interface FileInfo {
/**
* Get the file id of the file or folder
*
* @return int
* @return int|null
* @since 7.0.0
*/
public function getId();