diff options
author | Mario <mario@mariovavti.com> | 2019-11-10 12:49:51 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-11-10 14:10:03 +0100 |
commit | 580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch) | |
tree | 82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/lib | |
parent | d22766f458a8539a40a57f3946459a9be1f21cd6 (diff) | |
download | volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2 volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip |
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/lib')
223 files changed, 6890 insertions, 7561 deletions
diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php b/vendor/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php index 311b1c415..336e104c8 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\CalDAV; @@ -14,8 +16,8 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface { - +abstract class AbstractBackend implements BackendInterface +{ /** * Updates properties for a calendar. * @@ -28,12 +30,11 @@ abstract class AbstractBackend implements BackendInterface { * * Read the PropPatch documentation for more info and examples. * - * @param mixed $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) { - + public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) + { } /** @@ -46,14 +47,14 @@ abstract class AbstractBackend implements BackendInterface { * * @param mixed $calendarId * @param array $uris + * * @return array */ - function getMultipleCalendarObjects($calendarId, array $uris) { - - return array_map(function($uri) use ($calendarId) { + public function getMultipleCalendarObjects($calendarId, array $uris) + { + return array_map(function ($uri) use ($calendarId) { return $this->getCalendarObject($calendarId, $uri); }, $uris); - } /** @@ -103,23 +104,21 @@ abstract class AbstractBackend implements BackendInterface { * * @param mixed $calendarId * @param array $filters + * * @return array */ - function calendarQuery($calendarId, array $filters) { - + public function calendarQuery($calendarId, array $filters) + { $result = []; $objects = $this->getCalendarObjects($calendarId); foreach ($objects as $object) { - if ($this->validateFilterForObject($object, $filters)) { $result[] = $object['uri']; } - } return $result; - } /** @@ -128,10 +127,11 @@ abstract class AbstractBackend implements BackendInterface { * * @param array $object * @param array $filters + * * @return bool */ - protected function validateFilterForObject(array $object, array $filters) { - + protected function validateFilterForObject(array $object, array $filters) + { // Unfortunately, setting the 'calendardata' here is optional. If // it was excluded, we actually need another call to get this as // well. @@ -148,7 +148,6 @@ abstract class AbstractBackend implements BackendInterface { $vObject->destroy(); return $result; - } /** @@ -168,14 +167,14 @@ abstract class AbstractBackend implements BackendInterface { * * @param string $principalUri * @param string $uid + * * @return string|null */ - function getCalendarObjectByUID($principalUri, $uid) { - + public function getCalendarObjectByUID($principalUri, $uid) + { // Note: this is a super slow naive implementation of this method. You // are highly recommended to optimize it, if your backend allows it. foreach ($this->getCalendarsForUser($principalUri) as $calendar) { - // We must ignore calendars owned by other principals. if ($calendar['principaluri'] !== $principalUri) { continue; @@ -189,38 +188,35 @@ abstract class AbstractBackend implements BackendInterface { $results = $this->calendarQuery( $calendar['id'], [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'prop-filters' => [], 'comp-filters' => [ [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'is-not-defined' => false, - 'time-range' => null, - 'comp-filters' => [], - 'prop-filters' => [ + 'time-range' => null, + 'comp-filters' => [], + 'prop-filters' => [ [ - 'name' => 'UID', + 'name' => 'UID', 'is-not-defined' => false, - 'time-range' => null, - 'text-match' => [ - 'value' => $uid, + 'time-range' => null, + 'text-match' => [ + 'value' => $uid, 'negate-condition' => false, - 'collation' => 'i;octet', + 'collation' => 'i;octet', ], 'param-filters' => [], ], - ] - ] + ], + ], ], ] ); if ($results) { // We have a match - return $calendar['uri'] . '/' . $results[0]; + return $calendar['uri'].'/'.$results[0]; } - } - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php b/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php index bd8ee7602..7d125cf89 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; /** @@ -9,8 +11,8 @@ namespace Sabre\CalDAV\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * Returns a list of calendars for a principal. * @@ -34,9 +36,10 @@ interface BackendInterface { * ACL will automatically be put in read-only mode. * * @param string $principalUri + * * @return array */ - function getCalendarsForUser($principalUri); + public function getCalendarsForUser($principalUri); /** * Creates a new calendar for a principal. @@ -48,10 +51,11 @@ interface BackendInterface { * * @param string $principalUri * @param string $calendarUri - * @param array $properties + * @param array $properties + * * @return mixed */ - function createCalendar($principalUri, $calendarUri, array $properties); + public function createCalendar($principalUri, $calendarUri, array $properties); /** * Updates properties for a calendar. @@ -65,19 +69,17 @@ interface BackendInterface { * * Read the PropPatch documentation for more info and examples. * - * @param mixed $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch); + public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch); /** - * Delete a calendar and all its objects + * Delete a calendar and all its objects. * * @param mixed $calendarId - * @return void */ - function deleteCalendar($calendarId); + public function deleteCalendar($calendarId); /** * Returns all calendar objects within a calendar. @@ -108,9 +110,10 @@ interface BackendInterface { * amount of times this is needed is reduced by a great degree. * * @param mixed $calendarId + * * @return array */ - function getCalendarObjects($calendarId); + public function getCalendarObjects($calendarId); /** * Returns information from a single calendar object, based on it's object @@ -124,11 +127,12 @@ interface BackendInterface { * * This method must return null if the object did not exist. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri + * * @return array|null */ - function getCalendarObject($calendarId, $objectUri); + public function getCalendarObject($calendarId, $objectUri); /** * Returns a list of calendar objects. @@ -140,9 +144,10 @@ interface BackendInterface { * * @param mixed $calendarId * @param array $uris + * * @return array */ - function getMultipleCalendarObjects($calendarId, array $uris); + public function getMultipleCalendarObjects($calendarId, array $uris); /** * Creates a new calendar object. @@ -157,12 +162,13 @@ interface BackendInterface { * calendar-data. If the result of a subsequent GET to this object is not * the exact same as this request body, you should omit the ETag. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri * @param string $calendarData + * * @return string|null */ - function createCalendarObject($calendarId, $objectUri, $calendarData); + public function createCalendarObject($calendarId, $objectUri, $calendarData); /** * Updates an existing calendarobject, based on it's uri. @@ -177,23 +183,23 @@ interface BackendInterface { * calendar-data. If the result of a subsequent GET to this object is not * the exact same as this request body, you should omit the ETag. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri * @param string $calendarData + * * @return string|null */ - function updateCalendarObject($calendarId, $objectUri, $calendarData); + public function updateCalendarObject($calendarId, $objectUri, $calendarData); /** * Deletes an existing calendar object. * * The object uri is only the basename, or filename and not a full path. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri - * @return void */ - function deleteCalendarObject($calendarId, $objectUri); + public function deleteCalendarObject($calendarId, $objectUri); /** * Performs a calendar-query on the contents of this calendar. @@ -242,9 +248,10 @@ interface BackendInterface { * * @param mixed $calendarId * @param array $filters + * * @return array */ - function calendarQuery($calendarId, array $filters); + public function calendarQuery($calendarId, array $filters); /** * Searches through all of a users calendars and calendar objects to find @@ -263,8 +270,8 @@ interface BackendInterface { * * @param string $principalUri * @param string $uid + * * @return string|null */ - function getCalendarObjectByUID($principalUri, $uid); - + public function getCalendarObjectByUID($principalUri, $uid); } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/NotificationSupport.php b/vendor/sabre/dav/lib/CalDAV/Backend/NotificationSupport.php index bf2ef27a0..0ba493305 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/NotificationSupport.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/NotificationSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\CalDAV\Xml\Notification\NotificationInterface; @@ -22,26 +24,26 @@ use Sabre\CalDAV\Xml\Notification\NotificationInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface NotificationSupport extends BackendInterface { - +interface NotificationSupport extends BackendInterface +{ /** * Returns a list of notifications for a given principal url. * * @param string $principalUri + * * @return NotificationInterface[] */ - function getNotificationsForPrincipal($principalUri); + public function getNotificationsForPrincipal($principalUri); /** * This deletes a specific notifcation. * * This may be called by a client once it deems a notification handled. * - * @param string $principalUri + * @param string $principalUri * @param NotificationInterface $notification - * @return void */ - function deleteNotification($principalUri, NotificationInterface $notification); + public function deleteNotification($principalUri, NotificationInterface $notification); /** * This method is called when a user replied to a request to share. @@ -49,13 +51,13 @@ interface NotificationSupport extends BackendInterface { * If the user chose to accept the share, this method should return the * newly created calendar url. * - * @param string $href The sharee who is replying (often a mailto: address) - * @param int $status One of the SharingPlugin::STATUS_* constants + * @param string $href The sharee who is replying (often a mailto: address) + * @param int $status One of the SharingPlugin::STATUS_* constants * @param string $calendarUri The url to the calendar thats being shared - * @param string $inReplyTo The unique id this message is a response to - * @param string $summary A description of the reply - * @return null|string + * @param string $inReplyTo The unique id this message is a response to + * @param string $summary A description of the reply + * + * @return string|null */ - function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null); - + public function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null); } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php b/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php index 458440588..003dc1392 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\CalDAV; @@ -9,7 +11,7 @@ use Sabre\DAV\Xml\Element\Sharee; use Sabre\VObject; /** - * PDO CalDAV backend + * PDO CalDAV backend. * * This backend is used to store calendar-data in a PDO database, such as * sqlite or MySQL @@ -18,15 +20,10 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend - implements - SyncSupport, - SubscriptionSupport, - SchedulingSupport, - SharingSupport { - +class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, SchedulingSupport, SharingSupport +{ /** - * We need to specify a max date, because we need to stop *somewhere* + * We need to specify a max date, because we need to stop *somewhere*. * * On 32 bit system the maximum for a signed integer is 2147483647, so * MAX_DATE cannot be higher than date('Y-m-d', 2147483647) which results @@ -36,14 +33,14 @@ class PDO extends AbstractBackend const MAX_DATE = '2038-01-01'; /** - * pdo + * pdo. * * @var \PDO */ protected $pdo; /** - * The table name that will be used for calendars + * The table name that will be used for calendars. * * @var string */ @@ -60,7 +57,7 @@ class PDO extends AbstractBackend public $calendarInstancesTableName = 'calendarinstances'; /** - * The table name that will be used for calendar objects + * The table name that will be used for calendar objects. * * @var string */ @@ -96,11 +93,11 @@ class PDO extends AbstractBackend * @var array */ public $propertyMap = [ - '{DAV:}displayname' => 'displayname', + '{DAV:}displayname' => 'displayname', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'description', - '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => 'timezone', - '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', - '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', + '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => 'timezone', + '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', + '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', ]; /** @@ -109,24 +106,23 @@ class PDO extends AbstractBackend * @var array */ public $subscriptionPropertyMap = [ - '{DAV:}displayname' => 'displayname', - '{http://apple.com/ns/ical/}refreshrate' => 'refreshrate', - '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', - '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', - '{http://calendarserver.org/ns/}subscribed-strip-todos' => 'striptodos', - '{http://calendarserver.org/ns/}subscribed-strip-alarms' => 'stripalarms', + '{DAV:}displayname' => 'displayname', + '{http://apple.com/ns/ical/}refreshrate' => 'refreshrate', + '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', + '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', + '{http://calendarserver.org/ns/}subscribed-strip-todos' => 'striptodos', + '{http://calendarserver.org/ns/}subscribed-strip-alarms' => 'stripalarms', '{http://calendarserver.org/ns/}subscribed-strip-attachments' => 'stripattachments', ]; /** - * Creates the backend + * Creates the backend. * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -151,10 +147,11 @@ class PDO extends AbstractBackend * ACL will automatically be put in read-only mode. * * @param string $principalUri + * * @return array */ - function getCalendarsForUser($principalUri) { - + public function getCalendarsForUser($principalUri) + { $fields = array_values($this->propertyMap); $fields[] = 'calendarid'; $fields[] = 'uri'; @@ -177,24 +174,23 @@ SQL $calendars = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $components = []; if ($row['components']) { $components = explode(',', $row['components']); } $calendar = [ - 'id' => [(int)$row['calendarid'], (int)$row['id']], - 'uri' => $row['uri'], - 'principaluri' => $row['principaluri'], - '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken'] ? $row['synctoken'] : '0'), - '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', - '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet($components), - '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'), - 'share-resource-uri' => '/ns/share/' . $row['calendarid'], + 'id' => [(int) $row['calendarid'], (int) $row['id']], + 'uri' => $row['uri'], + 'principaluri' => $row['principaluri'], + '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'), + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', + '{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet($components), + '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'), + 'share-resource-uri' => '/ns/share/'.$row['calendarid'], ]; - $calendar['share-access'] = (int)$row['access']; + $calendar['share-access'] = (int) $row['access']; // 1 = owner, 2 = readonly, 3 = readwrite if ($row['access'] > 1) { // We need to find more information about the original owner. @@ -203,7 +199,7 @@ SQL // read-only is for backwards compatbility. Might go away in // the future. - $calendar['read-only'] = (int)$row['access'] === \Sabre\DAV\Sharing\Plugin::ACCESS_READ; + $calendar['read-only'] = \Sabre\DAV\Sharing\Plugin::ACCESS_READ === (int) $row['access']; } foreach ($this->propertyMap as $xmlName => $dbName) { @@ -211,11 +207,9 @@ SQL } $calendars[] = $calendar; - } return $calendars; - } /** @@ -226,11 +220,12 @@ SQL * * @param string $principalUri * @param string $calendarUri - * @param array $properties + * @param array $properties + * * @return string */ - function createCalendar($principalUri, $calendarUri, array $properties) { - + public function createCalendar($principalUri, $calendarUri, array $properties) + { $fieldNames = [ 'principaluri', 'uri', @@ -239,51 +234,48 @@ SQL ]; $values = [ ':principaluri' => $principalUri, - ':uri' => $calendarUri, - ':transparent' => 0, + ':uri' => $calendarUri, + ':transparent' => 0, ]; - $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; if (!isset($properties[$sccs])) { // Default value $components = 'VEVENT,VTODO'; } else { if (!($properties[$sccs] instanceof CalDAV\Xml\Property\SupportedCalendarComponentSet)) { - throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet'); + throw new DAV\Exception('The '.$sccs.' property must be of type: \Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet'); } $components = implode(',', $properties[$sccs]->getValue()); } - $transp = '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp'; + $transp = '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp'; if (isset($properties[$transp])) { - $values[':transparent'] = $properties[$transp]->getValue() === 'transparent' ? 1 : 0; + $values[':transparent'] = 'transparent' === $properties[$transp]->getValue() ? 1 : 0; } - $stmt = $this->pdo->prepare("INSERT INTO " . $this->calendarTableName . " (synctoken, components) VALUES (1, ?)"); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarTableName.' (synctoken, components) VALUES (1, ?)'); $stmt->execute([$components]); $calendarId = $this->pdo->lastInsertId( - $this->calendarTableName . '_id_seq' + $this->calendarTableName.'_id_seq' ); $values[':calendarid'] = $calendarId; foreach ($this->propertyMap as $xmlName => $dbName) { if (isset($properties[$xmlName])) { - - $values[':' . $dbName] = $properties[$xmlName]; + $values[':'.$dbName] = $properties[$xmlName]; $fieldNames[] = $dbName; } } - $stmt = $this->pdo->prepare("INSERT INTO " . $this->calendarInstancesTableName . " (" . implode(', ', $fieldNames) . ") VALUES (" . implode(', ', array_keys($values)) . ")"); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarInstancesTableName.' ('.implode(', ', $fieldNames).') VALUES ('.implode(', ', array_keys($values)).')'); $stmt->execute($values); return [ $calendarId, - $this->pdo->lastInsertId($this->calendarInstancesTableName . '_id_seq') + $this->pdo->lastInsertId($this->calendarInstancesTableName.'_id_seq'), ]; - } /** @@ -298,100 +290,88 @@ SQL * * Read the PropPatch documentation for more info and examples. * - * @param mixed $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) { - + public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } list($calendarId, $instanceId) = $calendarId; $supportedProperties = array_keys($this->propertyMap); - $supportedProperties[] = '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp'; + $supportedProperties[] = '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp'; - $propPatch->handle($supportedProperties, function($mutations) use ($calendarId, $instanceId) { + $propPatch->handle($supportedProperties, function ($mutations) use ($calendarId, $instanceId) { $newValues = []; foreach ($mutations as $propertyName => $propertyValue) { - switch ($propertyName) { - case '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' : + case '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp': $fieldName = 'transparent'; - $newValues[$fieldName] = $propertyValue->getValue() === 'transparent'; + $newValues[$fieldName] = 'transparent' === $propertyValue->getValue(); break; - default : + default: $fieldName = $this->propertyMap[$propertyName]; $newValues[$fieldName] = $propertyValue; break; } - } $valuesSql = []; foreach ($newValues as $fieldName => $value) { - $valuesSql[] = $fieldName . ' = ?'; + $valuesSql[] = $fieldName.' = ?'; } - $stmt = $this->pdo->prepare("UPDATE " . $this->calendarInstancesTableName . " SET " . implode(', ', $valuesSql) . " WHERE id = ?"); + $stmt = $this->pdo->prepare('UPDATE '.$this->calendarInstancesTableName.' SET '.implode(', ', $valuesSql).' WHERE id = ?'); $newValues['id'] = $instanceId; $stmt->execute(array_values($newValues)); - $this->addChange($calendarId, "", 2); + $this->addChange($calendarId, '', 2); return true; - }); - } /** - * Delete a calendar and all it's objects + * Delete a calendar and all it's objects. * * @param mixed $calendarId - * @return void */ - function deleteCalendar($calendarId) { - + public function deleteCalendar($calendarId) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } list($calendarId, $instanceId) = $calendarId; - $stmt = $this->pdo->prepare('SELECT access FROM ' . $this->calendarInstancesTableName . ' where id = ?'); + $stmt = $this->pdo->prepare('SELECT access FROM '.$this->calendarInstancesTableName.' where id = ?'); $stmt->execute([$instanceId]); - $access = (int)$stmt->fetchColumn(); - - if ($access === \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER) { + $access = (int) $stmt->fetchColumn(); + if (\Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER === $access) { /** * If the user is the owner of the calendar, we delete all data and all * instances. **/ - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?'); $stmt->execute([$calendarId]); - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarChangesTableName . ' WHERE calendarid = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarChangesTableName.' WHERE calendarid = ?'); $stmt->execute([$calendarId]); - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarInstancesTableName . ' WHERE calendarid = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarInstancesTableName.' WHERE calendarid = ?'); $stmt->execute([$calendarId]); - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarTableName . ' WHERE id = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarTableName.' WHERE id = ?'); $stmt->execute([$calendarId]); - } else { - /** * If it was an instance of a shared calendar, we only delete that * instance. */ - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarInstancesTableName . ' WHERE id = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarInstancesTableName.' WHERE id = ?'); $stmt->execute([$instanceId]); - } - - } /** @@ -423,32 +403,32 @@ SQL * amount of times this is needed is reduced by a great degree. * * @param mixed $calendarId + * * @return array */ - function getCalendarObjects($calendarId) { - + public function getCalendarObjects($calendarId) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } list($calendarId, $instanceId) = $calendarId; - $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, componenttype FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ?'); + $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, componenttype FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?'); $stmt->execute([$calendarId]); $result = []; foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { $result[] = [ - 'id' => $row['id'], - 'uri' => $row['uri'], - 'lastmodified' => (int)$row['lastmodified'], - 'etag' => '"' . $row['etag'] . '"', - 'size' => (int)$row['size'], - 'component' => strtolower($row['componenttype']), + 'id' => $row['id'], + 'uri' => $row['uri'], + 'lastmodified' => (int) $row['lastmodified'], + 'etag' => '"'.$row['etag'].'"', + 'size' => (int) $row['size'], + 'component' => strtolower($row['componenttype']), ]; } return $result; - } /** @@ -463,33 +443,35 @@ SQL * * This method must return null if the object did not exist. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri + * * @return array|null */ - function getCalendarObject($calendarId, $objectUri) { - + public function getCalendarObject($calendarId, $objectUri) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } list($calendarId, $instanceId) = $calendarId; - $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, calendardata, componenttype FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ? AND uri = ?'); + $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, calendardata, componenttype FROM '.$this->calendarObjectTableName.' WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarId, $objectUri]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if (!$row) return null; + if (!$row) { + return null; + } return [ - 'id' => $row['id'], - 'uri' => $row['uri'], - 'lastmodified' => (int)$row['lastmodified'], - 'etag' => '"' . $row['etag'] . '"', - 'size' => (int)$row['size'], + 'id' => $row['id'], + 'uri' => $row['uri'], + 'lastmodified' => (int) $row['lastmodified'], + 'etag' => '"'.$row['etag'].'"', + 'size' => (int) $row['size'], 'calendardata' => $row['calendardata'], - 'component' => strtolower($row['componenttype']), + 'component' => strtolower($row['componenttype']), ]; - } /** @@ -502,10 +484,11 @@ SQL * * @param mixed $calendarId * @param array $uris + * * @return array */ - function getMultipleCalendarObjects($calendarId, array $uris) { - + public function getMultipleCalendarObjects($calendarId, array $uris) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } @@ -513,7 +496,7 @@ SQL $result = []; foreach (array_chunk($uris, 900) as $chunk) { - $query = 'SELECT id, uri, lastmodified, etag, calendarid, size, calendardata, componenttype FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ? AND uri IN ('; + $query = 'SELECT id, uri, lastmodified, etag, calendarid, size, calendardata, componenttype FROM '.$this->calendarObjectTableName.' WHERE calendarid = ? AND uri IN ('; // Inserting a whole bunch of question marks $query .= implode(',', array_fill(0, count($chunk), '?')); $query .= ')'; @@ -522,24 +505,21 @@ SQL $stmt->execute(array_merge([$calendarId], $chunk)); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $result[] = [ - 'id' => $row['id'], - 'uri' => $row['uri'], - 'lastmodified' => (int)$row['lastmodified'], - 'etag' => '"' . $row['etag'] . '"', - 'size' => (int)$row['size'], + 'id' => $row['id'], + 'uri' => $row['uri'], + 'lastmodified' => (int) $row['lastmodified'], + 'etag' => '"'.$row['etag'].'"', + 'size' => (int) $row['size'], 'calendardata' => $row['calendardata'], - 'component' => strtolower($row['componenttype']), + 'component' => strtolower($row['componenttype']), ]; - } } - return $result; + return $result; } - /** * Creates a new calendar object. * @@ -553,13 +533,14 @@ SQL * calendar-data. If the result of a subsequent GET to this object is not * the exact same as this request body, you should omit the ETag. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri * @param string $calendarData + * * @return string|null */ - function createCalendarObject($calendarId, $objectUri, $calendarData) { - + public function createCalendarObject($calendarId, $objectUri, $calendarData) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } @@ -567,7 +548,7 @@ SQL $extraData = $this->getDenormalizedData($calendarData); - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->calendarObjectTableName . ' (calendarid, uri, calendardata, lastmodified, etag, size, componenttype, firstoccurence, lastoccurence, uid) VALUES (?,?,?,?,?,?,?,?,?,?)'); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarObjectTableName.' (calendarid, uri, calendardata, lastmodified, etag, size, componenttype, firstoccurence, lastoccurence, uid) VALUES (?,?,?,?,?,?,?,?,?,?)'); $stmt->execute([ $calendarId, $objectUri, @@ -582,8 +563,7 @@ SQL ]); $this->addChange($calendarId, $objectUri, 1); - return '"' . $extraData['etag'] . '"'; - + return '"'.$extraData['etag'].'"'; } /** @@ -599,13 +579,14 @@ SQL * calendar-data. If the result of a subsequent GET to this object is not * the exact same as this request body, you should omit the ETag. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri * @param string $calendarData + * * @return string|null */ - function updateCalendarObject($calendarId, $objectUri, $calendarData) { - + public function updateCalendarObject($calendarId, $objectUri, $calendarData) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } @@ -613,13 +594,12 @@ SQL $extraData = $this->getDenormalizedData($calendarData); - $stmt = $this->pdo->prepare('UPDATE ' . $this->calendarObjectTableName . ' SET calendardata = ?, lastmodified = ?, etag = ?, size = ?, componenttype = ?, firstoccurence = ?, lastoccurence = ?, uid = ? WHERE calendarid = ? AND uri = ?'); + $stmt = $this->pdo->prepare('UPDATE '.$this->calendarObjectTableName.' SET calendardata = ?, lastmodified = ?, etag = ?, size = ?, componenttype = ?, firstoccurence = ?, lastoccurence = ?, uid = ? WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarData, time(), $extraData['etag'], $extraData['size'], $extraData['componentType'], $extraData['firstOccurence'], $extraData['lastOccurence'], $extraData['uid'], $calendarId, $objectUri]); $this->addChange($calendarId, $objectUri, 2); - return '"' . $extraData['etag'] . '"'; - + return '"'.$extraData['etag'].'"'; } /** @@ -635,10 +615,11 @@ SQL * * uid - value of the UID property * * @param string $calendarData + * * @return array */ - protected function getDenormalizedData($calendarData) { - + protected function getDenormalizedData($calendarData) + { $vObject = VObject\Reader::read($calendarData); $componentType = null; $component = null; @@ -646,16 +627,16 @@ SQL $lastOccurence = null; $uid = null; foreach ($vObject->getComponents() as $component) { - if ($component->name !== 'VTIMEZONE') { + if ('VTIMEZONE' !== $component->name) { $componentType = $component->name; - $uid = (string)$component->UID; + $uid = (string) $component->UID; break; } } if (!$componentType) { throw new \Sabre\DAV\Exception\BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component'); } - if ($componentType === 'VEVENT') { + if ('VEVENT' === $componentType) { $firstOccurence = $component->DTSTART->getDateTime()->getTimeStamp(); // Finding the last occurence is a bit harder if (!isset($component->RRULE)) { @@ -673,7 +654,7 @@ SQL $lastOccurence = $firstOccurence; } } else { - $it = new VObject\Recur\EventIterator($vObject, (string)$component->UID); + $it = new VObject\Recur\EventIterator($vObject, (string) $component->UID); $maxDate = new \DateTime(self::MAX_DATE); if ($it->isInfinite()) { $lastOccurence = $maxDate->getTimeStamp(); @@ -682,30 +663,31 @@ SQL while ($it->valid() && $end < $maxDate) { $end = $it->getDtEnd(); $it->next(); - } $lastOccurence = $end->getTimeStamp(); } - } // Ensure Occurence values are positive - if ($firstOccurence < 0) $firstOccurence = 0; - if ($lastOccurence < 0) $lastOccurence = 0; + if ($firstOccurence < 0) { + $firstOccurence = 0; + } + if ($lastOccurence < 0) { + $lastOccurence = 0; + } } // Destroy circular references to PHP will GC the object. $vObject->destroy(); return [ - 'etag' => md5($calendarData), - 'size' => strlen($calendarData), - 'componentType' => $componentType, + 'etag' => md5($calendarData), + 'size' => strlen($calendarData), + 'componentType' => $componentType, 'firstOccurence' => $firstOccurence, - 'lastOccurence' => $lastOccurence, - 'uid' => $uid, + 'lastOccurence' => $lastOccurence, + 'uid' => $uid, ]; - } /** @@ -713,22 +695,20 @@ SQL * * The object uri is only the basename, or filename and not a full path. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri - * @return void */ - function deleteCalendarObject($calendarId, $objectUri) { - + public function deleteCalendarObject($calendarId, $objectUri) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } list($calendarId, $instanceId) = $calendarId; - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ? AND uri = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarObjectTableName.' WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarId, $objectUri]); $this->addChange($calendarId, $objectUri, 3); - } /** @@ -781,10 +761,11 @@ SQL * * @param mixed $calendarId * @param array $filters + * * @return array */ - function calendarQuery($calendarId, array $filters) { - + public function calendarQuery($calendarId, array $filters) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } @@ -808,7 +789,7 @@ SQL $requirePostFilter = false; } // There was a time-range filter - if ($componentType == 'VEVENT' && isset($filters['comp-filters'][0]['time-range'])) { + if ('VEVENT' == $componentType && isset($filters['comp-filters'][0]['time-range'])) { $timeRange = $filters['comp-filters'][0]['time-range']; // If start time OR the end time is not specified, we can do a @@ -817,13 +798,12 @@ SQL $requirePostFilter = false; } } - } if ($requirePostFilter) { - $query = "SELECT uri, calendardata FROM " . $this->calendarObjectTableName . " WHERE calendarid = :calendarid"; + $query = 'SELECT uri, calendardata FROM '.$this->calendarObjectTableName.' WHERE calendarid = :calendarid'; } else { - $query = "SELECT uri FROM " . $this->calendarObjectTableName . " WHERE calendarid = :calendarid"; + $query = 'SELECT uri FROM '.$this->calendarObjectTableName.' WHERE calendarid = :calendarid'; } $values = [ @@ -831,16 +811,16 @@ SQL ]; if ($componentType) { - $query .= " AND componenttype = :componenttype"; + $query .= ' AND componenttype = :componenttype'; $values['componenttype'] = $componentType; } if ($timeRange && $timeRange['start']) { - $query .= " AND lastoccurence > :startdate"; + $query .= ' AND lastoccurence > :startdate'; $values['startdate'] = $timeRange['start']->getTimeStamp(); } if ($timeRange && $timeRange['end']) { - $query .= " AND firstoccurence < :enddate"; + $query .= ' AND firstoccurence < :enddate'; $values['enddate'] = $timeRange['end']->getTimeStamp(); } @@ -855,11 +835,9 @@ SQL } } $result[] = $row['uri']; - } return $result; - } /** @@ -879,10 +857,11 @@ SQL * * @param string $principalUri * @param string $uid + * * @return string|null */ - function getCalendarObjectByUID($principalUri, $uid) { - + public function getCalendarObjectByUID($principalUri, $uid) + { $query = <<<SQL SELECT calendar_instances.uri AS calendaruri, calendarobjects.uri as objecturi @@ -901,9 +880,8 @@ SQL; $stmt->execute([$principalUri, $uid]); if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - return $row['calendaruri'] . '/' . $row['objecturi']; + return $row['calendaruri'].'/'.$row['objecturi']; } - } /** @@ -956,37 +934,41 @@ SQL; * * The limit is 'suggestive'. You are free to ignore it. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $syncToken - * @param int $syncLevel - * @param int $limit + * @param int $syncLevel + * @param int $limit + * * @return array */ - function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) { - + public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } list($calendarId, $instanceId) = $calendarId; // Current synctoken - $stmt = $this->pdo->prepare('SELECT synctoken FROM ' . $this->calendarTableName . ' WHERE id = ?'); + $stmt = $this->pdo->prepare('SELECT synctoken FROM '.$this->calendarTableName.' WHERE id = ?'); $stmt->execute([$calendarId]); $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->calendarChangesTableName . " WHERE synctoken >= ? AND synctoken < ? AND calendarid = ? ORDER BY synctoken"; - if ($limit > 0) $query .= " LIMIT " . (int)$limit; + $query = 'SELECT uri, operation FROM '.$this->calendarChangesTableName.' WHERE synctoken >= ? AND synctoken < ? AND calendarid = ? ORDER BY synctoken'; + if ($limit > 0) { + $query .= ' LIMIT '.(int) $limit; + } // Fetching all changes $stmt = $this->pdo->prepare($query); @@ -997,60 +979,54 @@ SQL; // 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 : + case 1: $result['added'][] = $uri; break; - case 2 : + case 2: $result['modified'][] = $uri; break; - case 3 : + case 3: $result['deleted'][] = $uri; break; } - } } else { // No synctoken supplied, this is the initial sync. - $query = "SELECT uri FROM " . $this->calendarObjectTableName . " WHERE calendarid = ?"; + $query = 'SELECT uri FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?'; $stmt = $this->pdo->prepare($query); $stmt->execute([$calendarId]); $result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN); } - return $result; + return $result; } /** * Adds a change record to the calendarchanges table. * - * @param mixed $calendarId + * @param mixed $calendarId * @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($calendarId, $objectUri, $operation) { - - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->calendarChangesTableName . ' (uri, synctoken, calendarid, operation) SELECT ?, synctoken, ?, ? FROM ' . $this->calendarTableName . ' WHERE id = ?'); + protected function addChange($calendarId, $objectUri, $operation) + { + $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarChangesTableName.' (uri, synctoken, calendarid, operation) SELECT ?, synctoken, ?, ? FROM '.$this->calendarTableName.' WHERE id = ?'); $stmt->execute([ $objectUri, $calendarId, $operation, - $calendarId + $calendarId, ]); - $stmt = $this->pdo->prepare('UPDATE ' . $this->calendarTableName . ' SET synctoken = synctoken + 1 WHERE id = ?'); + $stmt = $this->pdo->prepare('UPDATE '.$this->calendarTableName.' SET synctoken = synctoken + 1 WHERE id = ?'); $stmt->execute([ - $calendarId + $calendarId, ]); - } /** @@ -1082,10 +1058,11 @@ SQL; * default components). * * @param string $principalUri + * * @return array */ - function getSubscriptionsForUser($principalUri) { - + public function getSubscriptionsForUser($principalUri) + { $fields = array_values($this->subscriptionPropertyMap); $fields[] = 'id'; $fields[] = 'uri'; @@ -1095,20 +1072,19 @@ SQL; // Making fields a comma-delimited list $fields = implode(', ', $fields); - $stmt = $this->pdo->prepare("SELECT " . $fields . " FROM " . $this->calendarSubscriptionsTableName . " WHERE principaluri = ? ORDER BY calendarorder ASC"); + $stmt = $this->pdo->prepare('SELECT '.$fields.' FROM '.$this->calendarSubscriptionsTableName.' WHERE principaluri = ? ORDER BY calendarorder ASC'); $stmt->execute([$principalUri]); $subscriptions = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $subscription = [ - 'id' => $row['id'], - 'uri' => $row['uri'], + 'id' => $row['id'], + 'uri' => $row['uri'], 'principaluri' => $row['principaluri'], - 'source' => $row['source'], + 'source' => $row['source'], 'lastmodified' => $row['lastmodified'], - '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VTODO', 'VEVENT']), + '{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VTODO', 'VEVENT']), ]; foreach ($this->subscriptionPropertyMap as $xmlName => $dbName) { @@ -1118,11 +1094,9 @@ SQL; } $subscriptions[] = $subscription; - } return $subscriptions; - } /** @@ -1133,11 +1107,12 @@ SQL; * * @param string $principalUri * @param string $uri - * @param array $properties + * @param array $properties + * * @return mixed */ - function createSubscription($principalUri, $uri, array $properties) { - + public function createSubscription($principalUri, $uri, array $properties) + { $fieldNames = [ 'principaluri', 'uri', @@ -1151,30 +1126,28 @@ SQL; $values = [ ':principaluri' => $principalUri, - ':uri' => $uri, - ':source' => $properties['{http://calendarserver.org/ns/}source']->getHref(), + ':uri' => $uri, + ':source' => $properties['{http://calendarserver.org/ns/}source']->getHref(), ':lastmodified' => time(), ]; foreach ($this->subscriptionPropertyMap as $xmlName => $dbName) { if (isset($properties[$xmlName])) { - - $values[':' . $dbName] = $properties[$xmlName]; + $values[':'.$dbName] = $properties[$xmlName]; $fieldNames[] = $dbName; } } - $stmt = $this->pdo->prepare("INSERT INTO " . $this->calendarSubscriptionsTableName . " (" . implode(', ', $fieldNames) . ") VALUES (" . implode(', ', array_keys($values)) . ")"); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarSubscriptionsTableName.' ('.implode(', ', $fieldNames).') VALUES ('.implode(', ', array_keys($values)).')'); $stmt->execute($values); return $this->pdo->lastInsertId( - $this->calendarSubscriptionsTableName . '_id_seq' + $this->calendarSubscriptionsTableName.'_id_seq' ); - } /** - * Updates a subscription + * Updates a subscription. * * The list of mutations is stored in a Sabre\DAV\PropPatch object. * To do the actual updates, you must tell this object which properties @@ -1185,58 +1158,50 @@ SQL; * * Read the PropPatch documentation for more info and examples. * - * @param mixed $subscriptionId + * @param mixed $subscriptionId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateSubscription($subscriptionId, DAV\PropPatch $propPatch) { - + public function updateSubscription($subscriptionId, DAV\PropPatch $propPatch) + { $supportedProperties = array_keys($this->subscriptionPropertyMap); $supportedProperties[] = '{http://calendarserver.org/ns/}source'; - $propPatch->handle($supportedProperties, function($mutations) use ($subscriptionId) { - + $propPatch->handle($supportedProperties, function ($mutations) use ($subscriptionId) { $newValues = []; foreach ($mutations as $propertyName => $propertyValue) { - - if ($propertyName === '{http://calendarserver.org/ns/}source') { + if ('{http://calendarserver.org/ns/}source' === $propertyName) { $newValues['source'] = $propertyValue->getHref(); } else { $fieldName = $this->subscriptionPropertyMap[$propertyName]; $newValues[$fieldName] = $propertyValue; } - } // Now we're generating the sql query. $valuesSql = []; foreach ($newValues as $fieldName => $value) { - $valuesSql[] = $fieldName . ' = ?'; + $valuesSql[] = $fieldName.' = ?'; } - $stmt = $this->pdo->prepare("UPDATE " . $this->calendarSubscriptionsTableName . " SET " . implode(', ', $valuesSql) . ", lastmodified = ? WHERE id = ?"); + $stmt = $this->pdo->prepare('UPDATE '.$this->calendarSubscriptionsTableName.' SET '.implode(', ', $valuesSql).', lastmodified = ? WHERE id = ?'); $newValues['lastmodified'] = time(); $newValues['id'] = $subscriptionId; $stmt->execute(array_values($newValues)); return true; - }); - } /** - * Deletes a subscription + * Deletes a subscription. * * @param mixed $subscriptionId - * @return void */ - function deleteSubscription($subscriptionId) { - - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarSubscriptionsTableName . ' WHERE id = ?'); + public function deleteSubscription($subscriptionId) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarSubscriptionsTableName.' WHERE id = ?'); $stmt->execute([$subscriptionId]); - } /** @@ -1253,24 +1218,26 @@ SQL; * * @param string $principalUri * @param string $objectUri + * * @return array */ - function getSchedulingObject($principalUri, $objectUri) { - - $stmt = $this->pdo->prepare('SELECT uri, calendardata, lastmodified, etag, size FROM ' . $this->schedulingObjectTableName . ' WHERE principaluri = ? AND uri = ?'); + public function getSchedulingObject($principalUri, $objectUri) + { + $stmt = $this->pdo->prepare('SELECT uri, calendardata, lastmodified, etag, size FROM '.$this->schedulingObjectTableName.' WHERE principaluri = ? AND uri = ?'); $stmt->execute([$principalUri, $objectUri]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if (!$row) return null; + if (!$row) { + return null; + } return [ - 'uri' => $row['uri'], + 'uri' => $row['uri'], 'calendardata' => $row['calendardata'], 'lastmodified' => $row['lastmodified'], - 'etag' => '"' . $row['etag'] . '"', - 'size' => (int)$row['size'], + 'etag' => '"'.$row['etag'].'"', + 'size' => (int) $row['size'], ]; - } /** @@ -1282,40 +1249,38 @@ SQL; * The main difference is that 'calendardata' is optional. * * @param string $principalUri + * * @return array */ - function getSchedulingObjects($principalUri) { - - $stmt = $this->pdo->prepare('SELECT id, calendardata, uri, lastmodified, etag, size FROM ' . $this->schedulingObjectTableName . ' WHERE principaluri = ?'); + public function getSchedulingObjects($principalUri) + { + $stmt = $this->pdo->prepare('SELECT id, calendardata, uri, lastmodified, etag, size FROM '.$this->schedulingObjectTableName.' WHERE principaluri = ?'); $stmt->execute([$principalUri]); $result = []; foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { $result[] = [ 'calendardata' => $row['calendardata'], - 'uri' => $row['uri'], + 'uri' => $row['uri'], 'lastmodified' => $row['lastmodified'], - 'etag' => '"' . $row['etag'] . '"', - 'size' => (int)$row['size'], + 'etag' => '"'.$row['etag'].'"', + 'size' => (int) $row['size'], ]; } return $result; - } /** - * Deletes a scheduling object + * Deletes a scheduling object. * * @param string $principalUri * @param string $objectUri - * @return void */ - function deleteSchedulingObject($principalUri, $objectUri) { - - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->schedulingObjectTableName . ' WHERE principaluri = ? AND uri = ?'); + public function deleteSchedulingObject($principalUri, $objectUri) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->schedulingObjectTableName.' WHERE principaluri = ? AND uri = ?'); $stmt->execute([$principalUri, $objectUri]); - } /** @@ -1324,35 +1289,32 @@ SQL; * @param string $principalUri * @param string $objectUri * @param string $objectData - * @return void */ - function createSchedulingObject($principalUri, $objectUri, $objectData) { - - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->schedulingObjectTableName . ' (principaluri, calendardata, uri, lastmodified, etag, size) VALUES (?, ?, ?, ?, ?, ?)'); + public function createSchedulingObject($principalUri, $objectUri, $objectData) + { + $stmt = $this->pdo->prepare('INSERT INTO '.$this->schedulingObjectTableName.' (principaluri, calendardata, uri, lastmodified, etag, size) VALUES (?, ?, ?, ?, ?, ?)'); $stmt->execute([$principalUri, $objectData, $objectUri, time(), md5($objectData), strlen($objectData)]); - } /** * Updates the list of shares. * - * @param mixed $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees - * @return void */ - function updateInvites($calendarId, array $sharees) { - + public function updateInvites($calendarId, array $sharees) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } $currentInvites = $this->getInvites($calendarId); list($calendarId, $instanceId) = $calendarId; - $removeStmt = $this->pdo->prepare("DELETE FROM " . $this->calendarInstancesTableName . " WHERE calendarid = ? AND share_href = ? AND access IN (2,3)"); - $updateStmt = $this->pdo->prepare("UPDATE " . $this->calendarInstancesTableName . " SET access = ?, share_displayname = ?, share_invitestatus = ? WHERE calendarid = ? AND share_href = ?"); + $removeStmt = $this->pdo->prepare('DELETE FROM '.$this->calendarInstancesTableName.' WHERE calendarid = ? AND share_href = ? AND access IN (2,3)'); + $updateStmt = $this->pdo->prepare('UPDATE '.$this->calendarInstancesTableName.' SET access = ?, share_displayname = ?, share_invitestatus = ? WHERE calendarid = ? AND share_href = ?'); $insertStmt = $this->pdo->prepare(' -INSERT INTO ' . $this->calendarInstancesTableName . ' +INSERT INTO '.$this->calendarInstancesTableName.' ( calendarid, principaluri, @@ -1382,11 +1344,10 @@ INSERT INTO ' . $this->calendarInstancesTableName . ' ?, ?, ? - FROM ' . $this->calendarInstancesTableName . ' WHERE id = ?'); + FROM '.$this->calendarInstancesTableName.' WHERE id = ?'); foreach ($sharees as $sharee) { - - if ($sharee->access === \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS) { + if (\Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS === $sharee->access) { // if access was set no NOACCESS, it means access for an // existing sharee was removed. $removeStmt->execute([$calendarId, $sharee->href]); @@ -1404,7 +1365,6 @@ INSERT INTO ' . $this->calendarInstancesTableName . ' } foreach ($currentInvites as $oldSharee) { - if ($oldSharee->href === $sharee->href) { // This is an update $sharee->properties = array_merge( @@ -1416,11 +1376,10 @@ INSERT INTO ' . $this->calendarInstancesTableName . ' isset($sharee->properties['{DAV:}displayname']) ? $sharee->properties['{DAV:}displayname'] : null, $sharee->inviteStatus ?: $oldSharee->inviteStatus, $calendarId, - $sharee->href + $sharee->href, ]); continue 2; } - } // If we got here, it means it was a new sharee $insertStmt->execute([ @@ -1431,11 +1390,9 @@ INSERT INTO ' . $this->calendarInstancesTableName . ' $sharee->href, isset($sharee->properties['{DAV:}displayname']) ? $sharee->properties['{DAV:}displayname'] : null, $sharee->inviteStatus ?: \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE, - $instanceId + $instanceId, ]); - } - } /** @@ -1451,10 +1408,11 @@ INSERT INTO ' . $this->calendarInstancesTableName . ' * $properties * * @param mixed $calendarId + * * @return \Sabre\DAV\Xml\Element\Sharee[] */ - function getInvites($calendarId) { - + public function getInvites($calendarId) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to getInvites() is expected to be an array with a calendarId and an instanceId'); } @@ -1477,35 +1435,29 @@ SQL; $result = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $result[] = new Sharee([ - 'href' => isset($row['share_href']) ? $row['share_href'] : \Sabre\HTTP\encodePath($row['principaluri']), - 'access' => (int)$row['access'], + 'href' => isset($row['share_href']) ? $row['share_href'] : \Sabre\HTTP\encodePath($row['principaluri']), + 'access' => (int) $row['access'], /// Everyone is always immediately accepted, for now. - 'inviteStatus' => (int)$row['share_invitestatus'], - 'properties' => - !empty($row['share_displayname']) + 'inviteStatus' => (int) $row['share_invitestatus'], + 'properties' => !empty($row['share_displayname']) ? ['{DAV:}displayname' => $row['share_displayname']] : [], 'principal' => $row['principaluri'], ]); - } - return $result; + return $result; } /** - * Publishes a calendar + * Publishes a calendar. * * @param mixed $calendarId - * @param bool $value - * @return void + * @param bool $value */ - function setPublishStatus($calendarId, $value) { - + public function setPublishStatus($calendarId, $value) + { throw new DAV\Exception\NotImplemented('Not implemented'); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/SchedulingSupport.php b/vendor/sabre/dav/lib/CalDAV/Backend/SchedulingSupport.php index 6ec0bf06b..7986d8c33 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/SchedulingSupport.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/SchedulingSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; /** @@ -10,8 +12,8 @@ namespace Sabre\CalDAV\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface SchedulingSupport extends BackendInterface { - +interface SchedulingSupport extends BackendInterface +{ /** * Returns a single scheduling object for the inbox collection. * @@ -26,9 +28,10 @@ interface SchedulingSupport extends BackendInterface { * * @param string $principalUri * @param string $objectUri + * * @return array */ - function getSchedulingObject($principalUri, $objectUri); + public function getSchedulingObject($principalUri, $objectUri); /** * Returns all scheduling objects for the inbox collection. @@ -39,18 +42,18 @@ interface SchedulingSupport extends BackendInterface { * The main difference is that 'calendardata' is optional. * * @param string $principalUri + * * @return array */ - function getSchedulingObjects($principalUri); + public function getSchedulingObjects($principalUri); /** * Deletes a scheduling object from the inbox collection. * * @param string $principalUri * @param string $objectUri - * @return void */ - function deleteSchedulingObject($principalUri, $objectUri); + public function deleteSchedulingObject($principalUri, $objectUri); /** * Creates a new scheduling object. This should land in a users' inbox. @@ -58,8 +61,6 @@ interface SchedulingSupport extends BackendInterface { * @param string $principalUri * @param string $objectUri * @param string $objectData - * @return void */ - function createSchedulingObject($principalUri, $objectUri, $objectData); - + public function createSchedulingObject($principalUri, $objectUri, $objectData); } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/SharingSupport.php b/vendor/sabre/dav/lib/CalDAV/Backend/SharingSupport.php index 278ec2564..ce6105990 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/SharingSupport.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/SharingSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; /** @@ -20,16 +22,15 @@ namespace Sabre\CalDAV\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface SharingSupport extends BackendInterface { - +interface SharingSupport extends BackendInterface +{ /** * Updates the list of shares. * - * @param mixed $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees - * @return void */ - function updateInvites($calendarId, array $sharees); + public function updateInvites($calendarId, array $sharees); /** * Returns the list of people whom this calendar is shared with. @@ -44,17 +45,16 @@ interface SharingSupport extends BackendInterface { * $properties * * @param mixed $calendarId + * * @return \Sabre\DAV\Xml\Element\Sharee[] */ - function getInvites($calendarId); + public function getInvites($calendarId); /** - * Publishes a calendar + * Publishes a calendar. * * @param mixed $calendarId - * @param bool $value - * @return void + * @param bool $value */ - function setPublishStatus($calendarId, $value); - + public function setPublishStatus($calendarId, $value); } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/SimplePDO.php b/vendor/sabre/dav/lib/CalDAV/Backend/SimplePDO.php index d21f7f916..b6f3c8bef 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/SimplePDO.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/SimplePDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\CalDAV; @@ -31,24 +33,23 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SimplePDO extends AbstractBackend { - +class SimplePDO extends AbstractBackend +{ /** - * pdo + * pdo. * * @var \PDO */ protected $pdo; /** - * Creates the backend + * Creates the backend. * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -73,27 +74,25 @@ class SimplePDO extends AbstractBackend { * ACL will automatically be put in read-only mode. * * @param string $principalUri + * * @return array */ - function getCalendarsForUser($principalUri) { - + public function getCalendarsForUser($principalUri) + { // Making fields a comma-delimited list - $stmt = $this->pdo->prepare("SELECT id, uri FROM simple_calendars WHERE principaluri = ? ORDER BY id ASC"); + $stmt = $this->pdo->prepare('SELECT id, uri FROM simple_calendars WHERE principaluri = ? ORDER BY id ASC'); $stmt->execute([$principalUri]); $calendars = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $calendars[] = [ - 'id' => $row['id'], - 'uri' => $row['uri'], + 'id' => $row['id'], + 'uri' => $row['uri'], 'principaluri' => $principalUri, ]; - } return $calendars; - } /** @@ -104,32 +103,30 @@ class SimplePDO extends AbstractBackend { * * @param string $principalUri * @param string $calendarUri - * @param array $properties + * @param array $properties + * * @return string */ - function createCalendar($principalUri, $calendarUri, array $properties) { - - $stmt = $this->pdo->prepare("INSERT INTO simple_calendars (principaluri, uri) VALUES (?, ?)"); + public function createCalendar($principalUri, $calendarUri, array $properties) + { + $stmt = $this->pdo->prepare('INSERT INTO simple_calendars (principaluri, uri) VALUES (?, ?)'); $stmt->execute([$principalUri, $calendarUri]); return $this->pdo->lastInsertId(); - } /** - * Delete a calendar and all it's objects + * Delete a calendar and all it's objects. * * @param string $calendarId - * @return void */ - function deleteCalendar($calendarId) { - + public function deleteCalendar($calendarId) + { $stmt = $this->pdo->prepare('DELETE FROM simple_calendarobjects WHERE calendarid = ?'); $stmt->execute([$calendarId]); $stmt = $this->pdo->prepare('DELETE FROM simple_calendars WHERE id = ?'); $stmt->execute([$calendarId]); - } /** @@ -161,27 +158,27 @@ class SimplePDO extends AbstractBackend { * amount of times this is needed is reduced by a great degree. * * @param string $calendarId + * * @return array */ - function getCalendarObjects($calendarId) { - + public function getCalendarObjects($calendarId) + { $stmt = $this->pdo->prepare('SELECT id, uri, calendardata FROM simple_calendarobjects WHERE calendarid = ?'); $stmt->execute([$calendarId]); $result = []; foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { $result[] = [ - 'id' => $row['id'], - 'uri' => $row['uri'], - 'etag' => '"' . md5($row['calendardata']) . '"', - 'calendarid' => $calendarId, - 'size' => strlen($row['calendardata']), + 'id' => $row['id'], + 'uri' => $row['uri'], + 'etag' => '"'.md5($row['calendardata']).'"', + 'calendarid' => $calendarId, + 'size' => strlen($row['calendardata']), 'calendardata' => $row['calendardata'], ]; } return $result; - } /** @@ -198,25 +195,27 @@ class SimplePDO extends AbstractBackend { * * @param string $calendarId * @param string $objectUri + * * @return array|null */ - function getCalendarObject($calendarId, $objectUri) { - + public function getCalendarObject($calendarId, $objectUri) + { $stmt = $this->pdo->prepare('SELECT id, uri, calendardata FROM simple_calendarobjects WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarId, $objectUri]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if (!$row) return null; + if (!$row) { + return null; + } return [ - 'id' => $row['id'], - 'uri' => $row['uri'], - 'etag' => '"' . md5($row['calendardata']) . '"', - 'calendarid' => $calendarId, - 'size' => strlen($row['calendardata']), + 'id' => $row['id'], + 'uri' => $row['uri'], + 'etag' => '"'.md5($row['calendardata']).'"', + 'calendarid' => $calendarId, + 'size' => strlen($row['calendardata']), 'calendardata' => $row['calendardata'], ]; - } /** @@ -232,22 +231,22 @@ class SimplePDO extends AbstractBackend { * calendar-data. If the result of a subsequent GET to this object is not * the exact same as this request body, you should omit the ETag. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri * @param string $calendarData + * * @return string|null */ - function createCalendarObject($calendarId, $objectUri, $calendarData) { - + public function createCalendarObject($calendarId, $objectUri, $calendarData) + { $stmt = $this->pdo->prepare('INSERT INTO simple_calendarobjects (calendarid, uri, calendardata) VALUES (?,?,?)'); $stmt->execute([ $calendarId, $objectUri, - $calendarData + $calendarData, ]); - return '"' . md5($calendarData) . '"'; - + return '"'.md5($calendarData).'"'; } /** @@ -263,18 +262,18 @@ class SimplePDO extends AbstractBackend { * calendar-data. If the result of a subsequent GET to this object is not * the exact same as this request body, you should omit the ETag. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri * @param string $calendarData + * * @return string|null */ - function updateCalendarObject($calendarId, $objectUri, $calendarData) { - + public function updateCalendarObject($calendarId, $objectUri, $calendarData) + { $stmt = $this->pdo->prepare('UPDATE simple_calendarobjects SET calendardata = ? WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarData, $calendarId, $objectUri]); - return '"' . md5($calendarData) . '"'; - + return '"'.md5($calendarData).'"'; } /** @@ -284,13 +283,10 @@ class SimplePDO extends AbstractBackend { * * @param string $calendarId * @param string $objectUri - * @return void */ - function deleteCalendarObject($calendarId, $objectUri) { - + public function deleteCalendarObject($calendarId, $objectUri) + { $stmt = $this->pdo->prepare('DELETE FROM simple_calendarobjects WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarId, $objectUri]); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/SubscriptionSupport.php b/vendor/sabre/dav/lib/CalDAV/Backend/SubscriptionSupport.php index d77a2fe0f..2aaf95cdb 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/SubscriptionSupport.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/SubscriptionSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\DAV; @@ -11,8 +13,8 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface SubscriptionSupport extends BackendInterface { - +interface SubscriptionSupport extends BackendInterface +{ /** * Returns a list of subscriptions for a principal. * @@ -43,9 +45,10 @@ interface SubscriptionSupport extends BackendInterface { * default components). * * @param string $principalUri + * * @return array */ - function getSubscriptionsForUser($principalUri); + public function getSubscriptionsForUser($principalUri); /** * Creates a new subscription for a principal. @@ -55,13 +58,14 @@ interface SubscriptionSupport extends BackendInterface { * * @param string $principalUri * @param string $uri - * @param array $properties + * @param array $properties + * * @return mixed */ - function createSubscription($principalUri, $uri, array $properties); + public function createSubscription($principalUri, $uri, array $properties); /** - * Updates a subscription + * Updates a subscription. * * The list of mutations is stored in a Sabre\DAV\PropPatch object. * To do the actual updates, you must tell this object which properties @@ -72,18 +76,15 @@ interface SubscriptionSupport extends BackendInterface { * * Read the PropPatch documentation for more info and examples. * - * @param mixed $subscriptionId + * @param mixed $subscriptionId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateSubscription($subscriptionId, DAV\PropPatch $propPatch); + public function updateSubscription($subscriptionId, DAV\PropPatch $propPatch); /** * Deletes a subscription. * * @param mixed $subscriptionId - * @return void */ - function deleteSubscription($subscriptionId); - + public function deleteSubscription($subscriptionId); } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/SyncSupport.php b/vendor/sabre/dav/lib/CalDAV/Backend/SyncSupport.php index a934505f9..c7f67d176 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/SyncSupport.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/SyncSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; /** @@ -18,8 +20,8 @@ namespace Sabre\CalDAV\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 calendar. @@ -72,10 +74,10 @@ interface SyncSupport extends BackendInterface { * * @param string $calendarId * @param string $syncToken - * @param int $syncLevel - * @param int $limit + * @param int $syncLevel + * @param int $limit + * * @return array */ - function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null); - + public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null); } diff --git a/vendor/sabre/dav/lib/CalDAV/Calendar.php b/vendor/sabre/dav/lib/CalDAV/Calendar.php index 7467900cc..717f04f94 100644 --- a/vendor/sabre/dav/lib/CalDAV/Calendar.php +++ b/vendor/sabre/dav/lib/CalDAV/Calendar.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; @@ -16,46 +18,44 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, DAV\IMultiGet { - +class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, DAV\IMultiGet +{ use DAVACL\ACLTrait; /** - * This is an array with calendar information + * This is an array with calendar information. * * @var array */ protected $calendarInfo; /** - * CalDAV backend + * CalDAV backend. * * @var Backend\BackendInterface */ protected $caldavBackend; /** - * Constructor + * Constructor. * * @param Backend\BackendInterface $caldavBackend - * @param array $calendarInfo + * @param array $calendarInfo */ - function __construct(Backend\BackendInterface $caldavBackend, $calendarInfo) { - + public function __construct(Backend\BackendInterface $caldavBackend, $calendarInfo) + { $this->caldavBackend = $caldavBackend; $this->calendarInfo = $calendarInfo; - } /** - * Returns the name of the calendar + * Returns the name of the calendar. * * @return string */ - function getName() { - + public function getName() + { return $this->calendarInfo['uri']; - } /** @@ -68,69 +68,68 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * Read the PropPatch documentation for more information. * * @param PropPatch $propPatch - * @return void */ - function propPatch(PropPatch $propPatch) { - + public function propPatch(PropPatch $propPatch) + { return $this->caldavBackend->updateCalendar($this->calendarInfo['id'], $propPatch); - } /** - * Returns the list of properties + * Returns the list of properties. * * @param array $requestedProperties + * * @return array */ - function getProperties($requestedProperties) { - + public function getProperties($requestedProperties) + { $response = []; foreach ($this->calendarInfo as $propName => $propValue) { - - if (!is_null($propValue) && $propName[0] === '{') + if (!is_null($propValue) && '{' === $propName[0]) { $response[$propName] = $this->calendarInfo[$propName]; - + } } - return $response; + return $response; } /** - * Returns a calendar object + * Returns a calendar object. * * The contained calendar objects are for example Events or Todo's. * * @param string $name + * * @return \Sabre\CalDAV\ICalendarObject */ - function getChild($name) { - + public function getChild($name) + { $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); - if (!$obj) throw new DAV\Exception\NotFound('Calendar object not found'); - + if (!$obj) { + throw new DAV\Exception\NotFound('Calendar object not found'); + } $obj['acl'] = $this->getChildACL(); return new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); - } /** - * Returns the full list of calendar objects + * Returns the full list of calendar objects. * * @return array */ - function getChildren() { - + public function getChildren() + { $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']); $children = []; foreach ($objs as $obj) { $obj['acl'] = $this->getChildACL(); $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); } - return $children; + return $children; } /** @@ -140,77 +139,75 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * 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->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths); $children = []; foreach ($objs as $obj) { $obj['acl'] = $this->getChildACL(); $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); } - return $children; + return $children; } /** * Checks if a child-node exists. * * @param string $name + * * @return bool */ - function childExists($name) { - + public function childExists($name) + { $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); - if (!$obj) + if (!$obj) { return false; - else + } else { return true; - + } } /** - * Creates a new directory + * Creates a new directory. * * We actually block this, as subdirectories are not allowed in calendars. * * @param string $name - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed'); - } /** - * Creates a new file + * Creates a new file. * * The contents of the new file must be a valid ICalendar string. * - * @param string $name + * @param string $name * @param resource $calendarData + * * @return string|null */ - function createFile($name, $calendarData = null) { - + public function createFile($name, $calendarData = null) + { if (is_resource($calendarData)) { $calendarData = stream_get_contents($calendarData); } - return $this->caldavBackend->createCalendarObject($this->calendarInfo['id'], $name, $calendarData); + return $this->caldavBackend->createCalendarObject($this->calendarInfo['id'], $name, $calendarData); } /** * Deletes the calendar. - * - * @return void */ - function delete() { - + public function delete() + { $this->caldavBackend->deleteCalendar($this->calendarInfo['id']); - } /** @@ -218,36 +215,30 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * {DAV:}displayname to display a name to display a name. * * @param string $newName - * @return void */ - function setName($newName) { - + public function setName($newName) + { throw new DAV\Exception\MethodNotAllowed('Renaming calendars is not yet supported'); - } /** * Returns the last modification date as a unix timestamp. - * - * @return null */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** - * 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->calendarInfo['principaluri']; - } /** @@ -262,8 +253,8 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * * @return array */ - function getACL() { - + public function getACL() + { $acl = [ [ 'privilege' => '{DAV:}read', @@ -272,20 +263,19 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-read', + 'principal' => $this->getOwner().'/calendar-proxy-read', 'protected' => true, ], [ - 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', + 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true, ], - ]; if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) { $acl[] = [ @@ -295,13 +285,12 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, ]; $acl[] = [ 'privilege' => '{DAV:}write', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ]; } return $acl; - } /** @@ -311,8 +300,8 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * * @return array */ - function getChildACL() { - + public function getChildACL() + { $acl = [ [ 'privilege' => '{DAV:}read', @@ -322,15 +311,14 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-read', + 'principal' => $this->getOwner().'/calendar-proxy-read', 'protected' => true, ], - ]; if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) { $acl[] = [ @@ -340,16 +328,14 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, ]; $acl[] = [ 'privilege' => '{DAV:}write', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ]; - } - return $acl; + return $acl; } - /** * Performs a calendar-query on the contents of this calendar. * @@ -365,12 +351,12 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * documented by Sabre\CalDAV\CalendarQueryParser. * * @param array $filters + * * @return array */ - function calendarQuery(array $filters) { - + public function calendarQuery(array $filters) + { return $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters); - } /** @@ -382,8 +368,8 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * * @return string|null */ - function getSyncToken() { - + public function getSyncToken() + { if ( $this->caldavBackend instanceof Backend\SyncSupport && isset($this->calendarInfo['{DAV:}sync-token']) @@ -396,7 +382,6 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, ) { return $this->calendarInfo['{http://sabredav.org/ns}sync-token']; } - } /** @@ -450,12 +435,13 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * 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->caldavBackend instanceof Backend\SyncSupport) { return null; } @@ -466,7 +452,5 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, $syncLevel, $limit ); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/CalendarHome.php b/vendor/sabre/dav/lib/CalDAV/CalendarHome.php index ffd7f72fb..663d449bf 100644 --- a/vendor/sabre/dav/lib/CalDAV/CalendarHome.php +++ b/vendor/sabre/dav/lib/CalDAV/CalendarHome.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; use Sabre\DAV\Exception\NotFound; use Sabre\DAV\MkCol; use Sabre\DAVACL; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** * The CalendarHome represents a node that is usually in a users' @@ -20,81 +22,74 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { - +class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL +{ use DAVACL\ACLTrait; /** - * CalDAV backend + * CalDAV backend. * * @var Backend\BackendInterface */ protected $caldavBackend; /** - * Principal information + * Principal information. * * @var array */ protected $principalInfo; /** - * Constructor + * Constructor. * * @param Backend\BackendInterface $caldavBackend - * @param array $principalInfo + * @param array $principalInfo */ - function __construct(Backend\BackendInterface $caldavBackend, $principalInfo) { - + public function __construct(Backend\BackendInterface $caldavBackend, $principalInfo) + { $this->caldavBackend = $caldavBackend; $this->principalInfo = $principalInfo; - } /** - * Returns the name of this object + * Returns the name of this object. * * @return string */ - function getName() { + public function getName() + { + list(, $name) = Uri\split($this->principalInfo['uri']); - list(, $name) = URLUtil::splitPath($this->principalInfo['uri']); 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\Forbidden(); - } /** - * Deletes this object - * - * @return void + * Deletes this object. */ - function delete() { - + public function delete() + { throw new DAV\Exception\Forbidden(); - } /** - * Returns the last modification date + * Returns the last modification date. * * @return int */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** @@ -102,14 +97,12 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { * * 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'); - } /** @@ -118,30 +111,29 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { * 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 calendar, by name + * Returns a single calendar, by name. * * @param string $name + * * @return Calendar */ - function getChild($name) { - + public function getChild($name) + { // Special nodes - if ($name === 'inbox' && $this->caldavBackend instanceof Backend\SchedulingSupport) { + if ('inbox' === $name && $this->caldavBackend instanceof Backend\SchedulingSupport) { return new Schedule\Inbox($this->caldavBackend, $this->principalInfo['uri']); } - if ($name === 'outbox' && $this->caldavBackend instanceof Backend\SchedulingSupport) { + if ('outbox' === $name && $this->caldavBackend instanceof Backend\SchedulingSupport) { return new Schedule\Outbox($this->principalInfo['uri']); } - if ($name === 'notifications' && $this->caldavBackend instanceof Backend\NotificationSupport) { + if ('notifications' === $name && $this->caldavBackend instanceof Backend\NotificationSupport) { return new Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); } @@ -162,36 +154,34 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { return new Subscriptions\Subscription($this->caldavBackend, $subscription); } } - } - throw new NotFound('Node with name \'' . $name . '\' could not be found'); - + throw new NotFound('Node with name \''.$name.'\' could not be found'); } /** * Checks if a calendar exists. * * @param string $name + * * @return bool */ - function childExists($name) { - + public function childExists($name) + { try { - return !!$this->getChild($name); + return (bool) $this->getChild($name); } catch (NotFound $e) { return false; } - } /** - * Returns a list of calendars + * Returns a list of calendars. * * @return array */ - function getChildren() { - + public function getChildren() + { $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); $objs = []; foreach ($calendars as $calendar) { @@ -220,35 +210,34 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { } return $objs; - } /** * Creates a new calendar or subscription. * * @param string $name - * @param MkCol $mkCol + * @param MkCol $mkCol + * * @throws DAV\Exception\InvalidResourceType - * @return void */ - function createExtendedCollection($name, MkCol $mkCol) { - + public function createExtendedCollection($name, MkCol $mkCol) + { $isCalendar = false; $isSubscription = false; foreach ($mkCol->getResourceType() as $rt) { switch ($rt) { - case '{DAV:}collection' : - case '{http://calendarserver.org/ns/}shared-owner' : + case '{DAV:}collection': + case '{http://calendarserver.org/ns/}shared-owner': // ignore break; - case '{urn:ietf:params:xml:ns:caldav}calendar' : + case '{urn:ietf:params:xml:ns:caldav}calendar': $isCalendar = true; break; - case '{http://calendarserver.org/ns/}subscribed' : + case '{http://calendarserver.org/ns/}subscribed': $isSubscription = true; break; - default : - throw new DAV\Exception\InvalidResourceType('Unknown resourceType: ' . $rt); + default: + throw new DAV\Exception\InvalidResourceType('Unknown resourceType: '.$rt); } } @@ -260,15 +249,11 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { throw new DAV\Exception\InvalidResourceType('This backend does not support subscriptions'); } $this->caldavBackend->createSubscription($this->principalInfo['uri'], $name, $properties); - } elseif ($isCalendar) { $this->caldavBackend->createCalendar($this->principalInfo['uri'], $name, $properties); - } else { throw new DAV\Exception\InvalidResourceType('You can only create calendars and subscriptions in this collection'); - } - } /** @@ -276,10 +261,9 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { * * @return string */ - function getOwner() { - + public function getOwner() + { return $this->principalInfo['uri']; - } /** @@ -294,8 +278,8 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ 'privilege' => '{DAV:}read', @@ -309,46 +293,43 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-write', + 'principal' => $this->principalInfo['uri'].'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}write', - 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-write', + 'principal' => $this->principalInfo['uri'].'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-read', + 'principal' => $this->principalInfo['uri'].'/calendar-proxy-read', 'protected' => true, ], - ]; - } - /** * This method is called when a user replied to a request to share. * * This method should return the url of the newly created calendar if the * share was accepted. * - * @param string $href The sharee who is replying (often a mailto: address) - * @param int $status One of the SharingPlugin::STATUS_* constants + * @param string $href The sharee who is replying (often a mailto: address) + * @param int $status One of the SharingPlugin::STATUS_* constants * @param string $calendarUri The url to the calendar thats being shared - * @param string $inReplyTo The unique id this message is a response to - * @param string $summary A description of the reply - * @return null|string + * @param string $inReplyTo The unique id this message is a response to + * @param string $summary A description of the reply + * + * @return string|null */ - function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null) { - + public function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null) + { if (!$this->caldavBackend instanceof Backend\SharingSupport) { throw new DAV\Exception\NotImplemented('Sharing support is not implemented by this backend.'); } return $this->caldavBackend->shareReply($href, $status, $calendarUri, $inReplyTo, $summary); - } /** @@ -367,12 +348,11 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { * collection should be ignored. * * @param string $uid + * * @return string|null */ - function getCalendarObjectByUID($uid) { - + public function getCalendarObjectByUID($uid) + { return $this->caldavBackend->getCalendarObjectByUID($this->principalInfo['uri'], $uid); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/CalendarObject.php b/vendor/sabre/dav/lib/CalDAV/CalendarObject.php index 9d6532a35..3f28ee7f7 100644 --- a/vendor/sabre/dav/lib/CalDAV/CalendarObject.php +++ b/vendor/sabre/dav/lib/CalDAV/CalendarObject.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; /** @@ -9,33 +11,33 @@ namespace Sabre\CalDAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\DAVACL\IACL { - +class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\DAVACL\IACL +{ use \Sabre\DAVACL\ACLTrait; /** - * Sabre\CalDAV\Backend\BackendInterface + * Sabre\CalDAV\Backend\BackendInterface. * * @var Backend\AbstractBackend */ protected $caldavBackend; /** - * Array with information about this CalendarObject + * Array with information about this CalendarObject. * * @var array */ protected $objectData; /** - * Array with information about the containing calendar + * Array with information about the containing calendar. * * @var array */ protected $calendarInfo; /** - * Constructor + * Constructor. * * The following properties may be passed within $objectData: * @@ -49,11 +51,11 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ * * acl - (optional) Use this to override the default ACL for the node. * * @param Backend\BackendInterface $caldavBackend - * @param array $calendarInfo - * @param array $objectData + * @param array $calendarInfo + * @param array $objectData */ - function __construct(Backend\BackendInterface $caldavBackend, array $calendarInfo, array $objectData) { - + public function __construct(Backend\BackendInterface $caldavBackend, array $calendarInfo, array $objectData) + { $this->caldavBackend = $caldavBackend; if (!isset($objectData['uri'])) { @@ -62,44 +64,43 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ $this->calendarInfo = $calendarInfo; $this->objectData = $objectData; - } /** - * Returns the uri for this object + * Returns the uri for this object. * * @return string */ - function getName() { - + public function getName() + { return $this->objectData['uri']; - } /** - * Returns the ICalendar-formatted object + * Returns the ICalendar-formatted object. * * @return string */ - function get() { - + public function get() + { // Pre-populating the 'calendardata' is optional, if we don't have it // already we fetch it from the backend. if (!isset($this->objectData['calendardata'])) { $this->objectData = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $this->objectData['uri']); } - return $this->objectData['calendardata']; + return $this->objectData['calendardata']; } /** - * Updates the ICalendar-formatted object + * Updates the ICalendar-formatted object. * * @param string|resource $calendarData + * * @return string */ - function put($calendarData) { - + public function put($calendarData) + { if (is_resource($calendarData)) { $calendarData = stream_get_contents($calendarData); } @@ -108,33 +109,29 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ $this->objectData['etag'] = $etag; return $etag; - } /** - * Deletes the calendar object - * - * @return void + * Deletes the calendar object. */ - function delete() { - + public function delete() + { $this->caldavBackend->deleteCalendarObject($this->calendarInfo['id'], $this->objectData['uri']); - } /** - * Returns the mime content-type + * Returns the mime content-type. * * @return string */ - function getContentType() { - + public function getContentType() + { $mime = 'text/calendar; charset=utf-8'; if (isset($this->objectData['component']) && $this->objectData['component']) { - $mime .= '; component=' . $this->objectData['component']; + $mime .= '; component='.$this->objectData['component']; } - return $mime; + return $mime; } /** @@ -144,53 +141,49 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ * * @return string */ - function getETag() { - + public function getETag() + { if (isset($this->objectData['etag'])) { return $this->objectData['etag']; } else { - return '"' . md5($this->get()) . '"'; + return '"'.md5($this->get()).'"'; } - } /** - * 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 $this->objectData['lastmodified']; - } /** - * 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->objectData)) { return $this->objectData['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->calendarInfo['principaluri']; - } /** @@ -205,8 +198,8 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ * * @return array */ - function getACL() { - + public function getACL() + { // An alternative acl may be specified in the object data. if (isset($this->objectData['acl'])) { return $this->objectData['acl']; @@ -221,17 +214,14 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ ], [ 'privilege' => '{DAV:}all', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read', 'protected' => true, ], - ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php b/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php index df8008fe2..0e7f1307d 100644 --- a/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php +++ b/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use DateTime; use Sabre\VObject; /** - * CalendarQuery Validator + * CalendarQuery Validator. * * This class is responsible for checking if an iCalendar object matches a set * of filters. The main function to do this is 'validate'. @@ -18,19 +20,20 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CalendarQueryValidator { - +class CalendarQueryValidator +{ /** - * Verify if a list of filters applies to the calendar data object + * Verify if a list of filters applies to the calendar data object. * * The list of filters must be formatted as parsed by \Sabre\CalDAV\CalendarQueryParser * * @param VObject\Component\VCalendar $vObject - * @param array $filters + * @param array $filters + * * @return bool */ - function validate(VObject\Component\VCalendar $vObject, array $filters) { - + public function validate(VObject\Component\VCalendar $vObject, array $filters) + { // The top level object is always a component filter. // We'll parse it manually, as it's pretty simple. if ($vObject->name !== $filters['name']) { @@ -40,8 +43,6 @@ class CalendarQueryValidator { return $this->validateCompFilters($vObject, $filters['comp-filters']) && $this->validatePropFilters($vObject, $filters['prop-filters']); - - } /** @@ -52,23 +53,21 @@ class CalendarQueryValidator { * itself. * * @param VObject\Component $parent - * @param array $filters + * @param array $filters + * * @return bool */ - protected function validateCompFilters(VObject\Component $parent, array $filters) { - + protected function validateCompFilters(VObject\Component $parent, array $filters) + { foreach ($filters as $filter) { - $isDefined = isset($parent->{$filter['name']}); if ($filter['is-not-defined']) { - if ($isDefined) { return false; } else { continue; } - } if (!$isDefined) { return false; @@ -80,6 +79,7 @@ class CalendarQueryValidator { continue 2; } } + return false; } @@ -90,27 +90,23 @@ class CalendarQueryValidator { // If there are sub-filters, we need to find at least one component // for which the subfilters hold true. foreach ($parent->{$filter['name']} as $subComponent) { - if ( $this->validateCompFilters($subComponent, $filter['comp-filters']) && $this->validatePropFilters($subComponent, $filter['prop-filters'])) { - // We had a match, so this comp-filter succeeds - continue 2; + // We had a match, so this comp-filter succeeds + continue 2; } - } // If we got here it means there were sub-comp-filters or // sub-prop-filters and there was no match. This means this filter // needs to return false. return false; - } // If we got here it means we got through all comp-filters alive so the // filters were all true. return true; - } /** @@ -121,23 +117,21 @@ class CalendarQueryValidator { * itself. * * @param VObject\Component $parent - * @param array $filters + * @param array $filters + * * @return bool */ - protected function validatePropFilters(VObject\Component $parent, array $filters) { - + protected function validatePropFilters(VObject\Component $parent, array $filters) + { foreach ($filters as $filter) { - $isDefined = isset($parent->{$filter['name']}); if ($filter['is-not-defined']) { - if ($isDefined) { return false; } else { continue; } - } if (!$isDefined) { return false; @@ -149,6 +143,7 @@ class CalendarQueryValidator { continue 2; } } + return false; } @@ -159,7 +154,6 @@ class CalendarQueryValidator { // If there are sub-filters, we need to find at least one property // for which the subfilters hold true. foreach ($parent->{$filter['name']} as $subComponent) { - if ( $this->validateParamFilters($subComponent, $filter['param-filters']) && (!$filter['text-match'] || $this->validateTextMatch($subComponent, $filter['text-match'])) @@ -167,20 +161,17 @@ class CalendarQueryValidator { // We had a match, so this prop-filter succeeds continue 2; } - } // If we got here it means there were sub-param-filters or // text-match filters and there was no match. This means the // filter needs to return false. return false; - } // If we got here it means we got through all prop-filters alive so the // filters were all true. return true; - } /** @@ -191,23 +182,21 @@ class CalendarQueryValidator { * itself. * * @param VObject\Property $parent - * @param array $filters + * @param array $filters + * * @return bool */ - protected function validateParamFilters(VObject\Property $parent, array $filters) { - + protected function validateParamFilters(VObject\Property $parent, array $filters) + { foreach ($filters as $filter) { - $isDefined = isset($parent[$filter['name']]); if ($filter['is-not-defined']) { - if ($isDefined) { return false; } else { continue; } - } if (!$isDefined) { return false; @@ -220,24 +209,20 @@ class CalendarQueryValidator { // If there are sub-filters, we need to find at least one parameter // for which the subfilters hold true. foreach ($parent[$filter['name']]->getParts() as $paramPart) { - if ($this->validateTextMatch($paramPart, $filter['text-match'])) { // We had a match, so this param-filter succeeds continue 2; } - } // If we got here it means there was a text-match filter and there // were no matches. This means the filter needs to return false. return false; - } // If we got here it means we got through all param-filters alive so the // filters were all true. return true; - } /** @@ -246,20 +231,20 @@ class CalendarQueryValidator { * A single text-match should be specified as well as the specific property * or parameter we need to validate. * - * @param VObject\Node|string $check Value to check against. - * @param array $textMatch + * @param VObject\Node|string $check value to check against + * @param array $textMatch + * * @return bool */ - protected function validateTextMatch($check, array $textMatch) { - + protected function validateTextMatch($check, array $textMatch) + { if ($check instanceof VObject\Node) { $check = $check->getValue(); } $isMatching = \Sabre\DAV\StringUtil::textMatch($check, $textMatch['value'], $textMatch['collation']); - return ($textMatch['negate-condition'] xor $isMatching); - + return $textMatch['negate-condition'] xor $isMatching; } /** @@ -269,12 +254,13 @@ class CalendarQueryValidator { * complex. * * @param VObject\Node $component - * @param DateTime $start - * @param DateTime $end + * @param DateTime $start + * @param DateTime $end + * * @return bool */ - protected function validateTimeRange(VObject\Node $component, $start, $end) { - + protected function validateTimeRange(VObject\Node $component, $start, $end) + { if (is_null($start)) { $start = new DateTime('1900-01-01'); } @@ -283,14 +269,13 @@ class CalendarQueryValidator { } switch ($component->name) { - - case 'VEVENT' : - case 'VTODO' : - case 'VJOURNAL' : + case 'VEVENT': + case 'VTODO': + case 'VJOURNAL': return $component->isInTimeRange($start, $end); - case 'VALARM' : + case 'VALARM': // If the valarm is wrapped in a recurring event, we need to // expand the recursions, and validate each. @@ -298,10 +283,9 @@ class CalendarQueryValidator { // Our datamodel doesn't easily allow us to do this straight // in the VALARM component code, so this is a hack, and an // expensive one too. - if ($component->parent->name === 'VEVENT' && $component->parent->RRULE) { - + if ('VEVENT' === $component->parent->name && $component->parent->RRULE) { // Fire up the iterator! - $it = new VObject\Recur\EventIterator($component->parent->parent, (string)$component->parent->UID); + $it = new VObject\Recur\EventIterator($component->parent->parent, (string) $component->parent->UID); while ($it->valid()) { $expandedEvent = $it->getEventObject(); @@ -309,15 +293,14 @@ class CalendarQueryValidator { // one is the first to trigger. Based on this, we can // determine if we can 'give up' expanding events. $firstAlarm = null; - if ($expandedEvent->VALARM !== null) { + if (null !== $expandedEvent->VALARM) { foreach ($expandedEvent->VALARM as $expandedAlarm) { - $effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime(); if ($expandedAlarm->isInTimeRange($start, $end)) { return true; } - if ((string)$expandedAlarm->TRIGGER['VALUE'] === 'DATE-TIME') { + if ('DATE-TIME' === (string) $expandedAlarm->TRIGGER['VALUE']) { // This is an alarm with a non-relative trigger // time, likely created by a buggy client. The // implication is that every alarm in this @@ -346,30 +329,26 @@ class CalendarQueryValidator { } $it->next(); } + return false; } else { return $component->isInTimeRange($start, $end); } - case 'VFREEBUSY' : - throw new \Sabre\DAV\Exception\NotImplemented('time-range filters are currently not supported on ' . $component->name . ' components'); - - case 'COMPLETED' : - case 'CREATED' : - case 'DTEND' : - case 'DTSTAMP' : - case 'DTSTART' : - case 'DUE' : - case 'LAST-MODIFIED' : - return ($start <= $component->getDateTime() && $end >= $component->getDateTime()); - - - - default : - throw new \Sabre\DAV\Exception\BadRequest('You cannot create a time-range filter on a ' . $component->name . ' component'); - + // no break + case 'VFREEBUSY': + throw new \Sabre\DAV\Exception\NotImplemented('time-range filters are currently not supported on '.$component->name.' components'); + case 'COMPLETED': + case 'CREATED': + case 'DTEND': + case 'DTSTAMP': + case 'DTSTART': + case 'DUE': + case 'LAST-MODIFIED': + return $start <= $component->getDateTime() && $end >= $component->getDateTime(); + + default: + throw new \Sabre\DAV\Exception\BadRequest('You cannot create a time-range filter on a '.$component->name.' component'); } - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/CalendarRoot.php b/vendor/sabre/dav/lib/CalDAV/CalendarRoot.php index 1d6b2ac9f..42f1a44d5 100644 --- a/vendor/sabre/dav/lib/CalDAV/CalendarRoot.php +++ b/vendor/sabre/dav/lib/CalDAV/CalendarRoot.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAVACL\PrincipalBackend; /** - * Calendars collection + * Calendars collection. * * This object is responsible for generating a list of calendar-homes for each * user. @@ -17,17 +19,17 @@ use Sabre\DAVACL\PrincipalBackend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CalendarRoot extends \Sabre\DAVACL\AbstractPrincipalCollection { - +class CalendarRoot extends \Sabre\DAVACL\AbstractPrincipalCollection +{ /** - * CalDAV backend + * CalDAV backend. * * @var Backend\BackendInterface */ protected $caldavBackend; /** - * Constructor + * Constructor. * * This constructor needs both an authentication and a caldav backend. * @@ -37,28 +39,26 @@ class CalendarRoot extends \Sabre\DAVACL\AbstractPrincipalCollection { * to override this. * * @param PrincipalBackend\BackendInterface $principalBackend - * @param Backend\BackendInterface $caldavBackend - * @param string $principalPrefix + * @param Backend\BackendInterface $caldavBackend + * @param string $principalPrefix */ - function __construct(PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $caldavBackend, $principalPrefix = 'principals') { - + public function __construct(PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $caldavBackend, $principalPrefix = 'principals') + { parent::__construct($principalBackend, $principalPrefix); $this->caldavBackend = $caldavBackend; - } /** - * Returns the nodename + * Returns the nodename. * * We're overriding this, because the default will be the 'principalPrefix', * and we want it to be Sabre\CalDAV\Plugin::CALENDAR_ROOT * * @return string */ - function getName() { - + public function getName() + { return Plugin::CALENDAR_ROOT; - } /** @@ -69,12 +69,11 @@ class CalendarRoot extends \Sabre\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 CalendarHome($this->caldavBackend, $principal); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Exception/InvalidComponentType.php b/vendor/sabre/dav/lib/CalDAV/Exception/InvalidComponentType.php index 7aff2edab..3385ad8fe 100644 --- a/vendor/sabre/dav/lib/CalDAV/Exception/InvalidComponentType.php +++ b/vendor/sabre/dav/lib/CalDAV/Exception/InvalidComponentType.php @@ -1,35 +1,34 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Exception; use Sabre\CalDAV; use Sabre\DAV; /** - * InvalidComponentType + * InvalidComponentType. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InvalidComponentType extends DAV\Exception\Forbidden { - +class InvalidComponentType extends DAV\Exception\Forbidden +{ /** * Adds in extra information in the xml response. * * This method adds the {CALDAV:}supported-calendar-component as defined in rfc4791 * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS(CalDAV\Plugin::NS_CALDAV, 'cal:supported-calendar-component'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php b/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php index fc8b971f3..717d3a9c9 100644 --- a/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php +++ b/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use DateTime; @@ -11,7 +13,7 @@ use Sabre\HTTP\ResponseInterface; use Sabre\VObject; /** - * ICS Exporter + * ICS Exporter. * * This plugin adds the ability to export entire calendars as .ics files. * This is useful for clients that don't support CalDAV yet. They often do @@ -44,44 +46,49 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ICSExportPlugin extends DAV\ServerPlugin { - +class ICSExportPlugin extends DAV\ServerPlugin +{ /** - * Reference to Server class + * Reference to Server class. * * @var \Sabre\DAV\Server */ protected $server; /** - * Initializes the plugin and registers event handlers + * Initializes the plugin and registers event handlers. * * @param \Sabre\DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $server->on('method:GET', [$this, 'httpGet'], 90); - $server->on('browserButtonActions', function($path, $node, &$actions) { + $server->on('browserButtonActions', function ($path, $node, &$actions) { if ($node instanceof ICalendar) { - $actions .= '<a href="' . htmlspecialchars($path, ENT_QUOTES, 'UTF-8') . '?export"><span class="oi" data-glyph="calendar"></span></a>'; + $actions .= '<a href="'.htmlspecialchars($path, ENT_QUOTES, 'UTF-8').'?export"><span class="oi" data-glyph="calendar"></span></a>'; } }); - } /** * Intercepts GET requests on calendar urls ending with ?export. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * + * @throws BadRequest + * @throws DAV\Exception\NotFound + * @throws VObject\InvalidDataException + * * @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(); @@ -93,7 +100,7 @@ class ICSExportPlugin extends DAV\ServerPlugin { '{http://apple.com/ns/ical/}calendar-color', ]); - if (!isset($node['{DAV:}resourcetype']) || !$node['{DAV:}resourcetype']->is('{' . Plugin::NS_CALDAV . '}calendar')) { + if (!isset($node['{DAV:}resourcetype']) || !$node['{DAV:}resourcetype']->is('{'.Plugin::NS_CALDAV.'}calendar')) { return; } // Marking the transactionType, for logging purposes. @@ -117,7 +124,7 @@ class ICSExportPlugin extends DAV\ServerPlugin { } $end = DateTime::createFromFormat('U', $queryParams['end']); } - if (isset($queryParams['expand']) && !!$queryParams['expand']) { + if (isset($queryParams['expand']) && (bool) $queryParams['expand']) { if (!$start || !$end) { throw new BadRequest('If you\'d like to expand recurrences, you must specify both a start= and end= parameter.'); } @@ -126,12 +133,12 @@ class ICSExportPlugin extends DAV\ServerPlugin { } if (isset($queryParams['componentType'])) { if (!in_array($queryParams['componentType'], ['VEVENT', 'VTODO', 'VJOURNAL'])) { - throw new BadRequest('You are not allowed to search for components of type: ' . $queryParams['componentType'] . ' here'); + throw new BadRequest('You are not allowed to search for components of type: '.$queryParams['componentType'].' here'); } $componentType = $queryParams['componentType']; } - $format = \Sabre\HTTP\Util::Negotiate( + $format = \Sabre\HTTP\negotiateContentType( $request->getHeader('Accept'), [ 'text/calendar', @@ -140,7 +147,7 @@ class ICSExportPlugin extends DAV\ServerPlugin { ); if (isset($queryParams['accept'])) { - if ($queryParams['accept'] === 'application/calendar+json' || $queryParams['accept'] === 'jcal') { + if ('application/calendar+json' === $queryParams['accept'] || 'jcal' === $queryParams['accept']) { $format = 'application/calendar+json'; } } @@ -152,61 +159,61 @@ class ICSExportPlugin extends DAV\ServerPlugin { // Returning false to break the event chain return false; - } /** * This method is responsible for generating the actual, full response. * - * @param string $path - * @param DateTime|null $start - * @param DateTime|null $end - * @param bool $expand - * @param string $componentType - * @param string $format - * @param array $properties + * @param string $path + * @param DateTime|null $start + * @param DateTime|null $end + * @param bool $expand + * @param string $componentType + * @param string $format + * @param array $properties * @param ResponseInterface $response + * + * @throws DAV\Exception\NotFound + * @throws VObject\InvalidDataException */ - protected function generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, ResponseInterface $response) { - - $calDataProp = '{' . Plugin::NS_CALDAV . '}calendar-data'; + protected function generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, ResponseInterface $response) + { + $calDataProp = '{'.Plugin::NS_CALDAV.'}calendar-data'; $calendarNode = $this->server->tree->getNodeForPath($path); $blobs = []; if ($start || $end || $componentType) { - // If there was a start or end filter, we need to enlist // calendarQuery for speed. $queryResult = $calendarNode->calendarQuery([ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => $componentType, - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => $componentType, + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => $start, - 'end' => $end, + 'end' => $end, ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]); // queryResult is just a list of base urls. We need to prefix the // calendar path. $queryResult = array_map( - function($item) use ($path) { - return $path . '/' . $item; + function ($item) use ($path) { + return $path.'/'.$item; }, $queryResult ); $nodes = $this->server->getPropertiesForMultiplePaths($queryResult, [$calDataProp]); unset($queryResult); - } else { $nodes = $this->server->getPropertiesForPath($path, [$calDataProp], 1); } @@ -228,7 +235,7 @@ class ICSExportPlugin extends DAV\ServerPlugin { $calendarTimeZone = null; // We're expanding, and for that we need to figure out the // calendar's timezone. - $tzProp = '{' . Plugin::NS_CALDAV . '}calendar-timezone'; + $tzProp = '{'.Plugin::NS_CALDAV.'}calendar-timezone'; $tzResult = $this->server->getProperties($path, [$tzProp]); if (isset($tzResult[$tzProp])) { // This property contains a VCALENDAR with a single @@ -249,11 +256,11 @@ class ICSExportPlugin extends DAV\ServerPlugin { $filenameExtension = '.ics'; switch ($format) { - case 'text/calendar' : + case 'text/calendar': $mergedCalendar = $mergedCalendar->serialize(); $filenameExtension = '.ics'; break; - case 'application/calendar+json' : + case 'application/calendar+json': $mergedCalendar = json_encode($mergedCalendar->jsonSerialize()); $filenameExtension = '.json'; break; @@ -264,29 +271,29 @@ class ICSExportPlugin extends DAV\ServerPlugin { '', $calendarNode->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); $response->setBody($mergedCalendar); - } /** * Merges all calendar objects, and builds one big iCalendar blob. * - * @param array $properties Some CalDAV properties + * @param array $properties Some CalDAV properties * @param array $inputObjects + * * @return VObject\Component\VCalendar */ - function mergeObjects(array $properties, array $inputObjects) { - + public function mergeObjects(array $properties, array $inputObjects) + { $calendar = new VObject\Component\VCalendar(); $calendar->VERSION = '2.0'; if (DAV\Server::$exposeVersion) { - $calendar->PRODID = '-//SabreDAV//SabreDAV ' . DAV\Version::VERSION . '//EN'; + $calendar->PRODID = '-//SabreDAV//SabreDAV '.DAV\Version::VERSION.'//EN'; } else { $calendar->PRODID = '-//SabreDAV//SabreDAV//EN'; } @@ -303,41 +310,41 @@ class ICSExportPlugin extends DAV\ServerPlugin { $objects = []; foreach ($inputObjects as $href => $inputObject) { - $nodeComp = VObject\Reader::read($inputObject); foreach ($nodeComp->children() as $child) { - switch ($child->name) { - case 'VEVENT' : - case 'VTODO' : - case 'VJOURNAL' : + case 'VEVENT': + case 'VTODO': + case 'VJOURNAL': $objects[] = clone $child; break; // VTIMEZONE is special, because we need to filter out the duplicates - case 'VTIMEZONE' : + case 'VTIMEZONE': // Naively just checking tzid. - if (in_array((string)$child->TZID, $collectedTimezones)) continue; + if (in_array((string) $child->TZID, $collectedTimezones)) { + break; + } $timezones[] = clone $child; $collectedTimezones[] = $child->TZID; break; - } - } // Destroy circular references to PHP will GC the object. $nodeComp->destroy(); unset($nodeComp); - } - foreach ($timezones as $tz) $calendar->add($tz); - foreach ($objects as $obj) $calendar->add($obj); + foreach ($timezones as $tz) { + $calendar->add($tz); + } + foreach ($objects as $obj) { + $calendar->add($obj); + } return $calendar; - } /** @@ -348,10 +355,9 @@ class ICSExportPlugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'ics-export'; - } /** @@ -365,14 +371,12 @@ class ICSExportPlugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds the ability to export CalDAV calendars as a single iCalendar file.', - 'link' => 'http://sabre.io/dav/ics-export-plugin/', + 'link' => 'http://sabre.io/dav/ics-export-plugin/', ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/ICalendar.php b/vendor/sabre/dav/lib/CalDAV/ICalendar.php index 7cf4b1256..8636e0bae 100644 --- a/vendor/sabre/dav/lib/CalDAV/ICalendar.php +++ b/vendor/sabre/dav/lib/CalDAV/ICalendar.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAVACL; /** - * Calendar interface + * Calendar interface. * * Implement this interface to allow a node to be recognized as an calendar. * @@ -13,6 +15,6 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ICalendar extends ICalendarObjectContainer, DAVACL\IACL { - +interface ICalendar extends ICalendarObjectContainer, DAVACL\IACL +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/ICalendarObject.php b/vendor/sabre/dav/lib/CalDAV/ICalendarObject.php index b3a767b74..86d9be634 100644 --- a/vendor/sabre/dav/lib/CalDAV/ICalendarObject.php +++ b/vendor/sabre/dav/lib/CalDAV/ICalendarObject.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; /** - * CalendarObject interface + * CalendarObject interface. * * Extend the ICalendarObject interface to allow your custom nodes to be picked up as * CalendarObjects. @@ -16,6 +18,6 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ICalendarObject extends DAV\IFile { - +interface ICalendarObject extends DAV\IFile +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/ICalendarObjectContainer.php b/vendor/sabre/dav/lib/CalDAV/ICalendarObjectContainer.php index 0308b8a55..d9346f311 100644 --- a/vendor/sabre/dav/lib/CalDAV/ICalendarObjectContainer.php +++ b/vendor/sabre/dav/lib/CalDAV/ICalendarObjectContainer.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; /** @@ -15,8 +17,8 @@ namespace Sabre\CalDAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ICalendarObjectContainer extends \Sabre\DAV\ICollection { - +interface ICalendarObjectContainer extends \Sabre\DAV\ICollection +{ /** * Performs a calendar-query on the contents of this calendar. * @@ -32,8 +34,8 @@ interface ICalendarObjectContainer extends \Sabre\DAV\ICollection { * documented by \Sabre\CalDAV\CalendarQueryParser. * * @param array $filters + * * @return array */ - function calendarQuery(array $filters); - + public function calendarQuery(array $filters); } diff --git a/vendor/sabre/dav/lib/CalDAV/ISharedCalendar.php b/vendor/sabre/dav/lib/CalDAV/ISharedCalendar.php index 15f3b5335..e3e9a7314 100644 --- a/vendor/sabre/dav/lib/CalDAV/ISharedCalendar.php +++ b/vendor/sabre/dav/lib/CalDAV/ISharedCalendar.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV\Sharing\ISharedNode; @@ -11,8 +13,8 @@ use Sabre\DAV\Sharing\ISharedNode; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ISharedCalendar extends ISharedNode { - +interface ISharedCalendar extends ISharedNode +{ /** * Marks this calendar as published. * @@ -20,7 +22,6 @@ interface ISharedCalendar extends ISharedNode { * subscribable calendar. * * @param bool $value - * @return void */ - function setPublishStatus($value); + public function setPublishStatus($value); } diff --git a/vendor/sabre/dav/lib/CalDAV/Notifications/Collection.php b/vendor/sabre/dav/lib/CalDAV/Notifications/Collection.php index 557832a5a..884f205e4 100644 --- a/vendor/sabre/dav/lib/CalDAV/Notifications/Collection.php +++ b/vendor/sabre/dav/lib/CalDAV/Notifications/Collection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Notifications; use Sabre\CalDAV; @@ -20,49 +22,47 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Collection extends DAV\Collection implements ICollection, DAVACL\IACL { - +class Collection extends DAV\Collection implements ICollection, DAVACL\IACL +{ use DAVACL\ACLTrait; /** - * The notification backend + * The notification backend. * * @var CalDAV\Backend\NotificationSupport */ protected $caldavBackend; /** - * Principal uri + * Principal uri. * * @var string */ protected $principalUri; /** - * Constructor + * Constructor. * * @param CalDAV\Backend\NotificationSupport $caldavBackend - * @param string $principalUri + * @param string $principalUri */ - function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri) { - + public function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri) + { $this->caldavBackend = $caldavBackend; $this->principalUri = $principalUri; - } /** - * Returns all notifications for a principal + * Returns all notifications for a principal. * * @return array */ - function getChildren() { - + public function getChildren() + { $children = []; $notifications = $this->caldavBackend->getNotificationsForPrincipal($this->principalUri); foreach ($notifications as $notification) { - $children[] = new Node( $this->caldavBackend, $this->principalUri, @@ -71,31 +71,27 @@ class Collection extends DAV\Collection implements ICollection, DAVACL\IACL { } return $children; - } /** - * Returns the name of this object + * Returns the name of this object. * * @return string */ - function getName() { - + public function getName() + { return 'notifications'; - } /** - * 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/CalDAV/Notifications/ICollection.php b/vendor/sabre/dav/lib/CalDAV/Notifications/ICollection.php index 008e87435..b12fb3909 100644 --- a/vendor/sabre/dav/lib/CalDAV/Notifications/ICollection.php +++ b/vendor/sabre/dav/lib/CalDAV/Notifications/ICollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Notifications; use Sabre\DAV; @@ -18,6 +20,6 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ICollection extends DAV\ICollection { - +interface ICollection extends DAV\ICollection +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Notifications/INode.php b/vendor/sabre/dav/lib/CalDAV/Notifications/INode.php index 783b92be9..c5897ef4e 100644 --- a/vendor/sabre/dav/lib/CalDAV/Notifications/INode.php +++ b/vendor/sabre/dav/lib/CalDAV/Notifications/INode.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Notifications; use Sabre\CalDAV\Xml\Notification\NotificationInterface; @@ -18,15 +20,15 @@ use Sabre\CalDAV\Xml\Notification\NotificationInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface INode { - +interface INode +{ /** * This method must return an xml element, using the * Sabre\CalDAV\Xml\Notification\NotificationInterface classes. * * @return NotificationInterface */ - function getNotificationType(); + public function getNotificationType(); /** * Returns the etag for the notification. @@ -35,6 +37,5 @@ interface INode { * * @return string */ - function getETag(); - + public function getETag(); } diff --git a/vendor/sabre/dav/lib/CalDAV/Notifications/Node.php b/vendor/sabre/dav/lib/CalDAV/Notifications/Node.php index ad7ddf8f5..b1ec13ff4 100644 --- a/vendor/sabre/dav/lib/CalDAV/Notifications/Node.php +++ b/vendor/sabre/dav/lib/CalDAV/Notifications/Node.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Notifications; use Sabre\CalDAV; @@ -18,55 +20,53 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Node extends DAV\File implements INode, DAVACL\IACL { - +class Node extends DAV\File implements INode, DAVACL\IACL +{ use DAVACL\ACLTrait; /** - * The notification backend + * The notification backend. * * @var CalDAV\Backend\NotificationSupport */ protected $caldavBackend; /** - * The actual notification + * The actual notification. * * @var NotificationInterface */ protected $notification; /** - * Owner principal of the notification + * Owner principal of the notification. * * @var string */ protected $principalUri; /** - * Constructor + * Constructor. * * @param CalDAV\Backend\NotificationSupport $caldavBackend - * @param string $principalUri - * @param NotificationInterface $notification + * @param string $principalUri + * @param NotificationInterface $notification */ - function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri, NotificationInterface $notification) { - + public function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri, NotificationInterface $notification) + { $this->caldavBackend = $caldavBackend; $this->principalUri = $principalUri; $this->notification = $notification; - } /** - * Returns the path name for this notification + * Returns the path name for this notification. * * @return string */ - function getName() { - - return $this->notification->getId() . '.xml'; - + public function getName() + { + return $this->notification->getId().'.xml'; } /** @@ -76,10 +76,9 @@ class Node extends DAV\File implements INode, DAVACL\IACL { * * @return string */ - function getETag() { - + public function getETag() + { return $this->notification->getETag(); - } /** @@ -88,34 +87,28 @@ class Node extends DAV\File implements INode, DAVACL\IACL { * * @return NotificationInterface */ - function getNotificationType() { - + public function getNotificationType() + { return $this->notification; - } /** - * Deletes this notification - * - * @return void + * Deletes this notification. */ - function delete() { - + public function delete() + { $this->caldavBackend->deleteNotification($this->getOwner(), $this->notification); - } /** - * 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/CalDAV/Notifications/Plugin.php b/vendor/sabre/dav/lib/CalDAV/Notifications/Plugin.php index e742351f5..182b70c8e 100644 --- a/vendor/sabre/dav/lib/CalDAV/Notifications/Plugin.php +++ b/vendor/sabre/dav/lib/CalDAV/Notifications/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Notifications; use Sabre\DAV; @@ -12,7 +14,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * Notifications plugin + * Notifications plugin. * * This plugin implements several features required by the caldav-notification * draft specification. @@ -24,10 +26,10 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ /** - * This is the namespace for the proprietary calendarserver extensions + * This is the namespace for the proprietary calendarserver extensions. */ const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'; @@ -46,10 +48,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'notifications'; - } /** @@ -61,58 +62,49 @@ class Plugin extends ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; $server->on('method:GET', [$this, 'httpGet'], 90); - $server->on('propFind', [$this, 'propFind']); + $server->on('propFind', [$this, 'propFind']); $server->xml->namespaceMap[self::NS_CALENDARSERVER] = 'cs'; - $server->resourceTypeMapping['\\Sabre\\CalDAV\\Notifications\\ICollection'] = '{' . self::NS_CALENDARSERVER . '}notification'; + $server->resourceTypeMapping['\\Sabre\\CalDAV\\Notifications\\ICollection'] = '{'.self::NS_CALENDARSERVER.'}notification'; array_push($server->protectedProperties, - '{' . self::NS_CALENDARSERVER . '}notification-URL', - '{' . self::NS_CALENDARSERVER . '}notificationtype' + '{'.self::NS_CALENDARSERVER.'}notification-URL', + '{'.self::NS_CALENDARSERVER.'}notificationtype' ); - } /** - * PropFind + * PropFind. * - * @param PropFind $propFind + * @param PropFind $propFind * @param BaseINode $node - * @return void */ - function propFind(PropFind $propFind, BaseINode $node) { - + public function propFind(PropFind $propFind, BaseINode $node) + { $caldavPlugin = $this->server->getPlugin('caldav'); if ($node instanceof DAVACL\IPrincipal) { - $principalUrl = $node->getPrincipalUrl(); // notification-URL property - $propFind->handle('{' . self::NS_CALENDARSERVER . '}notification-URL', function() use ($principalUrl, $caldavPlugin) { + $propFind->handle('{'.self::NS_CALENDARSERVER.'}notification-URL', function () use ($principalUrl, $caldavPlugin) { + $notificationPath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl).'/notifications/'; - $notificationPath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl) . '/notifications/'; return new DAV\Xml\Property\Href($notificationPath); - }); - } if ($node instanceof INode) { - $propFind->handle( - '{' . self::NS_CALENDARSERVER . '}notificationtype', + '{'.self::NS_CALENDARSERVER.'}notificationtype', [$node, 'getNotificationType'] ); - } - } /** @@ -121,12 +113,11 @@ class Plugin extends ServerPlugin { * We use this to intercept GET calls to notification nodes, and return the * proper response. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); try { @@ -135,8 +126,9 @@ class Plugin extends ServerPlugin { return; } - if (!$node instanceof INode) + if (!$node instanceof INode) { return; + } $writer = $this->server->xml->getWriter(); $writer->contextUri = $this->server->getBaseUri(); @@ -153,7 +145,6 @@ class Plugin extends ServerPlugin { // Return false to break the event chain. return false; - } /** @@ -167,14 +158,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds support for caldav-notifications, which is required to enable caldav-sharing.', - 'link' => 'http://sabre.io/dav/caldav-sharing/', + 'link' => 'http://sabre.io/dav/caldav-sharing/', ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Plugin.php b/vendor/sabre/dav/lib/CalDAV/Plugin.php index def11d52d..04eaedf73 100644 --- a/vendor/sabre/dav/lib/CalDAV/Plugin.php +++ b/vendor/sabre/dav/lib/CalDAV/Plugin.php @@ -1,8 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use DateTimeZone; +use Sabre\CalDAV\Xml\Request\CalendarMultiGetReport; use Sabre\DAV; use Sabre\DAV\Exception\BadRequest; use Sabre\DAV\INode; @@ -16,7 +19,7 @@ use Sabre\Uri; use Sabre\VObject; /** - * CalDAV plugin + * CalDAV plugin. * * This plugin provides functionality added by CalDAV (RFC 4791) * It implements new reports, and the MKCALENDAR method. @@ -25,26 +28,26 @@ 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 +{ /** - * This is the official CalDAV namespace + * This is the official CalDAV namespace. */ const NS_CALDAV = 'urn:ietf:params:xml:ns:caldav'; /** - * This is the namespace for the proprietary calendarserver extensions + * This is the namespace for the proprietary calendarserver extensions. */ const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'; /** * The hardcoded root for calendar objects. It is unfortunate - * that we're stuck with it, but it will have to do for now + * that we're stuck with it, but it will have to do for now. */ const CALENDAR_ROOT = 'calendars'; /** - * Reference to server object + * Reference to server object. * * @var DAV\Server */ @@ -65,14 +68,19 @@ class Plugin extends DAV\ServerPlugin { * available for the specified uri. * * @param string $uri + * * @return array */ - function getHTTPMethods($uri) { - + public function getHTTPMethods($uri) + { // The MKCALENDAR is only available on unmapped uri's, whose // parents extend IExtendedCollection list($parent, $name) = Uri\split($uri); + if ('' === $uri) { + $parent = ''; + } + $node = $this->server->tree->getNodeForPath($parent); if ($node instanceof DAV\IExtendedCollection) { @@ -82,8 +90,8 @@ class Plugin extends DAV\ServerPlugin { return ['MKCALENDAR']; } } - return []; + return []; } /** @@ -94,10 +102,11 @@ class Plugin extends DAV\ServerPlugin { * a calendar home. * * @param string $principalUrl + * * @return string */ - function getCalendarHomeForPrincipal($principalUrl) { - + public function getCalendarHomeForPrincipal($principalUrl) + { // The default behavior for most sabre/dav servers is that there is a // principals root node, which contains users directly under it. // @@ -106,11 +115,14 @@ class Plugin extends DAV\ServerPlugin { // excludes things like the calendar-proxy-read principal (which it // should). $parts = explode('/', trim($principalUrl, '/')); - if (count($parts) !== 2) return; - if ($parts[0] !== 'principals') return; - - return self::CALENDAR_ROOT . '/' . $parts[1]; + if (2 !== count($parts)) { + return; + } + if ('principals' !== $parts[0]) { + return; + } + return self::CALENDAR_ROOT.'/'.$parts[1]; } /** @@ -118,10 +130,9 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['calendar-access', 'calendar-proxy']; - } /** @@ -132,10 +143,9 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'caldav'; - } /** @@ -146,19 +156,20 @@ 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); $reports = []; if ($node instanceof ICalendarObjectContainer || $node instanceof ICalendarObject) { - $reports[] = '{' . self::NS_CALDAV . '}calendar-multiget'; - $reports[] = '{' . self::NS_CALDAV . '}calendar-query'; + $reports[] = '{'.self::NS_CALDAV.'}calendar-multiget'; + $reports[] = '{'.self::NS_CALDAV.'}calendar-query'; } if ($node instanceof ICalendar) { - $reports[] = '{' . self::NS_CALDAV . '}free-busy-query'; + $reports[] = '{'.self::NS_CALDAV.'}free-busy-query'; } // iCal has a bug where it assumes that sync support is enabled, only // if we say we support it on the calendar-home, even though this is @@ -166,39 +177,38 @@ class Plugin extends DAV\ServerPlugin { if ($node instanceof CalendarHome && $this->server->getPlugin('sync')) { $reports[] = '{DAV:}sync-collection'; } - return $reports; + return $reports; } /** - * Initializes the plugin + * Initializes the plugin. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; - $server->on('method:MKCALENDAR', [$this, 'httpMkCalendar']); - $server->on('report', [$this, 'report']); - $server->on('propFind', [$this, 'propFind']); - $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); - $server->on('beforeCreateFile', [$this, 'beforeCreateFile']); - $server->on('beforeWriteContent', [$this, 'beforeWriteContent']); - $server->on('afterMethod:GET', [$this, 'httpAfterGET']); + $server->on('method:MKCALENDAR', [$this, 'httpMkCalendar']); + $server->on('report', [$this, 'report']); + $server->on('propFind', [$this, 'propFind']); + $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); + $server->on('beforeCreateFile', [$this, 'beforeCreateFile']); + $server->on('beforeWriteContent', [$this, 'beforeWriteContent']); + $server->on('afterMethod:GET', [$this, 'httpAfterGET']); $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']); $server->xml->namespaceMap[self::NS_CALDAV] = 'cal'; $server->xml->namespaceMap[self::NS_CALENDARSERVER] = 'cs'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}supported-calendar-component-set'] = 'Sabre\\CalDAV\\Xml\\Property\\SupportedCalendarComponentSet'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}calendar-query'] = 'Sabre\\CalDAV\\Xml\\Request\\CalendarQueryReport'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}calendar-multiget'] = 'Sabre\\CalDAV\\Xml\\Request\\CalendarMultiGetReport'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}free-busy-query'] = 'Sabre\\CalDAV\\Xml\\Request\\FreeBusyQueryReport'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}mkcalendar'] = 'Sabre\\CalDAV\\Xml\\Request\\MkCalendar'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}schedule-calendar-transp'] = 'Sabre\\CalDAV\\Xml\\Property\\ScheduleCalendarTransp'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}supported-calendar-component-set'] = 'Sabre\\CalDAV\\Xml\\Property\\SupportedCalendarComponentSet'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}supported-calendar-component-set'] = 'Sabre\\CalDAV\\Xml\\Property\\SupportedCalendarComponentSet'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}calendar-query'] = 'Sabre\\CalDAV\\Xml\\Request\\CalendarQueryReport'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}calendar-multiget'] = 'Sabre\\CalDAV\\Xml\\Request\\CalendarMultiGetReport'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}free-busy-query'] = 'Sabre\\CalDAV\\Xml\\Request\\FreeBusyQueryReport'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}mkcalendar'] = 'Sabre\\CalDAV\\Xml\\Request\\MkCalendar'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}schedule-calendar-transp'] = 'Sabre\\CalDAV\\Xml\\Property\\ScheduleCalendarTransp'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}supported-calendar-component-set'] = 'Sabre\\CalDAV\\Xml\\Property\\SupportedCalendarComponentSet'; $server->resourceTypeMapping['\\Sabre\\CalDAV\\ICalendar'] = '{urn:ietf:params:xml:ns:caldav}calendar'; @@ -206,86 +216,84 @@ class Plugin extends DAV\ServerPlugin { $server->resourceTypeMapping['\\Sabre\\CalDAV\\Principal\\IProxyWrite'] = '{http://calendarserver.org/ns/}calendar-proxy-write'; array_push($server->protectedProperties, - - '{' . self::NS_CALDAV . '}supported-calendar-component-set', - '{' . self::NS_CALDAV . '}supported-calendar-data', - '{' . self::NS_CALDAV . '}max-resource-size', - '{' . self::NS_CALDAV . '}min-date-time', - '{' . self::NS_CALDAV . '}max-date-time', - '{' . self::NS_CALDAV . '}max-instances', - '{' . self::NS_CALDAV . '}max-attendees-per-instance', - '{' . self::NS_CALDAV . '}calendar-home-set', - '{' . self::NS_CALDAV . '}supported-collation-set', - '{' . self::NS_CALDAV . '}calendar-data', + '{'.self::NS_CALDAV.'}supported-calendar-component-set', + '{'.self::NS_CALDAV.'}supported-calendar-data', + '{'.self::NS_CALDAV.'}max-resource-size', + '{'.self::NS_CALDAV.'}min-date-time', + '{'.self::NS_CALDAV.'}max-date-time', + '{'.self::NS_CALDAV.'}max-instances', + '{'.self::NS_CALDAV.'}max-attendees-per-instance', + '{'.self::NS_CALDAV.'}calendar-home-set', + '{'.self::NS_CALDAV.'}supported-collation-set', + '{'.self::NS_CALDAV.'}calendar-data', // CalendarServer extensions - '{' . self::NS_CALENDARSERVER . '}getctag', - '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for', - '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for' - + '{'.self::NS_CALENDARSERVER.'}getctag', + '{'.self::NS_CALENDARSERVER.'}calendar-proxy-read-for', + '{'.self::NS_CALENDARSERVER.'}calendar-proxy-write-for' ); if ($aclPlugin = $server->getPlugin('acl')) { - $aclPlugin->principalSearchPropertySet['{' . self::NS_CALDAV . '}calendar-user-address-set'] = 'Calendar address'; + $aclPlugin->principalSearchPropertySet['{'.self::NS_CALDAV.'}calendar-user-address-set'] = 'Calendar address'; } } /** - * This functions handles REPORT requests specific to CalDAV + * This functions handles REPORT requests specific to CalDAV. * * @param string $reportName - * @param mixed $report - * @param mixed $path + * @param mixed $report + * @param mixed $path + * * @return bool */ - function report($reportName, $report, $path) { - + public function report($reportName, $report, $path) + { switch ($reportName) { - case '{' . self::NS_CALDAV . '}calendar-multiget' : + case '{'.self::NS_CALDAV.'}calendar-multiget': $this->server->transactionType = 'report-calendar-multiget'; $this->calendarMultiGetReport($report); + return false; - case '{' . self::NS_CALDAV . '}calendar-query' : + case '{'.self::NS_CALDAV.'}calendar-query': $this->server->transactionType = 'report-calendar-query'; $this->calendarQueryReport($report); + return false; - case '{' . self::NS_CALDAV . '}free-busy-query' : + case '{'.self::NS_CALDAV.'}free-busy-query': $this->server->transactionType = 'report-free-busy-query'; $this->freeBusyQueryReport($report); - return false; + return false; } - - } /** * This function handles the MKCALENDAR HTTP method, which creates * a new calendar. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpMkCalendar(RequestInterface $request, ResponseInterface $response) { - + public function httpMkCalendar(RequestInterface $request, ResponseInterface $response) + { $body = $request->getBodyAsString(); $path = $request->getPath(); $properties = []; if ($body) { - try { $mkcalendar = $this->server->xml->expect( '{urn:ietf:params:xml:ns:caldav}mkcalendar', $body ); } catch (\Sabre\Xml\ParseException $e) { - throw new BadRequest($e->getMessage(), null, $e); + throw new BadRequest($e->getMessage(), 0, $e); } $properties = $mkcalendar->getProperties(); - } // iCal abuses MKCALENDAR since iCal 10.9.2 to create server-stored @@ -297,7 +305,7 @@ class Plugin extends DAV\ServerPlugin { if (isset($properties['{DAV:}resourcetype'])) { $resourceType = $properties['{DAV:}resourcetype']->getValue(); } else { - $resourceType = ['{DAV:}collection','{urn:ietf:params:xml:ns:caldav}calendar']; + $resourceType = ['{DAV:}collection', '{urn:ietf:params:xml:ns:caldav}calendar']; } $this->server->createCollection($path, new MkCol($resourceType, $properties)); @@ -310,80 +318,77 @@ class Plugin extends DAV\ServerPlugin { } /** - * PropFind + * PropFind. * * This method handler is invoked before any after properties for a * resource are fetched. This allows us to add in any CalDAV specific * properties. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFind(DAV\PropFind $propFind, DAV\INode $node) { - - $ns = '{' . self::NS_CALDAV . '}'; + public function propFind(DAV\PropFind $propFind, DAV\INode $node) + { + $ns = '{'.self::NS_CALDAV.'}'; if ($node instanceof ICalendarObjectContainer) { - - $propFind->handle($ns . 'max-resource-size', $this->maxResourceSize); - $propFind->handle($ns . 'supported-calendar-data', function() { + $propFind->handle($ns.'max-resource-size', $this->maxResourceSize); + $propFind->handle($ns.'supported-calendar-data', function () { return new Xml\Property\SupportedCalendarData(); }); - $propFind->handle($ns . 'supported-collation-set', function() { + $propFind->handle($ns.'supported-collation-set', function () { return new Xml\Property\SupportedCollationSet(); }); - } if ($node instanceof DAVACL\IPrincipal) { - $principalUrl = $node->getPrincipalUrl(); - $propFind->handle('{' . self::NS_CALDAV . '}calendar-home-set', function() use ($principalUrl) { - + $propFind->handle('{'.self::NS_CALDAV.'}calendar-home-set', function () use ($principalUrl) { $calendarHomePath = $this->getCalendarHomeForPrincipal($principalUrl); - if (is_null($calendarHomePath)) return null; - return new LocalHref($calendarHomePath . '/'); + if (is_null($calendarHomePath)) { + return null; + } + return new LocalHref($calendarHomePath.'/'); }); // The calendar-user-address-set property is basically mapped to // the {DAV:}alternate-URI-set property. - $propFind->handle('{' . self::NS_CALDAV . '}calendar-user-address-set', function() use ($node) { + $propFind->handle('{'.self::NS_CALDAV.'}calendar-user-address-set', function () use ($node) { $addresses = $node->getAlternateUriSet(); - $addresses[] = $this->server->getBaseUri() . $node->getPrincipalUrl() . '/'; + $addresses[] = $this->server->getBaseUri().$node->getPrincipalUrl().'/'; + return new LocalHref($addresses); }); // For some reason somebody thought it was a good idea to add // another one of these properties. We're supporting it too. - $propFind->handle('{' . self::NS_CALENDARSERVER . '}email-address-set', function() use ($node) { + $propFind->handle('{'.self::NS_CALENDARSERVER.'}email-address-set', function () use ($node) { $addresses = $node->getAlternateUriSet(); $emails = []; foreach ($addresses as $address) { - if (substr($address, 0, 7) === 'mailto:') { + if ('mailto:' === substr($address, 0, 7)) { $emails[] = substr($address, 7); } } + return new Xml\Property\EmailAddressSet($emails); }); // These two properties are shortcuts for ical to easily find // other principals this principal has access to. - $propRead = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for'; - $propWrite = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for'; - - if ($propFind->getStatus($propRead) === 404 || $propFind->getStatus($propWrite) === 404) { + $propRead = '{'.self::NS_CALENDARSERVER.'}calendar-proxy-read-for'; + $propWrite = '{'.self::NS_CALENDARSERVER.'}calendar-proxy-write-for'; + if (404 === $propFind->getStatus($propRead) || 404 === $propFind->getStatus($propWrite)) { $aclPlugin = $this->server->getPlugin('acl'); $membership = $aclPlugin->getPrincipalMembership($propFind->getPath()); $readList = []; $writeList = []; foreach ($membership as $group) { - $groupNode = $this->server->tree->getNodeForPath($group); - $listItem = Uri\split($group)[0] . '/'; + $listItem = Uri\split($group)[0].'/'; // If the node is either ap proxy-read or proxy-write // group, we grab the parent principal and add it to the @@ -394,33 +399,27 @@ class Plugin extends DAV\ServerPlugin { if ($groupNode instanceof Principal\IProxyWrite) { $writeList[] = $listItem; } - } $propFind->set($propRead, new LocalHref($readList)); $propFind->set($propWrite, new LocalHref($writeList)); - } - } // instanceof IPrincipal if ($node instanceof ICalendarObject) { - // The calendar-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_CALDAV . '}calendar-data', function() use ($node) { + $propFind->handle('{'.self::NS_CALDAV.'}calendar-data', function () use ($node) { $val = $node->get(); - if (is_resource($val)) + if (is_resource($val)) { $val = stream_get_contents($val); + } // Taking out \r to not screw up the xml output - return str_replace("\r", "", $val); - + return str_replace("\r", '', $val); }); - } - } /** @@ -430,11 +429,10 @@ class Plugin extends DAV\ServerPlugin { * of urls. Effectively avoiding a lot of redundant requests. * * @param CalendarMultiGetReport $report - * @return void */ - function calendarMultiGetReport($report) { - - $needsJson = $report->contentType === 'application/calendar+json'; + public function calendarMultiGetReport($report) + { + $needsJson = 'application/calendar+json' === $report->contentType; $timeZones = []; $propertyList = []; @@ -445,9 +443,8 @@ class Plugin extends DAV\ServerPlugin { ); foreach ($this->server->getPropertiesForMultiplePaths($paths, $report->properties) as $uri => $objProps) { - - if (($needsJson || $report->expand) && isset($objProps[200]['{' . self::NS_CALDAV . '}calendar-data'])) { - $vObject = VObject\Reader::read($objProps[200]['{' . self::NS_CALDAV . '}calendar-data']); + if (($needsJson || $report->expand) && isset($objProps[200]['{'.self::NS_CALDAV.'}calendar-data'])) { + $vObject = VObject\Reader::read($objProps[200]['{'.self::NS_CALDAV.'}calendar-data']); if ($report->expand) { // We're expanding, and for that we need to figure out the @@ -455,7 +452,7 @@ class Plugin extends DAV\ServerPlugin { list($calendarPath) = Uri\split($uri); if (!isset($timeZones[$calendarPath])) { // Checking the calendar-timezone property. - $tzProp = '{' . self::NS_CALDAV . '}calendar-timezone'; + $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone'; $tzResult = $this->server->getProperties($calendarPath, [$tzProp]); if (isset($tzResult[$tzProp])) { // This property contains a VCALENDAR with a single @@ -472,9 +469,9 @@ class Plugin extends DAV\ServerPlugin { $vObject = $vObject->expand($report->expand['start'], $report->expand['end'], $timeZones[$calendarPath]); } if ($needsJson) { - $objProps[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize()); + $objProps[200]['{'.self::NS_CALDAV.'}calendar-data'] = json_encode($vObject->jsonSerialize()); } else { - $objProps[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize(); + $objProps[200]['{'.self::NS_CALDAV.'}calendar-data'] = $vObject->serialize(); } // Destroy circular references so PHP will garbage collect the // object. @@ -482,7 +479,6 @@ class Plugin extends DAV\ServerPlugin { } $propertyList[] = $objProps; - } $prefer = $this->server->getHTTPPrefer(); @@ -490,24 +486,22 @@ 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'])); } /** - * This function handles the calendar-query REPORT + * This function handles the calendar-query REPORT. * * This report is used by clients to request calendar objects based on * complex conditions. * * @param Xml\Request\CalendarQueryReport $report - * @return void */ - function calendarQueryReport($report) { - + public function calendarQueryReport($report) + { $path = $this->server->getRequestUri(); - $needsJson = $report->contentType === 'application/calendar+json'; + $needsJson = 'application/calendar+json' === $report->contentType; $node = $this->server->tree->getNodeForPath($this->server->getRequestUri()); $depth = $this->server->getHTTPDepth(0); @@ -519,7 +513,7 @@ class Plugin extends DAV\ServerPlugin { if ($report->expand) { // We're expanding, and for that we need to figure out the // calendar's timezone. - $tzProp = '{' . self::NS_CALDAV . '}calendar-timezone'; + $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone'; $tzResult = $this->server->getProperties($path, [$tzProp]); if (isset($tzResult[$tzProp])) { // This property contains a VCALENDAR with a single @@ -538,13 +532,11 @@ class Plugin extends DAV\ServerPlugin { // The calendarobject was requested directly. In this case we handle // this locally. - if ($depth == 0 && $node instanceof ICalendarObject) { - + if (0 == $depth && $node instanceof ICalendarObject) { $requestedCalendarData = true; $requestedProperties = $report->properties; if (!in_array('{urn:ietf:params:xml:ns:caldav}calendar-data', $requestedProperties)) { - // We always retrieve calendar-data, as we need it for filtering. $requestedProperties[] = '{urn:ietf:params:xml:ns:caldav}calendar-data'; @@ -566,43 +558,35 @@ class Plugin extends DAV\ServerPlugin { // If there wasn't any calendar-data returned somehow, we ignore // this. if (isset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data'])) { - $validator = new CalendarQueryValidator(); $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); if ($validator->validate($vObject, $report->filters)) { - // If the client didn't require the calendar-data property, // we won't give it back. if (!$requestedCalendarData) { unset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); } else { - - if ($report->expand) { $vObject = $vObject->expand($report->expand['start'], $report->expand['end'], $calendarTimeZone); } if ($needsJson) { - $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize()); + $properties[200]['{'.self::NS_CALDAV.'}calendar-data'] = json_encode($vObject->jsonSerialize()); } elseif ($report->expand) { - $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize(); + $properties[200]['{'.self::NS_CALDAV.'}calendar-data'] = $vObject->serialize(); } } $result = [$properties]; - } // Destroy circular references so PHP will garbage collect the // object. $vObject->destroy(); - } - } - if ($node instanceof ICalendarObjectContainer && $depth === 0) { - - if (strpos($this->server->httpRequest->getHeader('User-Agent'), 'MSFT-') === 0) { + if ($node instanceof ICalendarObjectContainer && 0 === $depth) { + if (0 === strpos((string) $this->server->httpRequest->getHeader('User-Agent'), 'MSFT-')) { // Microsoft clients incorrectly supplied depth as 0, when it actually // should have set depth to 1. We're implementing a workaround here // to deal with this. @@ -614,31 +598,28 @@ class Plugin extends DAV\ServerPlugin { } else { throw new BadRequest('A calendar-query REPORT on a calendar with a Depth: 0 is undefined. Set Depth to 1'); } - } // If we're dealing with a calendar, the calendar itself is responsible // for the calendar-query. - if ($node instanceof ICalendarObjectContainer && $depth == 1) { - + if ($node instanceof ICalendarObjectContainer && 1 == $depth) { $nodePaths = $node->calendarQuery($report->filters); foreach ($nodePaths as $path) { - list($properties) = - $this->server->getPropertiesForPath($this->server->getRequestUri() . '/' . $path, $report->properties); + $this->server->getPropertiesForPath($this->server->getRequestUri().'/'.$path, $report->properties); if (($needsJson || $report->expand)) { - $vObject = VObject\Reader::read($properties[200]['{' . self::NS_CALDAV . '}calendar-data']); + $vObject = VObject\Reader::read($properties[200]['{'.self::NS_CALDAV.'}calendar-data']); if ($report->expand) { $vObject = $vObject->expand($report->expand['start'], $report->expand['end'], $calendarTimeZone); } if ($needsJson) { - $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize()); + $properties[200]['{'.self::NS_CALDAV.'}calendar-data'] = json_encode($vObject->jsonSerialize()); } else { - $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize(); + $properties[200]['{'.self::NS_CALDAV.'}calendar-data'] = $vObject->serialize(); } // Destroy circular references so PHP will garbage collect the @@ -646,9 +627,7 @@ class Plugin extends DAV\ServerPlugin { $vObject->destroy(); } $result[] = $properties; - } - } $prefer = $this->server->getHTTPPrefer(); @@ -656,8 +635,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($result, $prefer['return'] === 'minimal')); - + $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, 'minimal' === $prefer['return'])); } /** @@ -665,15 +643,14 @@ class Plugin extends DAV\ServerPlugin { * response for the CALDAV:free-busy-query REPORT. * * @param Xml\Request\FreeBusyQueryReport $report - * @return void */ - protected function freeBusyQueryReport(Xml\Request\FreeBusyQueryReport $report) { - + protected function freeBusyQueryReport(Xml\Request\FreeBusyQueryReport $report) + { $uri = $this->server->getRequestUri(); $acl = $this->server->getPlugin('acl'); if ($acl) { - $acl->checkPrivileges($uri, '{' . self::NS_CALDAV . '}read-free-busy'); + $acl->checkPrivileges($uri, '{'.self::NS_CALDAV.'}read-free-busy'); } $calendar = $this->server->tree->getNodeForPath($uri); @@ -681,7 +658,7 @@ class Plugin extends DAV\ServerPlugin { throw new DAV\Exception\NotImplemented('The free-busy-query REPORT is only implemented on calendars'); } - $tzProp = '{' . self::NS_CALDAV . '}calendar-timezone'; + $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone'; // Figuring out the default timezone for the calendar, for floating // times. @@ -699,26 +676,27 @@ class Plugin extends DAV\ServerPlugin { // Doing a calendar-query first, to make sure we get the most // performance. $urls = $calendar->calendarQuery([ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => $report->start, - 'end' => $report->end, + 'end' => $report->end, ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]); - $objects = array_map(function($url) use ($calendar) { + $objects = array_map(function ($url) use ($calendar) { $obj = $calendar->getChild($url)->get(); + return $obj; }, $urls); @@ -733,7 +711,6 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setHeader('Content-Type', 'text/calendar'); $this->server->httpResponse->setHeader('Content-Length', strlen($result)); $this->server->httpResponse->setBody($result); - } /** @@ -742,17 +719,17 @@ class Plugin extends DAV\ServerPlugin { * This plugin uses this method to ensure that CalDAV objects receive * valid calendar 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 ICalendarObject) + public function beforeWriteContent($path, DAV\IFile $node, &$data, &$modified) + { + if (!$node instanceof ICalendarObject) { return; + } // We're onyl interested in ICalendarObject nodes that are inside of a // real calendar. This is to avoid triggering validation and scheduling @@ -760,8 +737,9 @@ class Plugin extends DAV\ServerPlugin { list($parent) = Uri\split($path); $parentNode = $this->server->tree->getNodeForPath($parent); - if (!$parentNode instanceof ICalendar) + if (!$parentNode instanceof ICalendar) { return; + } $this->validateICalendar( $data, @@ -771,7 +749,6 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse, false ); - } /** @@ -780,17 +757,17 @@ class Plugin extends DAV\ServerPlugin { * This plugin uses this method to ensure that newly created calendar * objects contain valid calendar 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 ICalendar) + public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode, &$modified) + { + if (!$parentNode instanceof ICalendar) { return; + } $this->validateICalendar( $data, @@ -800,7 +777,6 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse, true ); - } /** @@ -808,17 +784,16 @@ class Plugin extends DAV\ServerPlugin { * * An exception is thrown if it's not. * - * @param resource|string $data - * @param string $path - * @param bool $modified Should be set to true, if this event handler - * changed &$data. - * @param RequestInterface $request The http request. - * @param ResponseInterface $response The http response. - * @param bool $isNew Is the item a new one, or an update. - * @return void + * @param resource|string $data + * @param string $path + * @param bool $modified should be set to true, if this event handler + * changed &$data + * @param RequestInterface $request the http request + * @param ResponseInterface $response the http response + * @param bool $isNew is the item a new one, or an update */ - protected function validateICalendar(&$data, $path, &$modified, RequestInterface $request, ResponseInterface $response, $isNew) { - + protected function validateICalendar(&$data, $path, &$modified, RequestInterface $request, ResponseInterface $response, $isNew) + { // If it's a stream, we convert it to a string first. if (is_resource($data)) { $data = stream_get_contents($data); @@ -827,10 +802,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 @@ -840,14 +814,11 @@ 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 iCalendar 2.0 data. Parse error: ' . $e->getMessage()); - + throw new DAV\Exception\UnsupportedMediaType('This resource only supports valid iCalendar 2.0 data. Parse error: '.$e->getMessage()); } - if ($vobj->name !== 'VCALENDAR') { + if ('VCALENDAR' !== $vobj->name) { throw new DAV\Exception\UnsupportedMediaType('This collection can only support iCalendar objects.'); } @@ -867,25 +838,24 @@ class Plugin extends DAV\ServerPlugin { foreach ($vobj->getComponents() as $component) { switch ($component->name) { - case 'VTIMEZONE' : + case 'VTIMEZONE': continue 2; - case 'VEVENT' : - case 'VTODO' : - case 'VJOURNAL' : + case 'VEVENT': + case 'VTODO': + case 'VJOURNAL': $foundType = $component->name; break; } - } if (!$foundType || !in_array($foundType, $supportedComponents)) { - throw new Exception\InvalidComponentType('iCalendar objects must at least have a component of type ' . implode(', ', $supportedComponents)); + throw new Exception\InvalidComponentType('iCalendar objects must at least have a component of type '.implode(', ', $supportedComponents)); } $options = VObject\Node::PROFILE_CALDAV; $prefer = $this->server->getHTTPPrefer(); - if ($prefer['handling'] !== 'strict') { + if ('strict' !== $prefer['handling']) { $options |= VObject\Node::REPAIR; } @@ -897,32 +867,28 @@ 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']; $warningMessage = $message['message']; } 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 iCalendar: ' . $message['message']); - + throw new DAV\Exception\UnsupportedMediaType('Validation error in iCalendar: '.$message['message']); } - } if ($warningMessage) { $response->setHeader( 'X-Sabre-Ew-Gross', - 'iCalendar validation warning: ' . $warningMessage + 'iCalendar validation warning: '.$warningMessage ); } @@ -940,7 +906,7 @@ class Plugin extends DAV\ServerPlugin { $vobj, $parentPath, &$subModified, - $isNew + $isNew, ] ); @@ -949,15 +915,13 @@ class Plugin extends DAV\ServerPlugin { $data = $vobj->serialize(); // Using md5 to figure out if there was an *actual* change. - if (!$modified && strcmp($data, $before) !== 0) { + if (!$modified && 0 !== strcmp($data, $before)) { $modified = true; } - } // Destroy circular references so PHP will garbage collect the object. $vobj->destroy(); - } /** @@ -967,11 +931,11 @@ class Plugin extends DAV\ServerPlugin { * @param INode $node * @param array $supportedPrivilegeSet */ - function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) { - + public function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) + { if ($node instanceof ICalendar) { - $supportedPrivilegeSet['{DAV:}read']['aggregates']['{' . self::NS_CALDAV . '}read-free-busy'] = [ - 'abstract' => false, + $supportedPrivilegeSet['{DAV:}read']['aggregates']['{'.self::NS_CALDAV.'}read-free-busy'] = [ + 'abstract' => false, 'aggregates' => [], ]; } @@ -983,18 +947,20 @@ class Plugin extends DAV\ServerPlugin { * can use to create new calendars. * * @param DAV\INode $node - * @param string $output + * @param string $output + * * @return bool */ - function htmlActionsPanel(DAV\INode $node, &$output) { - - if (!$node instanceof CalendarHome) + public function htmlActionsPanel(DAV\INode $node, &$output) + { + if (!$node instanceof CalendarHome) { return; + } $output .= '<tr><td colspan="2"><form method="post" action=""> <h3>Create new calendar</h3> <input type="hidden" name="sabreAction" value="mkcol" /> - <input type="hidden" name="resourceType" value="{DAV:}collection,{' . self::NS_CALDAV . '}calendar" /> + <input type="hidden" name="resourceType" value="{DAV:}collection,{'.self::NS_CALDAV.'}calendar" /> <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" /> @@ -1002,7 +968,6 @@ class Plugin extends DAV\ServerPlugin { </td></tr>'; return false; - } /** @@ -1010,22 +975,22 @@ 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/calendar') === false) { + public function httpAfterGet(RequestInterface $request, ResponseInterface $response) + { + $contentType = $response->getHeader('Content-Type'); + if (null === $contentType || false === strpos($contentType, 'text/calendar')) { return; } - $result = HTTP\Util::negotiate( + $result = HTTP\negotiateContentType( $request->getHeader('Accept'), ['text/calendar', 'application/calendar+json'] ); - if ($result !== 'application/calendar+json') { + if ('application/calendar+json' !== $result) { // Do nothing return; } @@ -1041,7 +1006,6 @@ class Plugin extends DAV\ServerPlugin { $response->setHeader('Content-Type', 'application/calendar+json'); $response->setHeader('Content-Length', strlen($jsonBody)); - } /** @@ -1055,14 +1019,12 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds support for CalDAV (rfc4791)', - 'link' => 'http://sabre.io/dav/caldav/', + 'link' => 'http://sabre.io/dav/caldav/', ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Principal/Collection.php b/vendor/sabre/dav/lib/CalDAV/Principal/Collection.php index e19719a76..cae29c752 100644 --- a/vendor/sabre/dav/lib/CalDAV/Principal/Collection.php +++ b/vendor/sabre/dav/lib/CalDAV/Principal/Collection.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAVACL; /** - * Principal collection + * Principal collection. * * This is an alternative collection to the standard ACL principal collection. * This collection adds support for the calendar-proxy-read and @@ -16,18 +18,17 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Collection extends DAVACL\PrincipalCollection { - +class Collection extends DAVACL\PrincipalCollection +{ /** - * Returns a child object based on principal information + * Returns a child object based on principal information. * * @param array $principalInfo + * * @return User */ - function getChildForPrincipal(array $principalInfo) { - + public function getChildForPrincipal(array $principalInfo) + { return new User($this->principalBackend, $principalInfo); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Principal/IProxyRead.php b/vendor/sabre/dav/lib/CalDAV/Principal/IProxyRead.php index 7dd375932..96e6991c5 100644 --- a/vendor/sabre/dav/lib/CalDAV/Principal/IProxyRead.php +++ b/vendor/sabre/dav/lib/CalDAV/Principal/IProxyRead.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAVACL; /** - * ProxyRead principal interface + * ProxyRead principal interface. * * Any principal node implementing this interface will be picked up as a 'proxy * principal group'. @@ -14,6 +16,6 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IProxyRead extends DAVACL\IPrincipal { - +interface IProxyRead extends DAVACL\IPrincipal +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Principal/IProxyWrite.php b/vendor/sabre/dav/lib/CalDAV/Principal/IProxyWrite.php index eda87a4ff..2556039ca 100644 --- a/vendor/sabre/dav/lib/CalDAV/Principal/IProxyWrite.php +++ b/vendor/sabre/dav/lib/CalDAV/Principal/IProxyWrite.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAVACL; /** - * ProxyWrite principal interface + * ProxyWrite principal interface. * * Any principal node implementing this interface will be picked up as a 'proxy * principal group'. @@ -14,6 +16,6 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IProxyWrite extends DAVACL\IPrincipal { - +interface IProxyWrite extends DAVACL\IPrincipal +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Principal/ProxyRead.php b/vendor/sabre/dav/lib/CalDAV/Principal/ProxyRead.php index e3881831e..1b24984bd 100644 --- a/vendor/sabre/dav/lib/CalDAV/Principal/ProxyRead.php +++ b/vendor/sabre/dav/lib/CalDAV/Principal/ProxyRead.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAV; use Sabre\DAVACL; /** - * ProxyRead principal + * ProxyRead principal. * * This class represents a principal group, hosted under the main principal. * This is needed to implement 'Calendar delegation' support. This class is @@ -16,8 +18,8 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ProxyRead implements IProxyRead { - +class ProxyRead implements IProxyRead +{ /** * Principal information from the parent principal. * @@ -26,7 +28,7 @@ class ProxyRead implements IProxyRead { protected $principalInfo; /** - * Principal backend + * Principal backend. * * @var DAVACL\PrincipalBackend\BackendInterface */ @@ -38,13 +40,12 @@ class ProxyRead implements IProxyRead { * Note that you MUST supply the parent principal information. * * @param DAVACL\PrincipalBackend\BackendInterface $principalBackend - * @param array $principalInfo + * @param array $principalInfo */ - function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) { - + public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) + { $this->principalInfo = $principalInfo; $this->principalBackend = $principalBackend; - } /** @@ -52,103 +53,91 @@ class ProxyRead implements IProxyRead { * * @return string */ - function getName() { - + public function getName() + { return 'calendar-proxy-read'; - } /** - * Returns the last modification time - * - * @return null + * Returns the last modification time. */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** - * Deletes the current node + * Deletes the current node. * * @throws DAV\Exception\Forbidden - * @return void */ - function delete() { - + public function delete() + { throw new DAV\Exception\Forbidden('Permission denied to delete node'); - } /** - * Renames the node + * Renames the node. * * @param string $name The new name + * * @throws DAV\Exception\Forbidden - * @return void */ - function setName($name) { - + public function setName($name) + { throw new DAV\Exception\Forbidden('Permission denied to rename file'); - } - /** - * Returns a list of alternative urls for a principal + * Returns a list of alternative urls for a principal. * * This can for example be an email address, or ldap url. * * @return array */ - function getAlternateUriSet() { - + public function getAlternateUriSet() + { return []; - } /** - * Returns the full principal url + * Returns the full principal url. * * @return string */ - function getPrincipalUrl() { - - return $this->principalInfo['uri'] . '/' . $this->getName(); - + public function getPrincipalUrl() + { + return $this->principalInfo['uri'].'/'.$this->getName(); } /** - * Returns the list of group members + * Returns the list of group members. * * If this principal is a group, this function should return * all member principal uri's for the group. * * @return array */ - function getGroupMemberSet() { - + public function getGroupMemberSet() + { return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl()); - } /** - * Returns the list of groups this principal is member of + * Returns the list of groups this principal is member of. * * If this principal is a member of a (list of) groups, this function * should return a list of principal uri's for it's members. * * @return array */ - function getGroupMembership() { - + public function getGroupMembership() + { return $this->principalBackend->getGroupMembership($this->getPrincipalUrl()); - } /** - * Sets a list of group members + * Sets a list of group members. * * If this principal is a group, this method sets all the group members. * The list of members is always overwritten, never appended to. @@ -156,26 +145,22 @@ class ProxyRead implements IProxyRead { * This method should throw an exception if the members could not be set. * * @param array $principals - * @return void */ - function setGroupMemberSet(array $principals) { - + public function setGroupMemberSet(array $principals) + { $this->principalBackend->setGroupMemberSet($this->getPrincipalUrl(), $principals); - } /** - * Returns the displayname + * Returns the displayname. * * This should be a human readable name for the principal. * If none is available, return the nodename. * * @return string */ - function getDisplayName() { - + public function getDisplayName() + { return $this->getName(); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Principal/ProxyWrite.php b/vendor/sabre/dav/lib/CalDAV/Principal/ProxyWrite.php index 43dd9bf07..7b9c78e0a 100644 --- a/vendor/sabre/dav/lib/CalDAV/Principal/ProxyWrite.php +++ b/vendor/sabre/dav/lib/CalDAV/Principal/ProxyWrite.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAV; use Sabre\DAVACL; /** - * ProxyWrite principal + * ProxyWrite principal. * * This class represents a principal group, hosted under the main principal. * This is needed to implement 'Calendar delegation' support. This class is @@ -16,35 +18,34 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ProxyWrite implements IProxyWrite { - +class ProxyWrite implements IProxyWrite +{ /** - * Parent principal information + * Parent principal information. * * @var array */ protected $principalInfo; /** - * Principal Backend + * Principal Backend. * * @var DAVACL\PrincipalBackend\BackendInterface */ protected $principalBackend; /** - * Creates the object + * Creates the object. * * Note that you MUST supply the parent principal information. * * @param DAVACL\PrincipalBackend\BackendInterface $principalBackend - * @param array $principalInfo + * @param array $principalInfo */ - function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) { - + public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) + { $this->principalInfo = $principalInfo; $this->principalBackend = $principalBackend; - } /** @@ -52,103 +53,91 @@ class ProxyWrite implements IProxyWrite { * * @return string */ - function getName() { - + public function getName() + { return 'calendar-proxy-write'; - } /** - * Returns the last modification time - * - * @return null + * Returns the last modification time. */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** - * Deletes the current node + * Deletes the current node. * * @throws DAV\Exception\Forbidden - * @return void */ - function delete() { - + public function delete() + { throw new DAV\Exception\Forbidden('Permission denied to delete node'); - } /** - * Renames the node + * Renames the node. * * @param string $name The new name + * * @throws DAV\Exception\Forbidden - * @return void */ - function setName($name) { - + public function setName($name) + { throw new DAV\Exception\Forbidden('Permission denied to rename file'); - } - /** - * Returns a list of alternative urls for a principal + * Returns a list of alternative urls for a principal. * * This can for example be an email address, or ldap url. * * @return array */ - function getAlternateUriSet() { - + public function getAlternateUriSet() + { return []; - } /** - * Returns the full principal url + * Returns the full principal url. * * @return string */ - function getPrincipalUrl() { - - return $this->principalInfo['uri'] . '/' . $this->getName(); - + public function getPrincipalUrl() + { + return $this->principalInfo['uri'].'/'.$this->getName(); } /** - * Returns the list of group members + * Returns the list of group members. * * If this principal is a group, this function should return * all member principal uri's for the group. * * @return array */ - function getGroupMemberSet() { - + public function getGroupMemberSet() + { return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl()); - } /** - * Returns the list of groups this principal is member of + * Returns the list of groups this principal is member of. * * If this principal is a member of a (list of) groups, this function * should return a list of principal uri's for it's members. * * @return array */ - function getGroupMembership() { - + public function getGroupMembership() + { return $this->principalBackend->getGroupMembership($this->getPrincipalUrl()); - } /** - * Sets a list of group members + * Sets a list of group members. * * If this principal is a group, this method sets all the group members. * The list of members is always overwritten, never appended to. @@ -156,26 +145,22 @@ class ProxyWrite implements IProxyWrite { * This method should throw an exception if the members could not be set. * * @param array $principals - * @return void */ - function setGroupMemberSet(array $principals) { - + public function setGroupMemberSet(array $principals) + { $this->principalBackend->setGroupMemberSet($this->getPrincipalUrl(), $principals); - } /** - * Returns the displayname + * Returns the displayname. * * This should be a human readable name for the principal. * If none is available, return the nodename. * * @return string */ - function getDisplayName() { - + public function getDisplayName() + { return $this->getName(); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Principal/User.php b/vendor/sabre/dav/lib/CalDAV/Principal/User.php index 6e97e7cca..88bf4b4f7 100644 --- a/vendor/sabre/dav/lib/CalDAV/Principal/User.php +++ b/vendor/sabre/dav/lib/CalDAV/Principal/User.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAV; use Sabre\DAVACL; /** - * CalDAV principal + * CalDAV principal. * * This is a standard user-principal for CalDAV. This principal is also a * collection and returns the caldav-proxy-read and caldav-proxy-write child @@ -16,91 +18,91 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class User extends DAVACL\Principal implements DAV\ICollection { - +class User extends DAVACL\Principal implements DAV\ICollection +{ /** - * Creates a new file in the directory + * Creates a new file in the directory. + * + * @param string $name Name of the file + * @param resource $data initial payload, passed as a readable stream resource * - * @param string $name Name of the file - * @param resource $data Initial payload, passed as a readable stream resource. * @throws DAV\Exception\Forbidden - * @return void */ - function createFile($name, $data = null) { - - throw new DAV\Exception\Forbidden('Permission denied to create file (filename ' . $name . ')'); - + public function createFile($name, $data = null) + { + throw new DAV\Exception\Forbidden('Permission denied to create file (filename '.$name.')'); } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name + * * @throws DAV\Exception\Forbidden - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { throw new DAV\Exception\Forbidden('Permission denied to create directory'); - } /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * @param string $name + * * @return DAV\INode */ - function getChild($name) { - - $principal = $this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/' . $name); + public function getChild($name) + { + $principal = $this->principalBackend->getPrincipalByPath($this->getPrincipalURL().'/'.$name); if (!$principal) { - throw new DAV\Exception\NotFound('Node with name ' . $name . ' was not found'); + throw new DAV\Exception\NotFound('Node with name '.$name.' was not found'); } - if ($name === 'calendar-proxy-read') + if ('calendar-proxy-read' === $name) { return new ProxyRead($this->principalBackend, $this->principalProperties); + } - if ($name === 'calendar-proxy-write') + if ('calendar-proxy-write' === $name) { return new ProxyWrite($this->principalBackend, $this->principalProperties); + } - throw new DAV\Exception\NotFound('Node with name ' . $name . ' was not found'); - + throw new DAV\Exception\NotFound('Node with name '.$name.' was not found'); } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return DAV\INode[] */ - function getChildren() { - + public function getChildren() + { $r = []; - if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-read')) { + if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL().'/calendar-proxy-read')) { $r[] = new ProxyRead($this->principalBackend, $this->principalProperties); } - if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-write')) { + if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL().'/calendar-proxy-write')) { $r[] = new ProxyWrite($this->principalBackend, $this->principalProperties); } return $r; - } /** - * Returns whether or not the child node exists + * Returns whether or not the child node exists. * * @param string $name + * * @return bool */ - function childExists($name) { - + public function childExists($name) + { try { $this->getChild($name); + return true; } catch (DAV\Exception\NotFound $e) { return false; } - } /** @@ -115,21 +117,20 @@ class User extends DAVACL\Principal implements DAV\ICollection { * * @return array */ - function getACL() { - + public function getACL() + { $acl = parent::getACL(); $acl[] = [ 'privilege' => '{DAV:}read', - 'principal' => $this->principalProperties['uri'] . '/calendar-proxy-read', + 'principal' => $this->principalProperties['uri'].'/calendar-proxy-read', 'protected' => true, ]; $acl[] = [ 'privilege' => '{DAV:}read', - 'principal' => $this->principalProperties['uri'] . '/calendar-proxy-write', + 'principal' => $this->principalProperties['uri'].'/calendar-proxy-write', 'protected' => true, ]; - return $acl; + return $acl; } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php index c9fd77d93..64a94becc 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; /** @@ -10,6 +12,6 @@ namespace Sabre\CalDAV\Schedule; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IInbox extends \Sabre\CalDAV\ICalendarObjectContainer, \Sabre\DAVACL\IACL { - +interface IInbox extends \Sabre\CalDAV\ICalendarObjectContainer, \Sabre\DAVACL\IACL +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php b/vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php index 6f5acb29a..d71b3c0f8 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; use Sabre\DAV; @@ -19,8 +21,8 @@ use Sabre\VObject\ITip; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class IMipPlugin extends DAV\ServerPlugin { - +class IMipPlugin extends DAV\ServerPlugin +{ /** * Email address used in From: header. * @@ -29,7 +31,7 @@ class IMipPlugin extends DAV\ServerPlugin { protected $senderEmail; /** - * ITipMessage + * ITipMessage. * * @var ITip\Message */ @@ -43,10 +45,9 @@ class IMipPlugin extends DAV\ServerPlugin { * generally be some kind of no-reply email * address you own. */ - function __construct($senderEmail) { - + public function __construct($senderEmail) + { $this->senderEmail = $senderEmail; - } /* @@ -60,10 +61,9 @@ class IMipPlugin extends DAV\ServerPlugin { * @param DAV\Server $server * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $server->on('schedule', [$this, 'schedule'], 120); - } /** @@ -74,67 +74,68 @@ class IMipPlugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'imip'; - } /** * Event handler for the 'schedule' event. * * @param ITip\Message $iTipMessage - * @return void */ - function schedule(ITip\Message $iTipMessage) { - + public function schedule(ITip\Message $iTipMessage) + { // Not sending any emails if the system considers the update // insignificant. if (!$iTipMessage->significantChange) { if (!$iTipMessage->scheduleStatus) { $iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email'; } + return; } $summary = $iTipMessage->message->VEVENT->SUMMARY; - if (parse_url($iTipMessage->sender, PHP_URL_SCHEME) !== 'mailto') + if ('mailto' !== parse_url($iTipMessage->sender, PHP_URL_SCHEME)) { return; + } - if (parse_url($iTipMessage->recipient, PHP_URL_SCHEME) !== 'mailto') + if ('mailto' !== parse_url($iTipMessage->recipient, PHP_URL_SCHEME)) { return; + } $sender = substr($iTipMessage->sender, 7); $recipient = substr($iTipMessage->recipient, 7); if ($iTipMessage->senderName) { - $sender = $iTipMessage->senderName . ' <' . $sender . '>'; + $sender = $iTipMessage->senderName.' <'.$sender.'>'; } - if ($iTipMessage->recipientName) { - $recipient = $iTipMessage->recipientName . ' <' . $recipient . '>'; + if ($iTipMessage->recipientName && $iTipMessage->recipientName != $recipient) { + $recipient = $iTipMessage->recipientName.' <'.$recipient.'>'; } $subject = 'SabreDAV iTIP message'; switch (strtoupper($iTipMessage->method)) { - case 'REPLY' : - $subject = 'Re: ' . $summary; + case 'REPLY': + $subject = 'Re: '.$summary; break; - case 'REQUEST' : - $subject = $summary; + case 'REQUEST': + $subject = 'Invitation: '.$summary; break; - case 'CANCEL' : - $subject = 'Cancelled: ' . $summary; + case 'CANCEL': + $subject = 'Cancelled: '.$summary; break; } $headers = [ - 'Reply-To: ' . $sender, - 'From: ' . $this->senderEmail, - 'Content-Type: text/calendar; charset=UTF-8; method=' . $iTipMessage->method, + 'Reply-To: '.$sender, + 'From: '.$iTipMessage->senderName.' <'.$this->senderEmail.'>', + 'Content-Type: text/calendar; charset=UTF-8; method='.$iTipMessage->method, ]; if (DAV\Server::$exposeVersion) { - $headers[] = 'X-Sabre-Version: ' . DAV\Version::VERSION; + $headers[] = 'X-Sabre-Version: '.DAV\Version::VERSION; } $this->mail( $recipient, @@ -143,7 +144,6 @@ class IMipPlugin extends DAV\ServerPlugin { $headers ); $iTipMessage->scheduleStatus = '1.1; Scheduling message is sent via iMip'; - } // @codeCoverageIgnoreStart @@ -152,16 +152,14 @@ class IMipPlugin extends DAV\ServerPlugin { /** * This function is responsible for sending the actual email. * - * @param string $to Recipient email address + * @param string $to Recipient email address * @param string $subject Subject of the email - * @param string $body iCalendar body - * @param array $headers List of headers - * @return void + * @param string $body iCalendar body + * @param array $headers List of headers */ - protected function mail($to, $subject, $body, array $headers) { - + protected function mail($to, $subject, $body, array $headers) + { mail($to, $subject, $body, implode("\r\n", $headers)); - } // @codeCoverageIgnoreEnd @@ -177,14 +175,12 @@ class IMipPlugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Email delivery (rfc6047) for CalDAV scheduling', - 'link' => 'http://sabre.io/dav/scheduling/', + 'link' => 'http://sabre.io/dav/scheduling/', ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php index 88fbdc411..384b503df 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; /** @@ -10,6 +12,6 @@ namespace Sabre\CalDAV\Schedule; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IOutbox extends \Sabre\DAV\ICollection, \Sabre\DAVACL\IACL { - +interface IOutbox extends \Sabre\DAV\ICollection, \Sabre\DAVACL\IACL +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php b/vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php index b37cb40a1..345b55d9f 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; /** - * The SchedulingObject represents a scheduling object in the Inbox collection + * The SchedulingObject represents a scheduling object in the Inbox collection. * * @license http://sabre.io/license/ Modified BSD License * @copyright Copyright (C) fruux GmbH (https://fruux.com/) */ -interface ISchedulingObject extends \Sabre\CalDAV\ICalendarObject { - +interface ISchedulingObject extends \Sabre\CalDAV\ICalendarObject +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php index 81b017307..d92f1dd4c 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; use Sabre\CalDAV; @@ -9,41 +11,40 @@ use Sabre\DAVACL; use Sabre\VObject; /** - * The CalDAV scheduling inbox + * The CalDAV scheduling inbox. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Inbox extends DAV\Collection implements IInbox { - +class Inbox extends DAV\Collection implements IInbox +{ use DAVACL\ACLTrait; /** - * CalDAV backend + * CalDAV backend. * * @var Backend\BackendInterface */ protected $caldavBackend; /** - * The principal Uri + * The principal Uri. * * @var string */ protected $principalUri; /** - * Constructor + * Constructor. * * @param Backend\SchedulingSupport $caldavBackend - * @param string $principalUri + * @param string $principalUri */ - function __construct(Backend\SchedulingSupport $caldavBackend, $principalUri) { - + public function __construct(Backend\SchedulingSupport $caldavBackend, $principalUri) + { $this->caldavBackend = $caldavBackend; $this->principalUri = $principalUri; - } /** @@ -53,19 +54,18 @@ class Inbox extends DAV\Collection implements IInbox { * * @return string */ - function getName() { - + public function getName() + { return 'inbox'; - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return \Sabre\DAV\INode[] */ - function getChildren() { - + public function getChildren() + { $objs = $this->caldavBackend->getSchedulingObjects($this->principalUri); $children = []; foreach ($objs as $obj) { @@ -73,12 +73,12 @@ class Inbox extends DAV\Collection implements IInbox { $obj['principaluri'] = $this->principalUri; $children[] = new SchedulingObject($this->caldavBackend, $obj); } - return $children; + return $children; } /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -97,27 +97,26 @@ class Inbox extends DAV\Collection implements IInbox { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - + public function createFile($name, $data = null) + { $this->caldavBackend->createSchedulingObject($this->principalUri, $name, $data); - } /** - * 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; - } /** @@ -132,8 +131,8 @@ class Inbox extends DAV\Collection implements IInbox { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ 'privilege' => '{DAV:}read', @@ -152,16 +151,15 @@ class Inbox extends DAV\Collection implements IInbox { ], [ 'privilege' => '{DAV:}unbind', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ], [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-deliver', + 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-deliver', 'principal' => '{DAV:}authenticated', 'protected' => true, ], ]; - } /** @@ -179,10 +177,11 @@ class Inbox extends DAV\Collection implements IInbox { * documented by \Sabre\CalDAV\CalendarQueryParser. * * @param array $filters + * * @return array */ - function calendarQuery(array $filters) { - + public function calendarQuery(array $filters) + { $result = []; $validator = new CalDAV\CalendarQueryValidator(); @@ -196,8 +195,7 @@ class Inbox extends DAV\Collection implements IInbox { // Destroy circular references to PHP will GC the object. $vObject->destroy(); } - return $result; + return $result; } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php index 888ea3086..1442c4cc6 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; use Sabre\CalDAV; @@ -7,7 +9,7 @@ use Sabre\DAV; use Sabre\DAVACL; /** - * The CalDAV scheduling outbox + * The CalDAV scheduling outbox. * * The outbox is mainly used as an endpoint in the tree for a client to do * free-busy requests. This functionality is completely handled by the @@ -17,26 +19,25 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Outbox extends DAV\Collection implements IOutbox { - +class Outbox extends DAV\Collection implements IOutbox +{ use DAVACL\ACLTrait; /** - * The principal Uri + * The principal Uri. * * @var string */ protected $principalUri; /** - * Constructor + * Constructor. * * @param string $principalUri */ - function __construct($principalUri) { - + public function __construct($principalUri) + { $this->principalUri = $principalUri; - } /** @@ -46,34 +47,31 @@ class Outbox extends DAV\Collection implements IOutbox { * * @return string */ - function getName() { - + public function getName() + { return 'outbox'; - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return \Sabre\DAV\INode[] */ - function getChildren() { - + public function getChildren() + { return []; - } /** - * 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; - } /** @@ -88,11 +86,11 @@ class Outbox extends DAV\Collection implements IOutbox { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send', + 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send', 'principal' => $this->getOwner(), 'protected' => true, ], @@ -102,22 +100,20 @@ class Outbox extends DAV\Collection implements IOutbox { 'protected' => true, ], [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-read', + 'principal' => $this->getOwner().'/calendar-proxy-read', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ], ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php b/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php index 0b991e619..d2c9b68e9 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; use DateTimeZone; @@ -28,7 +30,7 @@ use Sabre\VObject\Reader; /** * CalDAV scheduling plugin. - * ========================= + * =========================. * * This plugin provides the functionality added by the "Scheduling Extensions * to CalDAV" standard, as defined in RFC6638. @@ -53,10 +55,10 @@ use Sabre\VObject\Reader; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ /** - * This is the official CalDAV namespace + * This is the official CalDAV namespace. */ const NS_CALDAV = 'urn:ietf:params:xml:ns:caldav'; @@ -72,10 +74,9 @@ class Plugin extends ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['calendar-auto-schedule', 'calendar-availability']; - } /** @@ -86,49 +87,46 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'caldav-schedule'; - } /** - * Initializes the plugin + * Initializes the plugin. * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; - $server->on('method:POST', [$this, 'httpPost']); - $server->on('propFind', [$this, 'propFind']); - $server->on('propPatch', [$this, 'propPatch']); - $server->on('calendarObjectChange', [$this, 'calendarObjectChange']); - $server->on('beforeUnbind', [$this, 'beforeUnbind']); - $server->on('schedule', [$this, 'scheduleLocalDelivery']); + $server->on('method:POST', [$this, 'httpPost']); + $server->on('propFind', [$this, 'propFind']); + $server->on('propPatch', [$this, 'propPatch']); + $server->on('calendarObjectChange', [$this, 'calendarObjectChange']); + $server->on('beforeUnbind', [$this, 'beforeUnbind']); + $server->on('schedule', [$this, 'scheduleLocalDelivery']); $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']); - $ns = '{' . self::NS_CALDAV . '}'; + $ns = '{'.self::NS_CALDAV.'}'; - /** + /* * This information ensures that the {DAV:}resourcetype property has * the correct values. */ - $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IOutbox'] = $ns . 'schedule-outbox'; - $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IInbox'] = $ns . 'schedule-inbox'; + $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IOutbox'] = $ns.'schedule-outbox'; + $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IInbox'] = $ns.'schedule-inbox'; - /** + /* * Properties we protect are made read-only by the server. */ array_push($server->protectedProperties, - $ns . 'schedule-inbox-URL', - $ns . 'schedule-outbox-URL', - $ns . 'calendar-user-address-set', - $ns . 'calendar-user-type', - $ns . 'schedule-default-calendar-URL' + $ns.'schedule-inbox-URL', + $ns.'schedule-outbox-URL', + $ns.'calendar-user-address-set', + $ns.'calendar-user-type', + $ns.'schedule-default-calendar-URL' ); - } /** @@ -139,10 +137,11 @@ class Plugin extends ServerPlugin { * available for the specified uri. * * @param string $uri + * * @return array */ - function getHTTPMethods($uri) { - + public function getHTTPMethods($uri) + { try { $node = $this->server->tree->getNodeForPath($uri); } catch (NotFound $e) { @@ -154,21 +153,21 @@ class Plugin extends ServerPlugin { } return []; - } /** * This method handles POST request for the outbox. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpPost(RequestInterface $request, ResponseInterface $response) { - + public function httpPost(RequestInterface $request, ResponseInterface $response) + { // Checking if this is a text/calendar content type $contentType = $request->getHeader('Content-Type'); - if (strpos($contentType, 'text/calendar') !== 0) { + if (!$contentType || 0 !== strpos($contentType, 'text/calendar')) { return; } @@ -180,8 +179,9 @@ class Plugin extends ServerPlugin { } catch (NotFound $e) { return; } - if (!$node instanceof IOutbox) + if (!$node instanceof IOutbox) { return; + } $this->server->transactionType = 'post-caldav-outbox'; $this->outboxRequest($node, $request, $response); @@ -189,7 +189,6 @@ class Plugin extends ServerPlugin { // Returning false breaks the event chain and tells the server we've // handled the request. return false; - } /** @@ -198,43 +197,36 @@ class Plugin extends ServerPlugin { * We use this event to add calendar-auto-schedule-specific properties. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - + public function propFind(PropFind $propFind, INode $node) + { if ($node instanceof DAVACL\IPrincipal) { - $caldavPlugin = $this->server->getPlugin('caldav'); $principalUrl = $node->getPrincipalUrl(); // schedule-outbox-URL property - $propFind->handle('{' . self::NS_CALDAV . '}schedule-outbox-URL', function() use ($principalUrl, $caldavPlugin) { - + $propFind->handle('{'.self::NS_CALDAV.'}schedule-outbox-URL', function () use ($principalUrl, $caldavPlugin) { $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl); if (!$calendarHomePath) { return null; } - $outboxPath = $calendarHomePath . '/outbox/'; + $outboxPath = $calendarHomePath.'/outbox/'; return new LocalHref($outboxPath); - }); // schedule-inbox-URL property - $propFind->handle('{' . self::NS_CALDAV . '}schedule-inbox-URL', function() use ($principalUrl, $caldavPlugin) { - + $propFind->handle('{'.self::NS_CALDAV.'}schedule-inbox-URL', function () use ($principalUrl, $caldavPlugin) { $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl); if (!$calendarHomePath) { return null; } - $inboxPath = $calendarHomePath . '/inbox/'; + $inboxPath = $calendarHomePath.'/inbox/'; return new LocalHref($inboxPath); - }); - $propFind->handle('{' . self::NS_CALDAV . '}schedule-default-calendar-URL', function() use ($principalUrl, $caldavPlugin) { - + $propFind->handle('{'.self::NS_CALDAV.'}schedule-default-calendar-URL', function () use ($principalUrl, $caldavPlugin) { // We don't support customizing this property yet, so in the // meantime we just grab the first calendar in the home-set. $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl); @@ -243,7 +235,7 @@ class Plugin extends ServerPlugin { return null; } - $sccs = '{' . self::NS_CALDAV . '}supported-calendar-component-set'; + $sccs = '{'.self::NS_CALDAV.'}supported-calendar-component-set'; $result = $this->server->getPropertiesForPath($calendarHomePath, [ '{DAV:}resourcetype', @@ -252,18 +244,17 @@ class Plugin extends ServerPlugin { ], 1); foreach ($result as $child) { - if (!isset($child[200]['{DAV:}resourcetype']) || !$child[200]['{DAV:}resourcetype']->is('{' . self::NS_CALDAV . '}calendar')) { + if (!isset($child[200]['{DAV:}resourcetype']) || !$child[200]['{DAV:}resourcetype']->is('{'.self::NS_CALDAV.'}calendar')) { // Node is either not a calendar continue; } if (isset($child[200]['{DAV:}share-access'])) { $shareAccess = $child[200]['{DAV:}share-access']->getValue(); - if ($shareAccess !== Sharing\Plugin::ACCESS_NOTSHARED && $shareAccess !== Sharing\Plugin::ACCESS_SHAREDOWNER) { + if (Sharing\Plugin::ACCESS_NOTSHARED !== $shareAccess && Sharing\Plugin::ACCESS_SHAREDOWNER !== $shareAccess) { // Node is a shared node, not owned by the relevant // user. continue; } - } if (!isset($child[200][$sccs]) || in_array('VEVENT', $child[200][$sccs]->getValue())) { // Either there is no supported-calendar-component-set @@ -271,82 +262,70 @@ class Plugin extends ServerPlugin { return new LocalHref($child['href']); } } - }); // The server currently reports every principal to be of type // 'INDIVIDUAL' - $propFind->handle('{' . self::NS_CALDAV . '}calendar-user-type', function() { - + $propFind->handle('{'.self::NS_CALDAV.'}calendar-user-type', function () { return 'INDIVIDUAL'; - }); - } // Mapping the old property to the new property. - $propFind->handle('{http://calendarserver.org/ns/}calendar-availability', function() use ($propFind, $node) { - - // In case it wasn't clear, the only difference is that we map the + $propFind->handle('{http://calendarserver.org/ns/}calendar-availability', function () use ($propFind, $node) { + // In case it wasn't clear, the only difference is that we map the // old property to a different namespace. - $availProp = '{' . self::NS_CALDAV . '}calendar-availability'; - $subPropFind = new PropFind( + $availProp = '{'.self::NS_CALDAV.'}calendar-availability'; + $subPropFind = new PropFind( $propFind->getPath(), [$availProp] ); - $this->server->getPropertiesByNode( + $this->server->getPropertiesByNode( $subPropFind, $node ); - $propFind->set( + $propFind->set( '{http://calendarserver.org/ns/}calendar-availability', $subPropFind->get($availProp), $subPropFind->getStatus($availProp) ); - }); - } /** * This method is called during property updates. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch) { - + public function propPatch($path, PropPatch $propPatch) + { // Mapping the old property to the new property. - $propPatch->handle('{http://calendarserver.org/ns/}calendar-availability', function($value) use ($path) { - - $availProp = '{' . self::NS_CALDAV . '}calendar-availability'; + $propPatch->handle('{http://calendarserver.org/ns/}calendar-availability', function ($value) use ($path) { + $availProp = '{'.self::NS_CALDAV.'}calendar-availability'; $subPropPatch = new PropPatch([$availProp => $value]); $this->server->emit('propPatch', [$path, $subPropPatch]); $subPropPatch->commit(); return $subPropPatch->getResult()[$availProp]; - }); - } /** * This method is triggered whenever there was a calendar object gets * created or updated. * - * @param RequestInterface $request HTTP request - * @param ResponseInterface $response HTTP Response - * @param VCalendar $vCal Parsed iCalendar object - * @param mixed $calendarPath Path to calendar collection - * @param mixed $modified The iCalendar object has been touched. - * @param mixed $isNew Whether this was a new item or we're updating one - * @return void + * @param RequestInterface $request HTTP request + * @param ResponseInterface $response HTTP Response + * @param VCalendar $vCal Parsed iCalendar object + * @param mixed $calendarPath Path to calendar collection + * @param mixed $modified the iCalendar object has been touched + * @param mixed $isNew Whether this was a new item or we're updating one */ - function calendarObjectChange(RequestInterface $request, ResponseInterface $response, VCalendar $vCal, $calendarPath, &$modified, $isNew) { - + public function calendarObjectChange(RequestInterface $request, ResponseInterface $response, VCalendar $vCal, $calendarPath, &$modified, $isNew) + { if (!$this->scheduleReply($this->server->httpRequest)) { return; } @@ -370,17 +349,15 @@ class Plugin extends ServerPlugin { // Destroy circular references so PHP will GC the object. $oldObj->destroy(); } - } /** * This method is responsible for delivering the ITip message. * * @param ITip\Message $iTipMessage - * @return void */ - function deliver(ITip\Message $iTipMessage) { - + public function deliver(ITip\Message $iTipMessage) + { $this->server->emit('schedule', [$iTipMessage]); if (!$iTipMessage->scheduleStatus) { $iTipMessage->scheduleStatus = '5.2;There was no system capable of delivering the scheduling message'; @@ -391,7 +368,6 @@ class Plugin extends ServerPlugin { if (!$iTipMessage->significantChange && in_array($baseCode, ['3', '5'])) { $iTipMessage->scheduleStatus = null; } - } /** @@ -401,13 +377,14 @@ class Plugin extends ServerPlugin { * cancellations, and organizers get 'DECLINED' statuses. * * @param string $path - * @return void */ - function beforeUnbind($path) { - + public function beforeUnbind($path) + { // FIXME: We shouldn't trigger this functionality when we're issuing a // MOVE. This is a hack. - if ($this->server->httpRequest->getMethod() === 'MOVE') return; + if ('MOVE' === $this->server->httpRequest->getMethod()) { + return; + } $node = $this->server->tree->getNodeForPath($path); @@ -429,7 +406,6 @@ class Plugin extends ServerPlugin { foreach ($messages as $message) { $this->deliver($message); } - } /** @@ -439,10 +415,9 @@ class Plugin extends ServerPlugin { * scheduling object. * * @param ITip\Message $iTipMessage - * @return void */ - function scheduleLocalDelivery(ITip\Message $iTipMessage) { - + public function scheduleLocalDelivery(ITip\Message $iTipMessage) + { $aclPlugin = $this->server->getPlugin('acl'); // Local delivery is not available if the ACL plugin is not loaded. @@ -450,11 +425,12 @@ class Plugin extends ServerPlugin { return; } - $caldavNS = '{' . self::NS_CALDAV . '}'; + $caldavNS = '{'.self::NS_CALDAV.'}'; $principalUri = $aclPlugin->getPrincipalByUri($iTipMessage->recipient); if (!$principalUri) { $iTipMessage->scheduleStatus = '3.7;Could not find principal.'; + return; } @@ -470,9 +446,9 @@ class Plugin extends ServerPlugin { $principalUri, [ '{DAV:}principal-URL', - $caldavNS . 'calendar-home-set', - $caldavNS . 'schedule-inbox-URL', - $caldavNS . 'schedule-default-calendar-URL', + $caldavNS.'calendar-home-set', + $caldavNS.'schedule-inbox-URL', + $caldavNS.'schedule-default-calendar-URL', '{http://sabredav.org/ns}email-address', ] ); @@ -480,31 +456,35 @@ class Plugin extends ServerPlugin { // Re-registering the ACL event $this->server->on('propFind', [$aclPlugin, 'propFind'], 20); - if (!isset($result[$caldavNS . 'schedule-inbox-URL'])) { + if (!isset($result[$caldavNS.'schedule-inbox-URL'])) { $iTipMessage->scheduleStatus = '5.2;Could not find local inbox'; + return; } - if (!isset($result[$caldavNS . 'calendar-home-set'])) { + if (!isset($result[$caldavNS.'calendar-home-set'])) { $iTipMessage->scheduleStatus = '5.2;Could not locate a calendar-home-set'; + return; } - if (!isset($result[$caldavNS . 'schedule-default-calendar-URL'])) { + if (!isset($result[$caldavNS.'schedule-default-calendar-URL'])) { $iTipMessage->scheduleStatus = '5.2;Could not find a schedule-default-calendar-URL property'; + return; } - $calendarPath = $result[$caldavNS . 'schedule-default-calendar-URL']->getHref(); - $homePath = $result[$caldavNS . 'calendar-home-set']->getHref(); - $inboxPath = $result[$caldavNS . 'schedule-inbox-URL']->getHref(); + $calendarPath = $result[$caldavNS.'schedule-default-calendar-URL']->getHref(); + $homePath = $result[$caldavNS.'calendar-home-set']->getHref(); + $inboxPath = $result[$caldavNS.'schedule-inbox-URL']->getHref(); - if ($iTipMessage->method === 'REPLY') { + if ('REPLY' === $iTipMessage->method) { $privilege = 'schedule-deliver-reply'; } else { $privilege = 'schedule-deliver-invite'; } - if (!$aclPlugin->checkPrivileges($inboxPath, $caldavNS . $privilege, DAVACL\Plugin::R_PARENT, false)) { - $iTipMessage->scheduleStatus = '3.8;insufficient privileges: ' . $privilege . ' is required on the recipient schedule inbox.'; + if (!$aclPlugin->checkPrivileges($inboxPath, $caldavNS.$privilege, DAVACL\Plugin::R_PARENT, false)) { + $iTipMessage->scheduleStatus = '3.8;insufficient privileges: '.$privilege.' is required on the recipient schedule inbox.'; + return; } @@ -512,7 +492,7 @@ class Plugin extends ServerPlugin { // the users' calendars. $uid = $iTipMessage->uid; - $newFileName = 'sabredav-' . \Sabre\DAV\UUIDUtil::getUUID() . '.ics'; + $newFileName = 'sabredav-'.\Sabre\DAV\UUIDUtil::getUUID().'.ics'; $home = $this->server->tree->getNodeForPath($homePath); $inbox = $this->server->tree->getNodeForPath($inboxPath); @@ -524,7 +504,7 @@ class Plugin extends ServerPlugin { $result = $home->getCalendarObjectByUID($uid); if ($result) { // There was an existing object, we need to update probably. - $objectPath = $homePath . '/' . $result; + $objectPath = $homePath.'/'.$result; $objectNode = $this->server->tree->getNodeForPath($objectPath); $oldICalendarData = $objectNode->get(); $currentObject = Reader::read($oldICalendarData); @@ -545,6 +525,7 @@ class Plugin extends ServerPlugin { // The implication is that processMessage did not understand the // iTip message. $iTipMessage->scheduleStatus = '5.0;iTip message was not processed by the server, likely because we didn\'t understand it.'; + return; } @@ -558,7 +539,7 @@ class Plugin extends ServerPlugin { // If the message was a reply, we may have to inform other // attendees of this attendees status. Therefore we're shooting off // another itipMessage. - if ($iTipMessage->method === 'REPLY') { + if ('REPLY' === $iTipMessage->method) { $this->processICalendarChange( $oldICalendarData, $newObject, @@ -569,7 +550,6 @@ class Plugin extends ServerPlugin { $objectNode->put($newObject->serialize()); } $iTipMessage->scheduleStatus = '1.2;Message delivered locally'; - } /** @@ -581,54 +561,53 @@ class Plugin extends ServerPlugin { * @param INode $node * @param array $supportedPrivilegeSet */ - function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) { - - $ns = '{' . self::NS_CALDAV . '}'; + public function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) + { + $ns = '{'.self::NS_CALDAV.'}'; if ($node instanceof IOutbox) { - $supportedPrivilegeSet[$ns . 'schedule-send'] = [ - 'abstract' => false, + $supportedPrivilegeSet[$ns.'schedule-send'] = [ + 'abstract' => false, 'aggregates' => [ - $ns . 'schedule-send-invite' => [ - 'abstract' => false, + $ns.'schedule-send-invite' => [ + 'abstract' => false, 'aggregates' => [], ], - $ns . 'schedule-send-reply' => [ - 'abstract' => false, + $ns.'schedule-send-reply' => [ + 'abstract' => false, 'aggregates' => [], ], - $ns . 'schedule-send-freebusy' => [ - 'abstract' => false, + $ns.'schedule-send-freebusy' => [ + 'abstract' => false, 'aggregates' => [], ], // Privilege from an earlier scheduling draft, but still // used by some clients. - $ns . 'schedule-post-vevent' => [ - 'abstract' => false, + $ns.'schedule-post-vevent' => [ + 'abstract' => false, 'aggregates' => [], ], - ] + ], ]; } if ($node instanceof IInbox) { - $supportedPrivilegeSet[$ns . 'schedule-deliver'] = [ - 'abstract' => false, + $supportedPrivilegeSet[$ns.'schedule-deliver'] = [ + 'abstract' => false, 'aggregates' => [ - $ns . 'schedule-deliver-invite' => [ - 'abstract' => false, + $ns.'schedule-deliver-invite' => [ + 'abstract' => false, 'aggregates' => [], ], - $ns . 'schedule-deliver-reply' => [ - 'abstract' => false, + $ns.'schedule-deliver-reply' => [ + 'abstract' => false, 'aggregates' => [], ], - $ns . 'schedule-query-freebusy' => [ - 'abstract' => false, + $ns.'schedule-query-freebusy' => [ + 'abstract' => false, 'aggregates' => [], ], - ] + ], ]; } - } /** @@ -642,22 +621,22 @@ class Plugin extends ServerPlugin { * This method may update $newObject to add any status changes. * * @param VCalendar|string $oldObject - * @param VCalendar $newObject - * @param array $addresses - * @param array $ignore Any addresses to not send messages to. - * @param bool $modified A marker to indicate that the original object - * modified by this process. - * @return void + * @param VCalendar $newObject + * @param array $addresses + * @param array $ignore any addresses to not send messages to + * @param bool $modified a marker to indicate that the original object + * modified by this process */ - protected function processICalendarChange($oldObject = null, VCalendar $newObject, array $addresses, array $ignore = [], &$modified = false) { - + protected function processICalendarChange($oldObject = null, VCalendar $newObject, array $addresses, array $ignore = [], &$modified = false) + { $broker = new ITip\Broker(); $messages = $broker->parseEvent($newObject, $addresses, $oldObject); - if ($messages) $modified = true; + if ($messages) { + $modified = true; + } foreach ($messages as $message) { - if (in_array($message->recipient, $ignore)) { continue; } @@ -669,36 +648,32 @@ class Plugin extends ServerPlugin { $newObject->VEVENT->ORGANIZER['SCHEDULE-STATUS'] = $message->getScheduleStatus(); } unset($newObject->VEVENT->ORGANIZER['SCHEDULE-FORCE-SEND']); - } else { - - if (isset($newObject->VEVENT->ATTENDEE)) foreach ($newObject->VEVENT->ATTENDEE as $attendee) { - - if ($attendee->getNormalizedValue() === $message->recipient) { - if ($message->scheduleStatus) { - $attendee['SCHEDULE-STATUS'] = $message->getScheduleStatus(); + if (isset($newObject->VEVENT->ATTENDEE)) { + foreach ($newObject->VEVENT->ATTENDEE as $attendee) { + if ($attendee->getNormalizedValue() === $message->recipient) { + if ($message->scheduleStatus) { + $attendee['SCHEDULE-STATUS'] = $message->getScheduleStatus(); + } + unset($attendee['SCHEDULE-FORCE-SEND']); + break; } - unset($attendee['SCHEDULE-FORCE-SEND']); - break; } - } - } - } - } /** * Returns a list of addresses that are associated with a principal. * * @param string $principal + * * @return array */ - protected function getAddressesForPrincipal($principal) { - - $CUAS = '{' . self::NS_CALDAV . '}calendar-user-address-set'; + protected function getAddressesForPrincipal($principal) + { + $CUAS = '{'.self::NS_CALDAV.'}calendar-user-address-set'; $properties = $this->server->getProperties( $principal, @@ -707,12 +682,12 @@ class Plugin extends ServerPlugin { // If we can't find this information, we'll stop processing if (!isset($properties[$CUAS])) { - return; + return []; } $addresses = $properties[$CUAS]->getHrefs(); - return $addresses; + return $addresses; } /** @@ -726,20 +701,19 @@ class Plugin extends ServerPlugin { * extensions, but iCal depends on a feature from that spec, so we * implement it. * - * @param IOutbox $outboxNode - * @param RequestInterface $request + * @param IOutbox $outboxNode + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function outboxRequest(IOutbox $outboxNode, RequestInterface $request, ResponseInterface $response) { - + public function outboxRequest(IOutbox $outboxNode, RequestInterface $request, ResponseInterface $response) + { $outboxPath = $request->getPath(); // Parsing the request body try { $vObject = VObject\Reader::read($request->getBody()); } catch (VObject\ParseException $e) { - throw new BadRequest('The request body must be a valid iCalendar object. Parse error: ' . $e->getMessage()); + throw new BadRequest('The request body must be a valid iCalendar object. Parse error: '.$e->getMessage()); } // The incoming iCalendar object must have a METHOD property, and a @@ -747,7 +721,7 @@ class Plugin extends ServerPlugin { // this is. $componentType = null; foreach ($vObject->getComponents() as $component) { - if ($component->name !== 'VTIMEZONE') { + if ('VTIMEZONE' !== $component->name) { $componentType = $component->name; break; } @@ -757,7 +731,7 @@ class Plugin extends ServerPlugin { } // Validating the METHOD - $method = strtoupper((string)$vObject->METHOD); + $method = strtoupper((string) $vObject->METHOD); if (!$method) { throw new BadRequest('A METHOD property must be specified in iTIP messages'); } @@ -768,46 +742,42 @@ class Plugin extends ServerPlugin { $acl = $this->server->getPlugin('acl'); - if ($componentType === 'VFREEBUSY' && $method === 'REQUEST') { - - $acl && $acl->checkPrivileges($outboxPath, '{' . self::NS_CALDAV . '}schedule-send-freebusy'); + if ('VFREEBUSY' === $componentType && 'REQUEST' === $method) { + $acl && $acl->checkPrivileges($outboxPath, '{'.self::NS_CALDAV.'}schedule-send-freebusy'); $this->handleFreeBusyRequest($outboxNode, $vObject, $request, $response); // Destroy circular references so PHP can GC the object. $vObject->destroy(); unset($vObject); - } else { - throw new NotImplemented('We only support VFREEBUSY (REQUEST) on this endpoint'); - } - } /** * This method is responsible for parsing a free-busy query request and * returning it's result. * - * @param IOutbox $outbox + * @param IOutbox $outbox * @param VObject\Component $vObject - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return string */ - protected function handleFreeBusyRequest(IOutbox $outbox, VObject\Component $vObject, RequestInterface $request, ResponseInterface $response) { - + protected function handleFreeBusyRequest(IOutbox $outbox, VObject\Component $vObject, RequestInterface $request, ResponseInterface $response) + { $vFreeBusy = $vObject->VFREEBUSY; $organizer = $vFreeBusy->ORGANIZER; - $organizer = (string)$organizer; + $organizer = (string) $organizer; // Validating if the organizer matches the owner of the inbox. $owner = $outbox->getOwner(); - $caldavNS = '{' . self::NS_CALDAV . '}'; + $caldavNS = '{'.self::NS_CALDAV.'}'; - $uas = $caldavNS . 'calendar-user-address-set'; + $uas = $caldavNS.'calendar-user-address-set'; $props = $this->server->getProperties($owner, [$uas]); if (empty($props[$uas]) || !in_array($organizer, $props[$uas]->getHrefs())) { @@ -820,10 +790,9 @@ class Plugin extends ServerPlugin { $attendees = []; foreach ($vFreeBusy->ATTENDEE as $attendee) { - $attendees[] = (string)$attendee; + $attendees[] = (string) $attendee; } - if (!isset($vFreeBusy->DTSTART) || !isset($vFreeBusy->DTEND)) { throw new BadRequest('DTSTART and DTEND must both be specified'); } @@ -840,9 +809,7 @@ class Plugin extends ServerPlugin { $dom->formatOutput = true; $scheduleResponse = $dom->createElement('cal:schedule-response'); foreach ($this->server->xml->namespaceMap as $namespace => $prefix) { - - $scheduleResponse->setAttribute('xmlns:' . $prefix, $namespace); - + $scheduleResponse->setAttribute('xmlns:'.$prefix, $namespace); } $dom->appendChild($scheduleResponse); @@ -861,11 +828,9 @@ class Plugin extends ServerPlugin { $xresponse->appendChild($reqStatus); if (isset($result['calendar-data'])) { - $calendardata = $dom->createElement('cal:calendar-data'); $calendardata->appendChild($dom->createTextNode(str_replace("\r\n", "\n", $result['calendar-data']->serialize()))); $xresponse->appendChild($calendardata); - } $scheduleResponse->appendChild($xresponse); } @@ -873,12 +838,11 @@ class Plugin extends ServerPlugin { $response->setStatus(200); $response->setHeader('Content-Type', 'application/xml'); $response->setBody($dom->saveXML()); - } /** * Returns free-busy information for a specific address. The returned - * data is an array containing the following properties: + * data is an array containing the following properties:. * * calendar-data : A VFREEBUSY VObject * request-status : an iTip status code. @@ -888,54 +852,56 @@ class Plugin extends ServerPlugin { * * 2.0;description * * 3.7;description * - * @param string $email address + * @param string $email address * @param \DateTimeInterface $start * @param \DateTimeInterface $end - * @param VObject\Component $request + * @param VObject\Component $request + * * @return array */ - protected function getFreeBusyForEmail($email, \DateTimeInterface $start, \DateTimeInterface $end, VObject\Component $request) { - - $caldavNS = '{' . self::NS_CALDAV . '}'; + protected function getFreeBusyForEmail($email, \DateTimeInterface $start, \DateTimeInterface $end, VObject\Component $request) + { + $caldavNS = '{'.self::NS_CALDAV.'}'; $aclPlugin = $this->server->getPlugin('acl'); - if (substr($email, 0, 7) === 'mailto:') $email = substr($email, 7); + if ('mailto:' === substr($email, 0, 7)) { + $email = substr($email, 7); + } $result = $aclPlugin->principalSearch( ['{http://sabredav.org/ns}email-address' => $email], [ '{DAV:}principal-URL', - $caldavNS . 'calendar-home-set', - $caldavNS . 'schedule-inbox-URL', + $caldavNS.'calendar-home-set', + $caldavNS.'schedule-inbox-URL', '{http://sabredav.org/ns}email-address', - ] ); if (!count($result)) { return [ 'request-status' => '3.7;Could not find principal', - 'href' => 'mailto:' . $email, + 'href' => 'mailto:'.$email, ]; } - if (!isset($result[0][200][$caldavNS . 'calendar-home-set'])) { + if (!isset($result[0][200][$caldavNS.'calendar-home-set'])) { return [ 'request-status' => '3.7;No calendar-home-set property found', - 'href' => 'mailto:' . $email, + 'href' => 'mailto:'.$email, ]; } - if (!isset($result[0][200][$caldavNS . 'schedule-inbox-URL'])) { + if (!isset($result[0][200][$caldavNS.'schedule-inbox-URL'])) { return [ 'request-status' => '3.7;No schedule-inbox-URL property found', - 'href' => 'mailto:' . $email, + 'href' => 'mailto:'.$email, ]; } - $homeSet = $result[0][200][$caldavNS . 'calendar-home-set']->getHref(); - $inboxUrl = $result[0][200][$caldavNS . 'schedule-inbox-URL']->getHref(); + $homeSet = $result[0][200][$caldavNS.'calendar-home-set']->getHref(); + $inboxUrl = $result[0][200][$caldavNS.'schedule-inbox-URL']->getHref(); // Do we have permission? - $aclPlugin->checkPrivileges($inboxUrl, $caldavNS . 'schedule-query-freebusy'); + $aclPlugin->checkPrivileges($inboxUrl, $caldavNS.'schedule-query-freebusy'); // Grabbing the calendar list $objects = []; @@ -946,11 +912,11 @@ class Plugin extends ServerPlugin { continue; } - $sct = $caldavNS . 'schedule-calendar-transp'; - $ctz = $caldavNS . 'calendar-timezone'; + $sct = $caldavNS.'schedule-calendar-transp'; + $ctz = $caldavNS.'calendar-timezone'; $props = $node->getProperties([$sct, $ctz]); - if (isset($props[$sct]) && $props[$sct]->getValue() == ScheduleCalendarTransp::TRANSPARENT) { + if (isset($props[$sct]) && ScheduleCalendarTransp::TRANSPARENT == $props[$sct]->getValue()) { // If a calendar is marked as 'transparent', it means we must // ignore it for free-busy purposes. continue; @@ -962,41 +928,40 @@ class Plugin extends ServerPlugin { // Destroy circular references so PHP can garbage collect the object. $vtimezoneObj->destroy(); - } // Getting the list of object uris within the time-range $urls = $node->calendarQuery([ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => $start, - 'end' => $end, + 'end' => $end, ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]); - $calObjects = array_map(function($url) use ($node) { + $calObjects = array_map(function ($url) use ($node) { $obj = $node->getChild($url)->get(); + return $obj; }, $urls); $objects = array_merge($objects, $calObjects); - } $inboxProps = $this->server->getProperties( $inboxUrl, - $caldavNS . 'calendar-availability' + $caldavNS.'calendar-availability' ); $vcalendar = new VObject\Component\VCalendar(); @@ -1011,21 +976,21 @@ class Plugin extends ServerPlugin { if ($inboxProps) { $generator->setVAvailability( VObject\Reader::read( - $inboxProps[$caldavNS . 'calendar-availability'] + $inboxProps[$caldavNS.'calendar-availability'] ) ); } $result = $generator->getResult(); - $vcalendar->VFREEBUSY->ATTENDEE = 'mailto:' . $email; - $vcalendar->VFREEBUSY->UID = (string)$request->VFREEBUSY->UID; + $vcalendar->VFREEBUSY->ATTENDEE = 'mailto:'.$email; + $vcalendar->VFREEBUSY->UID = (string) $request->VFREEBUSY->UID; $vcalendar->VFREEBUSY->ORGANIZER = clone $request->VFREEBUSY->ORGANIZER; return [ - 'calendar-data' => $result, + 'calendar-data' => $result, 'request-status' => '2.0;Success', - 'href' => 'mailto:' . $email, + 'href' => 'mailto:'.$email, ]; } @@ -1034,13 +999,14 @@ class Plugin extends ServerPlugin { * and returns false if it's 'F', otherwise true. * * @param RequestInterface $request + * * @return bool */ - private function scheduleReply(RequestInterface $request) { - + private function scheduleReply(RequestInterface $request) + { $scheduleReply = $request->getHeader('Schedule-Reply'); - return $scheduleReply !== 'F'; + return 'F' !== $scheduleReply; } /** @@ -1054,13 +1020,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds calendar-auto-schedule, as defined in rfc6638', - 'link' => 'http://sabre.io/dav/scheduling/', + 'link' => 'http://sabre.io/dav/scheduling/', ]; - } } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php b/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php index 0cd05a965..d34c92327 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php @@ -1,35 +1,23 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; use Sabre\CalDAV\Backend; use Sabre\DAV\Exception\MethodNotAllowed; /** - * The SchedulingObject represents a scheduling object in the Inbox collection + * The SchedulingObject represents a scheduling object in the Inbox collection. * * @author Brett (https://github.com/bretten) * @license http://sabre.io/license/ Modified BSD License * @copyright Copyright (C) fruux GmbH (https://fruux.com/) */ -class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements ISchedulingObject { - - /** - /* The CalDAV backend - * - * @var Backend\SchedulingSupport - */ - protected $caldavBackend; - - /** - * Array with information about this SchedulingObject - * - * @var array - */ - protected $objectData; - +class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements ISchedulingObject +{ /** - * Constructor + * Constructor. * * The following properties may be passed within $objectData: * @@ -43,73 +31,65 @@ class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements IScheduli * * acl - (optional) Use this to override the default ACL for the node. * * @param Backend\SchedulingSupport $caldavBackend - * @param array $objectData + * @param array $objectData */ - function __construct(Backend\SchedulingSupport $caldavBackend, array $objectData) { - - $this->caldavBackend = $caldavBackend; + public function __construct(Backend\SchedulingSupport $caldavBackend, array $objectData) + { + parent::__construct($caldavBackend, [], $objectData); if (!isset($objectData['uri'])) { throw new \InvalidArgumentException('The objectData argument must contain an \'uri\' property'); } - - $this->objectData = $objectData; - } /** - * Returns the ICalendar-formatted object + * Returns the ICalendar-formatted object. * * @return string */ - function get() { - + public function get() + { // Pre-populating the 'calendardata' is optional, if we don't have it // already we fetch it from the backend. if (!isset($this->objectData['calendardata'])) { $this->objectData = $this->caldavBackend->getSchedulingObject($this->objectData['principaluri'], $this->objectData['uri']); } - return $this->objectData['calendardata']; + return $this->objectData['calendardata']; } /** - * Updates the ICalendar-formatted object + * Updates the ICalendar-formatted object. * * @param string|resource $calendarData + * * @return string */ - function put($calendarData) { - + public function put($calendarData) + { throw new MethodNotAllowed('Updating scheduling objects is not supported'); - } /** - * Deletes the scheduling message - * - * @return void + * Deletes the scheduling message. */ - function delete() { - + public function delete() + { $this->caldavBackend->deleteSchedulingObject($this->objectData['principaluri'], $this->objectData['uri']); - } /** - * 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->objectData['principaluri']; - } - /** * Returns a list of ACE's for this node. * @@ -122,8 +102,8 @@ class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements IScheduli * * @return array */ - function getACL() { - + public function getACL() + { // An alternative acl may be specified in the object data. // @@ -140,16 +120,14 @@ class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements IScheduli ], [ 'privilege' => '{DAV:}all', - 'principal' => $this->objectData['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->objectData['principaluri'].'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->objectData['principaluri'] . '/calendar-proxy-read', + 'principal' => $this->objectData['principaluri'].'/calendar-proxy-read', 'protected' => true, ], ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php b/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php index 7a77616e3..818392f57 100644 --- a/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php +++ b/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV\Sharing\Plugin as SPlugin; @@ -11,8 +13,8 @@ use Sabre\DAV\Sharing\Plugin as SPlugin; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SharedCalendar extends Calendar implements ISharedCalendar { - +class SharedCalendar extends Calendar implements ISharedCalendar +{ /** * Returns the 'access level' for the instance of this shared resource. * @@ -21,10 +23,9 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * * @return int */ - function getShareAccess() { - + public function getShareAccess() + { return isset($this->calendarInfo['share-access']) ? $this->calendarInfo['share-access'] : SPlugin::ACCESS_NOTSHARED; - } /** @@ -38,10 +39,9 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * * @return string */ - function getShareResourceUri() { - + public function getShareResourceUri() + { return $this->calendarInfo['share-resource-uri']; - } /** @@ -50,12 +50,10 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * Every item must be a Sharee object. * * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees - * @return void */ - function updateInvites(array $sharees) { - + public function updateInvites(array $sharees) + { $this->caldavBackend->updateInvites($this->calendarInfo['id'], $sharees); - } /** @@ -74,10 +72,9 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * * @return \Sabre\DAV\Xml\Element\Sharee[] */ - function getInvites() { - + public function getInvites() + { return $this->caldavBackend->getInvites($this->calendarInfo['id']); - } /** @@ -87,12 +84,10 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * subscribable calendar. * * @param bool $value - * @return void */ - function setPublishStatus($value) { - + public function setPublishStatus($value) + { $this->caldavBackend->setPublishStatus($this->calendarInfo['id'], $value); - } /** @@ -107,13 +102,13 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * * @return array */ - function getACL() { - + public function getACL() + { $acl = []; switch ($this->getShareAccess()) { - case SPlugin::ACCESS_NOTSHARED : - case SPlugin::ACCESS_SHAREDOWNER : + case SPlugin::ACCESS_NOTSHARED: + case SPlugin::ACCESS_SHAREDOWNER: $acl[] = [ 'privilege' => '{DAV:}share', 'principal' => $this->calendarInfo['principaluri'], @@ -121,11 +116,11 @@ class SharedCalendar extends Calendar implements ISharedCalendar { ]; $acl[] = [ 'privilege' => '{DAV:}share', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ]; - // No break intentional! - case SPlugin::ACCESS_READWRITE : + // no break intentional! + case SPlugin::ACCESS_READWRITE: $acl[] = [ 'privilege' => '{DAV:}write', 'principal' => $this->calendarInfo['principaluri'], @@ -133,11 +128,11 @@ class SharedCalendar extends Calendar implements ISharedCalendar { ]; $acl[] = [ 'privilege' => '{DAV:}write', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ]; - // No break intentional! - case SPlugin::ACCESS_READ : + // no break intentional! + case SPlugin::ACCESS_READ: $acl[] = [ 'privilege' => '{DAV:}write-properties', 'principal' => $this->calendarInfo['principaluri'], @@ -145,7 +140,7 @@ class SharedCalendar extends Calendar implements ISharedCalendar { ]; $acl[] = [ 'privilege' => '{DAV:}write-properties', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ]; $acl[] = [ @@ -155,26 +150,25 @@ class SharedCalendar extends Calendar implements ISharedCalendar { ]; $acl[] = [ 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read', 'protected' => true, ]; $acl[] = [ 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ]; $acl[] = [ - 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', + 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true, ]; break; } - return $acl; + return $acl; } - /** * This method returns the ACL's for calendar objects in this calendar. * The result of this method automatically gets passed to the @@ -182,15 +176,13 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * * @return array */ - function getChildACL() { - + public function getChildACL() + { $acl = []; switch ($this->getShareAccess()) { - case SPlugin::ACCESS_NOTSHARED : - // No break intentional - case SPlugin::ACCESS_SHAREDOWNER : - // No break intentional + case SPlugin::ACCESS_NOTSHARED: + case SPlugin::ACCESS_SHAREDOWNER: case SPlugin::ACCESS_READWRITE: $acl[] = [ 'privilege' => '{DAV:}write', @@ -199,10 +191,10 @@ class SharedCalendar extends Calendar implements ISharedCalendar { ]; $acl[] = [ 'privilege' => '{DAV:}write', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ]; - // No break intentional + // no break intentional case SPlugin::ACCESS_READ: $acl[] = [ 'privilege' => '{DAV:}read', @@ -211,19 +203,17 @@ class SharedCalendar extends Calendar implements ISharedCalendar { ]; $acl[] = [ 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ]; $acl[] = [ 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read', 'protected' => true, ]; break; } return $acl; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php b/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php index 5cce79678..be8c46a9e 100644 --- a/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php +++ b/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; @@ -23,8 +25,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SharingPlugin extends DAV\ServerPlugin { - +class SharingPlugin extends DAV\ServerPlugin +{ /** * Reference to SabreDAV server object. * @@ -40,10 +42,9 @@ class SharingPlugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['calendarserver-sharing']; - } /** @@ -54,10 +55,9 @@ class SharingPlugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'caldav-sharing'; - } /** @@ -69,10 +69,9 @@ class SharingPlugin extends DAV\ServerPlugin { * This method should set up the required event subscriptions. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; if (is_null($this->server->getPlugin('sharing'))) { @@ -81,19 +80,18 @@ class SharingPlugin extends DAV\ServerPlugin { array_push( $this->server->protectedProperties, - '{' . Plugin::NS_CALENDARSERVER . '}invite', - '{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes', - '{' . Plugin::NS_CALENDARSERVER . '}shared-url' + '{'.Plugin::NS_CALENDARSERVER.'}invite', + '{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes', + '{'.Plugin::NS_CALENDARSERVER.'}shared-url' ); - $this->server->xml->elementMap['{' . Plugin::NS_CALENDARSERVER . '}share'] = 'Sabre\\CalDAV\\Xml\\Request\\Share'; - $this->server->xml->elementMap['{' . Plugin::NS_CALENDARSERVER . '}invite-reply'] = 'Sabre\\CalDAV\\Xml\\Request\\InviteReply'; - - $this->server->on('propFind', [$this, 'propFindEarly']); - $this->server->on('propFind', [$this, 'propFindLate'], 150); - $this->server->on('propPatch', [$this, 'propPatch'], 40); - $this->server->on('method:POST', [$this, 'httpPost']); + $this->server->xml->elementMap['{'.Plugin::NS_CALENDARSERVER.'}share'] = 'Sabre\\CalDAV\\Xml\\Request\\Share'; + $this->server->xml->elementMap['{'.Plugin::NS_CALENDARSERVER.'}invite-reply'] = 'Sabre\\CalDAV\\Xml\\Request\\InviteReply'; + $this->server->on('propFind', [$this, 'propFindEarly']); + $this->server->on('propFind', [$this, 'propFindLate'], 150); + $this->server->on('propPatch', [$this, 'propPatch'], 40); + $this->server->on('method:POST', [$this, 'httpPost']); } /** @@ -103,47 +101,17 @@ class SharingPlugin extends DAV\ServerPlugin { * This allows us to inject any properties early. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFindEarly(DAV\PropFind $propFind, DAV\INode $node) { - + public function propFindEarly(DAV\PropFind $propFind, DAV\INode $node) + { if ($node instanceof ISharedCalendar) { - - $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}invite', function() use ($node) { - - // Fetching owner information - $props = $this->server->getPropertiesForPath($node->getOwner(), [ - '{http://sabredav.org/ns}email-address', - '{DAV:}displayname', - ], 0); - - $ownerInfo = [ - 'href' => $node->getOwner(), - ]; - - if (isset($props[0][200])) { - - // We're mapping the internal webdav properties to the - // elements caldav-sharing expects. - if (isset($props[0][200]['{http://sabredav.org/ns}email-address'])) { - $ownerInfo['href'] = 'mailto:' . $props[0][200]['{http://sabredav.org/ns}email-address']; - } - if (isset($props[0][200]['{DAV:}displayname'])) { - $ownerInfo['commonName'] = $props[0][200]['{DAV:}displayname']; - } - - } - + $propFind->handle('{'.Plugin::NS_CALENDARSERVER.'}invite', function () use ($node) { return new Xml\Property\Invite( - $node->getInvites(), - $ownerInfo + $node->getInvites() ); - }); - } - } /** @@ -152,31 +120,27 @@ class SharingPlugin extends DAV\ServerPlugin { * have been shared. * * @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 ($node instanceof ISharedCalendar) { $shareAccess = $node->getShareAccess(); if ($rt = $propFind->get('{DAV:}resourcetype')) { switch ($shareAccess) { - case \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER : - $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared-owner'); + case \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER: + $rt->add('{'.Plugin::NS_CALENDARSERVER.'}shared-owner'); break; - case \Sabre\DAV\Sharing\Plugin::ACCESS_READ : - case \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE : - $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared'); + case \Sabre\DAV\Sharing\Plugin::ACCESS_READ: + case \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE: + $rt->add('{'.Plugin::NS_CALENDARSERVER.'}shared'); break; - } } - $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes', function() { + $propFind->handle('{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes', function () { return new Xml\Property\AllowedSharingModes(true, false); }); - } - } /** @@ -190,20 +154,21 @@ class SharingPlugin extends DAV\ServerPlugin { * Even though this is no longer in the current spec, we keep this around * because OS X 10.7 may still make use of this feature. * - * @param string $path + * @param string $path * @param DAV\PropPatch $propPatch - * @return void */ - function propPatch($path, DAV\PropPatch $propPatch) { - + public function propPatch($path, DAV\PropPatch $propPatch) + { $node = $this->server->tree->getNodeForPath($path); - if (!$node instanceof ISharedCalendar) + if (!$node instanceof ISharedCalendar) { return; + } - if ($node->getShareAccess() === \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER || $node->getShareAccess() === \Sabre\DAV\Sharing\Plugin::ACCESS_NOTSHARED) { - - $propPatch->handle('{DAV:}resourcetype', function($value) use ($node) { - if ($value->is('{' . Plugin::NS_CALENDARSERVER . '}shared-owner')) return false; + if (\Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER === $node->getShareAccess() || \Sabre\DAV\Sharing\Plugin::ACCESS_NOTSHARED === $node->getShareAccess()) { + $propPatch->handle('{DAV:}resourcetype', function ($value) use ($node) { + if ($value->is('{'.Plugin::NS_CALENDARSERVER.'}shared-owner')) { + return false; + } $shares = $node->getInvites(); foreach ($shares as $share) { $share->access = DAV\Sharing\Plugin::ACCESS_NOACCESS; @@ -211,28 +176,30 @@ class SharingPlugin extends DAV\ServerPlugin { $node->updateInvites($shares); return true; - }); - } - } /** * We intercept this to handle POST requests on calendars. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return null|bool + * + * @return bool|null */ - function httpPost(RequestInterface $request, ResponseInterface $response) { - + public function httpPost(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); // Only handling xml $contentType = $request->getHeader('Content-Type'); - if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) + if (null === $contentType) { return; + } + if (false === strpos($contentType, 'application/xml') && false === strpos($contentType, 'text/xml')) { + return; + } // Making sure the node exists try { @@ -255,10 +222,9 @@ class SharingPlugin extends DAV\ServerPlugin { $message = $this->server->xml->parse($requestBody, $request->getUrl(), $documentType); switch ($documentType) { - // Both the DAV:share-resource and CALENDARSERVER:share requests // behave identically. - case '{' . Plugin::NS_CALENDARSERVER . '}share' : + case '{'.Plugin::NS_CALENDARSERVER.'}share': $sharingPlugin = $this->server->getPlugin('sharing'); $sharingPlugin->shareResource($path, $message->sharees); @@ -273,7 +239,7 @@ class SharingPlugin extends DAV\ServerPlugin { // The invite-reply document is sent when the user replies to an // invitation of a calendar share. - case '{' . Plugin::NS_CALENDARSERVER . '}invite-reply' : + case '{'.Plugin::NS_CALENDARSERVER.'}invite-reply': // This only works on the calendar-home-root node. if (!$node instanceof CalendarHome) { @@ -304,20 +270,20 @@ class SharingPlugin extends DAV\ServerPlugin { if ($url) { $writer = $this->server->xml->getWriter(); + $writer->contextUri = $request->getUrl(); $writer->openMemory(); $writer->startDocument(); - $writer->startElement('{' . Plugin::NS_CALENDARSERVER . '}shared-as'); + $writer->startElement('{'.Plugin::NS_CALENDARSERVER.'}shared-as'); $writer->write(new LocalHref($url)); $writer->endElement(); $response->setHeader('Content-Type', 'application/xml'); $response->setBody($writer->outputMemory()); - } // Breaking the event chain return false; - case '{' . Plugin::NS_CALENDARSERVER . '}publish-calendar' : + case '{'.Plugin::NS_CALENDARSERVER.'}publish-calendar': // We can only deal with IShareableCalendar objects if (!$node instanceof ISharedCalendar) { @@ -345,7 +311,7 @@ class SharingPlugin extends DAV\ServerPlugin { // Breaking the event chain return false; - case '{' . Plugin::NS_CALENDARSERVER . '}unpublish-calendar' : + case '{'.Plugin::NS_CALENDARSERVER.'}unpublish-calendar': // We can only deal with IShareableCalendar objects if (!$node instanceof ISharedCalendar) { @@ -371,11 +337,7 @@ class SharingPlugin extends DAV\ServerPlugin { // Breaking the event chain return false; - } - - - } /** @@ -389,13 +351,12 @@ class SharingPlugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds support for caldav-sharing.', - 'link' => 'http://sabre.io/dav/caldav-sharing/', + 'link' => 'http://sabre.io/dav/caldav-sharing/', ]; - } } diff --git a/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php b/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php index 7ba259c7b..e83082c52 100644 --- a/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php +++ b/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Subscriptions; use Sabre\DAV\ICollection; use Sabre\DAV\IProperties; /** - * ISubscription + * ISubscription. * * Nodes implementing this interface represent calendar subscriptions. * @@ -34,7 +36,6 @@ use Sabre\DAV\IProperties; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ISubscription extends ICollection, IProperties { - - +interface ISubscription extends ICollection, IProperties +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php index 877d96c6c..238866894 100644 --- a/vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php +++ b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Subscriptions; use Sabre\DAV\INode; @@ -17,8 +19,8 @@ use Sabre\DAV\ServerPlugin; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ /** * This initializes the plugin. * @@ -28,10 +30,9 @@ class Plugin extends ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $server->resourceTypeMapping['Sabre\\CalDAV\\Subscriptions\\ISubscription'] = '{http://calendarserver.org/ns/}subscribed'; @@ -39,7 +40,6 @@ class Plugin extends ServerPlugin { 'Sabre\\DAV\\Xml\\Property\\Href'; $server->on('propFind', [$this, 'propFind'], 150); - } /** @@ -50,21 +50,19 @@ class Plugin extends ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['calendarserver-subscribed']; - } /** * Triggered after properties have been fetched. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - + public function propFind(PropFind $propFind, INode $node) + { // There's a bunch of properties that must appear as a self-closing // xml-element. This event handler ensures that this will be the case. $props = [ @@ -74,13 +72,10 @@ class Plugin extends ServerPlugin { ]; foreach ($props as $prop) { - - if ($propFind->getStatus($prop) === 200) { + if (200 === $propFind->getStatus($prop)) { $propFind->set($prop, '', 200); } - } - } /** @@ -91,10 +86,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'subscriptions'; - } /** @@ -108,13 +102,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'This plugin allows users to store iCalendar subscriptions in their calendar-home.', - 'link' => null, + 'link' => null, ]; - } } diff --git a/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php index 6a1851ed8..0b0282abe 100644 --- a/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php +++ b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Subscriptions; use Sabre\CalDAV\Backend\SubscriptionSupport; @@ -10,7 +12,7 @@ use Sabre\DAVACL\ACLTrait; use Sabre\DAVACL\IACL; /** - * Subscription Node + * Subscription Node. * * This node represents a subscription. * @@ -18,32 +20,32 @@ use Sabre\DAVACL\IACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Subscription extends Collection implements ISubscription, IACL { - +class Subscription extends Collection implements ISubscription, IACL +{ use ACLTrait; /** - * caldavBackend + * caldavBackend. * * @var SubscriptionSupport */ protected $caldavBackend; /** - * subscriptionInfo + * subscriptionInfo. * * @var array */ protected $subscriptionInfo; /** - * Constructor + * Constructor. * * @param SubscriptionSupport $caldavBackend - * @param array $subscriptionInfo + * @param array $subscriptionInfo */ - function __construct(SubscriptionSupport $caldavBackend, array $subscriptionInfo) { - + public function __construct(SubscriptionSupport $caldavBackend, array $subscriptionInfo) + { $this->caldavBackend = $caldavBackend; $this->subscriptionInfo = $subscriptionInfo; @@ -56,10 +58,9 @@ class Subscription extends Collection implements ISubscription, IACL { foreach ($required as $r) { if (!isset($subscriptionInfo[$r])) { - throw new \InvalidArgumentException('The ' . $r . ' field is required when creating a subscription node'); + throw new \InvalidArgumentException('The '.$r.' field is required when creating a subscription node'); } } - } /** @@ -69,47 +70,41 @@ class Subscription extends Collection implements ISubscription, IACL { * * @return string */ - function getName() { - + public function getName() + { return $this->subscriptionInfo['uri']; - } /** - * Returns the last modification time + * Returns the last modification time. * * @return int */ - function getLastModified() { - + public function getLastModified() + { if (isset($this->subscriptionInfo['lastmodified'])) { return $this->subscriptionInfo['lastmodified']; } - } /** - * Deletes the current node - * - * @return void + * Deletes the current node. */ - function delete() { - + public function delete() + { $this->caldavBackend->deleteSubscription( $this->subscriptionInfo['id'] ); - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return \Sabre\DAV\INode[] */ - function getChildren() { - + public function getChildren() + { return []; - } /** @@ -122,15 +117,13 @@ class Subscription extends Collection implements ISubscription, IACL { * Read the PropPatch documentation for more information. * * @param PropPatch $propPatch - * @return void */ - function propPatch(PropPatch $propPatch) { - + public function propPatch(PropPatch $propPatch) + { return $this->caldavBackend->updateSubscription( $this->subscriptionInfo['id'], $propPatch ); - } /** @@ -146,29 +139,27 @@ class Subscription extends Collection implements ISubscription, IACL { * The Server class will filter out the extra. * * @param array $properties + * * @return array */ - function getProperties($properties) { - + public function getProperties($properties) + { $r = []; foreach ($properties as $prop) { - switch ($prop) { - case '{http://calendarserver.org/ns/}source' : + case '{http://calendarserver.org/ns/}source': $r[$prop] = new Href($this->subscriptionInfo['source']); break; - default : + default: if (array_key_exists($prop, $this->subscriptionInfo)) { $r[$prop] = $this->subscriptionInfo[$prop]; } break; } - } return $r; - } /** @@ -178,10 +169,9 @@ class Subscription extends Collection implements ISubscription, IACL { * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->subscriptionInfo['principaluri']; - } /** @@ -196,8 +186,8 @@ class Subscription extends Collection implements ISubscription, IACL { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ 'privilege' => '{DAV:}all', @@ -206,16 +196,14 @@ class Subscription extends Collection implements ISubscription, IACL { ], [ 'privilege' => '{DAV:}all', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-read', + 'principal' => $this->getOwner().'/calendar-proxy-read', 'protected' => true, - ] + ], ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CalendarData.php b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CalendarData.php index 9669be304..0d53aeda3 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CalendarData.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CalendarData.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Filter; use Sabre\CalDAV\Plugin; @@ -25,8 +27,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class CalendarData implements XmlDeserializable { - +class CalendarData implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -46,24 +48,24 @@ class CalendarData 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/calendar', - 'version' => $reader->getAttribute('version') ?: '2.0', + 'version' => $reader->getAttribute('version') ?: '2.0', ]; - $elems = (array)$reader->parseInnerTree(); + $elems = (array) $reader->parseInnerTree(); foreach ($elems as $elem) { - switch ($elem['name']) { - case '{' . Plugin::NS_CALDAV . '}expand' : + case '{'.Plugin::NS_CALDAV.'}expand': $result['expand'] = [ 'start' => isset($elem['attributes']['start']) ? DateTimeParser::parseDateTime($elem['attributes']['start']) : null, - 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null, + 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null, ]; if (!$result['expand']['start'] || !$result['expand']['end']) { @@ -74,11 +76,8 @@ class CalendarData implements XmlDeserializable { } break; } - } return $result; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CompFilter.php b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CompFilter.php index c21ede66b..832346eea 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CompFilter.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CompFilter.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Filter; use Sabre\CalDAV\Plugin; @@ -22,8 +24,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class CompFilter implements XmlDeserializable { - +class CompFilter implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -43,16 +45,17 @@ class CompFilter implements XmlDeserializable { * 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, - 'comp-filters' => [], - 'prop-filters' => [], - 'time-range' => false, + 'comp-filters' => [], + 'prop-filters' => [], + 'time-range' => false, ]; $att = $reader->parseAttributes(); @@ -60,38 +63,34 @@ class CompFilter implements XmlDeserializable { $elems = $reader->parseInnerTree(); - if (is_array($elems)) foreach ($elems as $elem) { - - switch ($elem['name']) { - - case '{' . Plugin::NS_CALDAV . '}comp-filter' : + if (is_array($elems)) { + foreach ($elems as $elem) { + switch ($elem['name']) { + case '{'.Plugin::NS_CALDAV.'}comp-filter': $result['comp-filters'][] = $elem['value']; break; - case '{' . Plugin::NS_CALDAV . '}prop-filter' : + case '{'.Plugin::NS_CALDAV.'}prop-filter': $result['prop-filters'][] = $elem['value']; break; - case '{' . Plugin::NS_CALDAV . '}is-not-defined' : + case '{'.Plugin::NS_CALDAV.'}is-not-defined': $result['is-not-defined'] = true; break; - case '{' . Plugin::NS_CALDAV . '}time-range' : - if ($result['name'] === 'VCALENDAR') { + case '{'.Plugin::NS_CALDAV.'}time-range': + if ('VCALENDAR' === $result['name']) { throw new BadRequest('You cannot add time-range filters on the VCALENDAR component'); } $result['time-range'] = [ 'start' => isset($elem['attributes']['start']) ? DateTimeParser::parseDateTime($elem['attributes']['start']) : null, - 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null, + 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null, ]; if ($result['time-range']['start'] && $result['time-range']['end'] && $result['time-range']['end'] <= $result['time-range']['start']) { throw new BadRequest('The end-date must be larger than the start-date'); } break; - } - + } } return $result; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/ParamFilter.php b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/ParamFilter.php index bf422cf05..ec9ff753c 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/ParamFilter.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/ParamFilter.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Filter; use Sabre\CalDAV\Plugin; @@ -20,8 +22,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class ParamFilter implements XmlDeserializable { - +class ParamFilter implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -41,14 +43,15 @@ class ParamFilter implements XmlDeserializable { * 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(); @@ -56,27 +59,23 @@ class ParamFilter implements XmlDeserializable { $elems = $reader->parseInnerTree(); - if (is_array($elems)) foreach ($elems as $elem) { - - switch ($elem['name']) { - - case '{' . Plugin::NS_CALDAV . '}is-not-defined' : + if (is_array($elems)) { + foreach ($elems as $elem) { + switch ($elem['name']) { + case '{'.Plugin::NS_CALDAV.'}is-not-defined': $result['is-not-defined'] = true; break; - case '{' . Plugin::NS_CALDAV . '}text-match' : + case '{'.Plugin::NS_CALDAV.'}text-match': $result['text-match'] = [ - 'negate-condition' => isset($elem['attributes']['negate-condition']) && $elem['attributes']['negate-condition'] === 'yes', - 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;ascii-casemap', - 'value' => $elem['value'], + 'negate-condition' => isset($elem['attributes']['negate-condition']) && 'yes' === $elem['attributes']['negate-condition'], + 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;ascii-casemap', + 'value' => $elem['value'], ]; break; - } - + } } return $result; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php index db9207295..f4600574e 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Filter; use Sabre\CalDAV\Plugin; @@ -22,8 +24,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class PropFilter implements XmlDeserializable { - +class PropFilter implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -43,16 +45,17 @@ 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, + 'name' => null, 'is-not-defined' => false, - 'param-filters' => [], - 'text-match' => null, - 'time-range' => false, + 'param-filters' => [], + 'text-match' => null, + 'time-range' => false, ]; $att = $reader->parseAttributes(); @@ -60,39 +63,35 @@ class PropFilter implements XmlDeserializable { $elems = $reader->parseInnerTree(); - if (is_array($elems)) foreach ($elems as $elem) { - - switch ($elem['name']) { - - case '{' . Plugin::NS_CALDAV . '}param-filter' : + if (is_array($elems)) { + foreach ($elems as $elem) { + switch ($elem['name']) { + case '{'.Plugin::NS_CALDAV.'}param-filter': $result['param-filters'][] = $elem['value']; break; - case '{' . Plugin::NS_CALDAV . '}is-not-defined' : + case '{'.Plugin::NS_CALDAV.'}is-not-defined': $result['is-not-defined'] = true; break; - case '{' . Plugin::NS_CALDAV . '}time-range' : + case '{'.Plugin::NS_CALDAV.'}time-range': $result['time-range'] = [ 'start' => isset($elem['attributes']['start']) ? DateTimeParser::parseDateTime($elem['attributes']['start']) : null, - 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null, + 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null, ]; if ($result['time-range']['start'] && $result['time-range']['end'] && $result['time-range']['end'] <= $result['time-range']['start']) { throw new BadRequest('The end-date must be larger than the start-date'); } break; - case '{' . Plugin::NS_CALDAV . '}text-match' : + case '{'.Plugin::NS_CALDAV.'}text-match': $result['text-match'] = [ - 'negate-condition' => isset($elem['attributes']['negate-condition']) && $elem['attributes']['negate-condition'] === 'yes', - 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;ascii-casemap', - 'value' => $elem['value'], + 'negate-condition' => isset($elem['attributes']['negate-condition']) && 'yes' === $elem['attributes']['negate-condition'], + 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;ascii-casemap', + 'value' => $elem['value'], ]; break; - } - + } } return $result; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php index 92a9ac7b7..926656674 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Notification; use Sabre\CalDAV; @@ -17,19 +19,19 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Invite implements NotificationInterface { - +class Invite implements NotificationInterface +{ /** - * A unique id for the message + * A unique id for the message. * * @var string */ protected $id; /** - * Timestamp of the notification + * Timestamp of the notification. * - * @var DateTime + * @var \DateTime */ protected $dtStamp; @@ -63,7 +65,7 @@ class Invite implements NotificationInterface { protected $hostUrl; /** - * Url to the sharer of the calendar + * Url to the sharer of the calendar. * * @var string */ @@ -91,21 +93,21 @@ class Invite implements NotificationInterface { protected $lastName; /** - * A description of the share request + * A description of the share request. * * @var string */ protected $summary; /** - * The Etag for the notification + * The Etag for the notification. * * @var string */ protected $etag; /** - * The list of supported components + * The list of supported components. * * @var CalDAV\Xml\Property\SupportedCalendarComponentSet */ @@ -138,8 +140,8 @@ class Invite implements NotificationInterface { * * @param array $values All the options */ - function __construct(array $values) { - + public function __construct(array $values) + { $required = [ 'id', 'etag', @@ -152,17 +154,16 @@ class Invite implements NotificationInterface { ]; foreach ($required as $item) { if (!isset($values[$item])) { - throw new \InvalidArgumentException($item . ' is a required constructor option'); + throw new \InvalidArgumentException($item.' is a required constructor option'); } } foreach ($values as $key => $value) { if (!property_exists($this, $key)) { - throw new \InvalidArgumentException('Unknown option: ' . $key); + throw new \InvalidArgumentException('Unknown option: '.$key); } $this->$key = $value; } - } /** @@ -182,12 +183,10 @@ class Invite implements NotificationInterface { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - - $writer->writeElement('{' . CalDAV\Plugin::NS_CALENDARSERVER . '}invite-notification'); - + public function xmlSerialize(Writer $writer) + { + $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-notification'); } /** @@ -195,95 +194,90 @@ class Invite implements NotificationInterface { * response body. * * @param Writer $writer - * @return void */ - function xmlSerializeFull(Writer $writer) { + public function xmlSerializeFull(Writer $writer) + { + $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; - $cs = '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}'; + $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); + $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); - $this->dtStamp->setTimezone(new \DateTimezone('GMT')); - $writer->writeElement($cs . 'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); + $writer->startElement($cs.'invite-notification'); - $writer->startElement($cs . 'invite-notification'); - - $writer->writeElement($cs . 'uid', $this->id); + $writer->writeElement($cs.'uid', $this->id); $writer->writeElement('{DAV:}href', $this->href); switch ($this->type) { - - case DAV\Sharing\Plugin::INVITE_ACCEPTED : - $writer->writeElement($cs . 'invite-accepted'); + case DAV\Sharing\Plugin::INVITE_ACCEPTED: + $writer->writeElement($cs.'invite-accepted'); break; - case DAV\Sharing\Plugin::INVITE_NORESPONSE : - $writer->writeElement($cs . 'invite-noresponse'); + case DAV\Sharing\Plugin::INVITE_NORESPONSE: + $writer->writeElement($cs.'invite-noresponse'); break; - } - $writer->writeElement($cs . 'hosturl', [ - '{DAV:}href' => $writer->contextUri . $this->hostUrl + $writer->writeElement($cs.'hosturl', [ + '{DAV:}href' => $writer->contextUri.$this->hostUrl, ]); if ($this->summary) { - $writer->writeElement($cs . 'summary', $this->summary); + $writer->writeElement($cs.'summary', $this->summary); } - $writer->startElement($cs . 'access'); + $writer->startElement($cs.'access'); if ($this->readOnly) { - $writer->writeElement($cs . 'read'); + $writer->writeElement($cs.'read'); } else { - $writer->writeElement($cs . 'read-write'); + $writer->writeElement($cs.'read-write'); } $writer->endElement(); // access - $writer->startElement($cs . 'organizer'); + $writer->startElement($cs.'organizer'); // If the organizer contains a 'mailto:' part, it means it should be // treated as absolute. - if (strtolower(substr($this->organizer, 0, 7)) === 'mailto:') { + if ('mailto:' === strtolower(substr($this->organizer, 0, 7))) { $writer->writeElement('{DAV:}href', $this->organizer); } else { - $writer->writeElement('{DAV:}href', $writer->contextUri . $this->organizer); + $writer->writeElement('{DAV:}href', $writer->contextUri.$this->organizer); } if ($this->commonName) { - $writer->writeElement($cs . 'common-name', $this->commonName); + $writer->writeElement($cs.'common-name', $this->commonName); } if ($this->firstName) { - $writer->writeElement($cs . 'first-name', $this->firstName); + $writer->writeElement($cs.'first-name', $this->firstName); } if ($this->lastName) { - $writer->writeElement($cs . 'last-name', $this->lastName); + $writer->writeElement($cs.'last-name', $this->lastName); } $writer->endElement(); // organizer if ($this->commonName) { - $writer->writeElement($cs . 'organizer-cn', $this->commonName); + $writer->writeElement($cs.'organizer-cn', $this->commonName); } if ($this->firstName) { - $writer->writeElement($cs . 'organizer-first', $this->firstName); + $writer->writeElement($cs.'organizer-first', $this->firstName); } if ($this->lastName) { - $writer->writeElement($cs . 'organizer-last', $this->lastName); + $writer->writeElement($cs.'organizer-last', $this->lastName); } if ($this->supportedComponents) { - $writer->writeElement('{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set', $this->supportedComponents); + $writer->writeElement('{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set', $this->supportedComponents); } $writer->endElement(); // invite-notification - } /** - * Returns a unique id for this notification + * Returns a unique id for this notification. * * This is just the base url. This should generally be some kind of unique * id. * * @return string */ - function getId() { - + public function getId() + { return $this->id; - } /** @@ -293,10 +287,8 @@ class Invite implements NotificationInterface { * * @return string */ - function getETag() { - + public function getETag() + { return $this->etag; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php index f4b10a396..abcbde151 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Notification; use Sabre\CalDAV; @@ -14,19 +16,19 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InviteReply implements NotificationInterface { - +class InviteReply implements NotificationInterface +{ /** - * A unique id for the message + * A unique id for the message. * * @var string */ protected $id; /** - * Timestamp of the notification + * Timestamp of the notification. * - * @var DateTime + * @var \DateTime */ protected $dtStamp; @@ -59,14 +61,14 @@ class InviteReply implements NotificationInterface { protected $hostUrl; /** - * A description of the share request + * A description of the share request. * * @var string */ protected $summary; /** - * Notification Etag + * Notification Etag. * * @var string */ @@ -90,8 +92,8 @@ class InviteReply implements NotificationInterface { * * @param array $values */ - function __construct(array $values) { - + public function __construct(array $values) + { $required = [ 'id', 'etag', @@ -103,17 +105,16 @@ class InviteReply implements NotificationInterface { ]; foreach ($required as $item) { if (!isset($values[$item])) { - throw new \InvalidArgumentException($item . ' is a required constructor option'); + throw new \InvalidArgumentException($item.' is a required constructor option'); } } foreach ($values as $key => $value) { if (!property_exists($this, $key)) { - throw new \InvalidArgumentException('Unknown option: ' . $key); + throw new \InvalidArgumentException('Unknown option: '.$key); } $this->$key = $value; } - } /** @@ -133,12 +134,10 @@ class InviteReply implements NotificationInterface { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - - $writer->writeElement('{' . CalDAV\Plugin::NS_CALENDARSERVER . '}invite-reply'); - + public function xmlSerialize(Writer $writer) + { + $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-reply'); } /** @@ -146,55 +145,50 @@ class InviteReply implements NotificationInterface { * response body. * * @param Writer $writer - * @return void */ - function xmlSerializeFull(Writer $writer) { + public function xmlSerializeFull(Writer $writer) + { + $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; - $cs = '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}'; + $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); + $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); - $this->dtStamp->setTimezone(new \DateTimezone('GMT')); - $writer->writeElement($cs . 'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); + $writer->startElement($cs.'invite-reply'); - $writer->startElement($cs . 'invite-reply'); - - $writer->writeElement($cs . 'uid', $this->id); - $writer->writeElement($cs . 'in-reply-to', $this->inReplyTo); + $writer->writeElement($cs.'uid', $this->id); + $writer->writeElement($cs.'in-reply-to', $this->inReplyTo); $writer->writeElement('{DAV:}href', $this->href); switch ($this->type) { - - case DAV\Sharing\Plugin::INVITE_ACCEPTED : - $writer->writeElement($cs . 'invite-accepted'); + case DAV\Sharing\Plugin::INVITE_ACCEPTED: + $writer->writeElement($cs.'invite-accepted'); break; - case DAV\Sharing\Plugin::INVITE_DECLINED : - $writer->writeElement($cs . 'invite-declined'); + case DAV\Sharing\Plugin::INVITE_DECLINED: + $writer->writeElement($cs.'invite-declined'); break; - } - $writer->writeElement($cs . 'hosturl', [ - '{DAV:}href' => $writer->contextUri . $this->hostUrl + $writer->writeElement($cs.'hosturl', [ + '{DAV:}href' => $writer->contextUri.$this->hostUrl, ]); if ($this->summary) { - $writer->writeElement($cs . 'summary', $this->summary); + $writer->writeElement($cs.'summary', $this->summary); } $writer->endElement(); // invite-reply - } /** - * Returns a unique id for this notification + * Returns a unique id for this notification. * * This is just the base url. This should generally be some kind of unique * id. * * @return string */ - function getId() { - + public function getId() + { return $this->id; - } /** @@ -204,10 +198,8 @@ class InviteReply implements NotificationInterface { * * @return string */ - function getETag() { - + public function getETag() + { return $this->etag; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/NotificationInterface.php b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/NotificationInterface.php index b98f9c888..be7490533 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/NotificationInterface.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/NotificationInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Notification; use Sabre\Xml\Writer; @@ -12,26 +14,25 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface NotificationInterface extends XmlSerializable { - +interface NotificationInterface extends XmlSerializable +{ /** * This method serializes the entire notification, as it is used in the * response body. * * @param Writer $writer - * @return void */ - function xmlSerializeFull(Writer $writer); + public function xmlSerializeFull(Writer $writer); /** - * Returns a unique id for this notification + * Returns a unique id for this notification. * * This is just the base url. This should generally be some kind of unique * id. * * @return string */ - function getId(); + public function getId(); /** * Returns the ETag for this notification. @@ -40,6 +41,5 @@ interface NotificationInterface extends XmlSerializable { * * @return string */ - function getETag(); - + public function getETag(); } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/SystemStatus.php b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/SystemStatus.php index 8c945dd68..3c656df34 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/SystemStatus.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/SystemStatus.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Notification; use Sabre\CalDAV\Plugin; use Sabre\Xml\Writer; /** - * SystemStatus notification + * SystemStatus notification. * * This notification can be used to indicate to the user that the system is * down. @@ -15,14 +17,14 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SystemStatus implements NotificationInterface { - +class SystemStatus implements NotificationInterface +{ const TYPE_LOW = 1; const TYPE_MEDIUM = 2; const TYPE_HIGH = 3; /** - * A unique id + * A unique id. * * @var string */ @@ -50,7 +52,7 @@ class SystemStatus implements NotificationInterface { protected $href; /** - * Notification Etag + * Notification Etag. * * @var string */ @@ -64,18 +66,17 @@ class SystemStatus implements NotificationInterface { * * @param string $id * @param string $etag - * @param int $type + * @param int $type * @param string $description * @param string $href */ - function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) { - + public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) + { $this->id = $id; $this->type = $type; $this->description = $description; $this->href = $href; $this->etag = $etag; - } /** @@ -91,27 +92,25 @@ class SystemStatus implements NotificationInterface { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { switch ($this->type) { - case self::TYPE_LOW : + case self::TYPE_LOW: $type = 'low'; break; - case self::TYPE_MEDIUM : + case self::TYPE_MEDIUM: $type = 'medium'; break; - default : - case self::TYPE_HIGH : + default: + case self::TYPE_HIGH: $type = 'high'; break; } - $writer->startElement('{' . Plugin::NS_CALENDARSERVER . '}systemstatus'); + $writer->startElement('{'.Plugin::NS_CALENDARSERVER.'}systemstatus'); $writer->writeAttribute('type', $type); $writer->endElement(); - } /** @@ -119,51 +118,47 @@ class SystemStatus implements NotificationInterface { * response body. * * @param Writer $writer - * @return void */ - function xmlSerializeFull(Writer $writer) { - - $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; + public function xmlSerializeFull(Writer $writer) + { + $cs = '{'.Plugin::NS_CALENDARSERVER.'}'; switch ($this->type) { - case self::TYPE_LOW : + case self::TYPE_LOW: $type = 'low'; break; - case self::TYPE_MEDIUM : + case self::TYPE_MEDIUM: $type = 'medium'; break; - default : - case self::TYPE_HIGH : + default: + case self::TYPE_HIGH: $type = 'high'; break; } - $writer->startElement($cs . 'systemstatus'); + $writer->startElement($cs.'systemstatus'); $writer->writeAttribute('type', $type); - if ($this->description) { - $writer->writeElement($cs . 'description', $this->description); + $writer->writeElement($cs.'description', $this->description); } if ($this->href) { $writer->writeElement('{DAV:}href', $this->href); } $writer->endElement(); // systemstatus - } /** - * Returns a unique id for this notification + * Returns a unique id for this notification. * * This is just the base url. This should generally be some kind of unique * id. * * @return string */ - function getId() { - + public function getId() + { return $this->id; - } /* @@ -173,10 +168,8 @@ class SystemStatus implements NotificationInterface { * * @return string */ - function getETag() { - + public function getETag() + { return $this->etag; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php index 54e5a116a..224f52c96 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\CalDAV\Plugin; @@ -7,7 +9,7 @@ use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * AllowedSharingModes + * AllowedSharingModes. * * This property encodes the 'allowed-sharing-modes' property, as defined by * the 'caldav-sharing-02' spec, in the http://calendarserver.org/ns/ @@ -18,14 +20,15 @@ use Sabre\Xml\XmlSerializable; * such as VEVENT, VTODO * * @see https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-sharing-02.txt + * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class AllowedSharingModes implements XmlSerializable { - +class AllowedSharingModes implements XmlSerializable +{ /** - * Whether or not a calendar can be shared with another user + * Whether or not a calendar can be shared with another user. * * @var bool */ @@ -39,17 +42,15 @@ class AllowedSharingModes implements XmlSerializable { protected $canBePublished; /** - * Constructor + * Constructor. * * @param bool $canBeShared * @param bool $canBePublished - * @return void */ - function __construct($canBeShared, $canBePublished) { - + public function __construct($canBeShared, $canBePublished) + { $this->canBeShared = $canBeShared; $this->canBePublished = $canBePublished; - } /** @@ -69,19 +70,14 @@ class AllowedSharingModes 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) + { if ($this->canBeShared) { - $writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-shared'); + $writer->writeElement('{'.Plugin::NS_CALENDARSERVER.'}can-be-shared'); } if ($this->canBePublished) { - $writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-published'); + $writer->writeElement('{'.Plugin::NS_CALENDARSERVER.'}can-be-published'); } - } - - - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php index fc6f1d505..6b28d5df2 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * email-address-set property + * email-address-set property. * * This property represents the email-address-set property in the * http://calendarserver.org/ns/ namespace. @@ -17,35 +19,33 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class EmailAddressSet implements XmlSerializable { - +class EmailAddressSet implements XmlSerializable +{ /** - * emails + * emails. * * @var array */ private $emails; /** - * __construct + * __construct. * * @param array $emails */ - function __construct(array $emails) { - + public function __construct(array $emails) + { $this->emails = $emails; - } /** - * Returns the email addresses + * Returns the email addresses. * * @return array */ - function getValue() { - + public function getValue() + { return $this->emails; - } /** @@ -65,16 +65,11 @@ class EmailAddressSet 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->emails as $email) { - $writer->writeElement('{http://calendarserver.org/ns/}email-address', $email); - } - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php index 4f33c464c..db456617c 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\CalDAV\Plugin; @@ -9,19 +11,20 @@ use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * Invite property + * Invite property. * * This property encodes the 'invite' property, as defined by * the 'caldav-sharing-02' spec, in the http://calendarserver.org/ns/ * namespace. * * @see https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-sharing-02.txt + * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Invite implements XmlSerializable { - +class Invite implements XmlSerializable +{ /** * The list of users a calendar has been shared to. * @@ -34,10 +37,9 @@ class Invite implements XmlSerializable { * * @param Sharee[] $sharees */ - function __construct(array $sharees) { - + public function __construct(array $sharees) + { $this->sharees = $sharees; - } /** @@ -45,10 +47,9 @@ class Invite implements XmlSerializable { * * @return array */ - function getValue() { - + public function getValue() + { return $this->sharees; - } /** @@ -68,61 +69,54 @@ class Invite implements XmlSerializable { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - - $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; + public function xmlSerialize(Writer $writer) + { + $cs = '{'.Plugin::NS_CALENDARSERVER.'}'; foreach ($this->sharees as $sharee) { - - if ($sharee->access === DAV\Sharing\Plugin::ACCESS_SHAREDOWNER) { - $writer->startElement($cs . 'organizer'); + if (DAV\Sharing\Plugin::ACCESS_SHAREDOWNER === $sharee->access) { + $writer->startElement($cs.'organizer'); } else { - $writer->startElement($cs . 'user'); + $writer->startElement($cs.'user'); switch ($sharee->inviteStatus) { - case DAV\Sharing\Plugin::INVITE_ACCEPTED : - $writer->writeElement($cs . 'invite-accepted'); + case DAV\Sharing\Plugin::INVITE_ACCEPTED: + $writer->writeElement($cs.'invite-accepted'); break; - case DAV\Sharing\Plugin::INVITE_DECLINED : - $writer->writeElement($cs . 'invite-declined'); + case DAV\Sharing\Plugin::INVITE_DECLINED: + $writer->writeElement($cs.'invite-declined'); break; - case DAV\Sharing\Plugin::INVITE_NORESPONSE : - $writer->writeElement($cs . 'invite-noresponse'); + case DAV\Sharing\Plugin::INVITE_NORESPONSE: + $writer->writeElement($cs.'invite-noresponse'); break; - case DAV\Sharing\Plugin::INVITE_INVALID : - $writer->writeElement($cs . 'invite-invalid'); + case DAV\Sharing\Plugin::INVITE_INVALID: + $writer->writeElement($cs.'invite-invalid'); break; } - $writer->startElement($cs . 'access'); + $writer->startElement($cs.'access'); switch ($sharee->access) { - case DAV\Sharing\Plugin::ACCESS_READWRITE : - $writer->writeElement($cs . 'read-write'); + case DAV\Sharing\Plugin::ACCESS_READWRITE: + $writer->writeElement($cs.'read-write'); break; - case DAV\Sharing\Plugin::ACCESS_READ : - $writer->writeElement($cs . 'read'); + case DAV\Sharing\Plugin::ACCESS_READ: + $writer->writeElement($cs.'read'); break; - } $writer->endElement(); // access - } $href = new DAV\Xml\Property\Href($sharee->href); $href->xmlSerialize($writer); if (isset($sharee->properties['{DAV:}displayname'])) { - $writer->writeElement($cs . 'common-name', $sharee->properties['{DAV:}displayname']); + $writer->writeElement($cs.'common-name', $sharee->properties['{DAV:}displayname']); } if ($sharee->comment) { - $writer->writeElement($cs . 'summary', $sharee->comment); + $writer->writeElement($cs.'summary', $sharee->comment); } $writer->endElement(); // organizer or user - } - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php index 10c20be55..780907169 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\CalDAV\Plugin; @@ -24,41 +26,39 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class ScheduleCalendarTransp implements Element { - +class ScheduleCalendarTransp implements Element +{ const TRANSPARENT = 'transparent'; const OPAQUE = 'opaque'; /** - * value + * value. * * @var string */ protected $value; /** - * Creates the property + * Creates the property. * * @param string $value */ - function __construct($value) { - - if ($value !== self::TRANSPARENT && $value !== self::OPAQUE) { + public function __construct($value) + { + if (self::TRANSPARENT !== $value && self::OPAQUE !== $value) { throw new \InvalidArgumentException('The value must either be specified as "transparent" or "opaque"'); } $this->value = $value; - } /** - * Returns the current value + * Returns the current value. * * @return string */ - function getValue() { - + public function getValue() + { return $this->value; - } /** @@ -78,19 +78,17 @@ class ScheduleCalendarTransp implements Element { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { switch ($this->value) { - case self::TRANSPARENT : - $writer->writeElement('{' . Plugin::NS_CALDAV . '}transparent'); + case self::TRANSPARENT: + $writer->writeElement('{'.Plugin::NS_CALDAV.'}transparent'); break; - case self::OPAQUE : - $writer->writeElement('{' . Plugin::NS_CALDAV . '}opaque'); + case self::OPAQUE: + $writer->writeElement('{'.Plugin::NS_CALDAV.'}opaque'); break; } - } /** @@ -112,10 +110,11 @@ class ScheduleCalendarTransp implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = Deserializer\enum($reader, Plugin::NS_CALDAV); if (in_array('transparent', $elems)) { @@ -123,8 +122,7 @@ class ScheduleCalendarTransp implements Element { } else { $value = self::OPAQUE; } - return new self($value); + return new self($value); } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php index 7fc25c5f0..56fa61b13 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\CalDAV\Plugin; @@ -21,8 +23,8 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedCalendarComponentSet implements Element { - +class SupportedCalendarComponentSet implements Element +{ /** * List of supported components. * @@ -37,21 +39,19 @@ class SupportedCalendarComponentSet implements Element { * * @param array $components */ - function __construct(array $components) { - + public function __construct(array $components) + { $this->components = $components; - } /** - * Returns the list of supported components + * Returns the list of supported components. * * @return array */ - function getValue() { - + public function getValue() + { return $this->components; - } /** @@ -71,18 +71,14 @@ class SupportedCalendarComponentSet implements Element { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->components as $component) { - - $writer->startElement('{' . Plugin::NS_CALDAV . '}comp'); + $writer->startElement('{'.Plugin::NS_CALDAV.'}comp'); $writer->writeAttributes(['name' => $component]); $writer->endElement(); - } - } /** @@ -104,16 +100,17 @@ class SupportedCalendarComponentSet implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree(); $components = []; - foreach ((array)$elems as $elem) { - if ($elem['name'] === '{' . Plugin::NS_CALDAV . '}comp') { + foreach ((array) $elems as $elem) { + if ($elem['name'] === '{'.Plugin::NS_CALDAV.'}comp') { $components[] = $elem['attributes']['name']; } } @@ -123,7 +120,5 @@ class SupportedCalendarComponentSet implements Element { } return new self($components); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarData.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarData.php index d123ba4c0..1c9c4779f 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarData.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarData.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\CalDAV\Plugin; @@ -7,7 +9,7 @@ use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * Supported-calendar-data property + * Supported-calendar-data property. * * This property is a representation of the supported-calendar-data property * in the CalDAV namespace. SabreDAV only has support for text/calendar;2.0 @@ -20,8 +22,8 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedCalendarData implements XmlSerializable { - +class SupportedCalendarData implements XmlSerializable +{ /** * The xmlSerialize method is called during xml writing. * @@ -39,22 +41,19 @@ class SupportedCalendarData implements XmlSerializable { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - - $writer->startElement('{' . Plugin::NS_CALDAV . '}calendar-data'); + public function xmlSerialize(Writer $writer) + { + $writer->startElement('{'.Plugin::NS_CALDAV.'}calendar-data'); $writer->writeAttributes([ 'content-type' => 'text/calendar', - 'version' => '2.0', + 'version' => '2.0', ]); $writer->endElement(); // calendar-data - $writer->startElement('{' . Plugin::NS_CALDAV . '}calendar-data'); + $writer->startElement('{'.Plugin::NS_CALDAV.'}calendar-data'); $writer->writeAttributes([ 'content-type' => 'application/calendar+json', ]); $writer->endElement(); // calendar-data - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCollationSet.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCollationSet.php index af10860d0..b88cd0d92 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCollationSet.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCollationSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\CalDAV\Plugin; @@ -7,7 +9,7 @@ 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 CalDAV namespace. @@ -19,8 +21,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. * @@ -38,20 +40,17 @@ 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) + { $collations = [ 'i;ascii-casemap', 'i;octet', - 'i;unicode-casemap' + 'i;unicode-casemap', ]; foreach ($collations as $collation) { - $writer->writeElement('{' . Plugin::NS_CALDAV . '}supported-collation', $collation); + $writer->writeElement('{'.Plugin::NS_CALDAV.'}supported-collation', $collation); } - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php index 6d3c5d508..8231de6bd 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Request; use Sabre\CalDAV\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 CalendarMultiGetReport implements XmlDeserializable { - +class CalendarMultiGetReport implements XmlDeserializable +{ /** * An array with requested properties. * @@ -80,36 +82,33 @@ class CalendarMultiGetReport 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:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', ]); $newProps = [ - 'hrefs' => [], + '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_CALDAV . '}calendar-data'])) { - $newProps += $elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data']; + if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) { + $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data']; } break; - case '{DAV:}href' : + case '{DAV:}href': $newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']); break; - } - } $obj = new self(); @@ -118,7 +117,5 @@ class CalendarMultiGetReport implements XmlDeserializable { } return $obj; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarQueryReport.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarQueryReport.php index e0b1c7950..e85eccd2d 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarQueryReport.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarQueryReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Request; use Sabre\CalDAV\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 CalendarQueryReport implements XmlDeserializable { - +class CalendarQueryReport implements XmlDeserializable +{ /** * An array with requested properties. * @@ -80,38 +82,39 @@ class CalendarQueryReport 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:caldav}comp-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\CompFilter', - '{urn:ietf:params:xml:ns:caldav}prop-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\PropFilter', - '{urn:ietf:params:xml:ns:caldav}param-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\ParamFilter', + '{urn:ietf:params:xml:ns:caldav}comp-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\CompFilter', + '{urn:ietf:params:xml:ns:caldav}prop-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\PropFilter', + '{urn:ietf:params:xml:ns:caldav}param-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\ParamFilter', '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', ]); $newProps = [ - 'filters' => null, + 'filters' => null, 'properties' => [], ]; - 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_CALDAV . '}calendar-data'])) { - $newProps += $elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data']; + if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) { + $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data']; } break; - case '{' . Plugin::NS_CALDAV . '}filter' : + case '{'.Plugin::NS_CALDAV.'}filter': foreach ($elem['value'] as $subElem) { - if ($subElem['name'] === '{' . Plugin::NS_CALDAV . '}comp-filter') { + if ($subElem['name'] === '{'.Plugin::NS_CALDAV.'}comp-filter') { if (!is_null($newProps['filters'])) { throw new BadRequest('Only one top-level comp-filter may be defined'); } @@ -119,21 +122,18 @@ class CalendarQueryReport implements XmlDeserializable { } } break; - } - } if (is_null($newProps['filters'])) { - throw new BadRequest('The {' . Plugin::NS_CALDAV . '}filter element is required for this request'); + throw new BadRequest('The {'.Plugin::NS_CALDAV.'}filter element is required for this request'); } $obj = new self(); foreach ($newProps as $key => $value) { $obj->$key = $value; } - return $obj; + return $obj; } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php index 0f6c1e074..a4d98a8d4 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Request; use Sabre\CalDAV\Plugin; @@ -9,7 +11,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\XmlDeserializable; /** - * FreeBusyQueryReport + * FreeBusyQueryReport. * * This class parses the {DAV:}free-busy-query REPORT, as defined in: * @@ -19,19 +21,19 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class FreeBusyQueryReport implements XmlDeserializable { - +class FreeBusyQueryReport implements XmlDeserializable +{ /** - * Starttime of report + * Starttime of report. * - * @var DateTime|null + * @var \DateTime|null */ public $start; /** - * End time of report + * End time of report. * - * @var DateTime|null + * @var \DateTime|null */ public $end; @@ -54,22 +56,23 @@ class FreeBusyQueryReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - - $timeRange = '{' . Plugin::NS_CALDAV . '}time-range'; + public static function xmlDeserialize(Reader $reader) + { + $timeRange = '{'.Plugin::NS_CALDAV.'}time-range'; $start = null; $end = null; - foreach ((array)$reader->parseInnerTree([]) as $elem) { - - if ($elem['name'] !== $timeRange) continue; + foreach ((array) $reader->parseInnerTree([]) as $elem) { + if ($elem['name'] !== $timeRange) { + continue; + } $start = empty($elem['attributes']['start']) ?: $elem['attributes']['start']; $end = empty($elem['attributes']['end']) ?: $elem['attributes']['end']; - } if (!$start && !$end) { throw new BadRequest('The freebusy report must have a time-range element'); @@ -85,7 +88,5 @@ class FreeBusyQueryReport implements XmlDeserializable { $result->end = $end; return $result; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php index db32cc6a5..710095bb2 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Request; use Sabre\CalDAV\Plugin; @@ -11,7 +13,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\XmlDeserializable; /** - * Invite-reply POST request parser + * Invite-reply POST request parser. * * This class parses the invite-reply POST request, as defined in: * @@ -21,8 +23,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InviteReply implements XmlDeserializable { - +class InviteReply implements XmlDeserializable +{ /** * The sharee calendar user address. * @@ -40,14 +42,14 @@ class InviteReply implements XmlDeserializable { public $calendarUri; /** - * The id of the invite message that's being responded to + * The id of the invite message that's being responded to. * * @var string */ public $inReplyTo; /** - * An optional message + * An optional message. * * @var string */ @@ -61,22 +63,21 @@ class InviteReply implements XmlDeserializable { public $status; /** - * Constructor + * Constructor. * * @param string $href * @param string $calendarUri * @param string $inReplyTo * @param string $summary - * @param int $status + * @param int $status */ - function __construct($href, $calendarUri, $inReplyTo, $summary, $status) { - + public function __construct($href, $calendarUri, $inReplyTo, $summary, $status) + { $this->href = $href; $this->calendarUri = $calendarUri; $this->inReplyTo = $inReplyTo; $this->summary = $summary; $this->status = $status; - } /** @@ -98,10 +99,11 @@ class InviteReply implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = KeyValue::xmlDeserialize($reader); $href = null; @@ -111,40 +113,35 @@ class InviteReply implements XmlDeserializable { $status = null; foreach ($elems as $name => $value) { - switch ($name) { - - case '{' . Plugin::NS_CALENDARSERVER . '}hosturl' : + case '{'.Plugin::NS_CALENDARSERVER.'}hosturl': foreach ($value as $bla) { - if ($bla['name'] === '{DAV:}href') { + if ('{DAV:}href' === $bla['name']) { $calendarUri = $bla['value']; } } break; - case '{' . Plugin::NS_CALENDARSERVER . '}invite-accepted' : + case '{'.Plugin::NS_CALENDARSERVER.'}invite-accepted': $status = DAV\Sharing\Plugin::INVITE_ACCEPTED; break; - case '{' . Plugin::NS_CALENDARSERVER . '}invite-declined' : + case '{'.Plugin::NS_CALENDARSERVER.'}invite-declined': $status = DAV\Sharing\Plugin::INVITE_DECLINED; break; - case '{' . Plugin::NS_CALENDARSERVER . '}in-reply-to' : + case '{'.Plugin::NS_CALENDARSERVER.'}in-reply-to': $inReplyTo = $value; break; - case '{' . Plugin::NS_CALENDARSERVER . '}summary' : + case '{'.Plugin::NS_CALENDARSERVER.'}summary': $summary = $value; break; - case '{DAV:}href' : + case '{DAV:}href': $href = $value; break; } - } if (is_null($calendarUri)) { throw new BadRequest('The {http://calendarserver.org/ns/}hosturl/{DAV:}href element must exist'); } return new self($href, $calendarUri, $inReplyTo, $summary, $status); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/MkCalendar.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/MkCalendar.php index ce7fafde9..7cad98da5 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/MkCalendar.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/MkCalendar.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Request; use Sabre\Xml\Reader; @@ -16,8 +18,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MkCalendar implements XmlDeserializable { - +class MkCalendar implements XmlDeserializable +{ /** * The list of properties that will be set. * @@ -30,10 +32,9 @@ class MkCalendar implements XmlDeserializable { * * @return array */ - function getProperties() { - + public function getProperties() + { return $this->properties; - } /** @@ -55,10 +56,11 @@ class MkCalendar implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $elementMap = $reader->elementMap; @@ -67,13 +69,11 @@ class MkCalendar implements XmlDeserializable { $elems = $reader->parseInnerTree($elementMap); foreach ($elems as $elem) { - if ($elem['name'] === '{DAV:}set') { + if ('{DAV:}set' === $elem['name']) { $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); } } return $self; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php index e0bd8e0af..60bd579d5 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Request; use Sabre\CalDAV\Plugin; @@ -8,7 +10,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\XmlDeserializable; /** - * Share POST request parser + * Share POST request parser. * * This class parses the share POST request, as defined in: * @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Share implements XmlDeserializable { - +class Share implements XmlDeserializable +{ /** * The list of new people added or updated or removed from the share. * @@ -28,14 +30,13 @@ class Share implements XmlDeserializable { public $sharees = []; /** - * Constructor + * Constructor. * * @param Sharee[] $sharees */ - function __construct(array $sharees) { - + public function __construct(array $sharees) + { $this->sharees = $sharees; - } /** @@ -57,55 +58,52 @@ class Share implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseGetElements([ - '{' . Plugin::NS_CALENDARSERVER . '}set' => 'Sabre\\Xml\\Element\\KeyValue', - '{' . Plugin::NS_CALENDARSERVER . '}remove' => 'Sabre\\Xml\\Element\\KeyValue', + '{'.Plugin::NS_CALENDARSERVER.'}set' => 'Sabre\\Xml\\Element\\KeyValue', + '{'.Plugin::NS_CALENDARSERVER.'}remove' => 'Sabre\\Xml\\Element\\KeyValue', ]); $sharees = []; foreach ($elems as $elem) { switch ($elem['name']) { - - case '{' . Plugin::NS_CALENDARSERVER . '}set' : + case '{'.Plugin::NS_CALENDARSERVER.'}set': $sharee = $elem['value']; - $sumElem = '{' . Plugin::NS_CALENDARSERVER . '}summary'; - $commonName = '{' . Plugin::NS_CALENDARSERVER . '}common-name'; + $sumElem = '{'.Plugin::NS_CALENDARSERVER.'}summary'; + $commonName = '{'.Plugin::NS_CALENDARSERVER.'}common-name'; $properties = []; if (isset($sharee[$commonName])) { $properties['{DAV:}displayname'] = $sharee[$commonName]; } - $access = array_key_exists('{' . Plugin::NS_CALENDARSERVER . '}read-write', $sharee) + $access = array_key_exists('{'.Plugin::NS_CALENDARSERVER.'}read-write', $sharee) ? \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE : \Sabre\DAV\Sharing\Plugin::ACCESS_READ; $sharees[] = new Sharee([ - 'href' => $sharee['{DAV:}href'], + 'href' => $sharee['{DAV:}href'], 'properties' => $properties, - 'access' => $access, - 'comment' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null + 'access' => $access, + 'comment' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null, ]); break; - case '{' . Plugin::NS_CALENDARSERVER . '}remove' : + case '{'.Plugin::NS_CALENDARSERVER.'}remove': $sharees[] = new Sharee([ - 'href' => $elem['value']['{DAV:}href'], - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS + 'href' => $elem['value']['{DAV:}href'], + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS, ]); break; - } } return new self($sharees); - } - } 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; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php index 40a95f8bf..aa8b1f573 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php @@ -1,14 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * HTTP Basic authentication backend class + * HTTP Basic authentication backend class. * * This class can be used by authentication objects wishing to use HTTP Basic * Most of the digest logic is handled, implementors just need to worry about @@ -19,8 +20,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBasic implements BackendInterface { - +abstract class AbstractBasic implements BackendInterface +{ /** * Authentication Realm. * @@ -39,13 +40,14 @@ abstract class AbstractBasic implements BackendInterface { protected $principalPrefix = 'principals/'; /** - * Validates a username and password + * Validates a username and password. * * This method should return true or false depending on if login * succeeded. * * @param string $username * @param string $password + * * @return bool */ abstract protected function validateUserPass($username, $password); @@ -54,12 +56,10 @@ abstract class AbstractBasic implements BackendInterface { * Sets the authentication realm for this backend. * * @param string $realm - * @return void */ - function setRealm($realm) { - + public function setRealm($realm) + { $this->realm = $realm; - } /** @@ -86,12 +86,13 @@ abstract class AbstractBasic implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Basic( $this->realm, $request, @@ -103,10 +104,10 @@ abstract class AbstractBasic implements BackendInterface { return [false, "No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured"]; } if (!$this->validateUserPass($userpass[0], $userpass[1])) { - return [false, "Username or password was incorrect"]; + return [false, 'Username or password was incorrect']; } - return [true, $this->principalPrefix . $userpass[0]]; + return [true, $this->principalPrefix.$userpass[0]]; } /** @@ -126,19 +127,16 @@ abstract class AbstractBasic implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Basic( $this->realm, $request, $response ); $auth->requireLogin(); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php index ae7a8a12f..a2653b2b0 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php @@ -1,14 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * HTTP Bearer authentication backend class + * HTTP Bearer authentication backend class. * * This class can be used by authentication objects wishing to use HTTP Bearer * Most of the digest logic is handled, implementors just need to worry about @@ -20,8 +21,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBearer implements BackendInterface { - +abstract class AbstractBearer implements BackendInterface +{ /** * Authentication Realm. * @@ -33,12 +34,13 @@ abstract class AbstractBearer implements BackendInterface { protected $realm = 'sabre/dav'; /** - * Validates a Bearer token + * Validates a Bearer token. * * This method should return the full principal url, or false if the * token was incorrect. * * @param string $bearerToken + * * @return string|false */ abstract protected function validateBearerToken($bearerToken); @@ -47,12 +49,10 @@ abstract class AbstractBearer implements BackendInterface { * Sets the authentication realm for this backend. * * @param string $realm - * @return void */ - function setRealm($realm) { - + public function setRealm($realm) + { $this->realm = $realm; - } /** @@ -79,12 +79,13 @@ abstract class AbstractBearer implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Bearer( $this->realm, $request, @@ -97,10 +98,10 @@ abstract class AbstractBearer implements BackendInterface { } $principalUrl = $this->validateBearerToken($bearerToken); if (!$principalUrl) { - return [false, "Bearer token was incorrect"]; + return [false, 'Bearer token was incorrect']; } - return [true, $principalUrl]; + return [true, $principalUrl]; } /** @@ -120,19 +121,16 @@ abstract class AbstractBearer implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Bearer( $this->realm, $request, $response ); $auth->requireLogin(); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php index 4b47f56c9..06c9ed3a4 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\DAV; @@ -8,7 +10,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * HTTP Digest authentication backend class + * HTTP Digest authentication backend class. * * This class can be used by authentication objects wishing to use HTTP Digest * Most of the digest logic is handled, implementors just need to worry about @@ -18,8 +20,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractDigest implements BackendInterface { - +abstract class AbstractDigest implements BackendInterface +{ /** * Authentication Realm. * @@ -45,12 +47,10 @@ abstract class AbstractDigest implements BackendInterface { * existing hashes will break and nobody can authenticate. * * @param string $realm - * @return void */ - function setRealm($realm) { - + public function setRealm($realm) + { $this->realm = $realm; - } /** @@ -60,9 +60,10 @@ abstract class AbstractDigest implements BackendInterface { * * @param string $realm * @param string $username + * * @return string|null */ - abstract function getDigestHash($realm, $username); + abstract public function getDigestHash($realm, $username); /** * When this method is called, the backend must check if authentication was @@ -88,12 +89,13 @@ abstract class AbstractDigest implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { $digest = new HTTP\Auth\Digest( $this->realm, $request, @@ -110,8 +112,8 @@ abstract class AbstractDigest implements BackendInterface { $hash = $this->getDigestHash($this->realm, $username); // If this was false, the user account didn't exist - if ($hash === false || is_null($hash)) { - return [false, "Username or password was incorrect"]; + if (false === $hash || is_null($hash)) { + return [false, 'Username or password was incorrect']; } if (!is_string($hash)) { throw new DAV\Exception('The returned value from getDigestHash must be a string or null'); @@ -119,11 +121,10 @@ abstract class AbstractDigest implements BackendInterface { // If this was false, the password or part of the hash was incorrect. if (!$digest->validateA1($hash)) { - return [false, "Username or password was incorrect"]; + return [false, 'Username or password was incorrect']; } - return [true, $this->principalPrefix . $username]; - + return [true, $this->principalPrefix.$username]; } /** @@ -143,12 +144,11 @@ abstract class AbstractDigest implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Digest( $this->realm, $request, @@ -162,7 +162,5 @@ abstract class AbstractDigest implements BackendInterface { // Preventing the digest utility from modifying the http status code, // this should be handled by the main plugin. $response->setStatus($oldStatus); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php index e203d2685..201fe615c 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php @@ -1,24 +1,26 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * Apache authenticator + * Apache (or NGINX) authenticator. * * This authentication backend assumes that authentication has been - * configured in apache, rather than within SabreDAV. + * configured in apache (or NGINX), rather than within SabreDAV. * - * Make sure apache is properly configured for this to work. + * Make sure apache (or NGINX) is properly configured for this to work. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Apache implements BackendInterface { - +class Apache implements BackendInterface +{ /** * This is the prefix that will be used to generate principal urls. * @@ -50,22 +52,25 @@ class Apache implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { $remoteUser = $request->getRawServerValue('REMOTE_USER'); if (is_null($remoteUser)) { $remoteUser = $request->getRawServerValue('REDIRECT_REMOTE_USER'); } if (is_null($remoteUser)) { - return [false, 'No REMOTE_USER property was found in the PHP $_SERVER super-global. This likely means your server is not configured correctly']; + $remoteUser = $request->getRawServerValue('PHP_AUTH_USER'); + } + if (is_null($remoteUser)) { + return [false, 'No REMOTE_USER, REDIRECT_REMOTE_USER, or PHP_AUTH_USER property was found in the PHP $_SERVER super-global. This likely means your server is not configured correctly']; } - return [true, $this->principalPrefix . $remoteUser]; - + return [true, $this->principalPrefix.$remoteUser]; } /** @@ -85,12 +90,10 @@ class Apache implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php index 0fb2210f4..8598791fb 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP\RequestInterface; @@ -12,8 +14,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * When this method is called, the backend must check if authentication was * successful. @@ -38,11 +40,12 @@ interface BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response); + public function check(RequestInterface $request, ResponseInterface $response); /** * This method is called when a user could not be authenticated, and @@ -61,10 +64,8 @@ interface BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response); - + public function challenge(RequestInterface $request, ResponseInterface $response); } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php index 7ad8f48b2..aab3c5e1c 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; /** @@ -14,10 +16,10 @@ namespace Sabre\DAV\Auth\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class BasicCallBack extends AbstractBasic { - +class BasicCallBack extends AbstractBasic +{ /** - * Callback + * Callback. * * @var callable */ @@ -30,29 +32,27 @@ class BasicCallBack extends AbstractBasic { * password. * * @param callable $callBack - * @return void */ - function __construct(callable $callBack) { - + public function __construct(callable $callBack) + { $this->callBack = $callBack; - } /** - * Validates a username and password + * Validates a username and password. * * This method should return true or false depending on if login * succeeded. * * @param string $username * @param string $password + * * @return bool */ - protected function validateUserPass($username, $password) { - + protected function validateUserPass($username, $password) + { $cb = $this->callBack; - return $cb($username, $password); + return $cb($username, $password); } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php index 3a687d747..ea2d39679 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\DAV; @@ -13,10 +15,10 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends AbstractDigest { - +class File extends AbstractDigest +{ /** - * List of users + * List of users. * * @var array */ @@ -29,11 +31,11 @@ class File extends AbstractDigest { * * @param string|null $filename */ - function __construct($filename = null) { - - if (!is_null($filename)) + public function __construct($filename = null) + { + if (!is_null($filename)) { $this->loadFile($filename); - + } } /** @@ -41,37 +43,32 @@ class File extends AbstractDigest { * more than 1 file is used. * * @param string $filename - * @return void */ - function loadFile($filename) { - + public function loadFile($filename) + { foreach (file($filename, FILE_IGNORE_NEW_LINES) as $line) { - - if (substr_count($line, ":") !== 2) + if (2 !== substr_count($line, ':')) { throw new DAV\Exception('Malformed htdigest file. Every line should contain 2 colons'); - + } list($username, $realm, $A1) = explode(':', $line); - if (!preg_match('/^[a-zA-Z0-9]{32}$/', $A1)) + if (!preg_match('/^[a-zA-Z0-9]{32}$/', $A1)) { throw new DAV\Exception('Malformed htdigest file. Invalid md5 hash'); - - $this->users[$realm . ':' . $username] = $A1; - + } + $this->users[$realm.':'.$username] = $A1; } - } /** - * Returns a users' information + * Returns a users' information. * * @param string $realm * @param string $username + * * @return string */ - function getDigestHash($realm, $username) { - - return isset($this->users[$realm . ':' . $username]) ? $this->users[$realm . ':' . $username] : false; - + public function getDigestHash($realm, $username) + { + return isset($this->users[$realm.':'.$username]) ? $this->users[$realm.':'.$username] : false; } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php new file mode 100644 index 000000000..3a1831116 --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php @@ -0,0 +1,82 @@ +<?php + +namespace Sabre\DAV\Auth\Backend; + +/** + * This is an authentication backend that uses imap. + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @author Michael Niewöhner (foss@mniewoehner.de) + * @author rosali (https://github.com/rosali) + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class IMAP extends AbstractBasic +{ + /** + * IMAP server in the form {host[:port][/flag1/flag2...]}. + * + * @see http://php.net/manual/en/function.imap-open.php + * + * @var string + */ + protected $mailbox; + + /** + * Creates the backend object. + * + * @param string $mailbox + */ + public function __construct($mailbox) + { + $this->mailbox = $mailbox; + } + + /** + * Connects to an IMAP server and tries to authenticate. + * + * @param string $username + * @param string $password + * + * @return bool + */ + protected function imapOpen($username, $password) + { + $success = false; + + try { + $imap = imap_open($this->mailbox, $username, $password, OP_HALFOPEN | OP_READONLY, 1); + if ($imap) { + $success = true; + } + } catch (\ErrorException $e) { + error_log($e->getMessage()); + } + + $errors = imap_errors(); + if ($errors) { + foreach ($errors as $error) { + error_log($error); + } + } + + if (isset($imap) && $imap) { + imap_close($imap); + } + + return $success; + } + + /** + * Validates a username and password by trying to authenticate against IMAP. + * + * @param string $username + * @param string $password + * + * @return bool + */ + protected function validateUserPass($username, $password) + { + return $this->imapOpen($username, $password); + } +} diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php index c2f6de974..87ead6fcd 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; /** @@ -9,23 +11,22 @@ namespace Sabre\DAV\Auth\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractDigest { - +class PDO extends AbstractDigest +{ /** - * Reference to PDO connection + * Reference to PDO connection. * * @var PDO */ protected $pdo; /** - * PDO table name we'll be using + * PDO table name we'll be using. * * @var string */ public $tableName = 'users'; - /** * Creates the backend object. * @@ -33,10 +34,9 @@ class PDO extends AbstractDigest { * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -44,14 +44,14 @@ class PDO extends AbstractDigest { * * @param string $realm * @param string $username + * * @return string|null */ - function getDigestHash($realm, $username) { - - $stmt = $this->pdo->prepare('SELECT digesta1 FROM ' . $this->tableName . ' WHERE username = ?'); + public function getDigestHash($realm, $username) + { + $stmt = $this->pdo->prepare('SELECT digesta1 FROM '.$this->tableName.' WHERE username = ?'); $stmt->execute([$username]); - return $stmt->fetchColumn() ?: null; + return $stmt->fetchColumn() ?: null; } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Plugin.php b/vendor/sabre/dav/lib/DAV/Auth/Plugin.php index bbb5d180d..9be90283f 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth; use Sabre\DAV\Exception\NotAuthenticated; @@ -22,8 +24,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ /** * By default this plugin will require that the user is authenticated, * and refuse any access if the user is not authenticated. @@ -39,7 +41,7 @@ class Plugin extends ServerPlugin { public $autoRequireLogin = true; /** - * authentication backends + * authentication backends. */ protected $backends; @@ -52,40 +54,35 @@ class Plugin extends ServerPlugin { protected $currentPrincipal; /** - * Creates the authentication plugin + * Creates the authentication plugin. * * @param Backend\BackendInterface $authBackend */ - function __construct(Backend\BackendInterface $authBackend = null) { - + public function __construct(Backend\BackendInterface $authBackend = null) + { if (!is_null($authBackend)) { $this->addBackend($authBackend); } - } /** * Adds an authentication backend to the plugin. * * @param Backend\BackendInterface $authBackend - * @return void */ - function addBackend(Backend\BackendInterface $authBackend) { - + public function addBackend(Backend\BackendInterface $authBackend) + { $this->backends[] = $authBackend; - } /** - * Initializes the plugin. This function is automatically called by the server + * Initializes the plugin. This function is automatically called by the server. * * @param Server $server - * @return void */ - function initialize(Server $server) { - - $server->on('beforeMethod', [$this, 'beforeMethod'], 10); - + public function initialize(Server $server) + { + $server->on('beforeMethod:*', [$this, 'beforeMethod'], 10); } /** @@ -96,10 +93,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'auth'; - } /** @@ -114,23 +110,22 @@ class Plugin extends ServerPlugin { * * @return string|null */ - function getCurrentPrincipal() { - + public function getCurrentPrincipal() + { return $this->currentPrincipal; - } /** - * This method is called before any HTTP method and forces users to be authenticated + * This method is called before any HTTP method and forces users to be authenticated. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function beforeMethod(RequestInterface $request, ResponseInterface $response) { - + public function beforeMethod(RequestInterface $request, ResponseInterface $response) + { if ($this->currentPrincipal) { - // We already have authentication information. This means that the // event has already fired earlier, and is now likely fired for a // sub-request. @@ -144,7 +139,6 @@ class Plugin extends ServerPlugin { // // See issue #580 for more information about that. return; - } $authResult = $this->check($request, $response); @@ -153,11 +147,10 @@ class Plugin extends ServerPlugin { // Auth was successful $this->currentPrincipal = $authResult[1]; $this->loginFailedReasons = null; + return; } - - // If we got here, it means that no authentication backend was // successful in authenticating the user. $this->currentPrincipal = null; @@ -167,7 +160,6 @@ class Plugin extends ServerPlugin { $this->challenge($request, $response); throw new NotAuthenticated(implode(', ', $authResult[1])); } - } /** @@ -184,24 +176,24 @@ class Plugin extends ServerPlugin { * unsuccessful. For every auth backend there will be one reason, so usually * there's just one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { if (!$this->backends) { throw new \Sabre\DAV\Exception('No authentication backends were configured on this server.'); } $reasons = []; foreach ($this->backends as $backend) { - $result = $backend->check( $request, $response ); - if (!is_array($result) || count($result) !== 2 || !is_bool($result[0]) || !is_string($result[1])) { + if (!is_array($result) || 2 !== count($result) || !is_bool($result[0]) || !is_string($result[1])) { throw new \Sabre\DAV\Exception('The authentication backend did not return a correct value from the check() method.'); } @@ -211,11 +203,9 @@ class Plugin extends ServerPlugin { return [true, $result[1]]; } $reasons[] = $result[1]; - } return [false, $reasons]; - } /** @@ -225,16 +215,16 @@ class Plugin extends ServerPlugin { * WWW-Authorization header, indicating to the client that it should * authenticate. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { foreach ($this->backends as $backend) { $backend->challenge($request, $response); } - } /** @@ -255,10 +245,9 @@ class Plugin extends ServerPlugin { * * @return string[]|null */ - function getLoginFailedReasons() { - + public function getLoginFailedReasons() + { return $this->loginFailedReasons; - } /** @@ -272,14 +261,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Generic authentication plugin', - 'link' => 'http://sabre.io/dav/authentication/', + 'link' => 'http://sabre.io/dav/authentication/', ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php b/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php index 3ba2aee25..7466babb3 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php +++ b/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php @@ -1,14 +1,16 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; -use Sabre\DAV\Inode; +use Sabre\DAV\INode; use Sabre\DAV\PropFind; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * GuessContentType plugin + * GuessContentType plugin. * * A lot of the built-in File objects just return application/octet-stream * as a content-type by default. This is a problem for some clients, because @@ -22,17 +24,16 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class GuessContentType extends DAV\ServerPlugin { - +class GuessContentType extends DAV\ServerPlugin +{ /** - * List of recognized file extensions + * List of recognized file extensions. * * Feel free to add more * * @var array */ public $extensionMap = [ - // images 'jpg' => 'image/jpeg', 'gif' => 'image/gif', @@ -44,58 +45,52 @@ class GuessContentType extends DAV\ServerPlugin { // text 'txt' => 'text/plain', - ]; /** - * Initializes the plugin + * Initializes the plugin. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { // Using a relatively low priority (200) to allow other extensions // to set the content-type first. $server->on('propFind', [$this, 'propFind'], 200); - } /** - * Our PROPFIND handler + * Our PROPFIND handler. * * Here we set a contenttype, if the node didn't already have one. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - - $propFind->handle('{DAV:}getcontenttype', function() use ($propFind) { + public function propFind(PropFind $propFind, INode $node) + { + $propFind->handle('{DAV:}getcontenttype', function () use ($propFind) { + list(, $fileName) = Uri\split($propFind->getPath()); - list(, $fileName) = URLUtil::splitPath($propFind->getPath()); return $this->getContentType($fileName); - }); - } /** - * Simple method to return the contenttype + * Simple method to return the contenttype. * * @param string $fileName + * * @return string */ - protected function getContentType($fileName) { - + protected function getContentType($fileName) + { // Just grabbing the extension $extension = strtolower(substr($fileName, strrpos($fileName, '.') + 1)); if (isset($this->extensionMap[$extension])) { return $this->extensionMap[$extension]; } - return 'application/octet-stream'; + return 'application/octet-stream'; } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php b/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php index f4be6b348..59b3f5604 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php +++ b/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; /** @@ -13,8 +15,8 @@ namespace Sabre\DAV\Browser; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface HtmlOutput { - +interface HtmlOutput +{ /** * Generate html representation for this value. * @@ -27,8 +29,8 @@ interface HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html); - + public function toHtml(HtmlOutputHelper $html); } diff --git a/vendor/sabre/dav/lib/DAV/Browser/HtmlOutputHelper.php b/vendor/sabre/dav/lib/DAV/Browser/HtmlOutputHelper.php index 249d54047..a7c747437 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/HtmlOutputHelper.php +++ b/vendor/sabre/dav/lib/DAV/Browser/HtmlOutputHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\Uri; @@ -13,8 +15,8 @@ use Sabre\Xml\Service as XmlService; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class HtmlOutputHelper { - +class HtmlOutputHelper +{ /** * Link to the root of the application. * @@ -40,13 +42,12 @@ class HtmlOutputHelper { * that can be used to make output a lot shorter. * * @param string $baseUri - * @param array $namespaceMap + * @param array $namespaceMap */ - function __construct($baseUri, array $namespaceMap) { - + public function __construct($baseUri, array $namespaceMap) + { $this->baseUri = $baseUri; $this->namespaceMap = $namespaceMap; - } /** @@ -58,24 +59,24 @@ class HtmlOutputHelper { * Absolute urls are left alone. * * @param string $path + * * @return string */ - function fullUrl($path) { - + public function fullUrl($path) + { return Uri\resolve($this->baseUri, $path); - } /** * Escape string for HTML output. * - * @param string $input + * @param scalar $input + * * @return string */ - function h($input) { - - return htmlspecialchars($input, ENT_COMPAT, 'UTF-8'); - + public function h($input) + { + return htmlspecialchars((string) $input, ENT_COMPAT, 'UTF-8'); } /** @@ -86,13 +87,14 @@ class HtmlOutputHelper { * * @param string $url * @param string $label + * * @return string */ - function link($url, $label = null) { - + public function link($url, $label = null) + { $url = $this->h($this->fullUrl($url)); - return '<a href="' . $url . '">' . ($label ? $this->h($label) : $url) . '</a>'; + return '<a href="'.$url.'">'.($label ? $this->h($label) : $url).'</a>'; } /** @@ -100,18 +102,18 @@ class HtmlOutputHelper { * shortened version with a prefix, if it was a known namespace. * * @param string $element + * * @return string */ - function xmlName($element) { - + public function xmlName($element) + { list($ns, $localName) = XmlService::parseClarkNotation($element); if (isset($this->namespaceMap[$ns])) { - $propName = $this->namespaceMap[$ns] . ':' . $localName; + $propName = $this->namespaceMap[$ns].':'.$localName; } else { $propName = $element; } - return "<span title=\"" . $this->h($element) . "\">" . $this->h($propName) . "</span>"; + return '<span title="'.$this->h($element).'">'.$this->h($propName).'</span>'; } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php b/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php index 61327c49a..25e061128 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php +++ b/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; @@ -16,45 +18,46 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MapGetToPropFind extends DAV\ServerPlugin { - +class MapGetToPropFind extends DAV\ServerPlugin +{ /** - * reference to server class + * reference to server class. * * @var DAV\Server */ protected $server; /** - * Initializes the plugin and subscribes to events + * Initializes the plugin and subscribes to events. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->on('method:GET', [$this, 'httpGet'], 90); } /** - * This method intercepts GET requests to non-files, and changes it into an HTTP PROPFIND request + * This method intercepts GET requests to non-files, and changes it into an HTTP PROPFIND request. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $node = $this->server->tree->getNodeForPath($request->getPath()); - if ($node instanceof DAV\IFile) return; + if ($node instanceof DAV\IFile) { + return; + } $subRequest = clone $request; $subRequest->setMethod('PROPFIND'); $this->server->invokeMethod($subRequest, $response); - return false; + return false; } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/Plugin.php b/vendor/sabre/dav/lib/DAV/Browser/Plugin.php index 545ad5633..e2fab4b79 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Browser/Plugin.php @@ -1,15 +1,18 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; use Sabre\DAV\MkCol; +use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * Browser Plugin + * Browser Plugin. * * This plugin provides a html representation, so that a WebDAV server may be accessed * using a browser. @@ -21,10 +24,10 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * reference to server class + * reference to server class. * * @var DAV\Server */ @@ -60,53 +63,54 @@ class Plugin extends DAV\ServerPlugin { * * @param bool $enablePost */ - function __construct($enablePost = true) { - + public function __construct($enablePost = true) + { $this->enablePost = $enablePost; - } /** - * Initializes the plugin and subscribes to events + * Initializes the plugin and subscribes to events. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->on('method:GET', [$this, 'httpGetEarly'], 90); $this->server->on('method:GET', [$this, 'httpGet'], 200); $this->server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel'], 200); - if ($this->enablePost) $this->server->on('method:POST', [$this, 'httpPOST']); + if ($this->enablePost) { + $this->server->on('method:POST', [$this, 'httpPOST']); + } } /** * This method intercepts GET requests that have ?sabreAction=info - * appended to the URL + * appended to the URL. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGetEarly(RequestInterface $request, ResponseInterface $response) { - + public function httpGetEarly(RequestInterface $request, ResponseInterface $response) + { $params = $request->getQueryParameters(); - if (isset($params['sabreAction']) && $params['sabreAction'] === 'info') { + if (isset($params['sabreAction']) && 'info' === $params['sabreAction']) { return $this->httpGet($request, $response); } - } /** - * This method intercepts GET requests to collections and returns the html + * This method intercepts GET requests to collections and returns the html. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { // We're not using straight-up $_GET, because we want everything to be // unit testable. $getVars = $request->getQueryParameters(); @@ -117,13 +121,13 @@ class Plugin extends DAV\ServerPlugin { $sabreAction = isset($getVars['sabreAction']) ? $getVars['sabreAction'] : null; switch ($sabreAction) { - - case 'asset' : + case 'asset': // Asset handling, such as images $this->serveAsset(isset($getVars['assetName']) ? $getVars['assetName'] : null); + return false; - default : - case 'info' : + default: + case 'info': try { $this->server->tree->getNodeForPath($request->getPath()); } catch (DAV\Exception\NotFound $e) { @@ -141,7 +145,7 @@ class Plugin extends DAV\ServerPlugin { return false; - case 'plugins' : + case 'plugins': $response->setStatus(200); $response->setHeader('Content-Type', 'text/html; charset=utf-8'); @@ -150,41 +154,39 @@ class Plugin extends DAV\ServerPlugin { ); return false; - } - } /** * Handles POST requests for tree operations. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpPOST(RequestInterface $request, ResponseInterface $response) { - + public function httpPOST(RequestInterface $request, ResponseInterface $response) + { $contentType = $request->getHeader('Content-Type'); list($contentType) = explode(';', $contentType); - if ($contentType !== 'application/x-www-form-urlencoded' && - $contentType !== 'multipart/form-data') { - return; + if ('application/x-www-form-urlencoded' !== $contentType && + 'multipart/form-data' !== $contentType) { + return; } $postVars = $request->getPostData(); - if (!isset($postVars['sabreAction'])) + if (!isset($postVars['sabreAction'])) { return; + } $uri = $request->getPath(); if ($this->server->emit('onBrowserPostAction', [$uri, $postVars['sabreAction'], $postVars])) { - switch ($postVars['sabreAction']) { - - case 'mkcol' : + case 'mkcol': if (isset($postVars['name']) && trim($postVars['name'])) { // Using basename() because we won't allow slashes - list(, $folderName) = URLUtil::splitPath(trim($postVars['name'])); + list(, $folderName) = Uri\split(trim($postVars['name'])); if (isset($postVars['resourceType'])) { $resourceType = explode(',', $postVars['resourceType']); @@ -196,7 +198,7 @@ class Plugin extends DAV\ServerPlugin { foreach ($postVars as $varName => $varValue) { // Any _POST variable in clark notation is treated // like a property. - if ($varName[0] === '{') { + if ('{' === $varName[0]) { // PHP will convert any dots to underscores. // This leaves us with no way to differentiate // the two. @@ -212,65 +214,67 @@ class Plugin extends DAV\ServerPlugin { $resourceType, $properties ); - $this->server->createCollection($uri . '/' . $folderName, $mkCol); + $this->server->createCollection($uri.'/'.$folderName, $mkCol); } break; // @codeCoverageIgnoreStart - case 'put' : + case 'put': - if ($_FILES) $file = current($_FILES); - else break; + if ($_FILES) { + $file = current($_FILES); + } else { + break; + } - list(, $newName) = URLUtil::splitPath(trim($file['name'])); - if (isset($postVars['name']) && trim($postVars['name'])) + list(, $newName) = Uri\split(trim($file['name'])); + if (isset($postVars['name']) && trim($postVars['name'])) { $newName = trim($postVars['name']); + } // Making sure we only have a 'basename' component - list(, $newName) = URLUtil::splitPath($newName); + list(, $newName) = Uri\split($newName); if (is_uploaded_file($file['tmp_name'])) { - $this->server->createFile($uri . '/' . $newName, fopen($file['tmp_name'], 'r')); + $this->server->createFile($uri.'/'.$newName, fopen($file['tmp_name'], 'r')); } break; // @codeCoverageIgnoreEnd - } - } $response->setHeader('Location', $request->getUrl()); $response->setStatus(302); - return false; + return false; } /** * Escapes a string for html. * * @param string $value + * * @return string */ - function escapeHTML($value) { - + public function escapeHTML($value) + { return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); - } /** - * Generates the html directory index for a given url + * Generates the html directory index for a given url. * * @param string $path + * * @return string */ - function generateDirectoryIndex($path) { - + public function generateDirectoryIndex($path) + { $html = $this->generateHeader($path ? $path : '/', $path); $node = $this->server->tree->getNodeForPath($path); if ($node instanceof DAV\ICollection) { - $html .= "<section><h1>Nodes</h1>\n"; - $html .= "<table class=\"nodeTable\">"; + $html .= '<table class="nodeTable">'; $subNodes = $this->server->getPropertiesForChildren($path, [ '{DAV:}displayname', @@ -281,10 +285,9 @@ class Plugin extends DAV\ServerPlugin { ]); foreach ($subNodes as $subPath => $subProps) { - $subNode = $this->server->tree->getNodeForPath($subPath); - $fullPath = $this->server->getBaseUri() . URLUtil::encodePath($subPath); - list(, $displayPath) = URLUtil::splitPath($subPath); + $fullPath = $this->server->getBaseUri().HTTP\encodePath($subPath); + list(, $displayPath) = Uri\split($subPath); $subNodes[$subPath]['subNode'] = $subNode; $subNodes[$subPath]['fullPath'] = $fullPath; @@ -295,43 +298,46 @@ class Plugin extends DAV\ServerPlugin { foreach ($subNodes as $subProps) { $type = [ 'string' => 'Unknown', - 'icon' => 'cog', + 'icon' => 'cog', ]; if (isset($subProps['{DAV:}resourcetype'])) { $type = $this->mapResourceType($subProps['{DAV:}resourcetype']->getValue(), $subProps['subNode']); } $html .= '<tr>'; - $html .= '<td class="nameColumn"><a href="' . $this->escapeHTML($subProps['fullPath']) . '"><span class="oi" data-glyph="' . $this->escapeHTML($type['icon']) . '"></span> ' . $this->escapeHTML($subProps['displayPath']) . '</a></td>'; - $html .= '<td class="typeColumn">' . $this->escapeHTML($type['string']) . '</td>'; + $html .= '<td class="nameColumn"><a href="'.$this->escapeHTML($subProps['fullPath']).'"><span class="oi" data-glyph="'.$this->escapeHTML($type['icon']).'"></span> '.$this->escapeHTML($subProps['displayPath']).'</a></td>'; + $html .= '<td class="typeColumn">'.$this->escapeHTML($type['string']).'</td>'; $html .= '<td>'; if (isset($subProps['{DAV:}getcontentlength'])) { - $html .= $this->escapeHTML($subProps['{DAV:}getcontentlength'] . ' bytes'); + $html .= $this->escapeHTML($subProps['{DAV:}getcontentlength'].' bytes'); } $html .= '</td><td>'; if (isset($subProps['{DAV:}getlastmodified'])) { $lastMod = $subProps['{DAV:}getlastmodified']->getTime(); $html .= $this->escapeHTML($lastMod->format('F j, Y, g:i a')); } + $html .= '</td><td>'; + if (isset($subProps['{DAV:}displayname'])) { + $html .= $this->escapeHTML($subProps['{DAV:}displayname']); + } $html .= '</td>'; $buttonActions = ''; if ($subProps['subNode'] instanceof DAV\IFile) { - $buttonActions = '<a href="' . $this->escapeHTML($subProps['fullPath']) . '?sabreAction=info"><span class="oi" data-glyph="info"></span></a>'; + $buttonActions = '<a href="'.$this->escapeHTML($subProps['fullPath']).'?sabreAction=info"><span class="oi" data-glyph="info"></span></a>'; } $this->server->emit('browserButtonActions', [$subProps['fullPath'], $subProps['subNode'], &$buttonActions]); - $html .= '<td>' . $buttonActions . '</td>'; + $html .= '<td>'.$buttonActions.'</td>'; $html .= '</tr>'; } $html .= '</table>'; - } - $html .= "</section>"; - $html .= "<section><h1>Properties</h1>"; - $html .= "<table class=\"propTable\">"; + $html .= '</section>'; + $html .= '<section><h1>Properties</h1>'; + $html .= '<table class="propTable">'; // Allprops request $propFind = new PropFindAll($path); @@ -343,12 +349,10 @@ class Plugin extends DAV\ServerPlugin { if (!in_array($propName, $this->uninterestingProperties)) { $html .= $this->drawPropertyRow($propName, $propValue); } - } - - $html .= "</table>"; - $html .= "</section>"; + $html .= '</table>'; + $html .= '</section>'; /* Start of generating actions */ @@ -358,8 +362,7 @@ class Plugin extends DAV\ServerPlugin { } if ($output) { - - $html .= "<section><h1>Actions</h1>"; + $html .= '<section><h1>Actions</h1>'; $html .= "<div class=\"actions\">\n"; $html .= $output; $html .= "</div>\n"; @@ -371,7 +374,6 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setHeader('Content-Security-Policy', "default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"); return $html; - } /** @@ -379,31 +381,30 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function generatePluginListing() { - + public function generatePluginListing() + { $html = $this->generateHeader('Plugins'); - $html .= "<section><h1>Plugins</h1>"; - $html .= "<table class=\"propTable\">"; + $html .= '<section><h1>Plugins</h1>'; + $html .= '<table class="propTable">'; foreach ($this->server->getPlugins() as $plugin) { $info = $plugin->getPluginInfo(); - $html .= '<tr><th>' . $info['name'] . '</th>'; - $html .= '<td>' . $info['description'] . '</td>'; + $html .= '<tr><th>'.$info['name'].'</th>'; + $html .= '<td>'.$info['description'].'</td>'; $html .= '<td>'; if (isset($info['link']) && $info['link']) { - $html .= '<a href="' . $this->escapeHTML($info['link']) . '"><span class="oi" data-glyph="book"></span></a>'; + $html .= '<a href="'.$this->escapeHTML($info['link']).'"><span class="oi" data-glyph="book"></span></a>'; } $html .= '</td></tr>'; } - $html .= "</table>"; - $html .= "</section>"; + $html .= '</table>'; + $html .= '</section>'; /* Start of generating actions */ $html .= $this->generateFooter(); return $html; - } /** @@ -414,22 +415,23 @@ class Plugin extends DAV\ServerPlugin { * * @param string $title * @param string $path + * * @return string */ - function generateHeader($title, $path = null) { - + public function generateHeader($title, $path = null) + { $version = ''; if (DAV\Server::$exposeVersion) { $version = DAV\Version::VERSION; } $vars = [ - 'title' => $this->escapeHTML($title), - 'favicon' => $this->escapeHTML($this->getAssetUrl('favicon.ico')), - 'style' => $this->escapeHTML($this->getAssetUrl('sabredav.css')), + 'title' => $this->escapeHTML($title), + 'favicon' => $this->escapeHTML($this->getAssetUrl('favicon.ico')), + 'style' => $this->escapeHTML($this->getAssetUrl('sabredav.css')), 'iconstyle' => $this->escapeHTML($this->getAssetUrl('openiconic/open-iconic.css')), - 'logo' => $this->escapeHTML($this->getAssetUrl('sabredav.png')), - 'baseUrl' => $this->server->getBaseUri(), + 'logo' => $this->escapeHTML($this->getAssetUrl('sabredav.png')), + 'baseUrl' => $this->server->getBaseUri(), ]; $html = <<<HTML @@ -453,20 +455,19 @@ class Plugin extends DAV\ServerPlugin { HTML; // If the path is empty, there's no parent. - if ($path) { - list($parentUri) = URLUtil::splitPath($path); - $fullPath = $this->server->getBaseUri() . URLUtil::encodePath($parentUri); - $html .= '<a href="' . $fullPath . '" class="btn">⇤ Go to parent</a>'; + if ($path) { + list($parentUri) = Uri\split($path); + $fullPath = $this->server->getBaseUri().HTTP\encodePath($parentUri); + $html .= '<a href="'.$fullPath.'" class="btn">⇤ Go to parent</a>'; } else { $html .= '<span class="btn disabled">⇤ Go to parent</span>'; } $html .= ' <a href="?sabreAction=plugins" class="btn"><span class="oi" data-glyph="puzzle-piece"></span> Plugins</a>'; - $html .= "</nav>"; + $html .= '</nav>'; return $html; - } /** @@ -476,18 +477,19 @@ HTML; * * @return string */ - function generateFooter() { - + public function generateFooter() + { $version = ''; if (DAV\Server::$exposeVersion) { $version = DAV\Version::VERSION; } + $year = date('Y'); + return <<<HTML -<footer>Generated by SabreDAV $version (c)2007-2016 <a href="http://sabre.io/">http://sabre.io/</a></footer> +<footer>Generated by SabreDAV $version (c)2007-$year <a href="http://sabre.io/">http://sabre.io/</a></footer> </body> </html> HTML; - } /** @@ -498,19 +500,20 @@ HTML; * creating new directories. * * @param DAV\INode $node - * @param mixed $output - * @param string $path - * @return void + * @param mixed $output + * @param string $path */ - function htmlActionsPanel(DAV\INode $node, &$output, $path) { - - if (!$node instanceof DAV\ICollection) + public function htmlActionsPanel(DAV\INode $node, &$output, $path) + { + if (!$node instanceof DAV\ICollection) { return; + } // We also know fairly certain that if an object is a non-extended // SimpleCollection, we won't need to show the panel either. - if (get_class($node) === 'Sabre\\DAV\\SimpleCollection') + if ('Sabre\\DAV\\SimpleCollection' === get_class($node)) { return; + } $output .= <<<HTML <form method="post" action=""> @@ -527,7 +530,6 @@ HTML; <input type="submit" value="upload" /> </form> HTML; - } /** @@ -535,32 +537,35 @@ HTML; * suiteable for http access. * * @param string $assetName + * * @return string */ - protected function getAssetUrl($assetName) { - - return $this->server->getBaseUri() . '?sabreAction=asset&assetName=' . urlencode($assetName); - + protected function getAssetUrl($assetName) + { + return $this->server->getBaseUri().'?sabreAction=asset&assetName='.urlencode($assetName); } /** * This method returns a local pathname to an asset. * * @param string $assetName + * * @throws DAV\Exception\NotFound + * * @return string */ - protected function getLocalAssetPath($assetName) { - - $assetDir = __DIR__ . '/assets/'; - $path = $assetDir . $assetName; + protected function getLocalAssetPath($assetName) + { + $assetDir = __DIR__.'/assets/'; + $path = $assetDir.$assetName; // Making sure people aren't trying to escape from the base path. $path = str_replace('\\', '/', $path); - if (strpos($path, '/../') !== false || strrchr($path, '/') === '/..') { + if (false !== strpos($path, '/../') || '/..' === strrchr($path, '/')) { throw new DAV\Exception\NotFound('Path does not exist, or escaping from the base path was detected'); } - if (strpos(realpath($path), realpath($assetDir)) === 0 && file_exists($path)) { + $realPath = realpath($path); + if ($realPath && 0 === strpos($realPath, realpath($assetDir)) && file_exists($path)) { return $path; } throw new DAV\Exception\NotFound('Path does not exist, or escaping from the base path was detected'); @@ -570,10 +575,9 @@ HTML; * This method reads an asset from disk and generates a full http response. * * @param string $assetName - * @return void */ - protected function serveAsset($assetName) { - + protected function serveAsset($assetName) + { $assetPath = $this->getLocalAssetPath($assetName); // Rudimentary mime type detection @@ -594,7 +598,6 @@ HTML; $this->server->httpResponse->setHeader('Cache-Control', 'public, max-age=1209600'); $this->server->httpResponse->setStatus(200); $this->server->httpResponse->setBody(fopen($assetPath, 'r')); - } /** @@ -603,10 +606,11 @@ HTML; * * @param array $a * @param array $b + * * @return int */ - protected function compareNodes($a, $b) { - + protected function compareNodes($a, $b) + { $typeA = (isset($a['{DAV:}resourcetype'])) ? (in_array('{DAV:}collection', $a['{DAV:}resourcetype']->getValue())) : false; @@ -619,29 +623,30 @@ HTML; if ($typeA === $typeB) { return strnatcasecmp($a['displayPath'], $b['displayPath']); } - return (($typeA < $typeB) ? 1 : -1); + return ($typeA < $typeB) ? 1 : -1; } /** * Maps a resource type to a human-readable string and icon. * - * @param array $resourceTypes + * @param array $resourceTypes * @param DAV\INode $node + * * @return array */ - private function mapResourceType(array $resourceTypes, $node) { - + private function mapResourceType(array $resourceTypes, $node) + { if (!$resourceTypes) { if ($node instanceof DAV\IFile) { return [ 'string' => 'File', - 'icon' => 'file', + 'icon' => 'file', ]; } else { return [ 'string' => 'Unknown', - 'icon' => 'cog', + 'icon' => 'cog', ]; } } @@ -649,53 +654,53 @@ HTML; $types = [ '{http://calendarserver.org/ns/}calendar-proxy-write' => [ 'string' => 'Proxy-Write', - 'icon' => 'people', + 'icon' => 'people', ], '{http://calendarserver.org/ns/}calendar-proxy-read' => [ 'string' => 'Proxy-Read', - 'icon' => 'people', + 'icon' => 'people', ], '{urn:ietf:params:xml:ns:caldav}schedule-outbox' => [ 'string' => 'Outbox', - 'icon' => 'inbox', + 'icon' => 'inbox', ], '{urn:ietf:params:xml:ns:caldav}schedule-inbox' => [ 'string' => 'Inbox', - 'icon' => 'inbox', + 'icon' => 'inbox', ], '{urn:ietf:params:xml:ns:caldav}calendar' => [ 'string' => 'Calendar', - 'icon' => 'calendar', + 'icon' => 'calendar', ], '{http://calendarserver.org/ns/}shared-owner' => [ 'string' => 'Shared', - 'icon' => 'calendar', + 'icon' => 'calendar', ], '{http://calendarserver.org/ns/}subscribed' => [ 'string' => 'Subscription', - 'icon' => 'calendar', + 'icon' => 'calendar', ], '{urn:ietf:params:xml:ns:carddav}directory' => [ 'string' => 'Directory', - 'icon' => 'globe', + 'icon' => 'globe', ], '{urn:ietf:params:xml:ns:carddav}addressbook' => [ 'string' => 'Address book', - 'icon' => 'book', + 'icon' => 'book', ], '{DAV:}principal' => [ 'string' => 'Principal', - 'icon' => 'person', + 'icon' => 'person', ], '{DAV:}collection' => [ 'string' => 'Collection', - 'icon' => 'folder', + 'icon' => 'folder', ], ]; $info = [ 'string' => [], - 'icon' => 'cog', + 'icon' => 'cog', ]; foreach ($resourceTypes as $k => $resourceType) { if (isset($types[$resourceType])) { @@ -713,42 +718,41 @@ HTML; $info['string'] = implode(', ', $info['string']); return $info; - } /** - * Draws a table row for a property + * Draws a table row for a property. * * @param string $name - * @param mixed $value + * @param mixed $value + * * @return string */ - private function drawPropertyRow($name, $value) { - + private function drawPropertyRow($name, $value) + { $html = new HtmlOutputHelper( $this->server->getBaseUri(), $this->server->xml->namespaceMap ); - return "<tr><th>" . $html->xmlName($name) . "</th><td>" . $this->drawPropertyValue($html, $value) . "</td></tr>"; - + return '<tr><th>'.$html->xmlName($name).'</th><td>'.$this->drawPropertyValue($html, $value).'</td></tr>'; } /** - * Draws a table row for a property + * Draws a table row for a property. * * @param HtmlOutputHelper $html - * @param mixed $value + * @param mixed $value + * * @return string */ - private function drawPropertyValue($html, $value) { - + private function drawPropertyValue($html, $value) + { if (is_scalar($value)) { return $html->h($value); } elseif ($value instanceof HtmlOutput) { return $value->toHtml($html); } elseif ($value instanceof \Sabre\Xml\XmlSerializable) { - // There's no default html output for this property, we're going // to output the actual xml serialization instead. $xml = $this->server->xml->write('{DAV:}root', $value, $this->server->getBaseUri()); @@ -756,12 +760,11 @@ HTML; // element. $xml = explode("\n", $xml); $xml = array_slice($xml, 2, -2); - return "<pre>" . $html->h(implode("\n", $xml)) . "</pre>"; + return '<pre>'.$html->h(implode("\n", $xml)).'</pre>'; } else { - return "<em>unknown</em>"; + return '<em>unknown</em>'; } - } /** @@ -772,10 +775,9 @@ HTML; * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'browser'; - } /** @@ -789,14 +791,12 @@ HTML; * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Generates HTML indexes and debug information for your sabre/dav server', - 'link' => 'http://sabre.io/dav/browser-plugin/', + 'link' => 'http://sabre.io/dav/browser-plugin/', ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/PropFindAll.php b/vendor/sabre/dav/lib/DAV/Browser/PropFindAll.php index c14b7f2f9..34702bdd8 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/PropFindAll.php +++ b/vendor/sabre/dav/lib/DAV/Browser/PropFindAll.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV\PropFind; @@ -12,17 +14,16 @@ use Sabre\DAV\PropFind; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PropFindAll extends PropFind { - +class PropFindAll extends PropFind +{ /** - * Creates the PROPFIND object + * Creates the PROPFIND object. * * @param string $path */ - function __construct($path) { - + public function __construct($path) + { parent::__construct($path, []); - } /** @@ -44,11 +45,10 @@ class PropFindAll extends PropFind { * It's also possible to not pass a callback, but immediately pass a value * * @param string $propertyName - * @param mixed $valueOrCallBack - * @return void + * @param mixed $valueOrCallBack */ - function handle($propertyName, $valueOrCallBack) { - + public function handle($propertyName, $valueOrCallBack) + { if (is_callable($valueOrCallBack)) { $value = $valueOrCallBack(); } else { @@ -57,39 +57,36 @@ class PropFindAll extends PropFind { if (!is_null($value)) { $this->result[$propertyName] = [200, $value]; } - } /** - * Sets the value of the property + * Sets the value of the property. * * If status is not supplied, the status will default to 200 for non-null * properties, and 404 for null properties. * * @param string $propertyName - * @param mixed $value - * @param int $status - * @return void + * @param mixed $value + * @param int $status */ - function set($propertyName, $value, $status = null) { - + public function set($propertyName, $value, $status = null) + { if (is_null($status)) { $status = is_null($value) ? 404 : 200; } $this->result[$propertyName] = [$status, $value]; - } /** * Returns the current value for a property. * * @param string $propertyName + * * @return mixed */ - function get($propertyName) { - + public function get($propertyName) + { return isset($this->result[$propertyName]) ? $this->result[$propertyName][1] : null; - } /** @@ -99,12 +96,12 @@ class PropFindAll extends PropFind { * null will be returned. * * @param string $propertyName + * * @return int|null */ - function getStatus($propertyName) { - + public function getStatus($propertyName) + { return isset($this->result[$propertyName]) ? $this->result[$propertyName][0] : 404; - } /** @@ -113,11 +110,11 @@ class PropFindAll extends PropFind { * * @return array */ - function get404Properties() { - + public function get404Properties() + { $result = []; foreach ($this->result as $propertyName => $stuff) { - if ($stuff[0] === 404) { + if (404 === $stuff[0]) { $result[] = $propertyName; } } @@ -125,8 +122,7 @@ class PropFindAll extends PropFind { if (!$result) { $result[] = '{http://sabredav.org/ns}idk'; } - return $result; + return $result; } - } diff --git a/vendor/sabre/dav/lib/DAV/Client.php b/vendor/sabre/dav/lib/DAV/Client.php index 175ad1bc4..cfa24cd29 100644 --- a/vendor/sabre/dav/lib/DAV/Client.php +++ b/vendor/sabre/dav/lib/DAV/Client.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; use Sabre\Uri; /** - * SabreDAV DAV client + * SabreDAV DAV client. * * This client wraps around Curl to provide a convenient API to a WebDAV * server. @@ -17,8 +19,8 @@ use Sabre\Uri; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Client extends HTTP\Client { - +class Client extends HTTP\Client +{ /** * The xml service. * @@ -29,18 +31,19 @@ class Client extends HTTP\Client { public $xml; /** - * The elementMap + * The elementMap. * * This property is linked via reference to $this->xml->elementMap. * It's deprecated as of version 3.0.0, and should no longer be used. * * @deprecated + * * @var array */ public $propertyMap = []; /** - * Base URI + * Base URI. * * This URI will be used to resolve relative urls. * @@ -49,17 +52,17 @@ class Client extends HTTP\Client { protected $baseUri; /** - * Basic authentication + * Basic authentication. */ const AUTH_BASIC = 1; /** - * Digest authentication + * Digest authentication. */ const AUTH_DIGEST = 2; /** - * NTLM authentication + * NTLM authentication. */ const AUTH_NTLM = 4; @@ -69,12 +72,12 @@ class Client extends HTTP\Client { const ENCODING_IDENTITY = 1; /** - * Deflate encoding + * Deflate encoding. */ const ENCODING_DEFLATE = 2; /** - * Gzip encoding + * Gzip encoding. */ const ENCODING_GZIP = 4; @@ -84,14 +87,14 @@ class Client extends HTTP\Client { const ENCODING_ALL = 7; /** - * Content-encoding + * Content-encoding. * * @var int */ protected $encoding = self::ENCODING_IDENTITY; /** - * Constructor + * Constructor. * * Settings are provided through the 'settings' argument. The following * settings are supported: @@ -112,8 +115,8 @@ class Client extends HTTP\Client { * * @param array $settings */ - function __construct(array $settings) { - + public function __construct(array $settings) + { if (!isset($settings['baseUri'])) { throw new \InvalidArgumentException('A baseUri must be provided'); } @@ -146,8 +149,7 @@ class Client extends HTTP\Client { } $this->addCurlSetting(CURLOPT_HTTPAUTH, $curlType); - $this->addCurlSetting(CURLOPT_USERPWD, $userName . ':' . $password); - + $this->addCurlSetting(CURLOPT_USERPWD, $userName.':'.$password); } if (isset($settings['encoding'])) { @@ -166,16 +168,15 @@ class Client extends HTTP\Client { $this->addCurlSetting(CURLOPT_ENCODING, implode(',', $encodings)); } - $this->addCurlSetting(CURLOPT_USERAGENT, 'sabre-dav/' . Version::VERSION . ' (http://sabre.io/)'); + $this->addCurlSetting(CURLOPT_USERAGENT, 'sabre-dav/'.Version::VERSION.' (http://sabre.io/)'); $this->xml = new Xml\Service(); // BC - $this->propertyMap = & $this->xml->elementMap; - + $this->propertyMap = &$this->xml->elementMap; } /** - * Does a PROPFIND request + * Does a PROPFIND request. * * The list of requested properties must be specified as an array, in clark * notation. @@ -191,28 +192,28 @@ class Client extends HTTP\Client { * made to the server to also return all child resources. * * @param string $url - * @param array $properties - * @param int $depth + * @param array $properties + * @param int $depth + * * @return array */ - function propFind($url, array $properties, $depth = 0) { - + public function propFind($url, array $properties, $depth = 0) + { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->formatOutput = true; $root = $dom->createElementNS('DAV:', 'd:propfind'); $prop = $dom->createElement('d:prop'); foreach ($properties as $property) { - list( $namespace, $elementName ) = \Sabre\Xml\Service::parseClarkNotation($property); - if ($namespace === 'DAV:') { - $element = $dom->createElement('d:' . $elementName); + if ('DAV:' === $namespace) { + $element = $dom->createElement('d:'.$elementName); } else { - $element = $dom->createElementNS($namespace, 'x:' . $elementName); + $element = $dom->createElementNS($namespace, 'x:'.$elementName); } $prop->appendChild($element); @@ -224,49 +225,48 @@ class Client extends HTTP\Client { $url = $this->getAbsoluteUrl($url); $request = new HTTP\Request('PROPFIND', $url, [ - 'Depth' => $depth, - 'Content-Type' => 'application/xml' + 'Depth' => $depth, + 'Content-Type' => 'application/xml', ], $body); $response = $this->send($request); - if ((int)$response->getStatus() >= 400) { + if ((int) $response->getStatus() >= 400) { throw new HTTP\ClientHttpException($response); } $result = $this->parseMultiStatus($response->getBodyAsString()); // If depth was 0, we only return the top item - if ($depth === 0) { + if (0 === $depth) { reset($result); $result = current($result); + return isset($result[200]) ? $result[200] : []; } $newResult = []; foreach ($result as $href => $statusList) { - $newResult[$href] = isset($statusList[200]) ? $statusList[200] : []; - } return $newResult; - } /** - * Updates a list of properties on the server + * Updates a list of properties on the server. * * The list of properties must have clark-notation properties for the keys, * and the actual (string) value for the value. If the value is null, an * attempt is made to delete the property. * * @param string $url - * @param array $properties + * @param array $properties + * * @return bool */ - function propPatch($url, array $properties) { - + public function propPatch($url, array $properties) + { $propPatch = new Xml\Request\PropPatch(); $propPatch->properties = $properties; $xml = $this->xml->write( @@ -284,7 +284,7 @@ class Client extends HTTP\Client { throw new HTTP\ClientHttpException($response); } - if ($response->getStatus() === 207) { + if (207 === $response->getStatus()) { // If it's a 207, the request could still have failed, but the // information is hidden in the response body. $result = $this->parseMultiStatus($response->getBodyAsString()); @@ -292,26 +292,23 @@ class Client extends HTTP\Client { $errorProperties = []; foreach ($result as $href => $statusList) { foreach ($statusList as $status => $properties) { - if ($status >= 400) { foreach ($properties as $propName => $propValue) { - $errorProperties[] = $propName . ' (' . $status . ')'; + $errorProperties[] = $propName.' ('.$status.')'; } } - } } if ($errorProperties) { - - throw new HTTP\ClientException('PROPPATCH failed. The following properties errored: ' . implode(', ', $errorProperties)); + throw new HTTP\ClientException('PROPPATCH failed. The following properties errored: '.implode(', ', $errorProperties)); } } - return true; + return true; } /** - * Performs an HTTP options request + * Performs an HTTP options request. * * This method returns all the features from the 'DAV:' header as an array. * If there was no DAV header, or no contents this method will return an @@ -319,8 +316,8 @@ class Client extends HTTP\Client { * * @return array */ - function options() { - + public function options() + { $request = new HTTP\Request('OPTIONS', $this->getAbsoluteUrl('')); $response = $this->send($request); @@ -333,8 +330,8 @@ class Client extends HTTP\Client { foreach ($features as &$v) { $v = trim($v); } - return $features; + return $features; } /** @@ -359,24 +356,26 @@ class Client extends HTTP\Client { * Note that it is no longer recommended to use this method, use the send() * method instead. * - * @param string $method - * @param string $url + * @param string $method + * @param string $url * @param string|resource|null $body - * @param array $headers - * @throws ClientException, in case a curl error occurred. + * @param array $headers + * + * @throws clientException, in case a curl error occurred + * * @return array */ - function request($method, $url = '', $body = null, array $headers = []) { - + public function request($method, $url = '', $body = null, array $headers = []) + { $url = $this->getAbsoluteUrl($url); $response = $this->send(new HTTP\Request($method, $url, $headers, $body)); + return [ - 'body' => $response->getBodyAsString(), - 'statusCode' => (int)$response->getStatus(), - 'headers' => array_change_key_case($response->getHeaders()), + 'body' => $response->getBodyAsString(), + 'statusCode' => (int) $response->getStatus(), + 'headers' => array_change_key_case($response->getHeaders()), ]; - } /** @@ -384,19 +383,19 @@ class Client extends HTTP\Client { * urls are expanded based on the base url as given by the server. * * @param string $url + * * @return string */ - function getAbsoluteUrl($url) { - + public function getAbsoluteUrl($url) + { return Uri\resolve( $this->baseUri, $url ); - } /** - * Parses a WebDAV multistatus response body + * Parses a WebDAV multistatus response body. * * This method returns an array with the following structure * @@ -418,22 +417,19 @@ class Client extends HTTP\Client { * * * @param string $body xml body + * * @return array */ - function parseMultiStatus($body) { - + public function parseMultiStatus($body) + { $multistatus = $this->xml->expect('{DAV:}multistatus', $body); $result = []; foreach ($multistatus->getResponses() as $response) { - $result[$response->getHref()] = $response->getResponseProperties(); - } return $result; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Collection.php b/vendor/sabre/dav/lib/DAV/Collection.php index 35c90b5af..2728bb27e 100644 --- a/vendor/sabre/dav/lib/DAV/Collection.php +++ b/vendor/sabre/dav/lib/DAV/Collection.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * Collection class + * Collection class. * * This is a helper class, that should aid in getting collections classes setup. * Most of its methods are implemented, and throw permission denied exceptions @@ -12,8 +14,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Collection extends Node implements ICollection { - +abstract class Collection extends Node implements ICollection +{ /** * Returns a child object, by its name. * @@ -25,18 +27,19 @@ abstract class Collection extends Node implements ICollection { * exist. * * @param string $name + * * @throws Exception\NotFound + * * @return INode */ - function getChild($name) { - + public function getChild($name) + { foreach ($this->getChildren() as $child) { - - if ($child->getName() === $name) return $child; - + if ($child->getName() === $name) { + return $child; + } } - throw new Exception\NotFound('File not found: ' . $name); - + throw new Exception\NotFound('File not found: '.$name); } /** @@ -45,25 +48,22 @@ abstract class Collection extends Node implements ICollection { * It is generally a good idea to try and override this. Usually it can be optimized. * * @param string $name + * * @return bool */ - function childExists($name) { - + public function childExists($name) + { try { - $this->getChild($name); - return true; + return true; } catch (Exception\NotFound $e) { - return false; - } - } /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -82,28 +82,25 @@ abstract class Collection extends Node implements ICollection { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - - throw new Exception\Forbidden('Permission denied to create file (filename ' . $name . ')'); - + public function createFile($name, $data = null) + { + throw new Exception\Forbidden('Permission denied to create file (filename '.$name.')'); } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name + * * @throws Exception\Forbidden - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { throw new Exception\Forbidden('Permission denied to create directory'); - } - - } diff --git a/vendor/sabre/dav/lib/DAV/CorePlugin.php b/vendor/sabre/dav/lib/DAV/CorePlugin.php index 676cdd04a..ef1dfceb6 100644 --- a/vendor/sabre/dav/lib/DAV/CorePlugin.php +++ b/vendor/sabre/dav/lib/DAV/CorePlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\DAV\Exception\BadRequest; @@ -14,8 +16,8 @@ use Sabre\Xml\ParseException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CorePlugin extends ServerPlugin { - +class CorePlugin extends ServerPlugin +{ /** * Reference to server object. * @@ -24,34 +26,32 @@ class CorePlugin extends ServerPlugin { protected $server; /** - * Sets up the plugin + * Sets up the plugin. * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; - $server->on('method:GET', [$this, 'httpGet']); - $server->on('method:OPTIONS', [$this, 'httpOptions']); - $server->on('method:HEAD', [$this, 'httpHead']); - $server->on('method:DELETE', [$this, 'httpDelete']); - $server->on('method:PROPFIND', [$this, 'httpPropFind']); + $server->on('method:GET', [$this, 'httpGet']); + $server->on('method:OPTIONS', [$this, 'httpOptions']); + $server->on('method:HEAD', [$this, 'httpHead']); + $server->on('method:DELETE', [$this, 'httpDelete']); + $server->on('method:PROPFIND', [$this, 'httpPropFind']); $server->on('method:PROPPATCH', [$this, 'httpPropPatch']); - $server->on('method:PUT', [$this, 'httpPut']); - $server->on('method:MKCOL', [$this, 'httpMkcol']); - $server->on('method:MOVE', [$this, 'httpMove']); - $server->on('method:COPY', [$this, 'httpCopy']); - $server->on('method:REPORT', [$this, 'httpReport']); - - $server->on('propPatch', [$this, 'propPatchProtectedPropertyCheck'], 90); - $server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200); - $server->on('propFind', [$this, 'propFind']); - $server->on('propFind', [$this, 'propFindNode'], 120); - $server->on('propFind', [$this, 'propFindLate'], 200); - - $server->on('exception', [$this, 'exception']); - + $server->on('method:PUT', [$this, 'httpPut']); + $server->on('method:MKCOL', [$this, 'httpMkcol']); + $server->on('method:MOVE', [$this, 'httpMove']); + $server->on('method:COPY', [$this, 'httpCopy']); + $server->on('method:REPORT', [$this, 'httpReport']); + + $server->on('propPatch', [$this, 'propPatchProtectedPropertyCheck'], 90); + $server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200); + $server->on('propFind', [$this, 'propFind']); + $server->on('propFind', [$this, 'propFindNode'], 120); + $server->on('propFind', [$this, 'propFindLate'], 200); + + $server->on('exception', [$this, 'exception']); } /** @@ -62,34 +62,40 @@ class CorePlugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'core'; - } /** * This is the default implementation for the GET method. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $node = $this->server->tree->getNodeForPath($path); - if (!$node instanceof IFile) return; - - $body = $node->get(); + if (!$node instanceof IFile) { + return; + } - // Converting string into stream, if needed. - if (is_string($body)) { - $stream = fopen('php://temp', 'r+'); - fwrite($stream, $body); - rewind($stream); - $body = $stream; + if ('HEAD' === $request->getHeader('X-Sabre-Original-Method')) { + $body = ''; + } else { + $body = $node->get(); + + // Converting string into stream, if needed. + if (is_string($body)) { + $stream = fopen('php://temp', 'r+'); + fwrite($stream, $body); + rewind($stream); + $body = $stream; + } } /* @@ -105,14 +111,11 @@ class CorePlugin extends ServerPlugin { $httpHeaders['Content-Type'] = 'application/octet-stream'; } - if (isset($httpHeaders['Content-Length'])) { - $nodeSize = $httpHeaders['Content-Length']; // Need to unset Content-Length, because we'll handle that during figuring out the range unset($httpHeaders['Content-Length']); - } else { $nodeSize = null; } @@ -126,7 +129,6 @@ class CorePlugin extends ServerPlugin { // If ifRange is set, and range is specified, we first need to check // the precondition. if ($nodeSize && $range && $ifRange) { - // if IfRange is parsable as a date we'll treat it as a DateTime // otherwise, we must treat it as an etag. try { @@ -134,81 +136,87 @@ class CorePlugin extends ServerPlugin { // It's a date. We must check if the entity is modified since // the specified date. - if (!isset($httpHeaders['Last-Modified'])) $ignoreRangeHeader = true; - else { + if (!isset($httpHeaders['Last-Modified'])) { + $ignoreRangeHeader = true; + } else { $modified = new \DateTime($httpHeaders['Last-Modified']); - if ($modified > $ifRangeDate) $ignoreRangeHeader = true; + if ($modified > $ifRangeDate) { + $ignoreRangeHeader = true; + } } - } catch (\Exception $e) { - // It's an entity. We can do a simple comparison. - if (!isset($httpHeaders['ETag'])) $ignoreRangeHeader = true; - elseif ($httpHeaders['ETag'] !== $ifRange) $ignoreRangeHeader = true; + if (!isset($httpHeaders['ETag'])) { + $ignoreRangeHeader = true; + } elseif ($httpHeaders['ETag'] !== $ifRange) { + $ignoreRangeHeader = true; + } } } // We're only going to support HTTP ranges if the backend provided a filesize if (!$ignoreRangeHeader && $nodeSize && $range) { - // Determining the exact byte offsets if (!is_null($range[0])) { - $start = $range[0]; $end = $range[1] ? $range[1] : $nodeSize - 1; - if ($start >= $nodeSize) - throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $range[0] . ') exceeded the size of the entity (' . $nodeSize . ')'); - - if ($end < $start) throw new Exception\RequestedRangeNotSatisfiable('The end offset (' . $range[1] . ') is lower than the start offset (' . $range[0] . ')'); - if ($end >= $nodeSize) $end = $nodeSize - 1; - + if ($start >= $nodeSize) { + throw new Exception\RequestedRangeNotSatisfiable('The start offset ('.$range[0].') exceeded the size of the entity ('.$nodeSize.')'); + } + if ($end < $start) { + throw new Exception\RequestedRangeNotSatisfiable('The end offset ('.$range[1].') is lower than the start offset ('.$range[0].')'); + } + if ($end >= $nodeSize) { + $end = $nodeSize - 1; + } } else { - $start = $nodeSize - $range[1]; $end = $nodeSize - 1; - if ($start < 0) $start = 0; - + if ($start < 0) { + $start = 0; + } } // Streams may advertise themselves as seekable, but still not // actually allow fseek. We'll manually go forward in the stream // if fseek failed. - if (!stream_get_meta_data($body)['seekable'] || fseek($body, $start, SEEK_SET) === -1) { + if (!stream_get_meta_data($body)['seekable'] || -1 === fseek($body, $start, SEEK_SET)) { $consumeBlock = 8192; - for ($consumed = 0; $start - $consumed > 0;){ - if (feof($body)) throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $start . ') exceeded the size of the entity (' . $consumed . ')'); + for ($consumed = 0; $start - $consumed > 0;) { + if (feof($body)) { + throw new Exception\RequestedRangeNotSatisfiable('The start offset ('.$start.') exceeded the size of the entity ('.$consumed.')'); + } $consumed += strlen(fread($body, min($start - $consumed, $consumeBlock))); } } $response->setHeader('Content-Length', $end - $start + 1); - $response->setHeader('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $nodeSize); + $response->setHeader('Content-Range', 'bytes '.$start.'-'.$end.'/'.$nodeSize); $response->setStatus(206); $response->setBody($body); - } else { - - if ($nodeSize) $response->setHeader('Content-Length', $nodeSize); + if ($nodeSize) { + $response->setHeader('Content-Length', $nodeSize); + } $response->setStatus(200); $response->setBody($body); - } // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * HTTP OPTIONS + * HTTP OPTIONS. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpOptions(RequestInterface $request, ResponseInterface $response) { - + public function httpOptions(RequestInterface $request, ResponseInterface $response) + { $methods = $this->server->getAllowedMethods($request->getPath()); $response->setHeader('Allow', strtoupper(implode(', ', $methods))); @@ -227,31 +235,31 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * HTTP HEAD + * HTTP HEAD. * * This method is normally used to take a peak at a url, and only get the * HTTP response headers, without the body. This is used by clients to * determine if a remote file was changed, so they can use a local cached * version, instead of downloading it again * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpHead(RequestInterface $request, ResponseInterface $response) { - + public function httpHead(RequestInterface $request, ResponseInterface $response) + { // This is implemented by changing the HEAD request to a GET request, - // and dropping the response body. + // and telling the request handler that is doesn't need to create the body. $subRequest = clone $request; $subRequest->setMethod('GET'); + $subRequest->setHeader('X-Sabre-Original-Method', 'HEAD'); try { $this->server->invokeMethod($subRequest, $response, false); - $response->setBody(''); } catch (Exception\NotImplemented $e) { // Some clients may do HEAD requests on collections, however, GET // requests and HEAD requests _may_ not be defined on a collection, @@ -267,23 +275,23 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * HTTP Delete + * HTTP Delete. * * The HTTP delete method, deletes a given uri * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpDelete(RequestInterface $request, ResponseInterface $response) { - + public function httpDelete(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); - if (!$this->server->emit('beforeUnbind', [$path])) return false; + if (!$this->server->emit('beforeUnbind', [$path])) { + return false; + } $this->server->tree->delete($path); $this->server->emit('afterUnbind', [$path]); @@ -293,11 +301,10 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * WebDAV PROPFIND + * WebDAV PROPFIND. * * This WebDAV method requests information about an uri resource, or a list of resources * If a client wants to receive the properties for a single resource it will add an HTTP Depth: header with a 0 value @@ -308,12 +315,11 @@ class CorePlugin extends ServerPlugin { * * It has to return a HTTP 207 Multi-status status code * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpPropFind(RequestInterface $request, ResponseInterface $response) { - + public function httpPropFind(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $requestBody = $request->getBodyAsString(); @@ -321,7 +327,7 @@ class CorePlugin extends ServerPlugin { try { $propFindXml = $this->server->xml->expect('{DAV:}propfind', $requestBody); } catch (ParseException $e) { - throw new BadRequest($e->getMessage(), null, $e); + throw new BadRequest($e->getMessage(), 0, $e); } } else { $propFindXml = new Xml\Request\PropFind(); @@ -331,7 +337,9 @@ class CorePlugin extends ServerPlugin { $depth = $this->server->getHTTPDepth(1); // The only two options for the depth of a propfind is 0 or 1 - as long as depth infinity is not enabled - if (!$this->server->enablePropfindDepthInfinity && $depth != 0) $depth = 1; + if (!$this->server->enablePropfindDepthInfinity && 0 != $depth) { + $depth = 1; + } $newProperties = $this->server->getPropertiesIteratorForPath($path, $propFindXml->properties, $depth); @@ -350,7 +358,7 @@ class CorePlugin extends ServerPlugin { $response->setHeader('DAV', implode(', ', $features)); $prefer = $this->server->getHTTPPrefer(); - $minimal = $prefer['return'] === 'minimal'; + $minimal = 'minimal' === $prefer['return']; $data = $this->server->generateMultiStatus($newProperties, $minimal); $response->setBody($data); @@ -358,27 +366,27 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * WebDAV PROPPATCH + * WebDAV PROPPATCH. * * This method is called to update properties on a Node. The request is an XML body with all the mutations. * In this XML body it is specified which properties should be set/updated and/or deleted * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpPropPatch(RequestInterface $request, ResponseInterface $response) { - + public function httpPropPatch(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); try { $propPatch = $this->server->xml->expect('{DAV:}propertyupdate', $request->getBody()); } catch (ParseException $e) { - throw new BadRequest($e->getMessage(), null, $e); + throw new BadRequest($e->getMessage(), 0, $e); } $newProperties = $propPatch->properties; @@ -387,31 +395,27 @@ class CorePlugin extends ServerPlugin { $prefer = $this->server->getHTTPPrefer(); $response->setHeader('Vary', 'Brief,Prefer'); - if ($prefer['return'] === 'minimal') { - + if ('minimal' === $prefer['return']) { // If return-minimal is specified, we only have to check if the // request was successful, and don't need to return the // multi-status. $ok = true; foreach ($result as $prop => $code) { - if ((int)$code > 299) { + if ((int) $code > 299) { $ok = false; } } if ($ok) { - $response->setStatus(204); - return false; + return false; } - } $response->setStatus(207); $response->setHeader('Content-Type', 'application/xml; charset=utf-8'); - // Reorganizing the result for generateMultiStatus $multiStatus = []; foreach ($result as $propertyName => $code) { @@ -430,22 +434,22 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * HTTP PUT method + * HTTP PUT method. * * This HTTP method updates a file, or creates a new one. * * If a new resource was created, a 201 Created status code should be returned. If an existing resource is updated, it's a 204 No Content * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpPut(RequestInterface $request, ResponseInterface $response) { - + public function httpPut(RequestInterface $request, ResponseInterface $response) + { $body = $request->getBodyAsStream(); $path = $request->getPath(); @@ -463,7 +467,6 @@ class CorePlugin extends ServerPlugin { // Intercepting the Finder problem if (($expected = $request->getHeader('X-Expected-Entity-Length')) && $expected > 0) { - /* Many webservers will not cooperate well with Finder PUT requests, because it uses 'Chunked' transfer encoding for the request body. @@ -487,7 +490,7 @@ class CorePlugin extends ServerPlugin { // Only reading first byte $firstByte = fread($body, 1); - if (strlen($firstByte) !== 1) { + if (1 !== strlen($firstByte)) { throw new Exception\Forbidden('This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.'); } @@ -500,26 +503,25 @@ class CorePlugin extends ServerPlugin { rewind($newBody); $body = $newBody; - } if ($this->server->tree->nodeExists($path)) { - $node = $this->server->tree->getNodeForPath($path); // If the node is a collection, we'll deny it - if (!($node instanceof IFile)) throw new Exception\Conflict('PUT is not allowed on non-files.'); - + if (!($node instanceof IFile)) { + throw new Exception\Conflict('PUT is not allowed on non-files.'); + } if (!$this->server->updateFile($path, $body, $etag)) { return false; } $response->setHeader('Content-Length', '0'); - if ($etag) $response->setHeader('ETag', $etag); + if ($etag) { + $response->setHeader('ETag', $etag); + } $response->setStatus(204); - } else { - $etag = null; // If we got here, the resource didn't exist yet. if (!$this->server->createFile($path, $body, $etag)) { @@ -528,61 +530,55 @@ class CorePlugin extends ServerPlugin { } $response->setHeader('Content-Length', '0'); - if ($etag) $response->setHeader('ETag', $etag); + if ($etag) { + $response->setHeader('ETag', $etag); + } $response->setStatus(201); - } // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } - /** - * WebDAV MKCOL + * WebDAV MKCOL. * * The MKCOL method is used to create a new collection (directory) on the server * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpMkcol(RequestInterface $request, ResponseInterface $response) { - + public function httpMkcol(RequestInterface $request, ResponseInterface $response) + { $requestBody = $request->getBodyAsString(); $path = $request->getPath(); if ($requestBody) { - $contentType = $request->getHeader('Content-Type'); - if (strpos($contentType, 'application/xml') !== 0 && strpos($contentType, 'text/xml') !== 0) { - + if (null === $contentType || (0 !== strpos($contentType, 'application/xml') && 0 !== strpos($contentType, 'text/xml'))) { // We must throw 415 for unsupported mkcol bodies throw new Exception\UnsupportedMediaType('The request body for the MKCOL request must have an xml Content-Type'); - } try { $mkcol = $this->server->xml->expect('{DAV:}mkcol', $requestBody); } catch (\Sabre\Xml\ParseException $e) { - throw new Exception\BadRequest($e->getMessage(), null, $e); + throw new Exception\BadRequest($e->getMessage(), 0, $e); } $properties = $mkcol->getProperties(); - if (!isset($properties['{DAV:}resourcetype'])) + if (!isset($properties['{DAV:}resourcetype'])) { throw new Exception\BadRequest('The mkcol request must include a {DAV:}resourcetype property'); - + } $resourceType = $properties['{DAV:}resourcetype']->getValue(); unset($properties['{DAV:}resourcetype']); - } else { - $properties = []; $resourceType = ['{DAV:}collection']; - } $mkcol = new MkCol($resourceType, $properties); @@ -596,7 +592,6 @@ class CorePlugin extends ServerPlugin { $response->setBody( $this->server->generateMultiStatus([$result]) ); - } else { $response->setHeader('Content-Length', '0'); $response->setStatus(201); @@ -605,38 +600,42 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * WebDAV HTTP MOVE method + * WebDAV HTTP MOVE method. * * This method moves one uri to a different uri. A lot of the actual request processing is done in getCopyMoveInfo * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpMove(RequestInterface $request, ResponseInterface $response) { - + public function httpMove(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $moveInfo = $this->server->getCopyAndMoveInfo($request); if ($moveInfo['destinationExists']) { - - if (!$this->server->emit('beforeUnbind', [$moveInfo['destination']])) return false; - + if (!$this->server->emit('beforeUnbind', [$moveInfo['destination']])) { + return false; + } + } + if (!$this->server->emit('beforeUnbind', [$path])) { + return false; + } + if (!$this->server->emit('beforeBind', [$moveInfo['destination']])) { + return false; + } + if (!$this->server->emit('beforeMove', [$path, $moveInfo['destination']])) { + return false; } - if (!$this->server->emit('beforeUnbind', [$path])) return false; - if (!$this->server->emit('beforeBind', [$moveInfo['destination']])) return false; - if (!$this->server->emit('beforeMove', [$path, $moveInfo['destination']])) return false; if ($moveInfo['destinationExists']) { - $this->server->tree->delete($moveInfo['destination']); $this->server->emit('afterUnbind', [$moveInfo['destination']]); - } $this->server->tree->move($path, $moveInfo['destination']); @@ -656,28 +655,32 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * WebDAV HTTP COPY method + * WebDAV HTTP COPY method. * * This method copies one uri to a different uri, and works much like the MOVE request * A lot of the actual request processing is done in getCopyMoveInfo * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpCopy(RequestInterface $request, ResponseInterface $response) { - + public function httpCopy(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $copyInfo = $this->server->getCopyAndMoveInfo($request); - if (!$this->server->emit('beforeBind', [$copyInfo['destination']])) return false; + if (!$this->server->emit('beforeBind', [$copyInfo['destination']])) { + return false; + } if ($copyInfo['destinationExists']) { - if (!$this->server->emit('beforeUnbind', [$copyInfo['destination']])) return false; + if (!$this->server->emit('beforeUnbind', [$copyInfo['destination']])) { + return false; + } $this->server->tree->delete($copyInfo['destination']); } @@ -691,22 +694,21 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - - } /** - * HTTP REPORT method implementation + * HTTP REPORT method implementation. * * Although the REPORT method is not part of the standard WebDAV spec (it's from rfc3253) * It's used in a lot of extensions, so it made sense to implement it into the core. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpReport(RequestInterface $request, ResponseInterface $response) { - + public function httpReport(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $result = $this->server->xml->parse( @@ -716,16 +718,13 @@ class CorePlugin extends ServerPlugin { ); if ($this->server->emit('report', [$rootElementName, $result, $path])) { - // If emit returned true, it means the report was not supported throw new Exception\ReportNotSupported(); - } // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** @@ -734,12 +733,11 @@ class CorePlugin extends ServerPlugin { * Here we check if a user attempted to update a protected property and * ensure that the process fails if this is the case. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatchProtectedPropertyCheck($path, PropPatch $propPatch) { - + public function propPatchProtectedPropertyCheck($path, PropPatch $propPatch) + { // Comparing the mutation list to the list of protected properties. $mutations = $propPatch->getMutations(); @@ -751,7 +749,6 @@ class CorePlugin extends ServerPlugin { if ($protected) { $propPatch->setResultCode($protected, 403); } - } /** @@ -760,19 +757,17 @@ class CorePlugin extends ServerPlugin { * Here we check if a node implements IProperties and let the node handle * updating of (some) properties. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatchNodeUpdate($path, PropPatch $propPatch) { - + public function propPatchNodeUpdate($path, PropPatch $propPatch) + { // This should trigger a 404 if the node doesn't exist. $node = $this->server->tree->getNodeForPath($path); if ($node instanceof IProperties) { $node->propPatch($propPatch); } - } /** @@ -781,12 +776,11 @@ class CorePlugin extends ServerPlugin { * Here we add all the default properties. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - - $propFind->handle('{DAV:}getlastmodified', function() use ($node) { + public function propFind(PropFind $propFind, INode $node) + { + $propFind->handle('{DAV:}getlastmodified', function () use ($node) { $lm = $node->getLastModified(); if ($lm) { return new Xml\Property\GetLastModified($lm); @@ -801,34 +795,36 @@ class CorePlugin extends ServerPlugin { if ($node instanceof IQuota) { $quotaInfo = null; - $propFind->handle('{DAV:}quota-used-bytes', function() use (&$quotaInfo, $node) { + $propFind->handle('{DAV:}quota-used-bytes', function () use (&$quotaInfo, $node) { $quotaInfo = $node->getQuotaInfo(); + return $quotaInfo[0]; }); - $propFind->handle('{DAV:}quota-available-bytes', function() use (&$quotaInfo, $node) { + $propFind->handle('{DAV:}quota-available-bytes', function () use (&$quotaInfo, $node) { if (!$quotaInfo) { $quotaInfo = $node->getQuotaInfo(); } + return $quotaInfo[1]; }); } - $propFind->handle('{DAV:}supported-report-set', function() use ($propFind) { + $propFind->handle('{DAV:}supported-report-set', function () use ($propFind) { $reports = []; foreach ($this->server->getPlugins() as $plugin) { $reports = array_merge($reports, $plugin->getSupportedReportSet($propFind->getPath())); } + return new Xml\Property\SupportedReportSet($reports); }); - $propFind->handle('{DAV:}resourcetype', function() use ($node) { + $propFind->handle('{DAV:}resourcetype', function () use ($node) { return new Xml\Property\ResourceType($this->server->getResourceTypeForNode($node)); }); - $propFind->handle('{DAV:}supported-method-set', function() use ($propFind) { + $propFind->handle('{DAV:}supported-method-set', function () use ($propFind) { return new Xml\Property\SupportedMethodSet( $this->server->getAllowedMethods($propFind->getPath()) ); }); - } /** @@ -838,20 +834,16 @@ class CorePlugin extends ServerPlugin { * populate the result. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFindNode(PropFind $propFind, INode $node) { - + public function propFindNode(PropFind $propFind, INode $node) + { if ($node instanceof IProperties && $propertyNames = $propFind->get404Properties()) { - $nodeProperties = $node->getProperties($propertyNames); foreach ($nodeProperties as $propertyName => $propertyValue) { $propFind->set($propertyName, $propertyValue, 200); } - } - } /** @@ -861,17 +853,17 @@ class CorePlugin extends ServerPlugin { * want other systems to first have a chance to handle the properties. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFindLate(PropFind $propFind, INode $node) { - - $propFind->handle('{http://calendarserver.org/ns/}getctag', function() use ($propFind) { - + public function propFindLate(PropFind $propFind, INode $node) + { + $propFind->handle('{http://calendarserver.org/ns/}getctag', function () use ($propFind) { // If we already have a sync-token from the current propFind // request, we can re-use that. $val = $propFind->get('{http://sabredav.org/ns}sync-token'); - if ($val) return $val; + if ($val) { + return $val; + } $val = $propFind->get('{DAV:}sync-token'); if ($val && is_scalar($val)) { @@ -899,9 +891,7 @@ class CorePlugin extends ServerPlugin { return substr($val->getHref(), strlen(Sync\Plugin::SYNCTOKEN_PREFIX)); } } - }); - } /** @@ -909,8 +899,8 @@ class CorePlugin extends ServerPlugin { * * @param Exception $e */ - function exception($e) { - + public function exception($e) + { $logLevel = \Psr\Log\LogLevel::CRITICAL; if ($e instanceof \Sabre\DAV\Exception) { // If it's a standard sabre/dav exception, it means we have a http @@ -947,13 +937,12 @@ class CorePlugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'The Core plugin provides a lot of the basic functionality required by WebDAV, such as a default implementation for all HTTP and WebDAV methods.', - 'link' => null, + 'link' => null, ]; - } } diff --git a/vendor/sabre/dav/lib/DAV/Exception.php b/vendor/sabre/dav/lib/DAV/Exception.php index 14f5bab2a..e1d990623 100644 --- a/vendor/sabre/dav/lib/DAV/Exception.php +++ b/vendor/sabre/dav/lib/DAV/Exception.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -15,29 +17,26 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Exception extends \Exception { - +class Exception extends \Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 500; - } /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param Server $server + * @param Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(Server $server, \DOMElement $errorNode) { - - + public function serialize(Server $server, \DOMElement $errorNode) + { } /** @@ -46,12 +45,11 @@ class Exception extends \Exception { * The headers must be returned as an array. * * @param Server $server + * * @return array */ - function getHTTPHeaders(Server $server) { - + public function getHTTPHeaders(Server $server) + { return []; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/BadRequest.php b/vendor/sabre/dav/lib/DAV/Exception/BadRequest.php index c21f493da..569c63ba0 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/BadRequest.php +++ b/vendor/sabre/dav/lib/DAV/Exception/BadRequest.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * BadRequest + * BadRequest. * * The BadRequest is thrown when the user submitted an invalid HTTP request * BadRequest @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class BadRequest extends DAV\Exception { - +class BadRequest extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 400; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/Conflict.php b/vendor/sabre/dav/lib/DAV/Exception/Conflict.php index 4190e6082..2ec227feb 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/Conflict.php +++ b/vendor/sabre/dav/lib/DAV/Exception/Conflict.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * Conflict + * Conflict. * * A 409 Conflict is thrown when a user tried to make a directory over an existing * file or in a parent directory that doesn't exist. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Conflict extends DAV\Exception { - +class Conflict extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 409; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/ConflictingLock.php b/vendor/sabre/dav/lib/DAV/Exception/ConflictingLock.php index b2d2746c5..c1a4914ed 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/ConflictingLock.php +++ b/vendor/sabre/dav/lib/DAV/Exception/ConflictingLock.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * ConflictingLock + * ConflictingLock. * * Similar to the Locked exception, this exception thrown when a LOCK request * was made, on a resource which was already locked @@ -14,23 +16,20 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ConflictingLock extends Locked { - +class ConflictingLock extends Locked +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { if ($this->lock) { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:no-conflicting-lock'); $errorNode->appendChild($error); $error->appendChild($errorNode->ownerDocument->createElementNS('DAV:', 'd:href', $this->lock->uri)); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/Forbidden.php b/vendor/sabre/dav/lib/DAV/Exception/Forbidden.php index 77df7ca9e..2f882c396 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/Forbidden.php +++ b/vendor/sabre/dav/lib/DAV/Exception/Forbidden.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * Forbidden + * Forbidden. * * This exception is thrown whenever a user tries to do an operation he's not allowed to * @@ -13,17 +15,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Forbidden extends DAV\Exception { - +class Forbidden extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 403; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/InsufficientStorage.php b/vendor/sabre/dav/lib/DAV/Exception/InsufficientStorage.php index 96e1acc50..fe6e1268c 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/InsufficientStorage.php +++ b/vendor/sabre/dav/lib/DAV/Exception/InsufficientStorage.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * InsufficientStorage + * InsufficientStorage. * * This Exception can be thrown, when for example a harddisk is full or a quota is exceeded * @@ -13,17 +15,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InsufficientStorage extends DAV\Exception { - +class InsufficientStorage extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 507; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/InvalidResourceType.php b/vendor/sabre/dav/lib/DAV/Exception/InvalidResourceType.php index 6324d9f3a..99baeb8bc 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/InvalidResourceType.php +++ b/vendor/sabre/dav/lib/DAV/Exception/InvalidResourceType.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; /** - * InvalidResourceType + * InvalidResourceType. * * This exception is thrown when the user tried to create a new collection, with * a special resourcetype value that was not recognized by the server. @@ -14,20 +16,17 @@ namespace Sabre\DAV\Exception; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InvalidResourceType extends Forbidden { - +class InvalidResourceType extends Forbidden +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * * @param \Sabre\DAV\Server $server - * @param \DOMElement $errorNode - * @return void + * @param \DOMElement $errorNode */ - function serialize(\Sabre\DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(\Sabre\DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:valid-resourcetype'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php b/vendor/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php index 51a253b29..6c5f1c435 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php +++ b/vendor/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * InvalidSyncToken + * InvalidSyncToken. * * This exception is emited for the {DAV:}valid-sync-token pre-condition, as * defined in rfc6578, section 3.2. @@ -19,20 +21,17 @@ use Sabre\DAV; * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InvalidSyncToken extends Forbidden { - +class InvalidSyncToken extends Forbidden +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:valid-sync-token'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/LengthRequired.php b/vendor/sabre/dav/lib/DAV/Exception/LengthRequired.php index 989718558..9d26fcb10 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/LengthRequired.php +++ b/vendor/sabre/dav/lib/DAV/Exception/LengthRequired.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * LengthRequired + * LengthRequired. * * This exception is thrown when a request was made that required a * Content-Length header, but did not contain one. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class LengthRequired extends DAV\Exception { - +class LengthRequired extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 411; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/LockTokenMatchesRequestUri.php b/vendor/sabre/dav/lib/DAV/Exception/LockTokenMatchesRequestUri.php index 5f8c31868..1c7402384 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/LockTokenMatchesRequestUri.php +++ b/vendor/sabre/dav/lib/DAV/Exception/LockTokenMatchesRequestUri.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * LockTokenMatchesRequestUri + * LockTokenMatchesRequestUri. * * This exception is thrown by UNLOCK if a supplied lock-token is invalid * @@ -13,29 +15,25 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class LockTokenMatchesRequestUri extends Conflict { - +class LockTokenMatchesRequestUri extends Conflict +{ /** - * Creates the exception + * Creates the exception. */ - function __construct() { - - $this->message = 'The locktoken supplied does not match any locks on this entity'; - + public function __construct() + { + parent::__construct('The locktoken supplied does not match any locks on this entity'); } /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:lock-token-matches-request-uri'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/Locked.php b/vendor/sabre/dav/lib/DAV/Exception/Locked.php index 8176db46e..632bafc60 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/Locked.php +++ b/vendor/sabre/dav/lib/DAV/Exception/Locked.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * Locked + * Locked. * * The 423 is thrown when a client tried to access a resource that was locked, without supplying a valid lock token * @@ -13,49 +15,48 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Locked extends DAV\Exception { - +class Locked extends DAV\Exception +{ /** - * Lock information + * Lock information. * - * @var Sabre\DAV\Locks\LockInfo + * @var \Sabre\DAV\Locks\LockInfo */ protected $lock; /** - * Creates the exception + * Creates the exception. * * A LockInfo object should be passed if the user should be informed * which lock actually has the file locked. * * @param DAV\Locks\LockInfo $lock */ - function __construct(DAV\Locks\LockInfo $lock = null) { + public function __construct(DAV\Locks\LockInfo $lock = null) + { + parent::__construct(); $this->lock = $lock; - } /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 423; - } /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { if ($this->lock) { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:lock-token-submitted'); $errorNode->appendChild($error); @@ -66,7 +67,5 @@ class Locked extends DAV\Exception { $href ); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php b/vendor/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php index 30c1c2553..a3d9c56f2 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php +++ b/vendor/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * MethodNotAllowed + * MethodNotAllowed. * * The 405 is thrown when a client tried to create a directory on an already existing directory * @@ -13,17 +15,16 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MethodNotAllowed extends DAV\Exception { - +class MethodNotAllowed extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 405; - } /** @@ -32,16 +33,15 @@ class MethodNotAllowed extends DAV\Exception { * The headers must be returned as an array. * * @param \Sabre\DAV\Server $server + * * @return array */ - function getHTTPHeaders(\Sabre\DAV\Server $server) { - + public function getHTTPHeaders(\Sabre\DAV\Server $server) + { $methods = $server->getAllowedMethods($server->getRequestUri()); return [ 'Allow' => strtoupper(implode(', ', $methods)), ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/NotAuthenticated.php b/vendor/sabre/dav/lib/DAV/Exception/NotAuthenticated.php index e69a60c75..0a5ba9b5a 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/NotAuthenticated.php +++ b/vendor/sabre/dav/lib/DAV/Exception/NotAuthenticated.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * NotAuthenticated + * NotAuthenticated. * * This exception is thrown when the client did not provide valid * authentication credentials. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotAuthenticated extends DAV\Exception { - +class NotAuthenticated extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 401; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/NotFound.php b/vendor/sabre/dav/lib/DAV/Exception/NotFound.php index b0397446d..9cf837074 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/NotFound.php +++ b/vendor/sabre/dav/lib/DAV/Exception/NotFound.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * NotFound + * NotFound. * * This Exception is thrown when a Node couldn't be found. It returns HTTP error code 404 * @@ -13,17 +15,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotFound extends DAV\Exception { - +class NotFound extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 404; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/NotImplemented.php b/vendor/sabre/dav/lib/DAV/Exception/NotImplemented.php index 68f309222..cebb83363 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/NotImplemented.php +++ b/vendor/sabre/dav/lib/DAV/Exception/NotImplemented.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * NotImplemented + * NotImplemented. * * This exception is thrown when the client tried to call an unsupported HTTP method or other feature * @@ -13,17 +15,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotImplemented extends DAV\Exception { - +class NotImplemented extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 501; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/PaymentRequired.php b/vendor/sabre/dav/lib/DAV/Exception/PaymentRequired.php index 43e17344a..d237f906b 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/PaymentRequired.php +++ b/vendor/sabre/dav/lib/DAV/Exception/PaymentRequired.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * Payment Required + * Payment Required. * * The PaymentRequired exception may be thrown in a case where a user must pay * to access a certain resource or operation. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PaymentRequired extends DAV\Exception { - +class PaymentRequired extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 402; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/PreconditionFailed.php b/vendor/sabre/dav/lib/DAV/Exception/PreconditionFailed.php index 550360e5a..20d8a2a30 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/PreconditionFailed.php +++ b/vendor/sabre/dav/lib/DAV/Exception/PreconditionFailed.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * PreconditionFailed + * PreconditionFailed. * * This exception is normally thrown when a client submitted a conditional request, * like for example an If, If-None-Match or If-Match header, which caused the HTTP @@ -15,8 +17,8 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PreconditionFailed extends DAV\Exception { - +class PreconditionFailed extends DAV\Exception +{ /** * When this exception is thrown, the header-name might be set. * @@ -28,44 +30,39 @@ class PreconditionFailed extends DAV\Exception { public $header = null; /** - * Create the exception + * Create the exception. * * @param string $message * @param string $header */ - function __construct($message, $header = null) { - + public function __construct($message, $header = null) + { parent::__construct($message); $this->header = $header; - } /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 412; - } /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { if ($this->header) { $prop = $errorNode->ownerDocument->createElement('s:header'); $prop->nodeValue = $this->header; $errorNode->appendChild($prop); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/ReportNotSupported.php b/vendor/sabre/dav/lib/DAV/Exception/ReportNotSupported.php index a83695627..cecfec12d 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/ReportNotSupported.php +++ b/vendor/sabre/dav/lib/DAV/Exception/ReportNotSupported.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * ReportNotSupported + * ReportNotSupported. * * This exception is thrown when the client requested an unknown report through the REPORT method * @@ -13,20 +15,17 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ReportNotSupported extends UnsupportedMediaType { - +class ReportNotSupported extends UnsupportedMediaType +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:supported-report'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php b/vendor/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php index c8ccfc062..6ccb5b8c8 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php +++ b/vendor/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * RequestedRangeNotSatisfiable + * RequestedRangeNotSatisfiable. * * This exception is normally thrown when the user * request a range that is out of the entity bounds. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class RequestedRangeNotSatisfiable extends DAV\Exception { - +class RequestedRangeNotSatisfiable extends DAV\Exception +{ /** - * returns the http statuscode for this exception + * returns the http statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 416; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/ServiceUnavailable.php b/vendor/sabre/dav/lib/DAV/Exception/ServiceUnavailable.php index 31df606e2..43c995c9c 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/ServiceUnavailable.php +++ b/vendor/sabre/dav/lib/DAV/Exception/ServiceUnavailable.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * ServiceUnavailable + * ServiceUnavailable. * * This exception is thrown in case the service * is currently not available (e.g. down for maintenance). @@ -14,17 +16,15 @@ use Sabre\DAV; * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ServiceUnavailable extends DAV\Exception { - +class ServiceUnavailable extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 503; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/TooManyMatches.php b/vendor/sabre/dav/lib/DAV/Exception/TooManyMatches.php index d0f0f84e8..7dbe878b9 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/TooManyMatches.php +++ b/vendor/sabre/dav/lib/DAV/Exception/TooManyMatches.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * TooManyMatches + * TooManyMatches. * * This exception is emited for the {DAV:}number-of-matches-within-limits * post-condition, as defined in rfc6578, section 3.2. @@ -19,20 +21,17 @@ use Sabre\DAV; * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @license http://sabre.io/license/ Modified BSD License */ -class TooManyMatches extends Forbidden { - +class TooManyMatches extends Forbidden +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:number-of-matches-within-limits'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php b/vendor/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php index f3d92842d..bc9da30da 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php +++ b/vendor/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * UnSupportedMediaType + * UnSupportedMediaType. * * The 415 Unsupported Media Type status code is generally sent back when the client * tried to call an HTTP method, with a body the server didn't understand @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class UnsupportedMediaType extends DAV\Exception { - +class UnsupportedMediaType extends DAV\Exception +{ /** - * returns the http statuscode for this exception + * returns the http statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 415; - } - } diff --git a/vendor/sabre/dav/lib/DAV/FS/Directory.php b/vendor/sabre/dav/lib/DAV/FS/Directory.php index 362f7a411..047692294 100644 --- a/vendor/sabre/dav/lib/DAV/FS/Directory.php +++ b/vendor/sabre/dav/lib/DAV/FS/Directory.php @@ -1,20 +1,22 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FS; use Sabre\DAV; /** - * Directory class + * Directory class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Directory extends Node implements DAV\ICollection, DAV\IQuota { - +class Directory extends Node implements DAV\ICollection, DAV\IQuota +{ /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -33,67 +35,63 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - - $newPath = $this->path . '/' . $name; + public function createFile($name, $data = null) + { + $newPath = $this->path.'/'.$name; file_put_contents($newPath, $data); clearstatcache(true, $newPath); - } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name - * @return void */ - function createDirectory($name) { - - $newPath = $this->path . '/' . $name; + public function createDirectory($name) + { + $newPath = $this->path.'/'.$name; mkdir($newPath); clearstatcache(true, $newPath); - } /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * This method must throw DAV\Exception\NotFound if the node does not * exist. * * @param string $name + * * @throws DAV\Exception\NotFound + * * @return DAV\INode */ - function getChild($name) { - - $path = $this->path . '/' . $name; - - if (!file_exists($path)) throw new DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); + public function getChild($name) + { + $path = $this->path.'/'.$name; + if (!file_exists($path)) { + throw new DAV\Exception\NotFound('File with name '.$path.' could not be located'); + } if (is_dir($path)) { - return new self($path); - } else { - return new File($path); - } - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return DAV\INode[] */ - function getChildren() { - + public function getChildren() + { $nodes = []; $iterator = new \FilesystemIterator( $this->path, @@ -101,51 +99,49 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota { | \FilesystemIterator::SKIP_DOTS ); foreach ($iterator as $entry) { - $nodes[] = $this->getChild($entry->getFilename()); - } - return $nodes; + return $nodes; } /** * Checks if a child exists. * * @param string $name + * * @return bool */ - function childExists($name) { + public function childExists($name) + { + $path = $this->path.'/'.$name; - $path = $this->path . '/' . $name; return file_exists($path); - } /** - * Deletes all files in this directory, and then itself - * - * @return void + * Deletes all files in this directory, and then itself. */ - function delete() { - - foreach ($this->getChildren() as $child) $child->delete(); + public function delete() + { + foreach ($this->getChildren() as $child) { + $child->delete(); + } rmdir($this->path); - } /** - * Returns available diskspace information + * Returns available diskspace information. * * @return array */ - function getQuotaInfo() { + public function getQuotaInfo() + { $absolute = realpath($this->path); + return [ disk_total_space($absolute) - disk_free_space($absolute), - disk_free_space($absolute) + disk_free_space($absolute), ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/FS/File.php b/vendor/sabre/dav/lib/DAV/FS/File.php index 4fc5af057..b78a80138 100644 --- a/vendor/sabre/dav/lib/DAV/FS/File.php +++ b/vendor/sabre/dav/lib/DAV/FS/File.php @@ -1,66 +1,61 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FS; use Sabre\DAV; /** - * File class + * File class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends Node implements DAV\IFile { - +class File extends Node implements DAV\IFile +{ /** - * Updates the data + * Updates the data. * * @param resource $data - * @return void */ - function put($data) { - + public function put($data) + { file_put_contents($this->path, $data); clearstatcache(true, $this->path); - } /** - * Returns the data + * Returns the data. * * @return resource */ - function get() { - + public function get() + { return fopen($this->path, 'r'); - } /** - * Delete the current file - * - * @return void + * Delete the current file. */ - function delete() { - + public function delete() + { unlink($this->path); - } /** - * Returns the size of the node, in bytes + * Returns the size of the node, in bytes. * * @return int */ - function getSize() { - + public function getSize() + { return filesize($this->path); - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. @@ -69,27 +64,24 @@ class File extends Node implements DAV\IFile { * * @return mixed */ - function getETag() { - - return '"' . sha1( - fileinode($this->path) . - filesize($this->path) . + public function getETag() + { + return '"'.sha1( + fileinode($this->path). + filesize($this->path). filemtime($this->path) - ) . '"'; - + ).'"'; } /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream * * @return mixed */ - function getContentType() { - + public function getContentType() + { return null; - } - } diff --git a/vendor/sabre/dav/lib/DAV/FS/Node.php b/vendor/sabre/dav/lib/DAV/FS/Node.php index 424718f96..32aa74755 100644 --- a/vendor/sabre/dav/lib/DAV/FS/Node.php +++ b/vendor/sabre/dav/lib/DAV/FS/Node.php @@ -1,12 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FS; -use Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\DAV\Exception\Forbidden; +use Sabre\DAV\INode; +use Sabre\Uri; /** - * Base node-class + * Base node-class. * * The node class implements the method used by both the File and the Directory classes * @@ -14,67 +17,80 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Node implements DAV\INode { - +abstract class Node implements INode +{ /** - * The path to the current node + * The path to the current node. * * @var string */ protected $path; /** - * Sets up the node, expects a full path name + * The overridden name of the node. * - * @param string $path + * @var string */ - function __construct($path) { + protected $overrideName; + /** + * Sets up the node, expects a full path name. + * + * If $overrideName is set, this node shows up in the tree under a + * different name. In this case setName() will be disabled. + * + * @param string $path + * @param string $overrideName + */ + public function __construct($path, $overrideName = null) + { $this->path = $path; - + $this->overrideName = $overrideName; } - - /** - * Returns the name of the node + * Returns the name of the node. * * @return string */ - function getName() { + public function getName() + { + if ($this->overrideName) { + return $this->overrideName; + } - list(, $name) = URLUtil::splitPath($this->path); - return $name; + list(, $name) = Uri\split($this->path); + return $name; } /** - * Renames the node + * Renames the node. * * @param string $name The new name - * @return void */ - function setName($name) { + public function setName($name) + { + if ($this->overrideName) { + throw new Forbidden('This node cannot be renamed'); + } - list($parentPath, ) = URLUtil::splitPath($this->path); - list(, $newName) = URLUtil::splitPath($name); + list($parentPath) = Uri\split($this->path); + list(, $newName) = Uri\split($name); - $newPath = $parentPath . '/' . $newName; + $newPath = $parentPath.'/'.$newName; rename($this->path, $newPath); $this->path = $newPath; - } /** - * Returns the last modification time, as a unix timestamp + * Returns the last modification time, as a unix timestamp. * * @return int */ - function getLastModified() { - + public function getLastModified() + { return filemtime($this->path); - } - } diff --git a/vendor/sabre/dav/lib/DAV/FSExt/Directory.php b/vendor/sabre/dav/lib/DAV/FSExt/Directory.php index dd5f992db..d6aea0094 100644 --- a/vendor/sabre/dav/lib/DAV/FSExt/Directory.php +++ b/vendor/sabre/dav/lib/DAV/FSExt/Directory.php @@ -1,21 +1,23 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FSExt; use Sabre\DAV; use Sabre\DAV\FS\Node; /** - * Directory class + * Directory class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTarget { - +class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTarget +{ /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -34,94 +36,97 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - + public function createFile($name, $data = null) + { // We're not allowing dots - if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..'); - $newPath = $this->path . '/' . $name; + if ('.' == $name || '..' == $name) { + throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + } + $newPath = $this->path.'/'.$name; file_put_contents($newPath, $data); clearstatcache(true, $newPath); - return '"' . sha1( - fileinode($newPath) . - filesize($newPath) . + return '"'.sha1( + fileinode($newPath). + filesize($newPath). filemtime($newPath) - ) . '"'; - + ).'"'; } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { // We're not allowing dots - if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..'); - $newPath = $this->path . '/' . $name; + if ('.' == $name || '..' == $name) { + throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + } + $newPath = $this->path.'/'.$name; mkdir($newPath); clearstatcache(true, $newPath); - } /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * This method must throw Sabre\DAV\Exception\NotFound if the node does not * exist. * * @param string $name + * * @throws DAV\Exception\NotFound + * * @return DAV\INode */ - function getChild($name) { - - $path = $this->path . '/' . $name; - - if (!file_exists($path)) throw new DAV\Exception\NotFound('File could not be located'); - if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + public function getChild($name) + { + $path = $this->path.'/'.$name; + if (!file_exists($path)) { + throw new DAV\Exception\NotFound('File could not be located'); + } + if ('.' == $name || '..' == $name) { + throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + } if (is_dir($path)) { - return new self($path); - } else { - return new File($path); - } - } /** * Checks if a child exists. * * @param string $name + * * @return bool */ - function childExists($name) { - - if ($name == '.' || $name == '..') + public function childExists($name) + { + if ('.' == $name || '..' == $name) { throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + } + $path = $this->path.'/'.$name; - $path = $this->path . '/' . $name; return file_exists($path); - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return DAV\INode[] */ - function getChildren() { - + public function getChildren() + { $nodes = []; $iterator = new \FilesystemIterator( $this->path, @@ -130,44 +135,43 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa ); foreach ($iterator as $entry) { - $nodes[] = $this->getChild($entry->getFilename()); - } - return $nodes; + return $nodes; } /** - * Deletes all files in this directory, and then itself + * Deletes all files in this directory, and then itself. * * @return bool */ - function delete() { - + public function delete() + { // Deleting all children - foreach ($this->getChildren() as $child) $child->delete(); + foreach ($this->getChildren() as $child) { + $child->delete(); + } // Removing the directory itself rmdir($this->path); return true; - } /** - * Returns available diskspace information + * Returns available diskspace information. * * @return array */ - function getQuotaInfo() { - + public function getQuotaInfo() + { $total = disk_total_space(realpath($this->path)); $free = disk_free_space(realpath($this->path)); return [ $total - $free, - $free + $free, ]; } @@ -186,13 +190,14 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa * the move itself. If you return true from this function, the assumption * is that the move was successful. * - * @param string $targetName New local file/collection name. - * @param string $sourcePath Full path to source node + * @param string $targetName new local file/collection name + * @param string $sourcePath Full path to source node * @param DAV\INode $sourceNode Source node itself + * * @return bool */ - function moveInto($targetName, $sourcePath, DAV\INode $sourceNode) { - + public function moveInto($targetName, $sourcePath, DAV\INode $sourceNode) + { // We only support FSExt\Directory or FSExt\File objects, so // anything else we want to quickly reject. if (!$sourceNode instanceof self && !$sourceNode instanceof File) { @@ -200,12 +205,8 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa } // PHP allows us to access protected properties from other objects, as - // long as they are defined in a class that has a shared inheritence + // long as they are defined in a class that has a shared inheritance // with the current class. - rename($sourceNode->path, $this->path . '/' . $targetName); - - return true; - + return rename($sourceNode->path, $this->path.'/'.$targetName); } - } diff --git a/vendor/sabre/dav/lib/DAV/FSExt/File.php b/vendor/sabre/dav/lib/DAV/FSExt/File.php index eb5ae19fe..060ef5a48 100644 --- a/vendor/sabre/dav/lib/DAV/FSExt/File.php +++ b/vendor/sabre/dav/lib/DAV/FSExt/File.php @@ -1,33 +1,36 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FSExt; use Sabre\DAV; use Sabre\DAV\FS\Node; /** - * File class + * File class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends Node implements DAV\PartialUpdate\IPatchSupport { - +class File extends Node implements DAV\PartialUpdate\IPatchSupport +{ /** - * Updates the data + * Updates the data. * * Data is a readable stream resource. * * @param resource|string $data + * * @return string */ - function put($data) { - + public function put($data) + { file_put_contents($this->path, $data); clearstatcache(true, $this->path); - return $this->getETag(); + return $this->getETag(); } /** @@ -53,21 +56,22 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport { * time. * * @param resource|string $data - * @param int $rangeType - * @param int $offset + * @param int $rangeType + * @param int $offset + * * @return string|null */ - function patch($data, $rangeType, $offset = null) { - + public function patch($data, $rangeType, $offset = null) + { switch ($rangeType) { - case 1 : + case 1: $f = fopen($this->path, 'a'); break; - case 2 : + case 2: $f = fopen($this->path, 'c'); fseek($f, $offset); break; - case 3 : + case 3: $f = fopen($this->path, 'c'); fseek($f, $offset, SEEK_END); break; @@ -79,34 +83,32 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport { } fclose($f); clearstatcache(true, $this->path); - return $this->getETag(); + return $this->getETag(); } /** - * Returns the data + * Returns the data. * * @return resource */ - function get() { - + public function get() + { return fopen($this->path, 'r'); - } /** - * Delete the current file + * Delete the current file. * * @return bool */ - function delete() { - + public function delete() + { return unlink($this->path); - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. @@ -115,38 +117,34 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport { * * @return string|null */ - function getETag() { - - return '"' . sha1( - fileinode($this->path) . - filesize($this->path) . + public function getETag() + { + return '"'.sha1( + fileinode($this->path). + filesize($this->path). filemtime($this->path) - ) . '"'; - + ).'"'; } /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream * * @return string|null */ - function getContentType() { - + public function getContentType() + { return null; - } /** - * Returns the size of the file, in bytes + * Returns the size of the file, in bytes. * * @return int */ - function getSize() { - + public function getSize() + { return filesize($this->path); - } - } diff --git a/vendor/sabre/dav/lib/DAV/File.php b/vendor/sabre/dav/lib/DAV/File.php index 5161fbd51..daf83aa4d 100644 --- a/vendor/sabre/dav/lib/DAV/File.php +++ b/vendor/sabre/dav/lib/DAV/File.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * File class + * File class. * * This is a helper class, that should aid in getting file classes setup. * Most of its methods are implemented, and throw permission denied exceptions @@ -12,8 +14,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class File extends Node implements IFile { - +abstract class File extends Node implements IFile +{ /** * Replaces the contents of the file. * @@ -32,25 +34,24 @@ abstract class File extends Node implements IFile { * return an ETag, and just return null. * * @param string|resource $data + * * @return string|null */ - function put($data) { - + public function put($data) + { throw new Exception\Forbidden('Permission denied to change data'); - } /** - * Returns the data + * Returns the data. * * This method may either return a string or a readable stream resource * * @return mixed */ - function get() { - + public function get() + { throw new Exception\Forbidden('Permission denied to read this file'); - } /** @@ -58,14 +59,13 @@ abstract class File extends Node implements IFile { * * @return int */ - function getSize() { - + public function getSize() + { return 0; - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. @@ -74,23 +74,20 @@ abstract class File extends Node implements IFile { * * @return string|null */ - function getETag() { - + public function getETag() + { return null; - } /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream * * @return string|null */ - function getContentType() { - + public function getContentType() + { return null; - } - } diff --git a/vendor/sabre/dav/lib/DAV/ICollection.php b/vendor/sabre/dav/lib/DAV/ICollection.php index 7793070d3..c039dae56 100644 --- a/vendor/sabre/dav/lib/DAV/ICollection.php +++ b/vendor/sabre/dav/lib/DAV/ICollection.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * The ICollection Interface + * The ICollection Interface. * * This interface should be implemented by each class that represents a collection * @@ -11,10 +13,10 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ICollection extends INode { - +interface ICollection extends INode +{ /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -33,44 +35,45 @@ interface ICollection extends INode { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null); + public function createFile($name, $data = null); /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name - * @return void */ - function createDirectory($name); + public function createDirectory($name); /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * This method must throw Sabre\DAV\Exception\NotFound if the node does not * exist. * * @param string $name + * * @return INode */ - function getChild($name); + public function getChild($name); /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return INode[] */ - function getChildren(); + public function getChildren(); /** - * Checks if a child-node with the specified name exists + * Checks if a child-node with the specified name exists. * * @param string $name + * * @return bool */ - function childExists($name); - + public function childExists($name); } diff --git a/vendor/sabre/dav/lib/DAV/ICopyTarget.php b/vendor/sabre/dav/lib/DAV/ICopyTarget.php new file mode 100644 index 000000000..47227138a --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/ICopyTarget.php @@ -0,0 +1,38 @@ +<?php + +declare(strict_types=1); + +namespace Sabre\DAV; + +/** + * By implementing this interface, a collection can effectively say "other + * nodes may be copied into this collection". + * + * If a backend supports a better optimized copy operation, e.g. by avoiding + * copying the contents, this can trigger some huge speed gains. + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +interface ICopyTarget extends ICollection +{ + /** + * Copies a node into this collection. + * + * It is up to the implementors to: + * 1. Create the new resource. + * 2. Copy the data and any properties. + * + * If you return true from this function, the assumption + * is that the copy was successful. + * If you return false, sabre/dav will handle the copy itself. + * + * @param string $targetName new local file/collection name + * @param string $sourcePath Full path to source node + * @param INode $sourceNode Source node itself + * + * @return bool + */ + public function copyInto($targetName, $sourcePath, INode $sourceNode); +} diff --git a/vendor/sabre/dav/lib/DAV/IExtendedCollection.php b/vendor/sabre/dav/lib/DAV/IExtendedCollection.php index c561d7072..d43b44bcb 100644 --- a/vendor/sabre/dav/lib/DAV/IExtendedCollection.php +++ b/vendor/sabre/dav/lib/DAV/IExtendedCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -12,8 +14,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IExtendedCollection extends ICollection { - +interface IExtendedCollection extends ICollection +{ /** * Creates a new collection. * @@ -34,10 +36,9 @@ interface IExtendedCollection extends ICollection { * property for you. * * @param string $name - * @param MkCol $mkCol + * @param MkCol $mkCol + * * @throws Exception\InvalidResourceType - * @return void */ - function createExtendedCollection($name, MkCol $mkCol); - + public function createExtendedCollection($name, MkCol $mkCol); } diff --git a/vendor/sabre/dav/lib/DAV/IFile.php b/vendor/sabre/dav/lib/DAV/IFile.php index 19d8d8637..974aee00d 100644 --- a/vendor/sabre/dav/lib/DAV/IFile.php +++ b/vendor/sabre/dav/lib/DAV/IFile.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * This interface represents a file in the directory tree + * This interface represents a file in the directory tree. * * A file is a bit of a broad definition. In general it implies that on * this specific node a PUT or GET method may be performed, to either update, @@ -13,8 +15,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IFile extends INode { - +interface IFile extends INode +{ /** * Replaces the contents of the file. * @@ -33,30 +35,31 @@ interface IFile extends INode { * return an ETag, and just return null. * * @param resource|string $data + * * @return string|null */ - function put($data); + public function put($data); /** - * Returns the data + * Returns the data. * * This method may either return a string or a readable stream resource * * @return mixed */ - function get(); + public function get(); /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream * * @return string|null */ - function getContentType(); + public function getContentType(); /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * @@ -69,13 +72,12 @@ interface IFile extends INode { * * @return string|null */ - function getETag(); + public function getETag(); /** - * Returns the size of the node, in bytes + * Returns the size of the node, in bytes. * * @return int */ - function getSize(); - + public function getSize(); } diff --git a/vendor/sabre/dav/lib/DAV/IMoveTarget.php b/vendor/sabre/dav/lib/DAV/IMoveTarget.php index 92fde1d5c..18a24081e 100644 --- a/vendor/sabre/dav/lib/DAV/IMoveTarget.php +++ b/vendor/sabre/dav/lib/DAV/IMoveTarget.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -17,8 +19,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IMoveTarget extends ICollection { - +interface IMoveTarget extends ICollection +{ /** * Moves a node into this collection. * @@ -34,11 +36,11 @@ interface IMoveTarget extends ICollection { * the move itself. If you return true from this function, the assumption * is that the move was successful. * - * @param string $targetName New local file/collection name. + * @param string $targetName new local file/collection name * @param string $sourcePath Full path to source node - * @param INode $sourceNode Source node itself + * @param INode $sourceNode Source node itself + * * @return bool */ - function moveInto($targetName, $sourcePath, INode $sourceNode); - + public function moveInto($targetName, $sourcePath, INode $sourceNode); } diff --git a/vendor/sabre/dav/lib/DAV/IMultiGet.php b/vendor/sabre/dav/lib/DAV/IMultiGet.php index e26b457ef..445e761eb 100644 --- a/vendor/sabre/dav/lib/DAV/IMultiGet.php +++ b/vendor/sabre/dav/lib/DAV/IMultiGet.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * IMultiGet + * IMultiGet. * * This interface adds a tiny bit of functionality to collections. * @@ -20,8 +22,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IMultiGet extends ICollection { - +interface IMultiGet extends ICollection +{ /** * This method receives a list of paths in it's first argument. * It must return an array with Node objects. @@ -29,8 +31,8 @@ interface IMultiGet extends ICollection { * If any children are not found, you do not have to return them. * * @param string[] $paths + * * @return array */ - function getMultipleChildren(array $paths); - + public function getMultipleChildren(array $paths); } diff --git a/vendor/sabre/dav/lib/DAV/INode.php b/vendor/sabre/dav/lib/DAV/INode.php index bb884934d..f3e7e395b 100644 --- a/vendor/sabre/dav/lib/DAV/INode.php +++ b/vendor/sabre/dav/lib/DAV/INode.php @@ -1,22 +1,22 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * The INode interface is the base interface, and the parent class of both ICollection and IFile + * The INode interface is the base interface, and the parent class of both ICollection and IFile. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface INode { - +interface INode +{ /** - * Deleted the current node - * - * @return void + * Deleted the current node. */ - function delete(); + public function delete(); /** * Returns the name of the node. @@ -25,15 +25,14 @@ interface INode { * * @return string */ - function getName(); + public function getName(); /** - * Renames the node + * Renames the node. * * @param string $name The new name - * @return void */ - function setName($name); + public function setName($name); /** * Returns the last modification time, as a unix timestamp. Return null @@ -41,6 +40,5 @@ interface INode { * * @return int|null */ - function getLastModified(); - + public function getLastModified(); } diff --git a/vendor/sabre/dav/lib/DAV/IProperties.php b/vendor/sabre/dav/lib/DAV/IProperties.php index 00969c2c4..d50fdff20 100644 --- a/vendor/sabre/dav/lib/DAV/IProperties.php +++ b/vendor/sabre/dav/lib/DAV/IProperties.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * IProperties interface + * IProperties interface. * * Implement this interface to support custom WebDAV properties requested and sent from clients. * @@ -11,8 +13,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IProperties extends INode { - +interface IProperties extends INode +{ /** * Updates properties on this node. * @@ -23,9 +25,8 @@ interface IProperties extends INode { * Read the PropPatch documentation for more information. * * @param PropPatch $propPatch - * @return void */ - function propPatch(PropPatch $propPatch); + public function propPatch(PropPatch $propPatch); /** * Returns a list of properties for this nodes. @@ -40,8 +41,8 @@ interface IProperties extends INode { * The Server class will filter out the extra. * * @param array $properties + * * @return array */ - function getProperties($properties); - + public function getProperties($properties); } diff --git a/vendor/sabre/dav/lib/DAV/IQuota.php b/vendor/sabre/dav/lib/DAV/IQuota.php index e16f386b9..7d72e1174 100644 --- a/vendor/sabre/dav/lib/DAV/IQuota.php +++ b/vendor/sabre/dav/lib/DAV/IQuota.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * IQuota interface + * IQuota interface. * * Implement this interface to add the ability to return quota information. The ObjectTree * will check for quota information on any given node. If the information is not available it will @@ -13,14 +15,13 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IQuota extends ICollection { - +interface IQuota extends ICollection +{ /** - * Returns the quota information + * Returns the quota information. * * This method MUST return an array with 2 values, the first being the total used space, * the second the available space (in bytes) */ - function getQuotaInfo(); - + public function getQuotaInfo(); } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php index 044316cdb..a1bf48699 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; /** @@ -13,6 +15,6 @@ namespace Sabre\DAV\Locks\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface { - +abstract class AbstractBackend implements BackendInterface +{ } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php index a2d2fe89c..9a6919f50 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; use Sabre\DAV\Locks; @@ -12,10 +14,10 @@ use Sabre\DAV\Locks; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** - * Returns a list of Sabre\DAV\Locks\LockInfo objects + * Returns a list of Sabre\DAV\Locks\LockInfo objects. * * This method should return all the locks for a particular uri, including * locks that might be set on a parent uri. @@ -24,27 +26,29 @@ interface BackendInterface { * any locks in the subtree of the uri for locks. * * @param string $uri - * @param bool $returnChildLocks + * @param bool $returnChildLocks + * * @return array */ - function getLocks($uri, $returnChildLocks); + public function getLocks($uri, $returnChildLocks); /** - * Locks a uri + * Locks a uri. * - * @param string $uri + * @param string $uri * @param Locks\LockInfo $lockInfo + * * @return bool */ - function lock($uri, Locks\LockInfo $lockInfo); + public function lock($uri, Locks\LockInfo $lockInfo); /** - * Removes a lock from a uri + * Removes a lock from a uri. * - * @param string $uri + * @param string $uri * @param Locks\LockInfo $lockInfo + * * @return bool */ - function unlock($uri, Locks\LockInfo $lockInfo); - + public function unlock($uri, Locks\LockInfo $lockInfo); } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php index 849539bee..5957f35dd 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; use Sabre\DAV\Locks\LockInfo; @@ -17,28 +19,27 @@ use Sabre\DAV\Locks\LockInfo; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends AbstractBackend { - +class File extends AbstractBackend +{ /** - * The storage file + * The storage file. * * @var string */ private $locksFile; /** - * Constructor + * Constructor. * * @param string $locksFile path to file */ - function __construct($locksFile) { - + public function __construct($locksFile) + { $this->locksFile = $locksFile; - } /** - * Returns a list of Sabre\DAV\Locks\LockInfo objects + * Returns a list of Sabre\DAV\Locks\LockInfo objects. * * This method should return all the locks for a particular uri, including * locks that might be set on a parent uri. @@ -47,47 +48,47 @@ class File extends AbstractBackend { * any locks in the subtree of the uri for locks. * * @param string $uri - * @param bool $returnChildLocks + * @param bool $returnChildLocks + * * @return array */ - function getLocks($uri, $returnChildLocks) { - + public function getLocks($uri, $returnChildLocks) + { $newLocks = []; $locks = $this->getData(); foreach ($locks as $lock) { - if ($lock->uri === $uri || //deep locks on parents - ($lock->depth != 0 && strpos($uri, $lock->uri . '/') === 0) || + (0 != $lock->depth && 0 === strpos($uri, $lock->uri.'/')) || // locks on children - ($returnChildLocks && (strpos($lock->uri, $uri . '/') === 0))) { - + ($returnChildLocks && (0 === strpos($lock->uri, $uri.'/')))) { $newLocks[] = $lock; - } - } // Checking if we can remove any of these locks foreach ($newLocks as $k => $lock) { - if (time() > $lock->timeout + $lock->created) unset($newLocks[$k]); + if (time() > $lock->timeout + $lock->created) { + unset($newLocks[$k]); + } } - return $newLocks; + return $newLocks; } /** - * Locks a uri + * Locks a uri. * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function lock($uri, LockInfo $lockInfo) { - + public function lock($uri, LockInfo $lockInfo) + { // We're making the lock timeout 30 minutes $lockInfo->timeout = 1800; $lockInfo->created = time(); @@ -105,32 +106,31 @@ class File extends AbstractBackend { } $locks[] = $lockInfo; $this->putData($locks); - return true; + return true; } /** - * Removes a lock from a uri + * Removes a lock from a uri. * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function unlock($uri, LockInfo $lockInfo) { - + public function unlock($uri, LockInfo $lockInfo) + { $locks = $this->getData(); foreach ($locks as $k => $lock) { - if ($lock->token == $lockInfo->token) { - unset($locks[$k]); $this->putData($locks); - return true; + return true; } } - return false; + return false; } /** @@ -138,9 +138,11 @@ class File extends AbstractBackend { * * @return array */ - protected function getData() { - - if (!file_exists($this->locksFile)) return []; + protected function getData() + { + if (!file_exists($this->locksFile)) { + return []; + } // opening up the file, and creating a shared lock $handle = fopen($this->locksFile, 'r'); @@ -155,19 +157,20 @@ class File extends AbstractBackend { // Unserializing and checking if the resource file contains data for this file $data = unserialize($data); - if (!$data) return []; - return $data; + if (!$data) { + return []; + } + return $data; } /** - * Saves the lockdata + * Saves the lockdata. * * @param array $newData - * @return void */ - protected function putData(array $newData) { - + protected function putData(array $newData) + { // opening up the file, and creating an exclusive lock $handle = fopen($this->locksFile, 'a+'); flock($handle, LOCK_EX); @@ -179,7 +182,5 @@ class File extends AbstractBackend { fwrite($handle, serialize($newData)); flock($handle, LOCK_UN); fclose($handle); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php index 510f266f7..36a12d1ab 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; use Sabre\DAV\Locks\LockInfo; @@ -14,8 +16,8 @@ use Sabre\DAV\Locks\LockInfo; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend { - +class PDO extends AbstractBackend +{ /** * The PDO tablename this backend uses. * @@ -24,25 +26,24 @@ class PDO extends AbstractBackend { public $tableName = 'locks'; /** - * The PDO connection object + * The PDO connection object. * * @var pdo */ protected $pdo; /** - * Constructor + * Constructor. * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** - * Returns a list of Sabre\DAV\Locks\LockInfo objects + * Returns a list of Sabre\DAV\Locks\LockInfo objects. * * This method should return all the locks for a particular uri, including * locks that might be set on a parent uri. @@ -51,16 +52,17 @@ class PDO extends AbstractBackend { * any locks in the subtree of the uri for locks. * * @param string $uri - * @param bool $returnChildLocks + * @param bool $returnChildLocks + * * @return array */ - function getLocks($uri, $returnChildLocks) { - + public function getLocks($uri, $returnChildLocks) + { // NOTE: the following 10 lines or so could be easily replaced by // pure sql. MySQL's non-standard string concatenation prevents us // from doing this though. - $query = 'SELECT owner, token, timeout, created, scope, depth, uri FROM ' . $this->tableName . ' WHERE (created > (? - timeout)) AND ((uri = ?)'; - $params = [time(),$uri]; + $query = 'SELECT owner, token, timeout, created, scope, depth, uri FROM '.$this->tableName.' WHERE (created > (? - timeout)) AND ((uri = ?)'; + $params = [time(), $uri]; // We need to check locks for every part in the uri. $uriParts = explode('/', $uri); @@ -71,20 +73,18 @@ class PDO extends AbstractBackend { $currentPath = ''; foreach ($uriParts as $part) { - - if ($currentPath) $currentPath .= '/'; + if ($currentPath) { + $currentPath .= '/'; + } $currentPath .= $part; $query .= ' OR (depth!=0 AND uri = ?)'; $params[] = $currentPath; - } if ($returnChildLocks) { - $query .= ' OR (uri LIKE ?)'; - $params[] = $uri . '/%'; - + $params[] = $uri.'/%'; } $query .= ')'; @@ -94,7 +94,6 @@ class PDO extends AbstractBackend { $lockList = []; foreach ($result as $row) { - $lockInfo = new LockInfo(); $lockInfo->owner = $row['owner']; $lockInfo->token = $row['token']; @@ -104,22 +103,21 @@ class PDO extends AbstractBackend { $lockInfo->depth = $row['depth']; $lockInfo->uri = $row['uri']; $lockList[] = $lockInfo; - } return $lockList; - } /** - * Locks a uri + * Locks a uri. * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function lock($uri, LockInfo $lockInfo) { - + public function lock($uri, LockInfo $lockInfo) + { // We're making the lock timeout 30 minutes $lockInfo->timeout = 30 * 60; $lockInfo->created = time(); @@ -128,11 +126,13 @@ class PDO extends AbstractBackend { $locks = $this->getLocks($uri, false); $exists = false; foreach ($locks as $lock) { - if ($lock->token == $lockInfo->token) $exists = true; + if ($lock->token == $lockInfo->token) { + $exists = true; + } } if ($exists) { - $stmt = $this->pdo->prepare('UPDATE ' . $this->tableName . ' SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?'); + $stmt = $this->pdo->prepare('UPDATE '.$this->tableName.' SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?'); $stmt->execute([ $lockInfo->owner, $lockInfo->timeout, @@ -140,10 +140,10 @@ class PDO extends AbstractBackend { $lockInfo->depth, $uri, $lockInfo->created, - $lockInfo->token + $lockInfo->token, ]); } else { - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->tableName . ' (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)'); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->tableName.' (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)'); $stmt->execute([ $lockInfo->owner, $lockInfo->timeout, @@ -151,30 +151,26 @@ class PDO extends AbstractBackend { $lockInfo->depth, $uri, $lockInfo->created, - $lockInfo->token + $lockInfo->token, ]); } return true; - } - - /** - * Removes a lock from a uri + * Removes a lock from a uri. * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function unlock($uri, LockInfo $lockInfo) { - - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->tableName . ' WHERE uri = ? AND token = ?'); + public function unlock($uri, LockInfo $lockInfo) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->tableName.' WHERE uri = ? AND token = ?'); $stmt->execute([$uri, $lockInfo->token]); - return $stmt->rowCount() === 1; - + return 1 === $stmt->rowCount(); } - } diff --git a/vendor/sabre/dav/lib/DAV/Locks/LockInfo.php b/vendor/sabre/dav/lib/DAV/Locks/LockInfo.php index 2c8cca0fe..df8227566 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/LockInfo.php +++ b/vendor/sabre/dav/lib/DAV/Locks/LockInfo.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks; /** - * LockInfo class + * LockInfo class. * * An object of the LockInfo class holds all the information relevant to a * single lock. @@ -12,69 +14,69 @@ namespace Sabre\DAV\Locks; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class LockInfo { - +class LockInfo +{ /** - * A shared lock + * A shared lock. */ const SHARED = 1; /** - * An exclusive lock + * An exclusive lock. */ const EXCLUSIVE = 2; /** - * A never expiring timeout + * A never expiring timeout. */ const TIMEOUT_INFINITE = -1; /** - * The owner of the lock + * The owner of the lock. * * @var string */ public $owner; /** - * The locktoken + * The locktoken. * * @var string */ public $token; /** - * How long till the lock is expiring + * How long till the lock is expiring. * * @var int */ public $timeout; /** - * UNIX Timestamp of when this lock was created + * UNIX Timestamp of when this lock was created. * * @var int */ public $created; /** - * Exclusive or shared lock + * Exclusive or shared lock. * * @var int */ public $scope = self::EXCLUSIVE; /** - * Depth of lock, can be 0 or Sabre\DAV\Server::DEPTH_INFINITY + * Depth of lock, can be 0 or Sabre\DAV\Server::DEPTH_INFINITY. */ public $depth = 0; /** - * The uri this lock locks + * The uri this lock locks. * * TODO: This value is not always set + * * @var mixed */ public $uri; - } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Plugin.php b/vendor/sabre/dav/lib/DAV/Locks/Plugin.php index 41a3bf3fa..6d3e9b883 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks; use Sabre\DAV; @@ -7,7 +9,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * Locking plugin + * Locking plugin. * * This plugin provides locking support to a WebDAV server. * The easiest way to get started, is by hooking it up as such: @@ -20,53 +22,50 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * locksBackend + * locksBackend. * * @var Backend\BackendInterface */ protected $locksBackend; /** - * server + * server. * * @var DAV\Server */ protected $server; /** - * __construct + * __construct. * * @param Backend\BackendInterface $locksBackend */ - function __construct(Backend\BackendInterface $locksBackend) { - + public function __construct(Backend\BackendInterface $locksBackend) + { $this->locksBackend = $locksBackend; - } /** - * Initializes the plugin + * Initializes the plugin. * * This method is automatically called by the Server class after addPlugin. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->xml->elementMap['{DAV:}lockinfo'] = 'Sabre\\DAV\\Xml\\Request\\Lock'; - $server->on('method:LOCK', [$this, 'httpLock']); - $server->on('method:UNLOCK', [$this, 'httpUnlock']); + $server->on('method:LOCK', [$this, 'httpLock']); + $server->on('method:UNLOCK', [$this, 'httpUnlock']); $server->on('validateTokens', [$this, 'validateTokens']); - $server->on('propFind', [$this, 'propFind']); - $server->on('afterUnbind', [$this, 'afterUnbind']); - + $server->on('propFind', [$this, 'propFind']); + $server->on('afterUnbind', [$this, 'afterUnbind']); } /** @@ -77,31 +76,28 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'locks'; - } /** * This method is called after most properties have been found - * it allows us to add in any Lock-related properties + * it allows us to add in any Lock-related properties. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFind(DAV\PropFind $propFind, DAV\INode $node) { - - $propFind->handle('{DAV:}supportedlock', function() { + public function propFind(DAV\PropFind $propFind, DAV\INode $node) + { + $propFind->handle('{DAV:}supportedlock', function () { return new DAV\Xml\Property\SupportedLock(); }); - $propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) { + $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) { return new DAV\Xml\Property\LockDiscovery( $this->getLocks($propFind->getPath()) ); }); - } /** @@ -112,12 +108,12 @@ class Plugin extends DAV\ServerPlugin { * available for the specified uri. * * @param string $uri + * * @return array */ - function getHTTPMethods($uri) { - - return ['LOCK','UNLOCK']; - + public function getHTTPMethods($uri) + { + return ['LOCK', 'UNLOCK']; } /** @@ -128,14 +124,13 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return [2]; - } /** - * Returns all lock information on a particular uri + * Returns all lock information on a particular uri. * * This function should return an array with Sabre\DAV\Locks\LockInfo objects. If there are no locks on a file, return an empty array. * @@ -144,17 +139,17 @@ class Plugin extends DAV\ServerPlugin { * for any possible locks and return those as well. * * @param string $uri - * @param bool $returnChildLocks + * @param bool $returnChildLocks + * * @return array */ - function getLocks($uri, $returnChildLocks = false) { - + public function getLocks($uri, $returnChildLocks = false) + { return $this->locksBackend->getLocks($uri, $returnChildLocks); - } /** - * Locks an uri + * Locks an uri. * * The WebDAV lock request can be operated to either create a new lock on a file, or to refresh an existing lock * If a new lock is created, a full XML body should be supplied, containing information about the lock such as the type @@ -164,12 +159,13 @@ class Plugin extends DAV\ServerPlugin { * * Additionally, a lock can be requested for a non-existent file. In these case we're obligated to create an empty file as per RFC4918:S7.3 * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpLock(RequestInterface $request, ResponseInterface $response) { - + public function httpLock(RequestInterface $request, ResponseInterface $response) + { $uri = $request->getPath(); $existingLocks = $this->getLocks($uri); @@ -180,7 +176,7 @@ class Plugin extends DAV\ServerPlugin { $existingLock = null; // Checking if there's already non-shared locks on the uri. foreach ($existingLocks as $existingLock) { - if ($existingLock->scope === LockInfo::EXCLUSIVE) { + if (LockInfo::EXCLUSIVE === $existingLock->scope) { throw new DAV\Exception\ConflictingLock($existingLock); } } @@ -188,11 +184,10 @@ class Plugin extends DAV\ServerPlugin { $lockInfo = $this->parseLockRequest($body); $lockInfo->depth = $this->server->getHTTPDepth(); $lockInfo->uri = $uri; - if ($existingLock && $lockInfo->scope != LockInfo::SHARED) + if ($existingLock && LockInfo::SHARED != $lockInfo->scope) { throw new DAV\Exception\ConflictingLock($existingLock); - + } } else { - // Gonna check if this was a lock refresh. $existingLocks = $this->getLocks($uri); $conditions = $this->server->getIfConditions($request); @@ -201,7 +196,7 @@ class Plugin extends DAV\ServerPlugin { foreach ($existingLocks as $existingLock) { foreach ($conditions as $condition) { foreach ($condition['tokens'] as $token) { - if ($token['token'] === 'opaquelocktoken:' . $existingLock->token) { + if ($token['token'] === 'opaquelocktoken:'.$existingLock->token) { $found = $existingLock; break 3; } @@ -216,18 +211,20 @@ class Plugin extends DAV\ServerPlugin { } else { throw new DAV\Exception\BadRequest('An xml body is required for lock requests'); } - } // This must have been a lock refresh $lockInfo = $found; // The resource could have been locked through another uri. - if ($uri != $lockInfo->uri) $uri = $lockInfo->uri; - + if ($uri != $lockInfo->uri) { + $uri = $lockInfo->uri; + } } - if ($timeout = $this->getTimeoutHeader()) $lockInfo->timeout = $timeout; + if ($timeout = $this->getTimeoutHeader()) { + $lockInfo->timeout = $timeout; + } $newFile = false; @@ -240,56 +237,52 @@ class Plugin extends DAV\ServerPlugin { // // See Issue 222 // $this->server->emit('beforeWriteContent',array($uri)); - } catch (DAV\Exception\NotFound $e) { - // It didn't, lets create it $this->server->createFile($uri, fopen('php://memory', 'r')); $newFile = true; - } $this->lockNode($uri, $lockInfo); $response->setHeader('Content-Type', 'application/xml; charset=utf-8'); - $response->setHeader('Lock-Token', '<opaquelocktoken:' . $lockInfo->token . '>'); + $response->setHeader('Lock-Token', '<opaquelocktoken:'.$lockInfo->token.'>'); $response->setStatus($newFile ? 201 : 200); $response->setBody($this->generateLockResponse($lockInfo)); // Returning false will interrupt the event chain and mark this method // as 'handled'. return false; - } /** - * Unlocks a uri + * Unlocks a uri. * * This WebDAV method allows you to remove a lock from a node. The client should provide a valid locktoken through the Lock-token http header * The server should return 204 (No content) on success * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpUnlock(RequestInterface $request, ResponseInterface $response) { - + public function httpUnlock(RequestInterface $request, ResponseInterface $response) + { $lockToken = $request->getHeader('Lock-Token'); // If the locktoken header is not supplied, we need to throw a bad request exception - if (!$lockToken) throw new DAV\Exception\BadRequest('No lock token was supplied'); - + if (!$lockToken) { + throw new DAV\Exception\BadRequest('No lock token was supplied'); + } $path = $request->getPath(); $locks = $this->getLocks($path); // Windows sometimes forgets to include < and > in the Lock-Token // header - if ($lockToken[0] !== '<') $lockToken = '<' . $lockToken . '>'; + if ('<' !== $lockToken[0]) { + $lockToken = '<'.$lockToken.'>'; + } foreach ($locks as $lock) { - - if ('<opaquelocktoken:' . $lock->token . '>' == $lockToken) { - + if ('<opaquelocktoken:'.$lock->token.'>' == $lockToken) { $this->unlockNode($path, $lock); $response->setHeader('Content-Length', '0'); $response->setStatus(204); @@ -297,14 +290,11 @@ class Plugin extends DAV\ServerPlugin { // Returning false will break the method chain, and mark the // method as 'handled'. return false; - } - } // If we got here, it means the locktoken was invalid throw new DAV\Exception\LockTokenMatchesRequestUri(); - } /** @@ -313,51 +303,54 @@ class Plugin extends DAV\ServerPlugin { * We use this event to clean up any locks that still exist on the node. * * @param string $path - * @return void */ - function afterUnbind($path) { - + public function afterUnbind($path) + { $locks = $this->getLocks($path, $includeChildren = true); foreach ($locks as $lock) { $this->unlockNode($path, $lock); } - } /** - * Locks a uri + * Locks a uri. * * All the locking information is supplied in the lockInfo object. The object has a suggested timeout, but this can be safely ignored * It is important that if the existing timeout is ignored, the property is overwritten, as this needs to be sent back to the client * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function lockNode($uri, LockInfo $lockInfo) { + public function lockNode($uri, LockInfo $lockInfo) + { + if (!$this->server->emit('beforeLock', [$uri, $lockInfo])) { + return; + } - if (!$this->server->emit('beforeLock', [$uri, $lockInfo])) return; return $this->locksBackend->lock($uri, $lockInfo); - } /** - * Unlocks a uri + * Unlocks a uri. * * This method removes a lock from a uri. It is assumed all the supplied information is correct and verified * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function unlockNode($uri, LockInfo $lockInfo) { + public function unlockNode($uri, LockInfo $lockInfo) + { + if (!$this->server->emit('beforeUnlock', [$uri, $lockInfo])) { + return; + } - if (!$this->server->emit('beforeUnlock', [$uri, $lockInfo])) return; return $this->locksBackend->unlock($uri, $lockInfo); - } - /** * Returns the contents of the HTTP Timeout header. * @@ -365,37 +358,36 @@ class Plugin extends DAV\ServerPlugin { * * @return int */ - function getTimeoutHeader() { - + public function getTimeoutHeader() + { $header = $this->server->httpRequest->getHeader('Timeout'); if ($header) { - - if (stripos($header, 'second-') === 0) $header = (int)(substr($header, 7)); - elseif (stripos($header, 'infinite') === 0) $header = LockInfo::TIMEOUT_INFINITE; - else throw new DAV\Exception\BadRequest('Invalid HTTP timeout header'); - + if (0 === stripos($header, 'second-')) { + $header = (int) (substr($header, 7)); + } elseif (0 === stripos($header, 'infinite')) { + $header = LockInfo::TIMEOUT_INFINITE; + } else { + throw new DAV\Exception\BadRequest('Invalid HTTP timeout header'); + } } else { - $header = 0; - } return $header; - } /** - * Generates the response for successful LOCK requests + * Generates the response for successful LOCK requests. * * @param LockInfo $lockInfo + * * @return string */ - protected function generateLockResponse(LockInfo $lockInfo) { - + protected function generateLockResponse(LockInfo $lockInfo) + { return $this->server->xml->write('{DAV:}prop', [ - '{DAV:}lockdiscovery' => - new DAV\Xml\Property\LockDiscovery([$lockInfo]) + '{DAV:}lockdiscovery' => new DAV\Xml\Property\LockDiscovery([$lockInfo]), ]); } @@ -410,11 +402,10 @@ class Plugin extends DAV\ServerPlugin { * tokens. * * @param RequestInterface $request - * @param mixed $conditions - * @return void + * @param mixed $conditions */ - function validateTokens(RequestInterface $request, &$conditions) { - + public function validateTokens(RequestInterface $request, &$conditions) + { // First we need to gather a list of locks that must be satisfied. $mustLocks = []; $method = $request->getMethod(); @@ -422,24 +413,23 @@ class Plugin extends DAV\ServerPlugin { // Methods not in that list are operations that doesn't alter any // resources, and we don't need to check the lock-states for. switch ($method) { - - case 'DELETE' : + case 'DELETE': $mustLocks = array_merge($mustLocks, $this->getLocks( $request->getPath(), true )); break; - case 'MKCOL' : - case 'MKCALENDAR' : - case 'PROPPATCH' : - case 'PUT' : - case 'PATCH' : + case 'MKCOL': + case 'MKCALENDAR': + case 'PROPPATCH': + case 'PUT': + case 'PATCH': $mustLocks = array_merge($mustLocks, $this->getLocks( $request->getPath(), false )); break; - case 'MOVE' : + case 'MOVE': $mustLocks = array_merge($mustLocks, $this->getLocks( $request->getPath(), true @@ -449,13 +439,13 @@ class Plugin extends DAV\ServerPlugin { false )); break; - case 'COPY' : + case 'COPY': $mustLocks = array_merge($mustLocks, $this->getLocks( $this->server->calculateUri($request->getHeader('Destination')), false )); break; - case 'LOCK' : + case 'LOCK': //Temporary measure.. figure out later why this is needed // Here we basically ignore all incoming tokens... foreach ($conditions as $ii => $condition) { @@ -463,31 +453,29 @@ class Plugin extends DAV\ServerPlugin { $conditions[$ii]['tokens'][$jj]['validToken'] = true; } } - return; + return; } // It's possible that there's identical locks, because of shared // parents. We're removing the duplicates here. $tmp = []; - foreach ($mustLocks as $lock) $tmp[$lock->token] = $lock; + foreach ($mustLocks as $lock) { + $tmp[$lock->token] = $lock; + } $mustLocks = array_values($tmp); foreach ($conditions as $kk => $condition) { - foreach ($condition['tokens'] as $ii => $token) { - // Lock tokens always start with opaquelocktoken: - if (substr($token['token'], 0, 16) !== 'opaquelocktoken:') { + if ('opaquelocktoken:' !== substr($token['token'], 0, 16)) { continue; } $checkToken = substr($token['token'], 16); // Looping through our list with locks. foreach ($mustLocks as $jj => $mustLock) { - if ($mustLock->token == $checkToken) { - // We have a match! // Removing this one from mustlocks unset($mustLocks[$jj]); @@ -497,9 +485,7 @@ class Plugin extends DAV\ServerPlugin { // Advancing to the next token continue 2; - } - } // If we got here, it means that there was a @@ -514,42 +500,34 @@ class Plugin extends DAV\ServerPlugin { // lock-token that was expired. $oddLocks = $this->getLocks($condition['uri']); foreach ($oddLocks as $oddLock) { - if ($oddLock->token === $checkToken) { - // We have a hit! $conditions[$kk]['tokens'][$ii]['validToken'] = true; continue 2; - } } // If we get all the way here, the lock-token was // really unknown. - - } - } // If there's any locks left in the 'mustLocks' array, it means that // the resource was locked and we must block it. if ($mustLocks) { - throw new DAV\Exception\Locked(reset($mustLocks)); - } - } /** - * Parses a webdav lock xml body, and returns a new Sabre\DAV\Locks\LockInfo object + * Parses a webdav lock xml body, and returns a new Sabre\DAV\Locks\LockInfo object. * * @param string $body + * * @return LockInfo */ - protected function parseLockRequest($body) { - + protected function parseLockRequest($body) + { $result = $this->server->xml->expect( '{DAV:}lockinfo', $body @@ -562,7 +540,6 @@ class Plugin extends DAV\ServerPlugin { $lockInfo->scope = $result->scope; return $lockInfo; - } /** @@ -576,14 +553,12 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'The locks plugin turns this server into a class-2 WebDAV server and adds support for LOCK and UNLOCK', - 'link' => 'http://sabre.io/dav/locks/', + 'link' => 'http://sabre.io/dav/locks/', ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/MkCol.php b/vendor/sabre/dav/lib/DAV/MkCol.php index 042e14bca..f3c5ea5c0 100644 --- a/vendor/sabre/dav/lib/DAV/MkCol.php +++ b/vendor/sabre/dav/lib/DAV/MkCol.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -20,8 +22,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MkCol extends PropPatch { - +class MkCol extends PropPatch +{ /** * A list of resource-types in clark-notation. * @@ -32,14 +34,13 @@ class MkCol extends PropPatch { /** * Creates the MKCOL object. * - * @param string[] $resourceType List of resourcetype values. - * @param array $mutations List of new properties values. + * @param string[] $resourceType list of resourcetype values + * @param array $mutations list of new properties values */ - function __construct(array $resourceType, array $mutations) { - + public function __construct(array $resourceType, array $mutations) + { $this->resourceType = $resourceType; parent::__construct($mutations); - } /** @@ -47,10 +48,9 @@ class MkCol extends PropPatch { * * @return string[] */ - function getResourceType() { - + public function getResourceType() + { return $this->resourceType; - } /** @@ -61,12 +61,11 @@ class MkCol extends PropPatch { * checked. * * @param string|string[] $resourceType + * * @return bool */ - function hasResourceType($resourceType) { - - return count(array_diff((array)$resourceType, $this->resourceType)) === 0; - + public function hasResourceType($resourceType) + { + return 0 === count(array_diff((array) $resourceType, $this->resourceType)); } - } diff --git a/vendor/sabre/dav/lib/DAV/Mount/Plugin.php b/vendor/sabre/dav/lib/DAV/Mount/Plugin.php index dc923ad85..5eaa4d462 100644 --- a/vendor/sabre/dav/lib/DAV/Mount/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Mount/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Mount; use Sabre\DAV; @@ -7,7 +9,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * This plugin provides support for RFC4709: Mounting WebDAV servers + * This plugin provides support for RFC4709: Mounting WebDAV servers. * * Simply append ?mount to any collection to generate the davmount response. * @@ -15,40 +17,41 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * Reference to Server class + * Reference to Server class. * * @var DAV\Server */ protected $server; /** - * Initializes the plugin and registers event handles + * Initializes the plugin and registers event handles. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->on('method:GET', [$this, 'httpGet'], 90); - } /** * 'beforeMethod' event handles. This event handles intercepts GET requests ending - * with ?mount + * with ?mount. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $queryParams = $request->getQueryParameters(); - if (!array_key_exists('mount', $queryParams)) return; + if (!array_key_exists('mount', $queryParams)) { + return; + } $currentUri = $request->getAbsoluteUrl(); @@ -59,28 +62,23 @@ class Plugin extends DAV\ServerPlugin { // Returning false to break the event chain return false; - } /** - * Generates the davmount response + * Generates the davmount response. * * @param ResponseInterface $response - * @param string $uri absolute uri - * @return void + * @param string $uri absolute uri */ - function davMount(ResponseInterface $response, $uri) { - + public function davMount(ResponseInterface $response, $uri) + { $response->setStatus(200); $response->setHeader('Content-Type', 'application/davmount+xml'); ob_start(); echo '<?xml version="1.0"?>', "\n"; echo "<dm:mount xmlns:dm=\"http://purl.org/NET/webdav/mount\">\n"; - echo " <dm:url>", htmlspecialchars($uri, ENT_NOQUOTES, 'UTF-8'), "</dm:url>\n"; - echo "</dm:mount>"; + echo ' <dm:url>', htmlspecialchars($uri, ENT_NOQUOTES, 'UTF-8'), "</dm:url>\n"; + echo '</dm:mount>'; $response->setBody(ob_get_clean()); - } - - } diff --git a/vendor/sabre/dav/lib/DAV/Node.php b/vendor/sabre/dav/lib/DAV/Node.php index ef6eea18e..948060d9a 100644 --- a/vendor/sabre/dav/lib/DAV/Node.php +++ b/vendor/sabre/dav/lib/DAV/Node.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * Node class + * Node class. * * This is a helper class, that should aid in getting nodes setup. * @@ -11,8 +13,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Node implements INode { - +abstract class Node implements INode +{ /** * Returns the last modification time as a unix timestamp. * @@ -20,35 +22,30 @@ abstract class Node implements INode { * * @return int */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** - * Deletes the current node + * Deletes the current node. * * @throws Exception\Forbidden - * @return void */ - function delete() { - + public function delete() + { throw new Exception\Forbidden('Permission denied to delete node'); - } /** - * Renames the node + * Renames the node. * * @param string $name The new name + * * @throws Exception\Forbidden - * @return void */ - function setName($name) { - + public function setName($name) + { throw new Exception\Forbidden('Permission denied to rename file'); - } - } diff --git a/vendor/sabre/dav/lib/DAV/PartialUpdate/IPatchSupport.php b/vendor/sabre/dav/lib/DAV/PartialUpdate/IPatchSupport.php index 97d24f9cb..e516f4d08 100644 --- a/vendor/sabre/dav/lib/DAV/PartialUpdate/IPatchSupport.php +++ b/vendor/sabre/dav/lib/DAV/PartialUpdate/IPatchSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PartialUpdate; use Sabre\DAV; @@ -7,14 +9,14 @@ use Sabre\DAV; /** * This interface provides a way to modify only part of a target resource * It may be used to update a file chunk, upload big a file into smaller - * chunks or resume an upload + * chunks or resume an upload. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Jean-Tiare LE BIGOT (http://www.jtlebi.fr/) * @license http://sabre.io/license/ Modified BSD License */ -interface IPatchSupport extends DAV\IFile { - +interface IPatchSupport extends DAV\IFile +{ /** * Updates the file based on a range specification. * @@ -38,10 +40,10 @@ interface IPatchSupport extends DAV\IFile { * time. * * @param resource|string $data - * @param int $rangeType - * @param int $offset + * @param int $rangeType + * @param int $offset + * * @return string|null */ - function patch($data, $rangeType, $offset = null); - + public function patch($data, $rangeType, $offset = null); } diff --git a/vendor/sabre/dav/lib/DAV/PartialUpdate/Plugin.php b/vendor/sabre/dav/lib/DAV/PartialUpdate/Plugin.php index 9c129d705..f8ffc3706 100644 --- a/vendor/sabre/dav/lib/DAV/PartialUpdate/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/PartialUpdate/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PartialUpdate; use Sabre\DAV; @@ -7,7 +9,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * Partial update plugin (Patch method) + * Partial update plugin (Patch method). * * This plugin provides a way to modify only part of a target resource * It may bu used to update a file chunk, upload big a file into smaller @@ -20,32 +22,30 @@ use Sabre\HTTP\ResponseInterface; * @author Jean-Tiare LE BIGOT (http://www.jtlebi.fr/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ const RANGE_APPEND = 1; const RANGE_START = 2; const RANGE_END = 3; /** - * Reference to server + * Reference to server. * * @var DAV\Server */ protected $server; /** - * Initializes the plugin + * Initializes the plugin. * * This method is automatically called by the Server class after addPlugin. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $server->on('method:PATCH', [$this, 'httpPatch']); - } /** @@ -56,10 +56,9 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'partialupdate'; - } /** @@ -74,10 +73,11 @@ class Plugin extends DAV\ServerPlugin { * - the node implements our partial update interface * * @param string $uri + * * @return array */ - function getHTTPMethods($uri) { - + public function getHTTPMethods($uri) + { $tree = $this->server->tree; if ($tree->nodeExists($uri)) { @@ -86,8 +86,8 @@ class Plugin extends DAV\ServerPlugin { return ['PATCH']; } } - return []; + return []; } /** @@ -95,25 +95,23 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['sabredav-partialupdate']; - } /** - * Patch an uri + * Patch an uri. * * The WebDAV patch request can be used to modify only a part of an * existing resource. If the resource does not exist yet and the first * offset is not 0, the request fails * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpPatch(RequestInterface $request, ResponseInterface $response) { - + public function httpPatch(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); // Get the node. Will throw a 404 if not found @@ -129,53 +127,55 @@ class Plugin extends DAV\ServerPlugin { } $contentType = strtolower( - $request->getHeader('Content-Type') + (string) $request->getHeader('Content-Type') ); - if ($contentType != 'application/x-sabredav-partialupdate') { - throw new DAV\Exception\UnsupportedMediaType('Unknown Content-Type header "' . $contentType . '"'); + if ('application/x-sabredav-partialupdate' != $contentType) { + throw new DAV\Exception\UnsupportedMediaType('Unknown Content-Type header "'.$contentType.'"'); } $len = $this->server->httpRequest->getHeader('Content-Length'); - if (!$len) throw new DAV\Exception\LengthRequired('A Content-Length header is required'); - + if (!$len) { + throw new DAV\Exception\LengthRequired('A Content-Length header is required'); + } switch ($range[0]) { - case self::RANGE_START : + case self::RANGE_START: // Calculate the end-range if it doesn't exist. if (!$range[2]) { $range[2] = $range[1] + $len - 1; } else { if ($range[2] < $range[1]) { - throw new DAV\Exception\RequestedRangeNotSatisfiable('The end offset (' . $range[2] . ') is lower than the start offset (' . $range[1] . ')'); + throw new DAV\Exception\RequestedRangeNotSatisfiable('The end offset ('.$range[2].') is lower than the start offset ('.$range[1].')'); } if ($range[2] - $range[1] + 1 != $len) { - throw new DAV\Exception\RequestedRangeNotSatisfiable('Actual data length (' . $len . ') is not consistent with begin (' . $range[1] . ') and end (' . $range[2] . ') offsets'); + throw new DAV\Exception\RequestedRangeNotSatisfiable('Actual data length ('.$len.') is not consistent with begin ('.$range[1].') and end ('.$range[2].') offsets'); } } break; } - if (!$this->server->emit('beforeWriteContent', [$path, $node, null])) + if (!$this->server->emit('beforeWriteContent', [$path, $node, null])) { return; + } $body = $this->server->httpRequest->getBody(); - $etag = $node->patch($body, $range[0], isset($range[1]) ? $range[1] : null); $this->server->emit('afterWriteContent', [$path, $node]); $response->setHeader('Content-Length', '0'); - if ($etag) $response->setHeader('ETag', $etag); + if ($etag) { + $response->setHeader('ETag', $etag); + } $response->setStatus(204); // Breaks the event chain return false; - } /** - * Returns the HTTP custom range update header + * Returns the HTTP custom range update header. * * This method returns null if there is no well-formed HTTP range request * header. It returns array(1) if it was an append request, array(2, @@ -192,24 +192,28 @@ class Plugin extends DAV\ServerPlugin { * [3,-5] - update from 5 bytes from the end of the file. * * @param RequestInterface $request + * * @return array|null */ - function getHTTPUpdateRange(RequestInterface $request) { - + public function getHTTPUpdateRange(RequestInterface $request) + { $range = $request->getHeader('X-Update-Range'); - if (is_null($range)) return null; + if (is_null($range)) { + return null; + } // Matching "Range: bytes=1234-5678: both numbers are optional - if (!preg_match('/^(append)|(?:bytes=([0-9]+)-([0-9]*))|(?:bytes=(-[0-9]+))$/i', $range, $matches)) return null; + if (!preg_match('/^(append)|(?:bytes=([0-9]+)-([0-9]*))|(?:bytes=(-[0-9]+))$/i', $range, $matches)) { + return null; + } - if ($matches[1] === 'append') { + if ('append' === $matches[1]) { return [self::RANGE_APPEND]; } elseif (strlen($matches[2]) > 0) { - return [self::RANGE_START, $matches[2], $matches[3] ?: null]; + return [self::RANGE_START, (int) $matches[2], (int) $matches[3] ?: null]; } else { - return [self::RANGE_END, $matches[4]]; + return [self::RANGE_END, (int) $matches[4]]; } - } } diff --git a/vendor/sabre/dav/lib/DAV/PropFind.php b/vendor/sabre/dav/lib/DAV/PropFind.php index 0940a1ce2..4b6fe28eb 100644 --- a/vendor/sabre/dav/lib/DAV/PropFind.php +++ b/vendor/sabre/dav/lib/DAV/PropFind.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -8,10 +10,10 @@ namespace Sabre\DAV; * It contains the type of PROPFIND request, which properties were requested * and also the returned items. */ -class PropFind { - +class PropFind +{ /** - * A normal propfind + * A normal propfind. */ const NORMAL = 0; @@ -33,21 +35,21 @@ class PropFind { const PROPNAME = 2; /** - * Creates the PROPFIND object + * Creates the PROPFIND object. * * @param string $path - * @param array $properties - * @param int $depth - * @param int $requestType + * @param array $properties + * @param int $depth + * @param int $requestType */ - function __construct($path, array $properties, $depth = 0, $requestType = self::NORMAL) { - + public function __construct($path, array $properties, $depth = 0, $requestType = self::NORMAL) + { $this->path = $path; $this->properties = $properties; $this->depth = $depth; $this->requestType = $requestType; - if ($requestType === self::ALLPROPS) { + if (self::ALLPROPS === $requestType) { $this->properties = [ '{DAV:}getlastmodified', '{DAV:}getcontentlength', @@ -60,13 +62,10 @@ class PropFind { } foreach ($this->properties as $propertyName) { - // Seeding properties with 404's. $this->result[$propertyName] = [404, null]; - } $this->itemsLeft = count($this->result); - } /** @@ -88,68 +87,65 @@ class PropFind { * It's also possible to not pass a callback, but immediately pass a value * * @param string $propertyName - * @param mixed $valueOrCallBack - * @return void + * @param mixed $valueOrCallBack */ - function handle($propertyName, $valueOrCallBack) { - - if ($this->itemsLeft && isset($this->result[$propertyName]) && $this->result[$propertyName][0] === 404) { + public function handle($propertyName, $valueOrCallBack) + { + if ($this->itemsLeft && isset($this->result[$propertyName]) && 404 === $this->result[$propertyName][0]) { if (is_callable($valueOrCallBack)) { $value = $valueOrCallBack(); } else { $value = $valueOrCallBack; } if (!is_null($value)) { - $this->itemsLeft--; + --$this->itemsLeft; $this->result[$propertyName] = [200, $value]; } } - } /** - * Sets the value of the property + * Sets the value of the property. * * If status is not supplied, the status will default to 200 for non-null * properties, and 404 for null properties. * * @param string $propertyName - * @param mixed $value - * @param int $status - * @return void + * @param mixed $value + * @param int $status */ - function set($propertyName, $value, $status = null) { - + public function set($propertyName, $value, $status = null) + { if (is_null($status)) { $status = is_null($value) ? 404 : 200; } // If this is an ALLPROPS request and the property is // unknown, add it to the result; else ignore it: if (!isset($this->result[$propertyName])) { - if ($this->requestType === self::ALLPROPS) { + if (self::ALLPROPS === $this->requestType) { $this->result[$propertyName] = [$status, $value]; } + return; } - if ($status !== 404 && $this->result[$propertyName][0] === 404) { - $this->itemsLeft--; - } elseif ($status === 404 && $this->result[$propertyName][0] !== 404) { - $this->itemsLeft++; + if (404 !== $status && 404 === $this->result[$propertyName][0]) { + --$this->itemsLeft; + } elseif (404 === $status && 404 !== $this->result[$propertyName][0]) { + ++$this->itemsLeft; } $this->result[$propertyName] = [$status, $value]; - } /** * Returns the current value for a property. * * @param string $propertyName + * * @return mixed */ - function get($propertyName) { - + public function get($propertyName) + { return isset($this->result[$propertyName]) ? $this->result[$propertyName][1] : null; - } /** @@ -159,24 +155,22 @@ class PropFind { * null will be returned. * * @param string $propertyName + * * @return int|null */ - function getStatus($propertyName) { - + public function getStatus($propertyName) + { return isset($this->result[$propertyName]) ? $this->result[$propertyName][0] : null; - } /** * Updates the path for this PROPFIND. * * @param string $path - * @return void */ - function setPath($path) { - + public function setPath($path) + { $this->path = $path; - } /** @@ -184,10 +178,9 @@ class PropFind { * * @return string */ - function getPath() { - + public function getPath() + { return $this->path; - } /** @@ -195,22 +188,19 @@ class PropFind { * * @return int */ - function getDepth() { - + public function getDepth() + { return $this->depth; - } /** * Updates the depth of this propfind request. * * @param int $depth - * @return void */ - function setDepth($depth) { - + public function setDepth($depth) + { $this->depth = $depth; - } /** @@ -219,19 +209,19 @@ class PropFind { * * @return array */ - function get404Properties() { - - if ($this->itemsLeft === 0) { + public function get404Properties() + { + if (0 === $this->itemsLeft) { return []; } $result = []; foreach ($this->result as $propertyName => $stuff) { - if ($stuff[0] === 404) { + if (404 === $stuff[0]) { $result[] = $propertyName; } } - return $result; + return $result; } /** @@ -241,10 +231,9 @@ class PropFind { * * @return array */ - function getRequestedProperties() { - + public function getRequestedProperties() + { return $this->properties; - } /** @@ -252,10 +241,9 @@ class PropFind { * * @return bool */ - function isAllProps() { - - return $this->requestType === self::ALLPROPS; - + public function isAllProps() + { + return self::ALLPROPS === $this->requestType; } /** @@ -270,8 +258,8 @@ class PropFind { * * @return array */ - function getResultForMultiStatus() { - + public function getResultForMultiStatus() + { $r = [ 200 => [], 404 => [], @@ -284,9 +272,11 @@ class PropFind { } } // Removing the 404's for multi-status requests. - if ($this->requestType === self::ALLPROPS) unset($r[404]); - return $r; + if (self::ALLPROPS === $this->requestType) { + unset($r[404]); + } + return $r; } /** @@ -307,12 +297,12 @@ class PropFind { protected $depth = 0; /** - * The type of request. See the TYPE constants + * The type of request. See the TYPE constants. */ protected $requestType; /** - * A list of requested properties + * A list of requested properties. * * @var array */ @@ -343,5 +333,4 @@ class PropFind { * @var int */ protected $itemsLeft; - } diff --git a/vendor/sabre/dav/lib/DAV/PropPatch.php b/vendor/sabre/dav/lib/DAV/PropPatch.php index 6d599dacc..160bdb1a8 100644 --- a/vendor/sabre/dav/lib/DAV/PropPatch.php +++ b/vendor/sabre/dav/lib/DAV/PropPatch.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use UnexpectedValueException; @@ -17,8 +19,8 @@ use UnexpectedValueException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PropPatch { - +class PropPatch +{ /** * Properties that are being updated. * @@ -52,14 +54,13 @@ class PropPatch { protected $failed = false; /** - * Constructor + * Constructor. * * @param array $mutations A list of updates */ - function __construct(array $mutations) { - + public function __construct(array $mutations) + { $this->mutations = $mutations; - } /** @@ -81,21 +82,17 @@ class PropPatch { * code associated with the operation. * * @param string|string[] $properties - * @param callable $callback - * @return void + * @param callable $callback */ - function handle($properties, callable $callback) { - + public function handle($properties, callable $callback) + { $usedProperties = []; - foreach ((array)$properties as $propertyName) { - + foreach ((array) $properties as $propertyName) { if (array_key_exists($propertyName, $this->mutations) && !isset($this->result[$propertyName])) { - $usedProperties[] = $propertyName; // HTTP Accepted $this->result[$propertyName] = 202; } - } // Only registering if there's any unhandled properties. @@ -107,9 +104,8 @@ class PropPatch { // to also make sure that it stays that way, so the commit function // knows how to format the arguments to the callback. is_string($properties) ? $properties : $usedProperties, - $callback + $callback, ]; - } /** @@ -118,10 +114,9 @@ class PropPatch { * this that you promise to process _all_ properties that are coming in. * * @param callable $callback - * @return void */ - function handleRemaining(callable $callback) { - + public function handleRemaining(callable $callback) + { $properties = $this->getRemainingMutations(); if (!$properties) { // Nothing to do, don't register callback @@ -134,44 +129,39 @@ class PropPatch { $this->propertyUpdateCallbacks[] = [ $properties, - $callback + $callback, ]; } - } /** * Sets the result code for one or more properties. * * @param string|string[] $properties - * @param int $resultCode - * @return void + * @param int $resultCode */ - function setResultCode($properties, $resultCode) { - - foreach ((array)$properties as $propertyName) { + public function setResultCode($properties, $resultCode) + { + foreach ((array) $properties as $propertyName) { $this->result[$propertyName] = $resultCode; } if ($resultCode >= 400) { $this->failed = true; } - } /** * Sets the result code for all properties that did not have a result yet. * * @param int $resultCode - * @return void */ - function setRemainingResultCode($resultCode) { - + public function setRemainingResultCode($resultCode) + { $this->setResultCode( $this->getRemainingMutations(), $resultCode ); - } /** @@ -181,8 +171,8 @@ class PropPatch { * * @return string[] */ - function getRemainingMutations() { - + public function getRemainingMutations() + { $remaining = []; foreach ($this->mutations as $propertyName => $propValue) { if (!isset($this->result[$propertyName])) { @@ -191,7 +181,6 @@ class PropPatch { } return $remaining; - } /** @@ -201,8 +190,8 @@ class PropPatch { * * @return array */ - function getRemainingValues() { - + public function getRemainingValues() + { $remaining = []; foreach ($this->mutations as $propertyName => $propValue) { if (!isset($this->result[$propertyName])) { @@ -211,7 +200,6 @@ class PropPatch { } return $remaining; - } /** @@ -222,20 +210,17 @@ class PropPatch { * * @return bool */ - function commit() { - + public function commit() + { // First we validate if every property has a handler foreach ($this->mutations as $propertyName => $value) { - if (!isset($this->result[$propertyName])) { $this->failed = true; $this->result[$propertyName] = 403; } - } foreach ($this->propertyUpdateCallbacks as $callbackInfo) { - if ($this->failed) { break; } @@ -244,37 +229,32 @@ class PropPatch { } else { $this->doCallbackMultiProp($callbackInfo[0], $callbackInfo[1]); } - } - /** + /* * If anywhere in this operation updating a property failed, we must * update all other properties accordingly. */ if ($this->failed) { - foreach ($this->result as $propertyName => $status) { - if ($status === 202) { + if (202 === $status) { // Failed dependency $this->result[$propertyName] = 424; } } - } return !$this->failed; - } /** * Executes a property callback with the single-property syntax. * - * @param string $propertyName + * @param string $propertyName * @param callable $callback - * @return void */ - private function doCallBackSingleProp($propertyName, callable $callback) { - + private function doCallBackSingleProp($propertyName, callable $callback) + { $result = $callback($this->mutations[$propertyName]); if (is_bool($result)) { if ($result) { @@ -297,18 +277,16 @@ class PropPatch { if ($result >= 400) { $this->failed = true; } - } /** * Executes a property callback with the multi-property syntax. * - * @param array $propertyList + * @param array $propertyList * @param callable $callback - * @return void */ - private function doCallBackMultiProp(array $propertyList, callable $callback) { - + private function doCallBackMultiProp(array $propertyList, callable $callback) + { $argument = []; foreach ($propertyList as $propertyName) { $argument[$propertyName] = $this->mutations[$propertyName]; @@ -327,16 +305,13 @@ class PropPatch { $this->failed = true; } $this->result[$propertyName] = $resultCode; - } - } elseif ($result === true) { - + } elseif (true === $result) { // Success foreach ($argument as $propertyName => $propertyValue) { $this->result[$propertyName] = is_null($propertyValue) ? 204 : 200; } - - } elseif ($result === false) { + } elseif (false === $result) { // Fail :( $this->failed = true; foreach ($propertyList as $propertyName) { @@ -345,7 +320,6 @@ class PropPatch { } else { throw new UnexpectedValueException('A callback sent to handle() did not return an array or a bool'); } - } /** @@ -353,21 +327,18 @@ class PropPatch { * * @return array */ - function getResult() { - + public function getResult() + { return $this->result; - } /** - * Returns the full list of mutations + * Returns the full list of mutations. * * @return array */ - function getMutations() { - + public function getMutations() + { return $this->mutations; - } - } diff --git a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php index b15d7fef9..4bdc44775 100644 --- a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PropertyStorage\Backend; use Sabre\DAV\PropFind; @@ -15,8 +17,8 @@ use Sabre\DAV\PropPatch; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * Fetches properties for a path. * @@ -30,14 +32,13 @@ interface BackendInterface { * However, you can also support the 'allprops' property here. In that * case, you should check for $propFind->isAllProps(). * - * @param string $path + * @param string $path * @param PropFind $propFind - * @return void */ - function propFind($path, PropFind $propFind); + public function propFind($path, PropFind $propFind); /** - * Updates properties for a path + * Updates properties for a path. * * This method received a PropPatch object, which contains all the * information about the update. @@ -45,11 +46,10 @@ interface BackendInterface { * Usually you would want to call 'handleRemaining' on this object, to get; * a list of all properties that need to be stored. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch); + public function propPatch($path, PropPatch $propPatch); /** * This method is called after a node is deleted. @@ -60,12 +60,11 @@ interface BackendInterface { * tree. * * @param string $path - * @return void */ - function delete($path); + public function delete($path); /** - * This method is called after a successful MOVE + * This method is called after a successful MOVE. * * This should be used to migrate all properties from one path to another. * Note that entire collections may be moved, so ensure that all properties @@ -73,8 +72,6 @@ interface BackendInterface { * * @param string $source * @param string $destination - * @return void */ - function move($source, $destination); - + public function move($source, $destination); } diff --git a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php index 6f3f1feaf..e640f420e 100644 --- a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php +++ b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PropertyStorage\Backend; use Sabre\DAV\PropFind; @@ -18,8 +20,8 @@ use Sabre\DAV\Xml\Property\Complex; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO implements BackendInterface { - +class PDO implements BackendInterface +{ /** * Value is stored as string. */ @@ -36,28 +38,27 @@ class PDO implements BackendInterface { const VT_OBJECT = 3; /** - * PDO + * PDO. * * @var \PDO */ protected $pdo; /** - * PDO table name we'll be using + * PDO table name we'll be using. * * @var string */ public $tableName = 'propertystorage'; /** - * Creates the PDO property storage engine + * Creates the PDO property storage engine. * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -73,42 +74,40 @@ class PDO implements BackendInterface { * However, you can also support the 'allprops' property here. In that * case, you should check for $propFind->isAllProps(). * - * @param string $path + * @param string $path * @param PropFind $propFind - * @return void */ - function propFind($path, PropFind $propFind) { - - if (!$propFind->isAllProps() && count($propFind->get404Properties()) === 0) { + public function propFind($path, PropFind $propFind) + { + if (!$propFind->isAllProps() && 0 === count($propFind->get404Properties())) { return; } - $query = 'SELECT name, value, valuetype FROM ' . $this->tableName . ' WHERE path = ?'; + $query = 'SELECT name, value, valuetype FROM '.$this->tableName.' WHERE path = ?'; $stmt = $this->pdo->prepare($query); $stmt->execute([$path]); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - if (gettype($row['value']) === 'resource') { + if ('resource' === gettype($row['value'])) { $row['value'] = stream_get_contents($row['value']); } switch ($row['valuetype']) { - case null : - case self::VT_STRING : + case null: + case self::VT_STRING: $propFind->set($row['name'], $row['value']); break; - case self::VT_XML : + case self::VT_XML: $propFind->set($row['name'], new Complex($row['value'])); break; - case self::VT_OBJECT : + case self::VT_OBJECT: $propFind->set($row['name'], unserialize($row['value'])); break; } } - } /** - * Updates properties for a path + * Updates properties for a path. * * This method received a PropPatch object, which contains all the * information about the update. @@ -116,38 +115,30 @@ class PDO implements BackendInterface { * Usually you would want to call 'handleRemaining' on this object, to get; * a list of all properties that need to be stored. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch) { - - $propPatch->handleRemaining(function($properties) use ($path) { - - - if ($this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'pgsql') { - + public function propPatch($path, PropPatch $propPatch) + { + $propPatch->handleRemaining(function ($properties) use ($path) { + if ('pgsql' === $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) { $updateSql = <<<SQL INSERT INTO {$this->tableName} (path, name, valuetype, value) VALUES (:path, :name, :valuetype, :value) ON CONFLICT (path, name) DO UPDATE SET valuetype = :valuetype, value = :value SQL; - - } else { $updateSql = <<<SQL REPLACE INTO {$this->tableName} (path, name, valuetype, value) VALUES (:path, :name, :valuetype, :value) SQL; - } $updateStmt = $this->pdo->prepare($updateSql); - $deleteStmt = $this->pdo->prepare("DELETE FROM " . $this->tableName . " WHERE path = ? AND name = ?"); + $deleteStmt = $this->pdo->prepare('DELETE FROM '.$this->tableName.' WHERE path = ? AND name = ?'); foreach ($properties as $name => $value) { - if (!is_null($value)) { if (is_scalar($value)) { $valueType = self::VT_STRING; @@ -165,17 +156,13 @@ SQL; $updateStmt->bindParam('value', $value, \PDO::PARAM_LOB); $updateStmt->execute(); - } else { $deleteStmt->execute([$path, $name]); } - } return true; - }); - } /** @@ -187,26 +174,24 @@ SQL; * tree. * * @param string $path - * @return void */ - function delete($path) { - - $stmt = $this->pdo->prepare("DELETE FROM " . $this->tableName . " WHERE path = ? OR path LIKE ? ESCAPE '='"); + public function delete($path) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->tableName." WHERE path = ? OR path LIKE ? ESCAPE '='"); $childPath = strtr( $path, [ '=' => '==', '%' => '=%', - '_' => '=_' + '_' => '=_', ] - ) . '/%'; + ).'/%'; $stmt->execute([$path, $childPath]); - } /** - * This method is called after a successful MOVE + * This method is called after a successful MOVE. * * This should be used to migrate all properties from one path to another. * Note that entire collections may be moved, so ensure that all properties @@ -214,33 +199,30 @@ SQL; * * @param string $source * @param string $destination - * @return void */ - function move($source, $destination) { - + public function move($source, $destination) + { // I don't know a way to write this all in a single sql query that's // also compatible across db engines, so we're letting PHP do all the // updates. Much slower, but it should still be pretty fast in most // cases. - $select = $this->pdo->prepare('SELECT id, path FROM ' . $this->tableName . ' WHERE path = ? OR path LIKE ?'); - $select->execute([$source, $source . '/%']); + $select = $this->pdo->prepare('SELECT id, path FROM '.$this->tableName.' WHERE path = ? OR path LIKE ?'); + $select->execute([$source, $source.'/%']); - $update = $this->pdo->prepare('UPDATE ' . $this->tableName . ' SET path = ? WHERE id = ?'); + $update = $this->pdo->prepare('UPDATE '.$this->tableName.' SET path = ? WHERE id = ?'); while ($row = $select->fetch(\PDO::FETCH_ASSOC)) { - // Sanity check. SQL may select too many records, such as records // with different cases. - if ($row['path'] !== $source && strpos($row['path'], $source . '/') !== 0) continue; + if ($row['path'] !== $source && 0 !== strpos($row['path'], $source.'/')) { + continue; + } $trailingPart = substr($row['path'], strlen($source) + 1); $newPath = $destination; if ($trailingPart) { - $newPath .= '/' . $trailingPart; + $newPath .= '/'.$trailingPart; } $update->execute([$newPath, $row['id']]); - } - } - } diff --git a/vendor/sabre/dav/lib/DAV/PropertyStorage/Plugin.php b/vendor/sabre/dav/lib/DAV/PropertyStorage/Plugin.php index a66a14113..aa8610eb8 100644 --- a/vendor/sabre/dav/lib/DAV/PropertyStorage/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/PropertyStorage/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PropertyStorage; use Sabre\DAV\INode; @@ -23,8 +25,8 @@ use Sabre\DAV\ServerPlugin; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ /** * If you only want this plugin to store properties for a limited set of * paths, you can use a pathFilter to do this. @@ -43,14 +45,13 @@ class Plugin extends ServerPlugin { public $backend; /** - * Creates the plugin + * Creates the plugin. * * @param Backend\BackendInterface $backend */ - function __construct(Backend\BackendInterface $backend) { - + public function __construct(Backend\BackendInterface $backend) + { $this->backend = $backend; - } /** @@ -62,15 +63,13 @@ class Plugin extends ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - function initialize(Server $server) { - - $server->on('propFind', [$this, 'propFind'], 130); - $server->on('propPatch', [$this, 'propPatch'], 300); - $server->on('afterMove', [$this, 'afterMove']); + public function initialize(Server $server) + { + $server->on('propFind', [$this, 'propFind'], 130); + $server->on('propPatch', [$this, 'propPatch'], 300); + $server->on('afterMove', [$this, 'afterMove']); $server->on('afterUnbind', [$this, 'afterUnbind']); - } /** @@ -80,34 +79,34 @@ class Plugin extends ServerPlugin { * plugin will look in the property storage backend to find them. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - + public function propFind(PropFind $propFind, INode $node) + { $path = $propFind->getPath(); $pathFilter = $this->pathFilter; - if ($pathFilter && !$pathFilter($path)) return; + if ($pathFilter && !$pathFilter($path)) { + return; + } $this->backend->propFind($propFind->getPath(), $propFind); - } /** - * Called during PROPPATCH operations + * Called during PROPPATCH operations. * * If there's any updated properties that haven't been stored, the * propertystorage backend can handle it. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch) { - + public function propPatch($path, PropPatch $propPatch) + { $pathFilter = $this->pathFilter; - if ($pathFilter && !$pathFilter($path)) return; + if ($pathFilter && !$pathFilter($path)) { + return; + } $this->backend->propPatch($path, $propPatch); - } /** @@ -117,14 +116,14 @@ class Plugin extends ServerPlugin { * database. * * @param string $path - * @return void */ - function afterUnbind($path) { - + public function afterUnbind($path) + { $pathFilter = $this->pathFilter; - if ($pathFilter && !$pathFilter($path)) return; + if ($pathFilter && !$pathFilter($path)) { + return; + } $this->backend->delete($path); - } /** @@ -134,18 +133,20 @@ class Plugin extends ServerPlugin { * * @param string $source * @param string $destination - * @return void */ - function afterMove($source, $destination) { - + public function afterMove($source, $destination) + { $pathFilter = $this->pathFilter; - if ($pathFilter && !$pathFilter($source)) return; + if ($pathFilter && !$pathFilter($source)) { + return; + } // If the destination is filtered, afterUnbind will handle cleaning up // the properties. - if ($pathFilter && !$pathFilter($destination)) return; + if ($pathFilter && !$pathFilter($destination)) { + return; + } $this->backend->move($source, $destination); - } /** @@ -156,10 +157,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'property-storage'; - } /** @@ -173,13 +173,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'This plugin allows any arbitrary WebDAV property to be set on any resource.', - 'link' => 'http://sabre.io/dav/property-storage/', + 'link' => 'http://sabre.io/dav/property-storage/', ]; - } } diff --git a/vendor/sabre/dav/lib/DAV/Server.php b/vendor/sabre/dav/lib/DAV/Server.php index f7fcf3057..09760e9d1 100644 --- a/vendor/sabre/dav/lib/DAV/Server.php +++ b/vendor/sabre/dav/lib/DAV/Server.php @@ -1,76 +1,79 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; -use Sabre\Event\EventEmitter; +use Sabre\Event\EmitterInterface; +use Sabre\Event\WildcardEmitterTrait; use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -use Sabre\HTTP\URLUtil; use Sabre\Uri; /** - * Main DAV server class + * Main DAV server class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Server extends EventEmitter implements LoggerAwareInterface { - +class Server implements LoggerAwareInterface, EmitterInterface +{ + use WildcardEmitterTrait; use LoggerAwareTrait; /** - * Infinity is used for some request supporting the HTTP Depth header and indicates that the operation should traverse the entire tree + * Infinity is used for some request supporting the HTTP Depth header and indicates that the operation should traverse the entire tree. */ const DEPTH_INFINITY = -1; /** - * XML namespace for all SabreDAV related elements + * XML namespace for all SabreDAV related elements. */ const NS_SABREDAV = 'http://sabredav.org/ns'; /** - * The tree object + * The tree object. * * @var Tree */ public $tree; /** - * The base uri + * The base uri. * * @var string */ protected $baseUri = null; /** - * httpResponse + * httpResponse. * * @var HTTP\Response */ public $httpResponse; /** - * httpRequest + * httpRequest. * * @var HTTP\Request */ public $httpRequest; /** - * PHP HTTP Sapi + * PHP HTTP Sapi. * * @var HTTP\Sapi */ public $sapi; /** - * The list of plugins + * The list of plugins. * * @var array */ @@ -98,7 +101,6 @@ class Server extends EventEmitter implements LoggerAwareInterface { * @var string[] */ public $protectedProperties = [ - // RFC4918 '{DAV:}getcontentlength', '{DAV:}getetag', @@ -129,12 +131,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { // sabredav extensions '{http://sabredav.org/ns}sync-token', - ]; /** * This is a flag that allow or not showing file, line and code - * of the exception in the returned XML + * of the exception in the returned XML. * * @var bool */ @@ -181,10 +182,10 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @var bool */ - static $exposeVersion = true; + public static $exposeVersion = true; /** - * Sets up the server + * Sets up the server. * * If a Sabre\DAV\Tree object is passed as an argument, it will * use it as the directory tree. If a Sabre\DAV\INode is passed, it @@ -198,25 +199,15 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @param Tree|INode|array|null $treeOrNode The tree object */ - function __construct($treeOrNode = null) { - + public function __construct($treeOrNode = null) + { if ($treeOrNode instanceof Tree) { $this->tree = $treeOrNode; } elseif ($treeOrNode instanceof INode) { $this->tree = new Tree($treeOrNode); } elseif (is_array($treeOrNode)) { - - // If it's an array, a list of nodes was passed, and we need to - // create the root node. - foreach ($treeOrNode as $node) { - if (!($node instanceof INode)) { - throw new Exception('Invalid argument passed to constructor. If you\'re passing an array, all the values must implement Sabre\\DAV\\INode'); - } - } - $root = new SimpleCollection('root', $treeOrNode); $this->tree = new Tree($root); - } elseif (is_null($treeOrNode)) { $root = new SimpleCollection('root'); $this->tree = new Tree($root); @@ -229,18 +220,14 @@ class Server extends EventEmitter implements LoggerAwareInterface { $this->httpResponse = new HTTP\Response(); $this->httpRequest = $this->sapi->getRequest(); $this->addPlugin(new CorePlugin()); - } /** - * Starts the DAV Server - * - * @return void + * Starts the DAV Server. */ - function exec() { - + public function start() + { try { - // If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an // origin, we must make sure we send back HTTP/1.0 if this was // requested. @@ -252,9 +239,7 @@ class Server extends EventEmitter implements LoggerAwareInterface { // Setting the base url $this->httpRequest->setBaseUrl($this->getBaseUri()); $this->invokeMethod($this->httpRequest, $this->httpResponse); - - } catch (\Exception $e) { - + } catch (\Throwable $e) { try { $this->emit('exception', [$e]); } catch (\Exception $ignore) { @@ -266,10 +251,8 @@ class Server extends EventEmitter implements LoggerAwareInterface { $error->setAttribute('xmlns:s', self::NS_SABREDAV); $DOM->appendChild($error); - $h = function($v) { - - return htmlspecialchars($v, ENT_NOQUOTES, 'UTF-8'); - + $h = function ($v) { + return htmlspecialchars((string) $v, ENT_NOQUOTES, 'UTF-8'); }; if (self::$exposeVersion) { @@ -299,18 +282,13 @@ class Server extends EventEmitter implements LoggerAwareInterface { } } - if ($e instanceof Exception) { - $httpCode = $e->getHTTPCode(); $e->serialize($this, $error); $headers = $e->getHTTPHeaders($this); - } else { - $httpCode = 500; $headers = []; - } $headers['Content-Type'] = 'application/xml; charset=utf-8'; @@ -318,37 +296,46 @@ class Server extends EventEmitter implements LoggerAwareInterface { $this->httpResponse->setHeaders($headers); $this->httpResponse->setBody($DOM->saveXML()); $this->sapi->sendResponse($this->httpResponse); - } + } + /** + * Alias of start(). + * + * @deprecated + */ + public function exec() + { + $this->start(); } /** - * Sets the base server uri + * Sets the base server uri. * * @param string $uri - * @return void */ - function setBaseUri($uri) { - + public function setBaseUri($uri) + { // If the baseUri does not end with a slash, we must add it - if ($uri[strlen($uri) - 1] !== '/') + if ('/' !== $uri[strlen($uri) - 1]) { $uri .= '/'; + } $this->baseUri = $uri; - } /** - * Returns the base responding uri + * Returns the base responding uri. * * @return string */ - function getBaseUri() { + public function getBaseUri() + { + if (is_null($this->baseUri)) { + $this->baseUri = $this->guessBaseUri(); + } - if (is_null($this->baseUri)) $this->baseUri = $this->guessBaseUri(); return $this->baseUri; - } /** @@ -359,53 +346,50 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @return string */ - function guessBaseUri() { - + public function guessBaseUri() + { $pathInfo = $this->httpRequest->getRawServerValue('PATH_INFO'); $uri = $this->httpRequest->getRawServerValue('REQUEST_URI'); // If PATH_INFO is found, we can assume it's accurate. if (!empty($pathInfo)) { - // We need to make sure we ignore the QUERY_STRING part - if ($pos = strpos($uri, '?')) + if ($pos = strpos($uri, '?')) { $uri = substr($uri, 0, $pos); + } // PATH_INFO is only set for urls, such as: /example.php/path // in that case PATH_INFO contains '/path'. // Note that REQUEST_URI is percent encoded, while PATH_INFO is // not, Therefore they are only comparable if we first decode // REQUEST_INFO as well. - $decodedUri = URLUtil::decodePath($uri); + $decodedUri = HTTP\decodePath($uri); // A simple sanity check: if (substr($decodedUri, strlen($decodedUri) - strlen($pathInfo)) === $pathInfo) { $baseUri = substr($decodedUri, 0, strlen($decodedUri) - strlen($pathInfo)); - return rtrim($baseUri, '/') . '/'; - } - throw new Exception('The REQUEST_URI (' . $uri . ') did not end with the contents of PATH_INFO (' . $pathInfo . '). This server might be misconfigured.'); + return rtrim($baseUri, '/').'/'; + } + throw new Exception('The REQUEST_URI ('.$uri.') did not end with the contents of PATH_INFO ('.$pathInfo.'). This server might be misconfigured.'); } // The last fallback is that we're just going to assume the server root. return '/'; - } /** - * Adds a plugin to the server + * Adds a plugin to the server. * * For more information, console the documentation of Sabre\DAV\ServerPlugin * * @param ServerPlugin $plugin - * @return void */ - function addPlugin(ServerPlugin $plugin) { - + public function addPlugin(ServerPlugin $plugin) + { $this->plugins[$plugin->getPluginName()] = $plugin; $plugin->initialize($this); - } /** @@ -414,26 +398,26 @@ class Server extends EventEmitter implements LoggerAwareInterface { * This function returns null if the plugin was not found. * * @param string $name + * * @return ServerPlugin */ - function getPlugin($name) { - - if (isset($this->plugins[$name])) + public function getPlugin($name) + { + if (isset($this->plugins[$name])) { return $this->plugins[$name]; + } return null; - } /** - * Returns all plugins + * Returns all plugins. * * @return array */ - function getPlugins() { - + public function getPlugins() + { return $this->plugins; - } /** @@ -441,29 +425,29 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @return LoggerInterface */ - function getLogger() { - + public function getLogger() + { if (!$this->logger) { $this->logger = new NullLogger(); } - return $this->logger; + return $this->logger; } /** - * Handles a http request, and execute a method based on its name + * Handles a http request, and execute a method based on its name. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @param bool $sendResponse Whether to send the HTTP response to the DAV client. - * @return void + * @param bool $sendResponse whether to send the HTTP response to the DAV client */ - function invokeMethod(RequestInterface $request, ResponseInterface $response, $sendResponse = true) { - + public function invokeMethod(RequestInterface $request, ResponseInterface $response, $sendResponse = true) + { $method = $request->getMethod(); - if (!$this->emit('beforeMethod:' . $method, [$request, $response])) return; - if (!$this->emit('beforeMethod', [$request, $response])) return; + if (!$this->emit('beforeMethod:'.$method, [$request, $response])) { + return; + } if (self::$exposeVersion) { $response->setHeader('X-Sabre-Version', Version::VERSION); @@ -473,32 +457,31 @@ class Server extends EventEmitter implements LoggerAwareInterface { if (!$this->checkPreconditions($request, $response)) { $this->sapi->sendResponse($response); + return; } - if ($this->emit('method:' . $method, [$request, $response])) { - if ($this->emit('method', [$request, $response])) { - $exMessage = "There was no plugin in the system that was willing to handle this " . $method . " method."; - if ($method === "GET") { - $exMessage .= " Enable the Browser plugin to get a better result here."; - } - - // Unsupported method - throw new Exception\NotImplemented($exMessage); + if ($this->emit('method:'.$method, [$request, $response])) { + $exMessage = 'There was no plugin in the system that was willing to handle this '.$method.' method.'; + if ('GET' === $method) { + $exMessage .= ' Enable the Browser plugin to get a better result here.'; } + + // Unsupported method + throw new Exception\NotImplemented($exMessage); } - if (!$this->emit('afterMethod:' . $method, [$request, $response])) return; - if (!$this->emit('afterMethod', [$request, $response])) return; + if (!$this->emit('afterMethod:'.$method, [$request, $response])) { + return; + } - if ($response->getStatus() === null) { + if (null === $response->getStatus()) { throw new Exception('No subsystem set a valid HTTP status code. Something must have interrupted the request without providing further detail.'); } if ($sendResponse) { $this->sapi->sendResponse($response); $this->emit('afterResponse', [$request, $response]); } - } // {{{ HTTP/WebDAV protocol helpers @@ -507,10 +490,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { * Returns an array with all the supported HTTP methods for a specific uri. * * @param string $path + * * @return array */ - function getAllowedMethods($path) { - + public function getAllowedMethods($path) + { $methods = [ 'OPTIONS', 'GET', @@ -521,7 +505,7 @@ class Server extends EventEmitter implements LoggerAwareInterface { 'PROPPATCH', 'COPY', 'MOVE', - 'REPORT' + 'REPORT', ]; // The MKCOL is only allowed on an unmapped uri @@ -532,22 +516,22 @@ class Server extends EventEmitter implements LoggerAwareInterface { } // We're also checking if any of the plugins register any new methods - foreach ($this->plugins as $plugin) $methods = array_merge($methods, $plugin->getHTTPMethods($path)); + foreach ($this->plugins as $plugin) { + $methods = array_merge($methods, $plugin->getHTTPMethods($path)); + } array_unique($methods); return $methods; - } /** - * Gets the uri for the request, keeping the base uri into consideration + * Gets the uri for the request, keeping the base uri into consideration. * * @return string */ - function getRequestUri() { - + public function getRequestUri() + { return $this->calculateUri($this->httpRequest->getUrl()); - } /** @@ -559,66 +543,65 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * uri-decodes the path * * @param string $uri + * * @throws Exception\Forbidden A permission denied exception is thrown whenever there was an attempt to supply a uri outside of the base uri + * * @return string */ - function calculateUri($uri) { - - if ($uri[0] != '/' && strpos($uri, '://')) { - + public function calculateUri($uri) + { + if ('' != $uri && '/' != $uri[0] && strpos($uri, '://')) { $uri = parse_url($uri, PHP_URL_PATH); - } - $uri = Uri\normalize(str_replace('//', '/', $uri)); + $uri = Uri\normalize(preg_replace('|/+|', '/', $uri)); $baseUri = Uri\normalize($this->getBaseUri()); - if (strpos($uri, $baseUri) === 0) { - - return trim(URLUtil::decodePath(substr($uri, strlen($baseUri))), '/'); + if (0 === strpos($uri, $baseUri)) { + return trim(HTTP\decodePath(substr($uri, strlen($baseUri))), '/'); // A special case, if the baseUri was accessed without a trailing // slash, we'll accept it as well. - } elseif ($uri . '/' === $baseUri) { - + } elseif ($uri.'/' === $baseUri) { return ''; - } else { - - throw new Exception\Forbidden('Requested uri (' . $uri . ') is out of base uri (' . $this->getBaseUri() . ')'); - + throw new Exception\Forbidden('Requested uri ('.$uri.') is out of base uri ('.$this->getBaseUri().')'); } - } /** - * Returns the HTTP depth header + * Returns the HTTP depth header. * * This method returns the contents of the HTTP depth request header. If the depth header was 'infinity' it will return the Sabre\DAV\Server::DEPTH_INFINITY object * It is possible to supply a default depth value, which is used when the depth header has invalid content, or is completely non-existent * * @param mixed $default + * * @return int */ - function getHTTPDepth($default = self::DEPTH_INFINITY) { - + public function getHTTPDepth($default = self::DEPTH_INFINITY) + { // If its not set, we'll grab the default $depth = $this->httpRequest->getHeader('Depth'); - if (is_null($depth)) return $default; - - if ($depth == 'infinity') return self::DEPTH_INFINITY; + if (is_null($depth)) { + return $default; + } + if ('infinity' == $depth) { + return self::DEPTH_INFINITY; + } // If its an unknown value. we'll grab the default - if (!ctype_digit($depth)) return $default; - - return (int)$depth; + if (!ctype_digit($depth)) { + return $default; + } + return (int) $depth; } /** - * Returns the HTTP range header + * Returns the HTTP range header. * * This method returns null if there is no well-formed HTTP range request * header or array($start, $end). @@ -629,24 +612,29 @@ class Server extends EventEmitter implements LoggerAwareInterface { * If the second offset is null, it should be treated as the offset of the last byte of the entity * If the first offset is null, the second offset should be used to retrieve the last x bytes of the entity * - * @return array|null + * @return int[]|null */ - function getHTTPRange() { - + public function getHTTPRange() + { $range = $this->httpRequest->getHeader('range'); - if (is_null($range)) return null; + if (is_null($range)) { + return null; + } // Matching "Range: bytes=1234-5678: both numbers are optional - if (!preg_match('/^bytes=([0-9]*)-([0-9]*)$/i', $range, $matches)) return null; + if (!preg_match('/^bytes=([0-9]*)-([0-9]*)$/i', $range, $matches)) { + return null; + } - if ($matches[1] === '' && $matches[2] === '') return null; + if ('' === $matches[1] && '' === $matches[2]) { + return null; + } return [ - $matches[1] !== '' ? $matches[1] : null, - $matches[2] !== '' ? $matches[2] : null, + '' !== $matches[1] ? (int) $matches[1] : null, + '' !== $matches[2] ? (int) $matches[2] : null, ]; - } /** @@ -675,8 +663,8 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @return array */ - function getHTTPPrefer() { - + public function getHTTPPrefer() + { $result = [ // can be true or false 'respond-async' => false, @@ -689,23 +677,19 @@ class Server extends EventEmitter implements LoggerAwareInterface { ]; if ($prefer = $this->httpRequest->getHeader('Prefer')) { - $result = array_merge( $result, HTTP\parsePrefer($prefer) ); - - } elseif ($this->httpRequest->getHeader('Brief') == 't') { + } elseif ('t' == $this->httpRequest->getHeader('Brief')) { $result['return'] = 'minimal'; } return $result; - } - /** - * Returns information about Copy and Move requests + * Returns information about Copy and Move requests. * * This function is created to help getting information about the source and the destination for the * WebDAV MOVE and COPY HTTP request. It also validates a lot of information and throws proper exceptions @@ -715,74 +699,82 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * destinationExists - Whether or not the destination is an existing url (and should therefore be overwritten) * * @param RequestInterface $request - * @throws Exception\BadRequest upon missing or broken request headers + * + * @throws Exception\BadRequest upon missing or broken request headers * @throws Exception\UnsupportedMediaType when trying to copy into a - * non-collection. - * @throws Exception\PreconditionFailed If overwrite is set to false, but - * the destination exists. - * @throws Exception\Forbidden when source and destination paths are - * identical. - * @throws Exception\Conflict When trying to copy a node into its own - * subtree. + * non-collection + * @throws Exception\PreconditionFailed if overwrite is set to false, but + * the destination exists + * @throws Exception\Forbidden when source and destination paths are + * identical + * @throws Exception\Conflict when trying to copy a node into its own + * subtree + * * @return array */ - function getCopyAndMoveInfo(RequestInterface $request) { - + public function getCopyAndMoveInfo(RequestInterface $request) + { // Collecting the relevant HTTP headers - if (!$request->getHeader('Destination')) throw new Exception\BadRequest('The destination header was not supplied'); + if (!$request->getHeader('Destination')) { + throw new Exception\BadRequest('The destination header was not supplied'); + } $destination = $this->calculateUri($request->getHeader('Destination')); $overwrite = $request->getHeader('Overwrite'); - if (!$overwrite) $overwrite = 'T'; - if (strtoupper($overwrite) == 'T') $overwrite = true; - elseif (strtoupper($overwrite) == 'F') $overwrite = false; + if (!$overwrite) { + $overwrite = 'T'; + } + if ('T' == strtoupper($overwrite)) { + $overwrite = true; + } elseif ('F' == strtoupper($overwrite)) { + $overwrite = false; + } // We need to throw a bad request exception, if the header was invalid - else throw new Exception\BadRequest('The HTTP Overwrite header should be either T or F'); - - list($destinationDir) = URLUtil::splitPath($destination); + else { + throw new Exception\BadRequest('The HTTP Overwrite header should be either T or F'); + } + list($destinationDir) = Uri\split($destination); try { $destinationParent = $this->tree->getNodeForPath($destinationDir); - if (!($destinationParent instanceof ICollection)) throw new Exception\UnsupportedMediaType('The destination node is not a collection'); + if (!($destinationParent instanceof ICollection)) { + throw new Exception\UnsupportedMediaType('The destination node is not a collection'); + } } catch (Exception\NotFound $e) { - // If the destination parent node is not found, we throw a 409 throw new Exception\Conflict('The destination node is not found'); } try { - $destinationNode = $this->tree->getNodeForPath($destination); // If this succeeded, it means the destination already exists // we'll need to throw precondition failed in case overwrite is false - if (!$overwrite) throw new Exception\PreconditionFailed('The destination node already exists, and the overwrite header is set to false', 'Overwrite'); - + if (!$overwrite) { + throw new Exception\PreconditionFailed('The destination node already exists, and the overwrite header is set to false', 'Overwrite'); + } } catch (Exception\NotFound $e) { - // Destination didn't exist, we're all good $destinationNode = false; - } $requestPath = $request->getPath(); if ($destination === $requestPath) { throw new Exception\Forbidden('Source and destination uri are identical.'); } - if (substr($destination, 0, strlen($requestPath) + 1) === $requestPath . '/') { + if (substr($destination, 0, strlen($requestPath) + 1) === $requestPath.'/') { throw new Exception\Conflict('The destination may not be part of the same subtree as the source path.'); } // These are the three relevant properties we need to return return [ - 'destination' => $destination, - 'destinationExists' => !!$destinationNode, - 'destinationNode' => $destinationNode, + 'destination' => $destination, + 'destinationExists' => (bool) $destinationNode, + 'destinationNode' => $destinationNode, ]; - } /** - * Returns a list of properties for a path + * Returns a list of properties for a path. * * This is a simplified version getPropertiesForPath. If you aren't * interested in status codes, but you just want to have a flat list of @@ -793,18 +785,18 @@ class Server extends EventEmitter implements LoggerAwareInterface { * returned. * * @param string $path - * @param array $propertyNames + * @param array $propertyNames + * * @return array */ - function getProperties($path, $propertyNames) { - + public function getProperties($path, $propertyNames) + { $result = $this->getPropertiesForPath($path, $propertyNames, 0); if (isset($result[0][200])) { return $result[0][200]; } else { return []; } - } /** @@ -816,26 +808,27 @@ class Server extends EventEmitter implements LoggerAwareInterface { * The parent node will not be returned. * * @param string $path - * @param array $propertyNames + * @param array $propertyNames + * * @return array */ - function getPropertiesForChildren($path, $propertyNames) { - + public function getPropertiesForChildren($path, $propertyNames) + { $result = []; foreach ($this->getPropertiesForPath($path, $propertyNames, 1) as $k => $row) { - // Skipping the parent path - if ($k === 0) continue; + if (0 === $k) { + continue; + } $result[$row['href']] = $row[200]; - } - return $result; + return $result; } /** - * Returns a list of HTTP headers for a particular resource + * Returns a list of HTTP headers for a particular resource. * * The generated http headers are based on properties provided by the * resource. The method basically provides a simple mapping between @@ -844,61 +837,64 @@ class Server extends EventEmitter implements LoggerAwareInterface { * The headers are intended to be used for HEAD and GET requests. * * @param string $path + * * @return array */ - function getHTTPHeaders($path) { - + public function getHTTPHeaders($path) + { $propertyMap = [ - '{DAV:}getcontenttype' => 'Content-Type', + '{DAV:}getcontenttype' => 'Content-Type', '{DAV:}getcontentlength' => 'Content-Length', - '{DAV:}getlastmodified' => 'Last-Modified', - '{DAV:}getetag' => 'ETag', + '{DAV:}getlastmodified' => 'Last-Modified', + '{DAV:}getetag' => 'ETag', ]; $properties = $this->getProperties($path, array_keys($propertyMap)); $headers = []; foreach ($propertyMap as $property => $header) { - if (!isset($properties[$property])) continue; + if (!isset($properties[$property])) { + continue; + } if (is_scalar($properties[$property])) { $headers[$header] = $properties[$property]; // GetLastModified gets special cased } elseif ($properties[$property] instanceof Xml\Property\GetLastModified) { - $headers[$header] = HTTP\Util::toHTTPDate($properties[$property]->getTime()); + $headers[$header] = HTTP\toDate($properties[$property]->getTime()); } - } return $headers; - } /** * Small helper to support PROPFIND with DEPTH_INFINITY. * * @param PropFind $propFind - * @param array $yieldFirst - * @return \Iterator + * @param array $yieldFirst + * + * @return \Traversable */ - private function generatePathNodes(PropFind $propFind, array $yieldFirst = null) { - if ($yieldFirst !== null) { + private function generatePathNodes(PropFind $propFind, array $yieldFirst = null) + { + if (null !== $yieldFirst) { yield $yieldFirst; } $newDepth = $propFind->getDepth(); $path = $propFind->getPath(); - if ($newDepth !== self::DEPTH_INFINITY) { - $newDepth--; + if (self::DEPTH_INFINITY !== $newDepth) { + --$newDepth; } $propertyNames = $propFind->getRequestedProperties(); $propFindType = !empty($propertyNames) ? PropFind::NORMAL : PropFind::ALLPROPS; foreach ($this->tree->getChildren($path) as $childNode) { - if ($path !== '') { - $subPath = $path . '/' . $childNode->getName(); + if ('' !== $path) { + $subPath = $path.'/'.$childNode->getName(); } else { $subPath = $childNode->getName(); } @@ -906,20 +902,19 @@ class Server extends EventEmitter implements LoggerAwareInterface { yield [ $subPropFind, - $childNode + $childNode, ]; - if (($newDepth === self::DEPTH_INFINITY || $newDepth >= 1) && $childNode instanceof ICollection) { + if ((self::DEPTH_INFINITY === $newDepth || $newDepth >= 1) && $childNode instanceof ICollection) { foreach ($this->generatePathNodes($subPropFind) as $subItem) { yield $subItem; } } - } } /** - * Returns a list of properties for a given path + * Returns a list of properties for a given path. * * The path that should be supplied should have the baseUrl stripped out * The list of properties should be supplied in Clark notation. If the list is empty @@ -928,20 +923,21 @@ class Server extends EventEmitter implements LoggerAwareInterface { * If a depth of 1 is requested child elements will also be returned. * * @param string $path - * @param array $propertyNames - * @param int $depth + * @param array $propertyNames + * @param int $depth + * * @return array * * @deprecated Use getPropertiesIteratorForPath() instead (as it's more memory efficient) * @see getPropertiesIteratorForPath() */ - function getPropertiesForPath($path, $propertyNames = [], $depth = 0) { - + public function getPropertiesForPath($path, $propertyNames = [], $depth = 0) + { return iterator_to_array($this->getPropertiesIteratorForPath($path, $propertyNames, $depth)); - } + /** - * Returns a list of properties for a given path + * Returns a list of properties for a given path. * * The path that should be supplied should have the baseUrl stripped out * The list of properties should be supplied in Clark notation. If the list is empty @@ -950,33 +946,35 @@ class Server extends EventEmitter implements LoggerAwareInterface { * If a depth of 1 is requested child elements will also be returned. * * @param string $path - * @param array $propertyNames - * @param int $depth + * @param array $propertyNames + * @param int $depth + * * @return \Iterator */ - function getPropertiesIteratorForPath($path, $propertyNames = [], $depth = 0) { - + public function getPropertiesIteratorForPath($path, $propertyNames = [], $depth = 0) + { // The only two options for the depth of a propfind is 0 or 1 - as long as depth infinity is not enabled - if (!$this->enablePropfindDepthInfinity && $depth != 0) $depth = 1; + if (!$this->enablePropfindDepthInfinity && 0 != $depth) { + $depth = 1; + } $path = trim($path, '/'); $propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS; - $propFind = new PropFind($path, (array)$propertyNames, $depth, $propFindType); + $propFind = new PropFind($path, (array) $propertyNames, $depth, $propFindType); $parentNode = $this->tree->getNodeForPath($path); $propFindRequests = [[ $propFind, - $parentNode + $parentNode, ]]; - if (($depth > 0 || $depth === self::DEPTH_INFINITY) && $parentNode instanceof ICollection) { + if (($depth > 0 || self::DEPTH_INFINITY === $depth) && $parentNode instanceof ICollection) { $propFindRequests = $this->generatePathNodes(clone $propFind, current($propFindRequests)); } foreach ($propFindRequests as $propFindRequest) { - list($propFind, $node) = $propFindRequest; $r = $this->getPropertiesByNode($propFind, $node); if ($r) { @@ -993,9 +991,7 @@ class Server extends EventEmitter implements LoggerAwareInterface { } yield $result; } - } - } /** @@ -1010,17 +1006,17 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @param array $paths * @param array $propertyNames + * * @return array */ - function getPropertiesForMultiplePaths(array $paths, array $propertyNames = []) { - + public function getPropertiesForMultiplePaths(array $paths, array $propertyNames = []) + { $result = [ ]; $nodes = $this->tree->getMultipleNodes($paths); foreach ($nodes as $path => $node) { - $propFind = new PropFind($path, $propertyNames); $r = $this->getPropertiesByNode($propFind, $node); if ($r) { @@ -1032,14 +1028,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { $result[$path]['href'] .= '/'; } } - } return $result; - } - /** * Determines all properties for a node. * @@ -1051,13 +1044,13 @@ class Server extends EventEmitter implements LoggerAwareInterface { * list of properties. * * @param PropFind $propFind - * @param INode $node + * @param INode $node + * * @return bool */ - function getPropertiesByNode(PropFind $propFind, INode $node) { - + public function getPropertiesByNode(PropFind $propFind, INode $node) + { return $this->emit('propFind', [$propFind, $node]); - } /** @@ -1072,13 +1065,16 @@ class Server extends EventEmitter implements LoggerAwareInterface { * @param string $uri * @param resource $data * @param string $etag + * * @return bool */ - function createFile($uri, $data, &$etag = null) { + public function createFile($uri, $data, &$etag = null) + { + list($dir, $name) = Uri\split($uri); - list($dir, $name) = URLUtil::splitPath($uri); - - if (!$this->emit('beforeBind', [$uri])) return false; + if (!$this->emit('beforeBind', [$uri])) { + return false; + } $parent = $this->tree->getNodeForPath($dir); if (!$parent instanceof ICollection) { @@ -1091,13 +1087,17 @@ class Server extends EventEmitter implements LoggerAwareInterface { // // If $modified is true, we must not send back an ETag. $modified = false; - if (!$this->emit('beforeCreateFile', [$uri, &$data, $parent, &$modified])) return false; + if (!$this->emit('beforeCreateFile', [$uri, &$data, $parent, &$modified])) { + return false; + } $etag = $parent->createFile($name, $data); - if ($modified) $etag = null; + if ($modified) { + $etag = null; + } - $this->tree->markDirty($dir . '/' . $name); + $this->tree->markDirty($dir.'/'.$name); $this->emit('afterBind', [$uri]); $this->emit('afterCreateFile', [$uri, $parent]); @@ -1113,10 +1113,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { * @param string $uri * @param resource $data * @param string $etag + * * @return bool */ - function updateFile($uri, $data, &$etag = null) { - + public function updateFile($uri, $data, &$etag = null) + { $node = $this->tree->getNodeForPath($uri); // It is possible for an event handler to modify the content of the @@ -1125,47 +1126,46 @@ class Server extends EventEmitter implements LoggerAwareInterface { // // If $modified is true, we must not send back an ETag. $modified = false; - if (!$this->emit('beforeWriteContent', [$uri, $node, &$data, &$modified])) return false; + if (!$this->emit('beforeWriteContent', [$uri, $node, &$data, &$modified])) { + return false; + } $etag = $node->put($data); - if ($modified) $etag = null; + if ($modified) { + $etag = null; + } $this->emit('afterWriteContent', [$uri, $node]); return true; } - - /** * This method is invoked by sub-systems creating a new directory. * * @param string $uri - * @return void */ - function createDirectory($uri) { - + public function createDirectory($uri) + { $this->createCollection($uri, new MkCol(['{DAV:}collection'], [])); - } /** - * Use this method to create a new collection + * Use this method to create a new collection. + * + * @param string $uri The new uri + * @param MkCol $mkCol * - * @param string $uri The new uri - * @param MkCol $mkCol * @return array|null */ - function createCollection($uri, MkCol $mkCol) { - - list($parentUri, $newName) = URLUtil::splitPath($uri); + public function createCollection($uri, MkCol $mkCol) + { + list($parentUri, $newName) = Uri\split($uri); // Making sure the parent exists try { $parent = $this->tree->getNodeForPath($parentUri); - } catch (Exception\NotFound $e) { throw new Exception\Conflict('Parent node does not exist'); - } // Making sure the parent is a collection @@ -1179,26 +1179,23 @@ class Server extends EventEmitter implements LoggerAwareInterface { // If we got here.. it means there's already a node on that url, and we need to throw a 405 throw new Exception\MethodNotAllowed('The resource you tried to create already exists'); - } catch (Exception\NotFound $e) { // NotFound is the expected behavior. } - - if (!$this->emit('beforeBind', [$uri])) return; + if (!$this->emit('beforeBind', [$uri])) { + return; + } if ($parent instanceof IExtendedCollection) { - - /** + /* * If the parent is an instance of IExtendedCollection, it means that * we can pass the MkCol object directly as it may be able to store * properties immediately. */ $parent->createExtendedCollection($newName, $mkCol); - } else { - - /** + /* * If the parent is a standard ICollection, it means only * 'standard' collections can be created, so we should fail any * MKCOL operation that carries extra resourcetypes. @@ -1208,7 +1205,6 @@ class Server extends EventEmitter implements LoggerAwareInterface { } $parent->createDirectory($newName); - } // If there are any properties that have not been handled/stored, @@ -1227,23 +1223,21 @@ class Server extends EventEmitter implements LoggerAwareInterface { ]; foreach ($result as $propertyName => $status) { - if (!isset($formattedResult[$status])) { $formattedResult[$status] = []; } $formattedResult[$status][$propertyName] = null; - } + return $formattedResult; } $this->tree->markDirty($parentUri); $this->emit('afterBind', [$uri]); - } /** - * This method updates a resource's properties + * This method updates a resource's properties. * * The properties array must be a list of properties. Array-keys are * property names in clarknotation, array-values are it's values. @@ -1256,17 +1250,17 @@ class Server extends EventEmitter implements LoggerAwareInterface { * as their values. * * @param string $path - * @param array $properties + * @param array $properties + * * @return array */ - function updateProperties($path, array $properties) { - + public function updateProperties($path, array $properties) + { $propPatch = new PropPatch($properties); $this->emit('propPatch', [$path, $propPatch]); $propPatch->commit(); return $propPatch->getResult(); - } /** @@ -1287,19 +1281,19 @@ class Server extends EventEmitter implements LoggerAwareInterface { * related to If-None-Match, If-Match and If-Unmodified Since. It will * set the status to 304 Not Modified for If-Modified_since. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function checkPreconditions(RequestInterface $request, ResponseInterface $response) { - + public function checkPreconditions(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $node = null; $lastMod = null; $etag = null; if ($ifMatch = $request->getHeader('If-Match')) { - // If-Match contains an entity tag. Only if the entity-tag // matches we are allowed to make the request succeed. // If the entity-tag is '*' we are only allowed to make the @@ -1311,13 +1305,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { } // Only need to check entity tags if they are not * - if ($ifMatch !== '*') { - + if ('*' !== $ifMatch) { // There can be multiple ETags $ifMatch = explode(',', $ifMatch); $haveMatch = false; foreach ($ifMatch as $ifMatchItem) { - // Stripping any extra spaces $ifMatchItem = trim($ifMatchItem, ' '); @@ -1331,17 +1323,17 @@ class Server extends EventEmitter implements LoggerAwareInterface { $haveMatch = true; } } - } if (!$haveMatch) { - if ($etag) $response->setHeader('ETag', $etag); - throw new Exception\PreconditionFailed('An If-Match header was specified, but none of the specified the ETags matched.', 'If-Match'); + if ($etag) { + $response->setHeader('ETag', $etag); + } + throw new Exception\PreconditionFailed('An If-Match header was specified, but none of the specified ETags matched.', 'If-Match'); } } } if ($ifNoneMatch = $request->getHeader('If-None-Match')) { - // The If-None-Match header contains an ETag. // Only if the ETag does not match the current ETag, the request will succeed // The header can also contain *, in which case the request @@ -1356,46 +1348,46 @@ class Server extends EventEmitter implements LoggerAwareInterface { } if ($nodeExists) { $haveMatch = false; - if ($ifNoneMatch === '*') $haveMatch = true; - else { - + if ('*' === $ifNoneMatch) { + $haveMatch = true; + } else { // There might be multiple ETags $ifNoneMatch = explode(',', $ifNoneMatch); $etag = $node instanceof IFile ? $node->getETag() : null; foreach ($ifNoneMatch as $ifNoneMatchItem) { - // Stripping any extra spaces $ifNoneMatchItem = trim($ifNoneMatchItem, ' '); - if ($etag === $ifNoneMatchItem) $haveMatch = true; - + if ($etag === $ifNoneMatchItem) { + $haveMatch = true; + } } - } if ($haveMatch) { - if ($etag) $response->setHeader('ETag', $etag); - if ($request->getMethod() === 'GET') { + if ($etag) { + $response->setHeader('ETag', $etag); + } + if ('GET' === $request->getMethod()) { $response->setStatus(304); + return false; } else { throw new Exception\PreconditionFailed('An If-None-Match header was specified, but the ETag matched (or * was specified).', 'If-None-Match'); } } } - } if (!$ifNoneMatch && ($ifModifiedSince = $request->getHeader('If-Modified-Since'))) { - // The If-Modified-Since header contains a date. We // will only return the entity if it has been changed since // that date. If it hasn't been changed, we return a 304 // header // Note that this header only has to be checked if there was no If-None-Match header // as per the HTTP spec. - $date = HTTP\Util::parseHTTPDate($ifModifiedSince); + $date = HTTP\parseDate($ifModifiedSince); if ($date) { if (is_null($node)) { @@ -1403,10 +1395,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { } $lastMod = $node->getLastModified(); if ($lastMod) { - $lastMod = new \DateTime('@' . $lastMod); + $lastMod = new \DateTime('@'.$lastMod); if ($lastMod <= $date) { $response->setStatus(304); - $response->setHeader('Last-Modified', HTTP\Util::toHTTPDate($lastMod)); + $response->setHeader('Last-Modified', HTTP\toDate($lastMod)); + return false; } } @@ -1414,10 +1407,9 @@ class Server extends EventEmitter implements LoggerAwareInterface { } if ($ifUnmodifiedSince = $request->getHeader('If-Unmodified-Since')) { - // The If-Unmodified-Since will allow allow the request if the // entity has not changed since the specified date. - $date = HTTP\Util::parseHTTPDate($ifUnmodifiedSince); + $date = HTTP\parseDate($ifUnmodifiedSince); // We must only check the date if it's valid if ($date) { @@ -1426,13 +1418,12 @@ class Server extends EventEmitter implements LoggerAwareInterface { } $lastMod = $node->getLastModified(); if ($lastMod) { - $lastMod = new \DateTime('@' . $lastMod); + $lastMod = new \DateTime('@'.$lastMod); if ($lastMod > $date) { throw new Exception\PreconditionFailed('An If-Unmodified-Since header was specified, but the entity has been changed since the specified date.', 'If-Unmodified-Since'); } } } - } // Now the hardest, the If: header. The If: header can contain multiple @@ -1461,13 +1452,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { // Every ifCondition needs to validate to true, so we exit as soon as // we have an invalid condition. foreach ($ifConditions as $ifCondition) { - $uri = $ifCondition['uri']; $tokens = $ifCondition['tokens']; // We only need 1 valid token for the condition to succeed. foreach ($tokens as $token) { - $tokenValid = $token['validToken'] || !$token['token']; $etagValid = false; @@ -1477,35 +1466,28 @@ class Server extends EventEmitter implements LoggerAwareInterface { // Checking the ETag, only if the token was already deemed // valid and there is one. if ($token['etag'] && $tokenValid) { - // The token was valid, and there was an ETag. We must // grab the current ETag and check it. $node = $this->tree->getNodeForPath($uri); $etagValid = $node instanceof IFile && $node->getETag() == $token['etag']; - } - if (($tokenValid && $etagValid) ^ $token['negate']) { // Both were valid, so we can go to the next condition. continue 2; } - - } // If we ended here, it means there was no valid ETag + token // combination found for the current condition. This means we fail! - throw new Exception\PreconditionFailed('Failed to find a valid token/etag combination for ' . $uri, 'If'); - + throw new Exception\PreconditionFailed('Failed to find a valid token/etag combination for '.$uri, 'If'); } return true; - } /** - * This method is created to extract information from the WebDAV HTTP 'If:' header + * This method is created to extract information from the WebDAV HTTP 'If:' header. * * The If header can be quite complex, and has a bunch of features. We're using a regex to extract all relevant information * The function will return an array, containing structs with the following keys @@ -1573,12 +1555,15 @@ class Server extends EventEmitter implements LoggerAwareInterface { * ] * * @param RequestInterface $request + * * @return array */ - function getIfConditions(RequestInterface $request) { - + public function getIfConditions(RequestInterface $request) + { $header = $request->getHeader('If'); - if (!$header) return []; + if (!$header) { + return []; + } $matches = []; @@ -1588,18 +1573,16 @@ class Server extends EventEmitter implements LoggerAwareInterface { $conditions = []; foreach ($matches as $match) { - // If there was no uri specified in this match, and there were // already conditions parsed, we add the condition to the list of // conditions for the previous uri. if (!$match['uri'] && count($conditions)) { $conditions[count($conditions) - 1]['tokens'][] = [ 'negate' => $match['not'] ? true : false, - 'token' => $match['token'], - 'etag' => isset($match['etag']) ? $match['etag'] : '' + 'token' => $match['token'], + 'etag' => isset($match['etag']) ? $match['etag'] : '', ]; } else { - if (!$match['uri']) { $realUri = $request->getPath(); } else { @@ -1607,55 +1590,55 @@ class Server extends EventEmitter implements LoggerAwareInterface { } $conditions[] = [ - 'uri' => $realUri, + 'uri' => $realUri, 'tokens' => [ [ 'negate' => $match['not'] ? true : false, - 'token' => $match['token'], - 'etag' => isset($match['etag']) ? $match['etag'] : '' - ] + 'token' => $match['token'], + 'etag' => isset($match['etag']) ? $match['etag'] : '', + ], ], - ]; } - } return $conditions; - } /** * Returns an array with resourcetypes for a node. * * @param INode $node + * * @return array */ - function getResourceTypeForNode(INode $node) { - + public function getResourceTypeForNode(INode $node) + { $result = []; foreach ($this->resourceTypeMapping as $className => $resourceType) { - if ($node instanceof $className) $result[] = $resourceType; + if ($node instanceof $className) { + $result[] = $resourceType; + } } - return $result; + return $result; } // }}} // {{{ XML Readers & Writers - /** * Generates a WebDAV propfind response body based on a list of nodes. * * If 'strip404s' is set to true, all 404 responses will be removed. * * @param array|\Traversable $fileProperties The list with nodes - * @param bool $strip404s + * @param bool $strip404s + * * @return string */ - function generateMultiStatus($fileProperties, $strip404s = false) { - + public function generateMultiStatus($fileProperties, $strip404s = false) + { $w = $this->xml->getWriter(); $w->openMemory(); $w->contextUri = $this->baseUri; @@ -1664,7 +1647,6 @@ class Server extends EventEmitter implements LoggerAwareInterface { $w->startElement('{DAV:}multistatus'); foreach ($fileProperties as $entry) { - $href = $entry['href']; unset($entry['href']); if ($strip404s) { @@ -1675,14 +1657,12 @@ class Server extends EventEmitter implements LoggerAwareInterface { $entry ); $w->write([ - 'name' => '{DAV:}response', - 'value' => $response + 'name' => '{DAV:}response', + 'value' => $response, ]); } $w->endElement(); return $w->outputMemory(); - } - } diff --git a/vendor/sabre/dav/lib/DAV/ServerPlugin.php b/vendor/sabre/dav/lib/DAV/ServerPlugin.php index b2c468ab3..9aefa7f72 100644 --- a/vendor/sabre/dav/lib/DAV/ServerPlugin.php +++ b/vendor/sabre/dav/lib/DAV/ServerPlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -11,8 +13,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class ServerPlugin { - +abstract class ServerPlugin +{ /** * This initializes the plugin. * @@ -22,9 +24,8 @@ abstract class ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - abstract function initialize(Server $server); + abstract public function initialize(Server $server); /** * This method should return a list of server-features. @@ -34,10 +35,9 @@ abstract class ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return []; - } /** @@ -48,12 +48,12 @@ abstract class ServerPlugin { * available for the specified uri. * * @param string $path + * * @return array */ - function getHTTPMethods($path) { - + public function getHTTPMethods($path) + { return []; - } /** @@ -64,10 +64,9 @@ abstract class ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return get_class($this); - } /** @@ -78,12 +77,12 @@ abstract class ServerPlugin { * implement them * * @param string $uri + * * @return array */ - function getSupportedReportSet($uri) { - + public function getSupportedReportSet($uri) + { return []; - } /** @@ -97,14 +96,12 @@ abstract class ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => null, - 'link' => null, + 'link' => null, ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php b/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php index 034aefbdc..a746ac753 100644 --- a/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php +++ b/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Sharing; use Sabre\DAV\INode; @@ -13,8 +15,8 @@ use Sabre\DAV\INode; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ISharedNode extends INode { - +interface ISharedNode extends INode +{ /** * Returns the 'access level' for the instance of this shared resource. * @@ -23,7 +25,7 @@ interface ISharedNode extends INode { * * @return int */ - function getShareAccess(); + public function getShareAccess(); /** * This function must return a URI that uniquely identifies the shared @@ -36,7 +38,7 @@ interface ISharedNode extends INode { * * @return string */ - function getShareResourceUri(); + public function getShareResourceUri(); /** * Updates the list of sharees. @@ -44,9 +46,8 @@ interface ISharedNode extends INode { * Every item must be a Sharee object. * * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees - * @return void */ - function updateInvites(array $sharees); + public function updateInvites(array $sharees); /** * Returns the list of people whom this resource is shared with. @@ -64,6 +65,5 @@ interface ISharedNode extends INode { * * @return \Sabre\DAV\Xml\Element\Sharee[] */ - function getInvites(); - + public function getInvites(); } diff --git a/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php b/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php index ef5702c57..5706fabf1 100644 --- a/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Sharing; use Sabre\DAV\Exception\BadRequest; @@ -14,7 +16,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * This plugin implements HTTP requests and properties related to: + * This plugin implements HTTP requests and properties related to:. * * draft-pot-webdav-resource-sharing * @@ -24,8 +26,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ const ACCESS_NOTSHARED = 0; const ACCESS_SHAREDOWNER = 1; const ACCESS_READ = 2; @@ -52,10 +54,9 @@ class Plugin extends ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['resource-sharing']; - } /** @@ -66,10 +67,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'sharing'; - } /** @@ -81,10 +81,9 @@ class Plugin extends ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; $server->xml->elementMap['{DAV:}share-resource'] = 'Sabre\\DAV\\Xml\\Request\\ShareResource'; @@ -94,12 +93,11 @@ class Plugin extends ServerPlugin { '{DAV:}share-mode' ); - $server->on('method:POST', [$this, 'httpPost']); - $server->on('propFind', [$this, 'propFind']); + $server->on('method:POST', [$this, 'httpPost']); + $server->on('propFind', [$this, 'propFind']); $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']); - $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); - $server->on('onBrowserPostAction', [$this, 'browserPostAction']); - + $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); + $server->on('onBrowserPostAction', [$this, 'browserPostAction']); } /** @@ -108,18 +106,15 @@ class Plugin extends ServerPlugin { * The sharees array is a list of people that are to be added modified * or removed in the list of shares. * - * @param string $path + * @param string $path * @param Sharee[] $sharees - * @return void */ - function shareResource($path, array $sharees) { - + public function shareResource($path, array $sharees) + { $node = $this->server->tree->getNodeForPath($path); if (!$node instanceof ISharedNode) { - throw new Forbidden('Sharing is not allowed on this node'); - } // Getting ACL info @@ -138,7 +133,6 @@ class Plugin extends ServerPlugin { $sharee->principal = $principal; } $node->updateInvites($sharees); - } /** @@ -147,47 +141,41 @@ class Plugin extends ServerPlugin { * This allows us to inject any sharings-specific properties. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - + public function propFind(PropFind $propFind, INode $node) + { if ($node instanceof ISharedNode) { - - $propFind->handle('{DAV:}share-access', function() use ($node) { - + $propFind->handle('{DAV:}share-access', function () use ($node) { return new Property\ShareAccess($node->getShareAccess()); - }); - $propFind->handle('{DAV:}invite', function() use ($node) { - + $propFind->handle('{DAV:}invite', function () use ($node) { return new Property\Invite($node->getInvites()); - }); - $propFind->handle('{DAV:}share-resource-uri', function() use ($node) { - + $propFind->handle('{DAV:}share-resource-uri', function () use ($node) { return new Property\Href($node->getShareResourceUri()); - }); - } - } /** - * We intercept this to handle POST requests on shared resources + * We intercept this to handle POST requests on shared resources. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return null|bool + * + * @return bool|null */ - function httpPost(RequestInterface $request, ResponseInterface $response) { - + public function httpPost(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $contentType = $request->getHeader('Content-Type'); + if (null === $contentType) { + return; + } // We're only interested in the davsharing content type. - if (strpos($contentType, 'application/davsharing+xml') === false) { + if (false === strpos($contentType, 'application/davsharing+xml')) { return; } @@ -198,7 +186,6 @@ class Plugin extends ServerPlugin { ); switch ($documentType) { - case '{DAV:}share-resource': $this->shareResource($path, $message->sharees); @@ -210,11 +197,9 @@ class Plugin extends ServerPlugin { // Breaking the event chain return false; - default : - throw new BadRequest('Unexpected document type: ' . $documentType . ' for this Content-Type'); - + default: + throw new BadRequest('Unexpected document type: '.$documentType.' for this Content-Type'); } - } /** @@ -226,11 +211,11 @@ class Plugin extends ServerPlugin { * @param INode $node * @param array $supportedPrivilegeSet */ - function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) { - + public function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) + { if ($node instanceof ISharedNode) { $supportedPrivilegeSet['{DAV:}share'] = [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ]; } @@ -247,27 +232,27 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'This plugin implements WebDAV resource sharing', - 'link' => 'https://github.com/evert/webdav-sharing' + 'link' => 'https://github.com/evert/webdav-sharing', ]; - } /** * This method is used to generate HTML output for the * DAV\Browser\Plugin. * - * @param INode $node + * @param INode $node * @param string $output * @param string $path + * * @return bool|null */ - function htmlActionsPanel(INode $node, &$output, $path) { - + public function htmlActionsPanel(INode $node, &$output, $path) + { if (!$node instanceof ISharedNode) { return; } @@ -293,7 +278,6 @@ class Plugin extends ServerPlugin { <input type="submit" value="share" /> </form> </td></tr>'; - } /** @@ -302,11 +286,11 @@ class Plugin extends ServerPlugin { * * @param string $path * @param string $action - * @param array $postVars + * @param array $postVars */ - function browserPostAction($path, $action, $postVars) { - - if ($action !== 'share') { + public function browserPostAction($path, $action, $postVars) + { + if ('share' !== $action) { return; } @@ -319,7 +303,7 @@ class Plugin extends ServerPlugin { $accessMap = [ 'readwrite' => self::ACCESS_READWRITE, - 'read' => self::ACCESS_READ, + 'read' => self::ACCESS_READ, 'no-access' => self::ACCESS_NOACCESS, ]; @@ -327,7 +311,7 @@ class Plugin extends ServerPlugin { throw new BadRequest('The "access" POST must be readwrite, read or no-access'); } $sharee = new Sharee([ - 'href' => $postVars['href'], + 'href' => $postVars['href'], 'access' => $accessMap[$postVars['access']], ]); @@ -335,8 +319,7 @@ class Plugin extends ServerPlugin { $path, [$sharee] ); - return false; + return false; } - } diff --git a/vendor/sabre/dav/lib/DAV/SimpleCollection.php b/vendor/sabre/dav/lib/DAV/SimpleCollection.php index 998cfcbff..1fbb6982d 100644 --- a/vendor/sabre/dav/lib/DAV/SimpleCollection.php +++ b/vendor/sabre/dav/lib/DAV/SimpleCollection.php @@ -1,9 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; +use InvalidArgumentException; + /** - * SimpleCollection + * SimpleCollection. * * The SimpleCollection is used to quickly setup static directory structures. * Just create the object with a proper name, and add children to use it. @@ -12,64 +16,64 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SimpleCollection extends Collection { - +class SimpleCollection extends Collection +{ /** - * List of childnodes + * List of childnodes. * * @var INode[] */ protected $children = []; /** - * Name of this resource + * Name of this resource. * * @var string */ protected $name; /** - * Creates this node + * Creates this node. * * The name of the node must be passed, child nodes can also be passed. * This nodes must be instances of INode * - * @param string $name + * @param string $name * @param INode[] $children */ - function __construct($name, array $children = []) { - + public function __construct($name, array $children = []) + { $this->name = $name; - foreach ($children as $child) { - - if (!($child instanceof INode)) throw new Exception('Only instances of Sabre\DAV\INode are allowed to be passed in the children argument'); + foreach ($children as $key => $child) { + if (is_string($child)) { + $child = new SimpleFile($key, $child); + } elseif (is_array($child)) { + $child = new self($key, $child); + } elseif (!$child instanceof INode) { + throw new InvalidArgumentException('Children must be specified as strings, arrays or instances of Sabre\DAV\INode'); + } $this->addChild($child); - } - } /** - * Adds a new childnode to this collection + * Adds a new childnode to this collection. * * @param INode $child - * @return void */ - function addChild(INode $child) { - + public function addChild(INode $child) + { $this->children[$child->getName()] = $child; - } /** - * Returns the name of the collection + * Returns the name of the collection. * * @return string */ - function getName() { - + public function getName() + { return $this->name; - } /** @@ -82,26 +86,26 @@ class SimpleCollection extends Collection { * exist. * * @param string $name + * * @throws Exception\NotFound + * * @return INode */ - function getChild($name) { - - if (isset($this->children[$name])) return $this->children[$name]; - throw new Exception\NotFound('File not found: ' . $name . ' in \'' . $this->getName() . '\''); - + public function getChild($name) + { + if (isset($this->children[$name])) { + return $this->children[$name]; + } + throw new Exception\NotFound('File not found: '.$name.' in \''.$this->getName().'\''); } /** - * Returns a list of children for this collection + * Returns a list of children for this collection. * * @return INode[] */ - function getChildren() { - + public function getChildren() + { return array_values($this->children); - } - - } diff --git a/vendor/sabre/dav/lib/DAV/SimpleFile.php b/vendor/sabre/dav/lib/DAV/SimpleFile.php index bcad786f3..ca808b672 100644 --- a/vendor/sabre/dav/lib/DAV/SimpleFile.php +++ b/vendor/sabre/dav/lib/DAV/SimpleFile.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * SimpleFile + * SimpleFile. * * The 'SimpleFile' class is used to easily add read-only immutable files to * the directory structure. One usecase would be to add a 'readme.txt' to a @@ -13,45 +15,44 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SimpleFile extends File { - +class SimpleFile extends File +{ /** - * File contents + * File contents. * * @var string */ protected $contents = []; /** - * Name of this resource + * Name of this resource. * * @var string */ protected $name; /** - * A mimetype, such as 'text/plain' or 'text/html' + * A mimetype, such as 'text/plain' or 'text/html'. * * @var string */ protected $mimeType; /** - * Creates this node + * Creates this node. * * The name of the node must be passed, as well as the contents of the * file. * - * @param string $name - * @param string $contents + * @param string $name + * @param string $contents * @param string|null $mimeType */ - function __construct($name, $contents, $mimeType = null) { - + public function __construct($name, $contents, $mimeType = null) + { $this->name = $name; $this->contents = $contents; $this->mimeType = $mimeType; - } /** @@ -61,23 +62,21 @@ class SimpleFile extends File { * * @return string */ - function getName() { - + public function getName() + { return $this->name; - } /** - * Returns the data + * Returns the data. * * This method may either return a string or a readable stream resource * * @return mixed */ - function get() { - + public function get() + { return $this->contents; - } /** @@ -85,37 +84,35 @@ class SimpleFile extends File { * * @return int */ - function getSize() { - + public function getSize() + { return strlen($this->contents); - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. * * Return null if the ETag can not effectively be determined + * * @return string */ - function getETag() { - - return '"' . sha1($this->contents) . '"'; - + public function getETag() + { + return '"'.sha1($this->contents).'"'; } /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream + * * @return string */ - function getContentType() { - + public function getContentType() + { return $this->mimeType; - } - } diff --git a/vendor/sabre/dav/lib/DAV/StringUtil.php b/vendor/sabre/dav/lib/DAV/StringUtil.php index 10eecebfd..13a4399e3 100644 --- a/vendor/sabre/dav/lib/DAV/StringUtil.php +++ b/vendor/sabre/dav/lib/DAV/StringUtil.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * String utility + * String utility. * * This class is mainly used to implement the 'text-match' filter, used by both * the CalDAV calendar-query REPORT, and CardDAV addressbook-query REPORT. @@ -13,79 +15,74 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class StringUtil { - +class StringUtil +{ /** - * Checks if a needle occurs in a haystack ;) + * Checks if a needle occurs in a haystack ;). * * @param string $haystack * @param string $needle * @param string $collation * @param string $matchType + * * @return bool */ - static function textMatch($haystack, $needle, $collation, $matchType = 'contains') { - + public static function textMatch($haystack, $needle, $collation, $matchType = 'contains') + { switch ($collation) { - - case 'i;ascii-casemap' : + case 'i;ascii-casemap': // default strtolower takes locale into consideration // we don't want this. $haystack = str_replace(range('a', 'z'), range('A', 'Z'), $haystack); $needle = str_replace(range('a', 'z'), range('A', 'Z'), $needle); break; - case 'i;octet' : + case 'i;octet': // Do nothing break; - case 'i;unicode-casemap' : + case 'i;unicode-casemap': $haystack = mb_strtoupper($haystack, 'UTF-8'); $needle = mb_strtoupper($needle, 'UTF-8'); break; - default : - throw new Exception\BadRequest('Collation type: ' . $collation . ' is not supported'); - + default: + throw new Exception\BadRequest('Collation type: '.$collation.' is not supported'); } switch ($matchType) { - - case 'contains' : - return strpos($haystack, $needle) !== false; - case 'equals' : + case 'contains': + return false !== strpos($haystack, $needle); + case 'equals': return $haystack === $needle; - case 'starts-with' : - return strpos($haystack, $needle) === 0; - case 'ends-with' : + case 'starts-with': + return 0 === strpos($haystack, $needle); + case 'ends-with': return strrpos($haystack, $needle) === strlen($haystack) - strlen($needle); - default : - throw new Exception\BadRequest('Match-type: ' . $matchType . ' is not supported'); - + default: + throw new Exception\BadRequest('Match-type: '.$matchType.' is not supported'); } - } /** * This method takes an input string, checks if it's not valid UTF-8 and * attempts to convert it to UTF-8 if it's not. * - * Note that currently this can only convert ISO-8559-1 to UTF-8 (latin-1), + * Note that currently this can only convert ISO-8859-1 to UTF-8 (latin-1), * anything else will likely fail. * * @param string $input + * * @return string */ - static function ensureUTF8($input) { - + public static function ensureUTF8($input) + { $encoding = mb_detect_encoding($input, ['UTF-8', 'ISO-8859-1'], true); - if ($encoding === 'ISO-8859-1') { + if ('ISO-8859-1' === $encoding) { return utf8_encode($input); } else { return $input; } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php b/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php index d3dc28a80..4ca69dc89 100644 --- a/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php +++ b/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Sync; use Sabre\DAV; @@ -15,8 +17,8 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ISyncCollection extends DAV\ICollection { - +interface ISyncCollection extends DAV\ICollection +{ /** * This method returns the current sync-token for this collection. * This can be any string. @@ -26,7 +28,7 @@ interface ISyncCollection extends DAV\ICollection { * * @return string|null */ - function getSyncToken(); + public function getSyncToken(); /** * The getChanges method returns all the changes that have happened, since @@ -79,10 +81,10 @@ interface ISyncCollection extends DAV\ICollection { * The limit is 'suggestive'. You are free to ignore it. * * @param string $syncToken - * @param int $syncLevel - * @param int $limit + * @param int $syncLevel + * @param int $limit + * * @return array */ - function getChanges($syncToken, $syncLevel, $limit = null); - + public function getChanges($syncToken, $syncLevel, $limit = null); } diff --git a/vendor/sabre/dav/lib/DAV/Sync/Plugin.php b/vendor/sabre/dav/lib/DAV/Sync/Plugin.php index 8e4b1aa64..f76827fe3 100644 --- a/vendor/sabre/dav/lib/DAV/Sync/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Sync/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Sync; use Sabre\DAV; @@ -18,10 +20,10 @@ use Sabre\HTTP\RequestInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * Reference to server object + * Reference to server object. * * @var DAV\Server */ @@ -37,10 +39,9 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'sync'; - } /** @@ -49,28 +50,25 @@ class Plugin extends DAV\ServerPlugin { * This is when the plugin registers it's hooks. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $server->xml->elementMap['{DAV:}sync-collection'] = 'Sabre\\DAV\\Xml\\Request\\SyncCollectionReport'; $self = $this; - $server->on('report', function($reportName, $dom, $uri) use ($self) { - - if ($reportName === '{DAV:}sync-collection') { + $server->on('report', function ($reportName, $dom, $uri) use ($self) { + if ('{DAV:}sync-collection' === $reportName) { $this->server->transactionType = 'report-sync-collection'; $self->syncCollection($uri, $dom); + return false; } - }); - $server->on('propFind', [$this, 'propFind']); + $server->on('propFind', [$this, 'propFind']); $server->on('validateTokens', [$this, 'validateTokens']); - } /** @@ -81,10 +79,11 @@ class Plugin extends DAV\ServerPlugin { * implement them * * @param string $uri + * * @return array */ - function getSupportedReportSet($uri) { - + public function getSupportedReportSet($uri) + { $node = $this->server->tree->getNodeForPath($uri); if ($node instanceof ISyncCollection && $node->getSyncToken()) { return [ @@ -93,19 +92,16 @@ class Plugin extends DAV\ServerPlugin { } return []; - } - /** * This method handles the {DAV:}sync-collection HTTP REPORT. * - * @param string $uri + * @param string $uri * @param SyncCollectionReport $report - * @return void */ - function syncCollection($uri, SyncCollectionReport $report) { - + public function syncCollection($uri, SyncCollectionReport $report) + { // Getting the data $node = $this->server->tree->getNodeForPath($uri); if (!$node instanceof ISyncCollection) { @@ -119,19 +115,16 @@ class Plugin extends DAV\ServerPlugin { $syncToken = $report->syncToken; if (!is_null($syncToken)) { // Sync-token must start with our prefix - if (substr($syncToken, 0, strlen(self::SYNCTOKEN_PREFIX)) !== self::SYNCTOKEN_PREFIX) { + if (self::SYNCTOKEN_PREFIX !== substr($syncToken, 0, strlen(self::SYNCTOKEN_PREFIX))) { throw new DAV\Exception\InvalidSyncToken('Invalid or unknown sync token'); } $syncToken = substr($syncToken, strlen(self::SYNCTOKEN_PREFIX)); - } $changeInfo = $node->getChanges($syncToken, $report->syncLevel, $report->limit); if (is_null($changeInfo)) { - throw new DAV\Exception\InvalidSyncToken('Invalid or unknown sync token'); - } // Encoding the response @@ -143,7 +136,6 @@ class Plugin extends DAV\ServerPlugin { $changeInfo['deleted'], $report->properties ); - } /** @@ -151,50 +143,41 @@ class Plugin extends DAV\ServerPlugin { * * @param string $syncToken * @param string $collectionUrl - * @param array $added - * @param array $modified - * @param array $deleted - * @param array $properties - * @return void + * @param array $added + * @param array $modified + * @param array $deleted + * @param array $properties */ - protected function sendSyncCollectionResponse($syncToken, $collectionUrl, array $added, array $modified, array $deleted, array $properties) { - - + protected function sendSyncCollectionResponse($syncToken, $collectionUrl, array $added, array $modified, array $deleted, array $properties) + { $fullPaths = []; // Pre-fetching children, if this is possible. foreach (array_merge($added, $modified) as $item) { - $fullPath = $collectionUrl . '/' . $item; + $fullPath = $collectionUrl.'/'.$item; $fullPaths[] = $fullPath; } $responses = []; foreach ($this->server->getPropertiesForMultiplePaths($fullPaths, $properties) as $fullPath => $props) { - // The 'Property_Response' class is responsible for generating a // single {DAV:}response xml element. $responses[] = new DAV\Xml\Element\Response($fullPath, $props); - } - - // Deleted items also show up as 'responses'. They have no properties, // and a single {DAV:}status element set as 'HTTP/1.1 404 Not Found'. foreach ($deleted as $item) { - - $fullPath = $collectionUrl . '/' . $item; + $fullPath = $collectionUrl.'/'.$item; $responses[] = new DAV\Xml\Element\Response($fullPath, [], 404); - } - $multiStatus = new DAV\Xml\Response\MultiStatus($responses, self::SYNCTOKEN_PREFIX . $syncToken); + $multiStatus = new DAV\Xml\Response\MultiStatus($responses, self::SYNCTOKEN_PREFIX.$syncToken); $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setBody( $this->server->xml->write('{DAV:}multistatus', $multiStatus, $this->server->getBaseUri()) ); - } /** @@ -202,18 +185,17 @@ class Plugin extends DAV\ServerPlugin { * We intercept this to see if we must return a {DAV:}sync-token. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFind(DAV\PropFind $propFind, DAV\INode $node) { - - $propFind->handle('{DAV:}sync-token', function() use ($node) { + public function propFind(DAV\PropFind $propFind, DAV\INode $node) + { + $propFind->handle('{DAV:}sync-token', function () use ($node) { if (!$node instanceof ISyncCollection || !$token = $node->getSyncToken()) { return; } - return self::SYNCTOKEN_PREFIX . $token; - }); + return self::SYNCTOKEN_PREFIX.$token; + }); } /** @@ -223,17 +205,14 @@ class Plugin extends DAV\ServerPlugin { * in the If: header, and check if they are valid. * * @param RequestInterface $request - * @param array $conditions - * @return void + * @param array $conditions */ - function validateTokens(RequestInterface $request, &$conditions) { - + public function validateTokens(RequestInterface $request, &$conditions) + { foreach ($conditions as $kk => $condition) { - foreach ($condition['tokens'] as $ii => $token) { - // Sync-tokens must always start with our designated prefix. - if (substr($token['token'], 0, strlen(self::SYNCTOKEN_PREFIX)) !== self::SYNCTOKEN_PREFIX) { + if (self::SYNCTOKEN_PREFIX !== substr($token['token'], 0, strlen(self::SYNCTOKEN_PREFIX))) { continue; } @@ -246,11 +225,8 @@ class Plugin extends DAV\ServerPlugin { ) { $conditions[$kk]['tokens'][$ii]['validToken'] = true; } - } - } - } /** @@ -264,14 +240,12 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds support for WebDAV Collection Sync (rfc6578)', - 'link' => 'http://sabre.io/dav/sync/', + 'link' => 'http://sabre.io/dav/sync/', ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/TemporaryFileFilterPlugin.php b/vendor/sabre/dav/lib/DAV/TemporaryFileFilterPlugin.php index 7b453d105..6cf772f44 100644 --- a/vendor/sabre/dav/lib/DAV/TemporaryFileFilterPlugin.php +++ b/vendor/sabre/dav/lib/DAV/TemporaryFileFilterPlugin.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * Temporary File Filter Plugin + * Temporary File Filter Plugin. * * The purpose of this filter is to intercept some of the garbage files * operation systems and applications tend to generate when mounting @@ -30,8 +32,8 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class TemporaryFileFilterPlugin extends ServerPlugin { - +class TemporaryFileFilterPlugin extends ServerPlugin +{ /** * This is the list of patterns we intercept. * If new patterns are added, they must be valid patterns for preg_match. @@ -49,7 +51,7 @@ class TemporaryFileFilterPlugin extends ServerPlugin { ]; /** - * A reference to the main Server class + * A reference to the main Server class. * * @var \Sabre\DAV\Server */ @@ -72,58 +74,61 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * * @param string|null $dataDir */ - function __construct($dataDir = null) { - - if (!$dataDir) $dataDir = ini_get('session.save_path') . '/sabredav/'; - if (!is_dir($dataDir)) mkdir($dataDir); + public function __construct($dataDir = null) + { + if (!$dataDir) { + $dataDir = ini_get('session.save_path').'/sabredav/'; + } + if (!is_dir($dataDir)) { + mkdir($dataDir); + } $this->dataDir = $dataDir; - } /** - * Initialize the plugin + * Initialize the plugin. * * This is called automatically be the Server class after this plugin is * added with Sabre\DAV\Server::addPlugin() * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; - $server->on('beforeMethod', [$this, 'beforeMethod']); + $server->on('beforeMethod:*', [$this, 'beforeMethod']); $server->on('beforeCreateFile', [$this, 'beforeCreateFile']); - } /** - * This method is called before any HTTP method handler + * This method is called before any HTTP method handler. * * This method intercepts any GET, DELETE, PUT and PROPFIND calls to * filenames that are known to match the 'temporary file' regex. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function beforeMethod(RequestInterface $request, ResponseInterface $response) { - - if (!$tempLocation = $this->isTempFile($request->getPath())) + public function beforeMethod(RequestInterface $request, ResponseInterface $response) + { + if (!$tempLocation = $this->isTempFile($request->getPath())) { return; + } switch ($request->getMethod()) { - case 'GET' : + case 'GET': return $this->httpGet($request, $response, $tempLocation); - case 'PUT' : + case 'PUT': return $this->httpPut($request, $response, $tempLocation); - case 'PROPFIND' : + case 'PROPFIND': return $this->httpPropfind($request, $response, $tempLocation); - case 'DELETE' : + case 'DELETE': return $this->httpDelete($request, $response, $tempLocation); } - return; + return; } /** @@ -132,24 +137,25 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * This is used to deal with HTTP LOCK requests which create a new * file. * - * @param string $uri - * @param resource $data + * @param string $uri + * @param resource $data * @param ICollection $parent - * @param bool $modified Should be set to true, if this event handler - * changed &$data. + * @param bool $modified should be set to true, if this event handler + * changed &$data + * * @return bool */ - function beforeCreateFile($uri, $data, ICollection $parent, $modified) { - + public function beforeCreateFile($uri, $data, ICollection $parent, $modified) + { if ($tempPath = $this->isTempFile($uri)) { - $hR = $this->server->httpResponse; $hR->setHeader('X-Sabre-Temp', 'true'); file_put_contents($tempPath, $data); + return false; } - return; + return; } /** @@ -158,71 +164,76 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * temporary file storage. * * @param string $path + * * @return bool|string */ - protected function isTempFile($path) { - + protected function isTempFile($path) + { // We're only interested in the basename. - list(, $tempPath) = URLUtil::splitPath($path); + list(, $tempPath) = Uri\split($path); - foreach ($this->temporaryFilePatterns as $tempFile) { + if (null === $tempPath) { + return false; + } + foreach ($this->temporaryFilePatterns as $tempFile) { if (preg_match($tempFile, $tempPath)) { - return $this->getDataDir() . '/sabredav_' . md5($path) . '.tempfile'; + return $this->getDataDir().'/sabredav_'.md5($path).'.tempfile'; } - } return false; - } - /** * This method handles the GET method for temporary files. * If the file doesn't exist, it will return false which will kick in * the regular system for the GET method. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $hR - * @param string $tempLocation + * @param string $tempLocation + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $hR, $tempLocation) { - - if (!file_exists($tempLocation)) return; + public function httpGet(RequestInterface $request, ResponseInterface $hR, $tempLocation) + { + if (!file_exists($tempLocation)) { + return; + } $hR->setHeader('Content-Type', 'application/octet-stream'); $hR->setHeader('Content-Length', filesize($tempLocation)); $hR->setHeader('X-Sabre-Temp', 'true'); $hR->setStatus(200); $hR->setBody(fopen($tempLocation, 'r')); - return false; + return false; } /** * This method handles the PUT method. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $hR - * @param string $tempLocation + * @param string $tempLocation + * * @return bool */ - function httpPut(RequestInterface $request, ResponseInterface $hR, $tempLocation) { - + public function httpPut(RequestInterface $request, ResponseInterface $hR, $tempLocation) + { $hR->setHeader('X-Sabre-Temp', 'true'); $newFile = !file_exists($tempLocation); if (!$newFile && ($this->server->httpRequest->getHeader('If-None-Match'))) { - throw new Exception\PreconditionFailed('The resource already exists, and an If-None-Match header was supplied'); + throw new Exception\PreconditionFailed('The resource already exists, and an If-None-Match header was supplied'); } file_put_contents($tempLocation, $this->server->httpRequest->getBody()); $hR->setStatus($newFile ? 201 : 200); - return false; + return false; } /** @@ -231,20 +242,23 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * If the file didn't exist, it will return false, which will make the * standard HTTP DELETE handler kick in. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $hR - * @param string $tempLocation + * @param string $tempLocation + * * @return bool */ - function httpDelete(RequestInterface $request, ResponseInterface $hR, $tempLocation) { - - if (!file_exists($tempLocation)) return; + public function httpDelete(RequestInterface $request, ResponseInterface $hR, $tempLocation) + { + if (!file_exists($tempLocation)) { + return; + } unlink($tempLocation); $hR->setHeader('X-Sabre-Temp', 'true'); $hR->setStatus(204); - return false; + return false; } /** @@ -254,14 +268,17 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * for which properties were requested, and just sends back a default * set of properties. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $hR - * @param string $tempLocation + * @param string $tempLocation + * * @return bool */ - function httpPropfind(RequestInterface $request, ResponseInterface $hR, $tempLocation) { - - if (!file_exists($tempLocation)) return; + public function httpPropfind(RequestInterface $request, ResponseInterface $hR, $tempLocation) + { + if (!file_exists($tempLocation)) { + return; + } $hR->setHeader('X-Sabre-Temp', 'true'); $hR->setStatus(207); @@ -269,22 +286,20 @@ class TemporaryFileFilterPlugin extends ServerPlugin { $properties = [ 'href' => $request->getPath(), - 200 => [ - '{DAV:}getlastmodified' => new Xml\Property\GetLastModified(filemtime($tempLocation)), - '{DAV:}getcontentlength' => filesize($tempLocation), - '{DAV:}resourcetype' => new Xml\Property\ResourceType(null), - '{' . Server::NS_SABREDAV . '}tempFile' => true, - + 200 => [ + '{DAV:}getlastmodified' => new Xml\Property\GetLastModified(filemtime($tempLocation)), + '{DAV:}getcontentlength' => filesize($tempLocation), + '{DAV:}resourcetype' => new Xml\Property\ResourceType(null), + '{'.Server::NS_SABREDAV.'}tempFile' => true, ], ]; $data = $this->server->generateMultiStatus([$properties]); $hR->setBody($data); - return false; + return false; } - /** * This method returns the directory where the temporary files should be stored. * diff --git a/vendor/sabre/dav/lib/DAV/Tree.php b/vendor/sabre/dav/lib/DAV/Tree.php index 7c04f0915..7a5a25f87 100644 --- a/vendor/sabre/dav/lib/DAV/Tree.php +++ b/vendor/sabre/dav/lib/DAV/Tree.php @@ -1,8 +1,10 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** * The tree object is responsible for basic tree operations. @@ -14,10 +16,10 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Tree { - +class Tree +{ /** - * The root node + * The root node. * * @var ICollection */ @@ -32,28 +34,30 @@ class Tree { protected $cache = []; /** - * Creates the object + * Creates the object. * * This method expects the rootObject to be passed as a parameter * * @param ICollection $rootNode */ - function __construct(ICollection $rootNode) { - + public function __construct(ICollection $rootNode) + { $this->rootNode = $rootNode; - } /** - * Returns the INode object for the requested path + * Returns the INode object for the requested path. * * @param string $path + * * @return INode */ - function getNodeForPath($path) { - + public function getNodeForPath($path) + { $path = trim($path, '/'); - if (isset($this->cache[$path])) return $this->cache[$path]; + if (isset($this->cache[$path])) { + return $this->cache[$path]; + } // Is it the root node? if (!strlen($path)) { @@ -61,25 +65,24 @@ class Tree { } // Attempting to fetch its parent - list($parentName, $baseName) = URLUtil::splitPath($path); + list($parentName, $baseName) = Uri\split($path); // If there was no parent, we must simply ask it from the root node. - if ($parentName === "") { + if ('' === $parentName) { $node = $this->rootNode->getChild($baseName); } else { // Otherwise, we recursively grab the parent and ask him/her. $parent = $this->getNodeForPath($parentName); - if (!($parent instanceof ICollection)) - throw new Exception\NotFound('Could not find node at path: ' . $path); - + if (!($parent instanceof ICollection)) { + throw new Exception\NotFound('Could not find node at path: '.$path); + } $node = $parent->getChild($baseName); - } $this->cache[$path] = $node; - return $node; + return $node; } /** @@ -89,61 +92,64 @@ class Tree { * it cheaper. * * @param string $path + * * @return bool */ - function nodeExists($path) { - + public function nodeExists($path) + { try { - // The root always exists - if ($path === '') return true; + if ('' === $path) { + return true; + } - list($parent, $base) = URLUtil::splitPath($path); + list($parent, $base) = Uri\split($path); $parentNode = $this->getNodeForPath($parent); - if (!$parentNode instanceof ICollection) return false; - return $parentNode->childExists($base); + if (!$parentNode instanceof ICollection) { + return false; + } + return $parentNode->childExists($base); } catch (Exception\NotFound $e) { - return false; - } - } /** - * Copies a file from path to another + * Copies a file from path to another. * - * @param string $sourcePath The source location + * @param string $sourcePath The source location * @param string $destinationPath The full destination path - * @return void */ - function copy($sourcePath, $destinationPath) { - + public function copy($sourcePath, $destinationPath) + { $sourceNode = $this->getNodeForPath($sourcePath); // grab the dirname and basename components - list($destinationDir, $destinationName) = URLUtil::splitPath($destinationPath); + list($destinationDir, $destinationName) = Uri\split($destinationPath); $destinationParent = $this->getNodeForPath($destinationDir); - $this->copyNode($sourceNode, $destinationParent, $destinationName); + // Check if the target can handle the copy itself. If not, we do it ourselves. + if (!$destinationParent instanceof ICopyTarget || !$destinationParent->copyInto($destinationName, $sourcePath, $sourceNode)) { + $this->copyNode($sourceNode, $destinationParent, $destinationName); + } $this->markDirty($destinationDir); - } /** - * Moves a file from one location to another + * Moves a file from one location to another. * - * @param string $sourcePath The path to the file which should be moved + * @param string $sourcePath The path to the file which should be moved * @param string $destinationPath The full destination path, so not just the destination parent node + * * @return int */ - function move($sourcePath, $destinationPath) { - - list($sourceDir) = URLUtil::splitPath($sourcePath); - list($destinationDir, $destinationName) = URLUtil::splitPath($destinationPath); + public function move($sourcePath, $destinationPath) + { + list($sourceDir) = Uri\split($sourcePath); + list($destinationDir, $destinationName) = Uri\split($destinationPath); if ($sourceDir === $destinationDir) { // If this is a 'local' rename, it means we can just trigger a rename. @@ -164,49 +170,45 @@ class Tree { } $this->markDirty($sourceDir); $this->markDirty($destinationDir); - } /** - * Deletes a node from the tree + * Deletes a node from the tree. * * @param string $path - * @return void */ - function delete($path) { - + public function delete($path) + { $node = $this->getNodeForPath($path); $node->delete(); - list($parent) = URLUtil::splitPath($path); + list($parent) = Uri\split($path); $this->markDirty($parent); - } /** * Returns a list of childnodes for a given path. * * @param string $path - * @return array + * + * @return \Traversable */ - function getChildren($path) { - + public function getChildren($path) + { $node = $this->getNodeForPath($path); - $children = $node->getChildren(); $basePath = trim($path, '/'); - if ($basePath !== '') $basePath .= '/'; - - foreach ($children as $child) { - - $this->cache[$basePath . $child->getName()] = $child; - + if ('' !== $basePath) { + $basePath .= '/'; } - return $children; + foreach ($node->getChildren() as $child) { + $this->cache[$basePath.$child->getName()] = $child; + yield $child; + } } /** - * This method is called with every tree update + * This method is called with every tree update. * * Examples of tree updates are: * * node deletions @@ -221,19 +223,17 @@ class Tree { * If a path is passed, it is assumed that the entire subtree is dirty * * @param string $path - * @return void */ - function markDirty($path) { - + public function markDirty($path) + { // We don't care enough about sub-paths // flushing the entire cache $path = trim($path, '/'); foreach ($this->cache as $nodePath => $node) { - if ($path === '' || $nodePath == $path || strpos($nodePath, $path . '/') === 0) + if ('' === $path || $nodePath == $path || 0 === strpos($nodePath, $path.'/')) { unset($this->cache[$nodePath]); - + } } - } /** @@ -247,15 +247,16 @@ class Tree { * This method returns an array with the found nodes. It's keys are the * original paths. The result may be out of order. * - * @param array $paths List of nodes that must be fetched. + * @param array $paths list of nodes that must be fetched + * * @return array */ - function getMultipleNodes($paths) { - + public function getMultipleNodes($paths) + { // Finding common parents $parents = []; foreach ($paths as $path) { - list($parent, $node) = URLUtil::splitPath($path); + list($parent, $node) = Uri\split($path); if (!isset($parents[$parent])) { $parents[$parent] = [$node]; } else { @@ -266,44 +267,38 @@ class Tree { $result = []; foreach ($parents as $parent => $children) { - $parentNode = $this->getNodeForPath($parent); if ($parentNode instanceof IMultiGet) { foreach ($parentNode->getMultipleChildren($children) as $childNode) { - $fullPath = $parent . '/' . $childNode->getName(); + $fullPath = $parent.'/'.$childNode->getName(); $result[$fullPath] = $childNode; $this->cache[$fullPath] = $childNode; } } else { foreach ($children as $child) { - $fullPath = $parent . '/' . $child; + $fullPath = $parent.'/'.$child; $result[$fullPath] = $this->getNodeForPath($fullPath); } } - } return $result; - } - /** - * copyNode + * copyNode. * - * @param INode $source + * @param INode $source * @param ICollection $destinationParent - * @param string $destinationName - * @return void + * @param string $destinationName */ - protected function copyNode(INode $source, ICollection $destinationParent, $destinationName = null) { - - if ((string)$destinationName === '') { + protected function copyNode(INode $source, ICollection $destinationParent, $destinationName = null) + { + if ('' === (string) $destinationName) { $destinationName = $source->getName(); } if ($source instanceof IFile) { - $data = $source->get(); // If the body was a string, we need to convert it to a stream @@ -315,28 +310,19 @@ class Tree { } $destinationParent->createFile($destinationName, $data); $destination = $destinationParent->getChild($destinationName); - } elseif ($source instanceof ICollection) { - $destinationParent->createDirectory($destinationName); $destination = $destinationParent->getChild($destinationName); foreach ($source->getChildren() as $child) { - $this->copyNode($child, $destination); - } - } if ($source instanceof IProperties && $destination instanceof IProperties) { - $props = $source->getProperties([]); $propPatch = new PropPatch($props); $destination->propPatch($propPatch); $propPatch->commit(); - } - } - } diff --git a/vendor/sabre/dav/lib/DAV/UUIDUtil.php b/vendor/sabre/dav/lib/DAV/UUIDUtil.php index 177adafd3..8c36e1b0b 100644 --- a/vendor/sabre/dav/lib/DAV/UUIDUtil.php +++ b/vendor/sabre/dav/lib/DAV/UUIDUtil.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * UUID Utility + * UUID Utility. * * This class has static methods to generate and validate UUID's. * UUIDs are used a decent amount within various *DAV standards, so it made @@ -13,18 +15,19 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class UUIDUtil { - +class UUIDUtil +{ /** - * Returns a pseudo-random v4 UUID + * Returns a pseudo-random v4 UUID. * * This function is based on a comment by Andrew Moore on php.net * * @see http://www.php.net/manual/en/function.uniqid.php#94959 + * * @return string */ - static function getUUID() { - + public static function getUUID() + { return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low" mt_rand(0, 0xffff), mt_rand(0, 0xffff), @@ -50,15 +53,14 @@ class UUIDUtil { * Checks if a string is a valid UUID. * * @param string $uuid + * * @return bool */ - static function validateUUID($uuid) { - - return preg_match( + public static function validateUUID($uuid) + { + return 0 !== preg_match( '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i', $uuid - ) !== 0; - + ); } - } diff --git a/vendor/sabre/dav/lib/DAV/Version.php b/vendor/sabre/dav/lib/DAV/Version.php index 89918e5bc..c00255881 100644 --- a/vendor/sabre/dav/lib/DAV/Version.php +++ b/vendor/sabre/dav/lib/DAV/Version.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -9,11 +11,10 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Version { - +class Version +{ /** - * Full version number + * Full version number. */ - const VERSION = '3.2.2'; - + const VERSION = '4.0.2'; } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Prop.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Prop.php index 71ef03e3f..52a04cf08 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Element/Prop.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Prop.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Element; use Sabre\DAV\Xml\Property\Complex; @@ -17,8 +19,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Prop implements XmlDeserializable { - +class Prop implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -38,13 +40,15 @@ class Prop implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { // If there's no children, we don't do anything. if ($reader->isEmptyElement) { $reader->next(); + return []; } @@ -52,22 +56,17 @@ class Prop implements XmlDeserializable { $reader->read(); do { - - if ($reader->nodeType === Reader::ELEMENT) { - + if (Reader::ELEMENT === $reader->nodeType) { $clark = $reader->getClark(); $values[$clark] = self::parseCurrentElement($reader)['value']; - } else { $reader->read(); } - - } while ($reader->nodeType !== Reader::END_ELEMENT); + } while (Reader::END_ELEMENT !== $reader->nodeType); $reader->read(); return $values; - } /** @@ -81,10 +80,11 @@ class Prop implements XmlDeserializable { * * value - The parsed value. * * @param Reader $reader + * * @return array */ - private static function parseCurrentElement(Reader $reader) { - + private static function parseCurrentElement(Reader $reader) + { $name = $reader->getClark(); if (array_key_exists($name, $reader->elementMap)) { @@ -95,22 +95,20 @@ class Prop implements XmlDeserializable { $value = call_user_func($deserializer, $reader); } else { $type = gettype($deserializer); - if ($type === 'string') { - $type .= ' (' . $deserializer . ')'; - } elseif ($type === 'object') { - $type .= ' (' . get_class($deserializer) . ')'; + if ('string' === $type) { + $type .= ' ('.$deserializer.')'; + } elseif ('object' === $type) { + $type .= ' ('.get_class($deserializer).')'; } - throw new \LogicException('Could not use this type as a deserializer: ' . $type); + throw new \LogicException('Could not use this type as a deserializer: '.$type); } } else { $value = Complex::xmlDeserialize($reader); } return [ - 'name' => $name, + 'name' => $name, 'value' => $value, ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php index ce97ae943..a11091809 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Element; use Sabre\Xml\Element; @@ -7,7 +9,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * WebDAV {DAV:}response parser + * WebDAV {DAV:}response parser. * * This class parses the {DAV:}response element, as defined in: * @@ -17,17 +19,17 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class Response implements Element { - +class Response implements Element +{ /** - * Url for the response + * Url for the response. * * @var string */ protected $href; /** - * Propertylist, ordered by HTTP status code + * Propertylist, ordered by HTTP status code. * * @var array */ @@ -57,51 +59,46 @@ class Response implements Element { * deleted. * * @param string $href - * @param array $responseProperties + * @param array $responseProperties * @param string $httpStatus */ - function __construct($href, array $responseProperties, $httpStatus = null) { - + public function __construct($href, array $responseProperties, $httpStatus = null) + { $this->href = $href; $this->responseProperties = $responseProperties; $this->httpStatus = $httpStatus; - } /** - * Returns the url + * Returns the url. * * @return string */ - function getHref() { - + public function getHref() + { return $this->href; - } /** - * Returns the httpStatus value + * Returns the httpStatus value. * * @return string */ - function getHttpStatus() { - + public function getHttpStatus() + { return $this->httpStatus; - } /** - * Returns the property list + * Returns the property list. * * @return array */ - function getResponseProperties() { - + public function getResponseProperties() + { return $this->responseProperties; - } - /** * The serialize method is called during xml writing. * @@ -115,19 +112,17 @@ class Response implements Element { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { if ($status = $this->getHTTPStatus()) { - $writer->writeElement('{DAV:}status', 'HTTP/1.1 ' . $status . ' ' . \Sabre\HTTP\Response::$statusCodes[$status]); + $writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$status.' '.\Sabre\HTTP\Response::$statusCodes[$status]); } - $writer->writeElement('{DAV:}href', $writer->contextUri . \Sabre\HTTP\encodePath($this->getHref())); + $writer->writeElement('{DAV:}href', $writer->contextUri.\Sabre\HTTP\encodePath($this->getHref())); $empty = true; foreach ($this->getResponseProperties() as $status => $properties) { - // Skipping empty lists if (!$properties || (!ctype_digit($status) && !is_int($status))) { continue; @@ -135,9 +130,8 @@ class Response implements Element { $empty = false; $writer->startElement('{DAV:}propstat'); $writer->writeElement('{DAV:}prop', $properties); - $writer->writeElement('{DAV:}status', 'HTTP/1.1 ' . $status . ' ' . \Sabre\HTTP\Response::$statusCodes[$status]); + $writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$status.' '.\Sabre\HTTP\Response::$statusCodes[$status]); $writer->endElement(); // {DAV:}propstat - } if ($empty) { /* @@ -149,12 +143,10 @@ class Response implements Element { * no properties. */ $writer->writeElement('{DAV:}propstat', [ - '{DAV:}prop' => [], - '{DAV:}status' => 'HTTP/1.1 418 ' . \Sabre\HTTP\Response::$statusCodes[418] + '{DAV:}prop' => [], + '{DAV:}status' => 'HTTP/1.1 418 '.\Sabre\HTTP\Response::$statusCodes[418], ]); - } - } /** @@ -176,10 +168,11 @@ class Response implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $reader->pushContext(); $reader->elementMap['{DAV:}propstat'] = 'Sabre\\Xml\\Element\\KeyValue'; @@ -192,16 +185,16 @@ class Response implements Element { // called. But we don't want this, because a singular element without // child-elements implies 'no value' in {DAV:}prop, so we want to skip // deserializers and just set null for those. - $reader->elementMap['{DAV:}prop'] = function(Reader $reader) { - + $reader->elementMap['{DAV:}prop'] = function (Reader $reader) { if ($reader->isEmptyElement) { $reader->next(); + return []; } $values = []; $reader->read(); do { - if ($reader->nodeType === Reader::ELEMENT) { + if (Reader::ELEMENT === $reader->nodeType) { $clark = $reader->getClark(); if ($reader->isEmptyElement) { @@ -213,10 +206,10 @@ class Response implements Element { } else { $reader->read(); } - } while ($reader->nodeType !== Reader::END_ELEMENT); + } while (Reader::END_ELEMENT !== $reader->nodeType); $reader->read(); - return $values; + return $values; }; $elems = $reader->parseInnerTree(); $reader->popContext(); @@ -226,28 +219,24 @@ class Response implements Element { $statusCode = null; foreach ($elems as $elem) { - switch ($elem['name']) { - - case '{DAV:}href' : + case '{DAV:}href': $href = $elem['value']; break; - case '{DAV:}propstat' : + case '{DAV:}propstat': $status = $elem['value']['{DAV:}status']; - list(, $status, ) = explode(' ', $status, 3); + list(, $status) = explode(' ', $status, 3); $properties = isset($elem['value']['{DAV:}prop']) ? $elem['value']['{DAV:}prop'] : []; - if ($properties) $propertyLists[$status] = $properties; + if ($properties) { + $propertyLists[$status] = $properties; + } break; - case '{DAV:}status' : - list(, $statusCode, ) = explode(' ', $elem['value'], 3); + case '{DAV:}status': + list(, $statusCode) = explode(' ', $elem['value'], 3); break; - } - } return new self($href, $propertyLists, $statusCode); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php index e187bf11c..e0db3bf37 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Element; use Sabre\DAV\Exception\BadRequest; @@ -18,8 +20,8 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Sharee implements Element { - +class Sharee implements Element +{ /** * A URL. Usually a mailto: address, could also be a principal url. * This uniquely identifies the sharee. @@ -79,24 +81,21 @@ class Sharee implements Element { public $inviteStatus; /** - * Creates the object + * Creates the object. * * $properties will be used to populate all internal properties. * * @param array $properties */ - function __construct(array $properties = []) { - + public function __construct(array $properties = []) + { foreach ($properties as $k => $v) { - if (property_exists($this, $k)) { $this->$k = $v; } else { - throw new \InvalidArgumentException('Unknown property: ' . $k); + throw new \InvalidArgumentException('Unknown property: '.$k); } - } - } /** @@ -116,31 +115,28 @@ class Sharee implements Element { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - - + public function xmlSerialize(Writer $writer) + { $writer->write([ new Href($this->href), - '{DAV:}prop' => $this->properties, + '{DAV:}prop' => $this->properties, '{DAV:}share-access' => new ShareAccess($this->access), ]); switch ($this->inviteStatus) { - case Plugin::INVITE_NORESPONSE : + case Plugin::INVITE_NORESPONSE: $writer->writeElement('{DAV:}invite-noresponse'); break; - case Plugin::INVITE_ACCEPTED : + case Plugin::INVITE_ACCEPTED: $writer->writeElement('{DAV:}invite-accepted'); break; - case Plugin::INVITE_DECLINED : + case Plugin::INVITE_DECLINED: $writer->writeElement('{DAV:}invite-declined'); break; - case Plugin::INVITE_INVALID : + case Plugin::INVITE_INVALID: $writer->writeElement('{DAV:}invite-invalid'); break; } - } /** @@ -162,10 +158,11 @@ class Sharee implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { // Temporarily override configuration $reader->pushContext(); $reader->elementMap['{DAV:}share-access'] = 'Sabre\DAV\Xml\Property\ShareAccess'; @@ -192,8 +189,7 @@ class Sharee implements Element { throw new BadRequest('Every {DAV:}sharee must have a {DAV:}share-access child element'); } $sharee->access = $elems['share-access']->getValue(); - return $sharee; + return $sharee; } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php index 258806e4a..990302054 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\Xml\Element\XmlFragment; @@ -15,8 +17,8 @@ use Sabre\Xml\Reader; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Complex extends XmlFragment { - +class Complex extends XmlFragment +{ /** * The deserialize method is called during xml parsing. * @@ -36,15 +38,17 @@ class Complex extends XmlFragment { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $xml = $reader->readInnerXml(); - if ($reader->nodeType === Reader::ELEMENT && $reader->isEmptyElement) { + if (Reader::ELEMENT === $reader->nodeType && $reader->isEmptyElement) { // Easy! $reader->next(); + return null; } // Now we have a copy of the inner xml, we need to traverse it to get @@ -56,21 +60,19 @@ class Complex extends XmlFragment { $text = ''; while (true) { - switch ($reader->nodeType) { - case Reader::ELEMENT : + case Reader::ELEMENT: $nonText = true; $reader->next(); continue 2; - case Reader::TEXT : - case Reader::CDATA : + case Reader::TEXT: + case Reader::CDATA: $text .= $reader->value; break; - case Reader::END_ELEMENT : + case Reader::END_ELEMENT: break 2; } $reader->read(); - } // Make sure we advance the cursor one step further. @@ -78,12 +80,10 @@ class Complex extends XmlFragment { if ($nonText) { $new = new self($xml); + return $new; } else { return $text; } - } - - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php b/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php index 101a0f0c9..05a00c5e5 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use DateTime; @@ -19,42 +21,40 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class GetLastModified implements Element { - +class GetLastModified implements Element +{ /** - * time + * time. * * @var DateTime */ public $time; /** - * Constructor + * Constructor. * * @param int|DateTime $time */ - function __construct($time) { - + public function __construct($time) + { if ($time instanceof DateTime) { $this->time = clone $time; } else { - $this->time = new DateTime('@' . $time); + $this->time = new DateTime('@'.$time); } // Setting timezone to UTC $this->time->setTimezone(new DateTimeZone('UTC')); - } /** - * getTime + * getTime. * * @return DateTime */ - function getTime() { - + public function getTime() + { return $this->time; - } /** @@ -70,14 +70,12 @@ class GetLastModified implements Element { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { $writer->write( - HTTP\Util::toHTTPDate($this->time) + HTTP\toDate($this->time) ); - } /** @@ -99,12 +97,12 @@ class GetLastModified implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { return new self(new DateTime($reader->parseInnerTree())); - } } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php index 6c4f11b87..c479c1602 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -10,7 +12,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * Href property + * Href property. * * This class represents any WebDAV property that contains a {DAV:}href * element, and there are many. @@ -23,17 +25,17 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class Href implements Element, HtmlOutput { - +class Href implements Element, HtmlOutput +{ /** - * List of uris + * List of uris. * * @var array */ protected $hrefs; /** - * Constructor + * Constructor. * * You must either pass a string for a single href, or an array of hrefs. * @@ -42,35 +44,32 @@ class Href implements Element, HtmlOutput { * * @param string|string[] $hrefs */ - function __construct($hrefs) { - + public function __construct($hrefs) + { if (is_string($hrefs)) { $hrefs = [$hrefs]; } $this->hrefs = $hrefs; - } /** * Returns the first Href. * - * @return string + * @return string|null */ - function getHref() { - - return $this->hrefs[0]; - + public function getHref() + { + return $this->hrefs[0] ?? null; } /** - * Returns the hrefs as an array + * Returns the hrefs as an array. * * @return array */ - function getHrefs() { - + public function getHrefs() + { return $this->hrefs; - } /** @@ -90,15 +89,13 @@ class Href implements Element, HtmlOutput { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->getHrefs() as $href) { $href = Uri\resolve($writer->contextUri, $href); $writer->writeElement('{DAV:}href', $href); } - } /** @@ -113,16 +110,17 @@ class Href implements Element, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { $links = []; foreach ($this->getHrefs() as $href) { $links[] = $html->link($href); } - return implode('<br />', $links); + return implode('<br />', $links); } /** @@ -144,22 +142,21 @@ class Href implements Element, HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $hrefs = []; - foreach ((array)$reader->parseInnerTree() as $elem) { - if ($elem['name'] !== '{DAV:}href') + foreach ((array) $reader->parseInnerTree() as $elem) { + if ('{DAV:}href' !== $elem['name']) { continue; + } $hrefs[] = $elem['value']; - } if ($hrefs) { - return new self($hrefs, false); + return new self($hrefs); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php index 6adad3650..b5e2dae46 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Xml\Element\Sharee; @@ -20,10 +22,10 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Invite implements XmlSerializable { - +class Invite implements XmlSerializable +{ /** - * A list of sharees + * A list of sharees. * * @var Sharee[] */ @@ -34,10 +36,9 @@ class Invite implements XmlSerializable { * * @param Sharee[] $sharees */ - function __construct(array $sharees) { - + public function __construct(array $sharees) + { $this->sharees = $sharees; - } /** @@ -57,14 +58,11 @@ class Invite implements XmlSerializable { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->sharees as $sharee) { $writer->writeElement('{DAV:}sharee', $sharee); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php b/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php index 00d2fa708..cb794974f 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\HTTP; /** - * LocalHref property + * LocalHref property. * * Like the Href property, this element represents {DAV:}href. The difference * is that this is used strictly for paths on the server. The LocalHref property @@ -22,10 +24,10 @@ use Sabre\HTTP; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class LocalHref extends Href { - +class LocalHref extends Href +{ /** - * Constructor + * Constructor. * * You must either pass a string for a single href, or an array of hrefs. * @@ -34,15 +36,13 @@ class LocalHref extends Href { * * @param string|string[] $hrefs */ - function __construct($hrefs) { - + public function __construct($hrefs) + { parent::__construct(array_map( - function($href) { + function ($href) { return \Sabre\HTTP\encodePath($href); }, - (array)$hrefs + (array) $hrefs )); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php b/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php index f4b692219..c33812b3e 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV; @@ -20,10 +22,10 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class LockDiscovery implements XmlSerializable { - +class LockDiscovery implements XmlSerializable +{ /** - * locks + * locks. * * @var LockInfo[] */ @@ -37,17 +39,16 @@ class LockDiscovery implements XmlSerializable { * * @var bool */ - static $hideLockRoot = false; + public static $hideLockRoot = false; /** - * __construct + * __construct. * * @param LockInfo[] $locks */ - function __construct($locks) { - + public function __construct($locks) + { $this->locks = $locks; - } /** @@ -63,16 +64,14 @@ class LockDiscovery implements XmlSerializable { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->locks as $lock) { - $writer->startElement('{DAV:}activelock'); $writer->startElement('{DAV:}lockscope'); - if ($lock->scope === LockInfo::SHARED) { + if (LockInfo::SHARED === $lock->scope) { $writer->writeElement('{DAV:}shared'); } else { $writer->writeElement('{DAV:}exclusive'); @@ -86,21 +85,23 @@ class LockDiscovery implements XmlSerializable { if (!self::$hideLockRoot) { $writer->startElement('{DAV:}lockroot'); - $writer->writeElement('{DAV:}href', $writer->contextUri . $lock->uri); + $writer->writeElement('{DAV:}href', $writer->contextUri.$lock->uri); $writer->endElement(); // {DAV:}lockroot } - $writer->writeElement('{DAV:}depth', ($lock->depth == DAV\Server::DEPTH_INFINITY ? 'infinity' : $lock->depth)); - $writer->writeElement('{DAV:}timeout', 'Second-' . $lock->timeout); - - $writer->startElement('{DAV:}locktoken'); - $writer->writeElement('{DAV:}href', 'opaquelocktoken:' . $lock->token); - $writer->endElement(); // {DAV:}locktoken + $writer->writeElement('{DAV:}depth', (DAV\Server::DEPTH_INFINITY == $lock->depth ? 'infinity' : $lock->depth)); + $writer->writeElement('{DAV:}timeout', (LockInfo::TIMEOUT_INFINITE === $lock->timeout ? 'Infinite' : 'Second-'.$lock->timeout)); + + // optional according to https://tools.ietf.org/html/rfc4918#section-6.5 + if (null !== $lock->token && '' !== $lock->token) { + $writer->startElement('{DAV:}locktoken'); + $writer->writeElement('{DAV:}href', 'opaquelocktoken:'.$lock->token); + $writer->endElement(); // {DAV:}locktoken + } - $writer->writeElement('{DAV:}owner', new XmlFragment($lock->owner)); + if ($lock->owner) { + $writer->writeElement('{DAV:}owner', new XmlFragment($lock->owner)); + } $writer->endElement(); // {DAV:}activelock - } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php b/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php index ce640ff32..ce07d4382 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -8,7 +10,7 @@ use Sabre\Xml\Element; use Sabre\Xml\Reader; /** - * {DAV:}resourcetype property + * {DAV:}resourcetype property. * * This class represents the {DAV:}resourcetype property, as defined in: * @@ -18,10 +20,10 @@ use Sabre\Xml\Reader; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ResourceType extends Element\Elements implements HtmlOutput { - +class ResourceType extends Element\Elements implements HtmlOutput +{ /** - * Constructor + * Constructor. * * You can either pass null (for no resourcetype), a string (for a single * resourcetype) or an array (for multiple). @@ -30,48 +32,44 @@ class ResourceType extends Element\Elements implements HtmlOutput { * * @param array|string|null $resourceTypes */ - function __construct($resourceTypes = null) { - - parent::__construct((array)$resourceTypes); - + public function __construct($resourceTypes = null) + { + parent::__construct((array) $resourceTypes); } /** - * Returns the values in clark-notation + * Returns the values in clark-notation. * * For example array('{DAV:}collection') * * @return array */ - function getValue() { - + public function getValue() + { return $this->value; - } /** - * Checks if the principal contains a certain value + * Checks if the principal contains a certain value. * * @param string $type + * * @return bool */ - function is($type) { - + public function is($type) + { return in_array($type, $this->value); - } /** - * Adds a resourcetype value to this property + * Adds a resourcetype value to this property. * * @param string $type - * @return void */ - function add($type) { - + public function add($type) + { $this->value[] = $type; $this->value = array_unique($this->value); - } /** @@ -93,13 +91,13 @@ class ResourceType extends Element\Elements implements HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { return new self(parent::xmlDeserialize($reader)); - } /** @@ -114,15 +112,14 @@ class ResourceType extends Element\Elements implements HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { return implode( ', ', array_map([$html, 'xmlName'], $this->getValue()) ); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php b/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php index 939062f76..95175053a 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Exception\BadRequest; @@ -22,10 +24,10 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ShareAccess implements Element { - +class ShareAccess implements Element +{ /** - * Either SHARED or SHAREDOWNER + * Either SHARED or SHAREDOWNER. * * @var int */ @@ -39,10 +41,9 @@ class ShareAccess implements Element { * * @param int $shareAccess */ - function __construct($shareAccess) { - + public function __construct($shareAccess) + { $this->value = $shareAccess; - } /** @@ -50,10 +51,9 @@ class ShareAccess implements Element { * * @return int */ - function getValue() { - + public function getValue() + { return $this->value; - } /** @@ -73,30 +73,26 @@ class ShareAccess implements Element { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { switch ($this->value) { - - case SharingPlugin::ACCESS_NOTSHARED : + case SharingPlugin::ACCESS_NOTSHARED: $writer->writeElement('{DAV:}not-shared'); break; - case SharingPlugin::ACCESS_SHAREDOWNER : + case SharingPlugin::ACCESS_SHAREDOWNER: $writer->writeElement('{DAV:}shared-owner'); break; - case SharingPlugin::ACCESS_READ : + case SharingPlugin::ACCESS_READ: $writer->writeElement('{DAV:}read'); break; - case SharingPlugin::ACCESS_READWRITE : + case SharingPlugin::ACCESS_READWRITE: $writer->writeElement('{DAV:}read-write'); break; - case SharingPlugin::ACCESS_NOACCESS : + case SharingPlugin::ACCESS_NOACCESS: $writer->writeElement('{DAV:}no-access'); break; - } - } /** @@ -118,26 +114,26 @@ class ShareAccess implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree(); foreach ($elems as $elem) { switch ($elem['name']) { - case '{DAV:}not-shared' : + case '{DAV:}not-shared': return new self(SharingPlugin::ACCESS_NOTSHARED); - case '{DAV:}shared-owner' : + case '{DAV:}shared-owner': return new self(SharingPlugin::ACCESS_SHAREDOWNER); - case '{DAV:}read' : + case '{DAV:}read': return new self(SharingPlugin::ACCESS_READ); - case '{DAV:}read-write' : + case '{DAV:}read-write': return new self(SharingPlugin::ACCESS_READWRITE); - case '{DAV:}no-access' : + case '{DAV:}no-access': return new self(SharingPlugin::ACCESS_NOACCESS); } } throw new BadRequest('Invalid value for {DAV:}share-access element'); - } } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php index 677fdde4b..26e7d646e 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\Xml\Writer; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedLock implements XmlSerializable { - +class SupportedLock implements XmlSerializable +{ /** * The xmlSerialize method is called during xml writing. * @@ -37,18 +39,16 @@ class SupportedLock implements XmlSerializable { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { $writer->writeElement('{DAV:}lockentry', [ '{DAV:}lockscope' => ['{DAV:}exclusive' => null], - '{DAV:}locktype' => ['{DAV:}write' => null], + '{DAV:}locktype' => ['{DAV:}write' => null], ]); $writer->writeElement('{DAV:}lockentry', [ '{DAV:}lockscope' => ['{DAV:}shared' => null], - '{DAV:}locktype' => ['{DAV:}write' => null], + '{DAV:}locktype' => ['{DAV:}write' => null], ]); - } } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php index 1a3878ef7..06ab28c94 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -20,24 +22,23 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedMethodSet implements XmlSerializable, HtmlOutput { - +class SupportedMethodSet implements XmlSerializable, HtmlOutput +{ /** - * List of methods + * List of methods. * * @var string[] */ protected $methods = []; /** - * Creates the property + * Creates the property. * * @param string[] $methods */ - function __construct(array $methods) { - + public function __construct(array $methods) + { $this->methods = $methods; - } /** @@ -45,25 +46,24 @@ class SupportedMethodSet implements XmlSerializable, HtmlOutput { * * @return string[] */ - function getValue() { - + public function getValue() + { return $this->methods; - } /** * Returns true or false if the property contains a specific method. * * @param string $methodName + * * @return bool */ - function has($methodName) { - + public function has($methodName) + { return in_array( $methodName, $this->methods ); - } /** @@ -83,16 +83,14 @@ class SupportedMethodSet implements XmlSerializable, HtmlOutput { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->getValue() as $val) { $writer->startElement('{DAV:}supported-method'); $writer->writeAttribute('name', $val); $writer->endElement(); } - } /** @@ -107,15 +105,14 @@ class SupportedMethodSet implements XmlSerializable, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { return implode( ', ', array_map([$html, 'h'], $this->getValue()) ); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php index 96383ec96..4c25d23d9 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV; @@ -21,17 +23,17 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedReportSet implements XmlSerializable, HtmlOutput { - +class SupportedReportSet implements XmlSerializable, HtmlOutput +{ /** - * List of reports + * List of reports. * * @var array */ protected $reports = []; /** - * Creates the property + * Creates the property. * * Any reports passed in the constructor * should be valid report-types in clark-notation. @@ -40,61 +42,56 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { * * @param string|string[] $reports */ - function __construct($reports = null) { - - if (!is_null($reports)) + public function __construct($reports = null) + { + if (!is_null($reports)) { $this->addReport($reports); - + } } /** - * Adds a report to this property + * Adds a report to this property. * * The report must be a string in clark-notation. * Multiple reports can be specified as an array. * * @param mixed $report - * @return void */ - function addReport($report) { - - $report = (array)$report; + public function addReport($report) + { + $report = (array) $report; foreach ($report as $r) { - - if (!preg_match('/^{([^}]*)}(.*)$/', $r)) + if (!preg_match('/^{([^}]*)}(.*)$/', $r)) { throw new DAV\Exception('Reportname must be in clark-notation'); - + } $this->reports[] = $r; - } - } /** - * Returns the list of supported reports + * Returns the list of supported reports. * * @return string[] */ - function getValue() { - + public function getValue() + { return $this->reports; - } /** * Returns true or false if the property contains a specific report. * * @param string $reportName + * * @return bool */ - function has($reportName) { - + public function has($reportName) + { return in_array( $reportName, $this->reports ); - } /** @@ -114,10 +111,9 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->getValue() as $val) { $writer->startElement('{DAV:}supported-report'); $writer->startElement('{DAV:}report'); @@ -125,7 +121,6 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { $writer->endElement(); $writer->endElement(); } - } /** @@ -140,15 +135,14 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { return implode( ', ', array_map([$html, 'xmlName'], $this->getValue()) ); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php b/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php index c315a9a45..8d9348162 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\DAV\Locks\LockInfo; @@ -18,10 +20,10 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Lock implements XmlDeserializable { - +class Lock implements XmlDeserializable +{ /** - * Owner of the lock + * Owner of the lock. * * @var string */ @@ -31,6 +33,7 @@ class Lock implements XmlDeserializable { * Scope of the lock. * * Either LockInfo::SHARED or LockInfo::EXCLUSIVE + * * @var int */ public $scope; @@ -54,10 +57,11 @@ class Lock implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $reader->pushContext(); $reader->elementMap['{DAV:}owner'] = 'Sabre\\Xml\\Element\\XmlFragment'; @@ -71,11 +75,12 @@ class Lock implements XmlDeserializable { if (isset($values['{DAV:}lockscope'])) { foreach ($values['{DAV:}lockscope'] as $elem) { - if ($elem['name'] === '{DAV:}exclusive') $new->scope = LockInfo::EXCLUSIVE; + if ('{DAV:}exclusive' === $elem['name']) { + $new->scope = LockInfo::EXCLUSIVE; + } } } - return $new; + return $new; } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php b/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php index 9490bf58c..7713646ea 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\Xml\Reader; @@ -16,8 +18,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MkCol implements XmlDeserializable { - +class MkCol implements XmlDeserializable +{ /** * The list of properties that will be set. * @@ -31,10 +33,9 @@ class MkCol implements XmlDeserializable { * * @return array */ - function getProperties() { - + public function getProperties() + { return $this->properties; - } /** @@ -56,10 +57,11 @@ class MkCol implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $elementMap = $reader->elementMap; @@ -70,13 +72,11 @@ class MkCol implements XmlDeserializable { $elems = $reader->parseInnerTree($elementMap); foreach ($elems as $elem) { - if ($elem['name'] === '{DAV:}set') { + if ('{DAV:}set' === $elem['name']) { $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); } } return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php b/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php index f1b5b6fdc..b4cce423e 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\Xml\Element\KeyValue; @@ -17,8 +19,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class PropFind implements XmlDeserializable { - +class PropFind implements XmlDeserializable +{ /** * If this is set to true, this was an 'allprop' request. * @@ -27,9 +29,9 @@ class PropFind implements XmlDeserializable { public $allProp = false; /** - * The property list + * The property list. * - * @var null|array + * @var array|null */ public $properties; @@ -52,32 +54,28 @@ class PropFind implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $reader->pushContext(); $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements'; foreach (KeyValue::xmlDeserialize($reader) as $k => $v) { - switch ($k) { - case '{DAV:}prop' : + case '{DAV:}prop': $self->properties = $v; break; - case '{DAV:}allprop' : + case '{DAV:}allprop': $self->allProp = true; - } - } $reader->popContext(); return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php b/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php index 821b9e047..55e154ec7 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\Xml\Element; @@ -17,8 +19,8 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class PropPatch implements Element { - +class PropPatch implements Element +{ /** * The list of properties that will be updated and removed. * @@ -45,24 +47,20 @@ class PropPatch implements Element { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->properties as $propertyName => $propertyValue) { - if (is_null($propertyValue)) { - $writer->startElement("{DAV:}remove"); + $writer->startElement('{DAV:}remove'); $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); $writer->endElement(); } else { - $writer->startElement("{DAV:}set"); + $writer->startElement('{DAV:}set'); $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); $writer->endElement(); } - } - } /** @@ -84,10 +82,11 @@ class PropPatch implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $elementMap = $reader->elementMap; @@ -98,21 +97,17 @@ class PropPatch implements Element { $elems = $reader->parseInnerTree($elementMap); foreach ($elems as $elem) { - if ($elem['name'] === '{DAV:}set') { + if ('{DAV:}set' === $elem['name']) { $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); } - if ($elem['name'] === '{DAV:}remove') { - + if ('{DAV:}remove' === $elem['name']) { // Ensuring there are no values. foreach ($elem['value']['{DAV:}prop'] as $remove => $value) { $self->properties[$remove] = null; } - } } return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php b/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php index 526a4eb6f..e1985b8c3 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\DAV\Xml\Element\Sharee; @@ -17,8 +19,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class ShareResource implements XmlDeserializable { - +class ShareResource implements XmlDeserializable +{ /** * The list of new people added or updated or removed from the share. * @@ -27,14 +29,13 @@ class ShareResource implements XmlDeserializable { public $sharees = []; /** - * Constructor + * Constructor. * * @param Sharee[] $sharees */ - function __construct(array $sharees) { - + public function __construct(array $sharees) + { $this->sharees = $sharees; - } /** @@ -56,26 +57,26 @@ class ShareResource implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree([ - '{DAV:}sharee' => 'Sabre\DAV\Xml\Element\Sharee', + '{DAV:}sharee' => 'Sabre\DAV\Xml\Element\Sharee', '{DAV:}share-access' => 'Sabre\DAV\Xml\Property\ShareAccess', - '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue', + '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue', ]); $sharees = []; foreach ($elems as $elem) { - if ($elem['name'] !== '{DAV:}sharee') continue; + if ('{DAV:}sharee' !== $elem['name']) { + continue; + } $sharees[] = $elem['value']; - } return new self($sharees); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php b/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php index 830293a01..acf0039ce 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\DAV\Exception\BadRequest; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SyncCollectionReport implements XmlDeserializable { - +class SyncCollectionReport implements XmlDeserializable +{ /** * The sync-token the client supplied for the report. * @@ -44,7 +46,7 @@ class SyncCollectionReport implements XmlDeserializable { /** * The list of properties that are being requested for every change. * - * @var null|array + * @var array|null */ public $properties; @@ -67,10 +69,11 @@ class SyncCollectionReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $reader->pushContext(); @@ -87,36 +90,31 @@ class SyncCollectionReport implements XmlDeserializable { foreach ($required as $elem) { if (!array_key_exists($elem, $elems)) { - throw new BadRequest('The ' . $elem . ' element in the {DAV:}sync-collection report is required'); + throw new BadRequest('The '.$elem.' element in the {DAV:}sync-collection report is required'); } } - $self->properties = $elems['{DAV:}prop']; $self->syncToken = $elems['{DAV:}sync-token']; if (isset($elems['{DAV:}limit'])) { $nresults = null; foreach ($elems['{DAV:}limit'] as $child) { - if ($child['name'] === '{DAV:}nresults') { - $nresults = (int)$child['value']; + if ('{DAV:}nresults' === $child['name']) { + $nresults = (int) $child['value']; } } $self->limit = $nresults; } if (isset($elems['{DAV:}sync-level'])) { - $value = $elems['{DAV:}sync-level']; - if ($value === 'infinity') { + if ('infinity' === $value) { $value = \Sabre\DAV\Server::DEPTH_INFINITY; } $self->syncLevel = $value; - } return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Response/MultiStatus.php b/vendor/sabre/dav/lib/DAV/Xml/Response/MultiStatus.php index cf5a0453b..423d0b569 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Response/MultiStatus.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Response/MultiStatus.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Response; use Sabre\Xml\Element; @@ -7,7 +9,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * WebDAV MultiStatus parser + * WebDAV MultiStatus parser. * * This class parses the {DAV:}multistatus response, as defined in: * https://tools.ietf.org/html/rfc4918#section-14.16 @@ -19,10 +21,10 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MultiStatus implements Element { - +class MultiStatus implements Element +{ /** - * The responses + * The responses. * * @var \Sabre\DAV\Xml\Element\Response[] */ @@ -36,16 +38,15 @@ class MultiStatus implements Element { protected $syncToken; /** - * Constructor + * Constructor. * * @param \Sabre\DAV\Xml\Element\Response[] $responses - * @param string $syncToken + * @param string $syncToken */ - function __construct(array $responses, $syncToken = null) { - + public function __construct(array $responses, $syncToken = null) + { $this->responses = $responses; $this->syncToken = $syncToken; - } /** @@ -53,10 +54,9 @@ class MultiStatus implements Element { * * @return \Sabre\DAV\Xml\Element\Response[] */ - function getResponses() { - + public function getResponses() + { return $this->responses; - } /** @@ -64,10 +64,9 @@ class MultiStatus implements Element { * * @return string|null */ - function getSyncToken() { - + public function getSyncToken() + { return $this->syncToken; - } /** @@ -83,17 +82,15 @@ class MultiStatus implements Element { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->getResponses() as $response) { $writer->writeElement('{DAV:}response', $response); } if ($syncToken = $this->getSyncToken()) { $writer->writeElement('{DAV:}sync-token', $syncToken); } - } /** @@ -115,10 +112,11 @@ class MultiStatus implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elementMap = $reader->elementMap; $elementMap['{DAV:}prop'] = 'Sabre\\DAV\\Xml\\Element\\Prop'; $elements = $reader->parseInnerTree($elementMap); @@ -126,17 +124,17 @@ class MultiStatus implements Element { $responses = []; $syncToken = null; - if ($elements) foreach ($elements as $elem) { - if ($elem['name'] === '{DAV:}response') { - $responses[] = $elem['value']; - } - if ($elem['name'] === '{DAV:}sync-token') { - $syncToken = $elem['value']; + if ($elements) { + foreach ($elements as $elem) { + if ('{DAV:}response' === $elem['name']) { + $responses[] = $elem['value']; + } + if ('{DAV:}sync-token' === $elem['name']) { + $syncToken = $elem['value']; + } } } return new self($responses, $syncToken); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Service.php b/vendor/sabre/dav/lib/DAV/Xml/Service.php index f41ed984a..4406b022d 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Service.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Service.php @@ -1,16 +1,18 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml; /** - * XML service for WebDAV + * XML service for WebDAV. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Service extends \Sabre\Xml\Service { - +class Service extends \Sabre\Xml\Service +{ /** * This is a list of XML elements that we automatically map to PHP classes. * @@ -19,16 +21,15 @@ class Service extends \Sabre\Xml\Service { */ public $elementMap = [ '{DAV:}multistatus' => 'Sabre\\DAV\\Xml\\Response\\MultiStatus', - '{DAV:}response' => 'Sabre\\DAV\\Xml\\Element\\Response', + '{DAV:}response' => 'Sabre\\DAV\\Xml\\Element\\Response', // Requests - '{DAV:}propfind' => 'Sabre\\DAV\\Xml\\Request\\PropFind', + '{DAV:}propfind' => 'Sabre\\DAV\\Xml\\Request\\PropFind', '{DAV:}propertyupdate' => 'Sabre\\DAV\\Xml\\Request\\PropPatch', - '{DAV:}mkcol' => 'Sabre\\DAV\\Xml\\Request\\MkCol', + '{DAV:}mkcol' => 'Sabre\\DAV\\Xml\\Request\\MkCol', // Properties '{DAV:}resourcetype' => 'Sabre\\DAV\\Xml\\Property\\ResourceType', - ]; /** @@ -40,8 +41,7 @@ class Service extends \Sabre\Xml\Service { * @var array */ public $namespaceMap = [ - 'DAV:' => 'd', + 'DAV:' => 'd', 'http://sabredav.org/ns' => 's', ]; - } diff --git a/vendor/sabre/dav/lib/DAVACL/ACLTrait.php b/vendor/sabre/dav/lib/DAVACL/ACLTrait.php index 602654a2e..d9bf4e1e0 100644 --- a/vendor/sabre/dav/lib/DAVACL/ACLTrait.php +++ b/vendor/sabre/dav/lib/DAVACL/ACLTrait.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; /** @@ -14,32 +16,30 @@ namespace Sabre\DAVACL; * @author Evert Pot (https://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -trait ACLTrait { - +trait ACLTrait +{ /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return null; - } /** - * Returns a group principal + * Returns a group principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getGroup() { - + public function getGroup() + { return null; - } /** @@ -54,28 +54,26 @@ trait ACLTrait { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ 'privilege' => '{DAV:}all', 'principal' => '{DAV:}owner', 'protected' => true, - ] + ], ]; - } /** - * Updates the ACL + * Updates the ACL. * * This method will receive a list of new ACE's as an array argument. * * @param array $acl - * @return void */ - function setACL(array $acl) { - + public function setACL(array $acl) + { throw new \Sabre\DAV\Exception\Forbidden('Setting ACL is not supported on this node'); } @@ -91,10 +89,8 @@ trait ACLTrait { * * @return array|null */ - function getSupportedPrivilegeSet() { - + public function getSupportedPrivilegeSet() + { return null; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php b/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php index 9d2026380..1160dd7ac 100644 --- a/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * Principals Collection + * Principals Collection. * * This is a helper class that easily allows you to create a collection that * has a childnode for every principal. @@ -17,10 +19,10 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractPrincipalCollection extends DAV\Collection implements IPrincipalCollection { - +abstract class AbstractPrincipalCollection extends DAV\Collection implements IPrincipalCollection +{ /** - * Principal backend + * Principal backend. * * @var PrincipalBackend\BackendInterface */ @@ -42,7 +44,7 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr public $disableListing = false; /** - * Creates the object + * Creates the object. * * This object must be passed the principal backend. This object will * filter all principals from a specified prefix ($principalPrefix). The @@ -51,13 +53,12 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * * * @param PrincipalBackend\BackendInterface $principalBackend - * @param string $principalPrefix + * @param string $principalPrefix */ - function __construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix = 'principals') { - + public function __construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix = 'principals') + { $this->principalPrefix = $principalPrefix; $this->principalBackend = $principalBackend; - } /** @@ -68,56 +69,58 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * supplied by the authentication backend. * * @param array $principalInfo - * @return IPrincipal + * + * @return DAV\INode */ - abstract function getChildForPrincipal(array $principalInfo); + abstract public function getChildForPrincipal(array $principalInfo); /** * Returns the name of this collection. * * @return string */ - function getName() { + public function getName() + { + list(, $name) = Uri\split($this->principalPrefix); - list(, $name) = URLUtil::splitPath($this->principalPrefix); return $name; - } /** - * Return the list of users + * Return the list of users. * * @return array */ - function getChildren() { - - if ($this->disableListing) + public function getChildren() + { + if ($this->disableListing) { throw new DAV\Exception\MethodNotAllowed('Listing members of this collection is disabled'); - + } $children = []; foreach ($this->principalBackend->getPrincipalsByPrefix($this->principalPrefix) as $principalInfo) { - $children[] = $this->getChildForPrincipal($principalInfo); - - } - return $children; + return $children; } /** * Returns a child object, by its name. * * @param string $name + * * @throws DAV\Exception\NotFound + * * @return DAV\INode */ - function getChild($name) { + public function getChild($name) + { + $principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix.'/'.$name); + if (!$principalInfo) { + throw new DAV\Exception\NotFound('Principal with name '.$name.' not found'); + } - $principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix . '/' . $name); - if (!$principalInfo) throw new DAV\Exception\NotFound('Principal with name ' . $name . ' not found'); return $this->getChildForPrincipal($principalInfo); - } /** @@ -139,21 +142,21 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * This method should simply return a list of 'child names', which may be * used to call $this->getChild in the future. * - * @param array $searchProperties + * @param array $searchProperties * @param string $test + * * @return array */ - function searchPrincipals(array $searchProperties, $test = 'allof') { - + public function searchPrincipals(array $searchProperties, $test = 'allof') + { $result = $this->principalBackend->searchPrincipals($this->principalPrefix, $searchProperties, $test); $r = []; foreach ($result as $row) { - list(, $r[]) = URLUtil::splitPath($row); + list(, $r[]) = Uri\split($row); } return $r; - } /** @@ -170,12 +173,11 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * principal was not found or you refuse to find it. * * @param string $uri + * * @return string */ - function findByUri($uri) { - + public function findByUri($uri) + { return $this->principalBackend->findByUri($uri, $this->principalPrefix); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php b/vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php index 22450b4a6..7756d4728 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; @@ -12,24 +14,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AceConflict extends DAV\Exception\Conflict { - +class AceConflict extends DAV\Exception\Conflict +{ /** * Adds in extra information in the xml response. * * This method adds the {DAV:}no-ace-conflict element as defined in rfc3744 * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:no-ace-conflict'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php b/vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php index 5624fd22f..19e0dac9d 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; /** - * NeedPrivileges + * NeedPrivileges. * * The 403-need privileges is thrown when a user didn't have the appropriate * permissions to perform an operation @@ -14,10 +16,10 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NeedPrivileges extends DAV\Exception\Forbidden { - +class NeedPrivileges extends DAV\Exception\Forbidden +{ /** - * The relevant uri + * The relevant uri. * * @var string */ @@ -31,18 +33,17 @@ class NeedPrivileges extends DAV\Exception\Forbidden { protected $privileges; /** - * Constructor + * Constructor. * * @param string $uri - * @param array $privileges + * @param array $privileges */ - function __construct($uri, array $privileges) { - + public function __construct($uri, array $privileges) + { $this->uri = $uri; $this->privileges = $privileges; - parent::__construct('User did not have the required privileges (' . implode(',', $privileges) . ') for path "' . $uri . '"'); - + parent::__construct('User did not have the required privileges ('.implode(',', $privileges).') for path "'.$uri.'"'); } /** @@ -50,33 +51,27 @@ class NeedPrivileges extends DAV\Exception\Forbidden { * * This method adds the {DAV:}need-privileges element as defined in rfc3744 * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:need-privileges'); $errorNode->appendChild($np); foreach ($this->privileges as $privilege) { - $resource = $doc->createElementNS('DAV:', 'd:resource'); $np->appendChild($resource); - $resource->appendChild($doc->createElementNS('DAV:', 'd:href', $server->getBaseUri() . $this->uri)); + $resource->appendChild($doc->createElementNS('DAV:', 'd:href', $server->getBaseUri().$this->uri)); $priv = $doc->createElementNS('DAV:', 'd:privilege'); $resource->appendChild($priv); preg_match('/^{([^}]*)}(.*)$/', $privilege, $privilegeParts); - $priv->appendChild($doc->createElementNS($privilegeParts[1], 'd:' . $privilegeParts[2])); - - + $priv->appendChild($doc->createElementNS($privilegeParts[1], 'd:'.$privilegeParts[2])); } - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php b/vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php index a2363b174..d90b01ffd 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; @@ -12,24 +14,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NoAbstract extends DAV\Exception\PreconditionFailed { - +class NoAbstract extends DAV\Exception\PreconditionFailed +{ /** * Adds in extra information in the xml response. * * This method adds the {DAV:}no-abstract element as defined in rfc3744 * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:no-abstract'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php b/vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php index d7ae188ae..b005c55d8 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; @@ -12,24 +14,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotRecognizedPrincipal extends DAV\Exception\PreconditionFailed { - +class NotRecognizedPrincipal extends DAV\Exception\PreconditionFailed +{ /** * Adds in extra information in the xml response. * * This method adds the {DAV:}recognized-principal element as defined in rfc3744 * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:recognized-principal'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php b/vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php index 73b81190d..dda2e6281 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; @@ -12,24 +14,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotSupportedPrivilege extends DAV\Exception\PreconditionFailed { - +class NotSupportedPrivilege extends DAV\Exception\PreconditionFailed +{ /** * Adds in extra information in the xml response. * * This method adds the {DAV:}not-supported-privilege element as defined in rfc3744 * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:not-supported-privilege'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/FS/Collection.php b/vendor/sabre/dav/lib/DAVACL/FS/Collection.php index b4fe7a1b0..85b04e2bd 100644 --- a/vendor/sabre/dav/lib/DAVACL/FS/Collection.php +++ b/vendor/sabre/dav/lib/DAVACL/FS/Collection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\FS; use Sabre\DAV\Exception\Forbidden; @@ -15,8 +17,8 @@ use Sabre\DAVACL\IACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Collection extends BaseCollection implements IACL { - +class Collection extends BaseCollection implements IACL +{ use ACLTrait; /** @@ -34,60 +36,58 @@ class Collection extends BaseCollection implements IACL { protected $owner; /** - * Constructor + * Constructor. * - * @param string $path on-disk path. - * @param array $acl ACL rules. - * @param string|null $owner principal owner string. + * @param string $path on-disk path + * @param array $acl ACL rules + * @param string|null $owner principal owner string */ - function __construct($path, array $acl, $owner = null) { - + public function __construct($path, array $acl, $owner = null) + { parent::__construct($path); $this->acl = $acl; $this->owner = $owner; - } /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * This method must throw Sabre\DAV\Exception\NotFound if the node does not * exist. * * @param string $name + * * @throws NotFound + * * @return \Sabre\DAV\INode */ - function getChild($name) { - - $path = $this->path . '/' . $name; - - if (!file_exists($path)) throw new NotFound('File could not be located'); - if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..'); + public function getChild($name) + { + $path = $this->path.'/'.$name; + if (!file_exists($path)) { + throw new NotFound('File could not be located'); + } + if ('.' == $name || '..' == $name) { + throw new Forbidden('Permission denied to . and ..'); + } if (is_dir($path)) { - return new self($path, $this->acl, $this->owner); - } else { - return new File($path, $this->acl, $this->owner); - } - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->owner; - } /** @@ -102,10 +102,8 @@ class Collection extends BaseCollection implements IACL { * * @return array */ - function getACL() { - + public function getACL() + { return $this->acl; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/FS/File.php b/vendor/sabre/dav/lib/DAVACL/FS/File.php index aaf2ae148..5506aa2c1 100644 --- a/vendor/sabre/dav/lib/DAVACL/FS/File.php +++ b/vendor/sabre/dav/lib/DAVACL/FS/File.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\FS; use Sabre\DAV\FSExt\File as BaseFile; @@ -13,8 +15,8 @@ use Sabre\DAVACL\IACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends BaseFile implements IACL { - +class File extends BaseFile implements IACL +{ use ACLTrait; /** @@ -32,31 +34,29 @@ class File extends BaseFile implements IACL { protected $owner; /** - * Constructor + * Constructor. * - * @param string $path on-disk path. - * @param array $acl ACL rules. - * @param string|null $owner principal owner string. + * @param string $path on-disk path + * @param array $acl ACL rules + * @param string|null $owner principal owner string */ - function __construct($path, array $acl, $owner = null) { - + public function __construct($path, array $acl, $owner = null) + { parent::__construct($path); $this->acl = $acl; $this->owner = $owner; - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->owner; - } /** @@ -71,10 +71,8 @@ class File extends BaseFile implements IACL { * * @return array */ - function getACL() { - + public function getACL() + { return $this->acl; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php b/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php index 201235e5a..c896d8e25 100644 --- a/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\FS; use Sabre\DAVACL\AbstractPrincipalCollection; @@ -19,8 +21,8 @@ use Sabre\Uri; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class HomeCollection extends AbstractPrincipalCollection implements IACL { - +class HomeCollection extends AbstractPrincipalCollection implements IACL +{ use ACLTrait; /** @@ -41,14 +43,13 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * Creates the home collection. * * @param BackendInterface $principalBackend - * @param string $storagePath Where the actual files are stored. - * @param string $principalPrefix list of principals to iterate. + * @param string $storagePath where the actual files are stored + * @param string $principalPrefix list of principals to iterate */ - function __construct(BackendInterface $principalBackend, $storagePath, $principalPrefix = 'principals') { - + public function __construct(BackendInterface $principalBackend, $storagePath, $principalPrefix = 'principals') + { parent::__construct($principalBackend, $principalPrefix); $this->storagePath = $storagePath; - } /** @@ -58,10 +59,9 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * * @return string */ - function getName() { - + public function getName() + { return $this->collectionName; - } /** @@ -72,10 +72,11 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * supplied by the authentication backend. * * @param array $principalInfo + * * @return \Sabre\DAV\INode */ - function getChildForPrincipal(array $principalInfo) { - + public function getChildForPrincipal(array $principalInfo) + { $owner = $principalInfo['uri']; $acl = [ [ @@ -87,20 +88,19 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { list(, $principalBaseName) = Uri\split($owner); - $path = $this->storagePath . '/' . $principalBaseName; + $path = $this->storagePath.'/'.$principalBaseName; if (!is_dir($path)) { mkdir($path, 0777, true); } + return new Collection( $path, $acl, $owner ); - } - /** * Returns a list of ACE's for this node. * @@ -113,16 +113,14 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ 'principal' => '{DAV:}authenticated', 'privilege' => '{DAV:}read', 'protected' => true, - ] + ], ]; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/IACL.php b/vendor/sabre/dav/lib/DAVACL/IACL.php index f7a138665..d19a075be 100644 --- a/vendor/sabre/dav/lib/DAVACL/IACL.php +++ b/vendor/sabre/dav/lib/DAVACL/IACL.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; /** - * ACL-enabled node + * ACL-enabled node. * * If you want to add WebDAV ACL to a node, you must implement this class * @@ -13,25 +15,25 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IACL extends DAV\INode { - +interface IACL extends DAV\INode +{ /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner(); + public function getOwner(); /** - * Returns a group principal + * Returns a group principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getGroup(); + public function getGroup(); /** * Returns a list of ACE's for this node. @@ -45,17 +47,16 @@ interface IACL extends DAV\INode { * * @return array */ - function getACL(); + public function getACL(); /** - * Updates the ACL + * Updates the ACL. * * This method will receive a list of new ACE's as an array argument. * * @param array $acl - * @return void */ - function setACL(array $acl); + public function setACL(array $acl); /** * Returns the list of supported privileges for this node. @@ -69,6 +70,5 @@ interface IACL extends DAV\INode { * * @return array|null */ - function getSupportedPrivilegeSet(); - + public function getSupportedPrivilegeSet(); } diff --git a/vendor/sabre/dav/lib/DAVACL/IPrincipal.php b/vendor/sabre/dav/lib/DAVACL/IPrincipal.php index 13728471e..c804096de 100644 --- a/vendor/sabre/dav/lib/DAVACL/IPrincipal.php +++ b/vendor/sabre/dav/lib/DAVACL/IPrincipal.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; /** - * IPrincipal interface + * IPrincipal interface. * * Implement this interface to define your own principals * @@ -13,46 +15,46 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IPrincipal extends DAV\INode { - +interface IPrincipal extends DAV\INode +{ /** - * Returns a list of alternative urls for a principal + * Returns a list of alternative urls for a principal. * * This can for example be an email address, or ldap url. * * @return array */ - function getAlternateUriSet(); + public function getAlternateUriSet(); /** - * Returns the full principal url + * Returns the full principal url. * * @return string */ - function getPrincipalUrl(); + public function getPrincipalUrl(); /** - * Returns the list of group members + * Returns the list of group members. * * If this principal is a group, this function should return * all member principal uri's for the group. * * @return array */ - function getGroupMemberSet(); + public function getGroupMemberSet(); /** - * Returns the list of groups this principal is member of + * Returns the list of groups this principal is member of. * * If this principal is a member of a (list of) groups, this function * should return a list of principal uri's for it's members. * * @return array */ - function getGroupMembership(); + public function getGroupMembership(); /** - * Sets a list of group members + * Sets a list of group members. * * If this principal is a group, this method sets all the group members. * The list of members is always overwritten, never appended to. @@ -60,18 +62,16 @@ interface IPrincipal extends DAV\INode { * This method should throw an exception if the members could not be set. * * @param array $principals - * @return void */ - function setGroupMemberSet(array $principals); + public function setGroupMemberSet(array $principals); /** - * Returns the displayname + * Returns the displayname. * * This should be a human readable name for the principal. * If none is available, return the nodename. * * @return string */ - function getDisplayName(); - + public function getDisplayName(); } diff --git a/vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php b/vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php index 3ab8382fa..1003730d6 100644 --- a/vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -14,8 +16,8 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IPrincipalCollection extends DAV\ICollection { - +interface IPrincipalCollection extends DAV\ICollection +{ /** * This method is used to search for principals matching a set of * properties. @@ -35,11 +37,12 @@ interface IPrincipalCollection extends DAV\ICollection { * This method should simply return a list of 'child names', which may be * used to call $this->getChild in the future. * - * @param array $searchProperties + * @param array $searchProperties * @param string $test + * * @return array */ - function searchPrincipals(array $searchProperties, $test = 'allof'); + public function searchPrincipals(array $searchProperties, $test = 'allof'); /** * Finds a principal by its URI. @@ -55,8 +58,8 @@ interface IPrincipalCollection extends DAV\ICollection { * principal was not found or you refuse to find it. * * @param string $uri + * * @return string */ - function findByUri($uri); - + public function findByUri($uri); } diff --git a/vendor/sabre/dav/lib/DAVACL/Plugin.php b/vendor/sabre/dav/lib/DAVACL/Plugin.php index a2aa118d7..c1ea6027c 100644 --- a/vendor/sabre/dav/lib/DAVACL/Plugin.php +++ b/vendor/sabre/dav/lib/DAVACL/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -15,7 +17,7 @@ use Sabre\HTTP\ResponseInterface; use Sabre\Uri; /** - * SabreDAV ACL Plugin + * SabreDAV ACL Plugin. * * This plugin provides functionality to enforce ACL permissions. * ACL is defined in RFC3744. @@ -28,24 +30,24 @@ use Sabre\Uri; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * Recursion constants + * Recursion constants. * * This only checks the base node */ const R_PARENT = 1; /** - * Recursion constants + * Recursion constants. * * This checks every node in the tree */ const R_RECURSIVE = 2; /** - * Recursion constants + * Recursion constants. * * This checks every parentnode in the tree, but not leaf-nodes. */ @@ -70,7 +72,7 @@ class Plugin extends DAV\ServerPlugin { /** * By default nodes that are inaccessible by the user, can still be seen - * in directory listings (PROPFIND on parent with Depth: 1) + * in directory listings (PROPFIND on parent with Depth: 1). * * In certain cases it's desirable to hide inaccessible nodes. Setting this * to true will cause these nodes to be hidden from directory listings. @@ -88,7 +90,7 @@ class Plugin extends DAV\ServerPlugin { * @var array */ public $principalSearchPropertySet = [ - '{DAV:}displayname' => 'Display name', + '{DAV:}displayname' => 'Display name', '{http://sabredav.org/ns}email-address' => 'Email address', ]; @@ -120,22 +122,21 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['access-control', 'calendarserver-principal-property-search']; - } /** - * Returns a list of available methods for a given url + * Returns a list of available methods for a given url. * * @param string $uri + * * @return array */ - function getMethods($uri) { - + public function getMethods($uri) + { return ['ACL']; - } /** @@ -146,10 +147,9 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'acl'; - } /** @@ -160,20 +160,19 @@ class Plugin extends DAV\ServerPlugin { * implement them * * @param string $uri + * * @return array */ - function getSupportedReportSet($uri) { - + public function getSupportedReportSet($uri) + { return [ '{DAV:}expand-property', '{DAV:}principal-match', '{DAV:}principal-property-search', '{DAV:}principal-search-property-set', ]; - } - /** * Checks if the current user has the specified privilege(s). * @@ -181,27 +180,29 @@ class Plugin extends DAV\ServerPlugin { * This method will throw an exception if the privilege is not available * and return true otherwise. * - * @param string $uri + * @param string $uri * @param array|string $privileges - * @param int $recursion - * @param bool $throwExceptions if set to false, this method won't throw exceptions. + * @param int $recursion + * @param bool $throwExceptions if set to false, this method won't throw exceptions + * * @throws NeedPrivileges * @throws NotAuthenticated + * * @return bool */ - function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, $throwExceptions = true) { - - if (!is_array($privileges)) $privileges = [$privileges]; + public function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, $throwExceptions = true) + { + if (!is_array($privileges)) { + $privileges = [$privileges]; + } $acl = $this->getCurrentUserPrivilegeSet($uri); $failed = []; foreach ($privileges as $priv) { - if (!in_array($priv, $acl)) { $failed[] = $priv; } - } if ($failed) { @@ -213,17 +214,16 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpRequest, $this->server->httpResponse ); - throw new notAuthenticated(implode(', ', $reasons) . '. Login was needed for privilege: ' . implode(', ', $failed) . ' on ' . $uri); + throw new notAuthenticated(implode(', ', $reasons).'. Login was needed for privilege: '.implode(', ', $failed).' on '.$uri); } if ($throwExceptions) { - throw new NeedPrivileges($uri, $failed); } else { return false; } } - return true; + return true; } /** @@ -234,35 +234,35 @@ class Plugin extends DAV\ServerPlugin { * * @return string|null */ - function getCurrentUserPrincipal() { - + public function getCurrentUserPrincipal() + { /** @var $authPlugin \Sabre\DAV\Auth\Plugin */ $authPlugin = $this->server->getPlugin('auth'); if (!$authPlugin) { return null; } - return $authPlugin->getCurrentPrincipal(); + return $authPlugin->getCurrentPrincipal(); } - /** * Returns a list of principals that's associated to the current * user, either directly or through group membership. * * @return array */ - function getCurrentUserPrincipals() { - + public function getCurrentUserPrincipals() + { $currentUser = $this->getCurrentUserPrincipal(); - if (is_null($currentUser)) return []; + if (is_null($currentUser)) { + return []; + } return array_merge( [$currentUser], $this->getPrincipalMembership($currentUser) ); - } /** @@ -271,12 +271,10 @@ class Plugin extends DAV\ServerPlugin { * These rules are used for all nodes that don't implement the IACL interface. * * @param array $acl - * @return void */ - function setDefaultAcl(array $acl) { - + public function setDefaultAcl(array $acl) + { $this->defaultAcl = $acl; - } /** @@ -286,10 +284,9 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getDefaultAcl() { - + public function getDefaultAcl() + { return $this->defaultAcl; - } /** @@ -317,15 +314,15 @@ class Plugin extends DAV\ServerPlugin { */ protected $principalMembershipCache = []; - /** * Returns all the principal groups the specified principal is a member of. * * @param string $mainPrincipal + * * @return array */ - function getPrincipalMembership($mainPrincipal) { - + public function getPrincipalMembership($mainPrincipal) + { // First check our cache if (isset($this->principalMembershipCache[$mainPrincipal])) { return $this->principalMembershipCache[$mainPrincipal]; @@ -335,31 +332,23 @@ class Plugin extends DAV\ServerPlugin { $principals = []; while (count($check)) { - $principal = array_shift($check); $node = $this->server->tree->getNodeForPath($principal); if ($node instanceof IPrincipal) { foreach ($node->getGroupMembership() as $groupMember) { - if (!in_array($groupMember, $principals)) { - $check[] = $groupMember; $principals[] = $groupMember; - } - } - } - } // Store the result in the cache $this->principalMembershipCache[$mainPrincipal] = $principals; return $principals; - } /** @@ -381,24 +370,27 @@ class Plugin extends DAV\ServerPlugin { * * @param string $checkPrincipal * @param string $currentPrincipal + * * @return bool */ - function principalMatchesPrincipal($checkPrincipal, $currentPrincipal = null) { - + public function principalMatchesPrincipal($checkPrincipal, $currentPrincipal = null) + { if (is_null($currentPrincipal)) { $currentPrincipal = $this->getCurrentUserPrincipal(); } if ($currentPrincipal === $checkPrincipal) { return true; } + if (is_null($currentPrincipal)) { + return false; + } + return in_array( $checkPrincipal, $this->getPrincipalMembership($currentPrincipal) ); - } - /** * Returns a tree of supported privileges for a resource. * @@ -436,10 +428,11 @@ class Plugin extends DAV\ServerPlugin { * ] * * @param string|INode $node + * * @return array */ - function getSupportedPrivilegeSet($node) { - + public function getSupportedPrivilegeSet($node) + { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } @@ -450,35 +443,34 @@ class Plugin extends DAV\ServerPlugin { } if (is_null($supportedPrivileges)) { - // Default $supportedPrivileges = [ '{DAV:}read' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [ '{DAV:}read-acl' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], '{DAV:}read-current-user-privilege-set' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], ], ], '{DAV:}write' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [ '{DAV:}write-properties' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], '{DAV:}write-content' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], '{DAV:}unlock' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], ], @@ -486,21 +478,20 @@ class Plugin extends DAV\ServerPlugin { ]; if ($node instanceof DAV\ICollection) { $supportedPrivileges['{DAV:}write']['aggregates']['{DAV:}bind'] = [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ]; $supportedPrivileges['{DAV:}write']['aggregates']['{DAV:}unbind'] = [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ]; } if ($node instanceof IACL) { $supportedPrivileges['{DAV:}write']['aggregates']['{DAV:}write-acl'] = [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ]; } - } $this->server->emit( @@ -509,11 +500,10 @@ class Plugin extends DAV\ServerPlugin { ); return $supportedPrivileges; - } /** - * Returns the supported privilege set as a flat list + * Returns the supported privilege set as a flat list. * * This is much easier to parse. * @@ -524,54 +514,44 @@ class Plugin extends DAV\ServerPlugin { * - concrete * * @param string|INode $node + * * @return array */ - final function getFlatPrivilegeSet($node) { - + final public function getFlatPrivilegeSet($node) + { $privs = [ - 'abstract' => false, - 'aggregates' => $this->getSupportedPrivilegeSet($node) + 'abstract' => false, + 'aggregates' => $this->getSupportedPrivilegeSet($node), ]; $fpsTraverse = null; - $fpsTraverse = function($privName, $privInfo, $concrete, &$flat) use (&$fpsTraverse) { - + $fpsTraverse = function ($privName, $privInfo, $concrete, &$flat) use (&$fpsTraverse) { $myPriv = [ - 'privilege' => $privName, - 'abstract' => isset($privInfo['abstract']) && $privInfo['abstract'], + 'privilege' => $privName, + 'abstract' => isset($privInfo['abstract']) && $privInfo['abstract'], 'aggregates' => [], - 'concrete' => isset($privInfo['abstract']) && $privInfo['abstract'] ? $concrete : $privName, + 'concrete' => isset($privInfo['abstract']) && $privInfo['abstract'] ? $concrete : $privName, ]; if (isset($privInfo['aggregates'])) { - foreach ($privInfo['aggregates'] as $subPrivName => $subPrivInfo) { - $myPriv['aggregates'][] = $subPrivName; - } - } $flat[$privName] = $myPriv; if (isset($privInfo['aggregates'])) { - foreach ($privInfo['aggregates'] as $subPrivName => $subPrivInfo) { - $fpsTraverse($subPrivName, $subPrivInfo, $myPriv['concrete'], $flat); - } - } - }; $flat = []; $fpsTraverse('{DAV:}all', $privs, null, $flat); return $flat; - } /** @@ -582,10 +562,11 @@ class Plugin extends DAV\ServerPlugin { * null will be returned if the node doesn't support ACLs. * * @param string|DAV\INode $node + * * @return array */ - function getAcl($node) { - + public function getAcl($node) + { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } @@ -600,8 +581,8 @@ class Plugin extends DAV\ServerPlugin { 'protected' => true, ]; } - return $acl; + return $acl; } /** @@ -613,10 +594,11 @@ class Plugin extends DAV\ServerPlugin { * null will be returned if the node doesn't support ACLs. * * @param string|DAV\INode $node + * * @return array */ - function getCurrentUserPrivilegeSet($node) { - + public function getCurrentUserPrivilegeSet($node) + { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } @@ -625,50 +607,44 @@ class Plugin extends DAV\ServerPlugin { $collected = []; - $isAuthenticated = $this->getCurrentUserPrincipal() !== null; + $isAuthenticated = null !== $this->getCurrentUserPrincipal(); foreach ($acl as $ace) { - $principal = $ace['principal']; switch ($principal) { - - case '{DAV:}owner' : + case '{DAV:}owner': $owner = $node->getOwner(); if ($owner && $this->principalMatchesPrincipal($owner)) { $collected[] = $ace; } break; - // 'all' matches for every user - case '{DAV:}all' : + case '{DAV:}all': $collected[] = $ace; break; - case '{DAV:}authenticated' : + case '{DAV:}authenticated': // Authenticated users only if ($isAuthenticated) { $collected[] = $ace; } break; - case '{DAV:}unauthenticated' : + case '{DAV:}unauthenticated': // Unauthenticated users only if (!$isAuthenticated) { $collected[] = $ace; } break; - default : + default: if ($this->principalMatchesPrincipal($ace['principal'])) { $collected[] = $ace; } break; - } - - } // Now we deduct all aggregated privileges. @@ -676,41 +652,37 @@ class Plugin extends DAV\ServerPlugin { $collected2 = []; while (count($collected)) { - $current = array_pop($collected); $collected2[] = $current['privilege']; if (!isset($flat[$current['privilege']])) { // Ignoring privileges that are not in the supported-privileges list. - $this->server->getLogger()->debug('A node has the "' . $current['privilege'] . '" in its ACL list, but this privilege was not reported in the supportedPrivilegeSet list. This will be ignored.'); + $this->server->getLogger()->debug('A node has the "'.$current['privilege'].'" in its ACL list, but this privilege was not reported in the supportedPrivilegeSet list. This will be ignored.'); continue; } foreach ($flat[$current['privilege']]['aggregates'] as $subPriv) { $collected2[] = $subPriv; $collected[] = $flat[$subPriv]; } - } return array_values(array_unique($collected2)); - } - /** * Returns a principal based on its uri. * * Returns null if the principal could not be found. * * @param string $uri - * @return null|string + * + * @return string|null */ - function getPrincipalByUri($uri) { - + public function getPrincipalByUri($uri) + { $result = null; $collections = $this->principalCollectionSet; foreach ($collections as $collection) { - try { $principalCollection = $this->server->tree->getNodeForPath($collection); } catch (NotFound $e) { @@ -728,36 +700,35 @@ class Plugin extends DAV\ServerPlugin { if ($result) { return $result; } - } - } /** - * Principal property search + * Principal property search. * * This method can search for principals matching certain values in * properties. * * This method will return a list of properties for the matched properties. * - * @param array $searchProperties The properties to search on. This is a - * key-value list. The keys are property - * names, and the values the strings to - * match them on. - * @param array $requestedProperties This is the list of properties to - * return for every match. - * @param string $collectionUri The principal collection to search on. - * If this is ommitted, the standard - * principal collection-set will be used. - * @param string $test "allof" to use AND to search the - * properties. 'anyof' for OR. - * @return array This method returns an array structure similar to - * Sabre\DAV\Server::getPropertiesForPath. Returned - * properties are index by a HTTP status code. + * @param array $searchProperties The properties to search on. This is a + * key-value list. The keys are property + * names, and the values the strings to + * match them on. + * @param array $requestedProperties this is the list of properties to + * return for every match + * @param string $collectionUri the principal collection to search on. + * If this is ommitted, the standard + * principal collection-set will be used + * @param string $test "allof" to use AND to search the + * properties. 'anyof' for OR. + * + * @return array This method returns an array structure similar to + * Sabre\DAV\Server::getPropertiesForPath. Returned + * properties are index by a HTTP status code. */ - function principalSearch(array $searchProperties, array $requestedProperties, $collectionUri = null, $test = 'allof') { - + public function principalSearch(array $searchProperties, array $requestedProperties, $collectionUri = null, $test = 'allof') + { if (!is_null($collectionUri)) { $uris = [$collectionUri]; } else { @@ -766,7 +737,6 @@ class Plugin extends DAV\ServerPlugin { $lookupResults = []; foreach ($uris as $uri) { - $principalCollection = $this->server->tree->getNodeForPath($uri); if (!$principalCollection instanceof IPrincipalCollection) { // Not a principal collection, we're simply going to ignore @@ -776,33 +746,28 @@ class Plugin extends DAV\ServerPlugin { $results = $principalCollection->searchPrincipals($searchProperties, $test); foreach ($results as $result) { - $lookupResults[] = rtrim($uri, '/') . '/' . $result; + $lookupResults[] = rtrim($uri, '/').'/'.$result; } - } $matches = []; foreach ($lookupResults as $lookupResult) { - list($matches[]) = $this->server->getPropertiesForPath($lookupResult, $requestedProperties, 0); - } return $matches; - } /** - * Sets up the plugin + * Sets up the plugin. * * This method is automatically called by the server class. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { if ($this->allowUnauthenticatedAccess) { $authPlugin = $server->getPlugin('auth'); if (!$authPlugin) { @@ -812,22 +777,22 @@ class Plugin extends DAV\ServerPlugin { } $this->server = $server; - $server->on('propFind', [$this, 'propFind'], 20); - $server->on('beforeMethod', [$this, 'beforeMethod'], 20); - $server->on('beforeBind', [$this, 'beforeBind'], 20); - $server->on('beforeUnbind', [$this, 'beforeUnbind'], 20); - $server->on('propPatch', [$this, 'propPatch']); - $server->on('beforeUnlock', [$this, 'beforeUnlock'], 20); - $server->on('report', [$this, 'report']); - $server->on('method:ACL', [$this, 'httpAcl']); - $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); - $server->on('getPrincipalByUri', function($principal, &$uri) { - + $server->on('propFind', [$this, 'propFind'], 20); + $server->on('beforeMethod:*', [$this, 'beforeMethod'], 20); + $server->on('beforeBind', [$this, 'beforeBind'], 20); + $server->on('beforeUnbind', [$this, 'beforeUnbind'], 20); + $server->on('propPatch', [$this, 'propPatch']); + $server->on('beforeUnlock', [$this, 'beforeUnlock'], 20); + $server->on('report', [$this, 'report']); + $server->on('method:ACL', [$this, 'httpAcl']); + $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); + $server->on('getPrincipalByUri', function ($principal, &$uri) { $uri = $this->getPrincipalByUri($principal); // Break event chain - if ($uri) return false; - + if ($uri) { + return false; + } }); array_push($server->protectedProperties, @@ -858,39 +823,38 @@ class Plugin extends DAV\ServerPlugin { $server->xml->elementMap['{DAV:}principal-property-search'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalPropertySearchReport'; $server->xml->elementMap['{DAV:}principal-search-property-set'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalSearchPropertySetReport'; $server->xml->elementMap['{DAV:}principal-match'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalMatchReport'; - } /* {{{ Event handlers */ /** - * Triggered before any method is handled + * Triggered before any method is handled. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function beforeMethod(RequestInterface $request, ResponseInterface $response) { - + public function beforeMethod(RequestInterface $request, ResponseInterface $response) + { $method = $request->getMethod(); $path = $request->getPath(); $exists = $this->server->tree->nodeExists($path); // If the node doesn't exists, none of these checks apply - if (!$exists) return; + if (!$exists) { + return; + } switch ($method) { - - case 'GET' : - case 'HEAD' : - case 'OPTIONS' : + case 'GET': + case 'HEAD': + case 'OPTIONS': // For these 3 we only need to know if the node is readable. $this->checkPrivileges($path, '{DAV:}read'); break; - case 'PUT' : - case 'LOCK' : + case 'PUT': + case 'LOCK': // This method requires the write-content priv if the node // already exists, and bind on the parent if the node is being // created. @@ -898,20 +862,20 @@ class Plugin extends DAV\ServerPlugin { $this->checkPrivileges($path, '{DAV:}write-content'); break; - case 'UNLOCK' : + case 'UNLOCK': // Unlock is always allowed at the moment. break; - case 'PROPPATCH' : + case 'PROPPATCH': $this->checkPrivileges($path, '{DAV:}write-properties'); break; - case 'ACL' : + case 'ACL': $this->checkPrivileges($path, '{DAV:}write-acl'); break; - case 'COPY' : - case 'MOVE' : + case 'COPY': + case 'MOVE': // Copy requires read privileges on the entire source tree. // If the target exists write-content normally needs to be // checked, however, we're deleting the node beforehand and @@ -925,9 +889,7 @@ class Plugin extends DAV\ServerPlugin { // the sourcenode can be deleted. $this->checkPrivileges($path, '{DAV:}read', self::R_RECURSIVE); break; - } - } /** @@ -937,54 +899,49 @@ class Plugin extends DAV\ServerPlugin { * new node, such as PUT, MKCOL, MKCALENDAR, LOCK, COPY and MOVE. * * @param string $uri - * @return void */ - function beforeBind($uri) { - + public function beforeBind($uri) + { list($parentUri) = Uri\split($uri); $this->checkPrivileges($parentUri, '{DAV:}bind'); - } /** - * Triggered before a node is deleted + * Triggered before a node is deleted. * * This allows us to check permissions for any operation that will delete * an existing node. * * @param string $uri - * @return void */ - function beforeUnbind($uri) { - + public function beforeUnbind($uri) + { list($parentUri) = Uri\split($uri); $this->checkPrivileges($parentUri, '{DAV:}unbind', self::R_RECURSIVEPARENTS); - } /** * Triggered before a node is unlocked. * - * @param string $uri + * @param string $uri * @param DAV\Locks\LockInfo $lock * @TODO: not yet implemented - * @return void */ - function beforeUnlock($uri, DAV\Locks\LockInfo $lock) { - - + public function beforeUnlock($uri, DAV\Locks\LockInfo $lock) + { } /** * Triggered before properties are looked up in specific nodes. * * @param DAV\PropFind $propFind - * @param DAV\INode $node + * @param DAV\INode $node * @TODO really should be broken into multiple methods, or even a class. + * * @return bool */ - function propFind(DAV\PropFind $propFind, DAV\INode $node) { - + public function propFind(DAV\PropFind $propFind, DAV\INode $node) + { $path = $propFind->getPath(); // Checking the read permission @@ -1004,95 +961,95 @@ class Plugin extends DAV\ServerPlugin { } return; - } /* Adding principal properties */ if ($node instanceof IPrincipal) { - - $propFind->handle('{DAV:}alternate-URI-set', function() use ($node) { + $propFind->handle('{DAV:}alternate-URI-set', function () use ($node) { return new Href($node->getAlternateUriSet()); }); - $propFind->handle('{DAV:}principal-URL', function() use ($node) { - return new Href($node->getPrincipalUrl() . '/'); + $propFind->handle('{DAV:}principal-URL', function () use ($node) { + return new Href($node->getPrincipalUrl().'/'); }); - $propFind->handle('{DAV:}group-member-set', function() use ($node) { + $propFind->handle('{DAV:}group-member-set', function () use ($node) { $members = $node->getGroupMemberSet(); foreach ($members as $k => $member) { - $members[$k] = rtrim($member, '/') . '/'; + $members[$k] = rtrim($member, '/').'/'; } + return new Href($members); }); - $propFind->handle('{DAV:}group-membership', function() use ($node) { + $propFind->handle('{DAV:}group-membership', function () use ($node) { $members = $node->getGroupMembership(); foreach ($members as $k => $member) { - $members[$k] = rtrim($member, '/') . '/'; + $members[$k] = rtrim($member, '/').'/'; } + return new Href($members); }); $propFind->handle('{DAV:}displayname', [$node, 'getDisplayName']); - } - $propFind->handle('{DAV:}principal-collection-set', function() { - + $propFind->handle('{DAV:}principal-collection-set', function () { $val = $this->principalCollectionSet; // Ensuring all collections end with a slash - foreach ($val as $k => $v) $val[$k] = $v . '/'; - return new Href($val); + foreach ($val as $k => $v) { + $val[$k] = $v.'/'; + } + return new Href($val); }); - $propFind->handle('{DAV:}current-user-principal', function() { + $propFind->handle('{DAV:}current-user-principal', function () { if ($url = $this->getCurrentUserPrincipal()) { - return new Xml\Property\Principal(Xml\Property\Principal::HREF, $url . '/'); + return new Xml\Property\Principal(Xml\Property\Principal::HREF, $url.'/'); } else { return new Xml\Property\Principal(Xml\Property\Principal::UNAUTHENTICATED); } }); - $propFind->handle('{DAV:}supported-privilege-set', function() use ($node) { + $propFind->handle('{DAV:}supported-privilege-set', function () use ($node) { return new Xml\Property\SupportedPrivilegeSet($this->getSupportedPrivilegeSet($node)); }); - $propFind->handle('{DAV:}current-user-privilege-set', function() use ($node, $propFind, $path) { + $propFind->handle('{DAV:}current-user-privilege-set', function () use ($node, $propFind, $path) { if (!$this->checkPrivileges($path, '{DAV:}read-current-user-privilege-set', self::R_PARENT, false)) { $propFind->set('{DAV:}current-user-privilege-set', null, 403); } else { $val = $this->getCurrentUserPrivilegeSet($node); + return new Xml\Property\CurrentUserPrivilegeSet($val); } }); - $propFind->handle('{DAV:}acl', function() use ($node, $propFind, $path) { + $propFind->handle('{DAV:}acl', function () use ($node, $propFind, $path) { /* The ACL property contains all the permissions */ if (!$this->checkPrivileges($path, '{DAV:}read-acl', self::R_PARENT, false)) { $propFind->set('{DAV:}acl', null, 403); } else { $acl = $this->getACL($node); + return new Xml\Property\Acl($this->getACL($node)); } }); - $propFind->handle('{DAV:}acl-restrictions', function() { + $propFind->handle('{DAV:}acl-restrictions', function () { return new Xml\Property\AclRestrictions(); }); /* Adding ACL properties */ if ($node instanceof IACL) { - $propFind->handle('{DAV:}owner', function() use ($node) { - return new Href($node->getOwner() . '/'); + $propFind->handle('{DAV:}owner', function () use ($node) { + return new Href($node->getOwner().'/'); }); } - } /** * This method intercepts PROPPATCH methods and make sure the * group-member-set is updated correctly. * - * @param string $path + * @param string $path * @param DAV\PropPatch $propPatch - * @return void */ - function propPatch($path, DAV\PropPatch $propPatch) { - - $propPatch->handle('{DAV:}group-member-set', function($value) use ($path) { + public function propPatch($path, DAV\PropPatch $propPatch) + { + $propPatch->handle('{DAV:}group-member-set', function ($value) use ($path) { if (is_null($value)) { $memberSet = []; } elseif ($value instanceof Href) { @@ -1116,55 +1073,58 @@ class Plugin extends DAV\ServerPlugin { return true; }); - } /** - * This method handles HTTP REPORT requests + * This method handles HTTP REPORT requests. * * @param string $reportName - * @param mixed $report - * @param mixed $path + * @param mixed $report + * @param mixed $path + * * @return bool */ - function report($reportName, $report, $path) { - + public function report($reportName, $report, $path) + { switch ($reportName) { - - case '{DAV:}principal-property-search' : + case '{DAV:}principal-property-search': $this->server->transactionType = 'report-principal-property-search'; $this->principalPropertySearchReport($path, $report); + return false; - case '{DAV:}principal-search-property-set' : + case '{DAV:}principal-search-property-set': $this->server->transactionType = 'report-principal-search-property-set'; $this->principalSearchPropertySetReport($path, $report); + return false; - case '{DAV:}expand-property' : + case '{DAV:}expand-property': $this->server->transactionType = 'report-expand-property'; $this->expandPropertyReport($path, $report); + return false; - case '{DAV:}principal-match' : + case '{DAV:}principal-match': $this->server->transactionType = 'report-principal-match'; $this->principalMatchReport($path, $report); + return false; - case '{DAV:}acl-principal-prop-set' : + case '{DAV:}acl-principal-prop-set': $this->server->transactionType = 'acl-principal-prop-set'; $this->aclPrincipalPropSetReport($path, $report); - return false; + return false; } - } /** * This method is responsible for handling the 'ACL' event. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpAcl(RequestInterface $request, ResponseInterface $response) { - + public function httpAcl(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $body = $request->getBodyAsString(); @@ -1192,8 +1152,9 @@ class Plugin extends DAV\ServerPlugin { /* Checking if protected principals from the existing principal set are not overwritten. */ foreach ($oldAcl as $oldAce) { - - if (!isset($oldAce['protected']) || !$oldAce['protected']) continue; + if (!isset($oldAce['protected']) || !$oldAce['protected']) { + continue; + } $found = false; foreach ($newAcl as $newAce) { @@ -1201,36 +1162,35 @@ class Plugin extends DAV\ServerPlugin { $newAce['privilege'] === $oldAce['privilege'] && $newAce['principal'] === $oldAce['principal'] && $newAce['protected'] - ) - $found = true; + ) { + $found = true; + } } - if (!$found) + if (!$found) { throw new Exception\AceConflict('This resource contained a protected {DAV:}ace, but this privilege did not occur in the ACL request'); - + } } foreach ($newAcl as $newAce) { - // Do we recognize the privilege if (!isset($supportedPrivileges[$newAce['privilege']])) { - throw new Exception\NotSupportedPrivilege('The privilege you specified (' . $newAce['privilege'] . ') is not recognized by this server'); + throw new Exception\NotSupportedPrivilege('The privilege you specified ('.$newAce['privilege'].') is not recognized by this server'); } if ($supportedPrivileges[$newAce['privilege']]['abstract']) { - throw new Exception\NoAbstract('The privilege you specified (' . $newAce['privilege'] . ') is an abstract privilege'); + throw new Exception\NoAbstract('The privilege you specified ('.$newAce['privilege'].') is an abstract privilege'); } // Looking up the principal try { $principal = $this->server->tree->getNodeForPath($newAce['principal']); } catch (NotFound $e) { - throw new Exception\NotRecognizedPrincipal('The specified principal (' . $newAce['principal'] . ') does not exist'); + throw new Exception\NotRecognizedPrincipal('The specified principal ('.$newAce['principal'].') does not exist'); } if (!($principal instanceof IPrincipal)) { - throw new Exception\NotRecognizedPrincipal('The specified uri (' . $newAce['principal'] . ') is not a principal'); + throw new Exception\NotRecognizedPrincipal('The specified uri ('.$newAce['principal'].') is not a principal'); } - } $node->setACL($newAcl); @@ -1238,7 +1198,6 @@ class Plugin extends DAV\ServerPlugin { // Breaking the event chain, because we handled this method. return false; - } /* }}} */ @@ -1252,14 +1211,13 @@ class Plugin extends DAV\ServerPlugin { * or a principal URL, the principal URL and principal URLs of groups that * principal belongs to. * - * @param string $path + * @param string $path * @param Xml\Request\PrincipalMatchReport $report - * @return void */ - protected function principalMatchReport($path, Xml\Request\PrincipalMatchReport $report) { - + protected function principalMatchReport($path, Xml\Request\PrincipalMatchReport $report) + { $depth = $this->server->getHTTPDepth(0); - if ($depth !== 0) { + if (0 !== $depth) { throw new BadRequest('The principal-match report is only defined on Depth: 0'); } @@ -1267,20 +1225,15 @@ class Plugin extends DAV\ServerPlugin { $result = []; - if ($report->type === Xml\Request\PrincipalMatchReport::SELF) { - + if (Xml\Request\PrincipalMatchReport::SELF === $report->type) { // Finding all principals under the request uri that match the // current principal. foreach ($currentPrincipals as $currentPrincipal) { - - if ($currentPrincipal === $path || strpos($currentPrincipal, $path . '/') === 0) { + if ($currentPrincipal === $path || 0 === strpos($currentPrincipal, $path.'/')) { $result[] = $currentPrincipal; } - } - } else { - // We need to find all resources that have a property that matches // one of the current principals. $candidates = $this->server->getPropertiesForPath( @@ -1290,7 +1243,6 @@ class Plugin extends DAV\ServerPlugin { ); foreach ($candidates as $candidate) { - if (!isset($candidate[200][$report->principalProperty])) { continue; } @@ -1308,23 +1260,19 @@ class Plugin extends DAV\ServerPlugin { } } } - } $responses = []; foreach ($result as $item) { - $properties = []; if ($report->properties) { - $foo = $this->server->getPropertiesForPath($item, $report->properties); $foo = $foo[0]; $item = $foo['href']; unset($foo['href']); $properties = $foo; - } $responses[] = new DAV\Xml\Element\Response( @@ -1332,7 +1280,6 @@ class Plugin extends DAV\ServerPlugin { $properties, '200' ); - } $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); @@ -1344,8 +1291,6 @@ class Plugin extends DAV\ServerPlugin { $this->server->getBaseUri() ) ); - - } /** @@ -1359,12 +1304,11 @@ class Plugin extends DAV\ServerPlugin { * Other rfc's, such as ACL rely on this report, so it made sense to put * it in this plugin. * - * @param string $path + * @param string $path * @param Xml\Request\ExpandPropertyReport $report - * @return void */ - protected function expandPropertyReport($path, $report) { - + protected function expandPropertyReport($path, $report) + { $depth = $this->server->getHTTPDepth(0); $result = $this->expandProperties($path, $report->properties, $depth); @@ -1377,34 +1321,36 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setBody($xml); - } /** * This method expands all the properties and returns - * a list with property values + * a list with property values. * * @param array $path * @param array $requestedProperties the list of required properties - * @param int $depth + * @param int $depth + * * @return array */ - protected function expandProperties($path, array $requestedProperties, $depth) { - + protected function expandProperties($path, array $requestedProperties, $depth) + { $foundProperties = $this->server->getPropertiesForPath($path, array_keys($requestedProperties), $depth); $result = []; foreach ($foundProperties as $node) { - foreach ($requestedProperties as $propertyName => $childRequestedProperties) { - // We're only traversing if sub-properties were requested - if (count($childRequestedProperties) === 0) continue; + if (!is_array($childRequestedProperties) || 0 === count($childRequestedProperties)) { + continue; + } // We only have to do the expansion if the property was found // and it contains an href element. - if (!array_key_exists($propertyName, $node[200])) continue; + if (!array_key_exists($propertyName, $node[200])) { + continue; + } if (!$node[200][$propertyName] instanceof DAV\Xml\Property\Href) { continue; @@ -1416,39 +1362,35 @@ class Plugin extends DAV\ServerPlugin { foreach ($childHrefs as $href) { // Gathering the result of the children $childProps[] = [ - 'name' => '{DAV:}response', - 'value' => $this->expandProperties($href, $childRequestedProperties, 0)[0] + 'name' => '{DAV:}response', + 'value' => $this->expandProperties($href, $childRequestedProperties, 0)[0], ]; } // Replacing the property with its expanded form. $node[200][$propertyName] = $childProps; - } $result[] = new DAV\Xml\Element\Response($node['href'], $node); - } return $result; - } /** - * principalSearchPropertySetReport + * principalSearchPropertySetReport. * * This method responsible for handing the * {DAV:}principal-search-property-set report. This report returns a list * of properties the client may search on, using the * {DAV:}principal-property-search report. * - * @param string $path + * @param string $path * @param Xml\Request\PrincipalSearchPropertySetReport $report - * @return void */ - protected function principalSearchPropertySetReport($path, $report) { - + protected function principalSearchPropertySetReport($path, $report) + { $httpDepth = $this->server->getHTTPDepth(0); - if ($httpDepth !== 0) { + if (0 !== $httpDepth) { throw new DAV\Exception\BadRequest('This report is only defined when Depth: 0'); } @@ -1459,7 +1401,6 @@ class Plugin extends DAV\ServerPlugin { $writer->startElement('{DAV:}principal-search-property-set'); foreach ($this->principalSearchPropertySet as $propertyName => $description) { - $writer->startElement('{DAV:}principal-search-property'); $writer->startElement('{DAV:}prop'); @@ -1469,15 +1410,13 @@ class Plugin extends DAV\ServerPlugin { if ($description) { $writer->write([[ - 'name' => '{DAV:}description', - 'value' => $description, - 'attributes' => ['xml:lang' => 'en'] + 'name' => '{DAV:}description', + 'value' => $description, + 'attributes' => ['xml:lang' => 'en'], ]]); } $writer->endElement(); // principal-search-property - - } $writer->endElement(); // principal-search-property-set @@ -1485,27 +1424,25 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setStatus(200); $this->server->httpResponse->setBody($writer->outputMemory()); - } /** - * principalPropertySearchReport + * principalPropertySearchReport. * * This method is responsible for handing the * {DAV:}principal-property-search report. This report can be used for * clients to search for groups of principals, based on the value of one * or more properties. * - * @param string $path + * @param string $path * @param Xml\Request\PrincipalPropertySearchReport $report - * @return void */ - protected function principalPropertySearchReport($path, Xml\Request\PrincipalPropertySearchReport $report) { - + protected function principalPropertySearchReport($path, Xml\Request\PrincipalPropertySearchReport $report) + { if ($report->applyToPrincipalCollectionSet) { $path = null; } - if ($this->server->getHttpDepth('0') !== 0) { + if (0 !== $this->server->getHttpDepth('0')) { throw new BadRequest('Depth must be 0'); } $result = $this->principalSearch( @@ -1520,12 +1457,11 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer'); - $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, $prefer['return'] === 'minimal')); - + $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, 'minimal' === $prefer['return'])); } /** - * aclPrincipalPropSet REPORT + * aclPrincipalPropSet REPORT. * * This method is responsible for handling the {DAV:}acl-principal-prop-set * REPORT, as defined in: @@ -1537,13 +1473,12 @@ class Plugin extends DAV\ServerPlugin { * is used to for example generate a UI with ACL rules, allowing you * to show names for principals for every entry. * - * @param string $path + * @param string $path * @param Xml\Request\AclPrincipalPropSetReport $report - * @return void */ - protected function aclPrincipalPropSetReport($path, Xml\Request\AclPrincipalPropSetReport $report) { - - if ($this->server->getHTTPDepth(0) !== 0) { + protected function aclPrincipalPropSetReport($path, Xml\Request\AclPrincipalPropSetReport $report) + { + if (0 !== $this->server->getHTTPDepth(0)) { throw new BadRequest('The {DAV:}acl-principal-prop-set REPORT only supports Depth 0'); } @@ -1558,14 +1493,12 @@ class Plugin extends DAV\ServerPlugin { $principals = []; foreach ($acl['{DAV:}acl']->getPrivileges() as $ace) { - - if ($ace['principal'][0] === '{') { + if ('{' === $ace['principal'][0]) { // It's not a principal, it's one of the special rules such as {DAV:}authenticated continue; } $principals[] = $ace['principal']; - } $properties = $this->server->getPropertiesForMultiplePaths( @@ -1578,10 +1511,8 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setBody( $this->server->generateMultiStatus($properties) ); - } - /* }}} */ /** @@ -1590,13 +1521,15 @@ class Plugin extends DAV\ServerPlugin { * can use to create new calendars. * * @param DAV\INode $node - * @param string $output + * @param string $output + * * @return bool */ - function htmlActionsPanel(DAV\INode $node, &$output) { - - if (!$node instanceof PrincipalCollection) + public function htmlActionsPanel(DAV\INode $node, &$output) + { + if (!$node instanceof PrincipalCollection) { return; + } $output .= '<tr><td colspan="2"><form method="post" action=""> <h3>Create new principal</h3> @@ -1610,7 +1543,6 @@ class Plugin extends DAV\ServerPlugin { </td></tr>'; return false; - } /** @@ -1624,13 +1556,12 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds support for WebDAV ACL (rfc3744)', - 'link' => 'http://sabre.io/dav/acl/', + 'link' => 'http://sabre.io/dav/acl/', ]; - } } diff --git a/vendor/sabre/dav/lib/DAVACL/Principal.php b/vendor/sabre/dav/lib/DAVACL/Principal.php index d7db94999..e2df1c35e 100644 --- a/vendor/sabre/dav/lib/DAVACL/Principal.php +++ b/vendor/sabre/dav/lib/DAVACL/Principal.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * Principal class + * Principal class. * * This class is a representation of a simple principal * @@ -20,8 +22,8 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { - +class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL +{ use ACLTrait; /** @@ -32,93 +34,86 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { protected $principalProperties; /** - * Principal backend + * Principal backend. * * @var PrincipalBackend\BackendInterface */ protected $principalBackend; /** - * Creates the principal object + * Creates the principal object. * * @param PrincipalBackend\BackendInterface $principalBackend - * @param array $principalProperties + * @param array $principalProperties */ - function __construct(PrincipalBackend\BackendInterface $principalBackend, array $principalProperties = []) { - + public function __construct(PrincipalBackend\BackendInterface $principalBackend, array $principalProperties = []) + { if (!isset($principalProperties['uri'])) { throw new DAV\Exception('The principal properties must at least contain the \'uri\' key'); } $this->principalBackend = $principalBackend; $this->principalProperties = $principalProperties; - } /** - * Returns the full principal url + * Returns the full principal url. * * @return string */ - function getPrincipalUrl() { - + public function getPrincipalUrl() + { return $this->principalProperties['uri']; - } /** - * Returns a list of alternative urls for a principal + * Returns a list of alternative urls for a principal. * * This can for example be an email address, or ldap url. * * @return array */ - function getAlternateUriSet() { - + public function getAlternateUriSet() + { $uris = []; if (isset($this->principalProperties['{DAV:}alternate-URI-set'])) { - $uris = $this->principalProperties['{DAV:}alternate-URI-set']; - } if (isset($this->principalProperties['{http://sabredav.org/ns}email-address'])) { - $uris[] = 'mailto:' . $this->principalProperties['{http://sabredav.org/ns}email-address']; + $uris[] = 'mailto:'.$this->principalProperties['{http://sabredav.org/ns}email-address']; } return array_unique($uris); - } /** - * Returns the list of group members + * Returns the list of group members. * * If this principal is a group, this function should return * all member principal uri's for the group. * * @return array */ - function getGroupMemberSet() { - + public function getGroupMemberSet() + { return $this->principalBackend->getGroupMemberSet($this->principalProperties['uri']); - } /** - * Returns the list of groups this principal is member of + * Returns the list of groups this principal is member of. * * If this principal is a member of a (list of) groups, this function * should return a list of principal uri's for it's members. * * @return array */ - function getGroupMembership() { - + public function getGroupMembership() + { return $this->principalBackend->getGroupMemberShip($this->principalProperties['uri']); - } /** - * Sets a list of group members + * Sets a list of group members. * * If this principal is a group, this method sets all the group members. * The list of members is always overwritten, never appended to. @@ -126,12 +121,10 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { * This method should throw an exception if the members could not be set. * * @param array $groupMembers - * @return void */ - function setGroupMemberSet(array $groupMembers) { - + public function setGroupMemberSet(array $groupMembers) + { $this->principalBackend->setGroupMemberSet($this->principalProperties['uri'], $groupMembers); - } /** @@ -139,48 +132,45 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { * * @return string */ - function getName() { - + public function getName() + { $uri = $this->principalProperties['uri']; - list(, $name) = URLUtil::splitPath($uri); - return $name; + list(, $name) = Uri\split($uri); + return $name; } /** - * Returns the name of the user + * Returns the name of the user. * * @return string */ - function getDisplayName() { - + public function getDisplayName() + { if (isset($this->principalProperties['{DAV:}displayname'])) { return $this->principalProperties['{DAV:}displayname']; } else { return $this->getName(); } - } /** - * Returns a list of properties + * Returns a list of properties. * * @param array $requestedProperties + * * @return array */ - function getProperties($requestedProperties) { - + public function getProperties($requestedProperties) + { $newProperties = []; foreach ($requestedProperties as $propName) { - if (isset($this->principalProperties[$propName])) { $newProperties[$propName] = $this->principalProperties[$propName]; } - } return $newProperties; - } /** @@ -193,29 +183,24 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { * Read the PropPatch documentation for more information. * * @param DAV\PropPatch $propPatch - * @return void */ - function propPatch(DAV\PropPatch $propPatch) { - + public function propPatch(DAV\PropPatch $propPatch) + { return $this->principalBackend->updatePrincipal( $this->principalProperties['uri'], $propPatch ); - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->principalProperties['uri']; - - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php index 9bf9ba445..03a9c4bad 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; /** - * Abstract Principal Backend + * Abstract Principal Backend. * * Currently this class has no function. It's here for consistency and so we * have a non-bc-breaking way to add a default generic implementation to @@ -13,8 +15,8 @@ namespace Sabre\DAVACL\PrincipalBackend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface { - +abstract class AbstractBackend implements BackendInterface +{ /** * Finds a principal by its URI. * @@ -30,13 +32,14 @@ abstract class AbstractBackend implements BackendInterface { * * @param string $uri * @param string $principalPrefix + * * @return string */ - function findByUri($uri, $principalPrefix) { - + public function findByUri($uri, $principalPrefix) + { // Note that the default implementation here is a bit slow and could // likely be optimized. - if (substr($uri, 0, 7) !== 'mailto:') { + if ('mailto:' !== substr($uri, 0, 7)) { return; } $result = $this->searchPrincipals( @@ -47,7 +50,5 @@ abstract class AbstractBackend implements BackendInterface { if ($result) { return $result[0]; } - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php index 40b6e33ea..40ac272b5 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; /** @@ -13,8 +15,8 @@ namespace Sabre\DAVACL\PrincipalBackend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * Returns a list of principals based on a prefix. * @@ -29,9 +31,10 @@ interface BackendInterface { * you have an email address, use this property. * * @param string $prefixPath + * * @return array */ - function getPrincipalsByPrefix($prefixPath); + public function getPrincipalsByPrefix($prefixPath); /** * Returns a specific principal, specified by it's path. @@ -39,9 +42,10 @@ interface BackendInterface { * getPrincipalsByPrefix. * * @param string $path + * * @return array */ - function getPrincipalByPath($path); + public function getPrincipalByPath($path); /** * Updates one ore more webdav properties on a principal. @@ -55,11 +59,10 @@ interface BackendInterface { * * Read the PropPatch documentation for more info and examples. * - * @param string $path + * @param string $path * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch); + public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch); /** * This method is used to search for principals matching a set of @@ -86,11 +89,12 @@ interface BackendInterface { * from working. * * @param string $prefixPath - * @param array $searchProperties + * @param array $searchProperties * @param string $test + * * @return array */ - function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof'); + public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof'); /** * Finds a principal by its URI. @@ -107,25 +111,28 @@ interface BackendInterface { * * @param string $uri * @param string $principalPrefix + * * @return string */ - function findByUri($uri, $principalPrefix); + public function findByUri($uri, $principalPrefix); /** - * Returns the list of members for a group-principal + * Returns the list of members for a group-principal. * * @param string $principal + * * @return array */ - function getGroupMemberSet($principal); + public function getGroupMemberSet($principal); /** - * Returns the list of groups a principal is a member of + * Returns the list of groups a principal is a member of. * * @param string $principal + * * @return array */ - function getGroupMembership($principal); + public function getGroupMembership($principal); /** * Updates the list of group members for a group principal. @@ -133,9 +140,7 @@ interface BackendInterface { * The principals should be passed as a list of uri's. * * @param string $principal - * @param array $members - * @return void + * @param array $members */ - function setGroupMemberSet($principal, array $members); - + public function setGroupMemberSet($principal, array $members); } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php index e354a697d..ee418e49b 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; use Sabre\DAV\MkCol; @@ -12,8 +14,8 @@ use Sabre\DAV\MkCol; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface CreatePrincipalSupport extends BackendInterface { - +interface CreatePrincipalSupport extends BackendInterface +{ /** * Creates a new principal. * @@ -22,9 +24,7 @@ interface CreatePrincipalSupport extends BackendInterface { * of the principal. * * @param string $path - * @param MkCol $mkCol - * @return void + * @param MkCol $mkCol */ - function createPrincipal($path, MkCol $mkCol); - + public function createPrincipal($path, MkCol $mkCol); } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php index eb0df888b..350ecb145 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; use Sabre\DAV; use Sabre\DAV\MkCol; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * PDO principal backend + * PDO principal backend. * * * This backend assumes all principals are in a single collection. The default collection @@ -17,44 +19,43 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend implements CreatePrincipalSupport { - +class PDO extends AbstractBackend implements CreatePrincipalSupport +{ /** - * PDO table name for 'principals' + * PDO table name for 'principals'. * * @var string */ public $tableName = 'principals'; /** - * PDO table name for 'group members' + * PDO table name for 'group members'. * * @var string */ public $groupMembersTableName = 'groupmembers'; /** - * pdo + * pdo. * * @var PDO */ protected $pdo; /** - * A list of additional fields to support + * A list of additional fields to support. * * @var array */ protected $fieldMap = [ - - /** + /* * This property can be used to display the users' real name. */ '{DAV:}displayname' => [ 'dbField' => 'displayname', ], - /** + /* * This is the users' primary email-address. */ '{http://sabredav.org/ns}email-address' => [ @@ -67,10 +68,9 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -87,10 +87,11 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * you have an email address, use this property. * * @param string $prefixPath + * * @return array */ - function getPrincipalsByPrefix($prefixPath) { - + public function getPrincipalsByPrefix($prefixPath) + { $fields = [ 'uri', ]; @@ -98,15 +99,16 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { foreach ($this->fieldMap as $key => $value) { $fields[] = $value['dbField']; } - $result = $this->pdo->query('SELECT ' . implode(',', $fields) . ' FROM ' . $this->tableName); + $result = $this->pdo->query('SELECT '.implode(',', $fields).' FROM '.$this->tableName); $principals = []; while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { - // Checking if the principal is in the prefix - list($rowPrefix) = URLUtil::splitPath($row['uri']); - if ($rowPrefix !== $prefixPath) continue; + list($rowPrefix) = Uri\split($row['uri']); + if ($rowPrefix !== $prefixPath) { + continue; + } $principal = [ 'uri' => $row['uri'], @@ -117,11 +119,9 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { } } $principals[] = $principal; - } return $principals; - } /** @@ -130,10 +130,11 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * getPrincipalsByPrefix. * * @param string $path + * * @return array */ - function getPrincipalByPath($path) { - + public function getPrincipalByPath($path) + { $fields = [ 'id', 'uri', @@ -142,14 +143,16 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { foreach ($this->fieldMap as $key => $value) { $fields[] = $value['dbField']; } - $stmt = $this->pdo->prepare('SELECT ' . implode(',', $fields) . ' FROM ' . $this->tableName . ' WHERE uri = ?'); + $stmt = $this->pdo->prepare('SELECT '.implode(',', $fields).' FROM '.$this->tableName.' WHERE uri = ?'); $stmt->execute([$path]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if (!$row) return; + if (!$row) { + return; + } $principal = [ - 'id' => $row['id'], + 'id' => $row['id'], 'uri' => $row['uri'], ]; foreach ($this->fieldMap as $key => $value) { @@ -157,8 +160,8 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { $principal[$key] = $row[$value['dbField']]; } } - return $principal; + return $principal; } /** @@ -173,41 +176,36 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * * Read the PropPatch documentation for more info and examples. * - * @param string $path + * @param string $path * @param DAV\PropPatch $propPatch */ - function updatePrincipal($path, DAV\PropPatch $propPatch) { - - $propPatch->handle(array_keys($this->fieldMap), function($properties) use ($path) { - - $query = "UPDATE " . $this->tableName . " SET "; + public function updatePrincipal($path, DAV\PropPatch $propPatch) + { + $propPatch->handle(array_keys($this->fieldMap), function ($properties) use ($path) { + $query = 'UPDATE '.$this->tableName.' SET '; $first = true; $values = []; foreach ($properties as $key => $value) { - $dbField = $this->fieldMap[$key]['dbField']; if (!$first) { $query .= ', '; } $first = false; - $query .= $dbField . ' = :' . $dbField; + $query .= $dbField.' = :'.$dbField; $values[$dbField] = $value; - } - $query .= " WHERE uri = :uri"; + $query .= ' WHERE uri = :uri'; $values['uri'] = $path; $stmt = $this->pdo->prepare($query); $stmt->execute($values); return true; - }); - } /** @@ -235,48 +233,52 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * from working. * * @param string $prefixPath - * @param array $searchProperties + * @param array $searchProperties * @param string $test + * * @return array */ - function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') { - if (count($searchProperties) == 0) return []; //No criteria + public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') + { + if (0 == count($searchProperties)) { + return []; + } //No criteria - $query = 'SELECT uri FROM ' . $this->tableName . ' WHERE '; + $query = 'SELECT uri FROM '.$this->tableName.' WHERE '; $values = []; foreach ($searchProperties as $property => $value) { switch ($property) { - case '{DAV:}displayname' : - $column = "displayname"; + case '{DAV:}displayname': + $column = 'displayname'; break; - case '{http://sabredav.org/ns}email-address' : - $column = "email"; + case '{http://sabredav.org/ns}email-address': + $column = 'email'; break; - default : + default: // Unsupported property return []; } - if (count($values) > 0) $query .= (strcmp($test, "anyof") == 0 ? " OR " : " AND "); - $query .= 'lower(' . $column . ') LIKE lower(?)'; - $values[] = '%' . $value . '%'; - + if (count($values) > 0) { + $query .= (0 == strcmp($test, 'anyof') ? ' OR ' : ' AND '); + } + $query .= 'lower('.$column.') LIKE lower(?)'; + $values[] = '%'.$value.'%'; } $stmt = $this->pdo->prepare($query); $stmt->execute($values); $principals = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - // Checking if the principal is in the prefix - list($rowPrefix) = URLUtil::splitPath($row['uri']); - if ($rowPrefix !== $prefixPath) continue; + list($rowPrefix) = Uri\split($row['uri']); + if ($rowPrefix !== $prefixPath) { + continue; + } $principals[] = $row['uri']; - } return $principals; - } /** @@ -294,26 +296,32 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * * @param string $uri * @param string $principalPrefix + * * @return string */ - function findByUri($uri, $principalPrefix) { + public function findByUri($uri, $principalPrefix) + { $value = null; $scheme = null; - list($scheme, $value) = explode(":", $uri, 2); - if (empty($value)) return null; + list($scheme, $value) = explode(':', $uri, 2); + if (empty($value)) { + return null; + } $uri = null; - switch ($scheme){ - case "mailto": - $query = 'SELECT uri FROM ' . $this->tableName . ' WHERE lower(email)=lower(?)'; + switch ($scheme) { + case 'mailto': + $query = 'SELECT uri FROM '.$this->tableName.' WHERE lower(email)=lower(?)'; $stmt = $this->pdo->prepare($query); $stmt->execute([$value]); - + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { // Checking if the principal is in the prefix - list($rowPrefix) = URLUtil::splitPath($row['uri']); - if ($rowPrefix !== $principalPrefix) continue; - + list($rowPrefix) = Uri\split($row['uri']); + if ($rowPrefix !== $principalPrefix) { + continue; + } + $uri = $row['uri']; break; //Stop on first match } @@ -322,51 +330,56 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { //unsupported uri scheme return null; } + return $uri; } /** - * Returns the list of members for a group-principal + * Returns the list of members for a group-principal. * * @param string $principal + * * @return array */ - function getGroupMemberSet($principal) { - + public function getGroupMemberSet($principal) + { $principal = $this->getPrincipalByPath($principal); - if (!$principal) throw new DAV\Exception('Principal not found'); - - $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM ' . $this->groupMembersTableName . ' AS groupmembers LEFT JOIN ' . $this->tableName . ' AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.principal_id = ?'); + if (!$principal) { + throw new DAV\Exception('Principal not found'); + } + $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM '.$this->groupMembersTableName.' AS groupmembers LEFT JOIN '.$this->tableName.' AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.principal_id = ?'); $stmt->execute([$principal['id']]); $result = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row['uri']; } - return $result; + return $result; } /** - * Returns the list of groups a principal is a member of + * Returns the list of groups a principal is a member of. * * @param string $principal + * * @return array */ - function getGroupMembership($principal) { - + public function getGroupMembership($principal) + { $principal = $this->getPrincipalByPath($principal); - if (!$principal) throw new DAV\Exception('Principal not found'); - - $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM ' . $this->groupMembersTableName . ' AS groupmembers LEFT JOIN ' . $this->tableName . ' AS principals ON groupmembers.principal_id = principals.id WHERE groupmembers.member_id = ?'); + if (!$principal) { + throw new DAV\Exception('Principal not found'); + } + $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM '.$this->groupMembersTableName.' AS groupmembers LEFT JOIN '.$this->tableName.' AS principals ON groupmembers.principal_id = principals.id WHERE groupmembers.member_id = ?'); $stmt->execute([$principal['id']]); $result = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row['uri']; } - return $result; + return $result; } /** @@ -375,13 +388,12 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * The principals should be passed as a list of uri's. * * @param string $principal - * @param array $members - * @return void + * @param array $members */ - function setGroupMemberSet($principal, array $members) { - + public function setGroupMemberSet($principal, array $members) + { // Grabbing the list of principal id's. - $stmt = $this->pdo->prepare('SELECT id, uri FROM ' . $this->tableName . ' WHERE uri IN (? ' . str_repeat(', ? ', count($members)) . ');'); + $stmt = $this->pdo->prepare('SELECT id, uri FROM '.$this->tableName.' WHERE uri IN (? '.str_repeat(', ? ', count($members)).');'); $stmt->execute(array_merge([$principal], $members)); $memberIds = []; @@ -394,19 +406,17 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { $memberIds[] = $row['id']; } } - if (!$principalId) throw new DAV\Exception('Principal not found'); - + if (!$principalId) { + throw new DAV\Exception('Principal not found'); + } // Wiping out old members - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->groupMembersTableName . ' WHERE principal_id = ?;'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->groupMembersTableName.' WHERE principal_id = ?;'); $stmt->execute([$principalId]); foreach ($memberIds as $memberId) { - - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->groupMembersTableName . ' (principal_id, member_id) VALUES (?, ?);'); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->groupMembersTableName.' (principal_id, member_id) VALUES (?, ?);'); $stmt->execute([$principalId, $memberId]); - } - } /** @@ -417,15 +427,12 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * of the principal. * * @param string $path - * @param MkCol $mkCol - * @return void + * @param MkCol $mkCol */ - function createPrincipal($path, MkCol $mkCol) { - - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->tableName . ' (uri) VALUES (?)'); + public function createPrincipal($path, MkCol $mkCol) + { + $stmt = $this->pdo->prepare('INSERT INTO '.$this->tableName.' (uri) VALUES (?)'); $stmt->execute([$path]); $this->updatePrincipal($path, $mkCol); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php b/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php index ee5b88a90..4fae96e0c 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV\Exception\InvalidResourceType; @@ -7,7 +9,7 @@ use Sabre\DAV\IExtendedCollection; use Sabre\DAV\MkCol; /** - * Principals Collection + * Principals Collection. * * This collection represents a list of users. * The users are instances of Sabre\DAVACL\Principal @@ -16,8 +18,8 @@ use Sabre\DAV\MkCol; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalCollection extends AbstractPrincipalCollection implements IExtendedCollection, IACL { - +class PrincipalCollection extends AbstractPrincipalCollection implements IExtendedCollection, IACL +{ use ACLTrait; /** @@ -28,12 +30,12 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend * supplied by the authentication backend. * * @param array $principal + * * @return \Sabre\DAV\INode */ - function getChildForPrincipal(array $principal) { - + public function getChildForPrincipal(array $principal) + { return new Principal($this->principalBackend, $principal); - } /** @@ -56,21 +58,20 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend * property for you. * * @param string $name - * @param MkCol $mkCol + * @param MkCol $mkCol + * * @throws InvalidResourceType - * @return void */ - function createExtendedCollection($name, MkCol $mkCol) { - + public function createExtendedCollection($name, MkCol $mkCol) + { if (!$mkCol->hasResourceType('{DAV:}principal')) { throw new InvalidResourceType('Only resources of type {DAV:}principal may be created here'); } $this->principalBackend->createPrincipal( - $this->principalPrefix . '/' . $name, + $this->principalPrefix.'/'.$name, $mkCol ); - } /** @@ -85,7 +86,8 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend * * @return array */ - function getACL() { + public function getACL() + { return [ [ 'principal' => '{DAV:}authenticated', @@ -94,5 +96,4 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend ], ]; } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php index 0e1c30ccf..372f62ab3 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\DAV; @@ -25,10 +27,10 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Acl implements Element, HtmlOutput { - +class Acl implements Element, HtmlOutput +{ /** - * List of privileges + * List of privileges. * * @var array */ @@ -43,7 +45,7 @@ class Acl implements Element, HtmlOutput { protected $prefixBaseUrl; /** - * Constructor + * Constructor. * * This object requires a structure similar to the return value from * Sabre\DAVACL\Plugin::getACL(). @@ -57,24 +59,22 @@ class Acl implements Element, HtmlOutput { * will automatically be prefixed. * * @param array $privileges - * @param bool $prefixBaseUrl + * @param bool $prefixBaseUrl */ - function __construct(array $privileges, $prefixBaseUrl = true) { - + public function __construct(array $privileges, $prefixBaseUrl = true) + { $this->privileges = $privileges; $this->prefixBaseUrl = $prefixBaseUrl; - } /** - * Returns the list of privileges for this property + * Returns the list of privileges for this property. * * @return array */ - function getPrivileges() { - + public function getPrivileges() + { return $this->privileges; - } /** @@ -94,16 +94,12 @@ class Acl implements Element, HtmlOutput { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->privileges as $ace) { - $this->serializeAce($writer, $ace); - } - } /** @@ -118,32 +114,33 @@ class Acl implements Element, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { ob_start(); - echo "<table>"; - echo "<tr><th>Principal</th><th>Privilege</th><th></th></tr>"; + echo '<table>'; + echo '<tr><th>Principal</th><th>Privilege</th><th></th></tr>'; foreach ($this->privileges as $privilege) { - echo '<tr>'; // if it starts with a {, it's a special principal - if ($privilege['principal'][0] === '{') { + if ('{' === $privilege['principal'][0]) { echo '<td>', $html->xmlName($privilege['principal']), '</td>'; } else { echo '<td>', $html->link($privilege['principal']), '</td>'; } echo '<td>', $html->xmlName($privilege['privilege']), '</td>'; echo '<td>'; - if (!empty($privilege['protected'])) echo '(protected)'; + if (!empty($privilege['protected'])) { + echo '(protected)'; + } echo '</td>'; echo '</tr>'; - } - echo "</table>"; - return ob_get_clean(); + echo '</table>'; + return ob_get_clean(); } /** @@ -165,21 +162,21 @@ class Acl implements Element, HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elementMap = [ - '{DAV:}ace' => 'Sabre\Xml\Element\KeyValue', + '{DAV:}ace' => 'Sabre\Xml\Element\KeyValue', '{DAV:}privilege' => 'Sabre\Xml\Element\Elements', '{DAV:}principal' => 'Sabre\DAVACL\Xml\Property\Principal', ]; $privileges = []; - foreach ((array)$reader->parseInnerTree($elementMap) as $element) { - - if ($element['name'] !== '{DAV:}ace') { + foreach ((array) $reader->parseInnerTree($elementMap) as $element) { + if ('{DAV:}ace' !== $element['name']) { continue; } $ace = $element['value']; @@ -190,19 +187,18 @@ class Acl implements Element, HtmlOutput { $principal = $ace['{DAV:}principal']; switch ($principal->getType()) { - case Principal::HREF : + case Principal::HREF: $principal = $principal->getHref(); break; - case Principal::AUTHENTICATED : + case Principal::AUTHENTICATED: $principal = '{DAV:}authenticated'; break; - case Principal::UNAUTHENTICATED : + case Principal::UNAUTHENTICATED: $principal = '{DAV:}unauthenticated'; break; - case Principal::ALL : + case Principal::ALL: $principal = '{DAV:}all'; break; - } $protected = array_key_exists('{DAV:}protected', $ace); @@ -211,7 +207,7 @@ class Acl implements Element, HtmlOutput { throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported'); } foreach ($ace['{DAV:}grant'] as $elem) { - if ($elem['name'] !== '{DAV:}privilege') { + if ('{DAV:}privilege' !== $elem['name']) { continue; } @@ -222,34 +218,30 @@ class Acl implements Element, HtmlOutput { 'privilege' => $priv, ]; } - } - } return new self($privileges); - } /** * Serializes a single access control entry. * * @param Writer $writer - * @param array $ace - * @return void + * @param array $ace */ - private function serializeAce(Writer $writer, array $ace) { - + private function serializeAce(Writer $writer, array $ace) + { $writer->startElement('{DAV:}ace'); switch ($ace['principal']) { - case '{DAV:}authenticated' : + case '{DAV:}authenticated': $principal = new Principal(Principal::AUTHENTICATED); break; - case '{DAV:}unauthenticated' : + case '{DAV:}unauthenticated': $principal = new Principal(Principal::UNAUTHENTICATED); break; - case '{DAV:}all' : + case '{DAV:}all': $principal = new Principal(Principal::ALL); break; default: @@ -271,7 +263,5 @@ class Acl implements Element, HtmlOutput { } $writer->endElement(); // ace - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php index 8d5854c23..0bf16b431 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * AclRestrictions property + * AclRestrictions property. * * This property represents {DAV:}acl-restrictions, as defined in RFC3744. * @@ -14,8 +16,8 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AclRestrictions implements XmlSerializable { - +class AclRestrictions implements XmlSerializable +{ /** * The xmlSerialize method is called during xml writing. * @@ -33,13 +35,10 @@ class AclRestrictions implements XmlSerializable { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { $writer->writeElement('{DAV:}grant-only'); $writer->writeElement('{DAV:}no-invert'); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php index 74c09cee1..083856330 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -9,7 +11,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * CurrentUserPrivilegeSet + * CurrentUserPrivilegeSet. * * This class represents the current-user-privilege-set property. When * requested, it contain all the privileges a user has on a specific node. @@ -18,26 +20,25 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CurrentUserPrivilegeSet implements Element, HtmlOutput { - +class CurrentUserPrivilegeSet implements Element, HtmlOutput +{ /** - * List of privileges + * List of privileges. * * @var array */ private $privileges; /** - * Creates the object + * Creates the object. * * Pass the privileges in clark-notation * * @param array $privileges */ - function __construct(array $privileges) { - + public function __construct(array $privileges) + { $this->privileges = $privileges; - } /** @@ -57,19 +58,14 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->privileges as $privName) { - $writer->startElement('{DAV:}privilege'); $writer->writeElement($privName); $writer->endElement(); - } - - } /** @@ -77,12 +73,12 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * list. * * @param string $privilegeName + * * @return bool */ - function has($privilegeName) { - + public function has($privilegeName) + { return in_array($privilegeName, $this->privileges); - } /** @@ -90,10 +86,9 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * * @return array */ - function getValue() { - + public function getValue() + { return $this->privileges; - } /** @@ -115,21 +110,22 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $result = []; $tree = $reader->parseInnerTree(['{DAV:}privilege' => 'Sabre\\Xml\\Element\\Elements']); foreach ($tree as $element) { - if ($element['name'] !== '{DAV:}privilege') { + if ('{DAV:}privilege' !== $element['name']) { continue; } $result[] = $element['value'][0]; } - return new self($result); + return new self($result); } /** @@ -144,16 +140,14 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { return implode( ', ', array_map([$html, 'xmlName'], $this->getValue()) ); - } - - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php index 04d22165d..e304a2aed 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\DAV; @@ -9,7 +11,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * Principal property + * Principal property. * * The principal property represents a principal from RFC3744 (ACL). * The property can be used to specify a principal or pseudo principals. @@ -18,30 +20,30 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Principal extends DAV\Xml\Property\Href { - +class Principal extends DAV\Xml\Property\Href +{ /** - * To specify a not-logged-in user, use the UNAUTHENTICATED principal + * To specify a not-logged-in user, use the UNAUTHENTICATED principal. */ const UNAUTHENTICATED = 1; /** - * To specify any principal that is logged in, use AUTHENTICATED + * To specify any principal that is logged in, use AUTHENTICATED. */ const AUTHENTICATED = 2; /** - * Specific principals can be specified with the HREF + * Specific principals can be specified with the HREF. */ const HREF = 3; /** - * Everybody, basically + * Everybody, basically. */ const ALL = 4; /** - * Principal-type + * Principal-type. * * Must be one of the UNAUTHENTICATED, AUTHENTICATED or HREF constants. * @@ -56,34 +58,31 @@ class Principal extends DAV\Xml\Property\Href { * * 'href' is only required for the HREF type. * - * @param int $type + * @param int $type * @param string|null $href */ - function __construct($type, $href = null) { - + public function __construct($type, $href = null) + { $this->type = $type; - if ($type === self::HREF && is_null($href)) { + if (self::HREF === $type && is_null($href)) { throw new DAV\Exception('The href argument must be specified for the HREF principal type.'); } if ($href) { - $href = rtrim($href, '/') . '/'; + $href = rtrim($href, '/').'/'; parent::__construct($href); } - } /** - * Returns the principal type + * Returns the principal type. * * @return int */ - function getType() { - + public function getType() + { return $this->type; - } - /** * The xmlSerialize method is called during xml writing. * @@ -101,26 +100,23 @@ class Principal extends DAV\Xml\Property\Href { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { switch ($this->type) { - - case self::UNAUTHENTICATED : + case self::UNAUTHENTICATED: $writer->writeElement('{DAV:}unauthenticated'); break; - case self::AUTHENTICATED : + case self::AUTHENTICATED: $writer->writeElement('{DAV:}authenticated'); break; - case self::HREF : + case self::HREF: parent::xmlSerialize($writer); break; - case self::ALL : + case self::ALL: $writer->writeElement('{DAV:}all'); break; } - } /** @@ -135,22 +131,21 @@ class Principal extends DAV\Xml\Property\Href { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { switch ($this->type) { - - case self::UNAUTHENTICATED : + case self::UNAUTHENTICATED: return '<em>unauthenticated</em>'; - case self::AUTHENTICATED : + case self::AUTHENTICATED: return '<em>authenticated</em>'; - case self::HREF : + case self::HREF: return parent::toHtml($html); - case self::ALL : + case self::ALL: return '<em>all</em>'; } - } /** @@ -172,25 +167,24 @@ class Principal extends DAV\Xml\Property\Href { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $tree = $reader->parseInnerTree()[0]; switch ($tree['name']) { - case '{DAV:}unauthenticated' : + case '{DAV:}unauthenticated': return new self(self::UNAUTHENTICATED); - case '{DAV:}authenticated' : + case '{DAV:}authenticated': return new self(self::AUTHENTICATED); case '{DAV:}href': return new self(self::HREF, $tree['value']); case '{DAV:}all': return new self(self::ALL); - default : - throw new BadRequest('Unknown or unsupported principal type: ' . $tree['name']); + default: + throw new BadRequest('Unknown or unsupported principal type: '.$tree['name']); } - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php index b963cc8c3..1762391d9 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -8,7 +10,7 @@ use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * SupportedPrivilegeSet property + * SupportedPrivilegeSet property. * * This property encodes the {DAV:}supported-privilege-set property, as defined * in rfc3744. Please consult the rfc for details about it's structure. @@ -21,24 +23,23 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { - +class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput +{ /** - * privileges + * privileges. * * @var array */ protected $privileges; /** - * Constructor + * Constructor. * * @param array $privileges */ - function __construct(array $privileges) { - + public function __construct(array $privileges) + { $this->privileges = $privileges; - } /** @@ -46,10 +47,9 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { * * @return array */ - function getValue() { - + public function getValue() + { return $this->privileges; - } /** @@ -69,12 +69,10 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { $this->serializePriv($writer, '{DAV:}all', ['aggregates' => $this->privileges]); - } /** @@ -89,52 +87,49 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - - $traverse = function($privName, $priv) use (&$traverse, $html) { - echo "<li>"; + public function toHtml(HtmlOutputHelper $html) + { + $traverse = function ($privName, $priv) use (&$traverse, $html) { + echo '<li>'; echo $html->xmlName($privName); if (isset($priv['abstract']) && $priv['abstract']) { - echo " <i>(abstract)</i>"; + echo ' <i>(abstract)</i>'; } if (isset($priv['description'])) { - echo " " . $html->h($priv['description']); + echo ' '.$html->h($priv['description']); } if (isset($priv['aggregates'])) { echo "\n<ul>\n"; foreach ($priv['aggregates'] as $subPrivName => $subPriv) { $traverse($subPrivName, $subPriv); } - echo "</ul>"; + echo '</ul>'; } echo "</li>\n"; }; ob_start(); - echo "<ul class=\"tree\">"; + echo '<ul class="tree">'; $traverse('{DAV:}all', ['aggregates' => $this->getValue()]); echo "</ul>\n"; return ob_get_clean(); - } - - /** - * Serializes a property + * Serializes a property. * * This is a recursive function. * * @param Writer $writer * @param string $privName - * @param array $privilege - * @return void + * @param array $privilege */ - private function serializePriv(Writer $writer, $privName, $privilege) { - + private function serializePriv(Writer $writer, $privName, $privilege) + { $writer->startElement('{DAV:}supported-privilege'); $writer->startElement('{DAV:}privilege'); @@ -154,7 +149,5 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { } $writer->endElement(); // supported-privilege - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php index 0aa2f29a5..17b37afab 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\Xml\Deserializer; @@ -17,8 +19,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (https://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AclPrincipalPropSetReport implements XmlDeserializable { - +class AclPrincipalPropSetReport implements XmlDeserializable +{ public $properties = []; /** @@ -40,10 +42,11 @@ class AclPrincipalPropSetReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $reader->pushContext(); $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\enum'; @@ -61,7 +64,5 @@ class AclPrincipalPropSetReport implements XmlDeserializable { } return $report; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php index a9938ba5b..393308cd2 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\Xml\Reader; @@ -16,8 +18,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ExpandPropertyReport implements XmlDeserializable { - +class ExpandPropertyReport implements XmlDeserializable +{ /** * An array with requested properties. * @@ -51,17 +53,17 @@ class ExpandPropertyReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree(); $obj = new self(); $obj->properties = self::traverse($elems); return $obj; - } /** @@ -69,15 +71,15 @@ class ExpandPropertyReport implements XmlDeserializable { * {DAV:}property elements. * * @param array $elems - * @return void + * + * @return array */ - private static function traverse($elems) { - + private static function traverse($elems) + { $result = []; foreach ($elems as $elem) { - - if ($elem['name'] !== '{DAV:}property') { + if ('{DAV:}property' !== $elem['name']) { continue; } @@ -85,7 +87,7 @@ class ExpandPropertyReport implements XmlDeserializable { $elem['attributes']['namespace'] : 'DAV:'; - $propName = '{' . $namespace . '}' . $elem['attributes']['name']; + $propName = '{'.$namespace.'}'.$elem['attributes']['name']; $value = null; if (is_array($elem['value'])) { @@ -93,11 +95,8 @@ class ExpandPropertyReport implements XmlDeserializable { } $result[$propName] = $value; - } return $result; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php index 1be15ab2d..f868cc9df 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\Xml\Deserializer; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalMatchReport implements XmlDeserializable { - +class PrincipalMatchReport implements XmlDeserializable +{ /** * Report on a list of principals that match the current principal. */ @@ -31,7 +33,7 @@ class PrincipalMatchReport implements XmlDeserializable { const PRINCIPAL_PROPERTY = 2; /** - * Must be SELF or PRINCIPAL_PROPERTY + * Must be SELF or PRINCIPAL_PROPERTY. * * @var int */ @@ -71,10 +73,11 @@ class PrincipalMatchReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $reader->pushContext(); $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\enum'; @@ -101,7 +104,5 @@ class PrincipalMatchReport implements XmlDeserializable { } return $principalMatch; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php index b0cf0e408..26468fd21 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\DAV\Exception\BadRequest; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalPropertySearchReport implements XmlDeserializable { - +class PrincipalPropertySearchReport implements XmlDeserializable +{ /** * The requested properties. * @@ -28,7 +30,7 @@ class PrincipalPropertySearchReport implements XmlDeserializable { public $properties; /** - * searchProperties + * searchProperties. * * @var array */ @@ -72,31 +74,30 @@ class PrincipalPropertySearchReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $foundSearchProp = false; $self->test = 'allof'; - if ($reader->getAttribute('test') === 'anyof') { + if ('anyof' === $reader->getAttribute('test')) { $self->test = 'anyof'; } $elemMap = [ '{DAV:}property-search' => 'Sabre\\Xml\\Element\\KeyValue', - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', ]; - - foreach ($reader->parseInnerTree($elemMap) as $elem) { + foreach ($reader->parseInnerTree($elemMap) as $elem) { switch ($elem['name']) { - - case '{DAV:}prop' : + case '{DAV:}prop': $self->properties = array_keys($elem['value']); break; - case '{DAV:}property-search' : + case '{DAV:}property-search': $foundSearchProp = true; // This property has two sub-elements: // {DAV:}prop - The property to be searched on. This may @@ -109,19 +110,15 @@ class PrincipalPropertySearchReport implements XmlDeserializable { $self->searchProperties[$propName] = $elem['value']['{DAV:}match']; } break; - case '{DAV:}apply-to-principal-collection-set' : + case '{DAV:}apply-to-principal-collection-set': $self->applyToPrincipalCollectionSet = true; break; - } - } if (!$foundSearchProp) { throw new BadRequest('The {DAV:}principal-property-search report must contain at least 1 {DAV:}property-search element'); } return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php index 64d1f7f86..37bc2cfbf 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\DAV\Exception\BadRequest; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalSearchPropertySetReport implements XmlDeserializable { - +class PrincipalSearchPropertySetReport implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -39,10 +41,11 @@ class PrincipalSearchPropertySetReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { if (!$reader->isEmptyElement) { throw new BadRequest('The {DAV:}principal-search-property-set element must be empty'); } @@ -51,8 +54,7 @@ class PrincipalSearchPropertySetReport implements XmlDeserializable { $reader->next(); $self = new self(); - return $self; + return $self; } - } |