diff options
author | Mario <mario@mariovavti.com> | 2019-11-10 12:49:51 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-11-10 14:10:03 +0100 |
commit | 580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch) | |
tree | 82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/lib/DAVACL | |
parent | d22766f458a8539a40a57f3946459a9be1f21cd6 (diff) | |
download | volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2 volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip |
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/lib/DAVACL')
30 files changed, 863 insertions, 977 deletions
diff --git a/vendor/sabre/dav/lib/DAVACL/ACLTrait.php b/vendor/sabre/dav/lib/DAVACL/ACLTrait.php index 602654a2e..d9bf4e1e0 100644 --- a/vendor/sabre/dav/lib/DAVACL/ACLTrait.php +++ b/vendor/sabre/dav/lib/DAVACL/ACLTrait.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; /** @@ -14,32 +16,30 @@ namespace Sabre\DAVACL; * @author Evert Pot (https://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -trait ACLTrait { - +trait ACLTrait +{ /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return null; - } /** - * Returns a group principal + * Returns a group principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getGroup() { - + public function getGroup() + { return null; - } /** @@ -54,28 +54,26 @@ trait ACLTrait { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ 'privilege' => '{DAV:}all', 'principal' => '{DAV:}owner', 'protected' => true, - ] + ], ]; - } /** - * Updates the ACL + * Updates the ACL. * * This method will receive a list of new ACE's as an array argument. * * @param array $acl - * @return void */ - function setACL(array $acl) { - + public function setACL(array $acl) + { throw new \Sabre\DAV\Exception\Forbidden('Setting ACL is not supported on this node'); } @@ -91,10 +89,8 @@ trait ACLTrait { * * @return array|null */ - function getSupportedPrivilegeSet() { - + public function getSupportedPrivilegeSet() + { return null; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php b/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php index 9d2026380..1160dd7ac 100644 --- a/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * Principals Collection + * Principals Collection. * * This is a helper class that easily allows you to create a collection that * has a childnode for every principal. @@ -17,10 +19,10 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractPrincipalCollection extends DAV\Collection implements IPrincipalCollection { - +abstract class AbstractPrincipalCollection extends DAV\Collection implements IPrincipalCollection +{ /** - * Principal backend + * Principal backend. * * @var PrincipalBackend\BackendInterface */ @@ -42,7 +44,7 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr public $disableListing = false; /** - * Creates the object + * Creates the object. * * This object must be passed the principal backend. This object will * filter all principals from a specified prefix ($principalPrefix). The @@ -51,13 +53,12 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * * * @param PrincipalBackend\BackendInterface $principalBackend - * @param string $principalPrefix + * @param string $principalPrefix */ - function __construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix = 'principals') { - + public function __construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix = 'principals') + { $this->principalPrefix = $principalPrefix; $this->principalBackend = $principalBackend; - } /** @@ -68,56 +69,58 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * supplied by the authentication backend. * * @param array $principalInfo - * @return IPrincipal + * + * @return DAV\INode */ - abstract function getChildForPrincipal(array $principalInfo); + abstract public function getChildForPrincipal(array $principalInfo); /** * Returns the name of this collection. * * @return string */ - function getName() { + public function getName() + { + list(, $name) = Uri\split($this->principalPrefix); - list(, $name) = URLUtil::splitPath($this->principalPrefix); return $name; - } /** - * Return the list of users + * Return the list of users. * * @return array */ - function getChildren() { - - if ($this->disableListing) + public function getChildren() + { + if ($this->disableListing) { throw new DAV\Exception\MethodNotAllowed('Listing members of this collection is disabled'); - + } $children = []; foreach ($this->principalBackend->getPrincipalsByPrefix($this->principalPrefix) as $principalInfo) { - $children[] = $this->getChildForPrincipal($principalInfo); - - } - return $children; + return $children; } /** * Returns a child object, by its name. * * @param string $name + * * @throws DAV\Exception\NotFound + * * @return DAV\INode */ - function getChild($name) { + public function getChild($name) + { + $principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix.'/'.$name); + if (!$principalInfo) { + throw new DAV\Exception\NotFound('Principal with name '.$name.' not found'); + } - $principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix . '/' . $name); - if (!$principalInfo) throw new DAV\Exception\NotFound('Principal with name ' . $name . ' not found'); return $this->getChildForPrincipal($principalInfo); - } /** @@ -139,21 +142,21 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * This method should simply return a list of 'child names', which may be * used to call $this->getChild in the future. * - * @param array $searchProperties + * @param array $searchProperties * @param string $test + * * @return array */ - function searchPrincipals(array $searchProperties, $test = 'allof') { - + public function searchPrincipals(array $searchProperties, $test = 'allof') + { $result = $this->principalBackend->searchPrincipals($this->principalPrefix, $searchProperties, $test); $r = []; foreach ($result as $row) { - list(, $r[]) = URLUtil::splitPath($row); + list(, $r[]) = Uri\split($row); } return $r; - } /** @@ -170,12 +173,11 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * principal was not found or you refuse to find it. * * @param string $uri + * * @return string */ - function findByUri($uri) { - + public function findByUri($uri) + { return $this->principalBackend->findByUri($uri, $this->principalPrefix); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php b/vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php index 22450b4a6..7756d4728 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; @@ -12,24 +14,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AceConflict extends DAV\Exception\Conflict { - +class AceConflict extends DAV\Exception\Conflict +{ /** * Adds in extra information in the xml response. * * This method adds the {DAV:}no-ace-conflict element as defined in rfc3744 * - * @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) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:no-ace-conflict'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php b/vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php index 5624fd22f..19e0dac9d 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; /** - * NeedPrivileges + * NeedPrivileges. * * The 403-need privileges is thrown when a user didn't have the appropriate * permissions to perform an operation @@ -14,10 +16,10 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NeedPrivileges extends DAV\Exception\Forbidden { - +class NeedPrivileges extends DAV\Exception\Forbidden +{ /** - * The relevant uri + * The relevant uri. * * @var string */ @@ -31,18 +33,17 @@ class NeedPrivileges extends DAV\Exception\Forbidden { protected $privileges; /** - * Constructor + * Constructor. * * @param string $uri - * @param array $privileges + * @param array $privileges */ - function __construct($uri, array $privileges) { - + public function __construct($uri, array $privileges) + { $this->uri = $uri; $this->privileges = $privileges; - parent::__construct('User did not have the required privileges (' . implode(',', $privileges) . ') for path "' . $uri . '"'); - + parent::__construct('User did not have the required privileges ('.implode(',', $privileges).') for path "'.$uri.'"'); } /** @@ -50,33 +51,27 @@ class NeedPrivileges extends DAV\Exception\Forbidden { * * This method adds the {DAV:}need-privileges element as defined in rfc3744 * - * @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) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:need-privileges'); $errorNode->appendChild($np); foreach ($this->privileges as $privilege) { - $resource = $doc->createElementNS('DAV:', 'd:resource'); $np->appendChild($resource); - $resource->appendChild($doc->createElementNS('DAV:', 'd:href', $server->getBaseUri() . $this->uri)); + $resource->appendChild($doc->createElementNS('DAV:', 'd:href', $server->getBaseUri().$this->uri)); $priv = $doc->createElementNS('DAV:', 'd:privilege'); $resource->appendChild($priv); preg_match('/^{([^}]*)}(.*)$/', $privilege, $privilegeParts); - $priv->appendChild($doc->createElementNS($privilegeParts[1], 'd:' . $privilegeParts[2])); - - + $priv->appendChild($doc->createElementNS($privilegeParts[1], 'd:'.$privilegeParts[2])); } - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php b/vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php index a2363b174..d90b01ffd 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; @@ -12,24 +14,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NoAbstract extends DAV\Exception\PreconditionFailed { - +class NoAbstract extends DAV\Exception\PreconditionFailed +{ /** * Adds in extra information in the xml response. * * This method adds the {DAV:}no-abstract element as defined in rfc3744 * - * @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) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:no-abstract'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php b/vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php index d7ae188ae..b005c55d8 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; @@ -12,24 +14,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotRecognizedPrincipal extends DAV\Exception\PreconditionFailed { - +class NotRecognizedPrincipal extends DAV\Exception\PreconditionFailed +{ /** * Adds in extra information in the xml response. * * This method adds the {DAV:}recognized-principal element as defined in rfc3744 * - * @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) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:recognized-principal'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php b/vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php index 73b81190d..dda2e6281 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; @@ -12,24 +14,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotSupportedPrivilege extends DAV\Exception\PreconditionFailed { - +class NotSupportedPrivilege extends DAV\Exception\PreconditionFailed +{ /** * Adds in extra information in the xml response. * * This method adds the {DAV:}not-supported-privilege element as defined in rfc3744 * - * @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) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:not-supported-privilege'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/FS/Collection.php b/vendor/sabre/dav/lib/DAVACL/FS/Collection.php index b4fe7a1b0..85b04e2bd 100644 --- a/vendor/sabre/dav/lib/DAVACL/FS/Collection.php +++ b/vendor/sabre/dav/lib/DAVACL/FS/Collection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\FS; use Sabre\DAV\Exception\Forbidden; @@ -15,8 +17,8 @@ use Sabre\DAVACL\IACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Collection extends BaseCollection implements IACL { - +class Collection extends BaseCollection implements IACL +{ use ACLTrait; /** @@ -34,60 +36,58 @@ class Collection extends BaseCollection implements IACL { protected $owner; /** - * Constructor + * Constructor. * - * @param string $path on-disk path. - * @param array $acl ACL rules. - * @param string|null $owner principal owner string. + * @param string $path on-disk path + * @param array $acl ACL rules + * @param string|null $owner principal owner string */ - function __construct($path, array $acl, $owner = null) { - + public function __construct($path, array $acl, $owner = null) + { parent::__construct($path); $this->acl = $acl; $this->owner = $owner; - } /** - * 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 NotFound + * * @return \Sabre\DAV\INode */ - function getChild($name) { - - $path = $this->path . '/' . $name; - - if (!file_exists($path)) throw new NotFound('File could not be located'); - if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..'); + public function getChild($name) + { + $path = $this->path.'/'.$name; + if (!file_exists($path)) { + throw new NotFound('File could not be located'); + } + if ('.' == $name || '..' == $name) { + throw new Forbidden('Permission denied to . and ..'); + } if (is_dir($path)) { - return new self($path, $this->acl, $this->owner); - } else { - return new File($path, $this->acl, $this->owner); - } - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->owner; - } /** @@ -102,10 +102,8 @@ class Collection extends BaseCollection implements IACL { * * @return array */ - function getACL() { - + public function getACL() + { return $this->acl; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/FS/File.php b/vendor/sabre/dav/lib/DAVACL/FS/File.php index aaf2ae148..5506aa2c1 100644 --- a/vendor/sabre/dav/lib/DAVACL/FS/File.php +++ b/vendor/sabre/dav/lib/DAVACL/FS/File.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\FS; use Sabre\DAV\FSExt\File as BaseFile; @@ -13,8 +15,8 @@ use Sabre\DAVACL\IACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends BaseFile implements IACL { - +class File extends BaseFile implements IACL +{ use ACLTrait; /** @@ -32,31 +34,29 @@ class File extends BaseFile implements IACL { protected $owner; /** - * Constructor + * Constructor. * - * @param string $path on-disk path. - * @param array $acl ACL rules. - * @param string|null $owner principal owner string. + * @param string $path on-disk path + * @param array $acl ACL rules + * @param string|null $owner principal owner string */ - function __construct($path, array $acl, $owner = null) { - + public function __construct($path, array $acl, $owner = null) + { parent::__construct($path); $this->acl = $acl; $this->owner = $owner; - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->owner; - } /** @@ -71,10 +71,8 @@ class File extends BaseFile implements IACL { * * @return array */ - function getACL() { - + public function getACL() + { return $this->acl; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php b/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php index 201235e5a..c896d8e25 100644 --- a/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\FS; use Sabre\DAVACL\AbstractPrincipalCollection; @@ -19,8 +21,8 @@ use Sabre\Uri; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class HomeCollection extends AbstractPrincipalCollection implements IACL { - +class HomeCollection extends AbstractPrincipalCollection implements IACL +{ use ACLTrait; /** @@ -41,14 +43,13 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * Creates the home collection. * * @param BackendInterface $principalBackend - * @param string $storagePath Where the actual files are stored. - * @param string $principalPrefix list of principals to iterate. + * @param string $storagePath where the actual files are stored + * @param string $principalPrefix list of principals to iterate */ - function __construct(BackendInterface $principalBackend, $storagePath, $principalPrefix = 'principals') { - + public function __construct(BackendInterface $principalBackend, $storagePath, $principalPrefix = 'principals') + { parent::__construct($principalBackend, $principalPrefix); $this->storagePath = $storagePath; - } /** @@ -58,10 +59,9 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * * @return string */ - function getName() { - + public function getName() + { return $this->collectionName; - } /** @@ -72,10 +72,11 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * supplied by the authentication backend. * * @param array $principalInfo + * * @return \Sabre\DAV\INode */ - function getChildForPrincipal(array $principalInfo) { - + public function getChildForPrincipal(array $principalInfo) + { $owner = $principalInfo['uri']; $acl = [ [ @@ -87,20 +88,19 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { list(, $principalBaseName) = Uri\split($owner); - $path = $this->storagePath . '/' . $principalBaseName; + $path = $this->storagePath.'/'.$principalBaseName; if (!is_dir($path)) { mkdir($path, 0777, true); } + return new Collection( $path, $acl, $owner ); - } - /** * Returns a list of ACE's for this node. * @@ -113,16 +113,14 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ 'principal' => '{DAV:}authenticated', 'privilege' => '{DAV:}read', 'protected' => true, - ] + ], ]; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/IACL.php b/vendor/sabre/dav/lib/DAVACL/IACL.php index f7a138665..d19a075be 100644 --- a/vendor/sabre/dav/lib/DAVACL/IACL.php +++ b/vendor/sabre/dav/lib/DAVACL/IACL.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; /** - * ACL-enabled node + * ACL-enabled node. * * If you want to add WebDAV ACL to a node, you must implement this class * @@ -13,25 +15,25 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IACL extends DAV\INode { - +interface IACL extends DAV\INode +{ /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner(); + public function getOwner(); /** - * Returns a group principal + * Returns a group principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getGroup(); + public function getGroup(); /** * Returns a list of ACE's for this node. @@ -45,17 +47,16 @@ interface IACL extends DAV\INode { * * @return array */ - function getACL(); + public function getACL(); /** - * Updates the ACL + * Updates the ACL. * * This method will receive a list of new ACE's as an array argument. * * @param array $acl - * @return void */ - function setACL(array $acl); + public function setACL(array $acl); /** * Returns the list of supported privileges for this node. @@ -69,6 +70,5 @@ interface IACL extends DAV\INode { * * @return array|null */ - function getSupportedPrivilegeSet(); - + public function getSupportedPrivilegeSet(); } diff --git a/vendor/sabre/dav/lib/DAVACL/IPrincipal.php b/vendor/sabre/dav/lib/DAVACL/IPrincipal.php index 13728471e..c804096de 100644 --- a/vendor/sabre/dav/lib/DAVACL/IPrincipal.php +++ b/vendor/sabre/dav/lib/DAVACL/IPrincipal.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; /** - * IPrincipal interface + * IPrincipal interface. * * Implement this interface to define your own principals * @@ -13,46 +15,46 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IPrincipal extends DAV\INode { - +interface IPrincipal extends DAV\INode +{ /** - * Returns a list of alternative urls for a principal + * Returns a list of alternative urls for a principal. * * This can for example be an email address, or ldap url. * * @return array */ - function getAlternateUriSet(); + public function getAlternateUriSet(); /** - * Returns the full principal url + * Returns the full principal url. * * @return string */ - function getPrincipalUrl(); + public function getPrincipalUrl(); /** - * Returns the list of group members + * Returns the list of group members. * * If this principal is a group, this function should return * all member principal uri's for the group. * * @return array */ - function getGroupMemberSet(); + public function getGroupMemberSet(); /** - * Returns the list of groups this principal is member of + * Returns the list of groups this principal is member of. * * If this principal is a member of a (list of) groups, this function * should return a list of principal uri's for it's members. * * @return array */ - function getGroupMembership(); + public function getGroupMembership(); /** - * Sets a list of group members + * Sets a list of group members. * * If this principal is a group, this method sets all the group members. * The list of members is always overwritten, never appended to. @@ -60,18 +62,16 @@ interface IPrincipal extends DAV\INode { * This method should throw an exception if the members could not be set. * * @param array $principals - * @return void */ - function setGroupMemberSet(array $principals); + public function setGroupMemberSet(array $principals); /** - * Returns the displayname + * Returns the displayname. * * This should be a human readable name for the principal. * If none is available, return the nodename. * * @return string */ - function getDisplayName(); - + public function getDisplayName(); } diff --git a/vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php b/vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php index 3ab8382fa..1003730d6 100644 --- a/vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -14,8 +16,8 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IPrincipalCollection extends DAV\ICollection { - +interface IPrincipalCollection extends DAV\ICollection +{ /** * This method is used to search for principals matching a set of * properties. @@ -35,11 +37,12 @@ interface IPrincipalCollection extends DAV\ICollection { * This method should simply return a list of 'child names', which may be * used to call $this->getChild in the future. * - * @param array $searchProperties + * @param array $searchProperties * @param string $test + * * @return array */ - function searchPrincipals(array $searchProperties, $test = 'allof'); + public function searchPrincipals(array $searchProperties, $test = 'allof'); /** * Finds a principal by its URI. @@ -55,8 +58,8 @@ interface IPrincipalCollection extends DAV\ICollection { * principal was not found or you refuse to find it. * * @param string $uri + * * @return string */ - function findByUri($uri); - + public function findByUri($uri); } diff --git a/vendor/sabre/dav/lib/DAVACL/Plugin.php b/vendor/sabre/dav/lib/DAVACL/Plugin.php index a2aa118d7..c1ea6027c 100644 --- a/vendor/sabre/dav/lib/DAVACL/Plugin.php +++ b/vendor/sabre/dav/lib/DAVACL/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -15,7 +17,7 @@ use Sabre\HTTP\ResponseInterface; use Sabre\Uri; /** - * SabreDAV ACL Plugin + * SabreDAV ACL Plugin. * * This plugin provides functionality to enforce ACL permissions. * ACL is defined in RFC3744. @@ -28,24 +30,24 @@ use Sabre\Uri; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * Recursion constants + * Recursion constants. * * This only checks the base node */ const R_PARENT = 1; /** - * Recursion constants + * Recursion constants. * * This checks every node in the tree */ const R_RECURSIVE = 2; /** - * Recursion constants + * Recursion constants. * * This checks every parentnode in the tree, but not leaf-nodes. */ @@ -70,7 +72,7 @@ class Plugin extends DAV\ServerPlugin { /** * By default nodes that are inaccessible by the user, can still be seen - * in directory listings (PROPFIND on parent with Depth: 1) + * in directory listings (PROPFIND on parent with Depth: 1). * * In certain cases it's desirable to hide inaccessible nodes. Setting this * to true will cause these nodes to be hidden from directory listings. @@ -88,7 +90,7 @@ class Plugin extends DAV\ServerPlugin { * @var array */ public $principalSearchPropertySet = [ - '{DAV:}displayname' => 'Display name', + '{DAV:}displayname' => 'Display name', '{http://sabredav.org/ns}email-address' => 'Email address', ]; @@ -120,22 +122,21 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['access-control', 'calendarserver-principal-property-search']; - } /** - * Returns a list of available methods for a given url + * Returns a list of available methods for a given url. * * @param string $uri + * * @return array */ - function getMethods($uri) { - + public function getMethods($uri) + { return ['ACL']; - } /** @@ -146,10 +147,9 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'acl'; - } /** @@ -160,20 +160,19 @@ class Plugin extends DAV\ServerPlugin { * implement them * * @param string $uri + * * @return array */ - function getSupportedReportSet($uri) { - + public function getSupportedReportSet($uri) + { return [ '{DAV:}expand-property', '{DAV:}principal-match', '{DAV:}principal-property-search', '{DAV:}principal-search-property-set', ]; - } - /** * Checks if the current user has the specified privilege(s). * @@ -181,27 +180,29 @@ class Plugin extends DAV\ServerPlugin { * This method will throw an exception if the privilege is not available * and return true otherwise. * - * @param string $uri + * @param string $uri * @param array|string $privileges - * @param int $recursion - * @param bool $throwExceptions if set to false, this method won't throw exceptions. + * @param int $recursion + * @param bool $throwExceptions if set to false, this method won't throw exceptions + * * @throws NeedPrivileges * @throws NotAuthenticated + * * @return bool */ - function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, $throwExceptions = true) { - - if (!is_array($privileges)) $privileges = [$privileges]; + public function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, $throwExceptions = true) + { + if (!is_array($privileges)) { + $privileges = [$privileges]; + } $acl = $this->getCurrentUserPrivilegeSet($uri); $failed = []; foreach ($privileges as $priv) { - if (!in_array($priv, $acl)) { $failed[] = $priv; } - } if ($failed) { @@ -213,17 +214,16 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpRequest, $this->server->httpResponse ); - throw new notAuthenticated(implode(', ', $reasons) . '. Login was needed for privilege: ' . implode(', ', $failed) . ' on ' . $uri); + throw new notAuthenticated(implode(', ', $reasons).'. Login was needed for privilege: '.implode(', ', $failed).' on '.$uri); } if ($throwExceptions) { - throw new NeedPrivileges($uri, $failed); } else { return false; } } - return true; + return true; } /** @@ -234,35 +234,35 @@ class Plugin extends DAV\ServerPlugin { * * @return string|null */ - function getCurrentUserPrincipal() { - + public function getCurrentUserPrincipal() + { /** @var $authPlugin \Sabre\DAV\Auth\Plugin */ $authPlugin = $this->server->getPlugin('auth'); if (!$authPlugin) { return null; } - return $authPlugin->getCurrentPrincipal(); + return $authPlugin->getCurrentPrincipal(); } - /** * Returns a list of principals that's associated to the current * user, either directly or through group membership. * * @return array */ - function getCurrentUserPrincipals() { - + public function getCurrentUserPrincipals() + { $currentUser = $this->getCurrentUserPrincipal(); - if (is_null($currentUser)) return []; + if (is_null($currentUser)) { + return []; + } return array_merge( [$currentUser], $this->getPrincipalMembership($currentUser) ); - } /** @@ -271,12 +271,10 @@ class Plugin extends DAV\ServerPlugin { * These rules are used for all nodes that don't implement the IACL interface. * * @param array $acl - * @return void */ - function setDefaultAcl(array $acl) { - + public function setDefaultAcl(array $acl) + { $this->defaultAcl = $acl; - } /** @@ -286,10 +284,9 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getDefaultAcl() { - + public function getDefaultAcl() + { return $this->defaultAcl; - } /** @@ -317,15 +314,15 @@ class Plugin extends DAV\ServerPlugin { */ protected $principalMembershipCache = []; - /** * Returns all the principal groups the specified principal is a member of. * * @param string $mainPrincipal + * * @return array */ - function getPrincipalMembership($mainPrincipal) { - + public function getPrincipalMembership($mainPrincipal) + { // First check our cache if (isset($this->principalMembershipCache[$mainPrincipal])) { return $this->principalMembershipCache[$mainPrincipal]; @@ -335,31 +332,23 @@ class Plugin extends DAV\ServerPlugin { $principals = []; while (count($check)) { - $principal = array_shift($check); $node = $this->server->tree->getNodeForPath($principal); if ($node instanceof IPrincipal) { foreach ($node->getGroupMembership() as $groupMember) { - if (!in_array($groupMember, $principals)) { - $check[] = $groupMember; $principals[] = $groupMember; - } - } - } - } // Store the result in the cache $this->principalMembershipCache[$mainPrincipal] = $principals; return $principals; - } /** @@ -381,24 +370,27 @@ class Plugin extends DAV\ServerPlugin { * * @param string $checkPrincipal * @param string $currentPrincipal + * * @return bool */ - function principalMatchesPrincipal($checkPrincipal, $currentPrincipal = null) { - + public function principalMatchesPrincipal($checkPrincipal, $currentPrincipal = null) + { if (is_null($currentPrincipal)) { $currentPrincipal = $this->getCurrentUserPrincipal(); } if ($currentPrincipal === $checkPrincipal) { return true; } + if (is_null($currentPrincipal)) { + return false; + } + return in_array( $checkPrincipal, $this->getPrincipalMembership($currentPrincipal) ); - } - /** * Returns a tree of supported privileges for a resource. * @@ -436,10 +428,11 @@ class Plugin extends DAV\ServerPlugin { * ] * * @param string|INode $node + * * @return array */ - function getSupportedPrivilegeSet($node) { - + public function getSupportedPrivilegeSet($node) + { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } @@ -450,35 +443,34 @@ class Plugin extends DAV\ServerPlugin { } if (is_null($supportedPrivileges)) { - // Default $supportedPrivileges = [ '{DAV:}read' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [ '{DAV:}read-acl' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], '{DAV:}read-current-user-privilege-set' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], ], ], '{DAV:}write' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [ '{DAV:}write-properties' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], '{DAV:}write-content' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], '{DAV:}unlock' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], ], @@ -486,21 +478,20 @@ class Plugin extends DAV\ServerPlugin { ]; if ($node instanceof DAV\ICollection) { $supportedPrivileges['{DAV:}write']['aggregates']['{DAV:}bind'] = [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ]; $supportedPrivileges['{DAV:}write']['aggregates']['{DAV:}unbind'] = [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ]; } if ($node instanceof IACL) { $supportedPrivileges['{DAV:}write']['aggregates']['{DAV:}write-acl'] = [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ]; } - } $this->server->emit( @@ -509,11 +500,10 @@ class Plugin extends DAV\ServerPlugin { ); return $supportedPrivileges; - } /** - * Returns the supported privilege set as a flat list + * Returns the supported privilege set as a flat list. * * This is much easier to parse. * @@ -524,54 +514,44 @@ class Plugin extends DAV\ServerPlugin { * - concrete * * @param string|INode $node + * * @return array */ - final function getFlatPrivilegeSet($node) { - + final public function getFlatPrivilegeSet($node) + { $privs = [ - 'abstract' => false, - 'aggregates' => $this->getSupportedPrivilegeSet($node) + 'abstract' => false, + 'aggregates' => $this->getSupportedPrivilegeSet($node), ]; $fpsTraverse = null; - $fpsTraverse = function($privName, $privInfo, $concrete, &$flat) use (&$fpsTraverse) { - + $fpsTraverse = function ($privName, $privInfo, $concrete, &$flat) use (&$fpsTraverse) { $myPriv = [ - 'privilege' => $privName, - 'abstract' => isset($privInfo['abstract']) && $privInfo['abstract'], + 'privilege' => $privName, + 'abstract' => isset($privInfo['abstract']) && $privInfo['abstract'], 'aggregates' => [], - 'concrete' => isset($privInfo['abstract']) && $privInfo['abstract'] ? $concrete : $privName, + 'concrete' => isset($privInfo['abstract']) && $privInfo['abstract'] ? $concrete : $privName, ]; if (isset($privInfo['aggregates'])) { - foreach ($privInfo['aggregates'] as $subPrivName => $subPrivInfo) { - $myPriv['aggregates'][] = $subPrivName; - } - } $flat[$privName] = $myPriv; if (isset($privInfo['aggregates'])) { - foreach ($privInfo['aggregates'] as $subPrivName => $subPrivInfo) { - $fpsTraverse($subPrivName, $subPrivInfo, $myPriv['concrete'], $flat); - } - } - }; $flat = []; $fpsTraverse('{DAV:}all', $privs, null, $flat); return $flat; - } /** @@ -582,10 +562,11 @@ class Plugin extends DAV\ServerPlugin { * null will be returned if the node doesn't support ACLs. * * @param string|DAV\INode $node + * * @return array */ - function getAcl($node) { - + public function getAcl($node) + { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } @@ -600,8 +581,8 @@ class Plugin extends DAV\ServerPlugin { 'protected' => true, ]; } - return $acl; + return $acl; } /** @@ -613,10 +594,11 @@ class Plugin extends DAV\ServerPlugin { * null will be returned if the node doesn't support ACLs. * * @param string|DAV\INode $node + * * @return array */ - function getCurrentUserPrivilegeSet($node) { - + public function getCurrentUserPrivilegeSet($node) + { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } @@ -625,50 +607,44 @@ class Plugin extends DAV\ServerPlugin { $collected = []; - $isAuthenticated = $this->getCurrentUserPrincipal() !== null; + $isAuthenticated = null !== $this->getCurrentUserPrincipal(); foreach ($acl as $ace) { - $principal = $ace['principal']; switch ($principal) { - - case '{DAV:}owner' : + case '{DAV:}owner': $owner = $node->getOwner(); if ($owner && $this->principalMatchesPrincipal($owner)) { $collected[] = $ace; } break; - // 'all' matches for every user - case '{DAV:}all' : + case '{DAV:}all': $collected[] = $ace; break; - case '{DAV:}authenticated' : + case '{DAV:}authenticated': // Authenticated users only if ($isAuthenticated) { $collected[] = $ace; } break; - case '{DAV:}unauthenticated' : + case '{DAV:}unauthenticated': // Unauthenticated users only if (!$isAuthenticated) { $collected[] = $ace; } break; - default : + default: if ($this->principalMatchesPrincipal($ace['principal'])) { $collected[] = $ace; } break; - } - - } // Now we deduct all aggregated privileges. @@ -676,41 +652,37 @@ class Plugin extends DAV\ServerPlugin { $collected2 = []; while (count($collected)) { - $current = array_pop($collected); $collected2[] = $current['privilege']; if (!isset($flat[$current['privilege']])) { // Ignoring privileges that are not in the supported-privileges list. - $this->server->getLogger()->debug('A node has the "' . $current['privilege'] . '" in its ACL list, but this privilege was not reported in the supportedPrivilegeSet list. This will be ignored.'); + $this->server->getLogger()->debug('A node has the "'.$current['privilege'].'" in its ACL list, but this privilege was not reported in the supportedPrivilegeSet list. This will be ignored.'); continue; } foreach ($flat[$current['privilege']]['aggregates'] as $subPriv) { $collected2[] = $subPriv; $collected[] = $flat[$subPriv]; } - } return array_values(array_unique($collected2)); - } - /** * Returns a principal based on its uri. * * Returns null if the principal could not be found. * * @param string $uri - * @return null|string + * + * @return string|null */ - function getPrincipalByUri($uri) { - + public function getPrincipalByUri($uri) + { $result = null; $collections = $this->principalCollectionSet; foreach ($collections as $collection) { - try { $principalCollection = $this->server->tree->getNodeForPath($collection); } catch (NotFound $e) { @@ -728,36 +700,35 @@ class Plugin extends DAV\ServerPlugin { if ($result) { return $result; } - } - } /** - * Principal property search + * Principal property search. * * This method can search for principals matching certain values in * properties. * * This method will return a list of properties for the matched properties. * - * @param array $searchProperties The properties to search on. This is a - * key-value list. The keys are property - * names, and the values the strings to - * match them on. - * @param array $requestedProperties This is the list of properties to - * return for every match. - * @param string $collectionUri The principal collection to search on. - * If this is ommitted, the standard - * principal collection-set will be used. - * @param string $test "allof" to use AND to search the - * properties. 'anyof' for OR. - * @return array This method returns an array structure similar to - * Sabre\DAV\Server::getPropertiesForPath. Returned - * properties are index by a HTTP status code. + * @param array $searchProperties The properties to search on. This is a + * key-value list. The keys are property + * names, and the values the strings to + * match them on. + * @param array $requestedProperties this is the list of properties to + * return for every match + * @param string $collectionUri the principal collection to search on. + * If this is ommitted, the standard + * principal collection-set will be used + * @param string $test "allof" to use AND to search the + * properties. 'anyof' for OR. + * + * @return array This method returns an array structure similar to + * Sabre\DAV\Server::getPropertiesForPath. Returned + * properties are index by a HTTP status code. */ - function principalSearch(array $searchProperties, array $requestedProperties, $collectionUri = null, $test = 'allof') { - + public function principalSearch(array $searchProperties, array $requestedProperties, $collectionUri = null, $test = 'allof') + { if (!is_null($collectionUri)) { $uris = [$collectionUri]; } else { @@ -766,7 +737,6 @@ class Plugin extends DAV\ServerPlugin { $lookupResults = []; foreach ($uris as $uri) { - $principalCollection = $this->server->tree->getNodeForPath($uri); if (!$principalCollection instanceof IPrincipalCollection) { // Not a principal collection, we're simply going to ignore @@ -776,33 +746,28 @@ class Plugin extends DAV\ServerPlugin { $results = $principalCollection->searchPrincipals($searchProperties, $test); foreach ($results as $result) { - $lookupResults[] = rtrim($uri, '/') . '/' . $result; + $lookupResults[] = rtrim($uri, '/').'/'.$result; } - } $matches = []; foreach ($lookupResults as $lookupResult) { - list($matches[]) = $this->server->getPropertiesForPath($lookupResult, $requestedProperties, 0); - } return $matches; - } /** - * Sets up the plugin + * Sets up the plugin. * * This method is automatically called by the server class. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { if ($this->allowUnauthenticatedAccess) { $authPlugin = $server->getPlugin('auth'); if (!$authPlugin) { @@ -812,22 +777,22 @@ class Plugin extends DAV\ServerPlugin { } $this->server = $server; - $server->on('propFind', [$this, 'propFind'], 20); - $server->on('beforeMethod', [$this, 'beforeMethod'], 20); - $server->on('beforeBind', [$this, 'beforeBind'], 20); - $server->on('beforeUnbind', [$this, 'beforeUnbind'], 20); - $server->on('propPatch', [$this, 'propPatch']); - $server->on('beforeUnlock', [$this, 'beforeUnlock'], 20); - $server->on('report', [$this, 'report']); - $server->on('method:ACL', [$this, 'httpAcl']); - $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); - $server->on('getPrincipalByUri', function($principal, &$uri) { - + $server->on('propFind', [$this, 'propFind'], 20); + $server->on('beforeMethod:*', [$this, 'beforeMethod'], 20); + $server->on('beforeBind', [$this, 'beforeBind'], 20); + $server->on('beforeUnbind', [$this, 'beforeUnbind'], 20); + $server->on('propPatch', [$this, 'propPatch']); + $server->on('beforeUnlock', [$this, 'beforeUnlock'], 20); + $server->on('report', [$this, 'report']); + $server->on('method:ACL', [$this, 'httpAcl']); + $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); + $server->on('getPrincipalByUri', function ($principal, &$uri) { $uri = $this->getPrincipalByUri($principal); // Break event chain - if ($uri) return false; - + if ($uri) { + return false; + } }); array_push($server->protectedProperties, @@ -858,39 +823,38 @@ class Plugin extends DAV\ServerPlugin { $server->xml->elementMap['{DAV:}principal-property-search'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalPropertySearchReport'; $server->xml->elementMap['{DAV:}principal-search-property-set'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalSearchPropertySetReport'; $server->xml->elementMap['{DAV:}principal-match'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalMatchReport'; - } /* {{{ Event handlers */ /** - * Triggered before any method is handled + * Triggered before any method is handled. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function beforeMethod(RequestInterface $request, ResponseInterface $response) { - + public function beforeMethod(RequestInterface $request, ResponseInterface $response) + { $method = $request->getMethod(); $path = $request->getPath(); $exists = $this->server->tree->nodeExists($path); // If the node doesn't exists, none of these checks apply - if (!$exists) return; + if (!$exists) { + return; + } switch ($method) { - - case 'GET' : - case 'HEAD' : - case 'OPTIONS' : + case 'GET': + case 'HEAD': + case 'OPTIONS': // For these 3 we only need to know if the node is readable. $this->checkPrivileges($path, '{DAV:}read'); break; - case 'PUT' : - case 'LOCK' : + case 'PUT': + case 'LOCK': // This method requires the write-content priv if the node // already exists, and bind on the parent if the node is being // created. @@ -898,20 +862,20 @@ class Plugin extends DAV\ServerPlugin { $this->checkPrivileges($path, '{DAV:}write-content'); break; - case 'UNLOCK' : + case 'UNLOCK': // Unlock is always allowed at the moment. break; - case 'PROPPATCH' : + case 'PROPPATCH': $this->checkPrivileges($path, '{DAV:}write-properties'); break; - case 'ACL' : + case 'ACL': $this->checkPrivileges($path, '{DAV:}write-acl'); break; - case 'COPY' : - case 'MOVE' : + case 'COPY': + case 'MOVE': // Copy requires read privileges on the entire source tree. // If the target exists write-content normally needs to be // checked, however, we're deleting the node beforehand and @@ -925,9 +889,7 @@ class Plugin extends DAV\ServerPlugin { // the sourcenode can be deleted. $this->checkPrivileges($path, '{DAV:}read', self::R_RECURSIVE); break; - } - } /** @@ -937,54 +899,49 @@ class Plugin extends DAV\ServerPlugin { * new node, such as PUT, MKCOL, MKCALENDAR, LOCK, COPY and MOVE. * * @param string $uri - * @return void */ - function beforeBind($uri) { - + public function beforeBind($uri) + { list($parentUri) = Uri\split($uri); $this->checkPrivileges($parentUri, '{DAV:}bind'); - } /** - * Triggered before a node is deleted + * Triggered before a node is deleted. * * This allows us to check permissions for any operation that will delete * an existing node. * * @param string $uri - * @return void */ - function beforeUnbind($uri) { - + public function beforeUnbind($uri) + { list($parentUri) = Uri\split($uri); $this->checkPrivileges($parentUri, '{DAV:}unbind', self::R_RECURSIVEPARENTS); - } /** * Triggered before a node is unlocked. * - * @param string $uri + * @param string $uri * @param DAV\Locks\LockInfo $lock * @TODO: not yet implemented - * @return void */ - function beforeUnlock($uri, DAV\Locks\LockInfo $lock) { - - + public function beforeUnlock($uri, DAV\Locks\LockInfo $lock) + { } /** * Triggered before properties are looked up in specific nodes. * * @param DAV\PropFind $propFind - * @param DAV\INode $node + * @param DAV\INode $node * @TODO really should be broken into multiple methods, or even a class. + * * @return bool */ - function propFind(DAV\PropFind $propFind, DAV\INode $node) { - + public function propFind(DAV\PropFind $propFind, DAV\INode $node) + { $path = $propFind->getPath(); // Checking the read permission @@ -1004,95 +961,95 @@ class Plugin extends DAV\ServerPlugin { } return; - } /* Adding principal properties */ if ($node instanceof IPrincipal) { - - $propFind->handle('{DAV:}alternate-URI-set', function() use ($node) { + $propFind->handle('{DAV:}alternate-URI-set', function () use ($node) { return new Href($node->getAlternateUriSet()); }); - $propFind->handle('{DAV:}principal-URL', function() use ($node) { - return new Href($node->getPrincipalUrl() . '/'); + $propFind->handle('{DAV:}principal-URL', function () use ($node) { + return new Href($node->getPrincipalUrl().'/'); }); - $propFind->handle('{DAV:}group-member-set', function() use ($node) { + $propFind->handle('{DAV:}group-member-set', function () use ($node) { $members = $node->getGroupMemberSet(); foreach ($members as $k => $member) { - $members[$k] = rtrim($member, '/') . '/'; + $members[$k] = rtrim($member, '/').'/'; } + return new Href($members); }); - $propFind->handle('{DAV:}group-membership', function() use ($node) { + $propFind->handle('{DAV:}group-membership', function () use ($node) { $members = $node->getGroupMembership(); foreach ($members as $k => $member) { - $members[$k] = rtrim($member, '/') . '/'; + $members[$k] = rtrim($member, '/').'/'; } + return new Href($members); }); $propFind->handle('{DAV:}displayname', [$node, 'getDisplayName']); - } - $propFind->handle('{DAV:}principal-collection-set', function() { - + $propFind->handle('{DAV:}principal-collection-set', function () { $val = $this->principalCollectionSet; // Ensuring all collections end with a slash - foreach ($val as $k => $v) $val[$k] = $v . '/'; - return new Href($val); + foreach ($val as $k => $v) { + $val[$k] = $v.'/'; + } + return new Href($val); }); - $propFind->handle('{DAV:}current-user-principal', function() { + $propFind->handle('{DAV:}current-user-principal', function () { if ($url = $this->getCurrentUserPrincipal()) { - return new Xml\Property\Principal(Xml\Property\Principal::HREF, $url . '/'); + return new Xml\Property\Principal(Xml\Property\Principal::HREF, $url.'/'); } else { return new Xml\Property\Principal(Xml\Property\Principal::UNAUTHENTICATED); } }); - $propFind->handle('{DAV:}supported-privilege-set', function() use ($node) { + $propFind->handle('{DAV:}supported-privilege-set', function () use ($node) { return new Xml\Property\SupportedPrivilegeSet($this->getSupportedPrivilegeSet($node)); }); - $propFind->handle('{DAV:}current-user-privilege-set', function() use ($node, $propFind, $path) { + $propFind->handle('{DAV:}current-user-privilege-set', function () use ($node, $propFind, $path) { if (!$this->checkPrivileges($path, '{DAV:}read-current-user-privilege-set', self::R_PARENT, false)) { $propFind->set('{DAV:}current-user-privilege-set', null, 403); } else { $val = $this->getCurrentUserPrivilegeSet($node); + return new Xml\Property\CurrentUserPrivilegeSet($val); } }); - $propFind->handle('{DAV:}acl', function() use ($node, $propFind, $path) { + $propFind->handle('{DAV:}acl', function () use ($node, $propFind, $path) { /* The ACL property contains all the permissions */ if (!$this->checkPrivileges($path, '{DAV:}read-acl', self::R_PARENT, false)) { $propFind->set('{DAV:}acl', null, 403); } else { $acl = $this->getACL($node); + return new Xml\Property\Acl($this->getACL($node)); } }); - $propFind->handle('{DAV:}acl-restrictions', function() { + $propFind->handle('{DAV:}acl-restrictions', function () { return new Xml\Property\AclRestrictions(); }); /* Adding ACL properties */ if ($node instanceof IACL) { - $propFind->handle('{DAV:}owner', function() use ($node) { - return new Href($node->getOwner() . '/'); + $propFind->handle('{DAV:}owner', function () use ($node) { + return new Href($node->getOwner().'/'); }); } - } /** * This method intercepts PROPPATCH methods and make sure the * group-member-set is updated correctly. * - * @param string $path + * @param string $path * @param DAV\PropPatch $propPatch - * @return void */ - function propPatch($path, DAV\PropPatch $propPatch) { - - $propPatch->handle('{DAV:}group-member-set', function($value) use ($path) { + public function propPatch($path, DAV\PropPatch $propPatch) + { + $propPatch->handle('{DAV:}group-member-set', function ($value) use ($path) { if (is_null($value)) { $memberSet = []; } elseif ($value instanceof Href) { @@ -1116,55 +1073,58 @@ class Plugin extends DAV\ServerPlugin { return true; }); - } /** - * This method handles HTTP REPORT requests + * This method handles HTTP REPORT requests. * * @param string $reportName - * @param mixed $report - * @param mixed $path + * @param mixed $report + * @param mixed $path + * * @return bool */ - function report($reportName, $report, $path) { - + public function report($reportName, $report, $path) + { switch ($reportName) { - - case '{DAV:}principal-property-search' : + case '{DAV:}principal-property-search': $this->server->transactionType = 'report-principal-property-search'; $this->principalPropertySearchReport($path, $report); + return false; - case '{DAV:}principal-search-property-set' : + case '{DAV:}principal-search-property-set': $this->server->transactionType = 'report-principal-search-property-set'; $this->principalSearchPropertySetReport($path, $report); + return false; - case '{DAV:}expand-property' : + case '{DAV:}expand-property': $this->server->transactionType = 'report-expand-property'; $this->expandPropertyReport($path, $report); + return false; - case '{DAV:}principal-match' : + case '{DAV:}principal-match': $this->server->transactionType = 'report-principal-match'; $this->principalMatchReport($path, $report); + return false; - case '{DAV:}acl-principal-prop-set' : + case '{DAV:}acl-principal-prop-set': $this->server->transactionType = 'acl-principal-prop-set'; $this->aclPrincipalPropSetReport($path, $report); - return false; + return false; } - } /** * This method is responsible for handling the 'ACL' event. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpAcl(RequestInterface $request, ResponseInterface $response) { - + public function httpAcl(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $body = $request->getBodyAsString(); @@ -1192,8 +1152,9 @@ class Plugin extends DAV\ServerPlugin { /* Checking if protected principals from the existing principal set are not overwritten. */ foreach ($oldAcl as $oldAce) { - - if (!isset($oldAce['protected']) || !$oldAce['protected']) continue; + if (!isset($oldAce['protected']) || !$oldAce['protected']) { + continue; + } $found = false; foreach ($newAcl as $newAce) { @@ -1201,36 +1162,35 @@ class Plugin extends DAV\ServerPlugin { $newAce['privilege'] === $oldAce['privilege'] && $newAce['principal'] === $oldAce['principal'] && $newAce['protected'] - ) - $found = true; + ) { + $found = true; + } } - if (!$found) + if (!$found) { throw new Exception\AceConflict('This resource contained a protected {DAV:}ace, but this privilege did not occur in the ACL request'); - + } } foreach ($newAcl as $newAce) { - // Do we recognize the privilege if (!isset($supportedPrivileges[$newAce['privilege']])) { - throw new Exception\NotSupportedPrivilege('The privilege you specified (' . $newAce['privilege'] . ') is not recognized by this server'); + throw new Exception\NotSupportedPrivilege('The privilege you specified ('.$newAce['privilege'].') is not recognized by this server'); } if ($supportedPrivileges[$newAce['privilege']]['abstract']) { - throw new Exception\NoAbstract('The privilege you specified (' . $newAce['privilege'] . ') is an abstract privilege'); + throw new Exception\NoAbstract('The privilege you specified ('.$newAce['privilege'].') is an abstract privilege'); } // Looking up the principal try { $principal = $this->server->tree->getNodeForPath($newAce['principal']); } catch (NotFound $e) { - throw new Exception\NotRecognizedPrincipal('The specified principal (' . $newAce['principal'] . ') does not exist'); + throw new Exception\NotRecognizedPrincipal('The specified principal ('.$newAce['principal'].') does not exist'); } if (!($principal instanceof IPrincipal)) { - throw new Exception\NotRecognizedPrincipal('The specified uri (' . $newAce['principal'] . ') is not a principal'); + throw new Exception\NotRecognizedPrincipal('The specified uri ('.$newAce['principal'].') is not a principal'); } - } $node->setACL($newAcl); @@ -1238,7 +1198,6 @@ class Plugin extends DAV\ServerPlugin { // Breaking the event chain, because we handled this method. return false; - } /* }}} */ @@ -1252,14 +1211,13 @@ class Plugin extends DAV\ServerPlugin { * or a principal URL, the principal URL and principal URLs of groups that * principal belongs to. * - * @param string $path + * @param string $path * @param Xml\Request\PrincipalMatchReport $report - * @return void */ - protected function principalMatchReport($path, Xml\Request\PrincipalMatchReport $report) { - + protected function principalMatchReport($path, Xml\Request\PrincipalMatchReport $report) + { $depth = $this->server->getHTTPDepth(0); - if ($depth !== 0) { + if (0 !== $depth) { throw new BadRequest('The principal-match report is only defined on Depth: 0'); } @@ -1267,20 +1225,15 @@ class Plugin extends DAV\ServerPlugin { $result = []; - if ($report->type === Xml\Request\PrincipalMatchReport::SELF) { - + if (Xml\Request\PrincipalMatchReport::SELF === $report->type) { // Finding all principals under the request uri that match the // current principal. foreach ($currentPrincipals as $currentPrincipal) { - - if ($currentPrincipal === $path || strpos($currentPrincipal, $path . '/') === 0) { + if ($currentPrincipal === $path || 0 === strpos($currentPrincipal, $path.'/')) { $result[] = $currentPrincipal; } - } - } else { - // We need to find all resources that have a property that matches // one of the current principals. $candidates = $this->server->getPropertiesForPath( @@ -1290,7 +1243,6 @@ class Plugin extends DAV\ServerPlugin { ); foreach ($candidates as $candidate) { - if (!isset($candidate[200][$report->principalProperty])) { continue; } @@ -1308,23 +1260,19 @@ class Plugin extends DAV\ServerPlugin { } } } - } $responses = []; foreach ($result as $item) { - $properties = []; if ($report->properties) { - $foo = $this->server->getPropertiesForPath($item, $report->properties); $foo = $foo[0]; $item = $foo['href']; unset($foo['href']); $properties = $foo; - } $responses[] = new DAV\Xml\Element\Response( @@ -1332,7 +1280,6 @@ class Plugin extends DAV\ServerPlugin { $properties, '200' ); - } $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); @@ -1344,8 +1291,6 @@ class Plugin extends DAV\ServerPlugin { $this->server->getBaseUri() ) ); - - } /** @@ -1359,12 +1304,11 @@ class Plugin extends DAV\ServerPlugin { * Other rfc's, such as ACL rely on this report, so it made sense to put * it in this plugin. * - * @param string $path + * @param string $path * @param Xml\Request\ExpandPropertyReport $report - * @return void */ - protected function expandPropertyReport($path, $report) { - + protected function expandPropertyReport($path, $report) + { $depth = $this->server->getHTTPDepth(0); $result = $this->expandProperties($path, $report->properties, $depth); @@ -1377,34 +1321,36 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setBody($xml); - } /** * This method expands all the properties and returns - * a list with property values + * a list with property values. * * @param array $path * @param array $requestedProperties the list of required properties - * @param int $depth + * @param int $depth + * * @return array */ - protected function expandProperties($path, array $requestedProperties, $depth) { - + protected function expandProperties($path, array $requestedProperties, $depth) + { $foundProperties = $this->server->getPropertiesForPath($path, array_keys($requestedProperties), $depth); $result = []; foreach ($foundProperties as $node) { - foreach ($requestedProperties as $propertyName => $childRequestedProperties) { - // We're only traversing if sub-properties were requested - if (count($childRequestedProperties) === 0) continue; + if (!is_array($childRequestedProperties) || 0 === count($childRequestedProperties)) { + continue; + } // We only have to do the expansion if the property was found // and it contains an href element. - if (!array_key_exists($propertyName, $node[200])) continue; + if (!array_key_exists($propertyName, $node[200])) { + continue; + } if (!$node[200][$propertyName] instanceof DAV\Xml\Property\Href) { continue; @@ -1416,39 +1362,35 @@ class Plugin extends DAV\ServerPlugin { foreach ($childHrefs as $href) { // Gathering the result of the children $childProps[] = [ - 'name' => '{DAV:}response', - 'value' => $this->expandProperties($href, $childRequestedProperties, 0)[0] + 'name' => '{DAV:}response', + 'value' => $this->expandProperties($href, $childRequestedProperties, 0)[0], ]; } // Replacing the property with its expanded form. $node[200][$propertyName] = $childProps; - } $result[] = new DAV\Xml\Element\Response($node['href'], $node); - } return $result; - } /** - * principalSearchPropertySetReport + * principalSearchPropertySetReport. * * This method responsible for handing the * {DAV:}principal-search-property-set report. This report returns a list * of properties the client may search on, using the * {DAV:}principal-property-search report. * - * @param string $path + * @param string $path * @param Xml\Request\PrincipalSearchPropertySetReport $report - * @return void */ - protected function principalSearchPropertySetReport($path, $report) { - + protected function principalSearchPropertySetReport($path, $report) + { $httpDepth = $this->server->getHTTPDepth(0); - if ($httpDepth !== 0) { + if (0 !== $httpDepth) { throw new DAV\Exception\BadRequest('This report is only defined when Depth: 0'); } @@ -1459,7 +1401,6 @@ class Plugin extends DAV\ServerPlugin { $writer->startElement('{DAV:}principal-search-property-set'); foreach ($this->principalSearchPropertySet as $propertyName => $description) { - $writer->startElement('{DAV:}principal-search-property'); $writer->startElement('{DAV:}prop'); @@ -1469,15 +1410,13 @@ class Plugin extends DAV\ServerPlugin { if ($description) { $writer->write([[ - 'name' => '{DAV:}description', - 'value' => $description, - 'attributes' => ['xml:lang' => 'en'] + 'name' => '{DAV:}description', + 'value' => $description, + 'attributes' => ['xml:lang' => 'en'], ]]); } $writer->endElement(); // principal-search-property - - } $writer->endElement(); // principal-search-property-set @@ -1485,27 +1424,25 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setStatus(200); $this->server->httpResponse->setBody($writer->outputMemory()); - } /** - * principalPropertySearchReport + * principalPropertySearchReport. * * This method is responsible for handing the * {DAV:}principal-property-search report. This report can be used for * clients to search for groups of principals, based on the value of one * or more properties. * - * @param string $path + * @param string $path * @param Xml\Request\PrincipalPropertySearchReport $report - * @return void */ - protected function principalPropertySearchReport($path, Xml\Request\PrincipalPropertySearchReport $report) { - + protected function principalPropertySearchReport($path, Xml\Request\PrincipalPropertySearchReport $report) + { if ($report->applyToPrincipalCollectionSet) { $path = null; } - if ($this->server->getHttpDepth('0') !== 0) { + if (0 !== $this->server->getHttpDepth('0')) { throw new BadRequest('Depth must be 0'); } $result = $this->principalSearch( @@ -1520,12 +1457,11 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer'); - $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, $prefer['return'] === 'minimal')); - + $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, 'minimal' === $prefer['return'])); } /** - * aclPrincipalPropSet REPORT + * aclPrincipalPropSet REPORT. * * This method is responsible for handling the {DAV:}acl-principal-prop-set * REPORT, as defined in: @@ -1537,13 +1473,12 @@ class Plugin extends DAV\ServerPlugin { * is used to for example generate a UI with ACL rules, allowing you * to show names for principals for every entry. * - * @param string $path + * @param string $path * @param Xml\Request\AclPrincipalPropSetReport $report - * @return void */ - protected function aclPrincipalPropSetReport($path, Xml\Request\AclPrincipalPropSetReport $report) { - - if ($this->server->getHTTPDepth(0) !== 0) { + protected function aclPrincipalPropSetReport($path, Xml\Request\AclPrincipalPropSetReport $report) + { + if (0 !== $this->server->getHTTPDepth(0)) { throw new BadRequest('The {DAV:}acl-principal-prop-set REPORT only supports Depth 0'); } @@ -1558,14 +1493,12 @@ class Plugin extends DAV\ServerPlugin { $principals = []; foreach ($acl['{DAV:}acl']->getPrivileges() as $ace) { - - if ($ace['principal'][0] === '{') { + if ('{' === $ace['principal'][0]) { // It's not a principal, it's one of the special rules such as {DAV:}authenticated continue; } $principals[] = $ace['principal']; - } $properties = $this->server->getPropertiesForMultiplePaths( @@ -1578,10 +1511,8 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setBody( $this->server->generateMultiStatus($properties) ); - } - /* }}} */ /** @@ -1590,13 +1521,15 @@ class Plugin extends DAV\ServerPlugin { * can use to create new calendars. * * @param DAV\INode $node - * @param string $output + * @param string $output + * * @return bool */ - function htmlActionsPanel(DAV\INode $node, &$output) { - - if (!$node instanceof PrincipalCollection) + public function htmlActionsPanel(DAV\INode $node, &$output) + { + if (!$node instanceof PrincipalCollection) { return; + } $output .= '<tr><td colspan="2"><form method="post" action=""> <h3>Create new principal</h3> @@ -1610,7 +1543,6 @@ class Plugin extends DAV\ServerPlugin { </td></tr>'; return false; - } /** @@ -1624,13 +1556,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 ACL (rfc3744)', - 'link' => 'http://sabre.io/dav/acl/', + 'link' => 'http://sabre.io/dav/acl/', ]; - } } diff --git a/vendor/sabre/dav/lib/DAVACL/Principal.php b/vendor/sabre/dav/lib/DAVACL/Principal.php index d7db94999..e2df1c35e 100644 --- a/vendor/sabre/dav/lib/DAVACL/Principal.php +++ b/vendor/sabre/dav/lib/DAVACL/Principal.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * Principal class + * Principal class. * * This class is a representation of a simple principal * @@ -20,8 +22,8 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { - +class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL +{ use ACLTrait; /** @@ -32,93 +34,86 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { protected $principalProperties; /** - * Principal backend + * Principal backend. * * @var PrincipalBackend\BackendInterface */ protected $principalBackend; /** - * Creates the principal object + * Creates the principal object. * * @param PrincipalBackend\BackendInterface $principalBackend - * @param array $principalProperties + * @param array $principalProperties */ - function __construct(PrincipalBackend\BackendInterface $principalBackend, array $principalProperties = []) { - + public function __construct(PrincipalBackend\BackendInterface $principalBackend, array $principalProperties = []) + { if (!isset($principalProperties['uri'])) { throw new DAV\Exception('The principal properties must at least contain the \'uri\' key'); } $this->principalBackend = $principalBackend; $this->principalProperties = $principalProperties; - } /** - * Returns the full principal url + * Returns the full principal url. * * @return string */ - function getPrincipalUrl() { - + public function getPrincipalUrl() + { return $this->principalProperties['uri']; - } /** - * Returns a list of alternative urls for a principal + * Returns a list of alternative urls for a principal. * * This can for example be an email address, or ldap url. * * @return array */ - function getAlternateUriSet() { - + public function getAlternateUriSet() + { $uris = []; if (isset($this->principalProperties['{DAV:}alternate-URI-set'])) { - $uris = $this->principalProperties['{DAV:}alternate-URI-set']; - } if (isset($this->principalProperties['{http://sabredav.org/ns}email-address'])) { - $uris[] = 'mailto:' . $this->principalProperties['{http://sabredav.org/ns}email-address']; + $uris[] = 'mailto:'.$this->principalProperties['{http://sabredav.org/ns}email-address']; } return array_unique($uris); - } /** - * Returns the list of group members + * Returns the list of group members. * * If this principal is a group, this function should return * all member principal uri's for the group. * * @return array */ - function getGroupMemberSet() { - + public function getGroupMemberSet() + { return $this->principalBackend->getGroupMemberSet($this->principalProperties['uri']); - } /** - * Returns the list of groups this principal is member of + * Returns the list of groups this principal is member of. * * If this principal is a member of a (list of) groups, this function * should return a list of principal uri's for it's members. * * @return array */ - function getGroupMembership() { - + public function getGroupMembership() + { return $this->principalBackend->getGroupMemberShip($this->principalProperties['uri']); - } /** - * Sets a list of group members + * Sets a list of group members. * * If this principal is a group, this method sets all the group members. * The list of members is always overwritten, never appended to. @@ -126,12 +121,10 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { * This method should throw an exception if the members could not be set. * * @param array $groupMembers - * @return void */ - function setGroupMemberSet(array $groupMembers) { - + public function setGroupMemberSet(array $groupMembers) + { $this->principalBackend->setGroupMemberSet($this->principalProperties['uri'], $groupMembers); - } /** @@ -139,48 +132,45 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { * * @return string */ - function getName() { - + public function getName() + { $uri = $this->principalProperties['uri']; - list(, $name) = URLUtil::splitPath($uri); - return $name; + list(, $name) = Uri\split($uri); + return $name; } /** - * Returns the name of the user + * Returns the name of the user. * * @return string */ - function getDisplayName() { - + public function getDisplayName() + { if (isset($this->principalProperties['{DAV:}displayname'])) { return $this->principalProperties['{DAV:}displayname']; } else { return $this->getName(); } - } /** - * Returns a list of properties + * Returns a list of properties. * * @param array $requestedProperties + * * @return array */ - function getProperties($requestedProperties) { - + public function getProperties($requestedProperties) + { $newProperties = []; foreach ($requestedProperties as $propName) { - if (isset($this->principalProperties[$propName])) { $newProperties[$propName] = $this->principalProperties[$propName]; } - } return $newProperties; - } /** @@ -193,29 +183,24 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { * Read the PropPatch documentation for more information. * * @param DAV\PropPatch $propPatch - * @return void */ - function propPatch(DAV\PropPatch $propPatch) { - + public function propPatch(DAV\PropPatch $propPatch) + { return $this->principalBackend->updatePrincipal( $this->principalProperties['uri'], $propPatch ); - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->principalProperties['uri']; - - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php index 9bf9ba445..03a9c4bad 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; /** - * Abstract Principal Backend + * Abstract Principal Backend. * * Currently this class has no function. It's here for consistency and so we * have a non-bc-breaking way to add a default generic implementation to @@ -13,8 +15,8 @@ namespace Sabre\DAVACL\PrincipalBackend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface { - +abstract class AbstractBackend implements BackendInterface +{ /** * Finds a principal by its URI. * @@ -30,13 +32,14 @@ abstract class AbstractBackend implements BackendInterface { * * @param string $uri * @param string $principalPrefix + * * @return string */ - function findByUri($uri, $principalPrefix) { - + public function findByUri($uri, $principalPrefix) + { // Note that the default implementation here is a bit slow and could // likely be optimized. - if (substr($uri, 0, 7) !== 'mailto:') { + if ('mailto:' !== substr($uri, 0, 7)) { return; } $result = $this->searchPrincipals( @@ -47,7 +50,5 @@ abstract class AbstractBackend implements BackendInterface { if ($result) { return $result[0]; } - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php index 40b6e33ea..40ac272b5 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; /** @@ -13,8 +15,8 @@ namespace Sabre\DAVACL\PrincipalBackend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * Returns a list of principals based on a prefix. * @@ -29,9 +31,10 @@ interface BackendInterface { * you have an email address, use this property. * * @param string $prefixPath + * * @return array */ - function getPrincipalsByPrefix($prefixPath); + public function getPrincipalsByPrefix($prefixPath); /** * Returns a specific principal, specified by it's path. @@ -39,9 +42,10 @@ interface BackendInterface { * getPrincipalsByPrefix. * * @param string $path + * * @return array */ - function getPrincipalByPath($path); + public function getPrincipalByPath($path); /** * Updates one ore more webdav properties on a principal. @@ -55,11 +59,10 @@ interface BackendInterface { * * Read the PropPatch documentation for more info and examples. * - * @param string $path + * @param string $path * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch); + public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch); /** * This method is used to search for principals matching a set of @@ -86,11 +89,12 @@ interface BackendInterface { * from working. * * @param string $prefixPath - * @param array $searchProperties + * @param array $searchProperties * @param string $test + * * @return array */ - function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof'); + public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof'); /** * Finds a principal by its URI. @@ -107,25 +111,28 @@ interface BackendInterface { * * @param string $uri * @param string $principalPrefix + * * @return string */ - function findByUri($uri, $principalPrefix); + public function findByUri($uri, $principalPrefix); /** - * Returns the list of members for a group-principal + * Returns the list of members for a group-principal. * * @param string $principal + * * @return array */ - function getGroupMemberSet($principal); + public function getGroupMemberSet($principal); /** - * Returns the list of groups a principal is a member of + * Returns the list of groups a principal is a member of. * * @param string $principal + * * @return array */ - function getGroupMembership($principal); + public function getGroupMembership($principal); /** * Updates the list of group members for a group principal. @@ -133,9 +140,7 @@ interface BackendInterface { * The principals should be passed as a list of uri's. * * @param string $principal - * @param array $members - * @return void + * @param array $members */ - function setGroupMemberSet($principal, array $members); - + public function setGroupMemberSet($principal, array $members); } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php index e354a697d..ee418e49b 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; use Sabre\DAV\MkCol; @@ -12,8 +14,8 @@ use Sabre\DAV\MkCol; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface CreatePrincipalSupport extends BackendInterface { - +interface CreatePrincipalSupport extends BackendInterface +{ /** * Creates a new principal. * @@ -22,9 +24,7 @@ interface CreatePrincipalSupport extends BackendInterface { * of the principal. * * @param string $path - * @param MkCol $mkCol - * @return void + * @param MkCol $mkCol */ - function createPrincipal($path, MkCol $mkCol); - + public function createPrincipal($path, MkCol $mkCol); } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php index eb0df888b..350ecb145 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; use Sabre\DAV; use Sabre\DAV\MkCol; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * PDO principal backend + * PDO principal backend. * * * This backend assumes all principals are in a single collection. The default collection @@ -17,44 +19,43 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend implements CreatePrincipalSupport { - +class PDO extends AbstractBackend implements CreatePrincipalSupport +{ /** - * PDO table name for 'principals' + * PDO table name for 'principals'. * * @var string */ public $tableName = 'principals'; /** - * PDO table name for 'group members' + * PDO table name for 'group members'. * * @var string */ public $groupMembersTableName = 'groupmembers'; /** - * pdo + * pdo. * * @var PDO */ protected $pdo; /** - * A list of additional fields to support + * A list of additional fields to support. * * @var array */ protected $fieldMap = [ - - /** + /* * This property can be used to display the users' real name. */ '{DAV:}displayname' => [ 'dbField' => 'displayname', ], - /** + /* * This is the users' primary email-address. */ '{http://sabredav.org/ns}email-address' => [ @@ -67,10 +68,9 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -87,10 +87,11 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * you have an email address, use this property. * * @param string $prefixPath + * * @return array */ - function getPrincipalsByPrefix($prefixPath) { - + public function getPrincipalsByPrefix($prefixPath) + { $fields = [ 'uri', ]; @@ -98,15 +99,16 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { foreach ($this->fieldMap as $key => $value) { $fields[] = $value['dbField']; } - $result = $this->pdo->query('SELECT ' . implode(',', $fields) . ' FROM ' . $this->tableName); + $result = $this->pdo->query('SELECT '.implode(',', $fields).' FROM '.$this->tableName); $principals = []; while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { - // Checking if the principal is in the prefix - list($rowPrefix) = URLUtil::splitPath($row['uri']); - if ($rowPrefix !== $prefixPath) continue; + list($rowPrefix) = Uri\split($row['uri']); + if ($rowPrefix !== $prefixPath) { + continue; + } $principal = [ 'uri' => $row['uri'], @@ -117,11 +119,9 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { } } $principals[] = $principal; - } return $principals; - } /** @@ -130,10 +130,11 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * getPrincipalsByPrefix. * * @param string $path + * * @return array */ - function getPrincipalByPath($path) { - + public function getPrincipalByPath($path) + { $fields = [ 'id', 'uri', @@ -142,14 +143,16 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { foreach ($this->fieldMap as $key => $value) { $fields[] = $value['dbField']; } - $stmt = $this->pdo->prepare('SELECT ' . implode(',', $fields) . ' FROM ' . $this->tableName . ' WHERE uri = ?'); + $stmt = $this->pdo->prepare('SELECT '.implode(',', $fields).' FROM '.$this->tableName.' WHERE uri = ?'); $stmt->execute([$path]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if (!$row) return; + if (!$row) { + return; + } $principal = [ - 'id' => $row['id'], + 'id' => $row['id'], 'uri' => $row['uri'], ]; foreach ($this->fieldMap as $key => $value) { @@ -157,8 +160,8 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { $principal[$key] = $row[$value['dbField']]; } } - return $principal; + return $principal; } /** @@ -173,41 +176,36 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * * Read the PropPatch documentation for more info and examples. * - * @param string $path + * @param string $path * @param DAV\PropPatch $propPatch */ - function updatePrincipal($path, DAV\PropPatch $propPatch) { - - $propPatch->handle(array_keys($this->fieldMap), function($properties) use ($path) { - - $query = "UPDATE " . $this->tableName . " SET "; + public function updatePrincipal($path, DAV\PropPatch $propPatch) + { + $propPatch->handle(array_keys($this->fieldMap), function ($properties) use ($path) { + $query = 'UPDATE '.$this->tableName.' SET '; $first = true; $values = []; foreach ($properties as $key => $value) { - $dbField = $this->fieldMap[$key]['dbField']; if (!$first) { $query .= ', '; } $first = false; - $query .= $dbField . ' = :' . $dbField; + $query .= $dbField.' = :'.$dbField; $values[$dbField] = $value; - } - $query .= " WHERE uri = :uri"; + $query .= ' WHERE uri = :uri'; $values['uri'] = $path; $stmt = $this->pdo->prepare($query); $stmt->execute($values); return true; - }); - } /** @@ -235,48 +233,52 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * from working. * * @param string $prefixPath - * @param array $searchProperties + * @param array $searchProperties * @param string $test + * * @return array */ - function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') { - if (count($searchProperties) == 0) return []; //No criteria + public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') + { + if (0 == count($searchProperties)) { + return []; + } //No criteria - $query = 'SELECT uri FROM ' . $this->tableName . ' WHERE '; + $query = 'SELECT uri FROM '.$this->tableName.' WHERE '; $values = []; foreach ($searchProperties as $property => $value) { switch ($property) { - case '{DAV:}displayname' : - $column = "displayname"; + case '{DAV:}displayname': + $column = 'displayname'; break; - case '{http://sabredav.org/ns}email-address' : - $column = "email"; + case '{http://sabredav.org/ns}email-address': + $column = 'email'; break; - default : + default: // Unsupported property return []; } - if (count($values) > 0) $query .= (strcmp($test, "anyof") == 0 ? " OR " : " AND "); - $query .= 'lower(' . $column . ') LIKE lower(?)'; - $values[] = '%' . $value . '%'; - + if (count($values) > 0) { + $query .= (0 == strcmp($test, 'anyof') ? ' OR ' : ' AND '); + } + $query .= 'lower('.$column.') LIKE lower(?)'; + $values[] = '%'.$value.'%'; } $stmt = $this->pdo->prepare($query); $stmt->execute($values); $principals = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - // Checking if the principal is in the prefix - list($rowPrefix) = URLUtil::splitPath($row['uri']); - if ($rowPrefix !== $prefixPath) continue; + list($rowPrefix) = Uri\split($row['uri']); + if ($rowPrefix !== $prefixPath) { + continue; + } $principals[] = $row['uri']; - } return $principals; - } /** @@ -294,26 +296,32 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * * @param string $uri * @param string $principalPrefix + * * @return string */ - function findByUri($uri, $principalPrefix) { + public function findByUri($uri, $principalPrefix) + { $value = null; $scheme = null; - list($scheme, $value) = explode(":", $uri, 2); - if (empty($value)) return null; + list($scheme, $value) = explode(':', $uri, 2); + if (empty($value)) { + return null; + } $uri = null; - switch ($scheme){ - case "mailto": - $query = 'SELECT uri FROM ' . $this->tableName . ' WHERE lower(email)=lower(?)'; + switch ($scheme) { + case 'mailto': + $query = 'SELECT uri FROM '.$this->tableName.' WHERE lower(email)=lower(?)'; $stmt = $this->pdo->prepare($query); $stmt->execute([$value]); - + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { // Checking if the principal is in the prefix - list($rowPrefix) = URLUtil::splitPath($row['uri']); - if ($rowPrefix !== $principalPrefix) continue; - + list($rowPrefix) = Uri\split($row['uri']); + if ($rowPrefix !== $principalPrefix) { + continue; + } + $uri = $row['uri']; break; //Stop on first match } @@ -322,51 +330,56 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { //unsupported uri scheme return null; } + return $uri; } /** - * Returns the list of members for a group-principal + * Returns the list of members for a group-principal. * * @param string $principal + * * @return array */ - function getGroupMemberSet($principal) { - + public function getGroupMemberSet($principal) + { $principal = $this->getPrincipalByPath($principal); - if (!$principal) throw new DAV\Exception('Principal not found'); - - $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM ' . $this->groupMembersTableName . ' AS groupmembers LEFT JOIN ' . $this->tableName . ' AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.principal_id = ?'); + if (!$principal) { + throw new DAV\Exception('Principal not found'); + } + $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM '.$this->groupMembersTableName.' AS groupmembers LEFT JOIN '.$this->tableName.' AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.principal_id = ?'); $stmt->execute([$principal['id']]); $result = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row['uri']; } - return $result; + return $result; } /** - * Returns the list of groups a principal is a member of + * Returns the list of groups a principal is a member of. * * @param string $principal + * * @return array */ - function getGroupMembership($principal) { - + public function getGroupMembership($principal) + { $principal = $this->getPrincipalByPath($principal); - if (!$principal) throw new DAV\Exception('Principal not found'); - - $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM ' . $this->groupMembersTableName . ' AS groupmembers LEFT JOIN ' . $this->tableName . ' AS principals ON groupmembers.principal_id = principals.id WHERE groupmembers.member_id = ?'); + if (!$principal) { + throw new DAV\Exception('Principal not found'); + } + $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM '.$this->groupMembersTableName.' AS groupmembers LEFT JOIN '.$this->tableName.' AS principals ON groupmembers.principal_id = principals.id WHERE groupmembers.member_id = ?'); $stmt->execute([$principal['id']]); $result = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row['uri']; } - return $result; + return $result; } /** @@ -375,13 +388,12 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * The principals should be passed as a list of uri's. * * @param string $principal - * @param array $members - * @return void + * @param array $members */ - function setGroupMemberSet($principal, array $members) { - + public function setGroupMemberSet($principal, array $members) + { // Grabbing the list of principal id's. - $stmt = $this->pdo->prepare('SELECT id, uri FROM ' . $this->tableName . ' WHERE uri IN (? ' . str_repeat(', ? ', count($members)) . ');'); + $stmt = $this->pdo->prepare('SELECT id, uri FROM '.$this->tableName.' WHERE uri IN (? '.str_repeat(', ? ', count($members)).');'); $stmt->execute(array_merge([$principal], $members)); $memberIds = []; @@ -394,19 +406,17 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { $memberIds[] = $row['id']; } } - if (!$principalId) throw new DAV\Exception('Principal not found'); - + if (!$principalId) { + throw new DAV\Exception('Principal not found'); + } // Wiping out old members - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->groupMembersTableName . ' WHERE principal_id = ?;'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->groupMembersTableName.' WHERE principal_id = ?;'); $stmt->execute([$principalId]); foreach ($memberIds as $memberId) { - - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->groupMembersTableName . ' (principal_id, member_id) VALUES (?, ?);'); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->groupMembersTableName.' (principal_id, member_id) VALUES (?, ?);'); $stmt->execute([$principalId, $memberId]); - } - } /** @@ -417,15 +427,12 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * of the principal. * * @param string $path - * @param MkCol $mkCol - * @return void + * @param MkCol $mkCol */ - function createPrincipal($path, MkCol $mkCol) { - - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->tableName . ' (uri) VALUES (?)'); + public function createPrincipal($path, MkCol $mkCol) + { + $stmt = $this->pdo->prepare('INSERT INTO '.$this->tableName.' (uri) VALUES (?)'); $stmt->execute([$path]); $this->updatePrincipal($path, $mkCol); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php b/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php index ee5b88a90..4fae96e0c 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV\Exception\InvalidResourceType; @@ -7,7 +9,7 @@ use Sabre\DAV\IExtendedCollection; use Sabre\DAV\MkCol; /** - * Principals Collection + * Principals Collection. * * This collection represents a list of users. * The users are instances of Sabre\DAVACL\Principal @@ -16,8 +18,8 @@ use Sabre\DAV\MkCol; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalCollection extends AbstractPrincipalCollection implements IExtendedCollection, IACL { - +class PrincipalCollection extends AbstractPrincipalCollection implements IExtendedCollection, IACL +{ use ACLTrait; /** @@ -28,12 +30,12 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend * supplied by the authentication backend. * * @param array $principal + * * @return \Sabre\DAV\INode */ - function getChildForPrincipal(array $principal) { - + public function getChildForPrincipal(array $principal) + { return new Principal($this->principalBackend, $principal); - } /** @@ -56,21 +58,20 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend * property for you. * * @param string $name - * @param MkCol $mkCol + * @param MkCol $mkCol + * * @throws InvalidResourceType - * @return void */ - function createExtendedCollection($name, MkCol $mkCol) { - + public function createExtendedCollection($name, MkCol $mkCol) + { if (!$mkCol->hasResourceType('{DAV:}principal')) { throw new InvalidResourceType('Only resources of type {DAV:}principal may be created here'); } $this->principalBackend->createPrincipal( - $this->principalPrefix . '/' . $name, + $this->principalPrefix.'/'.$name, $mkCol ); - } /** @@ -85,7 +86,8 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend * * @return array */ - function getACL() { + public function getACL() + { return [ [ 'principal' => '{DAV:}authenticated', @@ -94,5 +96,4 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend ], ]; } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php index 0e1c30ccf..372f62ab3 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\DAV; @@ -25,10 +27,10 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Acl implements Element, HtmlOutput { - +class Acl implements Element, HtmlOutput +{ /** - * List of privileges + * List of privileges. * * @var array */ @@ -43,7 +45,7 @@ class Acl implements Element, HtmlOutput { protected $prefixBaseUrl; /** - * Constructor + * Constructor. * * This object requires a structure similar to the return value from * Sabre\DAVACL\Plugin::getACL(). @@ -57,24 +59,22 @@ class Acl implements Element, HtmlOutput { * will automatically be prefixed. * * @param array $privileges - * @param bool $prefixBaseUrl + * @param bool $prefixBaseUrl */ - function __construct(array $privileges, $prefixBaseUrl = true) { - + public function __construct(array $privileges, $prefixBaseUrl = true) + { $this->privileges = $privileges; $this->prefixBaseUrl = $prefixBaseUrl; - } /** - * Returns the list of privileges for this property + * Returns the list of privileges for this property. * * @return array */ - function getPrivileges() { - + public function getPrivileges() + { return $this->privileges; - } /** @@ -94,16 +94,12 @@ class Acl 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->privileges as $ace) { - $this->serializeAce($writer, $ace); - } - } /** @@ -118,32 +114,33 @@ class Acl implements Element, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { ob_start(); - echo "<table>"; - echo "<tr><th>Principal</th><th>Privilege</th><th></th></tr>"; + echo '<table>'; + echo '<tr><th>Principal</th><th>Privilege</th><th></th></tr>'; foreach ($this->privileges as $privilege) { - echo '<tr>'; // if it starts with a {, it's a special principal - if ($privilege['principal'][0] === '{') { + if ('{' === $privilege['principal'][0]) { echo '<td>', $html->xmlName($privilege['principal']), '</td>'; } else { echo '<td>', $html->link($privilege['principal']), '</td>'; } echo '<td>', $html->xmlName($privilege['privilege']), '</td>'; echo '<td>'; - if (!empty($privilege['protected'])) echo '(protected)'; + if (!empty($privilege['protected'])) { + echo '(protected)'; + } echo '</td>'; echo '</tr>'; - } - echo "</table>"; - return ob_get_clean(); + echo '</table>'; + return ob_get_clean(); } /** @@ -165,21 +162,21 @@ class Acl implements Element, HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elementMap = [ - '{DAV:}ace' => 'Sabre\Xml\Element\KeyValue', + '{DAV:}ace' => 'Sabre\Xml\Element\KeyValue', '{DAV:}privilege' => 'Sabre\Xml\Element\Elements', '{DAV:}principal' => 'Sabre\DAVACL\Xml\Property\Principal', ]; $privileges = []; - foreach ((array)$reader->parseInnerTree($elementMap) as $element) { - - if ($element['name'] !== '{DAV:}ace') { + foreach ((array) $reader->parseInnerTree($elementMap) as $element) { + if ('{DAV:}ace' !== $element['name']) { continue; } $ace = $element['value']; @@ -190,19 +187,18 @@ class Acl implements Element, HtmlOutput { $principal = $ace['{DAV:}principal']; switch ($principal->getType()) { - case Principal::HREF : + case Principal::HREF: $principal = $principal->getHref(); break; - case Principal::AUTHENTICATED : + case Principal::AUTHENTICATED: $principal = '{DAV:}authenticated'; break; - case Principal::UNAUTHENTICATED : + case Principal::UNAUTHENTICATED: $principal = '{DAV:}unauthenticated'; break; - case Principal::ALL : + case Principal::ALL: $principal = '{DAV:}all'; break; - } $protected = array_key_exists('{DAV:}protected', $ace); @@ -211,7 +207,7 @@ class Acl implements Element, HtmlOutput { throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported'); } foreach ($ace['{DAV:}grant'] as $elem) { - if ($elem['name'] !== '{DAV:}privilege') { + if ('{DAV:}privilege' !== $elem['name']) { continue; } @@ -222,34 +218,30 @@ class Acl implements Element, HtmlOutput { 'privilege' => $priv, ]; } - } - } return new self($privileges); - } /** * Serializes a single access control entry. * * @param Writer $writer - * @param array $ace - * @return void + * @param array $ace */ - private function serializeAce(Writer $writer, array $ace) { - + private function serializeAce(Writer $writer, array $ace) + { $writer->startElement('{DAV:}ace'); switch ($ace['principal']) { - case '{DAV:}authenticated' : + case '{DAV:}authenticated': $principal = new Principal(Principal::AUTHENTICATED); break; - case '{DAV:}unauthenticated' : + case '{DAV:}unauthenticated': $principal = new Principal(Principal::UNAUTHENTICATED); break; - case '{DAV:}all' : + case '{DAV:}all': $principal = new Principal(Principal::ALL); break; default: @@ -271,7 +263,5 @@ class Acl implements Element, HtmlOutput { } $writer->endElement(); // ace - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php index 8d5854c23..0bf16b431 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * AclRestrictions property + * AclRestrictions property. * * This property represents {DAV:}acl-restrictions, as defined in RFC3744. * @@ -14,8 +16,8 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AclRestrictions implements XmlSerializable { - +class AclRestrictions implements XmlSerializable +{ /** * The xmlSerialize method is called during xml writing. * @@ -33,13 +35,10 @@ class AclRestrictions 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:}grant-only'); $writer->writeElement('{DAV:}no-invert'); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php index 74c09cee1..083856330 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -9,7 +11,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * CurrentUserPrivilegeSet + * CurrentUserPrivilegeSet. * * This class represents the current-user-privilege-set property. When * requested, it contain all the privileges a user has on a specific node. @@ -18,26 +20,25 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CurrentUserPrivilegeSet implements Element, HtmlOutput { - +class CurrentUserPrivilegeSet implements Element, HtmlOutput +{ /** - * List of privileges + * List of privileges. * * @var array */ private $privileges; /** - * Creates the object + * Creates the object. * * Pass the privileges in clark-notation * * @param array $privileges */ - function __construct(array $privileges) { - + public function __construct(array $privileges) + { $this->privileges = $privileges; - } /** @@ -57,19 +58,14 @@ class CurrentUserPrivilegeSet 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->privileges as $privName) { - $writer->startElement('{DAV:}privilege'); $writer->writeElement($privName); $writer->endElement(); - } - - } /** @@ -77,12 +73,12 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * list. * * @param string $privilegeName + * * @return bool */ - function has($privilegeName) { - + public function has($privilegeName) + { return in_array($privilegeName, $this->privileges); - } /** @@ -90,10 +86,9 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * * @return array */ - function getValue() { - + public function getValue() + { return $this->privileges; - } /** @@ -115,21 +110,22 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $result = []; $tree = $reader->parseInnerTree(['{DAV:}privilege' => 'Sabre\\Xml\\Element\\Elements']); foreach ($tree as $element) { - if ($element['name'] !== '{DAV:}privilege') { + if ('{DAV:}privilege' !== $element['name']) { continue; } $result[] = $element['value'][0]; } - return new self($result); + return new self($result); } /** @@ -144,16 +140,14 @@ class CurrentUserPrivilegeSet implements Element, 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/DAVACL/Xml/Property/Principal.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php index 04d22165d..e304a2aed 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\DAV; @@ -9,7 +11,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * Principal property + * Principal property. * * The principal property represents a principal from RFC3744 (ACL). * The property can be used to specify a principal or pseudo principals. @@ -18,30 +20,30 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Principal extends DAV\Xml\Property\Href { - +class Principal extends DAV\Xml\Property\Href +{ /** - * To specify a not-logged-in user, use the UNAUTHENTICATED principal + * To specify a not-logged-in user, use the UNAUTHENTICATED principal. */ const UNAUTHENTICATED = 1; /** - * To specify any principal that is logged in, use AUTHENTICATED + * To specify any principal that is logged in, use AUTHENTICATED. */ const AUTHENTICATED = 2; /** - * Specific principals can be specified with the HREF + * Specific principals can be specified with the HREF. */ const HREF = 3; /** - * Everybody, basically + * Everybody, basically. */ const ALL = 4; /** - * Principal-type + * Principal-type. * * Must be one of the UNAUTHENTICATED, AUTHENTICATED or HREF constants. * @@ -56,34 +58,31 @@ class Principal extends DAV\Xml\Property\Href { * * 'href' is only required for the HREF type. * - * @param int $type + * @param int $type * @param string|null $href */ - function __construct($type, $href = null) { - + public function __construct($type, $href = null) + { $this->type = $type; - if ($type === self::HREF && is_null($href)) { + if (self::HREF === $type && is_null($href)) { throw new DAV\Exception('The href argument must be specified for the HREF principal type.'); } if ($href) { - $href = rtrim($href, '/') . '/'; + $href = rtrim($href, '/').'/'; parent::__construct($href); } - } /** - * Returns the principal type + * Returns the principal type. * * @return int */ - function getType() { - + public function getType() + { return $this->type; - } - /** * The xmlSerialize method is called during xml writing. * @@ -101,26 +100,23 @@ class Principal extends DAV\Xml\Property\Href { * 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->type) { - - case self::UNAUTHENTICATED : + case self::UNAUTHENTICATED: $writer->writeElement('{DAV:}unauthenticated'); break; - case self::AUTHENTICATED : + case self::AUTHENTICATED: $writer->writeElement('{DAV:}authenticated'); break; - case self::HREF : + case self::HREF: parent::xmlSerialize($writer); break; - case self::ALL : + case self::ALL: $writer->writeElement('{DAV:}all'); break; } - } /** @@ -135,22 +131,21 @@ class Principal extends DAV\Xml\Property\Href { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { switch ($this->type) { - - case self::UNAUTHENTICATED : + case self::UNAUTHENTICATED: return '<em>unauthenticated</em>'; - case self::AUTHENTICATED : + case self::AUTHENTICATED: return '<em>authenticated</em>'; - case self::HREF : + case self::HREF: return parent::toHtml($html); - case self::ALL : + case self::ALL: return '<em>all</em>'; } - } /** @@ -172,25 +167,24 @@ class Principal extends DAV\Xml\Property\Href { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $tree = $reader->parseInnerTree()[0]; switch ($tree['name']) { - case '{DAV:}unauthenticated' : + case '{DAV:}unauthenticated': return new self(self::UNAUTHENTICATED); - case '{DAV:}authenticated' : + case '{DAV:}authenticated': return new self(self::AUTHENTICATED); case '{DAV:}href': return new self(self::HREF, $tree['value']); case '{DAV:}all': return new self(self::ALL); - default : - throw new BadRequest('Unknown or unsupported principal type: ' . $tree['name']); + default: + throw new BadRequest('Unknown or unsupported principal type: '.$tree['name']); } - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php index b963cc8c3..1762391d9 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -8,7 +10,7 @@ use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * SupportedPrivilegeSet property + * SupportedPrivilegeSet property. * * This property encodes the {DAV:}supported-privilege-set property, as defined * in rfc3744. Please consult the rfc for details about it's structure. @@ -21,24 +23,23 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { - +class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput +{ /** - * privileges + * privileges. * * @var array */ protected $privileges; /** - * Constructor + * Constructor. * * @param array $privileges */ - function __construct(array $privileges) { - + public function __construct(array $privileges) + { $this->privileges = $privileges; - } /** @@ -46,10 +47,9 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { * * @return array */ - function getValue() { - + public function getValue() + { return $this->privileges; - } /** @@ -69,12 +69,10 @@ class SupportedPrivilegeSet 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) + { $this->serializePriv($writer, '{DAV:}all', ['aggregates' => $this->privileges]); - } /** @@ -89,52 +87,49 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - - $traverse = function($privName, $priv) use (&$traverse, $html) { - echo "<li>"; + public function toHtml(HtmlOutputHelper $html) + { + $traverse = function ($privName, $priv) use (&$traverse, $html) { + echo '<li>'; echo $html->xmlName($privName); if (isset($priv['abstract']) && $priv['abstract']) { - echo " <i>(abstract)</i>"; + echo ' <i>(abstract)</i>'; } if (isset($priv['description'])) { - echo " " . $html->h($priv['description']); + echo ' '.$html->h($priv['description']); } if (isset($priv['aggregates'])) { echo "\n<ul>\n"; foreach ($priv['aggregates'] as $subPrivName => $subPriv) { $traverse($subPrivName, $subPriv); } - echo "</ul>"; + echo '</ul>'; } echo "</li>\n"; }; ob_start(); - echo "<ul class=\"tree\">"; + echo '<ul class="tree">'; $traverse('{DAV:}all', ['aggregates' => $this->getValue()]); echo "</ul>\n"; return ob_get_clean(); - } - - /** - * Serializes a property + * Serializes a property. * * This is a recursive function. * * @param Writer $writer * @param string $privName - * @param array $privilege - * @return void + * @param array $privilege */ - private function serializePriv(Writer $writer, $privName, $privilege) { - + private function serializePriv(Writer $writer, $privName, $privilege) + { $writer->startElement('{DAV:}supported-privilege'); $writer->startElement('{DAV:}privilege'); @@ -154,7 +149,5 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { } $writer->endElement(); // supported-privilege - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php index 0aa2f29a5..17b37afab 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\Xml\Deserializer; @@ -17,8 +19,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (https://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AclPrincipalPropSetReport implements XmlDeserializable { - +class AclPrincipalPropSetReport implements XmlDeserializable +{ public $properties = []; /** @@ -40,10 +42,11 @@ class AclPrincipalPropSetReport 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:}prop'] = 'Sabre\Xml\Deserializer\enum'; @@ -61,7 +64,5 @@ class AclPrincipalPropSetReport implements XmlDeserializable { } return $report; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php index a9938ba5b..393308cd2 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\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 ExpandPropertyReport implements XmlDeserializable { - +class ExpandPropertyReport implements XmlDeserializable +{ /** * An array with requested properties. * @@ -51,17 +53,17 @@ class ExpandPropertyReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree(); $obj = new self(); $obj->properties = self::traverse($elems); return $obj; - } /** @@ -69,15 +71,15 @@ class ExpandPropertyReport implements XmlDeserializable { * {DAV:}property elements. * * @param array $elems - * @return void + * + * @return array */ - private static function traverse($elems) { - + private static function traverse($elems) + { $result = []; foreach ($elems as $elem) { - - if ($elem['name'] !== '{DAV:}property') { + if ('{DAV:}property' !== $elem['name']) { continue; } @@ -85,7 +87,7 @@ class ExpandPropertyReport implements XmlDeserializable { $elem['attributes']['namespace'] : 'DAV:'; - $propName = '{' . $namespace . '}' . $elem['attributes']['name']; + $propName = '{'.$namespace.'}'.$elem['attributes']['name']; $value = null; if (is_array($elem['value'])) { @@ -93,11 +95,8 @@ class ExpandPropertyReport implements XmlDeserializable { } $result[$propName] = $value; - } return $result; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php index 1be15ab2d..f868cc9df 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\Xml\Deserializer; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalMatchReport implements XmlDeserializable { - +class PrincipalMatchReport implements XmlDeserializable +{ /** * Report on a list of principals that match the current principal. */ @@ -31,7 +33,7 @@ class PrincipalMatchReport implements XmlDeserializable { const PRINCIPAL_PROPERTY = 2; /** - * Must be SELF or PRINCIPAL_PROPERTY + * Must be SELF or PRINCIPAL_PROPERTY. * * @var int */ @@ -71,10 +73,11 @@ class PrincipalMatchReport 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:}prop'] = 'Sabre\Xml\Deserializer\enum'; @@ -101,7 +104,5 @@ class PrincipalMatchReport implements XmlDeserializable { } return $principalMatch; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php index b0cf0e408..26468fd21 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\DAV\Exception\BadRequest; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalPropertySearchReport implements XmlDeserializable { - +class PrincipalPropertySearchReport implements XmlDeserializable +{ /** * The requested properties. * @@ -28,7 +30,7 @@ class PrincipalPropertySearchReport implements XmlDeserializable { public $properties; /** - * searchProperties + * searchProperties. * * @var array */ @@ -72,31 +74,30 @@ class PrincipalPropertySearchReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $foundSearchProp = false; $self->test = 'allof'; - if ($reader->getAttribute('test') === 'anyof') { + if ('anyof' === $reader->getAttribute('test')) { $self->test = 'anyof'; } $elemMap = [ '{DAV:}property-search' => 'Sabre\\Xml\\Element\\KeyValue', - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', ]; - - foreach ($reader->parseInnerTree($elemMap) as $elem) { + foreach ($reader->parseInnerTree($elemMap) as $elem) { switch ($elem['name']) { - - case '{DAV:}prop' : + case '{DAV:}prop': $self->properties = array_keys($elem['value']); break; - case '{DAV:}property-search' : + case '{DAV:}property-search': $foundSearchProp = true; // This property has two sub-elements: // {DAV:}prop - The property to be searched on. This may @@ -109,19 +110,15 @@ class PrincipalPropertySearchReport implements XmlDeserializable { $self->searchProperties[$propName] = $elem['value']['{DAV:}match']; } break; - case '{DAV:}apply-to-principal-collection-set' : + case '{DAV:}apply-to-principal-collection-set': $self->applyToPrincipalCollectionSet = true; break; - } - } if (!$foundSearchProp) { throw new BadRequest('The {DAV:}principal-property-search report must contain at least 1 {DAV:}property-search element'); } return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php index 64d1f7f86..37bc2cfbf 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\DAV\Exception\BadRequest; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalSearchPropertySetReport implements XmlDeserializable { - +class PrincipalSearchPropertySetReport implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -39,10 +41,11 @@ class PrincipalSearchPropertySetReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { if (!$reader->isEmptyElement) { throw new BadRequest('The {DAV:}principal-search-property-set element must be empty'); } @@ -51,8 +54,7 @@ class PrincipalSearchPropertySetReport implements XmlDeserializable { $reader->next(); $self = new self(); - return $self; + return $self; } - } |