diff options
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/Xml/Element/Response.php')
-rw-r--r-- | vendor/sabre/dav/lib/DAV/Xml/Element/Response.php | 95 |
1 files changed, 42 insertions, 53 deletions
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); - } - } |