diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2017-03-26 11:32:29 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-03-29 00:04:29 +0200 |
commit | f0850b266e25437bd1cfc2cbcfc27c2036f36b46 (patch) | |
tree | 047f2cf7b48ad6295f13aa1c5ae78f2f6cfd624a /apps/dav/lib | |
parent | 836271e0fddb33271ffac5f6f84dee8c4ea7140e (diff) | |
download | nextcloud-server-f0850b266e25437bd1cfc2cbcfc27c2036f36b46.tar.gz nextcloud-server-f0850b266e25437bd1cfc2cbcfc27c2036f36b46.zip |
Fix inspection results
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/Avatars/AvatarHome.php | 29 | ||||
-rw-r--r-- | apps/dav/lib/Avatars/AvatarNode.php | 10 | ||||
-rw-r--r-- | apps/dav/lib/Avatars/RootCollection.php | 6 |
3 files changed, 23 insertions, 22 deletions
diff --git a/apps/dav/lib/Avatars/AvatarHome.php b/apps/dav/lib/Avatars/AvatarHome.php index 9e00fe2e8f4..d72bfa3220a 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 270f66d6dbe..17edf80d217 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 8614d5d22b0..d7c7ff4e9fb 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'; } |