diff --git a/apps/dav/lib/Avatars/AvatarHome.php b/apps/dav/lib/Avatars/AvatarHome.php index 9e00fe2e8f..d72bfa3220 100644 --- a/apps/dav/lib/Avatars/AvatarHome.php +++ b/apps/dav/lib/Avatars/AvatarHome.php @@ -28,7 +28,7 @@ use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\MethodNotAllowed; use Sabre\DAV\Exception\NotFound; use Sabre\DAV\ICollection; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; class AvatarHome implements ICollection { @@ -41,25 +41,26 @@ class AvatarHome implements ICollection { * AvatarHome constructor. * * @param array $principalInfo + * @param IAvatarManager $avatarManager */ public function __construct($principalInfo, IAvatarManager $avatarManager) { $this->principalInfo = $principalInfo; $this->avatarManager = $avatarManager; } - function createFile($name, $data = null) { + public function createFile($name, $data = null) { throw new Forbidden('Permission denied to create a file'); } - function createDirectory($name) { + public function createDirectory($name) { throw new Forbidden('Permission denied to create a folder'); } - function getChild($name) { + public function getChild($name) { $elements = pathinfo($name); $ext = isset($elements['extension']) ? $elements['extension'] : ''; - $size = intval(isset($elements['filename']) ? $elements['filename'] : '64'); - if (!in_array($ext, ['jpeg', 'png'])) { + $size = (int)(isset($elements['filename']) ? $elements['filename'] : '64'); + if (!in_array($ext, ['jpeg', 'png'], true)) { throw new MethodNotAllowed('File format not allowed'); } if ($size <= 0 || $size > 1024) { @@ -72,7 +73,7 @@ class AvatarHome implements ICollection { return new AvatarNode($size, $ext, $avatar); } - function getChildren() { + public function getChildren() { try { return [ $this->getChild('96.jpeg') @@ -82,10 +83,10 @@ class AvatarHome implements ICollection { } } - function childExists($name) { + public function childExists($name) { try { $ret = $this->getChild($name); - return !is_null($ret); + return $ret !== null; } catch (NotFound $ex) { return false; } catch (MethodNotAllowed $ex) { @@ -93,16 +94,16 @@ class AvatarHome implements ICollection { } } - function delete() { + public function delete() { throw new Forbidden('Permission denied to delete this folder'); } - function getName() { - list(,$name) = URLUtil::splitPath($this->principalInfo['uri']); + public function getName() { + list(,$name) = Uri\split($this->principalInfo['uri']); return $name; } - function setName($name) { + public function setName($name) { throw new Forbidden('Permission denied to rename this folder'); } @@ -111,7 +112,7 @@ class AvatarHome implements ICollection { * * @return int */ - function getLastModified() { + public function getLastModified() { return null; } diff --git a/apps/dav/lib/Avatars/AvatarNode.php b/apps/dav/lib/Avatars/AvatarNode.php index 270f66d6db..17edf80d21 100644 --- a/apps/dav/lib/Avatars/AvatarNode.php +++ b/apps/dav/lib/Avatars/AvatarNode.php @@ -51,11 +51,11 @@ class AvatarNode extends File { * * @return string */ - function getName() { + public function getName() { return "$this->size.$this->ext"; } - function get() { + public function get() { $image = $this->avatar->get($this->size); $res = $image->resource(); @@ -75,18 +75,18 @@ class AvatarNode extends File { * * @return string|null */ - function getContentType() { + public function getContentType() { if ($this->ext === 'png') { return 'image/png'; } return 'image/jpeg'; } - function getETag() { + public function getETag() { return $this->avatar->getFile($this->size)->getEtag(); } - function getLastModified() { + public function getLastModified() { $timestamp = $this->avatar->getFile($this->size)->getMTime(); if (!empty($timestamp)) { return (int)$timestamp; diff --git a/apps/dav/lib/Avatars/RootCollection.php b/apps/dav/lib/Avatars/RootCollection.php index 8614d5d22b..d7c7ff4e9f 100644 --- a/apps/dav/lib/Avatars/RootCollection.php +++ b/apps/dav/lib/Avatars/RootCollection.php @@ -3,7 +3,7 @@ namespace OCA\DAV\Avatars; use Sabre\DAVACL\AbstractPrincipalCollection; -use Sabre\DAVACL\IPrincipal; + class RootCollection extends AbstractPrincipalCollection { @@ -17,12 +17,12 @@ class RootCollection extends AbstractPrincipalCollection { * @param array $principalInfo * @return AvatarHome */ - function getChildForPrincipal(array $principalInfo) { + public function getChildForPrincipal(array $principalInfo) { $avatarManager = \OC::$server->getAvatarManager(); return new AvatarHome($principalInfo, $avatarManager); } - function getName() { + public function getName() { return 'avatars'; }