diff options
Diffstat (limited to 'vendor/sabre/dav/lib/DAV')
107 files changed, 3084 insertions, 3193 deletions
diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php index 40a95f8bf..aa8b1f573 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php @@ -1,14 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * HTTP Basic authentication backend class + * HTTP Basic authentication backend class. * * This class can be used by authentication objects wishing to use HTTP Basic * Most of the digest logic is handled, implementors just need to worry about @@ -19,8 +20,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBasic implements BackendInterface { - +abstract class AbstractBasic implements BackendInterface +{ /** * Authentication Realm. * @@ -39,13 +40,14 @@ abstract class AbstractBasic implements BackendInterface { protected $principalPrefix = 'principals/'; /** - * Validates a username and password + * Validates a username and password. * * This method should return true or false depending on if login * succeeded. * * @param string $username * @param string $password + * * @return bool */ abstract protected function validateUserPass($username, $password); @@ -54,12 +56,10 @@ abstract class AbstractBasic implements BackendInterface { * Sets the authentication realm for this backend. * * @param string $realm - * @return void */ - function setRealm($realm) { - + public function setRealm($realm) + { $this->realm = $realm; - } /** @@ -86,12 +86,13 @@ abstract class AbstractBasic implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Basic( $this->realm, $request, @@ -103,10 +104,10 @@ abstract class AbstractBasic implements BackendInterface { return [false, "No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured"]; } if (!$this->validateUserPass($userpass[0], $userpass[1])) { - return [false, "Username or password was incorrect"]; + return [false, 'Username or password was incorrect']; } - return [true, $this->principalPrefix . $userpass[0]]; + return [true, $this->principalPrefix.$userpass[0]]; } /** @@ -126,19 +127,16 @@ abstract class AbstractBasic implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Basic( $this->realm, $request, $response ); $auth->requireLogin(); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php index ae7a8a12f..a2653b2b0 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php @@ -1,14 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * HTTP Bearer authentication backend class + * HTTP Bearer authentication backend class. * * This class can be used by authentication objects wishing to use HTTP Bearer * Most of the digest logic is handled, implementors just need to worry about @@ -20,8 +21,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBearer implements BackendInterface { - +abstract class AbstractBearer implements BackendInterface +{ /** * Authentication Realm. * @@ -33,12 +34,13 @@ abstract class AbstractBearer implements BackendInterface { protected $realm = 'sabre/dav'; /** - * Validates a Bearer token + * Validates a Bearer token. * * This method should return the full principal url, or false if the * token was incorrect. * * @param string $bearerToken + * * @return string|false */ abstract protected function validateBearerToken($bearerToken); @@ -47,12 +49,10 @@ abstract class AbstractBearer implements BackendInterface { * Sets the authentication realm for this backend. * * @param string $realm - * @return void */ - function setRealm($realm) { - + public function setRealm($realm) + { $this->realm = $realm; - } /** @@ -79,12 +79,13 @@ abstract class AbstractBearer implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Bearer( $this->realm, $request, @@ -97,10 +98,10 @@ abstract class AbstractBearer implements BackendInterface { } $principalUrl = $this->validateBearerToken($bearerToken); if (!$principalUrl) { - return [false, "Bearer token was incorrect"]; + return [false, 'Bearer token was incorrect']; } - return [true, $principalUrl]; + return [true, $principalUrl]; } /** @@ -120,19 +121,16 @@ abstract class AbstractBearer implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Bearer( $this->realm, $request, $response ); $auth->requireLogin(); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php index 4b47f56c9..06c9ed3a4 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\DAV; @@ -8,7 +10,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * HTTP Digest authentication backend class + * HTTP Digest authentication backend class. * * This class can be used by authentication objects wishing to use HTTP Digest * Most of the digest logic is handled, implementors just need to worry about @@ -18,8 +20,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractDigest implements BackendInterface { - +abstract class AbstractDigest implements BackendInterface +{ /** * Authentication Realm. * @@ -45,12 +47,10 @@ abstract class AbstractDigest implements BackendInterface { * existing hashes will break and nobody can authenticate. * * @param string $realm - * @return void */ - function setRealm($realm) { - + public function setRealm($realm) + { $this->realm = $realm; - } /** @@ -60,9 +60,10 @@ abstract class AbstractDigest implements BackendInterface { * * @param string $realm * @param string $username + * * @return string|null */ - abstract function getDigestHash($realm, $username); + abstract public function getDigestHash($realm, $username); /** * When this method is called, the backend must check if authentication was @@ -88,12 +89,13 @@ abstract class AbstractDigest implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { $digest = new HTTP\Auth\Digest( $this->realm, $request, @@ -110,8 +112,8 @@ abstract class AbstractDigest implements BackendInterface { $hash = $this->getDigestHash($this->realm, $username); // If this was false, the user account didn't exist - if ($hash === false || is_null($hash)) { - return [false, "Username or password was incorrect"]; + if (false === $hash || is_null($hash)) { + return [false, 'Username or password was incorrect']; } if (!is_string($hash)) { throw new DAV\Exception('The returned value from getDigestHash must be a string or null'); @@ -119,11 +121,10 @@ abstract class AbstractDigest implements BackendInterface { // If this was false, the password or part of the hash was incorrect. if (!$digest->validateA1($hash)) { - return [false, "Username or password was incorrect"]; + return [false, 'Username or password was incorrect']; } - return [true, $this->principalPrefix . $username]; - + return [true, $this->principalPrefix.$username]; } /** @@ -143,12 +144,11 @@ abstract class AbstractDigest implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Digest( $this->realm, $request, @@ -162,7 +162,5 @@ abstract class AbstractDigest implements BackendInterface { // Preventing the digest utility from modifying the http status code, // this should be handled by the main plugin. $response->setStatus($oldStatus); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php index e203d2685..201fe615c 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php @@ -1,24 +1,26 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * Apache authenticator + * Apache (or NGINX) authenticator. * * This authentication backend assumes that authentication has been - * configured in apache, rather than within SabreDAV. + * configured in apache (or NGINX), rather than within SabreDAV. * - * Make sure apache is properly configured for this to work. + * Make sure apache (or NGINX) is properly configured for this to work. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Apache implements BackendInterface { - +class Apache implements BackendInterface +{ /** * This is the prefix that will be used to generate principal urls. * @@ -50,22 +52,25 @@ class Apache implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { $remoteUser = $request->getRawServerValue('REMOTE_USER'); if (is_null($remoteUser)) { $remoteUser = $request->getRawServerValue('REDIRECT_REMOTE_USER'); } if (is_null($remoteUser)) { - return [false, 'No REMOTE_USER property was found in the PHP $_SERVER super-global. This likely means your server is not configured correctly']; + $remoteUser = $request->getRawServerValue('PHP_AUTH_USER'); + } + if (is_null($remoteUser)) { + return [false, 'No REMOTE_USER, REDIRECT_REMOTE_USER, or PHP_AUTH_USER property was found in the PHP $_SERVER super-global. This likely means your server is not configured correctly']; } - return [true, $this->principalPrefix . $remoteUser]; - + return [true, $this->principalPrefix.$remoteUser]; } /** @@ -85,12 +90,10 @@ class Apache implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php index 0fb2210f4..8598791fb 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP\RequestInterface; @@ -12,8 +14,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * When this method is called, the backend must check if authentication was * successful. @@ -38,11 +40,12 @@ interface BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response); + public function check(RequestInterface $request, ResponseInterface $response); /** * This method is called when a user could not be authenticated, and @@ -61,10 +64,8 @@ interface BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response); - + public function challenge(RequestInterface $request, ResponseInterface $response); } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php index 7ad8f48b2..aab3c5e1c 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; /** @@ -14,10 +16,10 @@ namespace Sabre\DAV\Auth\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class BasicCallBack extends AbstractBasic { - +class BasicCallBack extends AbstractBasic +{ /** - * Callback + * Callback. * * @var callable */ @@ -30,29 +32,27 @@ class BasicCallBack extends AbstractBasic { * password. * * @param callable $callBack - * @return void */ - function __construct(callable $callBack) { - + public function __construct(callable $callBack) + { $this->callBack = $callBack; - } /** - * Validates a username and password + * Validates a username and password. * * This method should return true or false depending on if login * succeeded. * * @param string $username * @param string $password + * * @return bool */ - protected function validateUserPass($username, $password) { - + protected function validateUserPass($username, $password) + { $cb = $this->callBack; - return $cb($username, $password); + return $cb($username, $password); } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php index 3a687d747..ea2d39679 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\DAV; @@ -13,10 +15,10 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends AbstractDigest { - +class File extends AbstractDigest +{ /** - * List of users + * List of users. * * @var array */ @@ -29,11 +31,11 @@ class File extends AbstractDigest { * * @param string|null $filename */ - function __construct($filename = null) { - - if (!is_null($filename)) + public function __construct($filename = null) + { + if (!is_null($filename)) { $this->loadFile($filename); - + } } /** @@ -41,37 +43,32 @@ class File extends AbstractDigest { * more than 1 file is used. * * @param string $filename - * @return void */ - function loadFile($filename) { - + public function loadFile($filename) + { foreach (file($filename, FILE_IGNORE_NEW_LINES) as $line) { - - if (substr_count($line, ":") !== 2) + if (2 !== substr_count($line, ':')) { throw new DAV\Exception('Malformed htdigest file. Every line should contain 2 colons'); - + } list($username, $realm, $A1) = explode(':', $line); - if (!preg_match('/^[a-zA-Z0-9]{32}$/', $A1)) + if (!preg_match('/^[a-zA-Z0-9]{32}$/', $A1)) { throw new DAV\Exception('Malformed htdigest file. Invalid md5 hash'); - - $this->users[$realm . ':' . $username] = $A1; - + } + $this->users[$realm.':'.$username] = $A1; } - } /** - * Returns a users' information + * Returns a users' information. * * @param string $realm * @param string $username + * * @return string */ - function getDigestHash($realm, $username) { - - return isset($this->users[$realm . ':' . $username]) ? $this->users[$realm . ':' . $username] : false; - + public function getDigestHash($realm, $username) + { + return isset($this->users[$realm.':'.$username]) ? $this->users[$realm.':'.$username] : false; } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php new file mode 100644 index 000000000..3a1831116 --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php @@ -0,0 +1,82 @@ +<?php + +namespace Sabre\DAV\Auth\Backend; + +/** + * This is an authentication backend that uses imap. + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @author Michael Niewöhner (foss@mniewoehner.de) + * @author rosali (https://github.com/rosali) + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class IMAP extends AbstractBasic +{ + /** + * IMAP server in the form {host[:port][/flag1/flag2...]}. + * + * @see http://php.net/manual/en/function.imap-open.php + * + * @var string + */ + protected $mailbox; + + /** + * Creates the backend object. + * + * @param string $mailbox + */ + public function __construct($mailbox) + { + $this->mailbox = $mailbox; + } + + /** + * Connects to an IMAP server and tries to authenticate. + * + * @param string $username + * @param string $password + * + * @return bool + */ + protected function imapOpen($username, $password) + { + $success = false; + + try { + $imap = imap_open($this->mailbox, $username, $password, OP_HALFOPEN | OP_READONLY, 1); + if ($imap) { + $success = true; + } + } catch (\ErrorException $e) { + error_log($e->getMessage()); + } + + $errors = imap_errors(); + if ($errors) { + foreach ($errors as $error) { + error_log($error); + } + } + + if (isset($imap) && $imap) { + imap_close($imap); + } + + return $success; + } + + /** + * Validates a username and password by trying to authenticate against IMAP. + * + * @param string $username + * @param string $password + * + * @return bool + */ + protected function validateUserPass($username, $password) + { + return $this->imapOpen($username, $password); + } +} diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php index c2f6de974..87ead6fcd 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; /** @@ -9,23 +11,22 @@ namespace Sabre\DAV\Auth\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractDigest { - +class PDO extends AbstractDigest +{ /** - * Reference to PDO connection + * Reference to PDO connection. * * @var PDO */ protected $pdo; /** - * PDO table name we'll be using + * PDO table name we'll be using. * * @var string */ public $tableName = 'users'; - /** * Creates the backend object. * @@ -33,10 +34,9 @@ class PDO extends AbstractDigest { * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -44,14 +44,14 @@ class PDO extends AbstractDigest { * * @param string $realm * @param string $username + * * @return string|null */ - function getDigestHash($realm, $username) { - - $stmt = $this->pdo->prepare('SELECT digesta1 FROM ' . $this->tableName . ' WHERE username = ?'); + public function getDigestHash($realm, $username) + { + $stmt = $this->pdo->prepare('SELECT digesta1 FROM '.$this->tableName.' WHERE username = ?'); $stmt->execute([$username]); - return $stmt->fetchColumn() ?: null; + return $stmt->fetchColumn() ?: null; } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Plugin.php b/vendor/sabre/dav/lib/DAV/Auth/Plugin.php index bbb5d180d..9be90283f 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth; use Sabre\DAV\Exception\NotAuthenticated; @@ -22,8 +24,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ /** * By default this plugin will require that the user is authenticated, * and refuse any access if the user is not authenticated. @@ -39,7 +41,7 @@ class Plugin extends ServerPlugin { public $autoRequireLogin = true; /** - * authentication backends + * authentication backends. */ protected $backends; @@ -52,40 +54,35 @@ class Plugin extends ServerPlugin { protected $currentPrincipal; /** - * Creates the authentication plugin + * Creates the authentication plugin. * * @param Backend\BackendInterface $authBackend */ - function __construct(Backend\BackendInterface $authBackend = null) { - + public function __construct(Backend\BackendInterface $authBackend = null) + { if (!is_null($authBackend)) { $this->addBackend($authBackend); } - } /** * Adds an authentication backend to the plugin. * * @param Backend\BackendInterface $authBackend - * @return void */ - function addBackend(Backend\BackendInterface $authBackend) { - + public function addBackend(Backend\BackendInterface $authBackend) + { $this->backends[] = $authBackend; - } /** - * Initializes the plugin. This function is automatically called by the server + * Initializes the plugin. This function is automatically called by the server. * * @param Server $server - * @return void */ - function initialize(Server $server) { - - $server->on('beforeMethod', [$this, 'beforeMethod'], 10); - + public function initialize(Server $server) + { + $server->on('beforeMethod:*', [$this, 'beforeMethod'], 10); } /** @@ -96,10 +93,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'auth'; - } /** @@ -114,23 +110,22 @@ class Plugin extends ServerPlugin { * * @return string|null */ - function getCurrentPrincipal() { - + public function getCurrentPrincipal() + { return $this->currentPrincipal; - } /** - * This method is called before any HTTP method and forces users to be authenticated + * This method is called before any HTTP method and forces users to be authenticated. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function beforeMethod(RequestInterface $request, ResponseInterface $response) { - + public function beforeMethod(RequestInterface $request, ResponseInterface $response) + { if ($this->currentPrincipal) { - // We already have authentication information. This means that the // event has already fired earlier, and is now likely fired for a // sub-request. @@ -144,7 +139,6 @@ class Plugin extends ServerPlugin { // // See issue #580 for more information about that. return; - } $authResult = $this->check($request, $response); @@ -153,11 +147,10 @@ class Plugin extends ServerPlugin { // Auth was successful $this->currentPrincipal = $authResult[1]; $this->loginFailedReasons = null; + return; } - - // If we got here, it means that no authentication backend was // successful in authenticating the user. $this->currentPrincipal = null; @@ -167,7 +160,6 @@ class Plugin extends ServerPlugin { $this->challenge($request, $response); throw new NotAuthenticated(implode(', ', $authResult[1])); } - } /** @@ -184,24 +176,24 @@ class Plugin extends ServerPlugin { * unsuccessful. For every auth backend there will be one reason, so usually * there's just one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { if (!$this->backends) { throw new \Sabre\DAV\Exception('No authentication backends were configured on this server.'); } $reasons = []; foreach ($this->backends as $backend) { - $result = $backend->check( $request, $response ); - if (!is_array($result) || count($result) !== 2 || !is_bool($result[0]) || !is_string($result[1])) { + if (!is_array($result) || 2 !== count($result) || !is_bool($result[0]) || !is_string($result[1])) { throw new \Sabre\DAV\Exception('The authentication backend did not return a correct value from the check() method.'); } @@ -211,11 +203,9 @@ class Plugin extends ServerPlugin { return [true, $result[1]]; } $reasons[] = $result[1]; - } return [false, $reasons]; - } /** @@ -225,16 +215,16 @@ class Plugin extends ServerPlugin { * WWW-Authorization header, indicating to the client that it should * authenticate. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { foreach ($this->backends as $backend) { $backend->challenge($request, $response); } - } /** @@ -255,10 +245,9 @@ class Plugin extends ServerPlugin { * * @return string[]|null */ - function getLoginFailedReasons() { - + public function getLoginFailedReasons() + { return $this->loginFailedReasons; - } /** @@ -272,14 +261,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Generic authentication plugin', - 'link' => 'http://sabre.io/dav/authentication/', + 'link' => 'http://sabre.io/dav/authentication/', ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php b/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php index 3ba2aee25..7466babb3 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php +++ b/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php @@ -1,14 +1,16 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; -use Sabre\DAV\Inode; +use Sabre\DAV\INode; use Sabre\DAV\PropFind; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * GuessContentType plugin + * GuessContentType plugin. * * A lot of the built-in File objects just return application/octet-stream * as a content-type by default. This is a problem for some clients, because @@ -22,17 +24,16 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class GuessContentType extends DAV\ServerPlugin { - +class GuessContentType extends DAV\ServerPlugin +{ /** - * List of recognized file extensions + * List of recognized file extensions. * * Feel free to add more * * @var array */ public $extensionMap = [ - // images 'jpg' => 'image/jpeg', 'gif' => 'image/gif', @@ -44,58 +45,52 @@ class GuessContentType extends DAV\ServerPlugin { // text 'txt' => 'text/plain', - ]; /** - * Initializes the plugin + * Initializes the plugin. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { // Using a relatively low priority (200) to allow other extensions // to set the content-type first. $server->on('propFind', [$this, 'propFind'], 200); - } /** - * Our PROPFIND handler + * Our PROPFIND handler. * * Here we set a contenttype, if the node didn't already have one. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - - $propFind->handle('{DAV:}getcontenttype', function() use ($propFind) { + public function propFind(PropFind $propFind, INode $node) + { + $propFind->handle('{DAV:}getcontenttype', function () use ($propFind) { + list(, $fileName) = Uri\split($propFind->getPath()); - list(, $fileName) = URLUtil::splitPath($propFind->getPath()); return $this->getContentType($fileName); - }); - } /** - * Simple method to return the contenttype + * Simple method to return the contenttype. * * @param string $fileName + * * @return string */ - protected function getContentType($fileName) { - + protected function getContentType($fileName) + { // Just grabbing the extension $extension = strtolower(substr($fileName, strrpos($fileName, '.') + 1)); if (isset($this->extensionMap[$extension])) { return $this->extensionMap[$extension]; } - return 'application/octet-stream'; + return 'application/octet-stream'; } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php b/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php index f4be6b348..59b3f5604 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php +++ b/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; /** @@ -13,8 +15,8 @@ namespace Sabre\DAV\Browser; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface HtmlOutput { - +interface HtmlOutput +{ /** * Generate html representation for this value. * @@ -27,8 +29,8 @@ interface HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html); - + public function toHtml(HtmlOutputHelper $html); } diff --git a/vendor/sabre/dav/lib/DAV/Browser/HtmlOutputHelper.php b/vendor/sabre/dav/lib/DAV/Browser/HtmlOutputHelper.php index 249d54047..a7c747437 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/HtmlOutputHelper.php +++ b/vendor/sabre/dav/lib/DAV/Browser/HtmlOutputHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\Uri; @@ -13,8 +15,8 @@ use Sabre\Xml\Service as XmlService; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class HtmlOutputHelper { - +class HtmlOutputHelper +{ /** * Link to the root of the application. * @@ -40,13 +42,12 @@ class HtmlOutputHelper { * that can be used to make output a lot shorter. * * @param string $baseUri - * @param array $namespaceMap + * @param array $namespaceMap */ - function __construct($baseUri, array $namespaceMap) { - + public function __construct($baseUri, array $namespaceMap) + { $this->baseUri = $baseUri; $this->namespaceMap = $namespaceMap; - } /** @@ -58,24 +59,24 @@ class HtmlOutputHelper { * Absolute urls are left alone. * * @param string $path + * * @return string */ - function fullUrl($path) { - + public function fullUrl($path) + { return Uri\resolve($this->baseUri, $path); - } /** * Escape string for HTML output. * - * @param string $input + * @param scalar $input + * * @return string */ - function h($input) { - - return htmlspecialchars($input, ENT_COMPAT, 'UTF-8'); - + public function h($input) + { + return htmlspecialchars((string) $input, ENT_COMPAT, 'UTF-8'); } /** @@ -86,13 +87,14 @@ class HtmlOutputHelper { * * @param string $url * @param string $label + * * @return string */ - function link($url, $label = null) { - + public function link($url, $label = null) + { $url = $this->h($this->fullUrl($url)); - return '<a href="' . $url . '">' . ($label ? $this->h($label) : $url) . '</a>'; + return '<a href="'.$url.'">'.($label ? $this->h($label) : $url).'</a>'; } /** @@ -100,18 +102,18 @@ class HtmlOutputHelper { * shortened version with a prefix, if it was a known namespace. * * @param string $element + * * @return string */ - function xmlName($element) { - + public function xmlName($element) + { list($ns, $localName) = XmlService::parseClarkNotation($element); if (isset($this->namespaceMap[$ns])) { - $propName = $this->namespaceMap[$ns] . ':' . $localName; + $propName = $this->namespaceMap[$ns].':'.$localName; } else { $propName = $element; } - return "<span title=\"" . $this->h($element) . "\">" . $this->h($propName) . "</span>"; + return '<span title="'.$this->h($element).'">'.$this->h($propName).'</span>'; } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php b/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php index 61327c49a..25e061128 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php +++ b/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; @@ -16,45 +18,46 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MapGetToPropFind extends DAV\ServerPlugin { - +class MapGetToPropFind extends DAV\ServerPlugin +{ /** - * reference to server class + * reference to server class. * * @var DAV\Server */ protected $server; /** - * Initializes the plugin and subscribes to events + * Initializes the plugin and subscribes to events. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->on('method:GET', [$this, 'httpGet'], 90); } /** - * This method intercepts GET requests to non-files, and changes it into an HTTP PROPFIND request + * This method intercepts GET requests to non-files, and changes it into an HTTP PROPFIND request. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $node = $this->server->tree->getNodeForPath($request->getPath()); - if ($node instanceof DAV\IFile) return; + if ($node instanceof DAV\IFile) { + return; + } $subRequest = clone $request; $subRequest->setMethod('PROPFIND'); $this->server->invokeMethod($subRequest, $response); - return false; + return false; } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/Plugin.php b/vendor/sabre/dav/lib/DAV/Browser/Plugin.php index 545ad5633..e2fab4b79 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Browser/Plugin.php @@ -1,15 +1,18 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; use Sabre\DAV\MkCol; +use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * Browser Plugin + * Browser Plugin. * * This plugin provides a html representation, so that a WebDAV server may be accessed * using a browser. @@ -21,10 +24,10 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * reference to server class + * reference to server class. * * @var DAV\Server */ @@ -60,53 +63,54 @@ class Plugin extends DAV\ServerPlugin { * * @param bool $enablePost */ - function __construct($enablePost = true) { - + public function __construct($enablePost = true) + { $this->enablePost = $enablePost; - } /** - * Initializes the plugin and subscribes to events + * Initializes the plugin and subscribes to events. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->on('method:GET', [$this, 'httpGetEarly'], 90); $this->server->on('method:GET', [$this, 'httpGet'], 200); $this->server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel'], 200); - if ($this->enablePost) $this->server->on('method:POST', [$this, 'httpPOST']); + if ($this->enablePost) { + $this->server->on('method:POST', [$this, 'httpPOST']); + } } /** * This method intercepts GET requests that have ?sabreAction=info - * appended to the URL + * appended to the URL. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGetEarly(RequestInterface $request, ResponseInterface $response) { - + public function httpGetEarly(RequestInterface $request, ResponseInterface $response) + { $params = $request->getQueryParameters(); - if (isset($params['sabreAction']) && $params['sabreAction'] === 'info') { + if (isset($params['sabreAction']) && 'info' === $params['sabreAction']) { return $this->httpGet($request, $response); } - } /** - * This method intercepts GET requests to collections and returns the html + * This method intercepts GET requests to collections and returns the html. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { // We're not using straight-up $_GET, because we want everything to be // unit testable. $getVars = $request->getQueryParameters(); @@ -117,13 +121,13 @@ class Plugin extends DAV\ServerPlugin { $sabreAction = isset($getVars['sabreAction']) ? $getVars['sabreAction'] : null; switch ($sabreAction) { - - case 'asset' : + case 'asset': // Asset handling, such as images $this->serveAsset(isset($getVars['assetName']) ? $getVars['assetName'] : null); + return false; - default : - case 'info' : + default: + case 'info': try { $this->server->tree->getNodeForPath($request->getPath()); } catch (DAV\Exception\NotFound $e) { @@ -141,7 +145,7 @@ class Plugin extends DAV\ServerPlugin { return false; - case 'plugins' : + case 'plugins': $response->setStatus(200); $response->setHeader('Content-Type', 'text/html; charset=utf-8'); @@ -150,41 +154,39 @@ class Plugin extends DAV\ServerPlugin { ); return false; - } - } /** * Handles POST requests for tree operations. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpPOST(RequestInterface $request, ResponseInterface $response) { - + public function httpPOST(RequestInterface $request, ResponseInterface $response) + { $contentType = $request->getHeader('Content-Type'); list($contentType) = explode(';', $contentType); - if ($contentType !== 'application/x-www-form-urlencoded' && - $contentType !== 'multipart/form-data') { - return; + if ('application/x-www-form-urlencoded' !== $contentType && + 'multipart/form-data' !== $contentType) { + return; } $postVars = $request->getPostData(); - if (!isset($postVars['sabreAction'])) + if (!isset($postVars['sabreAction'])) { return; + } $uri = $request->getPath(); if ($this->server->emit('onBrowserPostAction', [$uri, $postVars['sabreAction'], $postVars])) { - switch ($postVars['sabreAction']) { - - case 'mkcol' : + case 'mkcol': if (isset($postVars['name']) && trim($postVars['name'])) { // Using basename() because we won't allow slashes - list(, $folderName) = URLUtil::splitPath(trim($postVars['name'])); + list(, $folderName) = Uri\split(trim($postVars['name'])); if (isset($postVars['resourceType'])) { $resourceType = explode(',', $postVars['resourceType']); @@ -196,7 +198,7 @@ class Plugin extends DAV\ServerPlugin { foreach ($postVars as $varName => $varValue) { // Any _POST variable in clark notation is treated // like a property. - if ($varName[0] === '{') { + if ('{' === $varName[0]) { // PHP will convert any dots to underscores. // This leaves us with no way to differentiate // the two. @@ -212,65 +214,67 @@ class Plugin extends DAV\ServerPlugin { $resourceType, $properties ); - $this->server->createCollection($uri . '/' . $folderName, $mkCol); + $this->server->createCollection($uri.'/'.$folderName, $mkCol); } break; // @codeCoverageIgnoreStart - case 'put' : + case 'put': - if ($_FILES) $file = current($_FILES); - else break; + if ($_FILES) { + $file = current($_FILES); + } else { + break; + } - list(, $newName) = URLUtil::splitPath(trim($file['name'])); - if (isset($postVars['name']) && trim($postVars['name'])) + list(, $newName) = Uri\split(trim($file['name'])); + if (isset($postVars['name']) && trim($postVars['name'])) { $newName = trim($postVars['name']); + } // Making sure we only have a 'basename' component - list(, $newName) = URLUtil::splitPath($newName); + list(, $newName) = Uri\split($newName); if (is_uploaded_file($file['tmp_name'])) { - $this->server->createFile($uri . '/' . $newName, fopen($file['tmp_name'], 'r')); + $this->server->createFile($uri.'/'.$newName, fopen($file['tmp_name'], 'r')); } break; // @codeCoverageIgnoreEnd - } - } $response->setHeader('Location', $request->getUrl()); $response->setStatus(302); - return false; + return false; } /** * Escapes a string for html. * * @param string $value + * * @return string */ - function escapeHTML($value) { - + public function escapeHTML($value) + { return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); - } /** - * Generates the html directory index for a given url + * Generates the html directory index for a given url. * * @param string $path + * * @return string */ - function generateDirectoryIndex($path) { - + public function generateDirectoryIndex($path) + { $html = $this->generateHeader($path ? $path : '/', $path); $node = $this->server->tree->getNodeForPath($path); if ($node instanceof DAV\ICollection) { - $html .= "<section><h1>Nodes</h1>\n"; - $html .= "<table class=\"nodeTable\">"; + $html .= '<table class="nodeTable">'; $subNodes = $this->server->getPropertiesForChildren($path, [ '{DAV:}displayname', @@ -281,10 +285,9 @@ class Plugin extends DAV\ServerPlugin { ]); foreach ($subNodes as $subPath => $subProps) { - $subNode = $this->server->tree->getNodeForPath($subPath); - $fullPath = $this->server->getBaseUri() . URLUtil::encodePath($subPath); - list(, $displayPath) = URLUtil::splitPath($subPath); + $fullPath = $this->server->getBaseUri().HTTP\encodePath($subPath); + list(, $displayPath) = Uri\split($subPath); $subNodes[$subPath]['subNode'] = $subNode; $subNodes[$subPath]['fullPath'] = $fullPath; @@ -295,43 +298,46 @@ class Plugin extends DAV\ServerPlugin { foreach ($subNodes as $subProps) { $type = [ 'string' => 'Unknown', - 'icon' => 'cog', + 'icon' => 'cog', ]; if (isset($subProps['{DAV:}resourcetype'])) { $type = $this->mapResourceType($subProps['{DAV:}resourcetype']->getValue(), $subProps['subNode']); } $html .= '<tr>'; - $html .= '<td class="nameColumn"><a href="' . $this->escapeHTML($subProps['fullPath']) . '"><span class="oi" data-glyph="' . $this->escapeHTML($type['icon']) . '"></span> ' . $this->escapeHTML($subProps['displayPath']) . '</a></td>'; - $html .= '<td class="typeColumn">' . $this->escapeHTML($type['string']) . '</td>'; + $html .= '<td class="nameColumn"><a href="'.$this->escapeHTML($subProps['fullPath']).'"><span class="oi" data-glyph="'.$this->escapeHTML($type['icon']).'"></span> '.$this->escapeHTML($subProps['displayPath']).'</a></td>'; + $html .= '<td class="typeColumn">'.$this->escapeHTML($type['string']).'</td>'; $html .= '<td>'; if (isset($subProps['{DAV:}getcontentlength'])) { - $html .= $this->escapeHTML($subProps['{DAV:}getcontentlength'] . ' bytes'); + $html .= $this->escapeHTML($subProps['{DAV:}getcontentlength'].' bytes'); } $html .= '</td><td>'; if (isset($subProps['{DAV:}getlastmodified'])) { $lastMod = $subProps['{DAV:}getlastmodified']->getTime(); $html .= $this->escapeHTML($lastMod->format('F j, Y, g:i a')); } + $html .= '</td><td>'; + if (isset($subProps['{DAV:}displayname'])) { + $html .= $this->escapeHTML($subProps['{DAV:}displayname']); + } $html .= '</td>'; $buttonActions = ''; if ($subProps['subNode'] instanceof DAV\IFile) { - $buttonActions = '<a href="' . $this->escapeHTML($subProps['fullPath']) . '?sabreAction=info"><span class="oi" data-glyph="info"></span></a>'; + $buttonActions = '<a href="'.$this->escapeHTML($subProps['fullPath']).'?sabreAction=info"><span class="oi" data-glyph="info"></span></a>'; } $this->server->emit('browserButtonActions', [$subProps['fullPath'], $subProps['subNode'], &$buttonActions]); - $html .= '<td>' . $buttonActions . '</td>'; + $html .= '<td>'.$buttonActions.'</td>'; $html .= '</tr>'; } $html .= '</table>'; - } - $html .= "</section>"; - $html .= "<section><h1>Properties</h1>"; - $html .= "<table class=\"propTable\">"; + $html .= '</section>'; + $html .= '<section><h1>Properties</h1>'; + $html .= '<table class="propTable">'; // Allprops request $propFind = new PropFindAll($path); @@ -343,12 +349,10 @@ class Plugin extends DAV\ServerPlugin { if (!in_array($propName, $this->uninterestingProperties)) { $html .= $this->drawPropertyRow($propName, $propValue); } - } - - $html .= "</table>"; - $html .= "</section>"; + $html .= '</table>'; + $html .= '</section>'; /* Start of generating actions */ @@ -358,8 +362,7 @@ class Plugin extends DAV\ServerPlugin { } if ($output) { - - $html .= "<section><h1>Actions</h1>"; + $html .= '<section><h1>Actions</h1>'; $html .= "<div class=\"actions\">\n"; $html .= $output; $html .= "</div>\n"; @@ -371,7 +374,6 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setHeader('Content-Security-Policy', "default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"); return $html; - } /** @@ -379,31 +381,30 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function generatePluginListing() { - + public function generatePluginListing() + { $html = $this->generateHeader('Plugins'); - $html .= "<section><h1>Plugins</h1>"; - $html .= "<table class=\"propTable\">"; + $html .= '<section><h1>Plugins</h1>'; + $html .= '<table class="propTable">'; foreach ($this->server->getPlugins() as $plugin) { $info = $plugin->getPluginInfo(); - $html .= '<tr><th>' . $info['name'] . '</th>'; - $html .= '<td>' . $info['description'] . '</td>'; + $html .= '<tr><th>'.$info['name'].'</th>'; + $html .= '<td>'.$info['description'].'</td>'; $html .= '<td>'; if (isset($info['link']) && $info['link']) { - $html .= '<a href="' . $this->escapeHTML($info['link']) . '"><span class="oi" data-glyph="book"></span></a>'; + $html .= '<a href="'.$this->escapeHTML($info['link']).'"><span class="oi" data-glyph="book"></span></a>'; } $html .= '</td></tr>'; } - $html .= "</table>"; - $html .= "</section>"; + $html .= '</table>'; + $html .= '</section>'; /* Start of generating actions */ $html .= $this->generateFooter(); return $html; - } /** @@ -414,22 +415,23 @@ class Plugin extends DAV\ServerPlugin { * * @param string $title * @param string $path + * * @return string */ - function generateHeader($title, $path = null) { - + public function generateHeader($title, $path = null) + { $version = ''; if (DAV\Server::$exposeVersion) { $version = DAV\Version::VERSION; } $vars = [ - 'title' => $this->escapeHTML($title), - 'favicon' => $this->escapeHTML($this->getAssetUrl('favicon.ico')), - 'style' => $this->escapeHTML($this->getAssetUrl('sabredav.css')), + 'title' => $this->escapeHTML($title), + 'favicon' => $this->escapeHTML($this->getAssetUrl('favicon.ico')), + 'style' => $this->escapeHTML($this->getAssetUrl('sabredav.css')), 'iconstyle' => $this->escapeHTML($this->getAssetUrl('openiconic/open-iconic.css')), - 'logo' => $this->escapeHTML($this->getAssetUrl('sabredav.png')), - 'baseUrl' => $this->server->getBaseUri(), + 'logo' => $this->escapeHTML($this->getAssetUrl('sabredav.png')), + 'baseUrl' => $this->server->getBaseUri(), ]; $html = <<<HTML @@ -453,20 +455,19 @@ class Plugin extends DAV\ServerPlugin { HTML; // If the path is empty, there's no parent. - if ($path) { - list($parentUri) = URLUtil::splitPath($path); - $fullPath = $this->server->getBaseUri() . URLUtil::encodePath($parentUri); - $html .= '<a href="' . $fullPath . '" class="btn">⇤ Go to parent</a>'; + if ($path) { + list($parentUri) = Uri\split($path); + $fullPath = $this->server->getBaseUri().HTTP\encodePath($parentUri); + $html .= '<a href="'.$fullPath.'" class="btn">⇤ Go to parent</a>'; } else { $html .= '<span class="btn disabled">⇤ Go to parent</span>'; } $html .= ' <a href="?sabreAction=plugins" class="btn"><span class="oi" data-glyph="puzzle-piece"></span> Plugins</a>'; - $html .= "</nav>"; + $html .= '</nav>'; return $html; - } /** @@ -476,18 +477,19 @@ HTML; * * @return string */ - function generateFooter() { - + public function generateFooter() + { $version = ''; if (DAV\Server::$exposeVersion) { $version = DAV\Version::VERSION; } + $year = date('Y'); + return <<<HTML -<footer>Generated by SabreDAV $version (c)2007-2016 <a href="http://sabre.io/">http://sabre.io/</a></footer> +<footer>Generated by SabreDAV $version (c)2007-$year <a href="http://sabre.io/">http://sabre.io/</a></footer> </body> </html> HTML; - } /** @@ -498,19 +500,20 @@ HTML; * creating new directories. * * @param DAV\INode $node - * @param mixed $output - * @param string $path - * @return void + * @param mixed $output + * @param string $path */ - function htmlActionsPanel(DAV\INode $node, &$output, $path) { - - if (!$node instanceof DAV\ICollection) + public function htmlActionsPanel(DAV\INode $node, &$output, $path) + { + if (!$node instanceof DAV\ICollection) { return; + } // We also know fairly certain that if an object is a non-extended // SimpleCollection, we won't need to show the panel either. - if (get_class($node) === 'Sabre\\DAV\\SimpleCollection') + if ('Sabre\\DAV\\SimpleCollection' === get_class($node)) { return; + } $output .= <<<HTML <form method="post" action=""> @@ -527,7 +530,6 @@ HTML; <input type="submit" value="upload" /> </form> HTML; - } /** @@ -535,32 +537,35 @@ HTML; * suiteable for http access. * * @param string $assetName + * * @return string */ - protected function getAssetUrl($assetName) { - - return $this->server->getBaseUri() . '?sabreAction=asset&assetName=' . urlencode($assetName); - + protected function getAssetUrl($assetName) + { + return $this->server->getBaseUri().'?sabreAction=asset&assetName='.urlencode($assetName); } /** * This method returns a local pathname to an asset. * * @param string $assetName + * * @throws DAV\Exception\NotFound + * * @return string */ - protected function getLocalAssetPath($assetName) { - - $assetDir = __DIR__ . '/assets/'; - $path = $assetDir . $assetName; + protected function getLocalAssetPath($assetName) + { + $assetDir = __DIR__.'/assets/'; + $path = $assetDir.$assetName; // Making sure people aren't trying to escape from the base path. $path = str_replace('\\', '/', $path); - if (strpos($path, '/../') !== false || strrchr($path, '/') === '/..') { + if (false !== strpos($path, '/../') || '/..' === strrchr($path, '/')) { throw new DAV\Exception\NotFound('Path does not exist, or escaping from the base path was detected'); } - if (strpos(realpath($path), realpath($assetDir)) === 0 && file_exists($path)) { + $realPath = realpath($path); + if ($realPath && 0 === strpos($realPath, realpath($assetDir)) && file_exists($path)) { return $path; } throw new DAV\Exception\NotFound('Path does not exist, or escaping from the base path was detected'); @@ -570,10 +575,9 @@ HTML; * This method reads an asset from disk and generates a full http response. * * @param string $assetName - * @return void */ - protected function serveAsset($assetName) { - + protected function serveAsset($assetName) + { $assetPath = $this->getLocalAssetPath($assetName); // Rudimentary mime type detection @@ -594,7 +598,6 @@ HTML; $this->server->httpResponse->setHeader('Cache-Control', 'public, max-age=1209600'); $this->server->httpResponse->setStatus(200); $this->server->httpResponse->setBody(fopen($assetPath, 'r')); - } /** @@ -603,10 +606,11 @@ HTML; * * @param array $a * @param array $b + * * @return int */ - protected function compareNodes($a, $b) { - + protected function compareNodes($a, $b) + { $typeA = (isset($a['{DAV:}resourcetype'])) ? (in_array('{DAV:}collection', $a['{DAV:}resourcetype']->getValue())) : false; @@ -619,29 +623,30 @@ HTML; if ($typeA === $typeB) { return strnatcasecmp($a['displayPath'], $b['displayPath']); } - return (($typeA < $typeB) ? 1 : -1); + return ($typeA < $typeB) ? 1 : -1; } /** * Maps a resource type to a human-readable string and icon. * - * @param array $resourceTypes + * @param array $resourceTypes * @param DAV\INode $node + * * @return array */ - private function mapResourceType(array $resourceTypes, $node) { - + private function mapResourceType(array $resourceTypes, $node) + { if (!$resourceTypes) { if ($node instanceof DAV\IFile) { return [ 'string' => 'File', - 'icon' => 'file', + 'icon' => 'file', ]; } else { return [ 'string' => 'Unknown', - 'icon' => 'cog', + 'icon' => 'cog', ]; } } @@ -649,53 +654,53 @@ HTML; $types = [ '{http://calendarserver.org/ns/}calendar-proxy-write' => [ 'string' => 'Proxy-Write', - 'icon' => 'people', + 'icon' => 'people', ], '{http://calendarserver.org/ns/}calendar-proxy-read' => [ 'string' => 'Proxy-Read', - 'icon' => 'people', + 'icon' => 'people', ], '{urn:ietf:params:xml:ns:caldav}schedule-outbox' => [ 'string' => 'Outbox', - 'icon' => 'inbox', + 'icon' => 'inbox', ], '{urn:ietf:params:xml:ns:caldav}schedule-inbox' => [ 'string' => 'Inbox', - 'icon' => 'inbox', + 'icon' => 'inbox', ], '{urn:ietf:params:xml:ns:caldav}calendar' => [ 'string' => 'Calendar', - 'icon' => 'calendar', + 'icon' => 'calendar', ], '{http://calendarserver.org/ns/}shared-owner' => [ 'string' => 'Shared', - 'icon' => 'calendar', + 'icon' => 'calendar', ], '{http://calendarserver.org/ns/}subscribed' => [ 'string' => 'Subscription', - 'icon' => 'calendar', + 'icon' => 'calendar', ], '{urn:ietf:params:xml:ns:carddav}directory' => [ 'string' => 'Directory', - 'icon' => 'globe', + 'icon' => 'globe', ], '{urn:ietf:params:xml:ns:carddav}addressbook' => [ 'string' => 'Address book', - 'icon' => 'book', + 'icon' => 'book', ], '{DAV:}principal' => [ 'string' => 'Principal', - 'icon' => 'person', + 'icon' => 'person', ], '{DAV:}collection' => [ 'string' => 'Collection', - 'icon' => 'folder', + 'icon' => 'folder', ], ]; $info = [ 'string' => [], - 'icon' => 'cog', + 'icon' => 'cog', ]; foreach ($resourceTypes as $k => $resourceType) { if (isset($types[$resourceType])) { @@ -713,42 +718,41 @@ HTML; $info['string'] = implode(', ', $info['string']); return $info; - } /** - * Draws a table row for a property + * Draws a table row for a property. * * @param string $name - * @param mixed $value + * @param mixed $value + * * @return string */ - private function drawPropertyRow($name, $value) { - + private function drawPropertyRow($name, $value) + { $html = new HtmlOutputHelper( $this->server->getBaseUri(), $this->server->xml->namespaceMap ); - return "<tr><th>" . $html->xmlName($name) . "</th><td>" . $this->drawPropertyValue($html, $value) . "</td></tr>"; - + return '<tr><th>'.$html->xmlName($name).'</th><td>'.$this->drawPropertyValue($html, $value).'</td></tr>'; } /** - * Draws a table row for a property + * Draws a table row for a property. * * @param HtmlOutputHelper $html - * @param mixed $value + * @param mixed $value + * * @return string */ - private function drawPropertyValue($html, $value) { - + private function drawPropertyValue($html, $value) + { if (is_scalar($value)) { return $html->h($value); } elseif ($value instanceof HtmlOutput) { return $value->toHtml($html); } elseif ($value instanceof \Sabre\Xml\XmlSerializable) { - // There's no default html output for this property, we're going // to output the actual xml serialization instead. $xml = $this->server->xml->write('{DAV:}root', $value, $this->server->getBaseUri()); @@ -756,12 +760,11 @@ HTML; // element. $xml = explode("\n", $xml); $xml = array_slice($xml, 2, -2); - return "<pre>" . $html->h(implode("\n", $xml)) . "</pre>"; + return '<pre>'.$html->h(implode("\n", $xml)).'</pre>'; } else { - return "<em>unknown</em>"; + return '<em>unknown</em>'; } - } /** @@ -772,10 +775,9 @@ HTML; * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'browser'; - } /** @@ -789,14 +791,12 @@ HTML; * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Generates HTML indexes and debug information for your sabre/dav server', - 'link' => 'http://sabre.io/dav/browser-plugin/', + 'link' => 'http://sabre.io/dav/browser-plugin/', ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/PropFindAll.php b/vendor/sabre/dav/lib/DAV/Browser/PropFindAll.php index c14b7f2f9..34702bdd8 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/PropFindAll.php +++ b/vendor/sabre/dav/lib/DAV/Browser/PropFindAll.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV\PropFind; @@ -12,17 +14,16 @@ use Sabre\DAV\PropFind; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PropFindAll extends PropFind { - +class PropFindAll extends PropFind +{ /** - * Creates the PROPFIND object + * Creates the PROPFIND object. * * @param string $path */ - function __construct($path) { - + public function __construct($path) + { parent::__construct($path, []); - } /** @@ -44,11 +45,10 @@ class PropFindAll extends PropFind { * It's also possible to not pass a callback, but immediately pass a value * * @param string $propertyName - * @param mixed $valueOrCallBack - * @return void + * @param mixed $valueOrCallBack */ - function handle($propertyName, $valueOrCallBack) { - + public function handle($propertyName, $valueOrCallBack) + { if (is_callable($valueOrCallBack)) { $value = $valueOrCallBack(); } else { @@ -57,39 +57,36 @@ class PropFindAll extends PropFind { if (!is_null($value)) { $this->result[$propertyName] = [200, $value]; } - } /** - * Sets the value of the property + * Sets the value of the property. * * If status is not supplied, the status will default to 200 for non-null * properties, and 404 for null properties. * * @param string $propertyName - * @param mixed $value - * @param int $status - * @return void + * @param mixed $value + * @param int $status */ - function set($propertyName, $value, $status = null) { - + public function set($propertyName, $value, $status = null) + { if (is_null($status)) { $status = is_null($value) ? 404 : 200; } $this->result[$propertyName] = [$status, $value]; - } /** * Returns the current value for a property. * * @param string $propertyName + * * @return mixed */ - function get($propertyName) { - + public function get($propertyName) + { return isset($this->result[$propertyName]) ? $this->result[$propertyName][1] : null; - } /** @@ -99,12 +96,12 @@ class PropFindAll extends PropFind { * null will be returned. * * @param string $propertyName + * * @return int|null */ - function getStatus($propertyName) { - + public function getStatus($propertyName) + { return isset($this->result[$propertyName]) ? $this->result[$propertyName][0] : 404; - } /** @@ -113,11 +110,11 @@ class PropFindAll extends PropFind { * * @return array */ - function get404Properties() { - + public function get404Properties() + { $result = []; foreach ($this->result as $propertyName => $stuff) { - if ($stuff[0] === 404) { + if (404 === $stuff[0]) { $result[] = $propertyName; } } @@ -125,8 +122,7 @@ class PropFindAll extends PropFind { if (!$result) { $result[] = '{http://sabredav.org/ns}idk'; } - return $result; + return $result; } - } diff --git a/vendor/sabre/dav/lib/DAV/Client.php b/vendor/sabre/dav/lib/DAV/Client.php index 175ad1bc4..cfa24cd29 100644 --- a/vendor/sabre/dav/lib/DAV/Client.php +++ b/vendor/sabre/dav/lib/DAV/Client.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; use Sabre\Uri; /** - * SabreDAV DAV client + * SabreDAV DAV client. * * This client wraps around Curl to provide a convenient API to a WebDAV * server. @@ -17,8 +19,8 @@ use Sabre\Uri; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Client extends HTTP\Client { - +class Client extends HTTP\Client +{ /** * The xml service. * @@ -29,18 +31,19 @@ class Client extends HTTP\Client { public $xml; /** - * The elementMap + * The elementMap. * * This property is linked via reference to $this->xml->elementMap. * It's deprecated as of version 3.0.0, and should no longer be used. * * @deprecated + * * @var array */ public $propertyMap = []; /** - * Base URI + * Base URI. * * This URI will be used to resolve relative urls. * @@ -49,17 +52,17 @@ class Client extends HTTP\Client { protected $baseUri; /** - * Basic authentication + * Basic authentication. */ const AUTH_BASIC = 1; /** - * Digest authentication + * Digest authentication. */ const AUTH_DIGEST = 2; /** - * NTLM authentication + * NTLM authentication. */ const AUTH_NTLM = 4; @@ -69,12 +72,12 @@ class Client extends HTTP\Client { const ENCODING_IDENTITY = 1; /** - * Deflate encoding + * Deflate encoding. */ const ENCODING_DEFLATE = 2; /** - * Gzip encoding + * Gzip encoding. */ const ENCODING_GZIP = 4; @@ -84,14 +87,14 @@ class Client extends HTTP\Client { const ENCODING_ALL = 7; /** - * Content-encoding + * Content-encoding. * * @var int */ protected $encoding = self::ENCODING_IDENTITY; /** - * Constructor + * Constructor. * * Settings are provided through the 'settings' argument. The following * settings are supported: @@ -112,8 +115,8 @@ class Client extends HTTP\Client { * * @param array $settings */ - function __construct(array $settings) { - + public function __construct(array $settings) + { if (!isset($settings['baseUri'])) { throw new \InvalidArgumentException('A baseUri must be provided'); } @@ -146,8 +149,7 @@ class Client extends HTTP\Client { } $this->addCurlSetting(CURLOPT_HTTPAUTH, $curlType); - $this->addCurlSetting(CURLOPT_USERPWD, $userName . ':' . $password); - + $this->addCurlSetting(CURLOPT_USERPWD, $userName.':'.$password); } if (isset($settings['encoding'])) { @@ -166,16 +168,15 @@ class Client extends HTTP\Client { $this->addCurlSetting(CURLOPT_ENCODING, implode(',', $encodings)); } - $this->addCurlSetting(CURLOPT_USERAGENT, 'sabre-dav/' . Version::VERSION . ' (http://sabre.io/)'); + $this->addCurlSetting(CURLOPT_USERAGENT, 'sabre-dav/'.Version::VERSION.' (http://sabre.io/)'); $this->xml = new Xml\Service(); // BC - $this->propertyMap = & $this->xml->elementMap; - + $this->propertyMap = &$this->xml->elementMap; } /** - * Does a PROPFIND request + * Does a PROPFIND request. * * The list of requested properties must be specified as an array, in clark * notation. @@ -191,28 +192,28 @@ class Client extends HTTP\Client { * made to the server to also return all child resources. * * @param string $url - * @param array $properties - * @param int $depth + * @param array $properties + * @param int $depth + * * @return array */ - function propFind($url, array $properties, $depth = 0) { - + public function propFind($url, array $properties, $depth = 0) + { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->formatOutput = true; $root = $dom->createElementNS('DAV:', 'd:propfind'); $prop = $dom->createElement('d:prop'); foreach ($properties as $property) { - list( $namespace, $elementName ) = \Sabre\Xml\Service::parseClarkNotation($property); - if ($namespace === 'DAV:') { - $element = $dom->createElement('d:' . $elementName); + if ('DAV:' === $namespace) { + $element = $dom->createElement('d:'.$elementName); } else { - $element = $dom->createElementNS($namespace, 'x:' . $elementName); + $element = $dom->createElementNS($namespace, 'x:'.$elementName); } $prop->appendChild($element); @@ -224,49 +225,48 @@ class Client extends HTTP\Client { $url = $this->getAbsoluteUrl($url); $request = new HTTP\Request('PROPFIND', $url, [ - 'Depth' => $depth, - 'Content-Type' => 'application/xml' + 'Depth' => $depth, + 'Content-Type' => 'application/xml', ], $body); $response = $this->send($request); - if ((int)$response->getStatus() >= 400) { + if ((int) $response->getStatus() >= 400) { throw new HTTP\ClientHttpException($response); } $result = $this->parseMultiStatus($response->getBodyAsString()); // If depth was 0, we only return the top item - if ($depth === 0) { + if (0 === $depth) { reset($result); $result = current($result); + return isset($result[200]) ? $result[200] : []; } $newResult = []; foreach ($result as $href => $statusList) { - $newResult[$href] = isset($statusList[200]) ? $statusList[200] : []; - } return $newResult; - } /** - * Updates a list of properties on the server + * Updates a list of properties on the server. * * The list of properties must have clark-notation properties for the keys, * and the actual (string) value for the value. If the value is null, an * attempt is made to delete the property. * * @param string $url - * @param array $properties + * @param array $properties + * * @return bool */ - function propPatch($url, array $properties) { - + public function propPatch($url, array $properties) + { $propPatch = new Xml\Request\PropPatch(); $propPatch->properties = $properties; $xml = $this->xml->write( @@ -284,7 +284,7 @@ class Client extends HTTP\Client { throw new HTTP\ClientHttpException($response); } - if ($response->getStatus() === 207) { + if (207 === $response->getStatus()) { // If it's a 207, the request could still have failed, but the // information is hidden in the response body. $result = $this->parseMultiStatus($response->getBodyAsString()); @@ -292,26 +292,23 @@ class Client extends HTTP\Client { $errorProperties = []; foreach ($result as $href => $statusList) { foreach ($statusList as $status => $properties) { - if ($status >= 400) { foreach ($properties as $propName => $propValue) { - $errorProperties[] = $propName . ' (' . $status . ')'; + $errorProperties[] = $propName.' ('.$status.')'; } } - } } if ($errorProperties) { - - throw new HTTP\ClientException('PROPPATCH failed. The following properties errored: ' . implode(', ', $errorProperties)); + throw new HTTP\ClientException('PROPPATCH failed. The following properties errored: '.implode(', ', $errorProperties)); } } - return true; + return true; } /** - * Performs an HTTP options request + * Performs an HTTP options request. * * This method returns all the features from the 'DAV:' header as an array. * If there was no DAV header, or no contents this method will return an @@ -319,8 +316,8 @@ class Client extends HTTP\Client { * * @return array */ - function options() { - + public function options() + { $request = new HTTP\Request('OPTIONS', $this->getAbsoluteUrl('')); $response = $this->send($request); @@ -333,8 +330,8 @@ class Client extends HTTP\Client { foreach ($features as &$v) { $v = trim($v); } - return $features; + return $features; } /** @@ -359,24 +356,26 @@ class Client extends HTTP\Client { * Note that it is no longer recommended to use this method, use the send() * method instead. * - * @param string $method - * @param string $url + * @param string $method + * @param string $url * @param string|resource|null $body - * @param array $headers - * @throws ClientException, in case a curl error occurred. + * @param array $headers + * + * @throws clientException, in case a curl error occurred + * * @return array */ - function request($method, $url = '', $body = null, array $headers = []) { - + public function request($method, $url = '', $body = null, array $headers = []) + { $url = $this->getAbsoluteUrl($url); $response = $this->send(new HTTP\Request($method, $url, $headers, $body)); + return [ - 'body' => $response->getBodyAsString(), - 'statusCode' => (int)$response->getStatus(), - 'headers' => array_change_key_case($response->getHeaders()), + 'body' => $response->getBodyAsString(), + 'statusCode' => (int) $response->getStatus(), + 'headers' => array_change_key_case($response->getHeaders()), ]; - } /** @@ -384,19 +383,19 @@ class Client extends HTTP\Client { * urls are expanded based on the base url as given by the server. * * @param string $url + * * @return string */ - function getAbsoluteUrl($url) { - + public function getAbsoluteUrl($url) + { return Uri\resolve( $this->baseUri, $url ); - } /** - * Parses a WebDAV multistatus response body + * Parses a WebDAV multistatus response body. * * This method returns an array with the following structure * @@ -418,22 +417,19 @@ class Client extends HTTP\Client { * * * @param string $body xml body + * * @return array */ - function parseMultiStatus($body) { - + public function parseMultiStatus($body) + { $multistatus = $this->xml->expect('{DAV:}multistatus', $body); $result = []; foreach ($multistatus->getResponses() as $response) { - $result[$response->getHref()] = $response->getResponseProperties(); - } return $result; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Collection.php b/vendor/sabre/dav/lib/DAV/Collection.php index 35c90b5af..2728bb27e 100644 --- a/vendor/sabre/dav/lib/DAV/Collection.php +++ b/vendor/sabre/dav/lib/DAV/Collection.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * Collection class + * Collection class. * * This is a helper class, that should aid in getting collections classes setup. * Most of its methods are implemented, and throw permission denied exceptions @@ -12,8 +14,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Collection extends Node implements ICollection { - +abstract class Collection extends Node implements ICollection +{ /** * Returns a child object, by its name. * @@ -25,18 +27,19 @@ abstract class Collection extends Node implements ICollection { * exist. * * @param string $name + * * @throws Exception\NotFound + * * @return INode */ - function getChild($name) { - + public function getChild($name) + { foreach ($this->getChildren() as $child) { - - if ($child->getName() === $name) return $child; - + if ($child->getName() === $name) { + return $child; + } } - throw new Exception\NotFound('File not found: ' . $name); - + throw new Exception\NotFound('File not found: '.$name); } /** @@ -45,25 +48,22 @@ abstract class Collection extends Node implements ICollection { * It is generally a good idea to try and override this. Usually it can be optimized. * * @param string $name + * * @return bool */ - function childExists($name) { - + public function childExists($name) + { try { - $this->getChild($name); - return true; + return true; } catch (Exception\NotFound $e) { - return false; - } - } /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -82,28 +82,25 @@ abstract class Collection extends Node implements ICollection { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - - throw new Exception\Forbidden('Permission denied to create file (filename ' . $name . ')'); - + public function createFile($name, $data = null) + { + throw new Exception\Forbidden('Permission denied to create file (filename '.$name.')'); } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name + * * @throws Exception\Forbidden - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { throw new Exception\Forbidden('Permission denied to create directory'); - } - - } diff --git a/vendor/sabre/dav/lib/DAV/CorePlugin.php b/vendor/sabre/dav/lib/DAV/CorePlugin.php index 676cdd04a..ef1dfceb6 100644 --- a/vendor/sabre/dav/lib/DAV/CorePlugin.php +++ b/vendor/sabre/dav/lib/DAV/CorePlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\DAV\Exception\BadRequest; @@ -14,8 +16,8 @@ use Sabre\Xml\ParseException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CorePlugin extends ServerPlugin { - +class CorePlugin extends ServerPlugin +{ /** * Reference to server object. * @@ -24,34 +26,32 @@ class CorePlugin extends ServerPlugin { protected $server; /** - * Sets up the plugin + * Sets up the plugin. * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; - $server->on('method:GET', [$this, 'httpGet']); - $server->on('method:OPTIONS', [$this, 'httpOptions']); - $server->on('method:HEAD', [$this, 'httpHead']); - $server->on('method:DELETE', [$this, 'httpDelete']); - $server->on('method:PROPFIND', [$this, 'httpPropFind']); + $server->on('method:GET', [$this, 'httpGet']); + $server->on('method:OPTIONS', [$this, 'httpOptions']); + $server->on('method:HEAD', [$this, 'httpHead']); + $server->on('method:DELETE', [$this, 'httpDelete']); + $server->on('method:PROPFIND', [$this, 'httpPropFind']); $server->on('method:PROPPATCH', [$this, 'httpPropPatch']); - $server->on('method:PUT', [$this, 'httpPut']); - $server->on('method:MKCOL', [$this, 'httpMkcol']); - $server->on('method:MOVE', [$this, 'httpMove']); - $server->on('method:COPY', [$this, 'httpCopy']); - $server->on('method:REPORT', [$this, 'httpReport']); - - $server->on('propPatch', [$this, 'propPatchProtectedPropertyCheck'], 90); - $server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200); - $server->on('propFind', [$this, 'propFind']); - $server->on('propFind', [$this, 'propFindNode'], 120); - $server->on('propFind', [$this, 'propFindLate'], 200); - - $server->on('exception', [$this, 'exception']); - + $server->on('method:PUT', [$this, 'httpPut']); + $server->on('method:MKCOL', [$this, 'httpMkcol']); + $server->on('method:MOVE', [$this, 'httpMove']); + $server->on('method:COPY', [$this, 'httpCopy']); + $server->on('method:REPORT', [$this, 'httpReport']); + + $server->on('propPatch', [$this, 'propPatchProtectedPropertyCheck'], 90); + $server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200); + $server->on('propFind', [$this, 'propFind']); + $server->on('propFind', [$this, 'propFindNode'], 120); + $server->on('propFind', [$this, 'propFindLate'], 200); + + $server->on('exception', [$this, 'exception']); } /** @@ -62,34 +62,40 @@ class CorePlugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'core'; - } /** * This is the default implementation for the GET method. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $node = $this->server->tree->getNodeForPath($path); - if (!$node instanceof IFile) return; - - $body = $node->get(); + if (!$node instanceof IFile) { + return; + } - // Converting string into stream, if needed. - if (is_string($body)) { - $stream = fopen('php://temp', 'r+'); - fwrite($stream, $body); - rewind($stream); - $body = $stream; + if ('HEAD' === $request->getHeader('X-Sabre-Original-Method')) { + $body = ''; + } else { + $body = $node->get(); + + // Converting string into stream, if needed. + if (is_string($body)) { + $stream = fopen('php://temp', 'r+'); + fwrite($stream, $body); + rewind($stream); + $body = $stream; + } } /* @@ -105,14 +111,11 @@ class CorePlugin extends ServerPlugin { $httpHeaders['Content-Type'] = 'application/octet-stream'; } - if (isset($httpHeaders['Content-Length'])) { - $nodeSize = $httpHeaders['Content-Length']; // Need to unset Content-Length, because we'll handle that during figuring out the range unset($httpHeaders['Content-Length']); - } else { $nodeSize = null; } @@ -126,7 +129,6 @@ class CorePlugin extends ServerPlugin { // If ifRange is set, and range is specified, we first need to check // the precondition. if ($nodeSize && $range && $ifRange) { - // if IfRange is parsable as a date we'll treat it as a DateTime // otherwise, we must treat it as an etag. try { @@ -134,81 +136,87 @@ class CorePlugin extends ServerPlugin { // It's a date. We must check if the entity is modified since // the specified date. - if (!isset($httpHeaders['Last-Modified'])) $ignoreRangeHeader = true; - else { + if (!isset($httpHeaders['Last-Modified'])) { + $ignoreRangeHeader = true; + } else { $modified = new \DateTime($httpHeaders['Last-Modified']); - if ($modified > $ifRangeDate) $ignoreRangeHeader = true; + if ($modified > $ifRangeDate) { + $ignoreRangeHeader = true; + } } - } catch (\Exception $e) { - // It's an entity. We can do a simple comparison. - if (!isset($httpHeaders['ETag'])) $ignoreRangeHeader = true; - elseif ($httpHeaders['ETag'] !== $ifRange) $ignoreRangeHeader = true; + if (!isset($httpHeaders['ETag'])) { + $ignoreRangeHeader = true; + } elseif ($httpHeaders['ETag'] !== $ifRange) { + $ignoreRangeHeader = true; + } } } // We're only going to support HTTP ranges if the backend provided a filesize if (!$ignoreRangeHeader && $nodeSize && $range) { - // Determining the exact byte offsets if (!is_null($range[0])) { - $start = $range[0]; $end = $range[1] ? $range[1] : $nodeSize - 1; - if ($start >= $nodeSize) - throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $range[0] . ') exceeded the size of the entity (' . $nodeSize . ')'); - - if ($end < $start) throw new Exception\RequestedRangeNotSatisfiable('The end offset (' . $range[1] . ') is lower than the start offset (' . $range[0] . ')'); - if ($end >= $nodeSize) $end = $nodeSize - 1; - + if ($start >= $nodeSize) { + throw new Exception\RequestedRangeNotSatisfiable('The start offset ('.$range[0].') exceeded the size of the entity ('.$nodeSize.')'); + } + if ($end < $start) { + throw new Exception\RequestedRangeNotSatisfiable('The end offset ('.$range[1].') is lower than the start offset ('.$range[0].')'); + } + if ($end >= $nodeSize) { + $end = $nodeSize - 1; + } } else { - $start = $nodeSize - $range[1]; $end = $nodeSize - 1; - if ($start < 0) $start = 0; - + if ($start < 0) { + $start = 0; + } } // Streams may advertise themselves as seekable, but still not // actually allow fseek. We'll manually go forward in the stream // if fseek failed. - if (!stream_get_meta_data($body)['seekable'] || fseek($body, $start, SEEK_SET) === -1) { + if (!stream_get_meta_data($body)['seekable'] || -1 === fseek($body, $start, SEEK_SET)) { $consumeBlock = 8192; - for ($consumed = 0; $start - $consumed > 0;){ - if (feof($body)) throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $start . ') exceeded the size of the entity (' . $consumed . ')'); + for ($consumed = 0; $start - $consumed > 0;) { + if (feof($body)) { + throw new Exception\RequestedRangeNotSatisfiable('The start offset ('.$start.') exceeded the size of the entity ('.$consumed.')'); + } $consumed += strlen(fread($body, min($start - $consumed, $consumeBlock))); } } $response->setHeader('Content-Length', $end - $start + 1); - $response->setHeader('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $nodeSize); + $response->setHeader('Content-Range', 'bytes '.$start.'-'.$end.'/'.$nodeSize); $response->setStatus(206); $response->setBody($body); - } else { - - if ($nodeSize) $response->setHeader('Content-Length', $nodeSize); + if ($nodeSize) { + $response->setHeader('Content-Length', $nodeSize); + } $response->setStatus(200); $response->setBody($body); - } // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * HTTP OPTIONS + * HTTP OPTIONS. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpOptions(RequestInterface $request, ResponseInterface $response) { - + public function httpOptions(RequestInterface $request, ResponseInterface $response) + { $methods = $this->server->getAllowedMethods($request->getPath()); $response->setHeader('Allow', strtoupper(implode(', ', $methods))); @@ -227,31 +235,31 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * HTTP HEAD + * HTTP HEAD. * * This method is normally used to take a peak at a url, and only get the * HTTP response headers, without the body. This is used by clients to * determine if a remote file was changed, so they can use a local cached * version, instead of downloading it again * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpHead(RequestInterface $request, ResponseInterface $response) { - + public function httpHead(RequestInterface $request, ResponseInterface $response) + { // This is implemented by changing the HEAD request to a GET request, - // and dropping the response body. + // and telling the request handler that is doesn't need to create the body. $subRequest = clone $request; $subRequest->setMethod('GET'); + $subRequest->setHeader('X-Sabre-Original-Method', 'HEAD'); try { $this->server->invokeMethod($subRequest, $response, false); - $response->setBody(''); } catch (Exception\NotImplemented $e) { // Some clients may do HEAD requests on collections, however, GET // requests and HEAD requests _may_ not be defined on a collection, @@ -267,23 +275,23 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * HTTP Delete + * HTTP Delete. * * The HTTP delete method, deletes a given uri * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpDelete(RequestInterface $request, ResponseInterface $response) { - + public function httpDelete(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); - if (!$this->server->emit('beforeUnbind', [$path])) return false; + if (!$this->server->emit('beforeUnbind', [$path])) { + return false; + } $this->server->tree->delete($path); $this->server->emit('afterUnbind', [$path]); @@ -293,11 +301,10 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * WebDAV PROPFIND + * WebDAV PROPFIND. * * This WebDAV method requests information about an uri resource, or a list of resources * If a client wants to receive the properties for a single resource it will add an HTTP Depth: header with a 0 value @@ -308,12 +315,11 @@ class CorePlugin extends ServerPlugin { * * It has to return a HTTP 207 Multi-status status code * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpPropFind(RequestInterface $request, ResponseInterface $response) { - + public function httpPropFind(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $requestBody = $request->getBodyAsString(); @@ -321,7 +327,7 @@ class CorePlugin extends ServerPlugin { try { $propFindXml = $this->server->xml->expect('{DAV:}propfind', $requestBody); } catch (ParseException $e) { - throw new BadRequest($e->getMessage(), null, $e); + throw new BadRequest($e->getMessage(), 0, $e); } } else { $propFindXml = new Xml\Request\PropFind(); @@ -331,7 +337,9 @@ class CorePlugin extends ServerPlugin { $depth = $this->server->getHTTPDepth(1); // The only two options for the depth of a propfind is 0 or 1 - as long as depth infinity is not enabled - if (!$this->server->enablePropfindDepthInfinity && $depth != 0) $depth = 1; + if (!$this->server->enablePropfindDepthInfinity && 0 != $depth) { + $depth = 1; + } $newProperties = $this->server->getPropertiesIteratorForPath($path, $propFindXml->properties, $depth); @@ -350,7 +358,7 @@ class CorePlugin extends ServerPlugin { $response->setHeader('DAV', implode(', ', $features)); $prefer = $this->server->getHTTPPrefer(); - $minimal = $prefer['return'] === 'minimal'; + $minimal = 'minimal' === $prefer['return']; $data = $this->server->generateMultiStatus($newProperties, $minimal); $response->setBody($data); @@ -358,27 +366,27 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * WebDAV PROPPATCH + * WebDAV PROPPATCH. * * This method is called to update properties on a Node. The request is an XML body with all the mutations. * In this XML body it is specified which properties should be set/updated and/or deleted * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpPropPatch(RequestInterface $request, ResponseInterface $response) { - + public function httpPropPatch(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); try { $propPatch = $this->server->xml->expect('{DAV:}propertyupdate', $request->getBody()); } catch (ParseException $e) { - throw new BadRequest($e->getMessage(), null, $e); + throw new BadRequest($e->getMessage(), 0, $e); } $newProperties = $propPatch->properties; @@ -387,31 +395,27 @@ class CorePlugin extends ServerPlugin { $prefer = $this->server->getHTTPPrefer(); $response->setHeader('Vary', 'Brief,Prefer'); - if ($prefer['return'] === 'minimal') { - + if ('minimal' === $prefer['return']) { // If return-minimal is specified, we only have to check if the // request was successful, and don't need to return the // multi-status. $ok = true; foreach ($result as $prop => $code) { - if ((int)$code > 299) { + if ((int) $code > 299) { $ok = false; } } if ($ok) { - $response->setStatus(204); - return false; + return false; } - } $response->setStatus(207); $response->setHeader('Content-Type', 'application/xml; charset=utf-8'); - // Reorganizing the result for generateMultiStatus $multiStatus = []; foreach ($result as $propertyName => $code) { @@ -430,22 +434,22 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * HTTP PUT method + * HTTP PUT method. * * This HTTP method updates a file, or creates a new one. * * If a new resource was created, a 201 Created status code should be returned. If an existing resource is updated, it's a 204 No Content * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpPut(RequestInterface $request, ResponseInterface $response) { - + public function httpPut(RequestInterface $request, ResponseInterface $response) + { $body = $request->getBodyAsStream(); $path = $request->getPath(); @@ -463,7 +467,6 @@ class CorePlugin extends ServerPlugin { // Intercepting the Finder problem if (($expected = $request->getHeader('X-Expected-Entity-Length')) && $expected > 0) { - /* Many webservers will not cooperate well with Finder PUT requests, because it uses 'Chunked' transfer encoding for the request body. @@ -487,7 +490,7 @@ class CorePlugin extends ServerPlugin { // Only reading first byte $firstByte = fread($body, 1); - if (strlen($firstByte) !== 1) { + if (1 !== strlen($firstByte)) { throw new Exception\Forbidden('This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.'); } @@ -500,26 +503,25 @@ class CorePlugin extends ServerPlugin { rewind($newBody); $body = $newBody; - } if ($this->server->tree->nodeExists($path)) { - $node = $this->server->tree->getNodeForPath($path); // If the node is a collection, we'll deny it - if (!($node instanceof IFile)) throw new Exception\Conflict('PUT is not allowed on non-files.'); - + if (!($node instanceof IFile)) { + throw new Exception\Conflict('PUT is not allowed on non-files.'); + } if (!$this->server->updateFile($path, $body, $etag)) { return false; } $response->setHeader('Content-Length', '0'); - if ($etag) $response->setHeader('ETag', $etag); + if ($etag) { + $response->setHeader('ETag', $etag); + } $response->setStatus(204); - } else { - $etag = null; // If we got here, the resource didn't exist yet. if (!$this->server->createFile($path, $body, $etag)) { @@ -528,61 +530,55 @@ class CorePlugin extends ServerPlugin { } $response->setHeader('Content-Length', '0'); - if ($etag) $response->setHeader('ETag', $etag); + if ($etag) { + $response->setHeader('ETag', $etag); + } $response->setStatus(201); - } // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } - /** - * WebDAV MKCOL + * WebDAV MKCOL. * * The MKCOL method is used to create a new collection (directory) on the server * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpMkcol(RequestInterface $request, ResponseInterface $response) { - + public function httpMkcol(RequestInterface $request, ResponseInterface $response) + { $requestBody = $request->getBodyAsString(); $path = $request->getPath(); if ($requestBody) { - $contentType = $request->getHeader('Content-Type'); - if (strpos($contentType, 'application/xml') !== 0 && strpos($contentType, 'text/xml') !== 0) { - + if (null === $contentType || (0 !== strpos($contentType, 'application/xml') && 0 !== strpos($contentType, 'text/xml'))) { // We must throw 415 for unsupported mkcol bodies throw new Exception\UnsupportedMediaType('The request body for the MKCOL request must have an xml Content-Type'); - } try { $mkcol = $this->server->xml->expect('{DAV:}mkcol', $requestBody); } catch (\Sabre\Xml\ParseException $e) { - throw new Exception\BadRequest($e->getMessage(), null, $e); + throw new Exception\BadRequest($e->getMessage(), 0, $e); } $properties = $mkcol->getProperties(); - if (!isset($properties['{DAV:}resourcetype'])) + if (!isset($properties['{DAV:}resourcetype'])) { throw new Exception\BadRequest('The mkcol request must include a {DAV:}resourcetype property'); - + } $resourceType = $properties['{DAV:}resourcetype']->getValue(); unset($properties['{DAV:}resourcetype']); - } else { - $properties = []; $resourceType = ['{DAV:}collection']; - } $mkcol = new MkCol($resourceType, $properties); @@ -596,7 +592,6 @@ class CorePlugin extends ServerPlugin { $response->setBody( $this->server->generateMultiStatus([$result]) ); - } else { $response->setHeader('Content-Length', '0'); $response->setStatus(201); @@ -605,38 +600,42 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * WebDAV HTTP MOVE method + * WebDAV HTTP MOVE method. * * This method moves one uri to a different uri. A lot of the actual request processing is done in getCopyMoveInfo * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpMove(RequestInterface $request, ResponseInterface $response) { - + public function httpMove(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $moveInfo = $this->server->getCopyAndMoveInfo($request); if ($moveInfo['destinationExists']) { - - if (!$this->server->emit('beforeUnbind', [$moveInfo['destination']])) return false; - + if (!$this->server->emit('beforeUnbind', [$moveInfo['destination']])) { + return false; + } + } + if (!$this->server->emit('beforeUnbind', [$path])) { + return false; + } + if (!$this->server->emit('beforeBind', [$moveInfo['destination']])) { + return false; + } + if (!$this->server->emit('beforeMove', [$path, $moveInfo['destination']])) { + return false; } - if (!$this->server->emit('beforeUnbind', [$path])) return false; - if (!$this->server->emit('beforeBind', [$moveInfo['destination']])) return false; - if (!$this->server->emit('beforeMove', [$path, $moveInfo['destination']])) return false; if ($moveInfo['destinationExists']) { - $this->server->tree->delete($moveInfo['destination']); $this->server->emit('afterUnbind', [$moveInfo['destination']]); - } $this->server->tree->move($path, $moveInfo['destination']); @@ -656,28 +655,32 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * WebDAV HTTP COPY method + * WebDAV HTTP COPY method. * * This method copies one uri to a different uri, and works much like the MOVE request * A lot of the actual request processing is done in getCopyMoveInfo * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpCopy(RequestInterface $request, ResponseInterface $response) { - + public function httpCopy(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $copyInfo = $this->server->getCopyAndMoveInfo($request); - if (!$this->server->emit('beforeBind', [$copyInfo['destination']])) return false; + if (!$this->server->emit('beforeBind', [$copyInfo['destination']])) { + return false; + } if ($copyInfo['destinationExists']) { - if (!$this->server->emit('beforeUnbind', [$copyInfo['destination']])) return false; + if (!$this->server->emit('beforeUnbind', [$copyInfo['destination']])) { + return false; + } $this->server->tree->delete($copyInfo['destination']); } @@ -691,22 +694,21 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - - } /** - * HTTP REPORT method implementation + * HTTP REPORT method implementation. * * Although the REPORT method is not part of the standard WebDAV spec (it's from rfc3253) * It's used in a lot of extensions, so it made sense to implement it into the core. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpReport(RequestInterface $request, ResponseInterface $response) { - + public function httpReport(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $result = $this->server->xml->parse( @@ -716,16 +718,13 @@ class CorePlugin extends ServerPlugin { ); if ($this->server->emit('report', [$rootElementName, $result, $path])) { - // If emit returned true, it means the report was not supported throw new Exception\ReportNotSupported(); - } // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** @@ -734,12 +733,11 @@ class CorePlugin extends ServerPlugin { * Here we check if a user attempted to update a protected property and * ensure that the process fails if this is the case. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatchProtectedPropertyCheck($path, PropPatch $propPatch) { - + public function propPatchProtectedPropertyCheck($path, PropPatch $propPatch) + { // Comparing the mutation list to the list of protected properties. $mutations = $propPatch->getMutations(); @@ -751,7 +749,6 @@ class CorePlugin extends ServerPlugin { if ($protected) { $propPatch->setResultCode($protected, 403); } - } /** @@ -760,19 +757,17 @@ class CorePlugin extends ServerPlugin { * Here we check if a node implements IProperties and let the node handle * updating of (some) properties. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatchNodeUpdate($path, PropPatch $propPatch) { - + public function propPatchNodeUpdate($path, PropPatch $propPatch) + { // This should trigger a 404 if the node doesn't exist. $node = $this->server->tree->getNodeForPath($path); if ($node instanceof IProperties) { $node->propPatch($propPatch); } - } /** @@ -781,12 +776,11 @@ class CorePlugin extends ServerPlugin { * Here we add all the default properties. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - - $propFind->handle('{DAV:}getlastmodified', function() use ($node) { + public function propFind(PropFind $propFind, INode $node) + { + $propFind->handle('{DAV:}getlastmodified', function () use ($node) { $lm = $node->getLastModified(); if ($lm) { return new Xml\Property\GetLastModified($lm); @@ -801,34 +795,36 @@ class CorePlugin extends ServerPlugin { if ($node instanceof IQuota) { $quotaInfo = null; - $propFind->handle('{DAV:}quota-used-bytes', function() use (&$quotaInfo, $node) { + $propFind->handle('{DAV:}quota-used-bytes', function () use (&$quotaInfo, $node) { $quotaInfo = $node->getQuotaInfo(); + return $quotaInfo[0]; }); - $propFind->handle('{DAV:}quota-available-bytes', function() use (&$quotaInfo, $node) { + $propFind->handle('{DAV:}quota-available-bytes', function () use (&$quotaInfo, $node) { if (!$quotaInfo) { $quotaInfo = $node->getQuotaInfo(); } + return $quotaInfo[1]; }); } - $propFind->handle('{DAV:}supported-report-set', function() use ($propFind) { + $propFind->handle('{DAV:}supported-report-set', function () use ($propFind) { $reports = []; foreach ($this->server->getPlugins() as $plugin) { $reports = array_merge($reports, $plugin->getSupportedReportSet($propFind->getPath())); } + return new Xml\Property\SupportedReportSet($reports); }); - $propFind->handle('{DAV:}resourcetype', function() use ($node) { + $propFind->handle('{DAV:}resourcetype', function () use ($node) { return new Xml\Property\ResourceType($this->server->getResourceTypeForNode($node)); }); - $propFind->handle('{DAV:}supported-method-set', function() use ($propFind) { + $propFind->handle('{DAV:}supported-method-set', function () use ($propFind) { return new Xml\Property\SupportedMethodSet( $this->server->getAllowedMethods($propFind->getPath()) ); }); - } /** @@ -838,20 +834,16 @@ class CorePlugin extends ServerPlugin { * populate the result. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFindNode(PropFind $propFind, INode $node) { - + public function propFindNode(PropFind $propFind, INode $node) + { if ($node instanceof IProperties && $propertyNames = $propFind->get404Properties()) { - $nodeProperties = $node->getProperties($propertyNames); foreach ($nodeProperties as $propertyName => $propertyValue) { $propFind->set($propertyName, $propertyValue, 200); } - } - } /** @@ -861,17 +853,17 @@ class CorePlugin extends ServerPlugin { * want other systems to first have a chance to handle the properties. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFindLate(PropFind $propFind, INode $node) { - - $propFind->handle('{http://calendarserver.org/ns/}getctag', function() use ($propFind) { - + public function propFindLate(PropFind $propFind, INode $node) + { + $propFind->handle('{http://calendarserver.org/ns/}getctag', function () use ($propFind) { // If we already have a sync-token from the current propFind // request, we can re-use that. $val = $propFind->get('{http://sabredav.org/ns}sync-token'); - if ($val) return $val; + if ($val) { + return $val; + } $val = $propFind->get('{DAV:}sync-token'); if ($val && is_scalar($val)) { @@ -899,9 +891,7 @@ class CorePlugin extends ServerPlugin { return substr($val->getHref(), strlen(Sync\Plugin::SYNCTOKEN_PREFIX)); } } - }); - } /** @@ -909,8 +899,8 @@ class CorePlugin extends ServerPlugin { * * @param Exception $e */ - function exception($e) { - + public function exception($e) + { $logLevel = \Psr\Log\LogLevel::CRITICAL; if ($e instanceof \Sabre\DAV\Exception) { // If it's a standard sabre/dav exception, it means we have a http @@ -947,13 +937,12 @@ class CorePlugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'The Core plugin provides a lot of the basic functionality required by WebDAV, such as a default implementation for all HTTP and WebDAV methods.', - 'link' => null, + 'link' => null, ]; - } } diff --git a/vendor/sabre/dav/lib/DAV/Exception.php b/vendor/sabre/dav/lib/DAV/Exception.php index 14f5bab2a..e1d990623 100644 --- a/vendor/sabre/dav/lib/DAV/Exception.php +++ b/vendor/sabre/dav/lib/DAV/Exception.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -15,29 +17,26 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Exception extends \Exception { - +class Exception extends \Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 500; - } /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param Server $server + * @param Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(Server $server, \DOMElement $errorNode) { - - + public function serialize(Server $server, \DOMElement $errorNode) + { } /** @@ -46,12 +45,11 @@ class Exception extends \Exception { * The headers must be returned as an array. * * @param Server $server + * * @return array */ - function getHTTPHeaders(Server $server) { - + public function getHTTPHeaders(Server $server) + { return []; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/BadRequest.php b/vendor/sabre/dav/lib/DAV/Exception/BadRequest.php index c21f493da..569c63ba0 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/BadRequest.php +++ b/vendor/sabre/dav/lib/DAV/Exception/BadRequest.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * BadRequest + * BadRequest. * * The BadRequest is thrown when the user submitted an invalid HTTP request * BadRequest @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class BadRequest extends DAV\Exception { - +class BadRequest extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 400; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/Conflict.php b/vendor/sabre/dav/lib/DAV/Exception/Conflict.php index 4190e6082..2ec227feb 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/Conflict.php +++ b/vendor/sabre/dav/lib/DAV/Exception/Conflict.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * Conflict + * Conflict. * * A 409 Conflict is thrown when a user tried to make a directory over an existing * file or in a parent directory that doesn't exist. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Conflict extends DAV\Exception { - +class Conflict extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 409; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/ConflictingLock.php b/vendor/sabre/dav/lib/DAV/Exception/ConflictingLock.php index b2d2746c5..c1a4914ed 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/ConflictingLock.php +++ b/vendor/sabre/dav/lib/DAV/Exception/ConflictingLock.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * ConflictingLock + * ConflictingLock. * * Similar to the Locked exception, this exception thrown when a LOCK request * was made, on a resource which was already locked @@ -14,23 +16,20 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ConflictingLock extends Locked { - +class ConflictingLock extends Locked +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { if ($this->lock) { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:no-conflicting-lock'); $errorNode->appendChild($error); $error->appendChild($errorNode->ownerDocument->createElementNS('DAV:', 'd:href', $this->lock->uri)); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/Forbidden.php b/vendor/sabre/dav/lib/DAV/Exception/Forbidden.php index 77df7ca9e..2f882c396 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/Forbidden.php +++ b/vendor/sabre/dav/lib/DAV/Exception/Forbidden.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * Forbidden + * Forbidden. * * This exception is thrown whenever a user tries to do an operation he's not allowed to * @@ -13,17 +15,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Forbidden extends DAV\Exception { - +class Forbidden extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 403; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/InsufficientStorage.php b/vendor/sabre/dav/lib/DAV/Exception/InsufficientStorage.php index 96e1acc50..fe6e1268c 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/InsufficientStorage.php +++ b/vendor/sabre/dav/lib/DAV/Exception/InsufficientStorage.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * InsufficientStorage + * InsufficientStorage. * * This Exception can be thrown, when for example a harddisk is full or a quota is exceeded * @@ -13,17 +15,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InsufficientStorage extends DAV\Exception { - +class InsufficientStorage extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 507; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/InvalidResourceType.php b/vendor/sabre/dav/lib/DAV/Exception/InvalidResourceType.php index 6324d9f3a..99baeb8bc 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/InvalidResourceType.php +++ b/vendor/sabre/dav/lib/DAV/Exception/InvalidResourceType.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; /** - * InvalidResourceType + * InvalidResourceType. * * This exception is thrown when the user tried to create a new collection, with * a special resourcetype value that was not recognized by the server. @@ -14,20 +16,17 @@ namespace Sabre\DAV\Exception; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InvalidResourceType extends Forbidden { - +class InvalidResourceType extends Forbidden +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * * @param \Sabre\DAV\Server $server - * @param \DOMElement $errorNode - * @return void + * @param \DOMElement $errorNode */ - function serialize(\Sabre\DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(\Sabre\DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:valid-resourcetype'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php b/vendor/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php index 51a253b29..6c5f1c435 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php +++ b/vendor/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * InvalidSyncToken + * InvalidSyncToken. * * This exception is emited for the {DAV:}valid-sync-token pre-condition, as * defined in rfc6578, section 3.2. @@ -19,20 +21,17 @@ use Sabre\DAV; * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InvalidSyncToken extends Forbidden { - +class InvalidSyncToken extends Forbidden +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:valid-sync-token'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/LengthRequired.php b/vendor/sabre/dav/lib/DAV/Exception/LengthRequired.php index 989718558..9d26fcb10 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/LengthRequired.php +++ b/vendor/sabre/dav/lib/DAV/Exception/LengthRequired.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * LengthRequired + * LengthRequired. * * This exception is thrown when a request was made that required a * Content-Length header, but did not contain one. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class LengthRequired extends DAV\Exception { - +class LengthRequired extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 411; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/LockTokenMatchesRequestUri.php b/vendor/sabre/dav/lib/DAV/Exception/LockTokenMatchesRequestUri.php index 5f8c31868..1c7402384 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/LockTokenMatchesRequestUri.php +++ b/vendor/sabre/dav/lib/DAV/Exception/LockTokenMatchesRequestUri.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * LockTokenMatchesRequestUri + * LockTokenMatchesRequestUri. * * This exception is thrown by UNLOCK if a supplied lock-token is invalid * @@ -13,29 +15,25 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class LockTokenMatchesRequestUri extends Conflict { - +class LockTokenMatchesRequestUri extends Conflict +{ /** - * Creates the exception + * Creates the exception. */ - function __construct() { - - $this->message = 'The locktoken supplied does not match any locks on this entity'; - + public function __construct() + { + parent::__construct('The locktoken supplied does not match any locks on this entity'); } /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:lock-token-matches-request-uri'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/Locked.php b/vendor/sabre/dav/lib/DAV/Exception/Locked.php index 8176db46e..632bafc60 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/Locked.php +++ b/vendor/sabre/dav/lib/DAV/Exception/Locked.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * Locked + * Locked. * * The 423 is thrown when a client tried to access a resource that was locked, without supplying a valid lock token * @@ -13,49 +15,48 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Locked extends DAV\Exception { - +class Locked extends DAV\Exception +{ /** - * Lock information + * Lock information. * - * @var Sabre\DAV\Locks\LockInfo + * @var \Sabre\DAV\Locks\LockInfo */ protected $lock; /** - * Creates the exception + * Creates the exception. * * A LockInfo object should be passed if the user should be informed * which lock actually has the file locked. * * @param DAV\Locks\LockInfo $lock */ - function __construct(DAV\Locks\LockInfo $lock = null) { + public function __construct(DAV\Locks\LockInfo $lock = null) + { + parent::__construct(); $this->lock = $lock; - } /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 423; - } /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { if ($this->lock) { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:lock-token-submitted'); $errorNode->appendChild($error); @@ -66,7 +67,5 @@ class Locked extends DAV\Exception { $href ); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php b/vendor/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php index 30c1c2553..a3d9c56f2 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php +++ b/vendor/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * MethodNotAllowed + * MethodNotAllowed. * * The 405 is thrown when a client tried to create a directory on an already existing directory * @@ -13,17 +15,16 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MethodNotAllowed extends DAV\Exception { - +class MethodNotAllowed extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 405; - } /** @@ -32,16 +33,15 @@ class MethodNotAllowed extends DAV\Exception { * The headers must be returned as an array. * * @param \Sabre\DAV\Server $server + * * @return array */ - function getHTTPHeaders(\Sabre\DAV\Server $server) { - + public function getHTTPHeaders(\Sabre\DAV\Server $server) + { $methods = $server->getAllowedMethods($server->getRequestUri()); return [ 'Allow' => strtoupper(implode(', ', $methods)), ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/NotAuthenticated.php b/vendor/sabre/dav/lib/DAV/Exception/NotAuthenticated.php index e69a60c75..0a5ba9b5a 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/NotAuthenticated.php +++ b/vendor/sabre/dav/lib/DAV/Exception/NotAuthenticated.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * NotAuthenticated + * NotAuthenticated. * * This exception is thrown when the client did not provide valid * authentication credentials. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotAuthenticated extends DAV\Exception { - +class NotAuthenticated extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 401; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/NotFound.php b/vendor/sabre/dav/lib/DAV/Exception/NotFound.php index b0397446d..9cf837074 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/NotFound.php +++ b/vendor/sabre/dav/lib/DAV/Exception/NotFound.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * NotFound + * NotFound. * * This Exception is thrown when a Node couldn't be found. It returns HTTP error code 404 * @@ -13,17 +15,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotFound extends DAV\Exception { - +class NotFound extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 404; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/NotImplemented.php b/vendor/sabre/dav/lib/DAV/Exception/NotImplemented.php index 68f309222..cebb83363 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/NotImplemented.php +++ b/vendor/sabre/dav/lib/DAV/Exception/NotImplemented.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * NotImplemented + * NotImplemented. * * This exception is thrown when the client tried to call an unsupported HTTP method or other feature * @@ -13,17 +15,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotImplemented extends DAV\Exception { - +class NotImplemented extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 501; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/PaymentRequired.php b/vendor/sabre/dav/lib/DAV/Exception/PaymentRequired.php index 43e17344a..d237f906b 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/PaymentRequired.php +++ b/vendor/sabre/dav/lib/DAV/Exception/PaymentRequired.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * Payment Required + * Payment Required. * * The PaymentRequired exception may be thrown in a case where a user must pay * to access a certain resource or operation. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PaymentRequired extends DAV\Exception { - +class PaymentRequired extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 402; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/PreconditionFailed.php b/vendor/sabre/dav/lib/DAV/Exception/PreconditionFailed.php index 550360e5a..20d8a2a30 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/PreconditionFailed.php +++ b/vendor/sabre/dav/lib/DAV/Exception/PreconditionFailed.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * PreconditionFailed + * PreconditionFailed. * * This exception is normally thrown when a client submitted a conditional request, * like for example an If, If-None-Match or If-Match header, which caused the HTTP @@ -15,8 +17,8 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PreconditionFailed extends DAV\Exception { - +class PreconditionFailed extends DAV\Exception +{ /** * When this exception is thrown, the header-name might be set. * @@ -28,44 +30,39 @@ class PreconditionFailed extends DAV\Exception { public $header = null; /** - * Create the exception + * Create the exception. * * @param string $message * @param string $header */ - function __construct($message, $header = null) { - + public function __construct($message, $header = null) + { parent::__construct($message); $this->header = $header; - } /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 412; - } /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { if ($this->header) { $prop = $errorNode->ownerDocument->createElement('s:header'); $prop->nodeValue = $this->header; $errorNode->appendChild($prop); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/ReportNotSupported.php b/vendor/sabre/dav/lib/DAV/Exception/ReportNotSupported.php index a83695627..cecfec12d 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/ReportNotSupported.php +++ b/vendor/sabre/dav/lib/DAV/Exception/ReportNotSupported.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * ReportNotSupported + * ReportNotSupported. * * This exception is thrown when the client requested an unknown report through the REPORT method * @@ -13,20 +15,17 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ReportNotSupported extends UnsupportedMediaType { - +class ReportNotSupported extends UnsupportedMediaType +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:supported-report'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php b/vendor/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php index c8ccfc062..6ccb5b8c8 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php +++ b/vendor/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * RequestedRangeNotSatisfiable + * RequestedRangeNotSatisfiable. * * This exception is normally thrown when the user * request a range that is out of the entity bounds. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class RequestedRangeNotSatisfiable extends DAV\Exception { - +class RequestedRangeNotSatisfiable extends DAV\Exception +{ /** - * returns the http statuscode for this exception + * returns the http statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 416; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/ServiceUnavailable.php b/vendor/sabre/dav/lib/DAV/Exception/ServiceUnavailable.php index 31df606e2..43c995c9c 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/ServiceUnavailable.php +++ b/vendor/sabre/dav/lib/DAV/Exception/ServiceUnavailable.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * ServiceUnavailable + * ServiceUnavailable. * * This exception is thrown in case the service * is currently not available (e.g. down for maintenance). @@ -14,17 +16,15 @@ use Sabre\DAV; * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ServiceUnavailable extends DAV\Exception { - +class ServiceUnavailable extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 503; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/TooManyMatches.php b/vendor/sabre/dav/lib/DAV/Exception/TooManyMatches.php index d0f0f84e8..7dbe878b9 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/TooManyMatches.php +++ b/vendor/sabre/dav/lib/DAV/Exception/TooManyMatches.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * TooManyMatches + * TooManyMatches. * * This exception is emited for the {DAV:}number-of-matches-within-limits * post-condition, as defined in rfc6578, section 3.2. @@ -19,20 +21,17 @@ use Sabre\DAV; * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @license http://sabre.io/license/ Modified BSD License */ -class TooManyMatches extends Forbidden { - +class TooManyMatches extends Forbidden +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:number-of-matches-within-limits'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php b/vendor/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php index f3d92842d..bc9da30da 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php +++ b/vendor/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * UnSupportedMediaType + * UnSupportedMediaType. * * The 415 Unsupported Media Type status code is generally sent back when the client * tried to call an HTTP method, with a body the server didn't understand @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class UnsupportedMediaType extends DAV\Exception { - +class UnsupportedMediaType extends DAV\Exception +{ /** - * returns the http statuscode for this exception + * returns the http statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 415; - } - } diff --git a/vendor/sabre/dav/lib/DAV/FS/Directory.php b/vendor/sabre/dav/lib/DAV/FS/Directory.php index 362f7a411..047692294 100644 --- a/vendor/sabre/dav/lib/DAV/FS/Directory.php +++ b/vendor/sabre/dav/lib/DAV/FS/Directory.php @@ -1,20 +1,22 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FS; use Sabre\DAV; /** - * Directory class + * Directory class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Directory extends Node implements DAV\ICollection, DAV\IQuota { - +class Directory extends Node implements DAV\ICollection, DAV\IQuota +{ /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -33,67 +35,63 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - - $newPath = $this->path . '/' . $name; + public function createFile($name, $data = null) + { + $newPath = $this->path.'/'.$name; file_put_contents($newPath, $data); clearstatcache(true, $newPath); - } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name - * @return void */ - function createDirectory($name) { - - $newPath = $this->path . '/' . $name; + public function createDirectory($name) + { + $newPath = $this->path.'/'.$name; mkdir($newPath); clearstatcache(true, $newPath); - } /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * This method must throw DAV\Exception\NotFound if the node does not * exist. * * @param string $name + * * @throws DAV\Exception\NotFound + * * @return DAV\INode */ - function getChild($name) { - - $path = $this->path . '/' . $name; - - if (!file_exists($path)) throw new DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); + public function getChild($name) + { + $path = $this->path.'/'.$name; + if (!file_exists($path)) { + throw new DAV\Exception\NotFound('File with name '.$path.' could not be located'); + } if (is_dir($path)) { - return new self($path); - } else { - return new File($path); - } - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return DAV\INode[] */ - function getChildren() { - + public function getChildren() + { $nodes = []; $iterator = new \FilesystemIterator( $this->path, @@ -101,51 +99,49 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota { | \FilesystemIterator::SKIP_DOTS ); foreach ($iterator as $entry) { - $nodes[] = $this->getChild($entry->getFilename()); - } - return $nodes; + return $nodes; } /** * Checks if a child exists. * * @param string $name + * * @return bool */ - function childExists($name) { + public function childExists($name) + { + $path = $this->path.'/'.$name; - $path = $this->path . '/' . $name; return file_exists($path); - } /** - * Deletes all files in this directory, and then itself - * - * @return void + * Deletes all files in this directory, and then itself. */ - function delete() { - - foreach ($this->getChildren() as $child) $child->delete(); + public function delete() + { + foreach ($this->getChildren() as $child) { + $child->delete(); + } rmdir($this->path); - } /** - * Returns available diskspace information + * Returns available diskspace information. * * @return array */ - function getQuotaInfo() { + public function getQuotaInfo() + { $absolute = realpath($this->path); + return [ disk_total_space($absolute) - disk_free_space($absolute), - disk_free_space($absolute) + disk_free_space($absolute), ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/FS/File.php b/vendor/sabre/dav/lib/DAV/FS/File.php index 4fc5af057..b78a80138 100644 --- a/vendor/sabre/dav/lib/DAV/FS/File.php +++ b/vendor/sabre/dav/lib/DAV/FS/File.php @@ -1,66 +1,61 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FS; use Sabre\DAV; /** - * File class + * File class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends Node implements DAV\IFile { - +class File extends Node implements DAV\IFile +{ /** - * Updates the data + * Updates the data. * * @param resource $data - * @return void */ - function put($data) { - + public function put($data) + { file_put_contents($this->path, $data); clearstatcache(true, $this->path); - } /** - * Returns the data + * Returns the data. * * @return resource */ - function get() { - + public function get() + { return fopen($this->path, 'r'); - } /** - * Delete the current file - * - * @return void + * Delete the current file. */ - function delete() { - + public function delete() + { unlink($this->path); - } /** - * Returns the size of the node, in bytes + * Returns the size of the node, in bytes. * * @return int */ - function getSize() { - + public function getSize() + { return filesize($this->path); - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. @@ -69,27 +64,24 @@ class File extends Node implements DAV\IFile { * * @return mixed */ - function getETag() { - - return '"' . sha1( - fileinode($this->path) . - filesize($this->path) . + public function getETag() + { + return '"'.sha1( + fileinode($this->path). + filesize($this->path). filemtime($this->path) - ) . '"'; - + ).'"'; } /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream * * @return mixed */ - function getContentType() { - + public function getContentType() + { return null; - } - } diff --git a/vendor/sabre/dav/lib/DAV/FS/Node.php b/vendor/sabre/dav/lib/DAV/FS/Node.php index 424718f96..32aa74755 100644 --- a/vendor/sabre/dav/lib/DAV/FS/Node.php +++ b/vendor/sabre/dav/lib/DAV/FS/Node.php @@ -1,12 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FS; -use Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\DAV\Exception\Forbidden; +use Sabre\DAV\INode; +use Sabre\Uri; /** - * Base node-class + * Base node-class. * * The node class implements the method used by both the File and the Directory classes * @@ -14,67 +17,80 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Node implements DAV\INode { - +abstract class Node implements INode +{ /** - * The path to the current node + * The path to the current node. * * @var string */ protected $path; /** - * Sets up the node, expects a full path name + * The overridden name of the node. * - * @param string $path + * @var string */ - function __construct($path) { + protected $overrideName; + /** + * Sets up the node, expects a full path name. + * + * If $overrideName is set, this node shows up in the tree under a + * different name. In this case setName() will be disabled. + * + * @param string $path + * @param string $overrideName + */ + public function __construct($path, $overrideName = null) + { $this->path = $path; - + $this->overrideName = $overrideName; } - - /** - * Returns the name of the node + * Returns the name of the node. * * @return string */ - function getName() { + public function getName() + { + if ($this->overrideName) { + return $this->overrideName; + } - list(, $name) = URLUtil::splitPath($this->path); - return $name; + list(, $name) = Uri\split($this->path); + return $name; } /** - * Renames the node + * Renames the node. * * @param string $name The new name - * @return void */ - function setName($name) { + public function setName($name) + { + if ($this->overrideName) { + throw new Forbidden('This node cannot be renamed'); + } - list($parentPath, ) = URLUtil::splitPath($this->path); - list(, $newName) = URLUtil::splitPath($name); + list($parentPath) = Uri\split($this->path); + list(, $newName) = Uri\split($name); - $newPath = $parentPath . '/' . $newName; + $newPath = $parentPath.'/'.$newName; rename($this->path, $newPath); $this->path = $newPath; - } /** - * Returns the last modification time, as a unix timestamp + * Returns the last modification time, as a unix timestamp. * * @return int */ - function getLastModified() { - + public function getLastModified() + { return filemtime($this->path); - } - } diff --git a/vendor/sabre/dav/lib/DAV/FSExt/Directory.php b/vendor/sabre/dav/lib/DAV/FSExt/Directory.php index dd5f992db..d6aea0094 100644 --- a/vendor/sabre/dav/lib/DAV/FSExt/Directory.php +++ b/vendor/sabre/dav/lib/DAV/FSExt/Directory.php @@ -1,21 +1,23 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FSExt; use Sabre\DAV; use Sabre\DAV\FS\Node; /** - * Directory class + * Directory class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTarget { - +class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTarget +{ /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -34,94 +36,97 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - + public function createFile($name, $data = null) + { // We're not allowing dots - if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..'); - $newPath = $this->path . '/' . $name; + if ('.' == $name || '..' == $name) { + throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + } + $newPath = $this->path.'/'.$name; file_put_contents($newPath, $data); clearstatcache(true, $newPath); - return '"' . sha1( - fileinode($newPath) . - filesize($newPath) . + return '"'.sha1( + fileinode($newPath). + filesize($newPath). filemtime($newPath) - ) . '"'; - + ).'"'; } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { // We're not allowing dots - if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..'); - $newPath = $this->path . '/' . $name; + if ('.' == $name || '..' == $name) { + throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + } + $newPath = $this->path.'/'.$name; mkdir($newPath); clearstatcache(true, $newPath); - } /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * This method must throw Sabre\DAV\Exception\NotFound if the node does not * exist. * * @param string $name + * * @throws DAV\Exception\NotFound + * * @return DAV\INode */ - function getChild($name) { - - $path = $this->path . '/' . $name; - - if (!file_exists($path)) throw new DAV\Exception\NotFound('File could not be located'); - if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + public function getChild($name) + { + $path = $this->path.'/'.$name; + if (!file_exists($path)) { + throw new DAV\Exception\NotFound('File could not be located'); + } + if ('.' == $name || '..' == $name) { + throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + } if (is_dir($path)) { - return new self($path); - } else { - return new File($path); - } - } /** * Checks if a child exists. * * @param string $name + * * @return bool */ - function childExists($name) { - - if ($name == '.' || $name == '..') + public function childExists($name) + { + if ('.' == $name || '..' == $name) { throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + } + $path = $this->path.'/'.$name; - $path = $this->path . '/' . $name; return file_exists($path); - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return DAV\INode[] */ - function getChildren() { - + public function getChildren() + { $nodes = []; $iterator = new \FilesystemIterator( $this->path, @@ -130,44 +135,43 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa ); foreach ($iterator as $entry) { - $nodes[] = $this->getChild($entry->getFilename()); - } - return $nodes; + return $nodes; } /** - * Deletes all files in this directory, and then itself + * Deletes all files in this directory, and then itself. * * @return bool */ - function delete() { - + public function delete() + { // Deleting all children - foreach ($this->getChildren() as $child) $child->delete(); + foreach ($this->getChildren() as $child) { + $child->delete(); + } // Removing the directory itself rmdir($this->path); return true; - } /** - * Returns available diskspace information + * Returns available diskspace information. * * @return array */ - function getQuotaInfo() { - + public function getQuotaInfo() + { $total = disk_total_space(realpath($this->path)); $free = disk_free_space(realpath($this->path)); return [ $total - $free, - $free + $free, ]; } @@ -186,13 +190,14 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa * the move itself. If you return true from this function, the assumption * is that the move was successful. * - * @param string $targetName New local file/collection name. - * @param string $sourcePath Full path to source node + * @param string $targetName new local file/collection name + * @param string $sourcePath Full path to source node * @param DAV\INode $sourceNode Source node itself + * * @return bool */ - function moveInto($targetName, $sourcePath, DAV\INode $sourceNode) { - + public function moveInto($targetName, $sourcePath, DAV\INode $sourceNode) + { // We only support FSExt\Directory or FSExt\File objects, so // anything else we want to quickly reject. if (!$sourceNode instanceof self && !$sourceNode instanceof File) { @@ -200,12 +205,8 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa } // PHP allows us to access protected properties from other objects, as - // long as they are defined in a class that has a shared inheritence + // long as they are defined in a class that has a shared inheritance // with the current class. - rename($sourceNode->path, $this->path . '/' . $targetName); - - return true; - + return rename($sourceNode->path, $this->path.'/'.$targetName); } - } diff --git a/vendor/sabre/dav/lib/DAV/FSExt/File.php b/vendor/sabre/dav/lib/DAV/FSExt/File.php index eb5ae19fe..060ef5a48 100644 --- a/vendor/sabre/dav/lib/DAV/FSExt/File.php +++ b/vendor/sabre/dav/lib/DAV/FSExt/File.php @@ -1,33 +1,36 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FSExt; use Sabre\DAV; use Sabre\DAV\FS\Node; /** - * File class + * File class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends Node implements DAV\PartialUpdate\IPatchSupport { - +class File extends Node implements DAV\PartialUpdate\IPatchSupport +{ /** - * Updates the data + * Updates the data. * * Data is a readable stream resource. * * @param resource|string $data + * * @return string */ - function put($data) { - + public function put($data) + { file_put_contents($this->path, $data); clearstatcache(true, $this->path); - return $this->getETag(); + return $this->getETag(); } /** @@ -53,21 +56,22 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport { * time. * * @param resource|string $data - * @param int $rangeType - * @param int $offset + * @param int $rangeType + * @param int $offset + * * @return string|null */ - function patch($data, $rangeType, $offset = null) { - + public function patch($data, $rangeType, $offset = null) + { switch ($rangeType) { - case 1 : + case 1: $f = fopen($this->path, 'a'); break; - case 2 : + case 2: $f = fopen($this->path, 'c'); fseek($f, $offset); break; - case 3 : + case 3: $f = fopen($this->path, 'c'); fseek($f, $offset, SEEK_END); break; @@ -79,34 +83,32 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport { } fclose($f); clearstatcache(true, $this->path); - return $this->getETag(); + return $this->getETag(); } /** - * Returns the data + * Returns the data. * * @return resource */ - function get() { - + public function get() + { return fopen($this->path, 'r'); - } /** - * Delete the current file + * Delete the current file. * * @return bool */ - function delete() { - + public function delete() + { return unlink($this->path); - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. @@ -115,38 +117,34 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport { * * @return string|null */ - function getETag() { - - return '"' . sha1( - fileinode($this->path) . - filesize($this->path) . + public function getETag() + { + return '"'.sha1( + fileinode($this->path). + filesize($this->path). filemtime($this->path) - ) . '"'; - + ).'"'; } /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream * * @return string|null */ - function getContentType() { - + public function getContentType() + { return null; - } /** - * Returns the size of the file, in bytes + * Returns the size of the file, in bytes. * * @return int */ - function getSize() { - + public function getSize() + { return filesize($this->path); - } - } diff --git a/vendor/sabre/dav/lib/DAV/File.php b/vendor/sabre/dav/lib/DAV/File.php index 5161fbd51..daf83aa4d 100644 --- a/vendor/sabre/dav/lib/DAV/File.php +++ b/vendor/sabre/dav/lib/DAV/File.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * File class + * File class. * * This is a helper class, that should aid in getting file classes setup. * Most of its methods are implemented, and throw permission denied exceptions @@ -12,8 +14,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class File extends Node implements IFile { - +abstract class File extends Node implements IFile +{ /** * Replaces the contents of the file. * @@ -32,25 +34,24 @@ abstract class File extends Node implements IFile { * return an ETag, and just return null. * * @param string|resource $data + * * @return string|null */ - function put($data) { - + public function put($data) + { throw new Exception\Forbidden('Permission denied to change data'); - } /** - * Returns the data + * Returns the data. * * This method may either return a string or a readable stream resource * * @return mixed */ - function get() { - + public function get() + { throw new Exception\Forbidden('Permission denied to read this file'); - } /** @@ -58,14 +59,13 @@ abstract class File extends Node implements IFile { * * @return int */ - function getSize() { - + public function getSize() + { return 0; - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. @@ -74,23 +74,20 @@ abstract class File extends Node implements IFile { * * @return string|null */ - function getETag() { - + public function getETag() + { return null; - } /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream * * @return string|null */ - function getContentType() { - + public function getContentType() + { return null; - } - } diff --git a/vendor/sabre/dav/lib/DAV/ICollection.php b/vendor/sabre/dav/lib/DAV/ICollection.php index 7793070d3..c039dae56 100644 --- a/vendor/sabre/dav/lib/DAV/ICollection.php +++ b/vendor/sabre/dav/lib/DAV/ICollection.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * The ICollection Interface + * The ICollection Interface. * * This interface should be implemented by each class that represents a collection * @@ -11,10 +13,10 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ICollection extends INode { - +interface ICollection extends INode +{ /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -33,44 +35,45 @@ interface ICollection extends INode { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null); + public function createFile($name, $data = null); /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name - * @return void */ - function createDirectory($name); + public function createDirectory($name); /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * This method must throw Sabre\DAV\Exception\NotFound if the node does not * exist. * * @param string $name + * * @return INode */ - function getChild($name); + public function getChild($name); /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return INode[] */ - function getChildren(); + public function getChildren(); /** - * Checks if a child-node with the specified name exists + * Checks if a child-node with the specified name exists. * * @param string $name + * * @return bool */ - function childExists($name); - + public function childExists($name); } diff --git a/vendor/sabre/dav/lib/DAV/ICopyTarget.php b/vendor/sabre/dav/lib/DAV/ICopyTarget.php new file mode 100644 index 000000000..47227138a --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/ICopyTarget.php @@ -0,0 +1,38 @@ +<?php + +declare(strict_types=1); + +namespace Sabre\DAV; + +/** + * By implementing this interface, a collection can effectively say "other + * nodes may be copied into this collection". + * + * If a backend supports a better optimized copy operation, e.g. by avoiding + * copying the contents, this can trigger some huge speed gains. + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +interface ICopyTarget extends ICollection +{ + /** + * Copies a node into this collection. + * + * It is up to the implementors to: + * 1. Create the new resource. + * 2. Copy the data and any properties. + * + * If you return true from this function, the assumption + * is that the copy was successful. + * If you return false, sabre/dav will handle the copy itself. + * + * @param string $targetName new local file/collection name + * @param string $sourcePath Full path to source node + * @param INode $sourceNode Source node itself + * + * @return bool + */ + public function copyInto($targetName, $sourcePath, INode $sourceNode); +} diff --git a/vendor/sabre/dav/lib/DAV/IExtendedCollection.php b/vendor/sabre/dav/lib/DAV/IExtendedCollection.php index c561d7072..d43b44bcb 100644 --- a/vendor/sabre/dav/lib/DAV/IExtendedCollection.php +++ b/vendor/sabre/dav/lib/DAV/IExtendedCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -12,8 +14,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IExtendedCollection extends ICollection { - +interface IExtendedCollection extends ICollection +{ /** * Creates a new collection. * @@ -34,10 +36,9 @@ interface IExtendedCollection extends ICollection { * property for you. * * @param string $name - * @param MkCol $mkCol + * @param MkCol $mkCol + * * @throws Exception\InvalidResourceType - * @return void */ - function createExtendedCollection($name, MkCol $mkCol); - + public function createExtendedCollection($name, MkCol $mkCol); } diff --git a/vendor/sabre/dav/lib/DAV/IFile.php b/vendor/sabre/dav/lib/DAV/IFile.php index 19d8d8637..974aee00d 100644 --- a/vendor/sabre/dav/lib/DAV/IFile.php +++ b/vendor/sabre/dav/lib/DAV/IFile.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * This interface represents a file in the directory tree + * This interface represents a file in the directory tree. * * A file is a bit of a broad definition. In general it implies that on * this specific node a PUT or GET method may be performed, to either update, @@ -13,8 +15,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IFile extends INode { - +interface IFile extends INode +{ /** * Replaces the contents of the file. * @@ -33,30 +35,31 @@ interface IFile extends INode { * return an ETag, and just return null. * * @param resource|string $data + * * @return string|null */ - function put($data); + public function put($data); /** - * Returns the data + * Returns the data. * * This method may either return a string or a readable stream resource * * @return mixed */ - function get(); + public function get(); /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream * * @return string|null */ - function getContentType(); + public function getContentType(); /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * @@ -69,13 +72,12 @@ interface IFile extends INode { * * @return string|null */ - function getETag(); + public function getETag(); /** - * Returns the size of the node, in bytes + * Returns the size of the node, in bytes. * * @return int */ - function getSize(); - + public function getSize(); } diff --git a/vendor/sabre/dav/lib/DAV/IMoveTarget.php b/vendor/sabre/dav/lib/DAV/IMoveTarget.php index 92fde1d5c..18a24081e 100644 --- a/vendor/sabre/dav/lib/DAV/IMoveTarget.php +++ b/vendor/sabre/dav/lib/DAV/IMoveTarget.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -17,8 +19,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IMoveTarget extends ICollection { - +interface IMoveTarget extends ICollection +{ /** * Moves a node into this collection. * @@ -34,11 +36,11 @@ interface IMoveTarget extends ICollection { * the move itself. If you return true from this function, the assumption * is that the move was successful. * - * @param string $targetName New local file/collection name. + * @param string $targetName new local file/collection name * @param string $sourcePath Full path to source node - * @param INode $sourceNode Source node itself + * @param INode $sourceNode Source node itself + * * @return bool */ - function moveInto($targetName, $sourcePath, INode $sourceNode); - + public function moveInto($targetName, $sourcePath, INode $sourceNode); } diff --git a/vendor/sabre/dav/lib/DAV/IMultiGet.php b/vendor/sabre/dav/lib/DAV/IMultiGet.php index e26b457ef..445e761eb 100644 --- a/vendor/sabre/dav/lib/DAV/IMultiGet.php +++ b/vendor/sabre/dav/lib/DAV/IMultiGet.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * IMultiGet + * IMultiGet. * * This interface adds a tiny bit of functionality to collections. * @@ -20,8 +22,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IMultiGet extends ICollection { - +interface IMultiGet extends ICollection +{ /** * This method receives a list of paths in it's first argument. * It must return an array with Node objects. @@ -29,8 +31,8 @@ interface IMultiGet extends ICollection { * If any children are not found, you do not have to return them. * * @param string[] $paths + * * @return array */ - function getMultipleChildren(array $paths); - + public function getMultipleChildren(array $paths); } diff --git a/vendor/sabre/dav/lib/DAV/INode.php b/vendor/sabre/dav/lib/DAV/INode.php index bb884934d..f3e7e395b 100644 --- a/vendor/sabre/dav/lib/DAV/INode.php +++ b/vendor/sabre/dav/lib/DAV/INode.php @@ -1,22 +1,22 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * The INode interface is the base interface, and the parent class of both ICollection and IFile + * The INode interface is the base interface, and the parent class of both ICollection and IFile. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface INode { - +interface INode +{ /** - * Deleted the current node - * - * @return void + * Deleted the current node. */ - function delete(); + public function delete(); /** * Returns the name of the node. @@ -25,15 +25,14 @@ interface INode { * * @return string */ - function getName(); + public function getName(); /** - * Renames the node + * Renames the node. * * @param string $name The new name - * @return void */ - function setName($name); + public function setName($name); /** * Returns the last modification time, as a unix timestamp. Return null @@ -41,6 +40,5 @@ interface INode { * * @return int|null */ - function getLastModified(); - + public function getLastModified(); } diff --git a/vendor/sabre/dav/lib/DAV/IProperties.php b/vendor/sabre/dav/lib/DAV/IProperties.php index 00969c2c4..d50fdff20 100644 --- a/vendor/sabre/dav/lib/DAV/IProperties.php +++ b/vendor/sabre/dav/lib/DAV/IProperties.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * IProperties interface + * IProperties interface. * * Implement this interface to support custom WebDAV properties requested and sent from clients. * @@ -11,8 +13,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IProperties extends INode { - +interface IProperties extends INode +{ /** * Updates properties on this node. * @@ -23,9 +25,8 @@ interface IProperties extends INode { * Read the PropPatch documentation for more information. * * @param PropPatch $propPatch - * @return void */ - function propPatch(PropPatch $propPatch); + public function propPatch(PropPatch $propPatch); /** * Returns a list of properties for this nodes. @@ -40,8 +41,8 @@ interface IProperties extends INode { * The Server class will filter out the extra. * * @param array $properties + * * @return array */ - function getProperties($properties); - + public function getProperties($properties); } diff --git a/vendor/sabre/dav/lib/DAV/IQuota.php b/vendor/sabre/dav/lib/DAV/IQuota.php index e16f386b9..7d72e1174 100644 --- a/vendor/sabre/dav/lib/DAV/IQuota.php +++ b/vendor/sabre/dav/lib/DAV/IQuota.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * IQuota interface + * IQuota interface. * * Implement this interface to add the ability to return quota information. The ObjectTree * will check for quota information on any given node. If the information is not available it will @@ -13,14 +15,13 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IQuota extends ICollection { - +interface IQuota extends ICollection +{ /** - * Returns the quota information + * Returns the quota information. * * This method MUST return an array with 2 values, the first being the total used space, * the second the available space (in bytes) */ - function getQuotaInfo(); - + public function getQuotaInfo(); } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php index 044316cdb..a1bf48699 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; /** @@ -13,6 +15,6 @@ namespace Sabre\DAV\Locks\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface { - +abstract class AbstractBackend implements BackendInterface +{ } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php index a2d2fe89c..9a6919f50 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; use Sabre\DAV\Locks; @@ -12,10 +14,10 @@ use Sabre\DAV\Locks; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** - * Returns a list of Sabre\DAV\Locks\LockInfo objects + * Returns a list of Sabre\DAV\Locks\LockInfo objects. * * This method should return all the locks for a particular uri, including * locks that might be set on a parent uri. @@ -24,27 +26,29 @@ interface BackendInterface { * any locks in the subtree of the uri for locks. * * @param string $uri - * @param bool $returnChildLocks + * @param bool $returnChildLocks + * * @return array */ - function getLocks($uri, $returnChildLocks); + public function getLocks($uri, $returnChildLocks); /** - * Locks a uri + * Locks a uri. * - * @param string $uri + * @param string $uri * @param Locks\LockInfo $lockInfo + * * @return bool */ - function lock($uri, Locks\LockInfo $lockInfo); + public function lock($uri, Locks\LockInfo $lockInfo); /** - * Removes a lock from a uri + * Removes a lock from a uri. * - * @param string $uri + * @param string $uri * @param Locks\LockInfo $lockInfo + * * @return bool */ - function unlock($uri, Locks\LockInfo $lockInfo); - + public function unlock($uri, Locks\LockInfo $lockInfo); } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php index 849539bee..5957f35dd 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; use Sabre\DAV\Locks\LockInfo; @@ -17,28 +19,27 @@ use Sabre\DAV\Locks\LockInfo; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends AbstractBackend { - +class File extends AbstractBackend +{ /** - * The storage file + * The storage file. * * @var string */ private $locksFile; /** - * Constructor + * Constructor. * * @param string $locksFile path to file */ - function __construct($locksFile) { - + public function __construct($locksFile) + { $this->locksFile = $locksFile; - } /** - * Returns a list of Sabre\DAV\Locks\LockInfo objects + * Returns a list of Sabre\DAV\Locks\LockInfo objects. * * This method should return all the locks for a particular uri, including * locks that might be set on a parent uri. @@ -47,47 +48,47 @@ class File extends AbstractBackend { * any locks in the subtree of the uri for locks. * * @param string $uri - * @param bool $returnChildLocks + * @param bool $returnChildLocks + * * @return array */ - function getLocks($uri, $returnChildLocks) { - + public function getLocks($uri, $returnChildLocks) + { $newLocks = []; $locks = $this->getData(); foreach ($locks as $lock) { - if ($lock->uri === $uri || //deep locks on parents - ($lock->depth != 0 && strpos($uri, $lock->uri . '/') === 0) || + (0 != $lock->depth && 0 === strpos($uri, $lock->uri.'/')) || // locks on children - ($returnChildLocks && (strpos($lock->uri, $uri . '/') === 0))) { - + ($returnChildLocks && (0 === strpos($lock->uri, $uri.'/')))) { $newLocks[] = $lock; - } - } // Checking if we can remove any of these locks foreach ($newLocks as $k => $lock) { - if (time() > $lock->timeout + $lock->created) unset($newLocks[$k]); + if (time() > $lock->timeout + $lock->created) { + unset($newLocks[$k]); + } } - return $newLocks; + return $newLocks; } /** - * Locks a uri + * Locks a uri. * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function lock($uri, LockInfo $lockInfo) { - + public function lock($uri, LockInfo $lockInfo) + { // We're making the lock timeout 30 minutes $lockInfo->timeout = 1800; $lockInfo->created = time(); @@ -105,32 +106,31 @@ class File extends AbstractBackend { } $locks[] = $lockInfo; $this->putData($locks); - return true; + return true; } /** - * Removes a lock from a uri + * Removes a lock from a uri. * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function unlock($uri, LockInfo $lockInfo) { - + public function unlock($uri, LockInfo $lockInfo) + { $locks = $this->getData(); foreach ($locks as $k => $lock) { - if ($lock->token == $lockInfo->token) { - unset($locks[$k]); $this->putData($locks); - return true; + return true; } } - return false; + return false; } /** @@ -138,9 +138,11 @@ class File extends AbstractBackend { * * @return array */ - protected function getData() { - - if (!file_exists($this->locksFile)) return []; + protected function getData() + { + if (!file_exists($this->locksFile)) { + return []; + } // opening up the file, and creating a shared lock $handle = fopen($this->locksFile, 'r'); @@ -155,19 +157,20 @@ class File extends AbstractBackend { // Unserializing and checking if the resource file contains data for this file $data = unserialize($data); - if (!$data) return []; - return $data; + if (!$data) { + return []; + } + return $data; } /** - * Saves the lockdata + * Saves the lockdata. * * @param array $newData - * @return void */ - protected function putData(array $newData) { - + protected function putData(array $newData) + { // opening up the file, and creating an exclusive lock $handle = fopen($this->locksFile, 'a+'); flock($handle, LOCK_EX); @@ -179,7 +182,5 @@ class File extends AbstractBackend { fwrite($handle, serialize($newData)); flock($handle, LOCK_UN); fclose($handle); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php index 510f266f7..36a12d1ab 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; use Sabre\DAV\Locks\LockInfo; @@ -14,8 +16,8 @@ use Sabre\DAV\Locks\LockInfo; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend { - +class PDO extends AbstractBackend +{ /** * The PDO tablename this backend uses. * @@ -24,25 +26,24 @@ class PDO extends AbstractBackend { public $tableName = 'locks'; /** - * The PDO connection object + * The PDO connection object. * * @var pdo */ protected $pdo; /** - * Constructor + * Constructor. * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** - * Returns a list of Sabre\DAV\Locks\LockInfo objects + * Returns a list of Sabre\DAV\Locks\LockInfo objects. * * This method should return all the locks for a particular uri, including * locks that might be set on a parent uri. @@ -51,16 +52,17 @@ class PDO extends AbstractBackend { * any locks in the subtree of the uri for locks. * * @param string $uri - * @param bool $returnChildLocks + * @param bool $returnChildLocks + * * @return array */ - function getLocks($uri, $returnChildLocks) { - + public function getLocks($uri, $returnChildLocks) + { // NOTE: the following 10 lines or so could be easily replaced by // pure sql. MySQL's non-standard string concatenation prevents us // from doing this though. - $query = 'SELECT owner, token, timeout, created, scope, depth, uri FROM ' . $this->tableName . ' WHERE (created > (? - timeout)) AND ((uri = ?)'; - $params = [time(),$uri]; + $query = 'SELECT owner, token, timeout, created, scope, depth, uri FROM '.$this->tableName.' WHERE (created > (? - timeout)) AND ((uri = ?)'; + $params = [time(), $uri]; // We need to check locks for every part in the uri. $uriParts = explode('/', $uri); @@ -71,20 +73,18 @@ class PDO extends AbstractBackend { $currentPath = ''; foreach ($uriParts as $part) { - - if ($currentPath) $currentPath .= '/'; + if ($currentPath) { + $currentPath .= '/'; + } $currentPath .= $part; $query .= ' OR (depth!=0 AND uri = ?)'; $params[] = $currentPath; - } if ($returnChildLocks) { - $query .= ' OR (uri LIKE ?)'; - $params[] = $uri . '/%'; - + $params[] = $uri.'/%'; } $query .= ')'; @@ -94,7 +94,6 @@ class PDO extends AbstractBackend { $lockList = []; foreach ($result as $row) { - $lockInfo = new LockInfo(); $lockInfo->owner = $row['owner']; $lockInfo->token = $row['token']; @@ -104,22 +103,21 @@ class PDO extends AbstractBackend { $lockInfo->depth = $row['depth']; $lockInfo->uri = $row['uri']; $lockList[] = $lockInfo; - } return $lockList; - } /** - * Locks a uri + * Locks a uri. * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function lock($uri, LockInfo $lockInfo) { - + public function lock($uri, LockInfo $lockInfo) + { // We're making the lock timeout 30 minutes $lockInfo->timeout = 30 * 60; $lockInfo->created = time(); @@ -128,11 +126,13 @@ class PDO extends AbstractBackend { $locks = $this->getLocks($uri, false); $exists = false; foreach ($locks as $lock) { - if ($lock->token == $lockInfo->token) $exists = true; + if ($lock->token == $lockInfo->token) { + $exists = true; + } } if ($exists) { - $stmt = $this->pdo->prepare('UPDATE ' . $this->tableName . ' SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?'); + $stmt = $this->pdo->prepare('UPDATE '.$this->tableName.' SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?'); $stmt->execute([ $lockInfo->owner, $lockInfo->timeout, @@ -140,10 +140,10 @@ class PDO extends AbstractBackend { $lockInfo->depth, $uri, $lockInfo->created, - $lockInfo->token + $lockInfo->token, ]); } else { - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->tableName . ' (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)'); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->tableName.' (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)'); $stmt->execute([ $lockInfo->owner, $lockInfo->timeout, @@ -151,30 +151,26 @@ class PDO extends AbstractBackend { $lockInfo->depth, $uri, $lockInfo->created, - $lockInfo->token + $lockInfo->token, ]); } return true; - } - - /** - * Removes a lock from a uri + * Removes a lock from a uri. * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function unlock($uri, LockInfo $lockInfo) { - - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->tableName . ' WHERE uri = ? AND token = ?'); + public function unlock($uri, LockInfo $lockInfo) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->tableName.' WHERE uri = ? AND token = ?'); $stmt->execute([$uri, $lockInfo->token]); - return $stmt->rowCount() === 1; - + return 1 === $stmt->rowCount(); } - } diff --git a/vendor/sabre/dav/lib/DAV/Locks/LockInfo.php b/vendor/sabre/dav/lib/DAV/Locks/LockInfo.php index 2c8cca0fe..df8227566 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/LockInfo.php +++ b/vendor/sabre/dav/lib/DAV/Locks/LockInfo.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks; /** - * LockInfo class + * LockInfo class. * * An object of the LockInfo class holds all the information relevant to a * single lock. @@ -12,69 +14,69 @@ namespace Sabre\DAV\Locks; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class LockInfo { - +class LockInfo +{ /** - * A shared lock + * A shared lock. */ const SHARED = 1; /** - * An exclusive lock + * An exclusive lock. */ const EXCLUSIVE = 2; /** - * A never expiring timeout + * A never expiring timeout. */ const TIMEOUT_INFINITE = -1; /** - * The owner of the lock + * The owner of the lock. * * @var string */ public $owner; /** - * The locktoken + * The locktoken. * * @var string */ public $token; /** - * How long till the lock is expiring + * How long till the lock is expiring. * * @var int */ public $timeout; /** - * UNIX Timestamp of when this lock was created + * UNIX Timestamp of when this lock was created. * * @var int */ public $created; /** - * Exclusive or shared lock + * Exclusive or shared lock. * * @var int */ public $scope = self::EXCLUSIVE; /** - * Depth of lock, can be 0 or Sabre\DAV\Server::DEPTH_INFINITY + * Depth of lock, can be 0 or Sabre\DAV\Server::DEPTH_INFINITY. */ public $depth = 0; /** - * The uri this lock locks + * The uri this lock locks. * * TODO: This value is not always set + * * @var mixed */ public $uri; - } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Plugin.php b/vendor/sabre/dav/lib/DAV/Locks/Plugin.php index 41a3bf3fa..6d3e9b883 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks; use Sabre\DAV; @@ -7,7 +9,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * Locking plugin + * Locking plugin. * * This plugin provides locking support to a WebDAV server. * The easiest way to get started, is by hooking it up as such: @@ -20,53 +22,50 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * locksBackend + * locksBackend. * * @var Backend\BackendInterface */ protected $locksBackend; /** - * server + * server. * * @var DAV\Server */ protected $server; /** - * __construct + * __construct. * * @param Backend\BackendInterface $locksBackend */ - function __construct(Backend\BackendInterface $locksBackend) { - + public function __construct(Backend\BackendInterface $locksBackend) + { $this->locksBackend = $locksBackend; - } /** - * Initializes the plugin + * Initializes the plugin. * * This method is automatically called by the Server class after addPlugin. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->xml->elementMap['{DAV:}lockinfo'] = 'Sabre\\DAV\\Xml\\Request\\Lock'; - $server->on('method:LOCK', [$this, 'httpLock']); - $server->on('method:UNLOCK', [$this, 'httpUnlock']); + $server->on('method:LOCK', [$this, 'httpLock']); + $server->on('method:UNLOCK', [$this, 'httpUnlock']); $server->on('validateTokens', [$this, 'validateTokens']); - $server->on('propFind', [$this, 'propFind']); - $server->on('afterUnbind', [$this, 'afterUnbind']); - + $server->on('propFind', [$this, 'propFind']); + $server->on('afterUnbind', [$this, 'afterUnbind']); } /** @@ -77,31 +76,28 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'locks'; - } /** * This method is called after most properties have been found - * it allows us to add in any Lock-related properties + * it allows us to add in any Lock-related properties. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFind(DAV\PropFind $propFind, DAV\INode $node) { - - $propFind->handle('{DAV:}supportedlock', function() { + public function propFind(DAV\PropFind $propFind, DAV\INode $node) + { + $propFind->handle('{DAV:}supportedlock', function () { return new DAV\Xml\Property\SupportedLock(); }); - $propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) { + $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) { return new DAV\Xml\Property\LockDiscovery( $this->getLocks($propFind->getPath()) ); }); - } /** @@ -112,12 +108,12 @@ class Plugin extends DAV\ServerPlugin { * available for the specified uri. * * @param string $uri + * * @return array */ - function getHTTPMethods($uri) { - - return ['LOCK','UNLOCK']; - + public function getHTTPMethods($uri) + { + return ['LOCK', 'UNLOCK']; } /** @@ -128,14 +124,13 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return [2]; - } /** - * Returns all lock information on a particular uri + * Returns all lock information on a particular uri. * * This function should return an array with Sabre\DAV\Locks\LockInfo objects. If there are no locks on a file, return an empty array. * @@ -144,17 +139,17 @@ class Plugin extends DAV\ServerPlugin { * for any possible locks and return those as well. * * @param string $uri - * @param bool $returnChildLocks + * @param bool $returnChildLocks + * * @return array */ - function getLocks($uri, $returnChildLocks = false) { - + public function getLocks($uri, $returnChildLocks = false) + { return $this->locksBackend->getLocks($uri, $returnChildLocks); - } /** - * Locks an uri + * Locks an uri. * * The WebDAV lock request can be operated to either create a new lock on a file, or to refresh an existing lock * If a new lock is created, a full XML body should be supplied, containing information about the lock such as the type @@ -164,12 +159,13 @@ class Plugin extends DAV\ServerPlugin { * * Additionally, a lock can be requested for a non-existent file. In these case we're obligated to create an empty file as per RFC4918:S7.3 * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpLock(RequestInterface $request, ResponseInterface $response) { - + public function httpLock(RequestInterface $request, ResponseInterface $response) + { $uri = $request->getPath(); $existingLocks = $this->getLocks($uri); @@ -180,7 +176,7 @@ class Plugin extends DAV\ServerPlugin { $existingLock = null; // Checking if there's already non-shared locks on the uri. foreach ($existingLocks as $existingLock) { - if ($existingLock->scope === LockInfo::EXCLUSIVE) { + if (LockInfo::EXCLUSIVE === $existingLock->scope) { throw new DAV\Exception\ConflictingLock($existingLock); } } @@ -188,11 +184,10 @@ class Plugin extends DAV\ServerPlugin { $lockInfo = $this->parseLockRequest($body); $lockInfo->depth = $this->server->getHTTPDepth(); $lockInfo->uri = $uri; - if ($existingLock && $lockInfo->scope != LockInfo::SHARED) + if ($existingLock && LockInfo::SHARED != $lockInfo->scope) { throw new DAV\Exception\ConflictingLock($existingLock); - + } } else { - // Gonna check if this was a lock refresh. $existingLocks = $this->getLocks($uri); $conditions = $this->server->getIfConditions($request); @@ -201,7 +196,7 @@ class Plugin extends DAV\ServerPlugin { foreach ($existingLocks as $existingLock) { foreach ($conditions as $condition) { foreach ($condition['tokens'] as $token) { - if ($token['token'] === 'opaquelocktoken:' . $existingLock->token) { + if ($token['token'] === 'opaquelocktoken:'.$existingLock->token) { $found = $existingLock; break 3; } @@ -216,18 +211,20 @@ class Plugin extends DAV\ServerPlugin { } else { throw new DAV\Exception\BadRequest('An xml body is required for lock requests'); } - } // This must have been a lock refresh $lockInfo = $found; // The resource could have been locked through another uri. - if ($uri != $lockInfo->uri) $uri = $lockInfo->uri; - + if ($uri != $lockInfo->uri) { + $uri = $lockInfo->uri; + } } - if ($timeout = $this->getTimeoutHeader()) $lockInfo->timeout = $timeout; + if ($timeout = $this->getTimeoutHeader()) { + $lockInfo->timeout = $timeout; + } $newFile = false; @@ -240,56 +237,52 @@ class Plugin extends DAV\ServerPlugin { // // See Issue 222 // $this->server->emit('beforeWriteContent',array($uri)); - } catch (DAV\Exception\NotFound $e) { - // It didn't, lets create it $this->server->createFile($uri, fopen('php://memory', 'r')); $newFile = true; - } $this->lockNode($uri, $lockInfo); $response->setHeader('Content-Type', 'application/xml; charset=utf-8'); - $response->setHeader('Lock-Token', '<opaquelocktoken:' . $lockInfo->token . '>'); + $response->setHeader('Lock-Token', '<opaquelocktoken:'.$lockInfo->token.'>'); $response->setStatus($newFile ? 201 : 200); $response->setBody($this->generateLockResponse($lockInfo)); // Returning false will interrupt the event chain and mark this method // as 'handled'. return false; - } /** - * Unlocks a uri + * Unlocks a uri. * * This WebDAV method allows you to remove a lock from a node. The client should provide a valid locktoken through the Lock-token http header * The server should return 204 (No content) on success * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpUnlock(RequestInterface $request, ResponseInterface $response) { - + public function httpUnlock(RequestInterface $request, ResponseInterface $response) + { $lockToken = $request->getHeader('Lock-Token'); // If the locktoken header is not supplied, we need to throw a bad request exception - if (!$lockToken) throw new DAV\Exception\BadRequest('No lock token was supplied'); - + if (!$lockToken) { + throw new DAV\Exception\BadRequest('No lock token was supplied'); + } $path = $request->getPath(); $locks = $this->getLocks($path); // Windows sometimes forgets to include < and > in the Lock-Token // header - if ($lockToken[0] !== '<') $lockToken = '<' . $lockToken . '>'; + if ('<' !== $lockToken[0]) { + $lockToken = '<'.$lockToken.'>'; + } foreach ($locks as $lock) { - - if ('<opaquelocktoken:' . $lock->token . '>' == $lockToken) { - + if ('<opaquelocktoken:'.$lock->token.'>' == $lockToken) { $this->unlockNode($path, $lock); $response->setHeader('Content-Length', '0'); $response->setStatus(204); @@ -297,14 +290,11 @@ class Plugin extends DAV\ServerPlugin { // Returning false will break the method chain, and mark the // method as 'handled'. return false; - } - } // If we got here, it means the locktoken was invalid throw new DAV\Exception\LockTokenMatchesRequestUri(); - } /** @@ -313,51 +303,54 @@ class Plugin extends DAV\ServerPlugin { * We use this event to clean up any locks that still exist on the node. * * @param string $path - * @return void */ - function afterUnbind($path) { - + public function afterUnbind($path) + { $locks = $this->getLocks($path, $includeChildren = true); foreach ($locks as $lock) { $this->unlockNode($path, $lock); } - } /** - * Locks a uri + * Locks a uri. * * All the locking information is supplied in the lockInfo object. The object has a suggested timeout, but this can be safely ignored * It is important that if the existing timeout is ignored, the property is overwritten, as this needs to be sent back to the client * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function lockNode($uri, LockInfo $lockInfo) { + public function lockNode($uri, LockInfo $lockInfo) + { + if (!$this->server->emit('beforeLock', [$uri, $lockInfo])) { + return; + } - if (!$this->server->emit('beforeLock', [$uri, $lockInfo])) return; return $this->locksBackend->lock($uri, $lockInfo); - } /** - * Unlocks a uri + * Unlocks a uri. * * This method removes a lock from a uri. It is assumed all the supplied information is correct and verified * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function unlockNode($uri, LockInfo $lockInfo) { + public function unlockNode($uri, LockInfo $lockInfo) + { + if (!$this->server->emit('beforeUnlock', [$uri, $lockInfo])) { + return; + } - if (!$this->server->emit('beforeUnlock', [$uri, $lockInfo])) return; return $this->locksBackend->unlock($uri, $lockInfo); - } - /** * Returns the contents of the HTTP Timeout header. * @@ -365,37 +358,36 @@ class Plugin extends DAV\ServerPlugin { * * @return int */ - function getTimeoutHeader() { - + public function getTimeoutHeader() + { $header = $this->server->httpRequest->getHeader('Timeout'); if ($header) { - - if (stripos($header, 'second-') === 0) $header = (int)(substr($header, 7)); - elseif (stripos($header, 'infinite') === 0) $header = LockInfo::TIMEOUT_INFINITE; - else throw new DAV\Exception\BadRequest('Invalid HTTP timeout header'); - + if (0 === stripos($header, 'second-')) { + $header = (int) (substr($header, 7)); + } elseif (0 === stripos($header, 'infinite')) { + $header = LockInfo::TIMEOUT_INFINITE; + } else { + throw new DAV\Exception\BadRequest('Invalid HTTP timeout header'); + } } else { - $header = 0; - } return $header; - } /** - * Generates the response for successful LOCK requests + * Generates the response for successful LOCK requests. * * @param LockInfo $lockInfo + * * @return string */ - protected function generateLockResponse(LockInfo $lockInfo) { - + protected function generateLockResponse(LockInfo $lockInfo) + { return $this->server->xml->write('{DAV:}prop', [ - '{DAV:}lockdiscovery' => - new DAV\Xml\Property\LockDiscovery([$lockInfo]) + '{DAV:}lockdiscovery' => new DAV\Xml\Property\LockDiscovery([$lockInfo]), ]); } @@ -410,11 +402,10 @@ class Plugin extends DAV\ServerPlugin { * tokens. * * @param RequestInterface $request - * @param mixed $conditions - * @return void + * @param mixed $conditions */ - function validateTokens(RequestInterface $request, &$conditions) { - + public function validateTokens(RequestInterface $request, &$conditions) + { // First we need to gather a list of locks that must be satisfied. $mustLocks = []; $method = $request->getMethod(); @@ -422,24 +413,23 @@ class Plugin extends DAV\ServerPlugin { // Methods not in that list are operations that doesn't alter any // resources, and we don't need to check the lock-states for. switch ($method) { - - case 'DELETE' : + case 'DELETE': $mustLocks = array_merge($mustLocks, $this->getLocks( $request->getPath(), true )); break; - case 'MKCOL' : - case 'MKCALENDAR' : - case 'PROPPATCH' : - case 'PUT' : - case 'PATCH' : + case 'MKCOL': + case 'MKCALENDAR': + case 'PROPPATCH': + case 'PUT': + case 'PATCH': $mustLocks = array_merge($mustLocks, $this->getLocks( $request->getPath(), false )); break; - case 'MOVE' : + case 'MOVE': $mustLocks = array_merge($mustLocks, $this->getLocks( $request->getPath(), true @@ -449,13 +439,13 @@ class Plugin extends DAV\ServerPlugin { false )); break; - case 'COPY' : + case 'COPY': $mustLocks = array_merge($mustLocks, $this->getLocks( $this->server->calculateUri($request->getHeader('Destination')), false )); break; - case 'LOCK' : + case 'LOCK': //Temporary measure.. figure out later why this is needed // Here we basically ignore all incoming tokens... foreach ($conditions as $ii => $condition) { @@ -463,31 +453,29 @@ class Plugin extends DAV\ServerPlugin { $conditions[$ii]['tokens'][$jj]['validToken'] = true; } } - return; + return; } // It's possible that there's identical locks, because of shared // parents. We're removing the duplicates here. $tmp = []; - foreach ($mustLocks as $lock) $tmp[$lock->token] = $lock; + foreach ($mustLocks as $lock) { + $tmp[$lock->token] = $lock; + } $mustLocks = array_values($tmp); foreach ($conditions as $kk => $condition) { - foreach ($condition['tokens'] as $ii => $token) { - // Lock tokens always start with opaquelocktoken: - if (substr($token['token'], 0, 16) !== 'opaquelocktoken:') { + if ('opaquelocktoken:' !== substr($token['token'], 0, 16)) { continue; } $checkToken = substr($token['token'], 16); // Looping through our list with locks. foreach ($mustLocks as $jj => $mustLock) { - if ($mustLock->token == $checkToken) { - // We have a match! // Removing this one from mustlocks unset($mustLocks[$jj]); @@ -497,9 +485,7 @@ class Plugin extends DAV\ServerPlugin { // Advancing to the next token continue 2; - } - } // If we got here, it means that there was a @@ -514,42 +500,34 @@ class Plugin extends DAV\ServerPlugin { // lock-token that was expired. $oddLocks = $this->getLocks($condition['uri']); foreach ($oddLocks as $oddLock) { - if ($oddLock->token === $checkToken) { - // We have a hit! $conditions[$kk]['tokens'][$ii]['validToken'] = true; continue 2; - } } // If we get all the way here, the lock-token was // really unknown. - - } - } // If there's any locks left in the 'mustLocks' array, it means that // the resource was locked and we must block it. if ($mustLocks) { - throw new DAV\Exception\Locked(reset($mustLocks)); - } - } /** - * Parses a webdav lock xml body, and returns a new Sabre\DAV\Locks\LockInfo object + * Parses a webdav lock xml body, and returns a new Sabre\DAV\Locks\LockInfo object. * * @param string $body + * * @return LockInfo */ - protected function parseLockRequest($body) { - + protected function parseLockRequest($body) + { $result = $this->server->xml->expect( '{DAV:}lockinfo', $body @@ -562,7 +540,6 @@ class Plugin extends DAV\ServerPlugin { $lockInfo->scope = $result->scope; return $lockInfo; - } /** @@ -576,14 +553,12 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'The locks plugin turns this server into a class-2 WebDAV server and adds support for LOCK and UNLOCK', - 'link' => 'http://sabre.io/dav/locks/', + 'link' => 'http://sabre.io/dav/locks/', ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/MkCol.php b/vendor/sabre/dav/lib/DAV/MkCol.php index 042e14bca..f3c5ea5c0 100644 --- a/vendor/sabre/dav/lib/DAV/MkCol.php +++ b/vendor/sabre/dav/lib/DAV/MkCol.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -20,8 +22,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MkCol extends PropPatch { - +class MkCol extends PropPatch +{ /** * A list of resource-types in clark-notation. * @@ -32,14 +34,13 @@ class MkCol extends PropPatch { /** * Creates the MKCOL object. * - * @param string[] $resourceType List of resourcetype values. - * @param array $mutations List of new properties values. + * @param string[] $resourceType list of resourcetype values + * @param array $mutations list of new properties values */ - function __construct(array $resourceType, array $mutations) { - + public function __construct(array $resourceType, array $mutations) + { $this->resourceType = $resourceType; parent::__construct($mutations); - } /** @@ -47,10 +48,9 @@ class MkCol extends PropPatch { * * @return string[] */ - function getResourceType() { - + public function getResourceType() + { return $this->resourceType; - } /** @@ -61,12 +61,11 @@ class MkCol extends PropPatch { * checked. * * @param string|string[] $resourceType + * * @return bool */ - function hasResourceType($resourceType) { - - return count(array_diff((array)$resourceType, $this->resourceType)) === 0; - + public function hasResourceType($resourceType) + { + return 0 === count(array_diff((array) $resourceType, $this->resourceType)); } - } diff --git a/vendor/sabre/dav/lib/DAV/Mount/Plugin.php b/vendor/sabre/dav/lib/DAV/Mount/Plugin.php index dc923ad85..5eaa4d462 100644 --- a/vendor/sabre/dav/lib/DAV/Mount/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Mount/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Mount; use Sabre\DAV; @@ -7,7 +9,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * This plugin provides support for RFC4709: Mounting WebDAV servers + * This plugin provides support for RFC4709: Mounting WebDAV servers. * * Simply append ?mount to any collection to generate the davmount response. * @@ -15,40 +17,41 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * Reference to Server class + * Reference to Server class. * * @var DAV\Server */ protected $server; /** - * Initializes the plugin and registers event handles + * Initializes the plugin and registers event handles. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->on('method:GET', [$this, 'httpGet'], 90); - } /** * 'beforeMethod' event handles. This event handles intercepts GET requests ending - * with ?mount + * with ?mount. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $queryParams = $request->getQueryParameters(); - if (!array_key_exists('mount', $queryParams)) return; + if (!array_key_exists('mount', $queryParams)) { + return; + } $currentUri = $request->getAbsoluteUrl(); @@ -59,28 +62,23 @@ class Plugin extends DAV\ServerPlugin { // Returning false to break the event chain return false; - } /** - * Generates the davmount response + * Generates the davmount response. * * @param ResponseInterface $response - * @param string $uri absolute uri - * @return void + * @param string $uri absolute uri */ - function davMount(ResponseInterface $response, $uri) { - + public function davMount(ResponseInterface $response, $uri) + { $response->setStatus(200); $response->setHeader('Content-Type', 'application/davmount+xml'); ob_start(); echo '<?xml version="1.0"?>', "\n"; echo "<dm:mount xmlns:dm=\"http://purl.org/NET/webdav/mount\">\n"; - echo " <dm:url>", htmlspecialchars($uri, ENT_NOQUOTES, 'UTF-8'), "</dm:url>\n"; - echo "</dm:mount>"; + echo ' <dm:url>', htmlspecialchars($uri, ENT_NOQUOTES, 'UTF-8'), "</dm:url>\n"; + echo '</dm:mount>'; $response->setBody(ob_get_clean()); - } - - } diff --git a/vendor/sabre/dav/lib/DAV/Node.php b/vendor/sabre/dav/lib/DAV/Node.php index ef6eea18e..948060d9a 100644 --- a/vendor/sabre/dav/lib/DAV/Node.php +++ b/vendor/sabre/dav/lib/DAV/Node.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * Node class + * Node class. * * This is a helper class, that should aid in getting nodes setup. * @@ -11,8 +13,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Node implements INode { - +abstract class Node implements INode +{ /** * Returns the last modification time as a unix timestamp. * @@ -20,35 +22,30 @@ abstract class Node implements INode { * * @return int */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** - * Deletes the current node + * Deletes the current node. * * @throws Exception\Forbidden - * @return void */ - function delete() { - + public function delete() + { throw new Exception\Forbidden('Permission denied to delete node'); - } /** - * Renames the node + * Renames the node. * * @param string $name The new name + * * @throws Exception\Forbidden - * @return void */ - function setName($name) { - + public function setName($name) + { throw new Exception\Forbidden('Permission denied to rename file'); - } - } diff --git a/vendor/sabre/dav/lib/DAV/PartialUpdate/IPatchSupport.php b/vendor/sabre/dav/lib/DAV/PartialUpdate/IPatchSupport.php index 97d24f9cb..e516f4d08 100644 --- a/vendor/sabre/dav/lib/DAV/PartialUpdate/IPatchSupport.php +++ b/vendor/sabre/dav/lib/DAV/PartialUpdate/IPatchSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PartialUpdate; use Sabre\DAV; @@ -7,14 +9,14 @@ use Sabre\DAV; /** * This interface provides a way to modify only part of a target resource * It may be used to update a file chunk, upload big a file into smaller - * chunks or resume an upload + * chunks or resume an upload. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Jean-Tiare LE BIGOT (http://www.jtlebi.fr/) * @license http://sabre.io/license/ Modified BSD License */ -interface IPatchSupport extends DAV\IFile { - +interface IPatchSupport extends DAV\IFile +{ /** * Updates the file based on a range specification. * @@ -38,10 +40,10 @@ interface IPatchSupport extends DAV\IFile { * time. * * @param resource|string $data - * @param int $rangeType - * @param int $offset + * @param int $rangeType + * @param int $offset + * * @return string|null */ - function patch($data, $rangeType, $offset = null); - + public function patch($data, $rangeType, $offset = null); } diff --git a/vendor/sabre/dav/lib/DAV/PartialUpdate/Plugin.php b/vendor/sabre/dav/lib/DAV/PartialUpdate/Plugin.php index 9c129d705..f8ffc3706 100644 --- a/vendor/sabre/dav/lib/DAV/PartialUpdate/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/PartialUpdate/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PartialUpdate; use Sabre\DAV; @@ -7,7 +9,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * Partial update plugin (Patch method) + * Partial update plugin (Patch method). * * This plugin provides a way to modify only part of a target resource * It may bu used to update a file chunk, upload big a file into smaller @@ -20,32 +22,30 @@ use Sabre\HTTP\ResponseInterface; * @author Jean-Tiare LE BIGOT (http://www.jtlebi.fr/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ const RANGE_APPEND = 1; const RANGE_START = 2; const RANGE_END = 3; /** - * Reference to server + * Reference to server. * * @var DAV\Server */ protected $server; /** - * Initializes the plugin + * Initializes the plugin. * * This method is automatically called by the Server class after addPlugin. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $server->on('method:PATCH', [$this, 'httpPatch']); - } /** @@ -56,10 +56,9 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'partialupdate'; - } /** @@ -74,10 +73,11 @@ class Plugin extends DAV\ServerPlugin { * - the node implements our partial update interface * * @param string $uri + * * @return array */ - function getHTTPMethods($uri) { - + public function getHTTPMethods($uri) + { $tree = $this->server->tree; if ($tree->nodeExists($uri)) { @@ -86,8 +86,8 @@ class Plugin extends DAV\ServerPlugin { return ['PATCH']; } } - return []; + return []; } /** @@ -95,25 +95,23 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['sabredav-partialupdate']; - } /** - * Patch an uri + * Patch an uri. * * The WebDAV patch request can be used to modify only a part of an * existing resource. If the resource does not exist yet and the first * offset is not 0, the request fails * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpPatch(RequestInterface $request, ResponseInterface $response) { - + public function httpPatch(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); // Get the node. Will throw a 404 if not found @@ -129,53 +127,55 @@ class Plugin extends DAV\ServerPlugin { } $contentType = strtolower( - $request->getHeader('Content-Type') + (string) $request->getHeader('Content-Type') ); - if ($contentType != 'application/x-sabredav-partialupdate') { - throw new DAV\Exception\UnsupportedMediaType('Unknown Content-Type header "' . $contentType . '"'); + if ('application/x-sabredav-partialupdate' != $contentType) { + throw new DAV\Exception\UnsupportedMediaType('Unknown Content-Type header "'.$contentType.'"'); } $len = $this->server->httpRequest->getHeader('Content-Length'); - if (!$len) throw new DAV\Exception\LengthRequired('A Content-Length header is required'); - + if (!$len) { + throw new DAV\Exception\LengthRequired('A Content-Length header is required'); + } switch ($range[0]) { - case self::RANGE_START : + case self::RANGE_START: // Calculate the end-range if it doesn't exist. if (!$range[2]) { $range[2] = $range[1] + $len - 1; } else { if ($range[2] < $range[1]) { - throw new DAV\Exception\RequestedRangeNotSatisfiable('The end offset (' . $range[2] . ') is lower than the start offset (' . $range[1] . ')'); + throw new DAV\Exception\RequestedRangeNotSatisfiable('The end offset ('.$range[2].') is lower than the start offset ('.$range[1].')'); } if ($range[2] - $range[1] + 1 != $len) { - throw new DAV\Exception\RequestedRangeNotSatisfiable('Actual data length (' . $len . ') is not consistent with begin (' . $range[1] . ') and end (' . $range[2] . ') offsets'); + throw new DAV\Exception\RequestedRangeNotSatisfiable('Actual data length ('.$len.') is not consistent with begin ('.$range[1].') and end ('.$range[2].') offsets'); } } break; } - if (!$this->server->emit('beforeWriteContent', [$path, $node, null])) + if (!$this->server->emit('beforeWriteContent', [$path, $node, null])) { return; + } $body = $this->server->httpRequest->getBody(); - $etag = $node->patch($body, $range[0], isset($range[1]) ? $range[1] : null); $this->server->emit('afterWriteContent', [$path, $node]); $response->setHeader('Content-Length', '0'); - if ($etag) $response->setHeader('ETag', $etag); + if ($etag) { + $response->setHeader('ETag', $etag); + } $response->setStatus(204); // Breaks the event chain return false; - } /** - * Returns the HTTP custom range update header + * Returns the HTTP custom range update header. * * This method returns null if there is no well-formed HTTP range request * header. It returns array(1) if it was an append request, array(2, @@ -192,24 +192,28 @@ class Plugin extends DAV\ServerPlugin { * [3,-5] - update from 5 bytes from the end of the file. * * @param RequestInterface $request + * * @return array|null */ - function getHTTPUpdateRange(RequestInterface $request) { - + public function getHTTPUpdateRange(RequestInterface $request) + { $range = $request->getHeader('X-Update-Range'); - if (is_null($range)) return null; + if (is_null($range)) { + return null; + } // Matching "Range: bytes=1234-5678: both numbers are optional - if (!preg_match('/^(append)|(?:bytes=([0-9]+)-([0-9]*))|(?:bytes=(-[0-9]+))$/i', $range, $matches)) return null; + if (!preg_match('/^(append)|(?:bytes=([0-9]+)-([0-9]*))|(?:bytes=(-[0-9]+))$/i', $range, $matches)) { + return null; + } - if ($matches[1] === 'append') { + if ('append' === $matches[1]) { return [self::RANGE_APPEND]; } elseif (strlen($matches[2]) > 0) { - return [self::RANGE_START, $matches[2], $matches[3] ?: null]; + return [self::RANGE_START, (int) $matches[2], (int) $matches[3] ?: null]; } else { - return [self::RANGE_END, $matches[4]]; + return [self::RANGE_END, (int) $matches[4]]; } - } } diff --git a/vendor/sabre/dav/lib/DAV/PropFind.php b/vendor/sabre/dav/lib/DAV/PropFind.php index 0940a1ce2..4b6fe28eb 100644 --- a/vendor/sabre/dav/lib/DAV/PropFind.php +++ b/vendor/sabre/dav/lib/DAV/PropFind.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -8,10 +10,10 @@ namespace Sabre\DAV; * It contains the type of PROPFIND request, which properties were requested * and also the returned items. */ -class PropFind { - +class PropFind +{ /** - * A normal propfind + * A normal propfind. */ const NORMAL = 0; @@ -33,21 +35,21 @@ class PropFind { const PROPNAME = 2; /** - * Creates the PROPFIND object + * Creates the PROPFIND object. * * @param string $path - * @param array $properties - * @param int $depth - * @param int $requestType + * @param array $properties + * @param int $depth + * @param int $requestType */ - function __construct($path, array $properties, $depth = 0, $requestType = self::NORMAL) { - + public function __construct($path, array $properties, $depth = 0, $requestType = self::NORMAL) + { $this->path = $path; $this->properties = $properties; $this->depth = $depth; $this->requestType = $requestType; - if ($requestType === self::ALLPROPS) { + if (self::ALLPROPS === $requestType) { $this->properties = [ '{DAV:}getlastmodified', '{DAV:}getcontentlength', @@ -60,13 +62,10 @@ class PropFind { } foreach ($this->properties as $propertyName) { - // Seeding properties with 404's. $this->result[$propertyName] = [404, null]; - } $this->itemsLeft = count($this->result); - } /** @@ -88,68 +87,65 @@ class PropFind { * It's also possible to not pass a callback, but immediately pass a value * * @param string $propertyName - * @param mixed $valueOrCallBack - * @return void + * @param mixed $valueOrCallBack */ - function handle($propertyName, $valueOrCallBack) { - - if ($this->itemsLeft && isset($this->result[$propertyName]) && $this->result[$propertyName][0] === 404) { + public function handle($propertyName, $valueOrCallBack) + { + if ($this->itemsLeft && isset($this->result[$propertyName]) && 404 === $this->result[$propertyName][0]) { if (is_callable($valueOrCallBack)) { $value = $valueOrCallBack(); } else { $value = $valueOrCallBack; } if (!is_null($value)) { - $this->itemsLeft--; + --$this->itemsLeft; $this->result[$propertyName] = [200, $value]; } } - } /** - * Sets the value of the property + * Sets the value of the property. * * If status is not supplied, the status will default to 200 for non-null * properties, and 404 for null properties. * * @param string $propertyName - * @param mixed $value - * @param int $status - * @return void + * @param mixed $value + * @param int $status */ - function set($propertyName, $value, $status = null) { - + public function set($propertyName, $value, $status = null) + { if (is_null($status)) { $status = is_null($value) ? 404 : 200; } // If this is an ALLPROPS request and the property is // unknown, add it to the result; else ignore it: if (!isset($this->result[$propertyName])) { - if ($this->requestType === self::ALLPROPS) { + if (self::ALLPROPS === $this->requestType) { $this->result[$propertyName] = [$status, $value]; } + return; } - if ($status !== 404 && $this->result[$propertyName][0] === 404) { - $this->itemsLeft--; - } elseif ($status === 404 && $this->result[$propertyName][0] !== 404) { - $this->itemsLeft++; + if (404 !== $status && 404 === $this->result[$propertyName][0]) { + --$this->itemsLeft; + } elseif (404 === $status && 404 !== $this->result[$propertyName][0]) { + ++$this->itemsLeft; } $this->result[$propertyName] = [$status, $value]; - } /** * Returns the current value for a property. * * @param string $propertyName + * * @return mixed */ - function get($propertyName) { - + public function get($propertyName) + { return isset($this->result[$propertyName]) ? $this->result[$propertyName][1] : null; - } /** @@ -159,24 +155,22 @@ class PropFind { * null will be returned. * * @param string $propertyName + * * @return int|null */ - function getStatus($propertyName) { - + public function getStatus($propertyName) + { return isset($this->result[$propertyName]) ? $this->result[$propertyName][0] : null; - } /** * Updates the path for this PROPFIND. * * @param string $path - * @return void */ - function setPath($path) { - + public function setPath($path) + { $this->path = $path; - } /** @@ -184,10 +178,9 @@ class PropFind { * * @return string */ - function getPath() { - + public function getPath() + { return $this->path; - } /** @@ -195,22 +188,19 @@ class PropFind { * * @return int */ - function getDepth() { - + public function getDepth() + { return $this->depth; - } /** * Updates the depth of this propfind request. * * @param int $depth - * @return void */ - function setDepth($depth) { - + public function setDepth($depth) + { $this->depth = $depth; - } /** @@ -219,19 +209,19 @@ class PropFind { * * @return array */ - function get404Properties() { - - if ($this->itemsLeft === 0) { + public function get404Properties() + { + if (0 === $this->itemsLeft) { return []; } $result = []; foreach ($this->result as $propertyName => $stuff) { - if ($stuff[0] === 404) { + if (404 === $stuff[0]) { $result[] = $propertyName; } } - return $result; + return $result; } /** @@ -241,10 +231,9 @@ class PropFind { * * @return array */ - function getRequestedProperties() { - + public function getRequestedProperties() + { return $this->properties; - } /** @@ -252,10 +241,9 @@ class PropFind { * * @return bool */ - function isAllProps() { - - return $this->requestType === self::ALLPROPS; - + public function isAllProps() + { + return self::ALLPROPS === $this->requestType; } /** @@ -270,8 +258,8 @@ class PropFind { * * @return array */ - function getResultForMultiStatus() { - + public function getResultForMultiStatus() + { $r = [ 200 => [], 404 => [], @@ -284,9 +272,11 @@ class PropFind { } } // Removing the 404's for multi-status requests. - if ($this->requestType === self::ALLPROPS) unset($r[404]); - return $r; + if (self::ALLPROPS === $this->requestType) { + unset($r[404]); + } + return $r; } /** @@ -307,12 +297,12 @@ class PropFind { protected $depth = 0; /** - * The type of request. See the TYPE constants + * The type of request. See the TYPE constants. */ protected $requestType; /** - * A list of requested properties + * A list of requested properties. * * @var array */ @@ -343,5 +333,4 @@ class PropFind { * @var int */ protected $itemsLeft; - } diff --git a/vendor/sabre/dav/lib/DAV/PropPatch.php b/vendor/sabre/dav/lib/DAV/PropPatch.php index 6d599dacc..160bdb1a8 100644 --- a/vendor/sabre/dav/lib/DAV/PropPatch.php +++ b/vendor/sabre/dav/lib/DAV/PropPatch.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use UnexpectedValueException; @@ -17,8 +19,8 @@ use UnexpectedValueException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PropPatch { - +class PropPatch +{ /** * Properties that are being updated. * @@ -52,14 +54,13 @@ class PropPatch { protected $failed = false; /** - * Constructor + * Constructor. * * @param array $mutations A list of updates */ - function __construct(array $mutations) { - + public function __construct(array $mutations) + { $this->mutations = $mutations; - } /** @@ -81,21 +82,17 @@ class PropPatch { * code associated with the operation. * * @param string|string[] $properties - * @param callable $callback - * @return void + * @param callable $callback */ - function handle($properties, callable $callback) { - + public function handle($properties, callable $callback) + { $usedProperties = []; - foreach ((array)$properties as $propertyName) { - + foreach ((array) $properties as $propertyName) { if (array_key_exists($propertyName, $this->mutations) && !isset($this->result[$propertyName])) { - $usedProperties[] = $propertyName; // HTTP Accepted $this->result[$propertyName] = 202; } - } // Only registering if there's any unhandled properties. @@ -107,9 +104,8 @@ class PropPatch { // to also make sure that it stays that way, so the commit function // knows how to format the arguments to the callback. is_string($properties) ? $properties : $usedProperties, - $callback + $callback, ]; - } /** @@ -118,10 +114,9 @@ class PropPatch { * this that you promise to process _all_ properties that are coming in. * * @param callable $callback - * @return void */ - function handleRemaining(callable $callback) { - + public function handleRemaining(callable $callback) + { $properties = $this->getRemainingMutations(); if (!$properties) { // Nothing to do, don't register callback @@ -134,44 +129,39 @@ class PropPatch { $this->propertyUpdateCallbacks[] = [ $properties, - $callback + $callback, ]; } - } /** * Sets the result code for one or more properties. * * @param string|string[] $properties - * @param int $resultCode - * @return void + * @param int $resultCode */ - function setResultCode($properties, $resultCode) { - - foreach ((array)$properties as $propertyName) { + public function setResultCode($properties, $resultCode) + { + foreach ((array) $properties as $propertyName) { $this->result[$propertyName] = $resultCode; } if ($resultCode >= 400) { $this->failed = true; } - } /** * Sets the result code for all properties that did not have a result yet. * * @param int $resultCode - * @return void */ - function setRemainingResultCode($resultCode) { - + public function setRemainingResultCode($resultCode) + { $this->setResultCode( $this->getRemainingMutations(), $resultCode ); - } /** @@ -181,8 +171,8 @@ class PropPatch { * * @return string[] */ - function getRemainingMutations() { - + public function getRemainingMutations() + { $remaining = []; foreach ($this->mutations as $propertyName => $propValue) { if (!isset($this->result[$propertyName])) { @@ -191,7 +181,6 @@ class PropPatch { } return $remaining; - } /** @@ -201,8 +190,8 @@ class PropPatch { * * @return array */ - function getRemainingValues() { - + public function getRemainingValues() + { $remaining = []; foreach ($this->mutations as $propertyName => $propValue) { if (!isset($this->result[$propertyName])) { @@ -211,7 +200,6 @@ class PropPatch { } return $remaining; - } /** @@ -222,20 +210,17 @@ class PropPatch { * * @return bool */ - function commit() { - + public function commit() + { // First we validate if every property has a handler foreach ($this->mutations as $propertyName => $value) { - if (!isset($this->result[$propertyName])) { $this->failed = true; $this->result[$propertyName] = 403; } - } foreach ($this->propertyUpdateCallbacks as $callbackInfo) { - if ($this->failed) { break; } @@ -244,37 +229,32 @@ class PropPatch { } else { $this->doCallbackMultiProp($callbackInfo[0], $callbackInfo[1]); } - } - /** + /* * If anywhere in this operation updating a property failed, we must * update all other properties accordingly. */ if ($this->failed) { - foreach ($this->result as $propertyName => $status) { - if ($status === 202) { + if (202 === $status) { // Failed dependency $this->result[$propertyName] = 424; } } - } return !$this->failed; - } /** * Executes a property callback with the single-property syntax. * - * @param string $propertyName + * @param string $propertyName * @param callable $callback - * @return void */ - private function doCallBackSingleProp($propertyName, callable $callback) { - + private function doCallBackSingleProp($propertyName, callable $callback) + { $result = $callback($this->mutations[$propertyName]); if (is_bool($result)) { if ($result) { @@ -297,18 +277,16 @@ class PropPatch { if ($result >= 400) { $this->failed = true; } - } /** * Executes a property callback with the multi-property syntax. * - * @param array $propertyList + * @param array $propertyList * @param callable $callback - * @return void */ - private function doCallBackMultiProp(array $propertyList, callable $callback) { - + private function doCallBackMultiProp(array $propertyList, callable $callback) + { $argument = []; foreach ($propertyList as $propertyName) { $argument[$propertyName] = $this->mutations[$propertyName]; @@ -327,16 +305,13 @@ class PropPatch { $this->failed = true; } $this->result[$propertyName] = $resultCode; - } - } elseif ($result === true) { - + } elseif (true === $result) { // Success foreach ($argument as $propertyName => $propertyValue) { $this->result[$propertyName] = is_null($propertyValue) ? 204 : 200; } - - } elseif ($result === false) { + } elseif (false === $result) { // Fail :( $this->failed = true; foreach ($propertyList as $propertyName) { @@ -345,7 +320,6 @@ class PropPatch { } else { throw new UnexpectedValueException('A callback sent to handle() did not return an array or a bool'); } - } /** @@ -353,21 +327,18 @@ class PropPatch { * * @return array */ - function getResult() { - + public function getResult() + { return $this->result; - } /** - * Returns the full list of mutations + * Returns the full list of mutations. * * @return array */ - function getMutations() { - + public function getMutations() + { return $this->mutations; - } - } diff --git a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php index b15d7fef9..4bdc44775 100644 --- a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PropertyStorage\Backend; use Sabre\DAV\PropFind; @@ -15,8 +17,8 @@ use Sabre\DAV\PropPatch; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * Fetches properties for a path. * @@ -30,14 +32,13 @@ interface BackendInterface { * However, you can also support the 'allprops' property here. In that * case, you should check for $propFind->isAllProps(). * - * @param string $path + * @param string $path * @param PropFind $propFind - * @return void */ - function propFind($path, PropFind $propFind); + public function propFind($path, PropFind $propFind); /** - * Updates properties for a path + * Updates properties for a path. * * This method received a PropPatch object, which contains all the * information about the update. @@ -45,11 +46,10 @@ interface BackendInterface { * Usually you would want to call 'handleRemaining' on this object, to get; * a list of all properties that need to be stored. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch); + public function propPatch($path, PropPatch $propPatch); /** * This method is called after a node is deleted. @@ -60,12 +60,11 @@ interface BackendInterface { * tree. * * @param string $path - * @return void */ - function delete($path); + public function delete($path); /** - * This method is called after a successful MOVE + * This method is called after a successful MOVE. * * This should be used to migrate all properties from one path to another. * Note that entire collections may be moved, so ensure that all properties @@ -73,8 +72,6 @@ interface BackendInterface { * * @param string $source * @param string $destination - * @return void */ - function move($source, $destination); - + public function move($source, $destination); } diff --git a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php index 6f3f1feaf..e640f420e 100644 --- a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php +++ b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PropertyStorage\Backend; use Sabre\DAV\PropFind; @@ -18,8 +20,8 @@ use Sabre\DAV\Xml\Property\Complex; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO implements BackendInterface { - +class PDO implements BackendInterface +{ /** * Value is stored as string. */ @@ -36,28 +38,27 @@ class PDO implements BackendInterface { const VT_OBJECT = 3; /** - * PDO + * PDO. * * @var \PDO */ protected $pdo; /** - * PDO table name we'll be using + * PDO table name we'll be using. * * @var string */ public $tableName = 'propertystorage'; /** - * Creates the PDO property storage engine + * Creates the PDO property storage engine. * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -73,42 +74,40 @@ class PDO implements BackendInterface { * However, you can also support the 'allprops' property here. In that * case, you should check for $propFind->isAllProps(). * - * @param string $path + * @param string $path * @param PropFind $propFind - * @return void */ - function propFind($path, PropFind $propFind) { - - if (!$propFind->isAllProps() && count($propFind->get404Properties()) === 0) { + public function propFind($path, PropFind $propFind) + { + if (!$propFind->isAllProps() && 0 === count($propFind->get404Properties())) { return; } - $query = 'SELECT name, value, valuetype FROM ' . $this->tableName . ' WHERE path = ?'; + $query = 'SELECT name, value, valuetype FROM '.$this->tableName.' WHERE path = ?'; $stmt = $this->pdo->prepare($query); $stmt->execute([$path]); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - if (gettype($row['value']) === 'resource') { + if ('resource' === gettype($row['value'])) { $row['value'] = stream_get_contents($row['value']); } switch ($row['valuetype']) { - case null : - case self::VT_STRING : + case null: + case self::VT_STRING: $propFind->set($row['name'], $row['value']); break; - case self::VT_XML : + case self::VT_XML: $propFind->set($row['name'], new Complex($row['value'])); break; - case self::VT_OBJECT : + case self::VT_OBJECT: $propFind->set($row['name'], unserialize($row['value'])); break; } } - } /** - * Updates properties for a path + * Updates properties for a path. * * This method received a PropPatch object, which contains all the * information about the update. @@ -116,38 +115,30 @@ class PDO implements BackendInterface { * Usually you would want to call 'handleRemaining' on this object, to get; * a list of all properties that need to be stored. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch) { - - $propPatch->handleRemaining(function($properties) use ($path) { - - - if ($this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'pgsql') { - + public function propPatch($path, PropPatch $propPatch) + { + $propPatch->handleRemaining(function ($properties) use ($path) { + if ('pgsql' === $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) { $updateSql = <<<SQL INSERT INTO {$this->tableName} (path, name, valuetype, value) VALUES (:path, :name, :valuetype, :value) ON CONFLICT (path, name) DO UPDATE SET valuetype = :valuetype, value = :value SQL; - - } else { $updateSql = <<<SQL REPLACE INTO {$this->tableName} (path, name, valuetype, value) VALUES (:path, :name, :valuetype, :value) SQL; - } $updateStmt = $this->pdo->prepare($updateSql); - $deleteStmt = $this->pdo->prepare("DELETE FROM " . $this->tableName . " WHERE path = ? AND name = ?"); + $deleteStmt = $this->pdo->prepare('DELETE FROM '.$this->tableName.' WHERE path = ? AND name = ?'); foreach ($properties as $name => $value) { - if (!is_null($value)) { if (is_scalar($value)) { $valueType = self::VT_STRING; @@ -165,17 +156,13 @@ SQL; $updateStmt->bindParam('value', $value, \PDO::PARAM_LOB); $updateStmt->execute(); - } else { $deleteStmt->execute([$path, $name]); } - } return true; - }); - } /** @@ -187,26 +174,24 @@ SQL; * tree. * * @param string $path - * @return void */ - function delete($path) { - - $stmt = $this->pdo->prepare("DELETE FROM " . $this->tableName . " WHERE path = ? OR path LIKE ? ESCAPE '='"); + public function delete($path) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->tableName." WHERE path = ? OR path LIKE ? ESCAPE '='"); $childPath = strtr( $path, [ '=' => '==', '%' => '=%', - '_' => '=_' + '_' => '=_', ] - ) . '/%'; + ).'/%'; $stmt->execute([$path, $childPath]); - } /** - * This method is called after a successful MOVE + * This method is called after a successful MOVE. * * This should be used to migrate all properties from one path to another. * Note that entire collections may be moved, so ensure that all properties @@ -214,33 +199,30 @@ SQL; * * @param string $source * @param string $destination - * @return void */ - function move($source, $destination) { - + public function move($source, $destination) + { // I don't know a way to write this all in a single sql query that's // also compatible across db engines, so we're letting PHP do all the // updates. Much slower, but it should still be pretty fast in most // cases. - $select = $this->pdo->prepare('SELECT id, path FROM ' . $this->tableName . ' WHERE path = ? OR path LIKE ?'); - $select->execute([$source, $source . '/%']); + $select = $this->pdo->prepare('SELECT id, path FROM '.$this->tableName.' WHERE path = ? OR path LIKE ?'); + $select->execute([$source, $source.'/%']); - $update = $this->pdo->prepare('UPDATE ' . $this->tableName . ' SET path = ? WHERE id = ?'); + $update = $this->pdo->prepare('UPDATE '.$this->tableName.' SET path = ? WHERE id = ?'); while ($row = $select->fetch(\PDO::FETCH_ASSOC)) { - // Sanity check. SQL may select too many records, such as records // with different cases. - if ($row['path'] !== $source && strpos($row['path'], $source . '/') !== 0) continue; + if ($row['path'] !== $source && 0 !== strpos($row['path'], $source.'/')) { + continue; + } $trailingPart = substr($row['path'], strlen($source) + 1); $newPath = $destination; if ($trailingPart) { - $newPath .= '/' . $trailingPart; + $newPath .= '/'.$trailingPart; } $update->execute([$newPath, $row['id']]); - } - } - } diff --git a/vendor/sabre/dav/lib/DAV/PropertyStorage/Plugin.php b/vendor/sabre/dav/lib/DAV/PropertyStorage/Plugin.php index a66a14113..aa8610eb8 100644 --- a/vendor/sabre/dav/lib/DAV/PropertyStorage/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/PropertyStorage/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PropertyStorage; use Sabre\DAV\INode; @@ -23,8 +25,8 @@ use Sabre\DAV\ServerPlugin; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ /** * If you only want this plugin to store properties for a limited set of * paths, you can use a pathFilter to do this. @@ -43,14 +45,13 @@ class Plugin extends ServerPlugin { public $backend; /** - * Creates the plugin + * Creates the plugin. * * @param Backend\BackendInterface $backend */ - function __construct(Backend\BackendInterface $backend) { - + public function __construct(Backend\BackendInterface $backend) + { $this->backend = $backend; - } /** @@ -62,15 +63,13 @@ class Plugin extends ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - function initialize(Server $server) { - - $server->on('propFind', [$this, 'propFind'], 130); - $server->on('propPatch', [$this, 'propPatch'], 300); - $server->on('afterMove', [$this, 'afterMove']); + public function initialize(Server $server) + { + $server->on('propFind', [$this, 'propFind'], 130); + $server->on('propPatch', [$this, 'propPatch'], 300); + $server->on('afterMove', [$this, 'afterMove']); $server->on('afterUnbind', [$this, 'afterUnbind']); - } /** @@ -80,34 +79,34 @@ class Plugin extends ServerPlugin { * plugin will look in the property storage backend to find them. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - + public function propFind(PropFind $propFind, INode $node) + { $path = $propFind->getPath(); $pathFilter = $this->pathFilter; - if ($pathFilter && !$pathFilter($path)) return; + if ($pathFilter && !$pathFilter($path)) { + return; + } $this->backend->propFind($propFind->getPath(), $propFind); - } /** - * Called during PROPPATCH operations + * Called during PROPPATCH operations. * * If there's any updated properties that haven't been stored, the * propertystorage backend can handle it. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch) { - + public function propPatch($path, PropPatch $propPatch) + { $pathFilter = $this->pathFilter; - if ($pathFilter && !$pathFilter($path)) return; + if ($pathFilter && !$pathFilter($path)) { + return; + } $this->backend->propPatch($path, $propPatch); - } /** @@ -117,14 +116,14 @@ class Plugin extends ServerPlugin { * database. * * @param string $path - * @return void */ - function afterUnbind($path) { - + public function afterUnbind($path) + { $pathFilter = $this->pathFilter; - if ($pathFilter && !$pathFilter($path)) return; + if ($pathFilter && !$pathFilter($path)) { + return; + } $this->backend->delete($path); - } /** @@ -134,18 +133,20 @@ class Plugin extends ServerPlugin { * * @param string $source * @param string $destination - * @return void */ - function afterMove($source, $destination) { - + public function afterMove($source, $destination) + { $pathFilter = $this->pathFilter; - if ($pathFilter && !$pathFilter($source)) return; + if ($pathFilter && !$pathFilter($source)) { + return; + } // If the destination is filtered, afterUnbind will handle cleaning up // the properties. - if ($pathFilter && !$pathFilter($destination)) return; + if ($pathFilter && !$pathFilter($destination)) { + return; + } $this->backend->move($source, $destination); - } /** @@ -156,10 +157,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'property-storage'; - } /** @@ -173,13 +173,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'This plugin allows any arbitrary WebDAV property to be set on any resource.', - 'link' => 'http://sabre.io/dav/property-storage/', + 'link' => 'http://sabre.io/dav/property-storage/', ]; - } } diff --git a/vendor/sabre/dav/lib/DAV/Server.php b/vendor/sabre/dav/lib/DAV/Server.php index f7fcf3057..09760e9d1 100644 --- a/vendor/sabre/dav/lib/DAV/Server.php +++ b/vendor/sabre/dav/lib/DAV/Server.php @@ -1,76 +1,79 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; -use Sabre\Event\EventEmitter; +use Sabre\Event\EmitterInterface; +use Sabre\Event\WildcardEmitterTrait; use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -use Sabre\HTTP\URLUtil; use Sabre\Uri; /** - * Main DAV server class + * Main DAV server class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Server extends EventEmitter implements LoggerAwareInterface { - +class Server implements LoggerAwareInterface, EmitterInterface +{ + use WildcardEmitterTrait; use LoggerAwareTrait; /** - * Infinity is used for some request supporting the HTTP Depth header and indicates that the operation should traverse the entire tree + * Infinity is used for some request supporting the HTTP Depth header and indicates that the operation should traverse the entire tree. */ const DEPTH_INFINITY = -1; /** - * XML namespace for all SabreDAV related elements + * XML namespace for all SabreDAV related elements. */ const NS_SABREDAV = 'http://sabredav.org/ns'; /** - * The tree object + * The tree object. * * @var Tree */ public $tree; /** - * The base uri + * The base uri. * * @var string */ protected $baseUri = null; /** - * httpResponse + * httpResponse. * * @var HTTP\Response */ public $httpResponse; /** - * httpRequest + * httpRequest. * * @var HTTP\Request */ public $httpRequest; /** - * PHP HTTP Sapi + * PHP HTTP Sapi. * * @var HTTP\Sapi */ public $sapi; /** - * The list of plugins + * The list of plugins. * * @var array */ @@ -98,7 +101,6 @@ class Server extends EventEmitter implements LoggerAwareInterface { * @var string[] */ public $protectedProperties = [ - // RFC4918 '{DAV:}getcontentlength', '{DAV:}getetag', @@ -129,12 +131,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { // sabredav extensions '{http://sabredav.org/ns}sync-token', - ]; /** * This is a flag that allow or not showing file, line and code - * of the exception in the returned XML + * of the exception in the returned XML. * * @var bool */ @@ -181,10 +182,10 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @var bool */ - static $exposeVersion = true; + public static $exposeVersion = true; /** - * Sets up the server + * Sets up the server. * * If a Sabre\DAV\Tree object is passed as an argument, it will * use it as the directory tree. If a Sabre\DAV\INode is passed, it @@ -198,25 +199,15 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @param Tree|INode|array|null $treeOrNode The tree object */ - function __construct($treeOrNode = null) { - + public function __construct($treeOrNode = null) + { if ($treeOrNode instanceof Tree) { $this->tree = $treeOrNode; } elseif ($treeOrNode instanceof INode) { $this->tree = new Tree($treeOrNode); } elseif (is_array($treeOrNode)) { - - // If it's an array, a list of nodes was passed, and we need to - // create the root node. - foreach ($treeOrNode as $node) { - if (!($node instanceof INode)) { - throw new Exception('Invalid argument passed to constructor. If you\'re passing an array, all the values must implement Sabre\\DAV\\INode'); - } - } - $root = new SimpleCollection('root', $treeOrNode); $this->tree = new Tree($root); - } elseif (is_null($treeOrNode)) { $root = new SimpleCollection('root'); $this->tree = new Tree($root); @@ -229,18 +220,14 @@ class Server extends EventEmitter implements LoggerAwareInterface { $this->httpResponse = new HTTP\Response(); $this->httpRequest = $this->sapi->getRequest(); $this->addPlugin(new CorePlugin()); - } /** - * Starts the DAV Server - * - * @return void + * Starts the DAV Server. */ - function exec() { - + public function start() + { try { - // If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an // origin, we must make sure we send back HTTP/1.0 if this was // requested. @@ -252,9 +239,7 @@ class Server extends EventEmitter implements LoggerAwareInterface { // Setting the base url $this->httpRequest->setBaseUrl($this->getBaseUri()); $this->invokeMethod($this->httpRequest, $this->httpResponse); - - } catch (\Exception $e) { - + } catch (\Throwable $e) { try { $this->emit('exception', [$e]); } catch (\Exception $ignore) { @@ -266,10 +251,8 @@ class Server extends EventEmitter implements LoggerAwareInterface { $error->setAttribute('xmlns:s', self::NS_SABREDAV); $DOM->appendChild($error); - $h = function($v) { - - return htmlspecialchars($v, ENT_NOQUOTES, 'UTF-8'); - + $h = function ($v) { + return htmlspecialchars((string) $v, ENT_NOQUOTES, 'UTF-8'); }; if (self::$exposeVersion) { @@ -299,18 +282,13 @@ class Server extends EventEmitter implements LoggerAwareInterface { } } - if ($e instanceof Exception) { - $httpCode = $e->getHTTPCode(); $e->serialize($this, $error); $headers = $e->getHTTPHeaders($this); - } else { - $httpCode = 500; $headers = []; - } $headers['Content-Type'] = 'application/xml; charset=utf-8'; @@ -318,37 +296,46 @@ class Server extends EventEmitter implements LoggerAwareInterface { $this->httpResponse->setHeaders($headers); $this->httpResponse->setBody($DOM->saveXML()); $this->sapi->sendResponse($this->httpResponse); - } + } + /** + * Alias of start(). + * + * @deprecated + */ + public function exec() + { + $this->start(); } /** - * Sets the base server uri + * Sets the base server uri. * * @param string $uri - * @return void */ - function setBaseUri($uri) { - + public function setBaseUri($uri) + { // If the baseUri does not end with a slash, we must add it - if ($uri[strlen($uri) - 1] !== '/') + if ('/' !== $uri[strlen($uri) - 1]) { $uri .= '/'; + } $this->baseUri = $uri; - } /** - * Returns the base responding uri + * Returns the base responding uri. * * @return string */ - function getBaseUri() { + public function getBaseUri() + { + if (is_null($this->baseUri)) { + $this->baseUri = $this->guessBaseUri(); + } - if (is_null($this->baseUri)) $this->baseUri = $this->guessBaseUri(); return $this->baseUri; - } /** @@ -359,53 +346,50 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @return string */ - function guessBaseUri() { - + public function guessBaseUri() + { $pathInfo = $this->httpRequest->getRawServerValue('PATH_INFO'); $uri = $this->httpRequest->getRawServerValue('REQUEST_URI'); // If PATH_INFO is found, we can assume it's accurate. if (!empty($pathInfo)) { - // We need to make sure we ignore the QUERY_STRING part - if ($pos = strpos($uri, '?')) + if ($pos = strpos($uri, '?')) { $uri = substr($uri, 0, $pos); + } // PATH_INFO is only set for urls, such as: /example.php/path // in that case PATH_INFO contains '/path'. // Note that REQUEST_URI is percent encoded, while PATH_INFO is // not, Therefore they are only comparable if we first decode // REQUEST_INFO as well. - $decodedUri = URLUtil::decodePath($uri); + $decodedUri = HTTP\decodePath($uri); // A simple sanity check: if (substr($decodedUri, strlen($decodedUri) - strlen($pathInfo)) === $pathInfo) { $baseUri = substr($decodedUri, 0, strlen($decodedUri) - strlen($pathInfo)); - return rtrim($baseUri, '/') . '/'; - } - throw new Exception('The REQUEST_URI (' . $uri . ') did not end with the contents of PATH_INFO (' . $pathInfo . '). This server might be misconfigured.'); + return rtrim($baseUri, '/').'/'; + } + throw new Exception('The REQUEST_URI ('.$uri.') did not end with the contents of PATH_INFO ('.$pathInfo.'). This server might be misconfigured.'); } // The last fallback is that we're just going to assume the server root. return '/'; - } /** - * Adds a plugin to the server + * Adds a plugin to the server. * * For more information, console the documentation of Sabre\DAV\ServerPlugin * * @param ServerPlugin $plugin - * @return void */ - function addPlugin(ServerPlugin $plugin) { - + public function addPlugin(ServerPlugin $plugin) + { $this->plugins[$plugin->getPluginName()] = $plugin; $plugin->initialize($this); - } /** @@ -414,26 +398,26 @@ class Server extends EventEmitter implements LoggerAwareInterface { * This function returns null if the plugin was not found. * * @param string $name + * * @return ServerPlugin */ - function getPlugin($name) { - - if (isset($this->plugins[$name])) + public function getPlugin($name) + { + if (isset($this->plugins[$name])) { return $this->plugins[$name]; + } return null; - } /** - * Returns all plugins + * Returns all plugins. * * @return array */ - function getPlugins() { - + public function getPlugins() + { return $this->plugins; - } /** @@ -441,29 +425,29 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @return LoggerInterface */ - function getLogger() { - + public function getLogger() + { if (!$this->logger) { $this->logger = new NullLogger(); } - return $this->logger; + return $this->logger; } /** - * Handles a http request, and execute a method based on its name + * Handles a http request, and execute a method based on its name. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @param bool $sendResponse Whether to send the HTTP response to the DAV client. - * @return void + * @param bool $sendResponse whether to send the HTTP response to the DAV client */ - function invokeMethod(RequestInterface $request, ResponseInterface $response, $sendResponse = true) { - + public function invokeMethod(RequestInterface $request, ResponseInterface $response, $sendResponse = true) + { $method = $request->getMethod(); - if (!$this->emit('beforeMethod:' . $method, [$request, $response])) return; - if (!$this->emit('beforeMethod', [$request, $response])) return; + if (!$this->emit('beforeMethod:'.$method, [$request, $response])) { + return; + } if (self::$exposeVersion) { $response->setHeader('X-Sabre-Version', Version::VERSION); @@ -473,32 +457,31 @@ class Server extends EventEmitter implements LoggerAwareInterface { if (!$this->checkPreconditions($request, $response)) { $this->sapi->sendResponse($response); + return; } - if ($this->emit('method:' . $method, [$request, $response])) { - if ($this->emit('method', [$request, $response])) { - $exMessage = "There was no plugin in the system that was willing to handle this " . $method . " method."; - if ($method === "GET") { - $exMessage .= " Enable the Browser plugin to get a better result here."; - } - - // Unsupported method - throw new Exception\NotImplemented($exMessage); + if ($this->emit('method:'.$method, [$request, $response])) { + $exMessage = 'There was no plugin in the system that was willing to handle this '.$method.' method.'; + if ('GET' === $method) { + $exMessage .= ' Enable the Browser plugin to get a better result here.'; } + + // Unsupported method + throw new Exception\NotImplemented($exMessage); } - if (!$this->emit('afterMethod:' . $method, [$request, $response])) return; - if (!$this->emit('afterMethod', [$request, $response])) return; + if (!$this->emit('afterMethod:'.$method, [$request, $response])) { + return; + } - if ($response->getStatus() === null) { + if (null === $response->getStatus()) { throw new Exception('No subsystem set a valid HTTP status code. Something must have interrupted the request without providing further detail.'); } if ($sendResponse) { $this->sapi->sendResponse($response); $this->emit('afterResponse', [$request, $response]); } - } // {{{ HTTP/WebDAV protocol helpers @@ -507,10 +490,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { * Returns an array with all the supported HTTP methods for a specific uri. * * @param string $path + * * @return array */ - function getAllowedMethods($path) { - + public function getAllowedMethods($path) + { $methods = [ 'OPTIONS', 'GET', @@ -521,7 +505,7 @@ class Server extends EventEmitter implements LoggerAwareInterface { 'PROPPATCH', 'COPY', 'MOVE', - 'REPORT' + 'REPORT', ]; // The MKCOL is only allowed on an unmapped uri @@ -532,22 +516,22 @@ class Server extends EventEmitter implements LoggerAwareInterface { } // We're also checking if any of the plugins register any new methods - foreach ($this->plugins as $plugin) $methods = array_merge($methods, $plugin->getHTTPMethods($path)); + foreach ($this->plugins as $plugin) { + $methods = array_merge($methods, $plugin->getHTTPMethods($path)); + } array_unique($methods); return $methods; - } /** - * Gets the uri for the request, keeping the base uri into consideration + * Gets the uri for the request, keeping the base uri into consideration. * * @return string */ - function getRequestUri() { - + public function getRequestUri() + { return $this->calculateUri($this->httpRequest->getUrl()); - } /** @@ -559,66 +543,65 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * uri-decodes the path * * @param string $uri + * * @throws Exception\Forbidden A permission denied exception is thrown whenever there was an attempt to supply a uri outside of the base uri + * * @return string */ - function calculateUri($uri) { - - if ($uri[0] != '/' && strpos($uri, '://')) { - + public function calculateUri($uri) + { + if ('' != $uri && '/' != $uri[0] && strpos($uri, '://')) { $uri = parse_url($uri, PHP_URL_PATH); - } - $uri = Uri\normalize(str_replace('//', '/', $uri)); + $uri = Uri\normalize(preg_replace('|/+|', '/', $uri)); $baseUri = Uri\normalize($this->getBaseUri()); - if (strpos($uri, $baseUri) === 0) { - - return trim(URLUtil::decodePath(substr($uri, strlen($baseUri))), '/'); + if (0 === strpos($uri, $baseUri)) { + return trim(HTTP\decodePath(substr($uri, strlen($baseUri))), '/'); // A special case, if the baseUri was accessed without a trailing // slash, we'll accept it as well. - } elseif ($uri . '/' === $baseUri) { - + } elseif ($uri.'/' === $baseUri) { return ''; - } else { - - throw new Exception\Forbidden('Requested uri (' . $uri . ') is out of base uri (' . $this->getBaseUri() . ')'); - + throw new Exception\Forbidden('Requested uri ('.$uri.') is out of base uri ('.$this->getBaseUri().')'); } - } /** - * Returns the HTTP depth header + * Returns the HTTP depth header. * * This method returns the contents of the HTTP depth request header. If the depth header was 'infinity' it will return the Sabre\DAV\Server::DEPTH_INFINITY object * It is possible to supply a default depth value, which is used when the depth header has invalid content, or is completely non-existent * * @param mixed $default + * * @return int */ - function getHTTPDepth($default = self::DEPTH_INFINITY) { - + public function getHTTPDepth($default = self::DEPTH_INFINITY) + { // If its not set, we'll grab the default $depth = $this->httpRequest->getHeader('Depth'); - if (is_null($depth)) return $default; - - if ($depth == 'infinity') return self::DEPTH_INFINITY; + if (is_null($depth)) { + return $default; + } + if ('infinity' == $depth) { + return self::DEPTH_INFINITY; + } // If its an unknown value. we'll grab the default - if (!ctype_digit($depth)) return $default; - - return (int)$depth; + if (!ctype_digit($depth)) { + return $default; + } + return (int) $depth; } /** - * Returns the HTTP range header + * Returns the HTTP range header. * * This method returns null if there is no well-formed HTTP range request * header or array($start, $end). @@ -629,24 +612,29 @@ class Server extends EventEmitter implements LoggerAwareInterface { * If the second offset is null, it should be treated as the offset of the last byte of the entity * If the first offset is null, the second offset should be used to retrieve the last x bytes of the entity * - * @return array|null + * @return int[]|null */ - function getHTTPRange() { - + public function getHTTPRange() + { $range = $this->httpRequest->getHeader('range'); - if (is_null($range)) return null; + if (is_null($range)) { + return null; + } // Matching "Range: bytes=1234-5678: both numbers are optional - if (!preg_match('/^bytes=([0-9]*)-([0-9]*)$/i', $range, $matches)) return null; + if (!preg_match('/^bytes=([0-9]*)-([0-9]*)$/i', $range, $matches)) { + return null; + } - if ($matches[1] === '' && $matches[2] === '') return null; + if ('' === $matches[1] && '' === $matches[2]) { + return null; + } return [ - $matches[1] !== '' ? $matches[1] : null, - $matches[2] !== '' ? $matches[2] : null, + '' !== $matches[1] ? (int) $matches[1] : null, + '' !== $matches[2] ? (int) $matches[2] : null, ]; - } /** @@ -675,8 +663,8 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @return array */ - function getHTTPPrefer() { - + public function getHTTPPrefer() + { $result = [ // can be true or false 'respond-async' => false, @@ -689,23 +677,19 @@ class Server extends EventEmitter implements LoggerAwareInterface { ]; if ($prefer = $this->httpRequest->getHeader('Prefer')) { - $result = array_merge( $result, HTTP\parsePrefer($prefer) ); - - } elseif ($this->httpRequest->getHeader('Brief') == 't') { + } elseif ('t' == $this->httpRequest->getHeader('Brief')) { $result['return'] = 'minimal'; } return $result; - } - /** - * Returns information about Copy and Move requests + * Returns information about Copy and Move requests. * * This function is created to help getting information about the source and the destination for the * WebDAV MOVE and COPY HTTP request. It also validates a lot of information and throws proper exceptions @@ -715,74 +699,82 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * destinationExists - Whether or not the destination is an existing url (and should therefore be overwritten) * * @param RequestInterface $request - * @throws Exception\BadRequest upon missing or broken request headers + * + * @throws Exception\BadRequest upon missing or broken request headers * @throws Exception\UnsupportedMediaType when trying to copy into a - * non-collection. - * @throws Exception\PreconditionFailed If overwrite is set to false, but - * the destination exists. - * @throws Exception\Forbidden when source and destination paths are - * identical. - * @throws Exception\Conflict When trying to copy a node into its own - * subtree. + * non-collection + * @throws Exception\PreconditionFailed if overwrite is set to false, but + * the destination exists + * @throws Exception\Forbidden when source and destination paths are + * identical + * @throws Exception\Conflict when trying to copy a node into its own + * subtree + * * @return array */ - function getCopyAndMoveInfo(RequestInterface $request) { - + public function getCopyAndMoveInfo(RequestInterface $request) + { // Collecting the relevant HTTP headers - if (!$request->getHeader('Destination')) throw new Exception\BadRequest('The destination header was not supplied'); + if (!$request->getHeader('Destination')) { + throw new Exception\BadRequest('The destination header was not supplied'); + } $destination = $this->calculateUri($request->getHeader('Destination')); $overwrite = $request->getHeader('Overwrite'); - if (!$overwrite) $overwrite = 'T'; - if (strtoupper($overwrite) == 'T') $overwrite = true; - elseif (strtoupper($overwrite) == 'F') $overwrite = false; + if (!$overwrite) { + $overwrite = 'T'; + } + if ('T' == strtoupper($overwrite)) { + $overwrite = true; + } elseif ('F' == strtoupper($overwrite)) { + $overwrite = false; + } // We need to throw a bad request exception, if the header was invalid - else throw new Exception\BadRequest('The HTTP Overwrite header should be either T or F'); - - list($destinationDir) = URLUtil::splitPath($destination); + else { + throw new Exception\BadRequest('The HTTP Overwrite header should be either T or F'); + } + list($destinationDir) = Uri\split($destination); try { $destinationParent = $this->tree->getNodeForPath($destinationDir); - if (!($destinationParent instanceof ICollection)) throw new Exception\UnsupportedMediaType('The destination node is not a collection'); + if (!($destinationParent instanceof ICollection)) { + throw new Exception\UnsupportedMediaType('The destination node is not a collection'); + } } catch (Exception\NotFound $e) { - // If the destination parent node is not found, we throw a 409 throw new Exception\Conflict('The destination node is not found'); } try { - $destinationNode = $this->tree->getNodeForPath($destination); // If this succeeded, it means the destination already exists // we'll need to throw precondition failed in case overwrite is false - if (!$overwrite) throw new Exception\PreconditionFailed('The destination node already exists, and the overwrite header is set to false', 'Overwrite'); - + if (!$overwrite) { + throw new Exception\PreconditionFailed('The destination node already exists, and the overwrite header is set to false', 'Overwrite'); + } } catch (Exception\NotFound $e) { - // Destination didn't exist, we're all good $destinationNode = false; - } $requestPath = $request->getPath(); if ($destination === $requestPath) { throw new Exception\Forbidden('Source and destination uri are identical.'); } - if (substr($destination, 0, strlen($requestPath) + 1) === $requestPath . '/') { + if (substr($destination, 0, strlen($requestPath) + 1) === $requestPath.'/') { throw new Exception\Conflict('The destination may not be part of the same subtree as the source path.'); } // These are the three relevant properties we need to return return [ - 'destination' => $destination, - 'destinationExists' => !!$destinationNode, - 'destinationNode' => $destinationNode, + 'destination' => $destination, + 'destinationExists' => (bool) $destinationNode, + 'destinationNode' => $destinationNode, ]; - } /** - * Returns a list of properties for a path + * Returns a list of properties for a path. * * This is a simplified version getPropertiesForPath. If you aren't * interested in status codes, but you just want to have a flat list of @@ -793,18 +785,18 @@ class Server extends EventEmitter implements LoggerAwareInterface { * returned. * * @param string $path - * @param array $propertyNames + * @param array $propertyNames + * * @return array */ - function getProperties($path, $propertyNames) { - + public function getProperties($path, $propertyNames) + { $result = $this->getPropertiesForPath($path, $propertyNames, 0); if (isset($result[0][200])) { return $result[0][200]; } else { return []; } - } /** @@ -816,26 +808,27 @@ class Server extends EventEmitter implements LoggerAwareInterface { * The parent node will not be returned. * * @param string $path - * @param array $propertyNames + * @param array $propertyNames + * * @return array */ - function getPropertiesForChildren($path, $propertyNames) { - + public function getPropertiesForChildren($path, $propertyNames) + { $result = []; foreach ($this->getPropertiesForPath($path, $propertyNames, 1) as $k => $row) { - // Skipping the parent path - if ($k === 0) continue; + if (0 === $k) { + continue; + } $result[$row['href']] = $row[200]; - } - return $result; + return $result; } /** - * Returns a list of HTTP headers for a particular resource + * Returns a list of HTTP headers for a particular resource. * * The generated http headers are based on properties provided by the * resource. The method basically provides a simple mapping between @@ -844,61 +837,64 @@ class Server extends EventEmitter implements LoggerAwareInterface { * The headers are intended to be used for HEAD and GET requests. * * @param string $path + * * @return array */ - function getHTTPHeaders($path) { - + public function getHTTPHeaders($path) + { $propertyMap = [ - '{DAV:}getcontenttype' => 'Content-Type', + '{DAV:}getcontenttype' => 'Content-Type', '{DAV:}getcontentlength' => 'Content-Length', - '{DAV:}getlastmodified' => 'Last-Modified', - '{DAV:}getetag' => 'ETag', + '{DAV:}getlastmodified' => 'Last-Modified', + '{DAV:}getetag' => 'ETag', ]; $properties = $this->getProperties($path, array_keys($propertyMap)); $headers = []; foreach ($propertyMap as $property => $header) { - if (!isset($properties[$property])) continue; + if (!isset($properties[$property])) { + continue; + } if (is_scalar($properties[$property])) { $headers[$header] = $properties[$property]; // GetLastModified gets special cased } elseif ($properties[$property] instanceof Xml\Property\GetLastModified) { - $headers[$header] = HTTP\Util::toHTTPDate($properties[$property]->getTime()); + $headers[$header] = HTTP\toDate($properties[$property]->getTime()); } - } return $headers; - } /** * Small helper to support PROPFIND with DEPTH_INFINITY. * * @param PropFind $propFind - * @param array $yieldFirst - * @return \Iterator + * @param array $yieldFirst + * + * @return \Traversable */ - private function generatePathNodes(PropFind $propFind, array $yieldFirst = null) { - if ($yieldFirst !== null) { + private function generatePathNodes(PropFind $propFind, array $yieldFirst = null) + { + if (null !== $yieldFirst) { yield $yieldFirst; } $newDepth = $propFind->getDepth(); $path = $propFind->getPath(); - if ($newDepth !== self::DEPTH_INFINITY) { - $newDepth--; + if (self::DEPTH_INFINITY !== $newDepth) { + --$newDepth; } $propertyNames = $propFind->getRequestedProperties(); $propFindType = !empty($propertyNames) ? PropFind::NORMAL : PropFind::ALLPROPS; foreach ($this->tree->getChildren($path) as $childNode) { - if ($path !== '') { - $subPath = $path . '/' . $childNode->getName(); + if ('' !== $path) { + $subPath = $path.'/'.$childNode->getName(); } else { $subPath = $childNode->getName(); } @@ -906,20 +902,19 @@ class Server extends EventEmitter implements LoggerAwareInterface { yield [ $subPropFind, - $childNode + $childNode, ]; - if (($newDepth === self::DEPTH_INFINITY || $newDepth >= 1) && $childNode instanceof ICollection) { + if ((self::DEPTH_INFINITY === $newDepth || $newDepth >= 1) && $childNode instanceof ICollection) { foreach ($this->generatePathNodes($subPropFind) as $subItem) { yield $subItem; } } - } } /** - * Returns a list of properties for a given path + * Returns a list of properties for a given path. * * The path that should be supplied should have the baseUrl stripped out * The list of properties should be supplied in Clark notation. If the list is empty @@ -928,20 +923,21 @@ class Server extends EventEmitter implements LoggerAwareInterface { * If a depth of 1 is requested child elements will also be returned. * * @param string $path - * @param array $propertyNames - * @param int $depth + * @param array $propertyNames + * @param int $depth + * * @return array * * @deprecated Use getPropertiesIteratorForPath() instead (as it's more memory efficient) * @see getPropertiesIteratorForPath() */ - function getPropertiesForPath($path, $propertyNames = [], $depth = 0) { - + public function getPropertiesForPath($path, $propertyNames = [], $depth = 0) + { return iterator_to_array($this->getPropertiesIteratorForPath($path, $propertyNames, $depth)); - } + /** - * Returns a list of properties for a given path + * Returns a list of properties for a given path. * * The path that should be supplied should have the baseUrl stripped out * The list of properties should be supplied in Clark notation. If the list is empty @@ -950,33 +946,35 @@ class Server extends EventEmitter implements LoggerAwareInterface { * If a depth of 1 is requested child elements will also be returned. * * @param string $path - * @param array $propertyNames - * @param int $depth + * @param array $propertyNames + * @param int $depth + * * @return \Iterator */ - function getPropertiesIteratorForPath($path, $propertyNames = [], $depth = 0) { - + public function getPropertiesIteratorForPath($path, $propertyNames = [], $depth = 0) + { // The only two options for the depth of a propfind is 0 or 1 - as long as depth infinity is not enabled - if (!$this->enablePropfindDepthInfinity && $depth != 0) $depth = 1; + if (!$this->enablePropfindDepthInfinity && 0 != $depth) { + $depth = 1; + } $path = trim($path, '/'); $propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS; - $propFind = new PropFind($path, (array)$propertyNames, $depth, $propFindType); + $propFind = new PropFind($path, (array) $propertyNames, $depth, $propFindType); $parentNode = $this->tree->getNodeForPath($path); $propFindRequests = [[ $propFind, - $parentNode + $parentNode, ]]; - if (($depth > 0 || $depth === self::DEPTH_INFINITY) && $parentNode instanceof ICollection) { + if (($depth > 0 || self::DEPTH_INFINITY === $depth) && $parentNode instanceof ICollection) { $propFindRequests = $this->generatePathNodes(clone $propFind, current($propFindRequests)); } foreach ($propFindRequests as $propFindRequest) { - list($propFind, $node) = $propFindRequest; $r = $this->getPropertiesByNode($propFind, $node); if ($r) { @@ -993,9 +991,7 @@ class Server extends EventEmitter implements LoggerAwareInterface { } yield $result; } - } - } /** @@ -1010,17 +1006,17 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @param array $paths * @param array $propertyNames + * * @return array */ - function getPropertiesForMultiplePaths(array $paths, array $propertyNames = []) { - + public function getPropertiesForMultiplePaths(array $paths, array $propertyNames = []) + { $result = [ ]; $nodes = $this->tree->getMultipleNodes($paths); foreach ($nodes as $path => $node) { - $propFind = new PropFind($path, $propertyNames); $r = $this->getPropertiesByNode($propFind, $node); if ($r) { @@ -1032,14 +1028,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { $result[$path]['href'] .= '/'; } } - } return $result; - } - /** * Determines all properties for a node. * @@ -1051,13 +1044,13 @@ class Server extends EventEmitter implements LoggerAwareInterface { * list of properties. * * @param PropFind $propFind - * @param INode $node + * @param INode $node + * * @return bool */ - function getPropertiesByNode(PropFind $propFind, INode $node) { - + public function getPropertiesByNode(PropFind $propFind, INode $node) + { return $this->emit('propFind', [$propFind, $node]); - } /** @@ -1072,13 +1065,16 @@ class Server extends EventEmitter implements LoggerAwareInterface { * @param string $uri * @param resource $data * @param string $etag + * * @return bool */ - function createFile($uri, $data, &$etag = null) { + public function createFile($uri, $data, &$etag = null) + { + list($dir, $name) = Uri\split($uri); - list($dir, $name) = URLUtil::splitPath($uri); - - if (!$this->emit('beforeBind', [$uri])) return false; + if (!$this->emit('beforeBind', [$uri])) { + return false; + } $parent = $this->tree->getNodeForPath($dir); if (!$parent instanceof ICollection) { @@ -1091,13 +1087,17 @@ class Server extends EventEmitter implements LoggerAwareInterface { // // If $modified is true, we must not send back an ETag. $modified = false; - if (!$this->emit('beforeCreateFile', [$uri, &$data, $parent, &$modified])) return false; + if (!$this->emit('beforeCreateFile', [$uri, &$data, $parent, &$modified])) { + return false; + } $etag = $parent->createFile($name, $data); - if ($modified) $etag = null; + if ($modified) { + $etag = null; + } - $this->tree->markDirty($dir . '/' . $name); + $this->tree->markDirty($dir.'/'.$name); $this->emit('afterBind', [$uri]); $this->emit('afterCreateFile', [$uri, $parent]); @@ -1113,10 +1113,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { * @param string $uri * @param resource $data * @param string $etag + * * @return bool */ - function updateFile($uri, $data, &$etag = null) { - + public function updateFile($uri, $data, &$etag = null) + { $node = $this->tree->getNodeForPath($uri); // It is possible for an event handler to modify the content of the @@ -1125,47 +1126,46 @@ class Server extends EventEmitter implements LoggerAwareInterface { // // If $modified is true, we must not send back an ETag. $modified = false; - if (!$this->emit('beforeWriteContent', [$uri, $node, &$data, &$modified])) return false; + if (!$this->emit('beforeWriteContent', [$uri, $node, &$data, &$modified])) { + return false; + } $etag = $node->put($data); - if ($modified) $etag = null; + if ($modified) { + $etag = null; + } $this->emit('afterWriteContent', [$uri, $node]); return true; } - - /** * This method is invoked by sub-systems creating a new directory. * * @param string $uri - * @return void */ - function createDirectory($uri) { - + public function createDirectory($uri) + { $this->createCollection($uri, new MkCol(['{DAV:}collection'], [])); - } /** - * Use this method to create a new collection + * Use this method to create a new collection. + * + * @param string $uri The new uri + * @param MkCol $mkCol * - * @param string $uri The new uri - * @param MkCol $mkCol * @return array|null */ - function createCollection($uri, MkCol $mkCol) { - - list($parentUri, $newName) = URLUtil::splitPath($uri); + public function createCollection($uri, MkCol $mkCol) + { + list($parentUri, $newName) = Uri\split($uri); // Making sure the parent exists try { $parent = $this->tree->getNodeForPath($parentUri); - } catch (Exception\NotFound $e) { throw new Exception\Conflict('Parent node does not exist'); - } // Making sure the parent is a collection @@ -1179,26 +1179,23 @@ class Server extends EventEmitter implements LoggerAwareInterface { // If we got here.. it means there's already a node on that url, and we need to throw a 405 throw new Exception\MethodNotAllowed('The resource you tried to create already exists'); - } catch (Exception\NotFound $e) { // NotFound is the expected behavior. } - - if (!$this->emit('beforeBind', [$uri])) return; + if (!$this->emit('beforeBind', [$uri])) { + return; + } if ($parent instanceof IExtendedCollection) { - - /** + /* * If the parent is an instance of IExtendedCollection, it means that * we can pass the MkCol object directly as it may be able to store * properties immediately. */ $parent->createExtendedCollection($newName, $mkCol); - } else { - - /** + /* * If the parent is a standard ICollection, it means only * 'standard' collections can be created, so we should fail any * MKCOL operation that carries extra resourcetypes. @@ -1208,7 +1205,6 @@ class Server extends EventEmitter implements LoggerAwareInterface { } $parent->createDirectory($newName); - } // If there are any properties that have not been handled/stored, @@ -1227,23 +1223,21 @@ class Server extends EventEmitter implements LoggerAwareInterface { ]; foreach ($result as $propertyName => $status) { - if (!isset($formattedResult[$status])) { $formattedResult[$status] = []; } $formattedResult[$status][$propertyName] = null; - } + return $formattedResult; } $this->tree->markDirty($parentUri); $this->emit('afterBind', [$uri]); - } /** - * This method updates a resource's properties + * This method updates a resource's properties. * * The properties array must be a list of properties. Array-keys are * property names in clarknotation, array-values are it's values. @@ -1256,17 +1250,17 @@ class Server extends EventEmitter implements LoggerAwareInterface { * as their values. * * @param string $path - * @param array $properties + * @param array $properties + * * @return array */ - function updateProperties($path, array $properties) { - + public function updateProperties($path, array $properties) + { $propPatch = new PropPatch($properties); $this->emit('propPatch', [$path, $propPatch]); $propPatch->commit(); return $propPatch->getResult(); - } /** @@ -1287,19 +1281,19 @@ class Server extends EventEmitter implements LoggerAwareInterface { * related to If-None-Match, If-Match and If-Unmodified Since. It will * set the status to 304 Not Modified for If-Modified_since. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function checkPreconditions(RequestInterface $request, ResponseInterface $response) { - + public function checkPreconditions(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $node = null; $lastMod = null; $etag = null; if ($ifMatch = $request->getHeader('If-Match')) { - // If-Match contains an entity tag. Only if the entity-tag // matches we are allowed to make the request succeed. // If the entity-tag is '*' we are only allowed to make the @@ -1311,13 +1305,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { } // Only need to check entity tags if they are not * - if ($ifMatch !== '*') { - + if ('*' !== $ifMatch) { // There can be multiple ETags $ifMatch = explode(',', $ifMatch); $haveMatch = false; foreach ($ifMatch as $ifMatchItem) { - // Stripping any extra spaces $ifMatchItem = trim($ifMatchItem, ' '); @@ -1331,17 +1323,17 @@ class Server extends EventEmitter implements LoggerAwareInterface { $haveMatch = true; } } - } if (!$haveMatch) { - if ($etag) $response->setHeader('ETag', $etag); - throw new Exception\PreconditionFailed('An If-Match header was specified, but none of the specified the ETags matched.', 'If-Match'); + if ($etag) { + $response->setHeader('ETag', $etag); + } + throw new Exception\PreconditionFailed('An If-Match header was specified, but none of the specified ETags matched.', 'If-Match'); } } } if ($ifNoneMatch = $request->getHeader('If-None-Match')) { - // The If-None-Match header contains an ETag. // Only if the ETag does not match the current ETag, the request will succeed // The header can also contain *, in which case the request @@ -1356,46 +1348,46 @@ class Server extends EventEmitter implements LoggerAwareInterface { } if ($nodeExists) { $haveMatch = false; - if ($ifNoneMatch === '*') $haveMatch = true; - else { - + if ('*' === $ifNoneMatch) { + $haveMatch = true; + } else { // There might be multiple ETags $ifNoneMatch = explode(',', $ifNoneMatch); $etag = $node instanceof IFile ? $node->getETag() : null; foreach ($ifNoneMatch as $ifNoneMatchItem) { - // Stripping any extra spaces $ifNoneMatchItem = trim($ifNoneMatchItem, ' '); - if ($etag === $ifNoneMatchItem) $haveMatch = true; - + if ($etag === $ifNoneMatchItem) { + $haveMatch = true; + } } - } if ($haveMatch) { - if ($etag) $response->setHeader('ETag', $etag); - if ($request->getMethod() === 'GET') { + if ($etag) { + $response->setHeader('ETag', $etag); + } + if ('GET' === $request->getMethod()) { $response->setStatus(304); + return false; } else { throw new Exception\PreconditionFailed('An If-None-Match header was specified, but the ETag matched (or * was specified).', 'If-None-Match'); } } } - } if (!$ifNoneMatch && ($ifModifiedSince = $request->getHeader('If-Modified-Since'))) { - // The If-Modified-Since header contains a date. We // will only return the entity if it has been changed since // that date. If it hasn't been changed, we return a 304 // header // Note that this header only has to be checked if there was no If-None-Match header // as per the HTTP spec. - $date = HTTP\Util::parseHTTPDate($ifModifiedSince); + $date = HTTP\parseDate($ifModifiedSince); if ($date) { if (is_null($node)) { @@ -1403,10 +1395,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { } $lastMod = $node->getLastModified(); if ($lastMod) { - $lastMod = new \DateTime('@' . $lastMod); + $lastMod = new \DateTime('@'.$lastMod); if ($lastMod <= $date) { $response->setStatus(304); - $response->setHeader('Last-Modified', HTTP\Util::toHTTPDate($lastMod)); + $response->setHeader('Last-Modified', HTTP\toDate($lastMod)); + return false; } } @@ -1414,10 +1407,9 @@ class Server extends EventEmitter implements LoggerAwareInterface { } if ($ifUnmodifiedSince = $request->getHeader('If-Unmodified-Since')) { - // The If-Unmodified-Since will allow allow the request if the // entity has not changed since the specified date. - $date = HTTP\Util::parseHTTPDate($ifUnmodifiedSince); + $date = HTTP\parseDate($ifUnmodifiedSince); // We must only check the date if it's valid if ($date) { @@ -1426,13 +1418,12 @@ class Server extends EventEmitter implements LoggerAwareInterface { } $lastMod = $node->getLastModified(); if ($lastMod) { - $lastMod = new \DateTime('@' . $lastMod); + $lastMod = new \DateTime('@'.$lastMod); if ($lastMod > $date) { throw new Exception\PreconditionFailed('An If-Unmodified-Since header was specified, but the entity has been changed since the specified date.', 'If-Unmodified-Since'); } } } - } // Now the hardest, the If: header. The If: header can contain multiple @@ -1461,13 +1452,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { // Every ifCondition needs to validate to true, so we exit as soon as // we have an invalid condition. foreach ($ifConditions as $ifCondition) { - $uri = $ifCondition['uri']; $tokens = $ifCondition['tokens']; // We only need 1 valid token for the condition to succeed. foreach ($tokens as $token) { - $tokenValid = $token['validToken'] || !$token['token']; $etagValid = false; @@ -1477,35 +1466,28 @@ class Server extends EventEmitter implements LoggerAwareInterface { // Checking the ETag, only if the token was already deemed // valid and there is one. if ($token['etag'] && $tokenValid) { - // The token was valid, and there was an ETag. We must // grab the current ETag and check it. $node = $this->tree->getNodeForPath($uri); $etagValid = $node instanceof IFile && $node->getETag() == $token['etag']; - } - if (($tokenValid && $etagValid) ^ $token['negate']) { // Both were valid, so we can go to the next condition. continue 2; } - - } // If we ended here, it means there was no valid ETag + token // combination found for the current condition. This means we fail! - throw new Exception\PreconditionFailed('Failed to find a valid token/etag combination for ' . $uri, 'If'); - + throw new Exception\PreconditionFailed('Failed to find a valid token/etag combination for '.$uri, 'If'); } return true; - } /** - * This method is created to extract information from the WebDAV HTTP 'If:' header + * This method is created to extract information from the WebDAV HTTP 'If:' header. * * The If header can be quite complex, and has a bunch of features. We're using a regex to extract all relevant information * The function will return an array, containing structs with the following keys @@ -1573,12 +1555,15 @@ class Server extends EventEmitter implements LoggerAwareInterface { * ] * * @param RequestInterface $request + * * @return array */ - function getIfConditions(RequestInterface $request) { - + public function getIfConditions(RequestInterface $request) + { $header = $request->getHeader('If'); - if (!$header) return []; + if (!$header) { + return []; + } $matches = []; @@ -1588,18 +1573,16 @@ class Server extends EventEmitter implements LoggerAwareInterface { $conditions = []; foreach ($matches as $match) { - // If there was no uri specified in this match, and there were // already conditions parsed, we add the condition to the list of // conditions for the previous uri. if (!$match['uri'] && count($conditions)) { $conditions[count($conditions) - 1]['tokens'][] = [ 'negate' => $match['not'] ? true : false, - 'token' => $match['token'], - 'etag' => isset($match['etag']) ? $match['etag'] : '' + 'token' => $match['token'], + 'etag' => isset($match['etag']) ? $match['etag'] : '', ]; } else { - if (!$match['uri']) { $realUri = $request->getPath(); } else { @@ -1607,55 +1590,55 @@ class Server extends EventEmitter implements LoggerAwareInterface { } $conditions[] = [ - 'uri' => $realUri, + 'uri' => $realUri, 'tokens' => [ [ 'negate' => $match['not'] ? true : false, - 'token' => $match['token'], - 'etag' => isset($match['etag']) ? $match['etag'] : '' - ] + 'token' => $match['token'], + 'etag' => isset($match['etag']) ? $match['etag'] : '', + ], ], - ]; } - } return $conditions; - } /** * Returns an array with resourcetypes for a node. * * @param INode $node + * * @return array */ - function getResourceTypeForNode(INode $node) { - + public function getResourceTypeForNode(INode $node) + { $result = []; foreach ($this->resourceTypeMapping as $className => $resourceType) { - if ($node instanceof $className) $result[] = $resourceType; + if ($node instanceof $className) { + $result[] = $resourceType; + } } - return $result; + return $result; } // }}} // {{{ XML Readers & Writers - /** * Generates a WebDAV propfind response body based on a list of nodes. * * If 'strip404s' is set to true, all 404 responses will be removed. * * @param array|\Traversable $fileProperties The list with nodes - * @param bool $strip404s + * @param bool $strip404s + * * @return string */ - function generateMultiStatus($fileProperties, $strip404s = false) { - + public function generateMultiStatus($fileProperties, $strip404s = false) + { $w = $this->xml->getWriter(); $w->openMemory(); $w->contextUri = $this->baseUri; @@ -1664,7 +1647,6 @@ class Server extends EventEmitter implements LoggerAwareInterface { $w->startElement('{DAV:}multistatus'); foreach ($fileProperties as $entry) { - $href = $entry['href']; unset($entry['href']); if ($strip404s) { @@ -1675,14 +1657,12 @@ class Server extends EventEmitter implements LoggerAwareInterface { $entry ); $w->write([ - 'name' => '{DAV:}response', - 'value' => $response + 'name' => '{DAV:}response', + 'value' => $response, ]); } $w->endElement(); return $w->outputMemory(); - } - } diff --git a/vendor/sabre/dav/lib/DAV/ServerPlugin.php b/vendor/sabre/dav/lib/DAV/ServerPlugin.php index b2c468ab3..9aefa7f72 100644 --- a/vendor/sabre/dav/lib/DAV/ServerPlugin.php +++ b/vendor/sabre/dav/lib/DAV/ServerPlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -11,8 +13,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class ServerPlugin { - +abstract class ServerPlugin +{ /** * This initializes the plugin. * @@ -22,9 +24,8 @@ abstract class ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - abstract function initialize(Server $server); + abstract public function initialize(Server $server); /** * This method should return a list of server-features. @@ -34,10 +35,9 @@ abstract class ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return []; - } /** @@ -48,12 +48,12 @@ abstract class ServerPlugin { * available for the specified uri. * * @param string $path + * * @return array */ - function getHTTPMethods($path) { - + public function getHTTPMethods($path) + { return []; - } /** @@ -64,10 +64,9 @@ abstract class ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return get_class($this); - } /** @@ -78,12 +77,12 @@ abstract class ServerPlugin { * implement them * * @param string $uri + * * @return array */ - function getSupportedReportSet($uri) { - + public function getSupportedReportSet($uri) + { return []; - } /** @@ -97,14 +96,12 @@ abstract class ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => null, - 'link' => null, + 'link' => null, ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php b/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php index 034aefbdc..a746ac753 100644 --- a/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php +++ b/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Sharing; use Sabre\DAV\INode; @@ -13,8 +15,8 @@ use Sabre\DAV\INode; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ISharedNode extends INode { - +interface ISharedNode extends INode +{ /** * Returns the 'access level' for the instance of this shared resource. * @@ -23,7 +25,7 @@ interface ISharedNode extends INode { * * @return int */ - function getShareAccess(); + public function getShareAccess(); /** * This function must return a URI that uniquely identifies the shared @@ -36,7 +38,7 @@ interface ISharedNode extends INode { * * @return string */ - function getShareResourceUri(); + public function getShareResourceUri(); /** * Updates the list of sharees. @@ -44,9 +46,8 @@ interface ISharedNode extends INode { * Every item must be a Sharee object. * * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees - * @return void */ - function updateInvites(array $sharees); + public function updateInvites(array $sharees); /** * Returns the list of people whom this resource is shared with. @@ -64,6 +65,5 @@ interface ISharedNode extends INode { * * @return \Sabre\DAV\Xml\Element\Sharee[] */ - function getInvites(); - + public function getInvites(); } diff --git a/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php b/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php index ef5702c57..5706fabf1 100644 --- a/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Sharing; use Sabre\DAV\Exception\BadRequest; @@ -14,7 +16,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * This plugin implements HTTP requests and properties related to: + * This plugin implements HTTP requests and properties related to:. * * draft-pot-webdav-resource-sharing * @@ -24,8 +26,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ const ACCESS_NOTSHARED = 0; const ACCESS_SHAREDOWNER = 1; const ACCESS_READ = 2; @@ -52,10 +54,9 @@ class Plugin extends ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['resource-sharing']; - } /** @@ -66,10 +67,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'sharing'; - } /** @@ -81,10 +81,9 @@ class Plugin extends ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; $server->xml->elementMap['{DAV:}share-resource'] = 'Sabre\\DAV\\Xml\\Request\\ShareResource'; @@ -94,12 +93,11 @@ class Plugin extends ServerPlugin { '{DAV:}share-mode' ); - $server->on('method:POST', [$this, 'httpPost']); - $server->on('propFind', [$this, 'propFind']); + $server->on('method:POST', [$this, 'httpPost']); + $server->on('propFind', [$this, 'propFind']); $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']); - $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); - $server->on('onBrowserPostAction', [$this, 'browserPostAction']); - + $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); + $server->on('onBrowserPostAction', [$this, 'browserPostAction']); } /** @@ -108,18 +106,15 @@ class Plugin extends ServerPlugin { * The sharees array is a list of people that are to be added modified * or removed in the list of shares. * - * @param string $path + * @param string $path * @param Sharee[] $sharees - * @return void */ - function shareResource($path, array $sharees) { - + public function shareResource($path, array $sharees) + { $node = $this->server->tree->getNodeForPath($path); if (!$node instanceof ISharedNode) { - throw new Forbidden('Sharing is not allowed on this node'); - } // Getting ACL info @@ -138,7 +133,6 @@ class Plugin extends ServerPlugin { $sharee->principal = $principal; } $node->updateInvites($sharees); - } /** @@ -147,47 +141,41 @@ class Plugin extends ServerPlugin { * This allows us to inject any sharings-specific properties. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - + public function propFind(PropFind $propFind, INode $node) + { if ($node instanceof ISharedNode) { - - $propFind->handle('{DAV:}share-access', function() use ($node) { - + $propFind->handle('{DAV:}share-access', function () use ($node) { return new Property\ShareAccess($node->getShareAccess()); - }); - $propFind->handle('{DAV:}invite', function() use ($node) { - + $propFind->handle('{DAV:}invite', function () use ($node) { return new Property\Invite($node->getInvites()); - }); - $propFind->handle('{DAV:}share-resource-uri', function() use ($node) { - + $propFind->handle('{DAV:}share-resource-uri', function () use ($node) { return new Property\Href($node->getShareResourceUri()); - }); - } - } /** - * We intercept this to handle POST requests on shared resources + * We intercept this to handle POST requests on shared resources. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return null|bool + * + * @return bool|null */ - function httpPost(RequestInterface $request, ResponseInterface $response) { - + public function httpPost(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $contentType = $request->getHeader('Content-Type'); + if (null === $contentType) { + return; + } // We're only interested in the davsharing content type. - if (strpos($contentType, 'application/davsharing+xml') === false) { + if (false === strpos($contentType, 'application/davsharing+xml')) { return; } @@ -198,7 +186,6 @@ class Plugin extends ServerPlugin { ); switch ($documentType) { - case '{DAV:}share-resource': $this->shareResource($path, $message->sharees); @@ -210,11 +197,9 @@ class Plugin extends ServerPlugin { // Breaking the event chain return false; - default : - throw new BadRequest('Unexpected document type: ' . $documentType . ' for this Content-Type'); - + default: + throw new BadRequest('Unexpected document type: '.$documentType.' for this Content-Type'); } - } /** @@ -226,11 +211,11 @@ class Plugin extends ServerPlugin { * @param INode $node * @param array $supportedPrivilegeSet */ - function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) { - + public function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) + { if ($node instanceof ISharedNode) { $supportedPrivilegeSet['{DAV:}share'] = [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ]; } @@ -247,27 +232,27 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'This plugin implements WebDAV resource sharing', - 'link' => 'https://github.com/evert/webdav-sharing' + 'link' => 'https://github.com/evert/webdav-sharing', ]; - } /** * This method is used to generate HTML output for the * DAV\Browser\Plugin. * - * @param INode $node + * @param INode $node * @param string $output * @param string $path + * * @return bool|null */ - function htmlActionsPanel(INode $node, &$output, $path) { - + public function htmlActionsPanel(INode $node, &$output, $path) + { if (!$node instanceof ISharedNode) { return; } @@ -293,7 +278,6 @@ class Plugin extends ServerPlugin { <input type="submit" value="share" /> </form> </td></tr>'; - } /** @@ -302,11 +286,11 @@ class Plugin extends ServerPlugin { * * @param string $path * @param string $action - * @param array $postVars + * @param array $postVars */ - function browserPostAction($path, $action, $postVars) { - - if ($action !== 'share') { + public function browserPostAction($path, $action, $postVars) + { + if ('share' !== $action) { return; } @@ -319,7 +303,7 @@ class Plugin extends ServerPlugin { $accessMap = [ 'readwrite' => self::ACCESS_READWRITE, - 'read' => self::ACCESS_READ, + 'read' => self::ACCESS_READ, 'no-access' => self::ACCESS_NOACCESS, ]; @@ -327,7 +311,7 @@ class Plugin extends ServerPlugin { throw new BadRequest('The "access" POST must be readwrite, read or no-access'); } $sharee = new Sharee([ - 'href' => $postVars['href'], + 'href' => $postVars['href'], 'access' => $accessMap[$postVars['access']], ]); @@ -335,8 +319,7 @@ class Plugin extends ServerPlugin { $path, [$sharee] ); - return false; + return false; } - } diff --git a/vendor/sabre/dav/lib/DAV/SimpleCollection.php b/vendor/sabre/dav/lib/DAV/SimpleCollection.php index 998cfcbff..1fbb6982d 100644 --- a/vendor/sabre/dav/lib/DAV/SimpleCollection.php +++ b/vendor/sabre/dav/lib/DAV/SimpleCollection.php @@ -1,9 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; +use InvalidArgumentException; + /** - * SimpleCollection + * SimpleCollection. * * The SimpleCollection is used to quickly setup static directory structures. * Just create the object with a proper name, and add children to use it. @@ -12,64 +16,64 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SimpleCollection extends Collection { - +class SimpleCollection extends Collection +{ /** - * List of childnodes + * List of childnodes. * * @var INode[] */ protected $children = []; /** - * Name of this resource + * Name of this resource. * * @var string */ protected $name; /** - * Creates this node + * Creates this node. * * The name of the node must be passed, child nodes can also be passed. * This nodes must be instances of INode * - * @param string $name + * @param string $name * @param INode[] $children */ - function __construct($name, array $children = []) { - + public function __construct($name, array $children = []) + { $this->name = $name; - foreach ($children as $child) { - - if (!($child instanceof INode)) throw new Exception('Only instances of Sabre\DAV\INode are allowed to be passed in the children argument'); + foreach ($children as $key => $child) { + if (is_string($child)) { + $child = new SimpleFile($key, $child); + } elseif (is_array($child)) { + $child = new self($key, $child); + } elseif (!$child instanceof INode) { + throw new InvalidArgumentException('Children must be specified as strings, arrays or instances of Sabre\DAV\INode'); + } $this->addChild($child); - } - } /** - * Adds a new childnode to this collection + * Adds a new childnode to this collection. * * @param INode $child - * @return void */ - function addChild(INode $child) { - + public function addChild(INode $child) + { $this->children[$child->getName()] = $child; - } /** - * Returns the name of the collection + * Returns the name of the collection. * * @return string */ - function getName() { - + public function getName() + { return $this->name; - } /** @@ -82,26 +86,26 @@ class SimpleCollection extends Collection { * exist. * * @param string $name + * * @throws Exception\NotFound + * * @return INode */ - function getChild($name) { - - if (isset($this->children[$name])) return $this->children[$name]; - throw new Exception\NotFound('File not found: ' . $name . ' in \'' . $this->getName() . '\''); - + public function getChild($name) + { + if (isset($this->children[$name])) { + return $this->children[$name]; + } + throw new Exception\NotFound('File not found: '.$name.' in \''.$this->getName().'\''); } /** - * Returns a list of children for this collection + * Returns a list of children for this collection. * * @return INode[] */ - function getChildren() { - + public function getChildren() + { return array_values($this->children); - } - - } diff --git a/vendor/sabre/dav/lib/DAV/SimpleFile.php b/vendor/sabre/dav/lib/DAV/SimpleFile.php index bcad786f3..ca808b672 100644 --- a/vendor/sabre/dav/lib/DAV/SimpleFile.php +++ b/vendor/sabre/dav/lib/DAV/SimpleFile.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * SimpleFile + * SimpleFile. * * The 'SimpleFile' class is used to easily add read-only immutable files to * the directory structure. One usecase would be to add a 'readme.txt' to a @@ -13,45 +15,44 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SimpleFile extends File { - +class SimpleFile extends File +{ /** - * File contents + * File contents. * * @var string */ protected $contents = []; /** - * Name of this resource + * Name of this resource. * * @var string */ protected $name; /** - * A mimetype, such as 'text/plain' or 'text/html' + * A mimetype, such as 'text/plain' or 'text/html'. * * @var string */ protected $mimeType; /** - * Creates this node + * Creates this node. * * The name of the node must be passed, as well as the contents of the * file. * - * @param string $name - * @param string $contents + * @param string $name + * @param string $contents * @param string|null $mimeType */ - function __construct($name, $contents, $mimeType = null) { - + public function __construct($name, $contents, $mimeType = null) + { $this->name = $name; $this->contents = $contents; $this->mimeType = $mimeType; - } /** @@ -61,23 +62,21 @@ class SimpleFile extends File { * * @return string */ - function getName() { - + public function getName() + { return $this->name; - } /** - * Returns the data + * Returns the data. * * This method may either return a string or a readable stream resource * * @return mixed */ - function get() { - + public function get() + { return $this->contents; - } /** @@ -85,37 +84,35 @@ class SimpleFile extends File { * * @return int */ - function getSize() { - + public function getSize() + { return strlen($this->contents); - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. * * Return null if the ETag can not effectively be determined + * * @return string */ - function getETag() { - - return '"' . sha1($this->contents) . '"'; - + public function getETag() + { + return '"'.sha1($this->contents).'"'; } /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream + * * @return string */ - function getContentType() { - + public function getContentType() + { return $this->mimeType; - } - } diff --git a/vendor/sabre/dav/lib/DAV/StringUtil.php b/vendor/sabre/dav/lib/DAV/StringUtil.php index 10eecebfd..13a4399e3 100644 --- a/vendor/sabre/dav/lib/DAV/StringUtil.php +++ b/vendor/sabre/dav/lib/DAV/StringUtil.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * String utility + * String utility. * * This class is mainly used to implement the 'text-match' filter, used by both * the CalDAV calendar-query REPORT, and CardDAV addressbook-query REPORT. @@ -13,79 +15,74 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class StringUtil { - +class StringUtil +{ /** - * Checks if a needle occurs in a haystack ;) + * Checks if a needle occurs in a haystack ;). * * @param string $haystack * @param string $needle * @param string $collation * @param string $matchType + * * @return bool */ - static function textMatch($haystack, $needle, $collation, $matchType = 'contains') { - + public static function textMatch($haystack, $needle, $collation, $matchType = 'contains') + { switch ($collation) { - - case 'i;ascii-casemap' : + case 'i;ascii-casemap': // default strtolower takes locale into consideration // we don't want this. $haystack = str_replace(range('a', 'z'), range('A', 'Z'), $haystack); $needle = str_replace(range('a', 'z'), range('A', 'Z'), $needle); break; - case 'i;octet' : + case 'i;octet': // Do nothing break; - case 'i;unicode-casemap' : + case 'i;unicode-casemap': $haystack = mb_strtoupper($haystack, 'UTF-8'); $needle = mb_strtoupper($needle, 'UTF-8'); break; - default : - throw new Exception\BadRequest('Collation type: ' . $collation . ' is not supported'); - + default: + throw new Exception\BadRequest('Collation type: '.$collation.' is not supported'); } switch ($matchType) { - - case 'contains' : - return strpos($haystack, $needle) !== false; - case 'equals' : + case 'contains': + return false !== strpos($haystack, $needle); + case 'equals': return $haystack === $needle; - case 'starts-with' : - return strpos($haystack, $needle) === 0; - case 'ends-with' : + case 'starts-with': + return 0 === strpos($haystack, $needle); + case 'ends-with': return strrpos($haystack, $needle) === strlen($haystack) - strlen($needle); - default : - throw new Exception\BadRequest('Match-type: ' . $matchType . ' is not supported'); - + default: + throw new Exception\BadRequest('Match-type: '.$matchType.' is not supported'); } - } /** * This method takes an input string, checks if it's not valid UTF-8 and * attempts to convert it to UTF-8 if it's not. * - * Note that currently this can only convert ISO-8559-1 to UTF-8 (latin-1), + * Note that currently this can only convert ISO-8859-1 to UTF-8 (latin-1), * anything else will likely fail. * * @param string $input + * * @return string */ - static function ensureUTF8($input) { - + public static function ensureUTF8($input) + { $encoding = mb_detect_encoding($input, ['UTF-8', 'ISO-8859-1'], true); - if ($encoding === 'ISO-8859-1') { + if ('ISO-8859-1' === $encoding) { return utf8_encode($input); } else { return $input; } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php b/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php index d3dc28a80..4ca69dc89 100644 --- a/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php +++ b/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Sync; use Sabre\DAV; @@ -15,8 +17,8 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ISyncCollection extends DAV\ICollection { - +interface ISyncCollection extends DAV\ICollection +{ /** * This method returns the current sync-token for this collection. * This can be any string. @@ -26,7 +28,7 @@ interface ISyncCollection extends DAV\ICollection { * * @return string|null */ - function getSyncToken(); + public function getSyncToken(); /** * The getChanges method returns all the changes that have happened, since @@ -79,10 +81,10 @@ interface ISyncCollection extends DAV\ICollection { * The limit is 'suggestive'. You are free to ignore it. * * @param string $syncToken - * @param int $syncLevel - * @param int $limit + * @param int $syncLevel + * @param int $limit + * * @return array */ - function getChanges($syncToken, $syncLevel, $limit = null); - + public function getChanges($syncToken, $syncLevel, $limit = null); } diff --git a/vendor/sabre/dav/lib/DAV/Sync/Plugin.php b/vendor/sabre/dav/lib/DAV/Sync/Plugin.php index 8e4b1aa64..f76827fe3 100644 --- a/vendor/sabre/dav/lib/DAV/Sync/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Sync/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Sync; use Sabre\DAV; @@ -18,10 +20,10 @@ use Sabre\HTTP\RequestInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * Reference to server object + * Reference to server object. * * @var DAV\Server */ @@ -37,10 +39,9 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'sync'; - } /** @@ -49,28 +50,25 @@ class Plugin extends DAV\ServerPlugin { * This is when the plugin registers it's hooks. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $server->xml->elementMap['{DAV:}sync-collection'] = 'Sabre\\DAV\\Xml\\Request\\SyncCollectionReport'; $self = $this; - $server->on('report', function($reportName, $dom, $uri) use ($self) { - - if ($reportName === '{DAV:}sync-collection') { + $server->on('report', function ($reportName, $dom, $uri) use ($self) { + if ('{DAV:}sync-collection' === $reportName) { $this->server->transactionType = 'report-sync-collection'; $self->syncCollection($uri, $dom); + return false; } - }); - $server->on('propFind', [$this, 'propFind']); + $server->on('propFind', [$this, 'propFind']); $server->on('validateTokens', [$this, 'validateTokens']); - } /** @@ -81,10 +79,11 @@ class Plugin extends DAV\ServerPlugin { * implement them * * @param string $uri + * * @return array */ - function getSupportedReportSet($uri) { - + public function getSupportedReportSet($uri) + { $node = $this->server->tree->getNodeForPath($uri); if ($node instanceof ISyncCollection && $node->getSyncToken()) { return [ @@ -93,19 +92,16 @@ class Plugin extends DAV\ServerPlugin { } return []; - } - /** * This method handles the {DAV:}sync-collection HTTP REPORT. * - * @param string $uri + * @param string $uri * @param SyncCollectionReport $report - * @return void */ - function syncCollection($uri, SyncCollectionReport $report) { - + public function syncCollection($uri, SyncCollectionReport $report) + { // Getting the data $node = $this->server->tree->getNodeForPath($uri); if (!$node instanceof ISyncCollection) { @@ -119,19 +115,16 @@ class Plugin extends DAV\ServerPlugin { $syncToken = $report->syncToken; if (!is_null($syncToken)) { // Sync-token must start with our prefix - if (substr($syncToken, 0, strlen(self::SYNCTOKEN_PREFIX)) !== self::SYNCTOKEN_PREFIX) { + if (self::SYNCTOKEN_PREFIX !== substr($syncToken, 0, strlen(self::SYNCTOKEN_PREFIX))) { throw new DAV\Exception\InvalidSyncToken('Invalid or unknown sync token'); } $syncToken = substr($syncToken, strlen(self::SYNCTOKEN_PREFIX)); - } $changeInfo = $node->getChanges($syncToken, $report->syncLevel, $report->limit); if (is_null($changeInfo)) { - throw new DAV\Exception\InvalidSyncToken('Invalid or unknown sync token'); - } // Encoding the response @@ -143,7 +136,6 @@ class Plugin extends DAV\ServerPlugin { $changeInfo['deleted'], $report->properties ); - } /** @@ -151,50 +143,41 @@ class Plugin extends DAV\ServerPlugin { * * @param string $syncToken * @param string $collectionUrl - * @param array $added - * @param array $modified - * @param array $deleted - * @param array $properties - * @return void + * @param array $added + * @param array $modified + * @param array $deleted + * @param array $properties */ - protected function sendSyncCollectionResponse($syncToken, $collectionUrl, array $added, array $modified, array $deleted, array $properties) { - - + protected function sendSyncCollectionResponse($syncToken, $collectionUrl, array $added, array $modified, array $deleted, array $properties) + { $fullPaths = []; // Pre-fetching children, if this is possible. foreach (array_merge($added, $modified) as $item) { - $fullPath = $collectionUrl . '/' . $item; + $fullPath = $collectionUrl.'/'.$item; $fullPaths[] = $fullPath; } $responses = []; foreach ($this->server->getPropertiesForMultiplePaths($fullPaths, $properties) as $fullPath => $props) { - // The 'Property_Response' class is responsible for generating a // single {DAV:}response xml element. $responses[] = new DAV\Xml\Element\Response($fullPath, $props); - } - - // Deleted items also show up as 'responses'. They have no properties, // and a single {DAV:}status element set as 'HTTP/1.1 404 Not Found'. foreach ($deleted as $item) { - - $fullPath = $collectionUrl . '/' . $item; + $fullPath = $collectionUrl.'/'.$item; $responses[] = new DAV\Xml\Element\Response($fullPath, [], 404); - } - $multiStatus = new DAV\Xml\Response\MultiStatus($responses, self::SYNCTOKEN_PREFIX . $syncToken); + $multiStatus = new DAV\Xml\Response\MultiStatus($responses, self::SYNCTOKEN_PREFIX.$syncToken); $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setBody( $this->server->xml->write('{DAV:}multistatus', $multiStatus, $this->server->getBaseUri()) ); - } /** @@ -202,18 +185,17 @@ class Plugin extends DAV\ServerPlugin { * We intercept this to see if we must return a {DAV:}sync-token. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFind(DAV\PropFind $propFind, DAV\INode $node) { - - $propFind->handle('{DAV:}sync-token', function() use ($node) { + public function propFind(DAV\PropFind $propFind, DAV\INode $node) + { + $propFind->handle('{DAV:}sync-token', function () use ($node) { if (!$node instanceof ISyncCollection || !$token = $node->getSyncToken()) { return; } - return self::SYNCTOKEN_PREFIX . $token; - }); + return self::SYNCTOKEN_PREFIX.$token; + }); } /** @@ -223,17 +205,14 @@ class Plugin extends DAV\ServerPlugin { * in the If: header, and check if they are valid. * * @param RequestInterface $request - * @param array $conditions - * @return void + * @param array $conditions */ - function validateTokens(RequestInterface $request, &$conditions) { - + public function validateTokens(RequestInterface $request, &$conditions) + { foreach ($conditions as $kk => $condition) { - foreach ($condition['tokens'] as $ii => $token) { - // Sync-tokens must always start with our designated prefix. - if (substr($token['token'], 0, strlen(self::SYNCTOKEN_PREFIX)) !== self::SYNCTOKEN_PREFIX) { + if (self::SYNCTOKEN_PREFIX !== substr($token['token'], 0, strlen(self::SYNCTOKEN_PREFIX))) { continue; } @@ -246,11 +225,8 @@ class Plugin extends DAV\ServerPlugin { ) { $conditions[$kk]['tokens'][$ii]['validToken'] = true; } - } - } - } /** @@ -264,14 +240,12 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds support for WebDAV Collection Sync (rfc6578)', - 'link' => 'http://sabre.io/dav/sync/', + 'link' => 'http://sabre.io/dav/sync/', ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/TemporaryFileFilterPlugin.php b/vendor/sabre/dav/lib/DAV/TemporaryFileFilterPlugin.php index 7b453d105..6cf772f44 100644 --- a/vendor/sabre/dav/lib/DAV/TemporaryFileFilterPlugin.php +++ b/vendor/sabre/dav/lib/DAV/TemporaryFileFilterPlugin.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * Temporary File Filter Plugin + * Temporary File Filter Plugin. * * The purpose of this filter is to intercept some of the garbage files * operation systems and applications tend to generate when mounting @@ -30,8 +32,8 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class TemporaryFileFilterPlugin extends ServerPlugin { - +class TemporaryFileFilterPlugin extends ServerPlugin +{ /** * This is the list of patterns we intercept. * If new patterns are added, they must be valid patterns for preg_match. @@ -49,7 +51,7 @@ class TemporaryFileFilterPlugin extends ServerPlugin { ]; /** - * A reference to the main Server class + * A reference to the main Server class. * * @var \Sabre\DAV\Server */ @@ -72,58 +74,61 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * * @param string|null $dataDir */ - function __construct($dataDir = null) { - - if (!$dataDir) $dataDir = ini_get('session.save_path') . '/sabredav/'; - if (!is_dir($dataDir)) mkdir($dataDir); + public function __construct($dataDir = null) + { + if (!$dataDir) { + $dataDir = ini_get('session.save_path').'/sabredav/'; + } + if (!is_dir($dataDir)) { + mkdir($dataDir); + } $this->dataDir = $dataDir; - } /** - * Initialize the plugin + * Initialize the plugin. * * This is called automatically be the Server class after this plugin is * added with Sabre\DAV\Server::addPlugin() * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; - $server->on('beforeMethod', [$this, 'beforeMethod']); + $server->on('beforeMethod:*', [$this, 'beforeMethod']); $server->on('beforeCreateFile', [$this, 'beforeCreateFile']); - } /** - * This method is called before any HTTP method handler + * This method is called before any HTTP method handler. * * This method intercepts any GET, DELETE, PUT and PROPFIND calls to * filenames that are known to match the 'temporary file' regex. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function beforeMethod(RequestInterface $request, ResponseInterface $response) { - - if (!$tempLocation = $this->isTempFile($request->getPath())) + public function beforeMethod(RequestInterface $request, ResponseInterface $response) + { + if (!$tempLocation = $this->isTempFile($request->getPath())) { return; + } switch ($request->getMethod()) { - case 'GET' : + case 'GET': return $this->httpGet($request, $response, $tempLocation); - case 'PUT' : + case 'PUT': return $this->httpPut($request, $response, $tempLocation); - case 'PROPFIND' : + case 'PROPFIND': return $this->httpPropfind($request, $response, $tempLocation); - case 'DELETE' : + case 'DELETE': return $this->httpDelete($request, $response, $tempLocation); } - return; + return; } /** @@ -132,24 +137,25 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * This is used to deal with HTTP LOCK requests which create a new * file. * - * @param string $uri - * @param resource $data + * @param string $uri + * @param resource $data * @param ICollection $parent - * @param bool $modified Should be set to true, if this event handler - * changed &$data. + * @param bool $modified should be set to true, if this event handler + * changed &$data + * * @return bool */ - function beforeCreateFile($uri, $data, ICollection $parent, $modified) { - + public function beforeCreateFile($uri, $data, ICollection $parent, $modified) + { if ($tempPath = $this->isTempFile($uri)) { - $hR = $this->server->httpResponse; $hR->setHeader('X-Sabre-Temp', 'true'); file_put_contents($tempPath, $data); + return false; } - return; + return; } /** @@ -158,71 +164,76 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * temporary file storage. * * @param string $path + * * @return bool|string */ - protected function isTempFile($path) { - + protected function isTempFile($path) + { // We're only interested in the basename. - list(, $tempPath) = URLUtil::splitPath($path); + list(, $tempPath) = Uri\split($path); - foreach ($this->temporaryFilePatterns as $tempFile) { + if (null === $tempPath) { + return false; + } + foreach ($this->temporaryFilePatterns as $tempFile) { if (preg_match($tempFile, $tempPath)) { - return $this->getDataDir() . '/sabredav_' . md5($path) . '.tempfile'; + return $this->getDataDir().'/sabredav_'.md5($path).'.tempfile'; } - } return false; - } - /** * This method handles the GET method for temporary files. * If the file doesn't exist, it will return false which will kick in * the regular system for the GET method. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $hR - * @param string $tempLocation + * @param string $tempLocation + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $hR, $tempLocation) { - - if (!file_exists($tempLocation)) return; + public function httpGet(RequestInterface $request, ResponseInterface $hR, $tempLocation) + { + if (!file_exists($tempLocation)) { + return; + } $hR->setHeader('Content-Type', 'application/octet-stream'); $hR->setHeader('Content-Length', filesize($tempLocation)); $hR->setHeader('X-Sabre-Temp', 'true'); $hR->setStatus(200); $hR->setBody(fopen($tempLocation, 'r')); - return false; + return false; } /** * This method handles the PUT method. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $hR - * @param string $tempLocation + * @param string $tempLocation + * * @return bool */ - function httpPut(RequestInterface $request, ResponseInterface $hR, $tempLocation) { - + public function httpPut(RequestInterface $request, ResponseInterface $hR, $tempLocation) + { $hR->setHeader('X-Sabre-Temp', 'true'); $newFile = !file_exists($tempLocation); if (!$newFile && ($this->server->httpRequest->getHeader('If-None-Match'))) { - throw new Exception\PreconditionFailed('The resource already exists, and an If-None-Match header was supplied'); + throw new Exception\PreconditionFailed('The resource already exists, and an If-None-Match header was supplied'); } file_put_contents($tempLocation, $this->server->httpRequest->getBody()); $hR->setStatus($newFile ? 201 : 200); - return false; + return false; } /** @@ -231,20 +242,23 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * If the file didn't exist, it will return false, which will make the * standard HTTP DELETE handler kick in. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $hR - * @param string $tempLocation + * @param string $tempLocation + * * @return bool */ - function httpDelete(RequestInterface $request, ResponseInterface $hR, $tempLocation) { - - if (!file_exists($tempLocation)) return; + public function httpDelete(RequestInterface $request, ResponseInterface $hR, $tempLocation) + { + if (!file_exists($tempLocation)) { + return; + } unlink($tempLocation); $hR->setHeader('X-Sabre-Temp', 'true'); $hR->setStatus(204); - return false; + return false; } /** @@ -254,14 +268,17 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * for which properties were requested, and just sends back a default * set of properties. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $hR - * @param string $tempLocation + * @param string $tempLocation + * * @return bool */ - function httpPropfind(RequestInterface $request, ResponseInterface $hR, $tempLocation) { - - if (!file_exists($tempLocation)) return; + public function httpPropfind(RequestInterface $request, ResponseInterface $hR, $tempLocation) + { + if (!file_exists($tempLocation)) { + return; + } $hR->setHeader('X-Sabre-Temp', 'true'); $hR->setStatus(207); @@ -269,22 +286,20 @@ class TemporaryFileFilterPlugin extends ServerPlugin { $properties = [ 'href' => $request->getPath(), - 200 => [ - '{DAV:}getlastmodified' => new Xml\Property\GetLastModified(filemtime($tempLocation)), - '{DAV:}getcontentlength' => filesize($tempLocation), - '{DAV:}resourcetype' => new Xml\Property\ResourceType(null), - '{' . Server::NS_SABREDAV . '}tempFile' => true, - + 200 => [ + '{DAV:}getlastmodified' => new Xml\Property\GetLastModified(filemtime($tempLocation)), + '{DAV:}getcontentlength' => filesize($tempLocation), + '{DAV:}resourcetype' => new Xml\Property\ResourceType(null), + '{'.Server::NS_SABREDAV.'}tempFile' => true, ], ]; $data = $this->server->generateMultiStatus([$properties]); $hR->setBody($data); - return false; + return false; } - /** * This method returns the directory where the temporary files should be stored. * diff --git a/vendor/sabre/dav/lib/DAV/Tree.php b/vendor/sabre/dav/lib/DAV/Tree.php index 7c04f0915..7a5a25f87 100644 --- a/vendor/sabre/dav/lib/DAV/Tree.php +++ b/vendor/sabre/dav/lib/DAV/Tree.php @@ -1,8 +1,10 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** * The tree object is responsible for basic tree operations. @@ -14,10 +16,10 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Tree { - +class Tree +{ /** - * The root node + * The root node. * * @var ICollection */ @@ -32,28 +34,30 @@ class Tree { protected $cache = []; /** - * Creates the object + * Creates the object. * * This method expects the rootObject to be passed as a parameter * * @param ICollection $rootNode */ - function __construct(ICollection $rootNode) { - + public function __construct(ICollection $rootNode) + { $this->rootNode = $rootNode; - } /** - * Returns the INode object for the requested path + * Returns the INode object for the requested path. * * @param string $path + * * @return INode */ - function getNodeForPath($path) { - + public function getNodeForPath($path) + { $path = trim($path, '/'); - if (isset($this->cache[$path])) return $this->cache[$path]; + if (isset($this->cache[$path])) { + return $this->cache[$path]; + } // Is it the root node? if (!strlen($path)) { @@ -61,25 +65,24 @@ class Tree { } // Attempting to fetch its parent - list($parentName, $baseName) = URLUtil::splitPath($path); + list($parentName, $baseName) = Uri\split($path); // If there was no parent, we must simply ask it from the root node. - if ($parentName === "") { + if ('' === $parentName) { $node = $this->rootNode->getChild($baseName); } else { // Otherwise, we recursively grab the parent and ask him/her. $parent = $this->getNodeForPath($parentName); - if (!($parent instanceof ICollection)) - throw new Exception\NotFound('Could not find node at path: ' . $path); - + if (!($parent instanceof ICollection)) { + throw new Exception\NotFound('Could not find node at path: '.$path); + } $node = $parent->getChild($baseName); - } $this->cache[$path] = $node; - return $node; + return $node; } /** @@ -89,61 +92,64 @@ class Tree { * it cheaper. * * @param string $path + * * @return bool */ - function nodeExists($path) { - + public function nodeExists($path) + { try { - // The root always exists - if ($path === '') return true; + if ('' === $path) { + return true; + } - list($parent, $base) = URLUtil::splitPath($path); + list($parent, $base) = Uri\split($path); $parentNode = $this->getNodeForPath($parent); - if (!$parentNode instanceof ICollection) return false; - return $parentNode->childExists($base); + if (!$parentNode instanceof ICollection) { + return false; + } + return $parentNode->childExists($base); } catch (Exception\NotFound $e) { - return false; - } - } /** - * Copies a file from path to another + * Copies a file from path to another. * - * @param string $sourcePath The source location + * @param string $sourcePath The source location * @param string $destinationPath The full destination path - * @return void */ - function copy($sourcePath, $destinationPath) { - + public function copy($sourcePath, $destinationPath) + { $sourceNode = $this->getNodeForPath($sourcePath); // grab the dirname and basename components - list($destinationDir, $destinationName) = URLUtil::splitPath($destinationPath); + list($destinationDir, $destinationName) = Uri\split($destinationPath); $destinationParent = $this->getNodeForPath($destinationDir); - $this->copyNode($sourceNode, $destinationParent, $destinationName); + // Check if the target can handle the copy itself. If not, we do it ourselves. + if (!$destinationParent instanceof ICopyTarget || !$destinationParent->copyInto($destinationName, $sourcePath, $sourceNode)) { + $this->copyNode($sourceNode, $destinationParent, $destinationName); + } $this->markDirty($destinationDir); - } /** - * Moves a file from one location to another + * Moves a file from one location to another. * - * @param string $sourcePath The path to the file which should be moved + * @param string $sourcePath The path to the file which should be moved * @param string $destinationPath The full destination path, so not just the destination parent node + * * @return int */ - function move($sourcePath, $destinationPath) { - - list($sourceDir) = URLUtil::splitPath($sourcePath); - list($destinationDir, $destinationName) = URLUtil::splitPath($destinationPath); + public function move($sourcePath, $destinationPath) + { + list($sourceDir) = Uri\split($sourcePath); + list($destinationDir, $destinationName) = Uri\split($destinationPath); if ($sourceDir === $destinationDir) { // If this is a 'local' rename, it means we can just trigger a rename. @@ -164,49 +170,45 @@ class Tree { } $this->markDirty($sourceDir); $this->markDirty($destinationDir); - } /** - * Deletes a node from the tree + * Deletes a node from the tree. * * @param string $path - * @return void */ - function delete($path) { - + public function delete($path) + { $node = $this->getNodeForPath($path); $node->delete(); - list($parent) = URLUtil::splitPath($path); + list($parent) = Uri\split($path); $this->markDirty($parent); - } /** * Returns a list of childnodes for a given path. * * @param string $path - * @return array + * + * @return \Traversable */ - function getChildren($path) { - + public function getChildren($path) + { $node = $this->getNodeForPath($path); - $children = $node->getChildren(); $basePath = trim($path, '/'); - if ($basePath !== '') $basePath .= '/'; - - foreach ($children as $child) { - - $this->cache[$basePath . $child->getName()] = $child; - + if ('' !== $basePath) { + $basePath .= '/'; } - return $children; + foreach ($node->getChildren() as $child) { + $this->cache[$basePath.$child->getName()] = $child; + yield $child; + } } /** - * This method is called with every tree update + * This method is called with every tree update. * * Examples of tree updates are: * * node deletions @@ -221,19 +223,17 @@ class Tree { * If a path is passed, it is assumed that the entire subtree is dirty * * @param string $path - * @return void */ - function markDirty($path) { - + public function markDirty($path) + { // We don't care enough about sub-paths // flushing the entire cache $path = trim($path, '/'); foreach ($this->cache as $nodePath => $node) { - if ($path === '' || $nodePath == $path || strpos($nodePath, $path . '/') === 0) + if ('' === $path || $nodePath == $path || 0 === strpos($nodePath, $path.'/')) { unset($this->cache[$nodePath]); - + } } - } /** @@ -247,15 +247,16 @@ class Tree { * This method returns an array with the found nodes. It's keys are the * original paths. The result may be out of order. * - * @param array $paths List of nodes that must be fetched. + * @param array $paths list of nodes that must be fetched + * * @return array */ - function getMultipleNodes($paths) { - + public function getMultipleNodes($paths) + { // Finding common parents $parents = []; foreach ($paths as $path) { - list($parent, $node) = URLUtil::splitPath($path); + list($parent, $node) = Uri\split($path); if (!isset($parents[$parent])) { $parents[$parent] = [$node]; } else { @@ -266,44 +267,38 @@ class Tree { $result = []; foreach ($parents as $parent => $children) { - $parentNode = $this->getNodeForPath($parent); if ($parentNode instanceof IMultiGet) { foreach ($parentNode->getMultipleChildren($children) as $childNode) { - $fullPath = $parent . '/' . $childNode->getName(); + $fullPath = $parent.'/'.$childNode->getName(); $result[$fullPath] = $childNode; $this->cache[$fullPath] = $childNode; } } else { foreach ($children as $child) { - $fullPath = $parent . '/' . $child; + $fullPath = $parent.'/'.$child; $result[$fullPath] = $this->getNodeForPath($fullPath); } } - } return $result; - } - /** - * copyNode + * copyNode. * - * @param INode $source + * @param INode $source * @param ICollection $destinationParent - * @param string $destinationName - * @return void + * @param string $destinationName */ - protected function copyNode(INode $source, ICollection $destinationParent, $destinationName = null) { - - if ((string)$destinationName === '') { + protected function copyNode(INode $source, ICollection $destinationParent, $destinationName = null) + { + if ('' === (string) $destinationName) { $destinationName = $source->getName(); } if ($source instanceof IFile) { - $data = $source->get(); // If the body was a string, we need to convert it to a stream @@ -315,28 +310,19 @@ class Tree { } $destinationParent->createFile($destinationName, $data); $destination = $destinationParent->getChild($destinationName); - } elseif ($source instanceof ICollection) { - $destinationParent->createDirectory($destinationName); $destination = $destinationParent->getChild($destinationName); foreach ($source->getChildren() as $child) { - $this->copyNode($child, $destination); - } - } if ($source instanceof IProperties && $destination instanceof IProperties) { - $props = $source->getProperties([]); $propPatch = new PropPatch($props); $destination->propPatch($propPatch); $propPatch->commit(); - } - } - } diff --git a/vendor/sabre/dav/lib/DAV/UUIDUtil.php b/vendor/sabre/dav/lib/DAV/UUIDUtil.php index 177adafd3..8c36e1b0b 100644 --- a/vendor/sabre/dav/lib/DAV/UUIDUtil.php +++ b/vendor/sabre/dav/lib/DAV/UUIDUtil.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * UUID Utility + * UUID Utility. * * This class has static methods to generate and validate UUID's. * UUIDs are used a decent amount within various *DAV standards, so it made @@ -13,18 +15,19 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class UUIDUtil { - +class UUIDUtil +{ /** - * Returns a pseudo-random v4 UUID + * Returns a pseudo-random v4 UUID. * * This function is based on a comment by Andrew Moore on php.net * * @see http://www.php.net/manual/en/function.uniqid.php#94959 + * * @return string */ - static function getUUID() { - + public static function getUUID() + { return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low" mt_rand(0, 0xffff), mt_rand(0, 0xffff), @@ -50,15 +53,14 @@ class UUIDUtil { * Checks if a string is a valid UUID. * * @param string $uuid + * * @return bool */ - static function validateUUID($uuid) { - - return preg_match( + public static function validateUUID($uuid) + { + return 0 !== preg_match( '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i', $uuid - ) !== 0; - + ); } - } diff --git a/vendor/sabre/dav/lib/DAV/Version.php b/vendor/sabre/dav/lib/DAV/Version.php index 89918e5bc..c00255881 100644 --- a/vendor/sabre/dav/lib/DAV/Version.php +++ b/vendor/sabre/dav/lib/DAV/Version.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -9,11 +11,10 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Version { - +class Version +{ /** - * Full version number + * Full version number. */ - const VERSION = '3.2.2'; - + const VERSION = '4.0.2'; } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Prop.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Prop.php index 71ef03e3f..52a04cf08 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Element/Prop.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Prop.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Element; use Sabre\DAV\Xml\Property\Complex; @@ -17,8 +19,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Prop implements XmlDeserializable { - +class Prop implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -38,13 +40,15 @@ class Prop implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { // If there's no children, we don't do anything. if ($reader->isEmptyElement) { $reader->next(); + return []; } @@ -52,22 +56,17 @@ class Prop implements XmlDeserializable { $reader->read(); do { - - if ($reader->nodeType === Reader::ELEMENT) { - + if (Reader::ELEMENT === $reader->nodeType) { $clark = $reader->getClark(); $values[$clark] = self::parseCurrentElement($reader)['value']; - } else { $reader->read(); } - - } while ($reader->nodeType !== Reader::END_ELEMENT); + } while (Reader::END_ELEMENT !== $reader->nodeType); $reader->read(); return $values; - } /** @@ -81,10 +80,11 @@ class Prop implements XmlDeserializable { * * value - The parsed value. * * @param Reader $reader + * * @return array */ - private static function parseCurrentElement(Reader $reader) { - + private static function parseCurrentElement(Reader $reader) + { $name = $reader->getClark(); if (array_key_exists($name, $reader->elementMap)) { @@ -95,22 +95,20 @@ class Prop implements XmlDeserializable { $value = call_user_func($deserializer, $reader); } else { $type = gettype($deserializer); - if ($type === 'string') { - $type .= ' (' . $deserializer . ')'; - } elseif ($type === 'object') { - $type .= ' (' . get_class($deserializer) . ')'; + if ('string' === $type) { + $type .= ' ('.$deserializer.')'; + } elseif ('object' === $type) { + $type .= ' ('.get_class($deserializer).')'; } - throw new \LogicException('Could not use this type as a deserializer: ' . $type); + throw new \LogicException('Could not use this type as a deserializer: '.$type); } } else { $value = Complex::xmlDeserialize($reader); } return [ - 'name' => $name, + 'name' => $name, 'value' => $value, ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php index ce97ae943..a11091809 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Element; use Sabre\Xml\Element; @@ -7,7 +9,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * WebDAV {DAV:}response parser + * WebDAV {DAV:}response parser. * * This class parses the {DAV:}response element, as defined in: * @@ -17,17 +19,17 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class Response implements Element { - +class Response implements Element +{ /** - * Url for the response + * Url for the response. * * @var string */ protected $href; /** - * Propertylist, ordered by HTTP status code + * Propertylist, ordered by HTTP status code. * * @var array */ @@ -57,51 +59,46 @@ class Response implements Element { * deleted. * * @param string $href - * @param array $responseProperties + * @param array $responseProperties * @param string $httpStatus */ - function __construct($href, array $responseProperties, $httpStatus = null) { - + public function __construct($href, array $responseProperties, $httpStatus = null) + { $this->href = $href; $this->responseProperties = $responseProperties; $this->httpStatus = $httpStatus; - } /** - * Returns the url + * Returns the url. * * @return string */ - function getHref() { - + public function getHref() + { return $this->href; - } /** - * Returns the httpStatus value + * Returns the httpStatus value. * * @return string */ - function getHttpStatus() { - + public function getHttpStatus() + { return $this->httpStatus; - } /** - * Returns the property list + * Returns the property list. * * @return array */ - function getResponseProperties() { - + public function getResponseProperties() + { return $this->responseProperties; - } - /** * The serialize method is called during xml writing. * @@ -115,19 +112,17 @@ class Response implements Element { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { if ($status = $this->getHTTPStatus()) { - $writer->writeElement('{DAV:}status', 'HTTP/1.1 ' . $status . ' ' . \Sabre\HTTP\Response::$statusCodes[$status]); + $writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$status.' '.\Sabre\HTTP\Response::$statusCodes[$status]); } - $writer->writeElement('{DAV:}href', $writer->contextUri . \Sabre\HTTP\encodePath($this->getHref())); + $writer->writeElement('{DAV:}href', $writer->contextUri.\Sabre\HTTP\encodePath($this->getHref())); $empty = true; foreach ($this->getResponseProperties() as $status => $properties) { - // Skipping empty lists if (!$properties || (!ctype_digit($status) && !is_int($status))) { continue; @@ -135,9 +130,8 @@ class Response implements Element { $empty = false; $writer->startElement('{DAV:}propstat'); $writer->writeElement('{DAV:}prop', $properties); - $writer->writeElement('{DAV:}status', 'HTTP/1.1 ' . $status . ' ' . \Sabre\HTTP\Response::$statusCodes[$status]); + $writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$status.' '.\Sabre\HTTP\Response::$statusCodes[$status]); $writer->endElement(); // {DAV:}propstat - } if ($empty) { /* @@ -149,12 +143,10 @@ class Response implements Element { * no properties. */ $writer->writeElement('{DAV:}propstat', [ - '{DAV:}prop' => [], - '{DAV:}status' => 'HTTP/1.1 418 ' . \Sabre\HTTP\Response::$statusCodes[418] + '{DAV:}prop' => [], + '{DAV:}status' => 'HTTP/1.1 418 '.\Sabre\HTTP\Response::$statusCodes[418], ]); - } - } /** @@ -176,10 +168,11 @@ class Response implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $reader->pushContext(); $reader->elementMap['{DAV:}propstat'] = 'Sabre\\Xml\\Element\\KeyValue'; @@ -192,16 +185,16 @@ class Response implements Element { // called. But we don't want this, because a singular element without // child-elements implies 'no value' in {DAV:}prop, so we want to skip // deserializers and just set null for those. - $reader->elementMap['{DAV:}prop'] = function(Reader $reader) { - + $reader->elementMap['{DAV:}prop'] = function (Reader $reader) { if ($reader->isEmptyElement) { $reader->next(); + return []; } $values = []; $reader->read(); do { - if ($reader->nodeType === Reader::ELEMENT) { + if (Reader::ELEMENT === $reader->nodeType) { $clark = $reader->getClark(); if ($reader->isEmptyElement) { @@ -213,10 +206,10 @@ class Response implements Element { } else { $reader->read(); } - } while ($reader->nodeType !== Reader::END_ELEMENT); + } while (Reader::END_ELEMENT !== $reader->nodeType); $reader->read(); - return $values; + return $values; }; $elems = $reader->parseInnerTree(); $reader->popContext(); @@ -226,28 +219,24 @@ class Response implements Element { $statusCode = null; foreach ($elems as $elem) { - switch ($elem['name']) { - - case '{DAV:}href' : + case '{DAV:}href': $href = $elem['value']; break; - case '{DAV:}propstat' : + case '{DAV:}propstat': $status = $elem['value']['{DAV:}status']; - list(, $status, ) = explode(' ', $status, 3); + list(, $status) = explode(' ', $status, 3); $properties = isset($elem['value']['{DAV:}prop']) ? $elem['value']['{DAV:}prop'] : []; - if ($properties) $propertyLists[$status] = $properties; + if ($properties) { + $propertyLists[$status] = $properties; + } break; - case '{DAV:}status' : - list(, $statusCode, ) = explode(' ', $elem['value'], 3); + case '{DAV:}status': + list(, $statusCode) = explode(' ', $elem['value'], 3); break; - } - } return new self($href, $propertyLists, $statusCode); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php index e187bf11c..e0db3bf37 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Element; use Sabre\DAV\Exception\BadRequest; @@ -18,8 +20,8 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Sharee implements Element { - +class Sharee implements Element +{ /** * A URL. Usually a mailto: address, could also be a principal url. * This uniquely identifies the sharee. @@ -79,24 +81,21 @@ class Sharee implements Element { public $inviteStatus; /** - * Creates the object + * Creates the object. * * $properties will be used to populate all internal properties. * * @param array $properties */ - function __construct(array $properties = []) { - + public function __construct(array $properties = []) + { foreach ($properties as $k => $v) { - if (property_exists($this, $k)) { $this->$k = $v; } else { - throw new \InvalidArgumentException('Unknown property: ' . $k); + throw new \InvalidArgumentException('Unknown property: '.$k); } - } - } /** @@ -116,31 +115,28 @@ class Sharee implements Element { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - - + public function xmlSerialize(Writer $writer) + { $writer->write([ new Href($this->href), - '{DAV:}prop' => $this->properties, + '{DAV:}prop' => $this->properties, '{DAV:}share-access' => new ShareAccess($this->access), ]); switch ($this->inviteStatus) { - case Plugin::INVITE_NORESPONSE : + case Plugin::INVITE_NORESPONSE: $writer->writeElement('{DAV:}invite-noresponse'); break; - case Plugin::INVITE_ACCEPTED : + case Plugin::INVITE_ACCEPTED: $writer->writeElement('{DAV:}invite-accepted'); break; - case Plugin::INVITE_DECLINED : + case Plugin::INVITE_DECLINED: $writer->writeElement('{DAV:}invite-declined'); break; - case Plugin::INVITE_INVALID : + case Plugin::INVITE_INVALID: $writer->writeElement('{DAV:}invite-invalid'); break; } - } /** @@ -162,10 +158,11 @@ class Sharee implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { // Temporarily override configuration $reader->pushContext(); $reader->elementMap['{DAV:}share-access'] = 'Sabre\DAV\Xml\Property\ShareAccess'; @@ -192,8 +189,7 @@ class Sharee implements Element { throw new BadRequest('Every {DAV:}sharee must have a {DAV:}share-access child element'); } $sharee->access = $elems['share-access']->getValue(); - return $sharee; + return $sharee; } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php index 258806e4a..990302054 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\Xml\Element\XmlFragment; @@ -15,8 +17,8 @@ use Sabre\Xml\Reader; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Complex extends XmlFragment { - +class Complex extends XmlFragment +{ /** * The deserialize method is called during xml parsing. * @@ -36,15 +38,17 @@ class Complex extends XmlFragment { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $xml = $reader->readInnerXml(); - if ($reader->nodeType === Reader::ELEMENT && $reader->isEmptyElement) { + if (Reader::ELEMENT === $reader->nodeType && $reader->isEmptyElement) { // Easy! $reader->next(); + return null; } // Now we have a copy of the inner xml, we need to traverse it to get @@ -56,21 +60,19 @@ class Complex extends XmlFragment { $text = ''; while (true) { - switch ($reader->nodeType) { - case Reader::ELEMENT : + case Reader::ELEMENT: $nonText = true; $reader->next(); continue 2; - case Reader::TEXT : - case Reader::CDATA : + case Reader::TEXT: + case Reader::CDATA: $text .= $reader->value; break; - case Reader::END_ELEMENT : + case Reader::END_ELEMENT: break 2; } $reader->read(); - } // Make sure we advance the cursor one step further. @@ -78,12 +80,10 @@ class Complex extends XmlFragment { if ($nonText) { $new = new self($xml); + return $new; } else { return $text; } - } - - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php b/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php index 101a0f0c9..05a00c5e5 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use DateTime; @@ -19,42 +21,40 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class GetLastModified implements Element { - +class GetLastModified implements Element +{ /** - * time + * time. * * @var DateTime */ public $time; /** - * Constructor + * Constructor. * * @param int|DateTime $time */ - function __construct($time) { - + public function __construct($time) + { if ($time instanceof DateTime) { $this->time = clone $time; } else { - $this->time = new DateTime('@' . $time); + $this->time = new DateTime('@'.$time); } // Setting timezone to UTC $this->time->setTimezone(new DateTimeZone('UTC')); - } /** - * getTime + * getTime. * * @return DateTime */ - function getTime() { - + public function getTime() + { return $this->time; - } /** @@ -70,14 +70,12 @@ class GetLastModified implements Element { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { $writer->write( - HTTP\Util::toHTTPDate($this->time) + HTTP\toDate($this->time) ); - } /** @@ -99,12 +97,12 @@ class GetLastModified implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { return new self(new DateTime($reader->parseInnerTree())); - } } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php index 6c4f11b87..c479c1602 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -10,7 +12,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * Href property + * Href property. * * This class represents any WebDAV property that contains a {DAV:}href * element, and there are many. @@ -23,17 +25,17 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class Href implements Element, HtmlOutput { - +class Href implements Element, HtmlOutput +{ /** - * List of uris + * List of uris. * * @var array */ protected $hrefs; /** - * Constructor + * Constructor. * * You must either pass a string for a single href, or an array of hrefs. * @@ -42,35 +44,32 @@ class Href implements Element, HtmlOutput { * * @param string|string[] $hrefs */ - function __construct($hrefs) { - + public function __construct($hrefs) + { if (is_string($hrefs)) { $hrefs = [$hrefs]; } $this->hrefs = $hrefs; - } /** * Returns the first Href. * - * @return string + * @return string|null */ - function getHref() { - - return $this->hrefs[0]; - + public function getHref() + { + return $this->hrefs[0] ?? null; } /** - * Returns the hrefs as an array + * Returns the hrefs as an array. * * @return array */ - function getHrefs() { - + public function getHrefs() + { return $this->hrefs; - } /** @@ -90,15 +89,13 @@ class Href implements Element, HtmlOutput { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->getHrefs() as $href) { $href = Uri\resolve($writer->contextUri, $href); $writer->writeElement('{DAV:}href', $href); } - } /** @@ -113,16 +110,17 @@ class Href implements Element, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { $links = []; foreach ($this->getHrefs() as $href) { $links[] = $html->link($href); } - return implode('<br />', $links); + return implode('<br />', $links); } /** @@ -144,22 +142,21 @@ class Href implements Element, HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $hrefs = []; - foreach ((array)$reader->parseInnerTree() as $elem) { - if ($elem['name'] !== '{DAV:}href') + foreach ((array) $reader->parseInnerTree() as $elem) { + if ('{DAV:}href' !== $elem['name']) { continue; + } $hrefs[] = $elem['value']; - } if ($hrefs) { - return new self($hrefs, false); + return new self($hrefs); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php index 6adad3650..b5e2dae46 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Xml\Element\Sharee; @@ -20,10 +22,10 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Invite implements XmlSerializable { - +class Invite implements XmlSerializable +{ /** - * A list of sharees + * A list of sharees. * * @var Sharee[] */ @@ -34,10 +36,9 @@ class Invite implements XmlSerializable { * * @param Sharee[] $sharees */ - function __construct(array $sharees) { - + public function __construct(array $sharees) + { $this->sharees = $sharees; - } /** @@ -57,14 +58,11 @@ class Invite implements XmlSerializable { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->sharees as $sharee) { $writer->writeElement('{DAV:}sharee', $sharee); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php b/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php index 00d2fa708..cb794974f 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\HTTP; /** - * LocalHref property + * LocalHref property. * * Like the Href property, this element represents {DAV:}href. The difference * is that this is used strictly for paths on the server. The LocalHref property @@ -22,10 +24,10 @@ use Sabre\HTTP; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class LocalHref extends Href { - +class LocalHref extends Href +{ /** - * Constructor + * Constructor. * * You must either pass a string for a single href, or an array of hrefs. * @@ -34,15 +36,13 @@ class LocalHref extends Href { * * @param string|string[] $hrefs */ - function __construct($hrefs) { - + public function __construct($hrefs) + { parent::__construct(array_map( - function($href) { + function ($href) { return \Sabre\HTTP\encodePath($href); }, - (array)$hrefs + (array) $hrefs )); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php b/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php index f4b692219..c33812b3e 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV; @@ -20,10 +22,10 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class LockDiscovery implements XmlSerializable { - +class LockDiscovery implements XmlSerializable +{ /** - * locks + * locks. * * @var LockInfo[] */ @@ -37,17 +39,16 @@ class LockDiscovery implements XmlSerializable { * * @var bool */ - static $hideLockRoot = false; + public static $hideLockRoot = false; /** - * __construct + * __construct. * * @param LockInfo[] $locks */ - function __construct($locks) { - + public function __construct($locks) + { $this->locks = $locks; - } /** @@ -63,16 +64,14 @@ class LockDiscovery implements XmlSerializable { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->locks as $lock) { - $writer->startElement('{DAV:}activelock'); $writer->startElement('{DAV:}lockscope'); - if ($lock->scope === LockInfo::SHARED) { + if (LockInfo::SHARED === $lock->scope) { $writer->writeElement('{DAV:}shared'); } else { $writer->writeElement('{DAV:}exclusive'); @@ -86,21 +85,23 @@ class LockDiscovery implements XmlSerializable { if (!self::$hideLockRoot) { $writer->startElement('{DAV:}lockroot'); - $writer->writeElement('{DAV:}href', $writer->contextUri . $lock->uri); + $writer->writeElement('{DAV:}href', $writer->contextUri.$lock->uri); $writer->endElement(); // {DAV:}lockroot } - $writer->writeElement('{DAV:}depth', ($lock->depth == DAV\Server::DEPTH_INFINITY ? 'infinity' : $lock->depth)); - $writer->writeElement('{DAV:}timeout', 'Second-' . $lock->timeout); - - $writer->startElement('{DAV:}locktoken'); - $writer->writeElement('{DAV:}href', 'opaquelocktoken:' . $lock->token); - $writer->endElement(); // {DAV:}locktoken + $writer->writeElement('{DAV:}depth', (DAV\Server::DEPTH_INFINITY == $lock->depth ? 'infinity' : $lock->depth)); + $writer->writeElement('{DAV:}timeout', (LockInfo::TIMEOUT_INFINITE === $lock->timeout ? 'Infinite' : 'Second-'.$lock->timeout)); + + // optional according to https://tools.ietf.org/html/rfc4918#section-6.5 + if (null !== $lock->token && '' !== $lock->token) { + $writer->startElement('{DAV:}locktoken'); + $writer->writeElement('{DAV:}href', 'opaquelocktoken:'.$lock->token); + $writer->endElement(); // {DAV:}locktoken + } - $writer->writeElement('{DAV:}owner', new XmlFragment($lock->owner)); + if ($lock->owner) { + $writer->writeElement('{DAV:}owner', new XmlFragment($lock->owner)); + } $writer->endElement(); // {DAV:}activelock - } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php b/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php index ce640ff32..ce07d4382 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -8,7 +10,7 @@ use Sabre\Xml\Element; use Sabre\Xml\Reader; /** - * {DAV:}resourcetype property + * {DAV:}resourcetype property. * * This class represents the {DAV:}resourcetype property, as defined in: * @@ -18,10 +20,10 @@ use Sabre\Xml\Reader; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ResourceType extends Element\Elements implements HtmlOutput { - +class ResourceType extends Element\Elements implements HtmlOutput +{ /** - * Constructor + * Constructor. * * You can either pass null (for no resourcetype), a string (for a single * resourcetype) or an array (for multiple). @@ -30,48 +32,44 @@ class ResourceType extends Element\Elements implements HtmlOutput { * * @param array|string|null $resourceTypes */ - function __construct($resourceTypes = null) { - - parent::__construct((array)$resourceTypes); - + public function __construct($resourceTypes = null) + { + parent::__construct((array) $resourceTypes); } /** - * Returns the values in clark-notation + * Returns the values in clark-notation. * * For example array('{DAV:}collection') * * @return array */ - function getValue() { - + public function getValue() + { return $this->value; - } /** - * Checks if the principal contains a certain value + * Checks if the principal contains a certain value. * * @param string $type + * * @return bool */ - function is($type) { - + public function is($type) + { return in_array($type, $this->value); - } /** - * Adds a resourcetype value to this property + * Adds a resourcetype value to this property. * * @param string $type - * @return void */ - function add($type) { - + public function add($type) + { $this->value[] = $type; $this->value = array_unique($this->value); - } /** @@ -93,13 +91,13 @@ class ResourceType extends Element\Elements implements HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { return new self(parent::xmlDeserialize($reader)); - } /** @@ -114,15 +112,14 @@ class ResourceType extends Element\Elements implements HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { return implode( ', ', array_map([$html, 'xmlName'], $this->getValue()) ); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php b/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php index 939062f76..95175053a 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Exception\BadRequest; @@ -22,10 +24,10 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ShareAccess implements Element { - +class ShareAccess implements Element +{ /** - * Either SHARED or SHAREDOWNER + * Either SHARED or SHAREDOWNER. * * @var int */ @@ -39,10 +41,9 @@ class ShareAccess implements Element { * * @param int $shareAccess */ - function __construct($shareAccess) { - + public function __construct($shareAccess) + { $this->value = $shareAccess; - } /** @@ -50,10 +51,9 @@ class ShareAccess implements Element { * * @return int */ - function getValue() { - + public function getValue() + { return $this->value; - } /** @@ -73,30 +73,26 @@ class ShareAccess implements Element { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { switch ($this->value) { - - case SharingPlugin::ACCESS_NOTSHARED : + case SharingPlugin::ACCESS_NOTSHARED: $writer->writeElement('{DAV:}not-shared'); break; - case SharingPlugin::ACCESS_SHAREDOWNER : + case SharingPlugin::ACCESS_SHAREDOWNER: $writer->writeElement('{DAV:}shared-owner'); break; - case SharingPlugin::ACCESS_READ : + case SharingPlugin::ACCESS_READ: $writer->writeElement('{DAV:}read'); break; - case SharingPlugin::ACCESS_READWRITE : + case SharingPlugin::ACCESS_READWRITE: $writer->writeElement('{DAV:}read-write'); break; - case SharingPlugin::ACCESS_NOACCESS : + case SharingPlugin::ACCESS_NOACCESS: $writer->writeElement('{DAV:}no-access'); break; - } - } /** @@ -118,26 +114,26 @@ class ShareAccess implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree(); foreach ($elems as $elem) { switch ($elem['name']) { - case '{DAV:}not-shared' : + case '{DAV:}not-shared': return new self(SharingPlugin::ACCESS_NOTSHARED); - case '{DAV:}shared-owner' : + case '{DAV:}shared-owner': return new self(SharingPlugin::ACCESS_SHAREDOWNER); - case '{DAV:}read' : + case '{DAV:}read': return new self(SharingPlugin::ACCESS_READ); - case '{DAV:}read-write' : + case '{DAV:}read-write': return new self(SharingPlugin::ACCESS_READWRITE); - case '{DAV:}no-access' : + case '{DAV:}no-access': return new self(SharingPlugin::ACCESS_NOACCESS); } } throw new BadRequest('Invalid value for {DAV:}share-access element'); - } } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php index 677fdde4b..26e7d646e 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\Xml\Writer; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedLock implements XmlSerializable { - +class SupportedLock implements XmlSerializable +{ /** * The xmlSerialize method is called during xml writing. * @@ -37,18 +39,16 @@ class SupportedLock implements XmlSerializable { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { $writer->writeElement('{DAV:}lockentry', [ '{DAV:}lockscope' => ['{DAV:}exclusive' => null], - '{DAV:}locktype' => ['{DAV:}write' => null], + '{DAV:}locktype' => ['{DAV:}write' => null], ]); $writer->writeElement('{DAV:}lockentry', [ '{DAV:}lockscope' => ['{DAV:}shared' => null], - '{DAV:}locktype' => ['{DAV:}write' => null], + '{DAV:}locktype' => ['{DAV:}write' => null], ]); - } } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php index 1a3878ef7..06ab28c94 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -20,24 +22,23 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedMethodSet implements XmlSerializable, HtmlOutput { - +class SupportedMethodSet implements XmlSerializable, HtmlOutput +{ /** - * List of methods + * List of methods. * * @var string[] */ protected $methods = []; /** - * Creates the property + * Creates the property. * * @param string[] $methods */ - function __construct(array $methods) { - + public function __construct(array $methods) + { $this->methods = $methods; - } /** @@ -45,25 +46,24 @@ class SupportedMethodSet implements XmlSerializable, HtmlOutput { * * @return string[] */ - function getValue() { - + public function getValue() + { return $this->methods; - } /** * Returns true or false if the property contains a specific method. * * @param string $methodName + * * @return bool */ - function has($methodName) { - + public function has($methodName) + { return in_array( $methodName, $this->methods ); - } /** @@ -83,16 +83,14 @@ class SupportedMethodSet implements XmlSerializable, HtmlOutput { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->getValue() as $val) { $writer->startElement('{DAV:}supported-method'); $writer->writeAttribute('name', $val); $writer->endElement(); } - } /** @@ -107,15 +105,14 @@ class SupportedMethodSet implements XmlSerializable, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { return implode( ', ', array_map([$html, 'h'], $this->getValue()) ); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php index 96383ec96..4c25d23d9 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV; @@ -21,17 +23,17 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedReportSet implements XmlSerializable, HtmlOutput { - +class SupportedReportSet implements XmlSerializable, HtmlOutput +{ /** - * List of reports + * List of reports. * * @var array */ protected $reports = []; /** - * Creates the property + * Creates the property. * * Any reports passed in the constructor * should be valid report-types in clark-notation. @@ -40,61 +42,56 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { * * @param string|string[] $reports */ - function __construct($reports = null) { - - if (!is_null($reports)) + public function __construct($reports = null) + { + if (!is_null($reports)) { $this->addReport($reports); - + } } /** - * Adds a report to this property + * Adds a report to this property. * * The report must be a string in clark-notation. * Multiple reports can be specified as an array. * * @param mixed $report - * @return void */ - function addReport($report) { - - $report = (array)$report; + public function addReport($report) + { + $report = (array) $report; foreach ($report as $r) { - - if (!preg_match('/^{([^}]*)}(.*)$/', $r)) + if (!preg_match('/^{([^}]*)}(.*)$/', $r)) { throw new DAV\Exception('Reportname must be in clark-notation'); - + } $this->reports[] = $r; - } - } /** - * Returns the list of supported reports + * Returns the list of supported reports. * * @return string[] */ - function getValue() { - + public function getValue() + { return $this->reports; - } /** * Returns true or false if the property contains a specific report. * * @param string $reportName + * * @return bool */ - function has($reportName) { - + public function has($reportName) + { return in_array( $reportName, $this->reports ); - } /** @@ -114,10 +111,9 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->getValue() as $val) { $writer->startElement('{DAV:}supported-report'); $writer->startElement('{DAV:}report'); @@ -125,7 +121,6 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { $writer->endElement(); $writer->endElement(); } - } /** @@ -140,15 +135,14 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { return implode( ', ', array_map([$html, 'xmlName'], $this->getValue()) ); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php b/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php index c315a9a45..8d9348162 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\DAV\Locks\LockInfo; @@ -18,10 +20,10 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Lock implements XmlDeserializable { - +class Lock implements XmlDeserializable +{ /** - * Owner of the lock + * Owner of the lock. * * @var string */ @@ -31,6 +33,7 @@ class Lock implements XmlDeserializable { * Scope of the lock. * * Either LockInfo::SHARED or LockInfo::EXCLUSIVE + * * @var int */ public $scope; @@ -54,10 +57,11 @@ class Lock implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $reader->pushContext(); $reader->elementMap['{DAV:}owner'] = 'Sabre\\Xml\\Element\\XmlFragment'; @@ -71,11 +75,12 @@ class Lock implements XmlDeserializable { if (isset($values['{DAV:}lockscope'])) { foreach ($values['{DAV:}lockscope'] as $elem) { - if ($elem['name'] === '{DAV:}exclusive') $new->scope = LockInfo::EXCLUSIVE; + if ('{DAV:}exclusive' === $elem['name']) { + $new->scope = LockInfo::EXCLUSIVE; + } } } - return $new; + return $new; } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php b/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php index 9490bf58c..7713646ea 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\Xml\Reader; @@ -16,8 +18,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MkCol implements XmlDeserializable { - +class MkCol implements XmlDeserializable +{ /** * The list of properties that will be set. * @@ -31,10 +33,9 @@ class MkCol implements XmlDeserializable { * * @return array */ - function getProperties() { - + public function getProperties() + { return $this->properties; - } /** @@ -56,10 +57,11 @@ class MkCol implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $elementMap = $reader->elementMap; @@ -70,13 +72,11 @@ class MkCol implements XmlDeserializable { $elems = $reader->parseInnerTree($elementMap); foreach ($elems as $elem) { - if ($elem['name'] === '{DAV:}set') { + if ('{DAV:}set' === $elem['name']) { $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); } } return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php b/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php index f1b5b6fdc..b4cce423e 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\Xml\Element\KeyValue; @@ -17,8 +19,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class PropFind implements XmlDeserializable { - +class PropFind implements XmlDeserializable +{ /** * If this is set to true, this was an 'allprop' request. * @@ -27,9 +29,9 @@ class PropFind implements XmlDeserializable { public $allProp = false; /** - * The property list + * The property list. * - * @var null|array + * @var array|null */ public $properties; @@ -52,32 +54,28 @@ class PropFind implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $reader->pushContext(); $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements'; foreach (KeyValue::xmlDeserialize($reader) as $k => $v) { - switch ($k) { - case '{DAV:}prop' : + case '{DAV:}prop': $self->properties = $v; break; - case '{DAV:}allprop' : + case '{DAV:}allprop': $self->allProp = true; - } - } $reader->popContext(); return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php b/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php index 821b9e047..55e154ec7 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\Xml\Element; @@ -17,8 +19,8 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class PropPatch implements Element { - +class PropPatch implements Element +{ /** * The list of properties that will be updated and removed. * @@ -45,24 +47,20 @@ class PropPatch implements Element { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->properties as $propertyName => $propertyValue) { - if (is_null($propertyValue)) { - $writer->startElement("{DAV:}remove"); + $writer->startElement('{DAV:}remove'); $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); $writer->endElement(); } else { - $writer->startElement("{DAV:}set"); + $writer->startElement('{DAV:}set'); $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); $writer->endElement(); } - } - } /** @@ -84,10 +82,11 @@ class PropPatch implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $elementMap = $reader->elementMap; @@ -98,21 +97,17 @@ class PropPatch implements Element { $elems = $reader->parseInnerTree($elementMap); foreach ($elems as $elem) { - if ($elem['name'] === '{DAV:}set') { + if ('{DAV:}set' === $elem['name']) { $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); } - if ($elem['name'] === '{DAV:}remove') { - + if ('{DAV:}remove' === $elem['name']) { // Ensuring there are no values. foreach ($elem['value']['{DAV:}prop'] as $remove => $value) { $self->properties[$remove] = null; } - } } return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php b/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php index 526a4eb6f..e1985b8c3 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\DAV\Xml\Element\Sharee; @@ -17,8 +19,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class ShareResource implements XmlDeserializable { - +class ShareResource implements XmlDeserializable +{ /** * The list of new people added or updated or removed from the share. * @@ -27,14 +29,13 @@ class ShareResource implements XmlDeserializable { public $sharees = []; /** - * Constructor + * Constructor. * * @param Sharee[] $sharees */ - function __construct(array $sharees) { - + public function __construct(array $sharees) + { $this->sharees = $sharees; - } /** @@ -56,26 +57,26 @@ class ShareResource implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree([ - '{DAV:}sharee' => 'Sabre\DAV\Xml\Element\Sharee', + '{DAV:}sharee' => 'Sabre\DAV\Xml\Element\Sharee', '{DAV:}share-access' => 'Sabre\DAV\Xml\Property\ShareAccess', - '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue', + '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue', ]); $sharees = []; foreach ($elems as $elem) { - if ($elem['name'] !== '{DAV:}sharee') continue; + if ('{DAV:}sharee' !== $elem['name']) { + continue; + } $sharees[] = $elem['value']; - } return new self($sharees); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php b/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php index 830293a01..acf0039ce 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\DAV\Exception\BadRequest; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SyncCollectionReport implements XmlDeserializable { - +class SyncCollectionReport implements XmlDeserializable +{ /** * The sync-token the client supplied for the report. * @@ -44,7 +46,7 @@ class SyncCollectionReport implements XmlDeserializable { /** * The list of properties that are being requested for every change. * - * @var null|array + * @var array|null */ public $properties; @@ -67,10 +69,11 @@ class SyncCollectionReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $reader->pushContext(); @@ -87,36 +90,31 @@ class SyncCollectionReport implements XmlDeserializable { foreach ($required as $elem) { if (!array_key_exists($elem, $elems)) { - throw new BadRequest('The ' . $elem . ' element in the {DAV:}sync-collection report is required'); + throw new BadRequest('The '.$elem.' element in the {DAV:}sync-collection report is required'); } } - $self->properties = $elems['{DAV:}prop']; $self->syncToken = $elems['{DAV:}sync-token']; if (isset($elems['{DAV:}limit'])) { $nresults = null; foreach ($elems['{DAV:}limit'] as $child) { - if ($child['name'] === '{DAV:}nresults') { - $nresults = (int)$child['value']; + if ('{DAV:}nresults' === $child['name']) { + $nresults = (int) $child['value']; } } $self->limit = $nresults; } if (isset($elems['{DAV:}sync-level'])) { - $value = $elems['{DAV:}sync-level']; - if ($value === 'infinity') { + if ('infinity' === $value) { $value = \Sabre\DAV\Server::DEPTH_INFINITY; } $self->syncLevel = $value; - } return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Response/MultiStatus.php b/vendor/sabre/dav/lib/DAV/Xml/Response/MultiStatus.php index cf5a0453b..423d0b569 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Response/MultiStatus.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Response/MultiStatus.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Response; use Sabre\Xml\Element; @@ -7,7 +9,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * WebDAV MultiStatus parser + * WebDAV MultiStatus parser. * * This class parses the {DAV:}multistatus response, as defined in: * https://tools.ietf.org/html/rfc4918#section-14.16 @@ -19,10 +21,10 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MultiStatus implements Element { - +class MultiStatus implements Element +{ /** - * The responses + * The responses. * * @var \Sabre\DAV\Xml\Element\Response[] */ @@ -36,16 +38,15 @@ class MultiStatus implements Element { protected $syncToken; /** - * Constructor + * Constructor. * * @param \Sabre\DAV\Xml\Element\Response[] $responses - * @param string $syncToken + * @param string $syncToken */ - function __construct(array $responses, $syncToken = null) { - + public function __construct(array $responses, $syncToken = null) + { $this->responses = $responses; $this->syncToken = $syncToken; - } /** @@ -53,10 +54,9 @@ class MultiStatus implements Element { * * @return \Sabre\DAV\Xml\Element\Response[] */ - function getResponses() { - + public function getResponses() + { return $this->responses; - } /** @@ -64,10 +64,9 @@ class MultiStatus implements Element { * * @return string|null */ - function getSyncToken() { - + public function getSyncToken() + { return $this->syncToken; - } /** @@ -83,17 +82,15 @@ class MultiStatus implements Element { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->getResponses() as $response) { $writer->writeElement('{DAV:}response', $response); } if ($syncToken = $this->getSyncToken()) { $writer->writeElement('{DAV:}sync-token', $syncToken); } - } /** @@ -115,10 +112,11 @@ class MultiStatus implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elementMap = $reader->elementMap; $elementMap['{DAV:}prop'] = 'Sabre\\DAV\\Xml\\Element\\Prop'; $elements = $reader->parseInnerTree($elementMap); @@ -126,17 +124,17 @@ class MultiStatus implements Element { $responses = []; $syncToken = null; - if ($elements) foreach ($elements as $elem) { - if ($elem['name'] === '{DAV:}response') { - $responses[] = $elem['value']; - } - if ($elem['name'] === '{DAV:}sync-token') { - $syncToken = $elem['value']; + if ($elements) { + foreach ($elements as $elem) { + if ('{DAV:}response' === $elem['name']) { + $responses[] = $elem['value']; + } + if ('{DAV:}sync-token' === $elem['name']) { + $syncToken = $elem['value']; + } } } return new self($responses, $syncToken); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Service.php b/vendor/sabre/dav/lib/DAV/Xml/Service.php index f41ed984a..4406b022d 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Service.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Service.php @@ -1,16 +1,18 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml; /** - * XML service for WebDAV + * XML service for WebDAV. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Service extends \Sabre\Xml\Service { - +class Service extends \Sabre\Xml\Service +{ /** * This is a list of XML elements that we automatically map to PHP classes. * @@ -19,16 +21,15 @@ class Service extends \Sabre\Xml\Service { */ public $elementMap = [ '{DAV:}multistatus' => 'Sabre\\DAV\\Xml\\Response\\MultiStatus', - '{DAV:}response' => 'Sabre\\DAV\\Xml\\Element\\Response', + '{DAV:}response' => 'Sabre\\DAV\\Xml\\Element\\Response', // Requests - '{DAV:}propfind' => 'Sabre\\DAV\\Xml\\Request\\PropFind', + '{DAV:}propfind' => 'Sabre\\DAV\\Xml\\Request\\PropFind', '{DAV:}propertyupdate' => 'Sabre\\DAV\\Xml\\Request\\PropPatch', - '{DAV:}mkcol' => 'Sabre\\DAV\\Xml\\Request\\MkCol', + '{DAV:}mkcol' => 'Sabre\\DAV\\Xml\\Request\\MkCol', // Properties '{DAV:}resourcetype' => 'Sabre\\DAV\\Xml\\Property\\ResourceType', - ]; /** @@ -40,8 +41,7 @@ class Service extends \Sabre\Xml\Service { * @var array */ public $namespaceMap = [ - 'DAV:' => 'd', + 'DAV:' => 'd', 'http://sabredav.org/ns' => 's', ]; - } |