aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/CardDAV
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/lib/CardDAV')
-rw-r--r--vendor/sabre/dav/lib/CardDAV/AddressBook.php141
-rw-r--r--vendor/sabre/dav/lib/CardDAV/AddressBookHome.php109
-rw-r--r--vendor/sabre/dav/lib/CardDAV/AddressBookRoot.php37
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Backend/AbstractBackend.php17
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php57
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Backend/PDO.php257
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php14
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Card.php104
-rw-r--r--vendor/sabre/dav/lib/CardDAV/IAddressBook.php8
-rw-r--r--vendor/sabre/dav/lib/CardDAV/ICard.php8
-rw-r--r--vendor/sabre/dav/lib/CardDAV/IDirectory.php8
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Plugin.php480
-rw-r--r--vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php74
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Xml/Filter/AddressData.php22
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Xml/Filter/ParamFilter.php41
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Xml/Filter/PropFilter.php49
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedAddressData.php28
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedCollationSet.php15
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php32
-rw-r--r--vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookQueryReport.php61
20 files changed, 741 insertions, 821 deletions
diff --git a/vendor/sabre/dav/lib/CardDAV/AddressBook.php b/vendor/sabre/dav/lib/CardDAV/AddressBook.php
index c9d28a091..434801554 100644
--- a/vendor/sabre/dav/lib/CardDAV/AddressBook.php
+++ b/vendor/sabre/dav/lib/CardDAV/AddressBook.php
@@ -1,12 +1,14 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV;
use Sabre\DAV;
use Sabre\DAVACL;
/**
- * The AddressBook class represents a CardDAV addressbook, owned by a specific user
+ * The AddressBook class represents a CardDAV addressbook, owned by a specific user.
*
* The AddressBook can contain multiple vcards
*
@@ -14,77 +16,78 @@ use Sabre\DAVACL;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class AddressBook extends DAV\Collection implements IAddressBook, DAV\IProperties, DAVACL\IACL, DAV\Sync\ISyncCollection, DAV\IMultiGet {
-
+class AddressBook extends DAV\Collection implements IAddressBook, DAV\IProperties, DAVACL\IACL, DAV\Sync\ISyncCollection, DAV\IMultiGet
+{
use DAVACL\ACLTrait;
/**
- * This is an array with addressbook information
+ * This is an array with addressbook information.
*
* @var array
*/
protected $addressBookInfo;
/**
- * CardDAV backend
+ * CardDAV backend.
*
* @var Backend\BackendInterface
*/
protected $carddavBackend;
/**
- * Constructor
+ * Constructor.
*
* @param Backend\BackendInterface $carddavBackend
- * @param array $addressBookInfo
+ * @param array $addressBookInfo
*/
- function __construct(Backend\BackendInterface $carddavBackend, array $addressBookInfo) {
-
+ public function __construct(Backend\BackendInterface $carddavBackend, array $addressBookInfo)
+ {
$this->carddavBackend = $carddavBackend;
$this->addressBookInfo = $addressBookInfo;
-
}
/**
- * Returns the name of the addressbook
+ * Returns the name of the addressbook.
*
* @return string
*/
- function getName() {
-
+ public function getName()
+ {
return $this->addressBookInfo['uri'];
-
}
/**
- * Returns a card
+ * Returns a card.
*
* @param string $name
+ *
* @return Card
*/
- function getChild($name) {
-
+ public function getChild($name)
+ {
$obj = $this->carddavBackend->getCard($this->addressBookInfo['id'], $name);
- if (!$obj) throw new DAV\Exception\NotFound('Card not found');
- return new Card($this->carddavBackend, $this->addressBookInfo, $obj);
+ if (!$obj) {
+ throw new DAV\Exception\NotFound('Card not found');
+ }
+ return new Card($this->carddavBackend, $this->addressBookInfo, $obj);
}
/**
- * Returns the full list of cards
+ * Returns the full list of cards.
*
* @return array
*/
- function getChildren() {
-
+ public function getChildren()
+ {
$objs = $this->carddavBackend->getCards($this->addressBookInfo['id']);
$children = [];
foreach ($objs as $obj) {
$obj['acl'] = $this->getChildACL();
$children[] = new Card($this->carddavBackend, $this->addressBookInfo, $obj);
}
- return $children;
+ return $children;
}
/**
@@ -94,47 +97,47 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie
* If any children are not found, you do not have to return them.
*
* @param string[] $paths
+ *
* @return array
*/
- function getMultipleChildren(array $paths) {
-
+ public function getMultipleChildren(array $paths)
+ {
$objs = $this->carddavBackend->getMultipleCards($this->addressBookInfo['id'], $paths);
$children = [];
foreach ($objs as $obj) {
$obj['acl'] = $this->getChildACL();
$children[] = new Card($this->carddavBackend, $this->addressBookInfo, $obj);
}
- return $children;
+ return $children;
}
/**
- * Creates a new directory
+ * Creates a new directory.
*
* We actually block this, as subdirectories are not allowed in addressbooks.
*
* @param string $name
- * @return void
*/
- function createDirectory($name) {
-
+ public function createDirectory($name)
+ {
throw new DAV\Exception\MethodNotAllowed('Creating collections in addressbooks is not allowed');
-
}
/**
- * Creates a new file
+ * Creates a new file.
*
* The contents of the new file must be a valid VCARD.
*
* This method may return an ETag.
*
- * @param string $name
+ * @param string $name
* @param resource $vcardData
+ *
* @return string|null
*/
- function createFile($name, $vcardData = null) {
-
+ public function createFile($name, $vcardData = null)
+ {
if (is_resource($vcardData)) {
$vcardData = stream_get_contents($vcardData);
}
@@ -142,41 +145,32 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie
$vcardData = DAV\StringUtil::ensureUTF8($vcardData);
return $this->carddavBackend->createCard($this->addressBookInfo['id'], $name, $vcardData);
-
}
/**
* Deletes the entire addressbook.
- *
- * @return void
*/
- function delete() {
-
+ public function delete()
+ {
$this->carddavBackend->deleteAddressBook($this->addressBookInfo['id']);
-
}
/**
- * Renames the addressbook
+ * Renames the addressbook.
*
* @param string $newName
- * @return void
*/
- function setName($newName) {
-
+ public function setName($newName)
+ {
throw new DAV\Exception\MethodNotAllowed('Renaming addressbooks is not yet supported');
-
}
/**
* Returns the last modification date as a unix timestamp.
- *
- * @return void
*/
- function getLastModified() {
-
+ public function getLastModified()
+ {
return null;
-
}
/**
@@ -189,12 +183,10 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie
* 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->carddavBackend->updateAddressBook($this->addressBookInfo['id'], $propPatch);
-
}
/**
@@ -206,39 +198,33 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie
* If the array is empty, it means 'all properties' were requested.
*
* @param array $properties
+ *
* @return array
*/
- function getProperties($properties) {
-
+ public function getProperties($properties)
+ {
$response = [];
foreach ($properties as $propertyName) {
-
if (isset($this->addressBookInfo[$propertyName])) {
-
$response[$propertyName] = $this->addressBookInfo[$propertyName];
-
}
-
}
return $response;
-
}
/**
- * 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->addressBookInfo['principaluri'];
-
}
-
/**
* This method returns the ACL's for card nodes in this address book.
* The result of this method automatically gets passed to the
@@ -246,8 +232,8 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie
*
* @return array
*/
- function getChildACL() {
-
+ public function getChildACL()
+ {
return [
[
'privilege' => '{DAV:}all',
@@ -255,10 +241,8 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie
'protected' => true,
],
];
-
}
-
/**
* This method returns the current sync-token for this collection.
* This can be any string.
@@ -268,8 +252,8 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie
*
* @return string|null
*/
- function getSyncToken() {
-
+ public function getSyncToken()
+ {
if (
$this->carddavBackend instanceof Backend\SyncSupport &&
isset($this->addressBookInfo['{DAV:}sync-token'])
@@ -282,7 +266,6 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie
) {
return $this->addressBookInfo['{http://sabredav.org/ns}sync-token'];
}
-
}
/**
@@ -336,12 +319,13 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie
* The limit is 'suggestive'. You are free to ignore it.
*
* @param string $syncToken
- * @param int $syncLevel
- * @param int $limit
+ * @param int $syncLevel
+ * @param int $limit
+ *
* @return array
*/
- function getChanges($syncToken, $syncLevel, $limit = null) {
-
+ public function getChanges($syncToken, $syncLevel, $limit = null)
+ {
if (!$this->carddavBackend instanceof Backend\SyncSupport) {
return null;
}
@@ -352,6 +336,5 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie
$syncLevel,
$limit
);
-
}
}
diff --git a/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php b/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php
index d770c0ffe..fb03000aa 100644
--- a/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php
+++ b/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV;
use Sabre\DAV;
@@ -8,7 +10,7 @@ use Sabre\DAVACL;
use Sabre\Uri;
/**
- * AddressBook Home class
+ * AddressBook Home class.
*
* This collection contains a list of addressbooks associated with one user.
*
@@ -16,81 +18,74 @@ use Sabre\Uri;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class AddressBookHome extends DAV\Collection implements DAV\IExtendedCollection, DAVACL\IACL {
-
+class AddressBookHome extends DAV\Collection implements DAV\IExtendedCollection, DAVACL\IACL
+{
use DAVACL\ACLTrait;
/**
- * Principal uri
+ * Principal uri.
*
* @var array
*/
protected $principalUri;
/**
- * carddavBackend
+ * carddavBackend.
*
* @var Backend\BackendInterface
*/
protected $carddavBackend;
/**
- * Constructor
+ * Constructor.
*
* @param Backend\BackendInterface $carddavBackend
- * @param string $principalUri
+ * @param string $principalUri
*/
- function __construct(Backend\BackendInterface $carddavBackend, $principalUri) {
-
+ public function __construct(Backend\BackendInterface $carddavBackend, $principalUri)
+ {
$this->carddavBackend = $carddavBackend;
$this->principalUri = $principalUri;
-
}
/**
- * Returns the name of this object
+ * Returns the name of this object.
*
* @return string
*/
- function getName() {
-
+ public function getName()
+ {
list(, $name) = Uri\split($this->principalUri);
- return $name;
+ return $name;
}
/**
- * Updates the name of this object
+ * Updates the name of this object.
*
* @param string $name
- * @return void
*/
- function setName($name) {
-
+ public function setName($name)
+ {
throw new DAV\Exception\MethodNotAllowed();
-
}
/**
- * Deletes this object
- *
- * @return void
+ * Deletes this object.
*/
- function delete() {
-
+ public function delete()
+ {
throw new DAV\Exception\MethodNotAllowed();
-
}
/**
- * Returns the last modification date
+ * Returns the last modification date.
*
* @return int
*/
- function getLastModified() {
-
+ public function getLastModified()
+ {
return null;
-
}
/**
@@ -98,14 +93,12 @@ class AddressBookHome extends DAV\Collection implements DAV\IExtendedCollection,
*
* This is currently not allowed
*
- * @param string $filename
+ * @param string $filename
* @param resource $data
- * @return void
*/
- function createFile($filename, $data = null) {
-
+ public function createFile($filename, $data = null)
+ {
throw new DAV\Exception\MethodNotAllowed('Creating new files in this collection is not supported');
-
}
/**
@@ -114,78 +107,74 @@ class AddressBookHome extends DAV\Collection implements DAV\IExtendedCollection,
* This is currently not allowed.
*
* @param string $filename
- * @return void
*/
- function createDirectory($filename) {
-
+ public function createDirectory($filename)
+ {
throw new DAV\Exception\MethodNotAllowed('Creating new collections in this collection is not supported');
-
}
/**
- * Returns a single addressbook, by name
+ * Returns a single addressbook, by name.
*
* @param string $name
+ *
* @todo needs optimizing
+ *
* @return AddressBook
*/
- function getChild($name) {
-
+ public function getChild($name)
+ {
foreach ($this->getChildren() as $child) {
- if ($name == $child->getName())
+ if ($name == $child->getName()) {
return $child;
-
+ }
}
- throw new DAV\Exception\NotFound('Addressbook with name \'' . $name . '\' could not be found');
-
+ throw new DAV\Exception\NotFound('Addressbook with name \''.$name.'\' could not be found');
}
/**
- * Returns a list of addressbooks
+ * Returns a list of addressbooks.
*
* @return array
*/
- function getChildren() {
-
+ public function getChildren()
+ {
$addressbooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri);
$objs = [];
foreach ($addressbooks as $addressbook) {
$objs[] = new AddressBook($this->carddavBackend, $addressbook);
}
- return $objs;
+ return $objs;
}
/**
* Creates a new address book.
*
* @param string $name
- * @param MkCol $mkCol
+ * @param MkCol $mkCol
+ *
* @throws DAV\Exception\InvalidResourceType
- * @return void
*/
- function createExtendedCollection($name, MkCol $mkCol) {
-
- if (!$mkCol->hasResourceType('{' . Plugin::NS_CARDDAV . '}addressbook')) {
+ public function createExtendedCollection($name, MkCol $mkCol)
+ {
+ if (!$mkCol->hasResourceType('{'.Plugin::NS_CARDDAV.'}addressbook')) {
throw new DAV\Exception\InvalidResourceType('Unknown resourceType for this collection');
}
$properties = $mkCol->getRemainingValues();
$mkCol->setRemainingResultCode(201);
$this->carddavBackend->createAddressBook($this->principalUri, $name, $properties);
-
}
/**
- * 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->principalUri;
-
}
-
}
diff --git a/vendor/sabre/dav/lib/CardDAV/AddressBookRoot.php b/vendor/sabre/dav/lib/CardDAV/AddressBookRoot.php
index a9f1183da..219f98906 100644
--- a/vendor/sabre/dav/lib/CardDAV/AddressBookRoot.php
+++ b/vendor/sabre/dav/lib/CardDAV/AddressBookRoot.php
@@ -1,11 +1,13 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV;
use Sabre\DAVACL;
/**
- * AddressBook rootnode
+ * AddressBook rootnode.
*
* This object lists a collection of users, which can contain addressbooks.
*
@@ -13,24 +15,24 @@ use Sabre\DAVACL;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class AddressBookRoot extends DAVACL\AbstractPrincipalCollection {
-
+class AddressBookRoot extends DAVACL\AbstractPrincipalCollection
+{
/**
- * Principal Backend
+ * Principal Backend.
*
* @var DAVACL\PrincipalBackend\BackendInterface
*/
protected $principalBackend;
/**
- * CardDAV backend
+ * CardDAV backend.
*
* @var Backend\BackendInterface
*/
protected $carddavBackend;
/**
- * Constructor
+ * Constructor.
*
* This constructor needs both a principal and a carddav backend.
*
@@ -40,25 +42,23 @@ class AddressBookRoot extends DAVACL\AbstractPrincipalCollection {
* to override this.
*
* @param DAVACL\PrincipalBackend\BackendInterface $principalBackend
- * @param Backend\BackendInterface $carddavBackend
- * @param string $principalPrefix
+ * @param Backend\BackendInterface $carddavBackend
+ * @param string $principalPrefix
*/
- function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $carddavBackend, $principalPrefix = 'principals') {
-
+ public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $carddavBackend, $principalPrefix = 'principals')
+ {
$this->carddavBackend = $carddavBackend;
parent::__construct($principalBackend, $principalPrefix);
-
}
/**
- * Returns the name of the node
+ * Returns the name of the node.
*
* @return string
*/
- function getName() {
-
+ public function getName()
+ {
return Plugin::ADDRESSBOOK_ROOT;
-
}
/**
@@ -69,12 +69,11 @@ class AddressBookRoot extends DAVACL\AbstractPrincipalCollection {
* supplied by the authentication backend.
*
* @param array $principal
+ *
* @return \Sabre\DAV\INode
*/
- function getChildForPrincipal(array $principal) {
-
+ public function getChildForPrincipal(array $principal)
+ {
return new AddressBookHome($this->carddavBackend, $principal['uri']);
-
}
-
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Backend/AbstractBackend.php b/vendor/sabre/dav/lib/CardDAV/Backend/AbstractBackend.php
index 03d2346da..6b041ade4 100644
--- a/vendor/sabre/dav/lib/CardDAV/Backend/AbstractBackend.php
+++ b/vendor/sabre/dav/lib/CardDAV/Backend/AbstractBackend.php
@@ -1,9 +1,11 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV\Backend;
/**
- * CardDAV abstract Backend
+ * CardDAV abstract Backend.
*
* This class serves as a base-class for addressbook backends
*
@@ -13,8 +15,8 @@ namespace Sabre\CardDAV\Backend;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-abstract class AbstractBackend implements BackendInterface {
-
+abstract class AbstractBackend implements BackendInterface
+{
/**
* Returns a list of cards.
*
@@ -25,14 +27,13 @@ abstract class AbstractBackend implements BackendInterface {
*
* @param mixed $addressBookId
* @param array $uris
+ *
* @return array
*/
- function getMultipleCards($addressBookId, array $uris) {
-
- return array_map(function($uri) use ($addressBookId) {
+ public function getMultipleCards($addressBookId, array $uris)
+ {
+ return array_map(function ($uri) use ($addressBookId) {
return $this->getCard($addressBookId, $uri);
}, $uris);
-
}
-
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php b/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php
index 18c0c0a99..804f09a36 100644
--- a/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php
+++ b/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php
@@ -1,9 +1,11 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV\Backend;
/**
- * CardDAV Backend Interface
+ * CardDAV Backend Interface.
*
* Any CardDAV backend must implement this interface.
*
@@ -15,8 +17,8 @@ namespace Sabre\CardDAV\Backend;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface BackendInterface {
-
+interface BackendInterface
+{
/**
* Returns the list of addressbooks for a specific user.
*
@@ -32,9 +34,10 @@ interface BackendInterface {
* {http://calendarserver.org/ns/}getctag
*
* @param string $principalUri
+ *
* @return array
*/
- function getAddressBooksForUser($principalUri);
+ public function getAddressBooksForUser($principalUri);
/**
* Updates properties for an address book.
@@ -48,11 +51,10 @@ interface BackendInterface {
*
* Read the PropPatch documentation for more info and examples.
*
- * @param string $addressBookId
+ * @param string $addressBookId
* @param \Sabre\DAV\PropPatch $propPatch
- * @return void
*/
- function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch);
+ public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch);
/**
* Creates a new address book.
@@ -61,19 +63,19 @@ interface BackendInterface {
* in any format, including ints, strings, arrays or objects.
*
* @param string $principalUri
- * @param string $url Just the 'basename' of the url.
- * @param array $properties
+ * @param string $url just the 'basename' of the url
+ * @param array $properties
+ *
* @return mixed
*/
- function createAddressBook($principalUri, $url, array $properties);
+ public function createAddressBook($principalUri, $url, array $properties);
/**
- * Deletes an entire addressbook and all its contents
+ * Deletes an entire addressbook and all its contents.
*
* @param mixed $addressBookId
- * @return void
*/
- function deleteAddressBook($addressBookId);
+ public function deleteAddressBook($addressBookId);
/**
* Returns all cards for a specific addressbook id.
@@ -92,9 +94,10 @@ interface BackendInterface {
* This may speed up certain requests, especially with large cards.
*
* @param mixed $addressbookId
+ *
* @return array
*/
- function getCards($addressbookId);
+ public function getCards($addressbookId);
/**
* Returns a specfic card.
@@ -104,11 +107,12 @@ interface BackendInterface {
*
* If the card does not exist, you must return false.
*
- * @param mixed $addressBookId
+ * @param mixed $addressBookId
* @param string $cardUri
+ *
* @return array
*/
- function getCard($addressBookId, $cardUri);
+ public function getCard($addressBookId, $cardUri);
/**
* Returns a list of cards.
@@ -120,9 +124,10 @@ interface BackendInterface {
*
* @param mixed $addressBookId
* @param array $uris
+ *
* @return array
*/
- function getMultipleCards($addressBookId, array $uris);
+ public function getMultipleCards($addressBookId, array $uris);
/**
* Creates a new card.
@@ -144,12 +149,13 @@ interface BackendInterface {
*
* If you don't return an ETag, you can just return null.
*
- * @param mixed $addressBookId
+ * @param mixed $addressBookId
* @param string $cardUri
* @param string $cardData
+ *
* @return string|null
*/
- function createCard($addressBookId, $cardUri, $cardData);
+ public function createCard($addressBookId, $cardUri, $cardData);
/**
* Updates a card.
@@ -171,20 +177,21 @@ interface BackendInterface {
*
* If you don't return an ETag, you can just return null.
*
- * @param mixed $addressBookId
+ * @param mixed $addressBookId
* @param string $cardUri
* @param string $cardData
+ *
* @return string|null
*/
- function updateCard($addressBookId, $cardUri, $cardData);
+ public function updateCard($addressBookId, $cardUri, $cardData);
/**
- * Deletes a card
+ * Deletes a card.
*
- * @param mixed $addressBookId
+ * @param mixed $addressBookId
* @param string $cardUri
+ *
* @return bool
*/
- function deleteCard($addressBookId, $cardUri);
-
+ public function deleteCard($addressBookId, $cardUri);
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Backend/PDO.php b/vendor/sabre/dav/lib/CardDAV/Backend/PDO.php
index 13487e9da..0659455e5 100644
--- a/vendor/sabre/dav/lib/CardDAV/Backend/PDO.php
+++ b/vendor/sabre/dav/lib/CardDAV/Backend/PDO.php
@@ -1,12 +1,14 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV\Backend;
use Sabre\CardDAV;
use Sabre\DAV;
/**
- * PDO CardDAV backend
+ * PDO CardDAV backend.
*
* This CardDAV backend uses PDO to store addressbooks
*
@@ -14,22 +16,22 @@ use Sabre\DAV;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class PDO extends AbstractBackend implements SyncSupport {
-
+class PDO extends AbstractBackend implements SyncSupport
+{
/**
- * PDO connection
+ * PDO connection.
*
* @var PDO
*/
protected $pdo;
/**
- * The PDO table name used to store addressbooks
+ * The PDO table name used to store addressbooks.
*/
public $addressBooksTableName = 'addressbooks';
/**
- * The PDO table name used to store cards
+ * The PDO table name used to store cards.
*/
public $cardsTableName = 'cards';
@@ -41,48 +43,44 @@ class PDO extends AbstractBackend implements SyncSupport {
public $addressBookChangesTableName = 'addressbookchanges';
/**
- * Sets up the object
+ * Sets up the object.
*
* @param \PDO $pdo
*/
- function __construct(\PDO $pdo) {
-
+ public function __construct(\PDO $pdo)
+ {
$this->pdo = $pdo;
-
}
/**
* Returns the list of addressbooks for a specific user.
*
* @param string $principalUri
+ *
* @return array
*/
- function getAddressBooksForUser($principalUri) {
-
- $stmt = $this->pdo->prepare('SELECT id, uri, displayname, principaluri, description, synctoken FROM ' . $this->addressBooksTableName . ' WHERE principaluri = ?');
+ public function getAddressBooksForUser($principalUri)
+ {
+ $stmt = $this->pdo->prepare('SELECT id, uri, displayname, principaluri, description, synctoken FROM '.$this->addressBooksTableName.' WHERE principaluri = ?');
$stmt->execute([$principalUri]);
$addressBooks = [];
foreach ($stmt->fetchAll() as $row) {
-
$addressBooks[] = [
- 'id' => $row['id'],
- 'uri' => $row['uri'],
- 'principaluri' => $row['principaluri'],
- '{DAV:}displayname' => $row['displayname'],
- '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
- '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
- '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
+ 'id' => $row['id'],
+ 'uri' => $row['uri'],
+ 'principaluri' => $row['principaluri'],
+ '{DAV:}displayname' => $row['displayname'],
+ '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
+ '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
+ '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
];
-
}
return $addressBooks;
-
}
-
/**
* Updates properties for an address book.
*
@@ -95,32 +93,29 @@ class PDO extends AbstractBackend implements SyncSupport {
*
* Read the PropPatch documentation for more info and examples.
*
- * @param string $addressBookId
+ * @param string $addressBookId
* @param \Sabre\DAV\PropPatch $propPatch
- * @return void
*/
- function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) {
-
+ public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch)
+ {
$supportedProperties = [
'{DAV:}displayname',
- '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description',
+ '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description',
];
- $propPatch->handle($supportedProperties, function($mutations) use ($addressBookId) {
-
+ $propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
$updates = [];
foreach ($mutations as $property => $newValue) {
-
switch ($property) {
- case '{DAV:}displayname' :
+ case '{DAV:}displayname':
$updates['displayname'] = $newValue;
break;
- case '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' :
+ case '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description':
$updates['description'] = $newValue;
break;
}
}
- $query = 'UPDATE ' . $this->addressBooksTableName . ' SET ';
+ $query = 'UPDATE '.$this->addressBooksTableName.' SET ';
$first = true;
foreach ($updates as $key => $value) {
if ($first) {
@@ -128,7 +123,7 @@ class PDO extends AbstractBackend implements SyncSupport {
} else {
$query .= ', ';
}
- $query .= ' ' . $key . ' = :' . $key . ' ';
+ $query .= ' '.$key.' = :'.$key.' ';
}
$query .= ' WHERE id = :addressbookid';
@@ -137,72 +132,67 @@ class PDO extends AbstractBackend implements SyncSupport {
$stmt->execute($updates);
- $this->addChange($addressBookId, "", 2);
+ $this->addChange($addressBookId, '', 2);
return true;
-
});
-
}
/**
- * Creates a new address book
+ * Creates a new address book.
*
* @param string $principalUri
- * @param string $url Just the 'basename' of the url.
- * @param array $properties
+ * @param string $url just the 'basename' of the url
+ * @param array $properties
+ *
* @return int Last insert id
*/
- function createAddressBook($principalUri, $url, array $properties) {
-
+ public function createAddressBook($principalUri, $url, array $properties)
+ {
$values = [
- 'displayname' => null,
- 'description' => null,
+ 'displayname' => null,
+ 'description' => null,
'principaluri' => $principalUri,
- 'uri' => $url,
+ 'uri' => $url,
];
foreach ($properties as $property => $newValue) {
-
switch ($property) {
- case '{DAV:}displayname' :
+ case '{DAV:}displayname':
$values['displayname'] = $newValue;
break;
- case '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' :
+ case '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description':
$values['description'] = $newValue;
break;
- default :
- throw new DAV\Exception\BadRequest('Unknown property: ' . $property);
+ default:
+ throw new DAV\Exception\BadRequest('Unknown property: '.$property);
}
-
}
- $query = 'INSERT INTO ' . $this->addressBooksTableName . ' (uri, displayname, description, principaluri, synctoken) VALUES (:uri, :displayname, :description, :principaluri, 1)';
+ $query = 'INSERT INTO '.$this->addressBooksTableName.' (uri, displayname, description, principaluri, synctoken) VALUES (:uri, :displayname, :description, :principaluri, 1)';
$stmt = $this->pdo->prepare($query);
$stmt->execute($values);
+
return $this->pdo->lastInsertId(
- $this->addressBooksTableName . '_id_seq'
+ $this->addressBooksTableName.'_id_seq'
);
-
}
/**
- * Deletes an entire addressbook and all its contents
+ * Deletes an entire addressbook and all its contents.
*
* @param int $addressBookId
- * @return void
*/
- function deleteAddressBook($addressBookId) {
-
- $stmt = $this->pdo->prepare('DELETE FROM ' . $this->cardsTableName . ' WHERE addressbookid = ?');
+ public function deleteAddressBook($addressBookId)
+ {
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->cardsTableName.' WHERE addressbookid = ?');
$stmt->execute([$addressBookId]);
- $stmt = $this->pdo->prepare('DELETE FROM ' . $this->addressBooksTableName . ' WHERE id = ?');
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->addressBooksTableName.' WHERE id = ?');
$stmt->execute([$addressBookId]);
- $stmt = $this->pdo->prepare('DELETE FROM ' . $this->addressBookChangesTableName . ' WHERE addressbookid = ?');
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->addressBookChangesTableName.' WHERE addressbookid = ?');
$stmt->execute([$addressBookId]);
-
}
/**
@@ -222,21 +212,22 @@ class PDO extends AbstractBackend implements SyncSupport {
* This may speed up certain requests, especially with large cards.
*
* @param mixed $addressbookId
+ *
* @return array
*/
- function getCards($addressbookId) {
-
- $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, size FROM ' . $this->cardsTableName . ' WHERE addressbookid = ?');
+ public function getCards($addressbookId)
+ {
+ $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, size FROM '.$this->cardsTableName.' WHERE addressbookid = ?');
$stmt->execute([$addressbookId]);
$result = [];
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
- $row['etag'] = '"' . $row['etag'] . '"';
- $row['lastmodified'] = (int)$row['lastmodified'];
+ $row['etag'] = '"'.$row['etag'].'"';
+ $row['lastmodified'] = (int) $row['lastmodified'];
$result[] = $row;
}
- return $result;
+ return $result;
}
/**
@@ -247,23 +238,26 @@ class PDO extends AbstractBackend implements SyncSupport {
*
* If the card does not exist, you must return false.
*
- * @param mixed $addressBookId
+ * @param mixed $addressBookId
* @param string $cardUri
+ *
* @return array
*/
- function getCard($addressBookId, $cardUri) {
-
- $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified, etag, size FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND uri = ? LIMIT 1');
+ public function getCard($addressBookId, $cardUri)
+ {
+ $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified, etag, size FROM '.$this->cardsTableName.' WHERE addressbookid = ? AND uri = ? LIMIT 1');
$stmt->execute([$addressBookId, $cardUri]);
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
- if (!$result) return false;
+ if (!$result) {
+ return false;
+ }
+
+ $result['etag'] = '"'.$result['etag'].'"';
+ $result['lastmodified'] = (int) $result['lastmodified'];
- $result['etag'] = '"' . $result['etag'] . '"';
- $result['lastmodified'] = (int)$result['lastmodified'];
return $result;
-
}
/**
@@ -276,11 +270,12 @@ class PDO extends AbstractBackend implements SyncSupport {
*
* @param mixed $addressBookId
* @param array $uris
+ *
* @return array
*/
- function getMultipleCards($addressBookId, array $uris) {
-
- $query = 'SELECT id, uri, lastmodified, etag, size, carddata FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND uri IN (';
+ public function getMultipleCards($addressBookId, array $uris)
+ {
+ $query = 'SELECT id, uri, lastmodified, etag, size, carddata FROM '.$this->cardsTableName.' WHERE addressbookid = ? AND uri IN (';
// Inserting a whole bunch of question marks
$query .= implode(',', array_fill(0, count($uris), '?'));
$query .= ')';
@@ -289,12 +284,12 @@ class PDO extends AbstractBackend implements SyncSupport {
$stmt->execute(array_merge([$addressBookId], $uris));
$result = [];
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
- $row['etag'] = '"' . $row['etag'] . '"';
- $row['lastmodified'] = (int)$row['lastmodified'];
+ $row['etag'] = '"'.$row['etag'].'"';
+ $row['lastmodified'] = (int) $row['lastmodified'];
$result[] = $row;
}
- return $result;
+ return $result;
}
/**
@@ -317,14 +312,15 @@ class PDO extends AbstractBackend implements SyncSupport {
*
* If you don't return an ETag, you can just return null.
*
- * @param mixed $addressBookId
+ * @param mixed $addressBookId
* @param string $cardUri
* @param string $cardData
+ *
* @return string|null
*/
- function createCard($addressBookId, $cardUri, $cardData) {
-
- $stmt = $this->pdo->prepare('INSERT INTO ' . $this->cardsTableName . ' (carddata, uri, lastmodified, addressbookid, size, etag) VALUES (?, ?, ?, ?, ?, ?)');
+ public function createCard($addressBookId, $cardUri, $cardData)
+ {
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->cardsTableName.' (carddata, uri, lastmodified, addressbookid, size, etag) VALUES (?, ?, ?, ?, ?, ?)');
$etag = md5($cardData);
@@ -339,8 +335,7 @@ class PDO extends AbstractBackend implements SyncSupport {
$this->addChange($addressBookId, $cardUri, 1);
- return '"' . $etag . '"';
-
+ return '"'.$etag.'"';
}
/**
@@ -363,14 +358,15 @@ class PDO extends AbstractBackend implements SyncSupport {
*
* If you don't return an ETag, you can just return null.
*
- * @param mixed $addressBookId
+ * @param mixed $addressBookId
* @param string $cardUri
* @param string $cardData
+ *
* @return string|null
*/
- function updateCard($addressBookId, $cardUri, $cardData) {
-
- $stmt = $this->pdo->prepare('UPDATE ' . $this->cardsTableName . ' SET carddata = ?, lastmodified = ?, size = ?, etag = ? WHERE uri = ? AND addressbookid =?');
+ public function updateCard($addressBookId, $cardUri, $cardData)
+ {
+ $stmt = $this->pdo->prepare('UPDATE '.$this->cardsTableName.' SET carddata = ?, lastmodified = ?, size = ?, etag = ? WHERE uri = ? AND addressbookid =?');
$etag = md5($cardData);
$stmt->execute([
@@ -379,31 +375,30 @@ class PDO extends AbstractBackend implements SyncSupport {
strlen($cardData),
$etag,
$cardUri,
- $addressBookId
+ $addressBookId,
]);
$this->addChange($addressBookId, $cardUri, 2);
- return '"' . $etag . '"';
-
+ return '"'.$etag.'"';
}
/**
- * Deletes a card
+ * Deletes a card.
*
- * @param mixed $addressBookId
+ * @param mixed $addressBookId
* @param string $cardUri
+ *
* @return bool
*/
- function deleteCard($addressBookId, $cardUri) {
-
- $stmt = $this->pdo->prepare('DELETE FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND uri = ?');
+ public function deleteCard($addressBookId, $cardUri)
+ {
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->cardsTableName.' WHERE addressbookid = ? AND uri = ?');
$stmt->execute([$addressBookId, $cardUri]);
$this->addChange($addressBookId, $cardUri, 3);
- return $stmt->rowCount() === 1;
-
+ return 1 === $stmt->rowCount();
}
/**
@@ -458,30 +453,34 @@ class PDO extends AbstractBackend implements SyncSupport {
*
* @param string $addressBookId
* @param string $syncToken
- * @param int $syncLevel
- * @param int $limit
+ * @param int $syncLevel
+ * @param int $limit
+ *
* @return array
*/
- function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) {
-
+ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null)
+ {
// Current synctoken
- $stmt = $this->pdo->prepare('SELECT synctoken FROM ' . $this->addressBooksTableName . ' WHERE id = ?');
+ $stmt = $this->pdo->prepare('SELECT synctoken FROM '.$this->addressBooksTableName.' WHERE id = ?');
$stmt->execute([$addressBookId]);
$currentToken = $stmt->fetchColumn(0);
- if (is_null($currentToken)) return null;
+ if (is_null($currentToken)) {
+ return null;
+ }
$result = [
'syncToken' => $currentToken,
- 'added' => [],
- 'modified' => [],
- 'deleted' => [],
+ 'added' => [],
+ 'modified' => [],
+ 'deleted' => [],
];
if ($syncToken) {
-
- $query = "SELECT uri, operation FROM " . $this->addressBookChangesTableName . " WHERE synctoken >= ? AND synctoken < ? AND addressbookid = ? ORDER BY synctoken";
- if ($limit > 0) $query .= " LIMIT " . (int)$limit;
+ $query = 'SELECT uri, operation FROM '.$this->addressBookChangesTableName.' WHERE synctoken >= ? AND synctoken < ? AND addressbookid = ? ORDER BY synctoken';
+ if ($limit > 0) {
+ $query .= ' LIMIT '.(int) $limit;
+ }
// Fetching all changes
$stmt = $this->pdo->prepare($query);
@@ -492,13 +491,10 @@ class PDO extends AbstractBackend implements SyncSupport {
// This loop ensures that any duplicates are overwritten, only the
// last change on a node is relevant.
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
-
$changes[$row['uri']] = $row['operation'];
-
}
foreach ($changes as $uri => $operation) {
-
switch ($operation) {
case 1:
$result['added'][] = $uri;
@@ -510,41 +506,38 @@ class PDO extends AbstractBackend implements SyncSupport {
$result['deleted'][] = $uri;
break;
}
-
}
} else {
// No synctoken supplied, this is the initial sync.
- $query = "SELECT uri FROM " . $this->cardsTableName . " WHERE addressbookid = ?";
+ $query = 'SELECT uri FROM '.$this->cardsTableName.' WHERE addressbookid = ?';
$stmt = $this->pdo->prepare($query);
$stmt->execute([$addressBookId]);
$result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN);
}
- return $result;
+ return $result;
}
/**
* Adds a change record to the addressbookchanges table.
*
- * @param mixed $addressBookId
+ * @param mixed $addressBookId
* @param string $objectUri
- * @param int $operation 1 = add, 2 = modify, 3 = delete
- * @return void
+ * @param int $operation 1 = add, 2 = modify, 3 = delete
*/
- protected function addChange($addressBookId, $objectUri, $operation) {
-
- $stmt = $this->pdo->prepare('INSERT INTO ' . $this->addressBookChangesTableName . ' (uri, synctoken, addressbookid, operation) SELECT ?, synctoken, ?, ? FROM ' . $this->addressBooksTableName . ' WHERE id = ?');
+ protected function addChange($addressBookId, $objectUri, $operation)
+ {
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->addressBookChangesTableName.' (uri, synctoken, addressbookid, operation) SELECT ?, synctoken, ?, ? FROM '.$this->addressBooksTableName.' WHERE id = ?');
$stmt->execute([
$objectUri,
$addressBookId,
$operation,
- $addressBookId
+ $addressBookId,
]);
- $stmt = $this->pdo->prepare('UPDATE ' . $this->addressBooksTableName . ' SET synctoken = synctoken + 1 WHERE id = ?');
+ $stmt = $this->pdo->prepare('UPDATE '.$this->addressBooksTableName.' SET synctoken = synctoken + 1 WHERE id = ?');
$stmt->execute([
- $addressBookId
+ $addressBookId,
]);
-
}
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php b/vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php
index f80618a8e..071361ed0 100644
--- a/vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php
+++ b/vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV\Backend;
/**
@@ -18,8 +20,8 @@ namespace Sabre\CardDAV\Backend;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface SyncSupport extends BackendInterface {
-
+interface SyncSupport extends BackendInterface
+{
/**
* The getChanges method returns all the changes that have happened, since
* the specified syncToken in the specified address book.
@@ -72,10 +74,10 @@ interface SyncSupport extends BackendInterface {
*
* @param string $addressBookId
* @param string $syncToken
- * @param int $syncLevel
- * @param int $limit
+ * @param int $syncLevel
+ * @param int $limit
+ *
* @return array
*/
- function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null);
-
+ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null);
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Card.php b/vendor/sabre/dav/lib/CardDAV/Card.php
index 42a2d7b6a..1d544f4aa 100644
--- a/vendor/sabre/dav/lib/CardDAV/Card.php
+++ b/vendor/sabre/dav/lib/CardDAV/Card.php
@@ -1,94 +1,96 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV;
use Sabre\DAV;
use Sabre\DAVACL;
/**
- * The Card object represents a single Card from an addressbook
+ * The Card object represents a single Card from an addressbook.
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Card extends DAV\File implements ICard, DAVACL\IACL {
-
+class Card extends DAV\File implements ICard, DAVACL\IACL
+{
use DAVACL\ACLTrait;
/**
- * CardDAV backend
+ * CardDAV backend.
*
* @var Backend\BackendInterface
*/
protected $carddavBackend;
/**
- * Array with information about this Card
+ * Array with information about this Card.
*
* @var array
*/
protected $cardData;
/**
- * Array with information about the containing addressbook
+ * Array with information about the containing addressbook.
*
* @var array
*/
protected $addressBookInfo;
/**
- * Constructor
+ * Constructor.
*
* @param Backend\BackendInterface $carddavBackend
- * @param array $addressBookInfo
- * @param array $cardData
+ * @param array $addressBookInfo
+ * @param array $cardData
*/
- function __construct(Backend\BackendInterface $carddavBackend, array $addressBookInfo, array $cardData) {
-
+ public function __construct(Backend\BackendInterface $carddavBackend, array $addressBookInfo, array $cardData)
+ {
$this->carddavBackend = $carddavBackend;
$this->addressBookInfo = $addressBookInfo;
$this->cardData = $cardData;
-
}
/**
- * Returns the uri for this object
+ * Returns the uri for this object.
*
* @return string
*/
- function getName() {
-
+ public function getName()
+ {
return $this->cardData['uri'];
-
}
/**
- * Returns the VCard-formatted object
+ * Returns the VCard-formatted object.
*
* @return string
*/
- function get() {
-
+ public function get()
+ {
// Pre-populating 'carddata' is optional. If we don't yet have it
// already, we fetch it from the backend.
if (!isset($this->cardData['carddata'])) {
$this->cardData = $this->carddavBackend->getCard($this->addressBookInfo['id'], $this->cardData['uri']);
}
- return $this->cardData['carddata'];
+ return $this->cardData['carddata'];
}
/**
- * Updates the VCard-formatted object
+ * Updates the VCard-formatted object.
*
* @param string $cardData
+ *
* @return string|null
*/
- function put($cardData) {
-
- if (is_resource($cardData))
+ public function put($cardData)
+ {
+ if (is_resource($cardData)) {
$cardData = stream_get_contents($cardData);
+ }
// Converting to UTF-8, if needed
$cardData = DAV\StringUtil::ensureUTF8($cardData);
@@ -98,92 +100,82 @@ class Card extends DAV\File implements ICard, DAVACL\IACL {
$this->cardData['etag'] = $etag;
return $etag;
-
}
/**
- * Deletes the card
- *
- * @return void
+ * Deletes the card.
*/
- function delete() {
-
+ public function delete()
+ {
$this->carddavBackend->deleteCard($this->addressBookInfo['id'], $this->cardData['uri']);
-
}
/**
- * Returns the mime content-type
+ * Returns the mime content-type.
*
* @return string
*/
- function getContentType() {
-
+ public function getContentType()
+ {
return 'text/vcard; charset=utf-8';
-
}
/**
- * Returns an ETag for this object
+ * Returns an ETag for this object.
*
* @return string
*/
- function getETag() {
-
+ public function getETag()
+ {
if (isset($this->cardData['etag'])) {
return $this->cardData['etag'];
} else {
$data = $this->get();
if (is_string($data)) {
- return '"' . md5($data) . '"';
+ return '"'.md5($data).'"';
} else {
// We refuse to calculate the md5 if it's a stream.
return null;
}
}
-
}
/**
- * Returns the last modification date as a unix timestamp
+ * Returns the last modification date as a unix timestamp.
*
* @return int
*/
- function getLastModified() {
-
+ public function getLastModified()
+ {
return isset($this->cardData['lastmodified']) ? $this->cardData['lastmodified'] : null;
-
}
/**
- * Returns the size of this object in bytes
+ * Returns the size of this object in bytes.
*
* @return int
*/
- function getSize() {
-
+ public function getSize()
+ {
if (array_key_exists('size', $this->cardData)) {
return $this->cardData['size'];
} else {
return strlen($this->get());
}
-
}
/**
- * 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->addressBookInfo['principaluri'];
-
}
-
/**
* Returns a list of ACE's for this node.
*
@@ -196,8 +188,8 @@ class Card extends DAV\File implements ICard, DAVACL\IACL {
*
* @return array
*/
- function getACL() {
-
+ public function getACL()
+ {
// An alternative acl may be specified through the cardData array.
if (isset($this->cardData['acl'])) {
return $this->cardData['acl'];
@@ -210,7 +202,5 @@ class Card extends DAV\File implements ICard, DAVACL\IACL {
'protected' => true,
],
];
-
}
-
}
diff --git a/vendor/sabre/dav/lib/CardDAV/IAddressBook.php b/vendor/sabre/dav/lib/CardDAV/IAddressBook.php
index f80e05575..3f489f4e5 100644
--- a/vendor/sabre/dav/lib/CardDAV/IAddressBook.php
+++ b/vendor/sabre/dav/lib/CardDAV/IAddressBook.php
@@ -1,11 +1,13 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV;
use Sabre\DAV;
/**
- * AddressBook interface
+ * AddressBook interface.
*
* Implement this interface to allow a node to be recognized as an addressbook.
*
@@ -13,6 +15,6 @@ use Sabre\DAV;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface IAddressBook extends DAV\ICollection {
-
+interface IAddressBook extends DAV\ICollection
+{
}
diff --git a/vendor/sabre/dav/lib/CardDAV/ICard.php b/vendor/sabre/dav/lib/CardDAV/ICard.php
index a974cbd8f..30e9d415e 100644
--- a/vendor/sabre/dav/lib/CardDAV/ICard.php
+++ b/vendor/sabre/dav/lib/CardDAV/ICard.php
@@ -1,11 +1,13 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV;
use Sabre\DAV;
/**
- * Card interface
+ * Card interface.
*
* Extend the ICard interface to allow your custom nodes to be picked up as
* 'Cards'.
@@ -14,6 +16,6 @@ use Sabre\DAV;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface ICard extends DAV\IFile {
-
+interface ICard extends DAV\IFile
+{
}
diff --git a/vendor/sabre/dav/lib/CardDAV/IDirectory.php b/vendor/sabre/dav/lib/CardDAV/IDirectory.php
index d991a1cc8..05e6bef32 100644
--- a/vendor/sabre/dav/lib/CardDAV/IDirectory.php
+++ b/vendor/sabre/dav/lib/CardDAV/IDirectory.php
@@ -1,9 +1,11 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV;
/**
- * IDirectory interface
+ * IDirectory interface.
*
* Implement this interface to have an addressbook marked as a 'directory'. A
* directory is an (often) global addressbook.
@@ -15,6 +17,6 @@ namespace Sabre\CardDAV;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface IDirectory extends IAddressBook {
-
+interface IDirectory extends IAddressBook
+{
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Plugin.php b/vendor/sabre/dav/lib/CardDAV/Plugin.php
index 272ae71fa..10398a4d2 100644
--- a/vendor/sabre/dav/lib/CardDAV/Plugin.php
+++ b/vendor/sabre/dav/lib/CardDAV/Plugin.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV;
use Sabre\DAV;
@@ -9,10 +11,11 @@ use Sabre\DAVACL;
use Sabre\HTTP;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
+use Sabre\Uri;
use Sabre\VObject;
/**
- * CardDAV plugin
+ * CardDAV plugin.
*
* The CardDAV plugin adds CardDAV functionality to the WebDAV server
*
@@ -20,15 +23,15 @@ use Sabre\VObject;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Plugin extends DAV\ServerPlugin {
-
+class Plugin extends DAV\ServerPlugin
+{
/**
- * Url to the addressbooks
+ * Url to the addressbooks.
*/
const ADDRESSBOOK_ROOT = 'addressbooks';
/**
- * xml namespace for CardDAV elements
+ * xml namespace for CardDAV elements.
*/
const NS_CARDDAV = 'urn:ietf:params:xml:ns:carddav';
@@ -41,7 +44,7 @@ class Plugin extends DAV\ServerPlugin {
public $directories = [];
/**
- * Server class
+ * Server class.
*
* @var DAV\Server
*/
@@ -55,41 +58,39 @@ class Plugin extends DAV\ServerPlugin {
protected $maxResourceSize = 10000000;
/**
- * Initializes the plugin
+ * Initializes the plugin.
*
* @param DAV\Server $server
- * @return void
*/
- function initialize(DAV\Server $server) {
-
+ public function initialize(DAV\Server $server)
+ {
/* Events */
- $server->on('propFind', [$this, 'propFindEarly']);
- $server->on('propFind', [$this, 'propFindLate'], 150);
- $server->on('report', [$this, 'report']);
- $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']);
- $server->on('beforeWriteContent', [$this, 'beforeWriteContent']);
- $server->on('beforeCreateFile', [$this, 'beforeCreateFile']);
- $server->on('afterMethod:GET', [$this, 'httpAfterGet']);
+ $server->on('propFind', [$this, 'propFindEarly']);
+ $server->on('propFind', [$this, 'propFindLate'], 150);
+ $server->on('report', [$this, 'report']);
+ $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']);
+ $server->on('beforeWriteContent', [$this, 'beforeWriteContent']);
+ $server->on('beforeCreateFile', [$this, 'beforeCreateFile']);
+ $server->on('afterMethod:GET', [$this, 'httpAfterGet']);
$server->xml->namespaceMap[self::NS_CARDDAV] = 'card';
- $server->xml->elementMap['{' . self::NS_CARDDAV . '}addressbook-query'] = 'Sabre\\CardDAV\\Xml\\Request\\AddressBookQueryReport';
- $server->xml->elementMap['{' . self::NS_CARDDAV . '}addressbook-multiget'] = 'Sabre\\CardDAV\\Xml\\Request\\AddressBookMultiGetReport';
+ $server->xml->elementMap['{'.self::NS_CARDDAV.'}addressbook-query'] = 'Sabre\\CardDAV\\Xml\\Request\\AddressBookQueryReport';
+ $server->xml->elementMap['{'.self::NS_CARDDAV.'}addressbook-multiget'] = 'Sabre\\CardDAV\\Xml\\Request\\AddressBookMultiGetReport';
/* Mapping Interfaces to {DAV:}resourcetype values */
- $server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook'] = '{' . self::NS_CARDDAV . '}addressbook';
- $server->resourceTypeMapping['Sabre\\CardDAV\\IDirectory'] = '{' . self::NS_CARDDAV . '}directory';
+ $server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook'] = '{'.self::NS_CARDDAV.'}addressbook';
+ $server->resourceTypeMapping['Sabre\\CardDAV\\IDirectory'] = '{'.self::NS_CARDDAV.'}directory';
/* Adding properties that may never be changed */
- $server->protectedProperties[] = '{' . self::NS_CARDDAV . '}supported-address-data';
- $server->protectedProperties[] = '{' . self::NS_CARDDAV . '}max-resource-size';
- $server->protectedProperties[] = '{' . self::NS_CARDDAV . '}addressbook-home-set';
- $server->protectedProperties[] = '{' . self::NS_CARDDAV . '}supported-collation-set';
+ $server->protectedProperties[] = '{'.self::NS_CARDDAV.'}supported-address-data';
+ $server->protectedProperties[] = '{'.self::NS_CARDDAV.'}max-resource-size';
+ $server->protectedProperties[] = '{'.self::NS_CARDDAV.'}addressbook-home-set';
+ $server->protectedProperties[] = '{'.self::NS_CARDDAV.'}supported-collation-set';
$server->xml->elementMap['{http://calendarserver.org/ns/}me-card'] = 'Sabre\\DAV\\Xml\\Property\\Href';
$this->server = $server;
-
}
/**
@@ -99,10 +100,9 @@ class Plugin extends DAV\ServerPlugin {
*
* @return array
*/
- function getFeatures() {
-
+ public function getFeatures()
+ {
return ['addressbook'];
-
}
/**
@@ -113,117 +113,111 @@ class Plugin extends DAV\ServerPlugin {
* implement them
*
* @param string $uri
+ *
* @return array
*/
- function getSupportedReportSet($uri) {
-
+ public function getSupportedReportSet($uri)
+ {
$node = $this->server->tree->getNodeForPath($uri);
if ($node instanceof IAddressBook || $node instanceof ICard) {
return [
- '{' . self::NS_CARDDAV . '}addressbook-multiget',
- '{' . self::NS_CARDDAV . '}addressbook-query',
+ '{'.self::NS_CARDDAV.'}addressbook-multiget',
+ '{'.self::NS_CARDDAV.'}addressbook-query',
];
}
- return [];
+ return [];
}
-
/**
- * Adds all CardDAV-specific properties
+ * Adds all CardDAV-specific properties.
*
* @param DAV\PropFind $propFind
- * @param DAV\INode $node
- * @return void
+ * @param DAV\INode $node
*/
- function propFindEarly(DAV\PropFind $propFind, DAV\INode $node) {
-
- $ns = '{' . self::NS_CARDDAV . '}';
+ public function propFindEarly(DAV\PropFind $propFind, DAV\INode $node)
+ {
+ $ns = '{'.self::NS_CARDDAV.'}';
if ($node instanceof IAddressBook) {
-
- $propFind->handle($ns . 'max-resource-size', $this->maxResourceSize);
- $propFind->handle($ns . 'supported-address-data', function() {
+ $propFind->handle($ns.'max-resource-size', $this->maxResourceSize);
+ $propFind->handle($ns.'supported-address-data', function () {
return new Xml\Property\SupportedAddressData();
});
- $propFind->handle($ns . 'supported-collation-set', function() {
+ $propFind->handle($ns.'supported-collation-set', function () {
return new Xml\Property\SupportedCollationSet();
});
-
}
if ($node instanceof DAVACL\IPrincipal) {
-
$path = $propFind->getPath();
- $propFind->handle('{' . self::NS_CARDDAV . '}addressbook-home-set', function() use ($path) {
- return new LocalHref($this->getAddressBookHomeForPrincipal($path) . '/');
- });
-
- if ($this->directories) $propFind->handle('{' . self::NS_CARDDAV . '}directory-gateway', function() {
- return new LocalHref($this->directories);
+ $propFind->handle('{'.self::NS_CARDDAV.'}addressbook-home-set', function () use ($path) {
+ return new LocalHref($this->getAddressBookHomeForPrincipal($path).'/');
});
+ if ($this->directories) {
+ $propFind->handle('{'.self::NS_CARDDAV.'}directory-gateway', function () {
+ return new LocalHref($this->directories);
+ });
+ }
}
if ($node instanceof ICard) {
-
// The address-data property is not supposed to be a 'real'
// property, but in large chunks of the spec it does act as such.
// Therefore we simply expose it as a property.
- $propFind->handle('{' . self::NS_CARDDAV . '}address-data', function() use ($node) {
+ $propFind->handle('{'.self::NS_CARDDAV.'}address-data', function () use ($node) {
$val = $node->get();
- if (is_resource($val))
+ if (is_resource($val)) {
$val = stream_get_contents($val);
+ }
return $val;
-
});
-
}
-
}
/**
- * This functions handles REPORT requests specific to CardDAV
+ * This functions handles REPORT requests specific to CardDAV.
*
- * @param string $reportName
+ * @param string $reportName
* @param \DOMNode $dom
- * @param mixed $path
+ * @param mixed $path
+ *
* @return bool
*/
- function report($reportName, $dom, $path) {
-
+ public function report($reportName, $dom, $path)
+ {
switch ($reportName) {
- case '{' . self::NS_CARDDAV . '}addressbook-multiget' :
+ case '{'.self::NS_CARDDAV.'}addressbook-multiget':
$this->server->transactionType = 'report-addressbook-multiget';
$this->addressbookMultiGetReport($dom);
+
return false;
- case '{' . self::NS_CARDDAV . '}addressbook-query' :
+ case '{'.self::NS_CARDDAV.'}addressbook-query':
$this->server->transactionType = 'report-addressbook-query';
$this->addressBookQueryReport($dom);
+
return false;
- default :
+ default:
return;
-
}
-
-
}
/**
- * Returns the addressbook home for a given principal
+ * Returns the addressbook home for a given principal.
*
* @param string $principal
+ *
* @return string
*/
- protected function getAddressbookHomeForPrincipal($principal) {
-
- list(, $principalId) = \Sabre\HTTP\URLUtil::splitPath($principal);
- return self::ADDRESSBOOK_ROOT . '/' . $principalId;
+ protected function getAddressbookHomeForPrincipal($principal)
+ {
+ list(, $principalId) = Uri\split($principal);
+ return self::ADDRESSBOOK_ROOT.'/'.$principalId;
}
-
/**
* This function handles the addressbook-multiget REPORT.
*
@@ -231,14 +225,13 @@ class Plugin extends DAV\ServerPlugin {
* of urls. Effectively avoiding a lot of redundant requests.
*
* @param Xml\Request\AddressBookMultiGetReport $report
- * @return void
*/
- function addressbookMultiGetReport($report) {
-
+ public function addressbookMultiGetReport($report)
+ {
$contentType = $report->contentType;
$version = $report->version;
if ($version) {
- $contentType .= '; version=' . $version;
+ $contentType .= '; version='.$version;
}
$vcardType = $this->negotiateVCard(
@@ -251,17 +244,13 @@ class Plugin extends DAV\ServerPlugin {
$report->hrefs
);
foreach ($this->server->getPropertiesForMultiplePaths($paths, $report->properties) as $props) {
-
- if (isset($props['200']['{' . self::NS_CARDDAV . '}address-data'])) {
-
- $props['200']['{' . self::NS_CARDDAV . '}address-data'] = $this->convertVCard(
- $props[200]['{' . self::NS_CARDDAV . '}address-data'],
+ if (isset($props['200']['{'.self::NS_CARDDAV.'}address-data'])) {
+ $props['200']['{'.self::NS_CARDDAV.'}address-data'] = $this->convertVCard(
+ $props[200]['{'.self::NS_CARDDAV.'}address-data'],
$vcardType
);
-
}
$propertyList[] = $props;
-
}
$prefer = $this->server->getHTTPPrefer();
@@ -269,8 +258,7 @@ 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($propertyList, $prefer['return'] === 'minimal'));
-
+ $this->server->httpResponse->setBody($this->server->generateMultiStatus($propertyList, 'minimal' === $prefer['return']));
}
/**
@@ -279,20 +267,19 @@ class Plugin extends DAV\ServerPlugin {
* This plugin uses this method to ensure that Card nodes receive valid
* vcard data.
*
- * @param string $path
+ * @param string $path
* @param DAV\IFile $node
- * @param resource $data
- * @param bool $modified Should be set to true, if this event handler
- * changed &$data.
- * @return void
+ * @param resource $data
+ * @param bool $modified should be set to true, if this event handler
+ * changed &$data
*/
- function beforeWriteContent($path, DAV\IFile $node, &$data, &$modified) {
-
- if (!$node instanceof ICard)
+ public function beforeWriteContent($path, DAV\IFile $node, &$data, &$modified)
+ {
+ if (!$node instanceof ICard) {
return;
+ }
$this->validateVCard($data, $modified);
-
}
/**
@@ -301,20 +288,19 @@ class Plugin extends DAV\ServerPlugin {
* This plugin uses this method to ensure that Card nodes receive valid
* vcard data.
*
- * @param string $path
- * @param resource $data
+ * @param string $path
+ * @param resource $data
* @param DAV\ICollection $parentNode
- * @param bool $modified Should be set to true, if this event handler
- * changed &$data.
- * @return void
+ * @param bool $modified should be set to true, if this event handler
+ * changed &$data
*/
- function beforeCreateFile($path, &$data, DAV\ICollection $parentNode, &$modified) {
-
- if (!$parentNode instanceof IAddressBook)
+ public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode, &$modified)
+ {
+ if (!$parentNode instanceof IAddressBook) {
return;
+ }
$this->validateVCard($data, $modified);
-
}
/**
@@ -323,12 +309,11 @@ class Plugin extends DAV\ServerPlugin {
* An exception is thrown if it's not.
*
* @param resource|string $data
- * @param bool $modified Should be set to true, if this event handler
- * changed &$data.
- * @return void
+ * @param bool $modified should be set to true, if this event handler
+ * changed &$data
*/
- protected function validateVCard(&$data, &$modified) {
-
+ protected function validateVCard(&$data, &$modified)
+ {
// If it's a stream, we convert it to a string first.
if (is_resource($data)) {
$data = stream_get_contents($data);
@@ -337,10 +322,9 @@ class Plugin extends DAV\ServerPlugin {
$before = $data;
try {
-
// If the data starts with a [, we can reasonably assume we're dealing
// with a jCal object.
- if (substr($data, 0, 1) === '[') {
+ if ('[' === substr($data, 0, 1)) {
$vobj = VObject\Reader::readJson($data);
// Converting $data back to iCalendar, as that's what we
@@ -350,21 +334,18 @@ class Plugin extends DAV\ServerPlugin {
} else {
$vobj = VObject\Reader::read($data);
}
-
} catch (VObject\ParseException $e) {
-
- throw new DAV\Exception\UnsupportedMediaType('This resource only supports valid vCard or jCard data. Parse error: ' . $e->getMessage());
-
+ throw new DAV\Exception\UnsupportedMediaType('This resource only supports valid vCard or jCard data. Parse error: '.$e->getMessage());
}
- if ($vobj->name !== 'VCARD') {
+ if ('VCARD' !== $vobj->name) {
throw new DAV\Exception\UnsupportedMediaType('This collection can only support vcard objects.');
}
$options = VObject\Node::PROFILE_CARDDAV;
$prefer = $this->server->getHTTPPrefer();
- if ($prefer['handling'] !== 'strict') {
+ if ('strict' !== $prefer['handling']) {
$options |= VObject\Node::REPAIR;
}
@@ -376,7 +357,6 @@ class Plugin extends DAV\ServerPlugin {
// $messages contains a list of problems with the vcard, along with
// their severity.
foreach ($messages as $message) {
-
if ($message['level'] > $highestLevel) {
// Recording the highest reported error level.
$highestLevel = $message['level'];
@@ -384,30 +364,27 @@ class Plugin extends DAV\ServerPlugin {
}
switch ($message['level']) {
-
- case 1 :
+ case 1:
// Level 1 means that there was a problem, but it was repaired.
$modified = true;
break;
- case 2 :
+ case 2:
// Level 2 means a warning, but not critical
break;
- case 3 :
+ case 3:
// Level 3 means a critical error
- throw new DAV\Exception\UnsupportedMediaType('Validation error in vCard: ' . $message['message']);
-
+ throw new DAV\Exception\UnsupportedMediaType('Validation error in vCard: '.$message['message']);
}
-
}
if ($warningMessage) {
$this->server->httpResponse->setHeader(
'X-Sabre-Ew-Gross',
- 'vCard validation warning: ' . $warningMessage
+ 'vCard validation warning: '.$warningMessage
);
// Re-serializing object.
$data = $vobj->serialize();
- if (!$modified && strcmp($data, $before) !== 0) {
+ if (!$modified && 0 !== strcmp($data, $before)) {
// This ensures that the system does not send an ETag back.
$modified = true;
}
@@ -417,23 +394,21 @@ class Plugin extends DAV\ServerPlugin {
$vobj->destroy();
}
-
/**
- * This function handles the addressbook-query REPORT
+ * This function handles the addressbook-query REPORT.
*
* This report is used by the client to filter an addressbook based on a
* complex query.
*
* @param Xml\Request\AddressBookQueryReport $report
- * @return void
*/
- protected function addressbookQueryReport($report) {
-
+ protected function addressbookQueryReport($report)
+ {
$depth = $this->server->getHTTPDepth(0);
- if ($depth == 0) {
+ if (0 == $depth) {
$candidateNodes = [
- $this->server->tree->getNodeForPath($this->server->getRequestUri())
+ $this->server->tree->getNodeForPath($this->server->getRequestUri()),
];
if (!$candidateNodes[0] instanceof ICard) {
throw new ReportNotSupported('The addressbook-query report is not supported on this url with Depth: 0');
@@ -444,7 +419,7 @@ class Plugin extends DAV\ServerPlugin {
$contentType = $report->contentType;
if ($report->version) {
- $contentType .= '; version=' . $report->version;
+ $contentType .= '; version='.$report->version;
}
$vcardType = $this->negotiateVCard(
@@ -453,9 +428,9 @@ class Plugin extends DAV\ServerPlugin {
$validNodes = [];
foreach ($candidateNodes as $node) {
-
- if (!$node instanceof ICard)
+ if (!$node instanceof ICard) {
continue;
+ }
$blob = $node->get();
if (is_resource($blob)) {
@@ -472,31 +447,26 @@ class Plugin extends DAV\ServerPlugin {
// We hit the maximum number of items, we can stop now.
break;
}
-
}
$result = [];
foreach ($validNodes as $validNode) {
-
- if ($depth == 0) {
+ if (0 == $depth) {
$href = $this->server->getRequestUri();
} else {
- $href = $this->server->getRequestUri() . '/' . $validNode->getName();
+ $href = $this->server->getRequestUri().'/'.$validNode->getName();
}
list($props) = $this->server->getPropertiesForPath($href, $report->properties, 0);
- if (isset($props[200]['{' . self::NS_CARDDAV . '}address-data'])) {
-
- $props[200]['{' . self::NS_CARDDAV . '}address-data'] = $this->convertVCard(
- $props[200]['{' . self::NS_CARDDAV . '}address-data'],
+ if (isset($props[200]['{'.self::NS_CARDDAV.'}address-data'])) {
+ $props[200]['{'.self::NS_CARDDAV.'}address-data'] = $this->convertVCard(
+ $props[200]['{'.self::NS_CARDDAV.'}address-data'],
$vcardType,
$report->addressDataProperties
);
-
}
$result[] = $props;
-
}
$prefer = $this->server->getHTTPPrefer();
@@ -504,26 +474,26 @@ 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']));
}
/**
* Validates if a vcard makes it throught a list of filters.
*
* @param string $vcardData
- * @param array $filters
- * @param string $test anyof or allof (which means OR or AND)
+ * @param array $filters
+ * @param string $test anyof or allof (which means OR or AND)
+ *
* @return bool
*/
- function validateFilters($vcardData, array $filters, $test) {
-
-
- if (!$filters) return true;
+ public function validateFilters($vcardData, array $filters, $test)
+ {
+ if (!$filters) {
+ return true;
+ }
$vcard = VObject\Reader::read($vcardData);
foreach ($filters as $filter) {
-
$isDefined = isset($vcard->{$filter['name']});
if ($filter['is-not-defined']) {
if ($isDefined) {
@@ -532,12 +502,9 @@ class Plugin extends DAV\ServerPlugin {
$success = true;
}
} elseif ((!$filter['param-filters'] && !$filter['text-matches']) || !$isDefined) {
-
// We only need to check for existence
$success = $isDefined;
-
} else {
-
$vProperties = $vcard->select($filter['name']);
$results = [];
@@ -546,44 +513,40 @@ class Plugin extends DAV\ServerPlugin {
}
if ($filter['text-matches']) {
$texts = [];
- foreach ($vProperties as $vProperty)
+ foreach ($vProperties as $vProperty) {
$texts[] = $vProperty->getValue();
+ }
$results[] = $this->validateTextMatches($texts, $filter['text-matches'], $filter['test']);
}
- if (count($results) === 1) {
+ if (1 === count($results)) {
$success = $results[0];
} else {
- if ($filter['test'] === 'anyof') {
+ if ('anyof' === $filter['test']) {
$success = $results[0] || $results[1];
} else {
$success = $results[0] && $results[1];
}
}
-
} // else
// There are two conditions where we can already determine whether
// or not this filter succeeds.
- if ($test === 'anyof' && $success) {
-
+ if ('anyof' === $test && $success) {
// Destroy circular references to PHP will GC the object.
$vcard->destroy();
return true;
}
- if ($test === 'allof' && !$success) {
-
+ if ('allof' === $test && !$success) {
// Destroy circular references to PHP will GC the object.
$vcard->destroy();
return false;
}
-
} // foreach
-
// Destroy circular references to PHP will GC the object.
$vcard->destroy();
@@ -592,8 +555,7 @@ class Plugin extends DAV\ServerPlugin {
//
// This implies for 'anyof' that the test failed, and for 'allof' that
// we succeeded. Sounds weird, but makes sense.
- return $test === 'allof';
-
+ return 'allof' === $test;
}
/**
@@ -602,19 +564,22 @@ class Plugin extends DAV\ServerPlugin {
* @todo currently we're only validating the first parameter of the passed
* property. Any subsequence parameters with the same name are
* ignored.
- * @param array $vProperties
- * @param array $filters
+ *
+ * @param array $vProperties
+ * @param array $filters
* @param string $test
+ *
* @return bool
*/
- protected function validateParamFilters(array $vProperties, array $filters, $test) {
-
+ protected function validateParamFilters(array $vProperties, array $filters, $test)
+ {
foreach ($filters as $filter) {
-
$isDefined = false;
foreach ($vProperties as $vProperty) {
$isDefined = isset($vProperty[$filter['name']]);
- if ($isDefined) break;
+ if ($isDefined) {
+ break;
+ }
}
if ($filter['is-not-defined']) {
@@ -624,35 +589,32 @@ class Plugin extends DAV\ServerPlugin {
$success = true;
}
- // If there's no text-match, we can just check for existence
+ // If there's no text-match, we can just check for existence
} elseif (!$filter['text-match'] || !$isDefined) {
-
$success = $isDefined;
-
} else {
-
$success = false;
foreach ($vProperties as $vProperty) {
// If we got all the way here, we'll need to validate the
// text-match filter.
$success = DAV\StringUtil::textMatch($vProperty[$filter['name']]->getValue(), $filter['text-match']['value'], $filter['text-match']['collation'], $filter['text-match']['match-type']);
- if ($success) break;
+ if ($success) {
+ break;
+ }
}
if ($filter['text-match']['negate-condition']) {
$success = !$success;
}
-
} // else
// There are two conditions where we can already determine whether
// or not this filter succeeds.
- if ($test === 'anyof' && $success) {
+ if ('anyof' === $test && $success) {
return true;
}
- if ($test === 'allof' && !$success) {
+ if ('allof' === $test && !$success) {
return false;
}
-
}
// If we got all the way here, it means we haven't been able to
@@ -660,40 +622,41 @@ class Plugin extends DAV\ServerPlugin {
//
// This implies for 'anyof' that the test failed, and for 'allof' that
// we succeeded. Sounds weird, but makes sense.
- return $test === 'allof';
-
+ return 'allof' === $test;
}
/**
* Validates if a text-filter can be applied to a specific property.
*
- * @param array $texts
- * @param array $filters
+ * @param array $texts
+ * @param array $filters
* @param string $test
+ *
* @return bool
*/
- protected function validateTextMatches(array $texts, array $filters, $test) {
-
+ protected function validateTextMatches(array $texts, array $filters, $test)
+ {
foreach ($filters as $filter) {
-
$success = false;
foreach ($texts as $haystack) {
$success = DAV\StringUtil::textMatch($haystack, $filter['value'], $filter['collation'], $filter['match-type']);
// Breaking on the first match
- if ($success) break;
+ if ($success) {
+ break;
+ }
}
if ($filter['negate-condition']) {
$success = !$success;
}
- if ($success && $test === 'anyof')
+ if ($success && 'anyof' === $test) {
return true;
+ }
- if (!$success && $test == 'allof')
+ if (!$success && 'allof' == $test) {
return false;
-
-
+ }
}
// If we got all the way here, it means we haven't been able to
@@ -701,8 +664,7 @@ class Plugin extends DAV\ServerPlugin {
//
// This implies for 'anyof' that the test failed, and for 'allof' that
// we succeeded. Sounds weird, but makes sense.
- return $test === 'allof';
-
+ return 'allof' === $test;
}
/**
@@ -712,24 +674,24 @@ class Plugin extends DAV\ServerPlugin {
* propfind has been done.
*
* @param DAV\PropFind $propFind
- * @param DAV\INode $node
- * @return void
+ * @param DAV\INode $node
*/
- function propFindLate(DAV\PropFind $propFind, DAV\INode $node) {
-
+ public function propFindLate(DAV\PropFind $propFind, DAV\INode $node)
+ {
// If the request was made using the SOGO connector, we must rewrite
// the content-type property. By default SabreDAV will send back
// text/x-vcard; charset=utf-8, but for SOGO we must strip that last
// part.
- if (strpos($this->server->httpRequest->getHeader('User-Agent'), 'Thunderbird') === false) {
+ if (false === strpos((string) $this->server->httpRequest->getHeader('User-Agent'), 'Thunderbird')) {
return;
}
$contentType = $propFind->get('{DAV:}getcontenttype');
- list($part) = explode(';', $contentType);
- if ($part === 'text/x-vcard' || $part === 'text/vcard') {
- $propFind->set('{DAV:}getcontenttype', 'text/x-vcard');
+ if (null !== $contentType) {
+ list($part) = explode(';', $contentType);
+ if ('text/x-vcard' === $part || 'text/vcard' === $part) {
+ $propFind->set('{DAV:}getcontenttype', 'text/x-vcard');
+ }
}
-
}
/**
@@ -738,18 +700,20 @@ class Plugin extends DAV\ServerPlugin {
* can use to create new addressbooks.
*
* @param DAV\INode $node
- * @param string $output
+ * @param string $output
+ *
* @return bool
*/
- function htmlActionsPanel(DAV\INode $node, &$output) {
-
- if (!$node instanceof AddressBookHome)
+ public function htmlActionsPanel(DAV\INode $node, &$output)
+ {
+ if (!$node instanceof AddressBookHome) {
return;
+ }
$output .= '<tr><td colspan="2"><form method="post" action="">
<h3>Create new address book</h3>
<input type="hidden" name="sabreAction" value="mkcol" />
- <input type="hidden" name="resourceType" value="{DAV:}collection,{' . self::NS_CARDDAV . '}addressbook" />
+ <input type="hidden" name="resourceType" value="{DAV:}collection,{'.self::NS_CARDDAV.'}addressbook" />
<label>Name (uri):</label> <input type="text" name="name" /><br />
<label>Display name:</label> <input type="text" name="{DAV:}displayname" /><br />
<input type="submit" value="create" />
@@ -757,7 +721,6 @@ class Plugin extends DAV\ServerPlugin {
</td></tr>';
return false;
-
}
/**
@@ -765,13 +728,13 @@ class Plugin extends DAV\ServerPlugin {
*
* This is used to transform data into jCal, if this was requested.
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
- * @return void
*/
- function httpAfterGet(RequestInterface $request, ResponseInterface $response) {
-
- if (strpos($response->getHeader('Content-Type'), 'text/vcard') === false) {
+ public function httpAfterGet(RequestInterface $request, ResponseInterface $response)
+ {
+ $contentType = $response->getHeader('Content-Type');
+ if (null === $contentType || false === strpos($contentType, 'text/vcard')) {
return;
}
@@ -783,9 +746,8 @@ class Plugin extends DAV\ServerPlugin {
);
$response->setBody($newBody);
- $response->setHeader('Content-Type', $mimeType . '; charset=utf-8');
+ $response->setHeader('Content-Type', $mimeType.'; charset=utf-8');
$response->setHeader('Content-Length', strlen($newBody));
-
}
/**
@@ -800,11 +762,12 @@ class Plugin extends DAV\ServerPlugin {
*
* @param string $input
* @param string $mimeType
+ *
* @return string
*/
- protected function negotiateVCard($input, &$mimeType = null) {
-
- $result = HTTP\Util::negotiate(
+ protected function negotiateVCard($input, &$mimeType = null)
+ {
+ $result = HTTP\negotiateContentType(
$input,
[
// Most often used mime-type. Version 3
@@ -823,41 +786,41 @@ class Plugin extends DAV\ServerPlugin {
$mimeType = $result;
switch ($result) {
-
- default :
- case 'text/x-vcard' :
- case 'text/vcard' :
- case 'text/vcard; version=3.0' :
+ default:
+ case 'text/x-vcard':
+ case 'text/vcard':
+ case 'text/vcard; version=3.0':
$mimeType = 'text/vcard';
+
return 'vcard3';
- case 'text/vcard; version=4.0' :
+ case 'text/vcard; version=4.0':
return 'vcard4';
- case 'application/vcard+json' :
+ case 'application/vcard+json':
return 'jcard';
// @codeCoverageIgnoreStart
}
// @codeCoverageIgnoreEnd
-
}
/**
* Converts a vcard blob to a different version, or jcard.
*
* @param string|resource $data
- * @param string $target
- * @param array $propertiesFilter
+ * @param string $target
+ * @param array $propertiesFilter
+ *
* @return string
*/
- protected function convertVCard($data, $target, array $propertiesFilter = null) {
-
+ protected function convertVCard($data, $target, array $propertiesFilter = null)
+ {
if (is_resource($data)) {
$data = stream_get_contents($data);
}
$input = VObject\Reader::read($data);
if (!empty($propertiesFilter)) {
$propertiesFilter = array_merge(['UID', 'VERSION', 'FN'], $propertiesFilter);
- $keys = array_unique(array_map(function($child) {
+ $keys = array_unique(array_map(function ($child) {
return $child->name;
}, $input->children()));
$keys = array_diff($keys, $propertiesFilter);
@@ -868,38 +831,36 @@ class Plugin extends DAV\ServerPlugin {
}
$output = null;
try {
-
switch ($target) {
- default :
- case 'vcard3' :
- if ($input->getDocumentType() === VObject\Document::VCARD30) {
+ default:
+ case 'vcard3':
+ if (VObject\Document::VCARD30 === $input->getDocumentType()) {
// Do nothing
return $data;
}
$output = $input->convert(VObject\Document::VCARD30);
+
return $output->serialize();
- case 'vcard4' :
- if ($input->getDocumentType() === VObject\Document::VCARD40) {
+ case 'vcard4':
+ if (VObject\Document::VCARD40 === $input->getDocumentType()) {
// Do nothing
return $data;
}
$output = $input->convert(VObject\Document::VCARD40);
+
return $output->serialize();
- case 'jcard' :
+ case 'jcard':
$output = $input->convert(VObject\Document::VCARD40);
- return json_encode($output);
+ return json_encode($output);
}
-
} finally {
-
// Destroy circular references to PHP will GC the object.
$input->destroy();
if (!is_null($output)) {
$output->destroy();
}
}
-
}
/**
@@ -910,10 +871,9 @@ class Plugin extends DAV\ServerPlugin {
*
* @return string
*/
- function getPluginName() {
-
+ public function getPluginName()
+ {
return 'carddav';
-
}
/**
@@ -927,14 +887,12 @@ class Plugin extends DAV\ServerPlugin {
*
* @return array
*/
- function getPluginInfo() {
-
+ public function getPluginInfo()
+ {
return [
- 'name' => $this->getPluginName(),
+ 'name' => $this->getPluginName(),
'description' => 'Adds support for CardDAV (rfc6352)',
- 'link' => 'http://sabre.io/dav/carddav/',
+ 'link' => 'http://sabre.io/dav/carddav/',
];
-
}
-
}
diff --git a/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php b/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
index 2d61db6ac..194927c53 100644
--- a/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
+++ b/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV;
use Sabre\DAV;
@@ -8,7 +10,7 @@ use Sabre\HTTP\ResponseInterface;
use Sabre\VObject;
/**
- * VCF Exporter
+ * VCF Exporter.
*
* This plugin adds the ability to export entire address books as .vcf files.
* This is useful for clients that don't support CardDAV yet. They often do
@@ -19,28 +21,27 @@ use Sabre\VObject;
* @author Thomas Tanghus (http://tanghus.net/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class VCFExportPlugin extends DAV\ServerPlugin {
-
+class VCFExportPlugin extends DAV\ServerPlugin
+{
/**
- * Reference to Server class
+ * Reference to Server class.
*
* @var DAV\Server
*/
protected $server;
/**
- * Initializes the plugin and registers event handlers
+ * Initializes the plugin and registers event handlers.
*
* @param DAV\Server $server
- * @return void
*/
- function initialize(DAV\Server $server) {
-
+ public function initialize(DAV\Server $server)
+ {
$this->server = $server;
$this->server->on('method:GET', [$this, 'httpGet'], 90);
- $server->on('browserButtonActions', function($path, $node, &$actions) {
+ $server->on('browserButtonActions', function ($path, $node, &$actions) {
if ($node instanceof IAddressBook) {
- $actions .= '<a href="' . htmlspecialchars($path, ENT_QUOTES, 'UTF-8') . '?export"><span class="oi" data-glyph="book"></span></a>';
+ $actions .= '<a href="'.htmlspecialchars($path, ENT_QUOTES, 'UTF-8').'?export"><span class="oi" data-glyph="book"></span></a>';
}
});
}
@@ -48,20 +49,25 @@ class VCFExportPlugin extends DAV\ServerPlugin {
/**
* Intercepts GET requests on addressbook urls ending with ?export.
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpGet(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpGet(RequestInterface $request, ResponseInterface $response)
+ {
$queryParams = $request->getQueryParameters();
- if (!array_key_exists('export', $queryParams)) return;
+ if (!array_key_exists('export', $queryParams)) {
+ return;
+ }
$path = $request->getPath();
$node = $this->server->tree->getNodeForPath($path);
- if (!($node instanceof IAddressBook)) return;
+ if (!($node instanceof IAddressBook)) {
+ return;
+ }
$this->server->transactionType = 'get-addressbook-export';
@@ -71,7 +77,7 @@ class VCFExportPlugin extends DAV\ServerPlugin {
}
$nodes = $this->server->getPropertiesForPath($path, [
- '{' . Plugin::NS_CARDDAV . '}address-data',
+ '{'.Plugin::NS_CARDDAV.'}address-data',
], 1);
$format = 'text/directory';
@@ -91,9 +97,9 @@ class VCFExportPlugin extends DAV\ServerPlugin {
'',
$node->getName()
);
- $filename .= '-' . date('Y-m-d') . $filenameExtension;
+ $filename .= '-'.date('Y-m-d').$filenameExtension;
- $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
+ $response->setHeader('Content-Disposition', 'attachment; filename="'.$filename.'"');
$response->setHeader('Content-Type', $format);
$response->setStatus(200);
@@ -101,25 +107,24 @@ class VCFExportPlugin extends DAV\ServerPlugin {
// Returning false to break the event chain
return false;
-
}
/**
- * Merges all vcard objects, and builds one big vcf export
+ * Merges all vcard objects, and builds one big vcf export.
*
* @param array $nodes
+ *
* @return string
*/
- function generateVCF(array $nodes) {
-
- $output = "";
+ public function generateVCF(array $nodes)
+ {
+ $output = '';
foreach ($nodes as $node) {
-
- if (!isset($node[200]['{' . Plugin::NS_CARDDAV . '}address-data'])) {
+ if (!isset($node[200]['{'.Plugin::NS_CARDDAV.'}address-data'])) {
continue;
}
- $nodeData = $node[200]['{' . Plugin::NS_CARDDAV . '}address-data'];
+ $nodeData = $node[200]['{'.Plugin::NS_CARDDAV.'}address-data'];
// Parsing this node so VObject can clean up the output.
$vcard = VObject\Reader::read($nodeData);
@@ -127,11 +132,9 @@ class VCFExportPlugin extends DAV\ServerPlugin {
// Destroy circular references to PHP will GC the object.
$vcard->destroy();
-
}
return $output;
-
}
/**
@@ -142,10 +145,9 @@ class VCFExportPlugin extends DAV\ServerPlugin {
*
* @return string
*/
- function getPluginName() {
-
+ public function getPluginName()
+ {
return 'vcf-export';
-
}
/**
@@ -159,14 +161,12 @@ class VCFExportPlugin extends DAV\ServerPlugin {
*
* @return array
*/
- function getPluginInfo() {
-
+ public function getPluginInfo()
+ {
return [
- 'name' => $this->getPluginName(),
+ 'name' => $this->getPluginName(),
'description' => 'Adds the ability to export CardDAV addressbooks as a single vCard file.',
- 'link' => 'http://sabre.io/dav/vcf-export-plugin/',
+ 'link' => 'http://sabre.io/dav/vcf-export-plugin/',
];
-
}
-
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Filter/AddressData.php b/vendor/sabre/dav/lib/CardDAV/Xml/Filter/AddressData.php
index 5b7b2ee17..f1b651e76 100644
--- a/vendor/sabre/dav/lib/CardDAV/Xml/Filter/AddressData.php
+++ b/vendor/sabre/dav/lib/CardDAV/Xml/Filter/AddressData.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV\Xml\Filter;
use Sabre\Xml\Reader;
@@ -21,8 +23,8 @@ use Sabre\Xml\XmlDeserializable;
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class AddressData implements XmlDeserializable {
-
+class AddressData implements XmlDeserializable
+{
/**
* The deserialize method is called during xml parsing.
*
@@ -42,25 +44,25 @@ class AddressData implements XmlDeserializable {
* the next element.
*
* @param Reader $reader
+ *
* @return mixed
*/
- static function xmlDeserialize(Reader $reader) {
-
+ public static function xmlDeserialize(Reader $reader)
+ {
$result = [
'contentType' => $reader->getAttribute('content-type') ?: 'text/vcard',
- 'version' => $reader->getAttribute('version') ?: '3.0',
+ 'version' => $reader->getAttribute('version') ?: '3.0',
];
- $elems = (array)$reader->parseInnerTree();
- $elems = array_filter($elems, function($element) {
- return $element['name'] === '{urn:ietf:params:xml:ns:carddav}prop' &&
+ $elems = (array) $reader->parseInnerTree();
+ $elems = array_filter($elems, function ($element) {
+ return '{urn:ietf:params:xml:ns:carddav}prop' === $element['name'] &&
isset($element['attributes']['name']);
});
- $result['addressDataProperties'] = array_map(function($element) {
+ $result['addressDataProperties'] = array_map(function ($element) {
return $element['attributes']['name'];
}, $elems);
return $result;
}
-
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Filter/ParamFilter.php b/vendor/sabre/dav/lib/CardDAV/Xml/Filter/ParamFilter.php
index 936e26917..2d39dea7f 100644
--- a/vendor/sabre/dav/lib/CardDAV/Xml/Filter/ParamFilter.php
+++ b/vendor/sabre/dav/lib/CardDAV/Xml/Filter/ParamFilter.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV\Xml\Filter;
use Sabre\CardDAV\Plugin;
@@ -21,8 +23,8 @@ use Sabre\Xml\Reader;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-abstract class ParamFilter implements Element {
-
+abstract class ParamFilter implements Element
+{
/**
* The deserialize method is called during xml parsing.
*
@@ -42,14 +44,15 @@ abstract class ParamFilter implements Element {
* the next element.
*
* @param Reader $reader
+ *
* @return mixed
*/
- static function xmlDeserialize(Reader $reader) {
-
+ public static function xmlDeserialize(Reader $reader)
+ {
$result = [
- 'name' => null,
+ 'name' => null,
'is-not-defined' => false,
- 'text-match' => null,
+ 'text-match' => null,
];
$att = $reader->parseAttributes();
@@ -57,33 +60,29 @@ abstract class ParamFilter implements Element {
$elems = $reader->parseInnerTree();
- if (is_array($elems)) foreach ($elems as $elem) {
-
- switch ($elem['name']) {
-
- case '{' . Plugin::NS_CARDDAV . '}is-not-defined' :
+ if (is_array($elems)) {
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{'.Plugin::NS_CARDDAV.'}is-not-defined':
$result['is-not-defined'] = true;
break;
- case '{' . Plugin::NS_CARDDAV . '}text-match' :
+ case '{'.Plugin::NS_CARDDAV.'}text-match':
$matchType = isset($elem['attributes']['match-type']) ? $elem['attributes']['match-type'] : 'contains';
if (!in_array($matchType, ['contains', 'equals', 'starts-with', 'ends-with'])) {
- throw new BadRequest('Unknown match-type: ' . $matchType);
+ throw new BadRequest('Unknown match-type: '.$matchType);
}
$result['text-match'] = [
- 'negate-condition' => isset($elem['attributes']['negate-condition']) && $elem['attributes']['negate-condition'] === 'yes',
- 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;unicode-casemap',
- 'value' => $elem['value'],
- 'match-type' => $matchType,
+ 'negate-condition' => isset($elem['attributes']['negate-condition']) && 'yes' === $elem['attributes']['negate-condition'],
+ 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;unicode-casemap',
+ 'value' => $elem['value'],
+ 'match-type' => $matchType,
];
break;
-
}
-
+ }
}
return $result;
-
}
-
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Filter/PropFilter.php b/vendor/sabre/dav/lib/CardDAV/Xml/Filter/PropFilter.php
index d7799429d..a22a577c9 100644
--- a/vendor/sabre/dav/lib/CardDAV/Xml/Filter/PropFilter.php
+++ b/vendor/sabre/dav/lib/CardDAV/Xml/Filter/PropFilter.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV\Xml\Filter;
use Sabre\CardDAV\Plugin;
@@ -21,8 +23,8 @@ use Sabre\Xml\XmlDeserializable;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class PropFilter implements XmlDeserializable {
-
+class PropFilter implements XmlDeserializable
+{
/**
* The deserialize method is called during xml parsing.
*
@@ -42,57 +44,54 @@ class PropFilter implements XmlDeserializable {
* the next element.
*
* @param Reader $reader
+ *
* @return mixed
*/
- static function xmlDeserialize(Reader $reader) {
-
+ public static function xmlDeserialize(Reader $reader)
+ {
$result = [
- 'name' => null,
- 'test' => 'anyof',
+ 'name' => null,
+ 'test' => 'anyof',
'is-not-defined' => false,
- 'param-filters' => [],
- 'text-matches' => [],
+ 'param-filters' => [],
+ 'text-matches' => [],
];
$att = $reader->parseAttributes();
$result['name'] = $att['name'];
- if (isset($att['test']) && $att['test'] === 'allof') {
+ if (isset($att['test']) && 'allof' === $att['test']) {
$result['test'] = 'allof';
}
$elems = $reader->parseInnerTree();
- if (is_array($elems)) foreach ($elems as $elem) {
-
- switch ($elem['name']) {
-
- case '{' . Plugin::NS_CARDDAV . '}param-filter' :
+ if (is_array($elems)) {
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{'.Plugin::NS_CARDDAV.'}param-filter':
$result['param-filters'][] = $elem['value'];
break;
- case '{' . Plugin::NS_CARDDAV . '}is-not-defined' :
+ case '{'.Plugin::NS_CARDDAV.'}is-not-defined':
$result['is-not-defined'] = true;
break;
- case '{' . Plugin::NS_CARDDAV . '}text-match' :
+ case '{'.Plugin::NS_CARDDAV.'}text-match':
$matchType = isset($elem['attributes']['match-type']) ? $elem['attributes']['match-type'] : 'contains';
if (!in_array($matchType, ['contains', 'equals', 'starts-with', 'ends-with'])) {
- throw new BadRequest('Unknown match-type: ' . $matchType);
+ throw new BadRequest('Unknown match-type: '.$matchType);
}
$result['text-matches'][] = [
- 'negate-condition' => isset($elem['attributes']['negate-condition']) && $elem['attributes']['negate-condition'] === 'yes',
- 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;unicode-casemap',
- 'value' => $elem['value'],
- 'match-type' => $matchType,
+ 'negate-condition' => isset($elem['attributes']['negate-condition']) && 'yes' === $elem['attributes']['negate-condition'],
+ 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;unicode-casemap',
+ 'value' => $elem['value'],
+ 'match-type' => $matchType,
];
break;
-
}
-
+ }
}
return $result;
-
}
-
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedAddressData.php b/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedAddressData.php
index aecd8a09f..9d0051698 100644
--- a/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedAddressData.php
+++ b/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedAddressData.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV\Xml\Property;
use Sabre\CardDAV\Plugin;
@@ -7,7 +9,7 @@ use Sabre\Xml\Writer;
use Sabre\Xml\XmlSerializable;
/**
- * Supported-address-data property
+ * Supported-address-data property.
*
* This property is a representation of the supported-address-data property
* in the CardDAV namespace.
@@ -20,22 +22,22 @@ use Sabre\Xml\XmlSerializable;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class SupportedAddressData implements XmlSerializable {
-
+class SupportedAddressData implements XmlSerializable
+{
/**
- * supported versions
+ * supported versions.
*
* @var array
*/
protected $supportedData = [];
/**
- * Creates the property
+ * Creates the property.
*
* @param array|null $supportedData
*/
- function __construct(array $supportedData = null) {
-
+ public function __construct(array $supportedData = null)
+ {
if (is_null($supportedData)) {
$supportedData = [
['contentType' => 'text/vcard', 'version' => '3.0'],
@@ -45,7 +47,6 @@ class SupportedAddressData implements XmlSerializable {
}
$this->supportedData = $supportedData;
-
}
/**
@@ -65,19 +66,16 @@ class SupportedAddressData implements XmlSerializable {
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
- * @return void
*/
- function xmlSerialize(Writer $writer) {
-
+ public function xmlSerialize(Writer $writer)
+ {
foreach ($this->supportedData as $supported) {
- $writer->startElement('{' . Plugin::NS_CARDDAV . '}address-data-type');
+ $writer->startElement('{'.Plugin::NS_CARDDAV.'}address-data-type');
$writer->writeAttributes([
'content-type' => $supported['contentType'],
- 'version' => $supported['version']
+ 'version' => $supported['version'],
]);
$writer->endElement(); // address-data-type
}
-
}
-
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedCollationSet.php b/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedCollationSet.php
index 778aa2b64..66e451a91 100644
--- a/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedCollationSet.php
+++ b/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedCollationSet.php
@@ -1,12 +1,14 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV\Xml\Property;
use Sabre\Xml\Writer;
use Sabre\Xml\XmlSerializable;
/**
- * supported-collation-set property
+ * supported-collation-set property.
*
* This property is a representation of the supported-collation-set property
* in the CardDAV namespace.
@@ -15,8 +17,8 @@ use Sabre\Xml\XmlSerializable;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class SupportedCollationSet implements XmlSerializable {
-
+class SupportedCollationSet implements XmlSerializable
+{
/**
* The xmlSerialize method is called during xml writing.
*
@@ -34,14 +36,11 @@ class SupportedCollationSet implements XmlSerializable {
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
- * @return void
*/
- function xmlSerialize(Writer $writer) {
-
+ public function xmlSerialize(Writer $writer)
+ {
foreach (['i;ascii-casemap', 'i;octet', 'i;unicode-casemap'] as $coll) {
$writer->writeElement('{urn:ietf:params:xml:ns:carddav}supported-collation', $coll);
}
-
}
-
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php b/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php
index 0115a0107..845796760 100644
--- a/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php
+++ b/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV\Xml\Request;
use Sabre\CardDAV\Plugin;
@@ -19,8 +21,8 @@ use Sabre\Xml\XmlDeserializable;
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class AddressBookMultiGetReport implements XmlDeserializable {
-
+class AddressBookMultiGetReport implements XmlDeserializable
+{
/**
* An array with requested properties.
*
@@ -70,44 +72,40 @@ class AddressBookMultiGetReport implements XmlDeserializable {
* the next element.
*
* @param Reader $reader
+ *
* @return mixed
*/
- static function xmlDeserialize(Reader $reader) {
-
+ public static function xmlDeserialize(Reader $reader)
+ {
$elems = $reader->parseInnerTree([
'{urn:ietf:params:xml:ns:carddav}address-data' => 'Sabre\\CardDAV\\Xml\\Filter\\AddressData',
- '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
+ '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
]);
$newProps = [
- 'hrefs' => [],
- 'properties' => []
+ 'hrefs' => [],
+ 'properties' => [],
];
foreach ($elems as $elem) {
-
switch ($elem['name']) {
-
- case '{DAV:}prop' :
+ case '{DAV:}prop':
$newProps['properties'] = array_keys($elem['value']);
- if (isset($elem['value']['{' . Plugin::NS_CARDDAV . '}address-data'])) {
- $newProps += $elem['value']['{' . Plugin::NS_CARDDAV . '}address-data'];
+ if (isset($elem['value']['{'.Plugin::NS_CARDDAV.'}address-data'])) {
+ $newProps += $elem['value']['{'.Plugin::NS_CARDDAV.'}address-data'];
}
break;
- case '{DAV:}href' :
+ case '{DAV:}href':
$newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']);
break;
-
}
-
}
$obj = new self();
foreach ($newProps as $key => $value) {
$obj->$key = $value;
}
- return $obj;
+ return $obj;
}
-
}
diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookQueryReport.php b/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookQueryReport.php
index 09fad008a..0e6f26d38 100644
--- a/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookQueryReport.php
+++ b/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookQueryReport.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CardDAV\Xml\Request;
use Sabre\CardDAV\Plugin;
@@ -19,8 +21,8 @@ use Sabre\Xml\XmlDeserializable;
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class AddressBookQueryReport implements XmlDeserializable {
-
+class AddressBookQueryReport implements XmlDeserializable
+{
/**
* An array with requested properties.
*
@@ -64,7 +66,7 @@ class AddressBookQueryReport implements XmlDeserializable {
public $filters;
/**
- * The number of results the client wants
+ * The number of results the client wants.
*
* null means it wasn't specified, which in most cases means 'all results'.
*
@@ -73,7 +75,7 @@ class AddressBookQueryReport implements XmlDeserializable {
public $limit;
/**
- * Either 'anyof' or 'allof'
+ * Either 'anyof' or 'allof'.
*
* @var string
*/
@@ -95,7 +97,6 @@ class AddressBookQueryReport implements XmlDeserializable {
*/
public $version = null;
-
/**
* The deserialize method is called during xml parsing.
*
@@ -115,65 +116,64 @@ class AddressBookQueryReport implements XmlDeserializable {
* the next element.
*
* @param Reader $reader
+ *
* @return mixed
*/
- static function xmlDeserialize(Reader $reader) {
-
- $elems = (array)$reader->parseInnerTree([
- '{urn:ietf:params:xml:ns:carddav}prop-filter' => 'Sabre\\CardDAV\\Xml\\Filter\\PropFilter',
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $elems = (array) $reader->parseInnerTree([
+ '{urn:ietf:params:xml:ns:carddav}prop-filter' => 'Sabre\\CardDAV\\Xml\\Filter\\PropFilter',
'{urn:ietf:params:xml:ns:carddav}param-filter' => 'Sabre\\CardDAV\\Xml\\Filter\\ParamFilter',
'{urn:ietf:params:xml:ns:carddav}address-data' => 'Sabre\\CardDAV\\Xml\\Filter\\AddressData',
- '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
+ '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
]);
$newProps = [
- 'filters' => null,
+ 'filters' => null,
'properties' => [],
- 'test' => 'anyof',
- 'limit' => null,
+ 'test' => 'anyof',
+ 'limit' => null,
];
- if (!is_array($elems)) $elems = [];
+ if (!is_array($elems)) {
+ $elems = [];
+ }
foreach ($elems as $elem) {
-
switch ($elem['name']) {
-
- case '{DAV:}prop' :
+ case '{DAV:}prop':
$newProps['properties'] = array_keys($elem['value']);
- if (isset($elem['value']['{' . Plugin::NS_CARDDAV . '}address-data'])) {
- $newProps += $elem['value']['{' . Plugin::NS_CARDDAV . '}address-data'];
+ if (isset($elem['value']['{'.Plugin::NS_CARDDAV.'}address-data'])) {
+ $newProps += $elem['value']['{'.Plugin::NS_CARDDAV.'}address-data'];
}
break;
- case '{' . Plugin::NS_CARDDAV . '}filter' :
+ case '{'.Plugin::NS_CARDDAV.'}filter':
if (!is_null($newProps['filters'])) {
- throw new BadRequest('You can only include 1 {' . Plugin::NS_CARDDAV . '}filter element');
+ throw new BadRequest('You can only include 1 {'.Plugin::NS_CARDDAV.'}filter element');
}
if (isset($elem['attributes']['test'])) {
$newProps['test'] = $elem['attributes']['test'];
- if ($newProps['test'] !== 'allof' && $newProps['test'] !== 'anyof') {
+ if ('allof' !== $newProps['test'] && 'anyof' !== $newProps['test']) {
throw new BadRequest('The "test" attribute must be one of "allof" or "anyof"');
}
}
$newProps['filters'] = [];
- foreach ((array)$elem['value'] as $subElem) {
- if ($subElem['name'] === '{' . Plugin::NS_CARDDAV . '}prop-filter') {
+ foreach ((array) $elem['value'] as $subElem) {
+ if ($subElem['name'] === '{'.Plugin::NS_CARDDAV.'}prop-filter') {
$newProps['filters'][] = $subElem['value'];
}
}
break;
- case '{' . Plugin::NS_CARDDAV . '}limit' :
+ case '{'.Plugin::NS_CARDDAV.'}limit':
foreach ($elem['value'] as $child) {
- if ($child['name'] === '{' . Plugin::NS_CARDDAV . '}nresults') {
- $newProps['limit'] = (int)$child['value'];
+ if ($child['name'] === '{'.Plugin::NS_CARDDAV.'}nresults') {
+ $newProps['limit'] = (int) $child['value'];
}
}
break;
-
}
-
}
if (is_null($newProps['filters'])) {
@@ -184,7 +184,6 @@ class AddressBookQueryReport implements XmlDeserializable {
*/
//throw new BadRequest('The {' . Plugin::NS_CARDDAV . '}filter element is required for this request');
$newProps['filters'] = [];
-
}
$obj = new self();
@@ -193,7 +192,5 @@ class AddressBookQueryReport implements XmlDeserializable {
}
return $obj;
-
}
-
}