aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/xml/lib
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/xml/lib')
-rw-r--r--vendor/sabre/xml/lib/ContextStackTrait.php2
-rw-r--r--vendor/sabre/xml/lib/Deserializer/functions.php43
-rw-r--r--vendor/sabre/xml/lib/Element/Uri.php2
-rw-r--r--vendor/sabre/xml/lib/Element/XmlFragment.php4
-rw-r--r--vendor/sabre/xml/lib/LibXMLException.php5
-rw-r--r--vendor/sabre/xml/lib/ParseException.php3
-rw-r--r--vendor/sabre/xml/lib/Reader.php11
-rw-r--r--vendor/sabre/xml/lib/Serializer/functions.php6
-rw-r--r--vendor/sabre/xml/lib/Service.php20
-rw-r--r--vendor/sabre/xml/lib/Version.php2
-rw-r--r--vendor/sabre/xml/lib/Writer.php2
11 files changed, 73 insertions, 27 deletions
diff --git a/vendor/sabre/xml/lib/ContextStackTrait.php b/vendor/sabre/xml/lib/ContextStackTrait.php
index bc770ffad..757088847 100644
--- a/vendor/sabre/xml/lib/ContextStackTrait.php
+++ b/vendor/sabre/xml/lib/ContextStackTrait.php
@@ -45,7 +45,7 @@ trait ContextStackTrait
* common use-case for parsing XML documents, it's added here as a
* convenience.
*
- * @var string
+ * @var string|null
*/
public $contextUri;
diff --git a/vendor/sabre/xml/lib/Deserializer/functions.php b/vendor/sabre/xml/lib/Deserializer/functions.php
index 0eff4b7e0..c4f240970 100644
--- a/vendor/sabre/xml/lib/Deserializer/functions.php
+++ b/vendor/sabre/xml/lib/Deserializer/functions.php
@@ -173,7 +173,7 @@ function enum(Reader $reader, string $namespace = null): array
if (!is_null($namespace) && $namespace === $reader->namespaceURI) {
$values[] = $reader->localName;
} else {
- $values[] = $reader->getClark();
+ $values[] = (string) $reader->getClark();
}
} while ($reader->depth >= $currentDepth && $reader->next());
@@ -316,3 +316,44 @@ function mixedContent(Reader $reader): array
return $content;
}
+
+/**
+ * The functionCaller deserializer turns an xml element into whatever your callable return.
+ *
+ * You can use, e.g., a named constructor (factory method) to create an object using
+ * this function.
+ *
+ * @return mixed
+ */
+function functionCaller(Reader $reader, callable $func, string $namespace)
+{
+ if ($reader->isEmptyElement) {
+ $reader->next();
+
+ return null;
+ }
+
+ $funcArgs = [];
+ $func = is_string($func) && false !== strpos($func, '::') ? explode('::', $func) : $func;
+ $ref = is_array($func) ? new \ReflectionMethod($func[0], $func[1]) : new \ReflectionFunction($func);
+ foreach ($ref->getParameters() as $parameter) {
+ $funcArgs[$parameter->getName()] = null;
+ }
+
+ $reader->read();
+ do {
+ if (Reader::ELEMENT === $reader->nodeType && $reader->namespaceURI == $namespace) {
+ if (array_key_exists($reader->localName, $funcArgs)) {
+ $funcArgs[$reader->localName] = $reader->parseCurrentElement()['value'];
+ } else {
+ // Ignore property
+ $reader->next();
+ }
+ } else {
+ $reader->read();
+ }
+ } while (Reader::END_ELEMENT !== $reader->nodeType);
+ $reader->read();
+
+ return $func(...array_values($funcArgs));
+}
diff --git a/vendor/sabre/xml/lib/Element/Uri.php b/vendor/sabre/xml/lib/Element/Uri.php
index 898a26457..2644fbcd7 100644
--- a/vendor/sabre/xml/lib/Element/Uri.php
+++ b/vendor/sabre/xml/lib/Element/Uri.php
@@ -91,7 +91,7 @@ class Uri implements Xml\Element
{
return new self(
\Sabre\Uri\resolve(
- $reader->contextUri,
+ (string) $reader->contextUri,
$reader->readText()
)
);
diff --git a/vendor/sabre/xml/lib/Element/XmlFragment.php b/vendor/sabre/xml/lib/Element/XmlFragment.php
index 413e0f106..12109e5c9 100644
--- a/vendor/sabre/xml/lib/Element/XmlFragment.php
+++ b/vendor/sabre/xml/lib/Element/XmlFragment.php
@@ -85,7 +85,7 @@ XML;
switch ($reader->nodeType) {
case Reader::ELEMENT:
$writer->startElement(
- $reader->getClark()
+ (string) $reader->getClark()
);
$empty = $reader->isEmptyElement;
while ($reader->moveToNextAttribute()) {
@@ -97,7 +97,7 @@ XML;
// Skip namespace declarations
break;
default:
- $writer->writeAttribute($reader->getClark(), $reader->value);
+ $writer->writeAttribute((string) $reader->getClark(), $reader->value);
break;
}
}
diff --git a/vendor/sabre/xml/lib/LibXMLException.php b/vendor/sabre/xml/lib/LibXMLException.php
index 4701c304a..ae136f57b 100644
--- a/vendor/sabre/xml/lib/LibXMLException.php
+++ b/vendor/sabre/xml/lib/LibXMLException.php
@@ -21,7 +21,7 @@ class LibXMLException extends ParseException
/**
* The error list.
*
- * @var []LibXMLError
+ * @var \LibXMLError[]
*/
protected $errors;
@@ -30,8 +30,7 @@ class LibXMLException extends ParseException
*
* You should pass a list of LibXMLError objects in its constructor.
*
- * @param []LibXMLError $errors
- * @param int $code
+ * @param LibXMLError[] $errors
* @param Throwable $previousException
*/
public function __construct(array $errors, int $code = 0, Throwable $previousException = null)
diff --git a/vendor/sabre/xml/lib/ParseException.php b/vendor/sabre/xml/lib/ParseException.php
index e237b8732..5980b5fc4 100644
--- a/vendor/sabre/xml/lib/ParseException.php
+++ b/vendor/sabre/xml/lib/ParseException.php
@@ -4,7 +4,8 @@ declare(strict_types=1);
namespace Sabre\Xml;
-use Exception;
+use
+ Exception;
/**
* This is a base exception for any exception related to parsing xml files.
diff --git a/vendor/sabre/xml/lib/Reader.php b/vendor/sabre/xml/lib/Reader.php
index 37e0c86dd..a28cf8c3b 100644
--- a/vendor/sabre/xml/lib/Reader.php
+++ b/vendor/sabre/xml/lib/Reader.php
@@ -118,7 +118,7 @@ class Reader extends XMLReader
* If the $elementMap argument is specified, the existing elementMap will
* be overridden while parsing the tree, and restored after this process.
*
- * @return array|string
+ * @return array|string|null
*/
public function parseInnerTree(array $elementMap = null)
{
@@ -147,7 +147,9 @@ class Reader extends XMLReader
throw new ParseException('This should never happen (famous last words)');
}
- while (true) {
+ $keepOnParsing = true;
+
+ while ($keepOnParsing) {
if (!$this->isValid()) {
$errors = libxml_get_errors();
@@ -169,7 +171,8 @@ class Reader extends XMLReader
case self::END_ELEMENT:
// Ensuring we are moving the cursor after the end element.
$this->read();
- break 2;
+ $keepOnParsing = false;
+ break;
case self::NONE:
throw new ParseException('We hit the end of the document prematurely. This likely means that some parser "eats" too many elements. Do not attempt to continue parsing.');
default:
@@ -223,7 +226,7 @@ class Reader extends XMLReader
}
$value = call_user_func(
- $this->getDeserializerForElementName($name),
+ $this->getDeserializerForElementName((string) $name),
$this
);
diff --git a/vendor/sabre/xml/lib/Serializer/functions.php b/vendor/sabre/xml/lib/Serializer/functions.php
index 3694d9791..8d0330558 100644
--- a/vendor/sabre/xml/lib/Serializer/functions.php
+++ b/vendor/sabre/xml/lib/Serializer/functions.php
@@ -148,7 +148,7 @@ function repeatingElements(Writer $writer, array $items, string $childElementNam
*
* You can even mix the two array syntaxes.
*
- * @param string|int|float|bool|array|object
+ * @param string|int|float|bool|array|object $value
*/
function standardSerializer(Writer $writer, $value)
{
@@ -164,8 +164,6 @@ function standardSerializer(Writer $writer, $value)
} elseif (is_callable($value)) {
// A callback
$value($writer);
- } elseif (is_null($value)) {
- // nothing!
} elseif (is_array($value) && array_key_exists('name', $value)) {
// if the array had a 'name' element, we assume that this array
// describes a 'name' and optionally 'attributes' and 'value'.
@@ -204,7 +202,7 @@ function standardSerializer(Writer $writer, $value)
}
} elseif (is_object($value)) {
throw new InvalidArgumentException('The writer cannot serialize objects of class: '.get_class($value));
- } else {
+ } elseif (!is_null($value)) {
throw new InvalidArgumentException('The writer cannot serialize values of type: '.gettype($value));
}
}
diff --git a/vendor/sabre/xml/lib/Service.php b/vendor/sabre/xml/lib/Service.php
index 882b2dc2c..9a2c47794 100644
--- a/vendor/sabre/xml/lib/Service.php
+++ b/vendor/sabre/xml/lib/Service.php
@@ -61,6 +61,13 @@ class Service
public $classMap = [];
/**
+ * A bitmask of the LIBXML_* constants.
+ *
+ * @var int
+ */
+ public $options = 0;
+
+ /**
* Returns a fresh XML Reader.
*/
public function getReader(): Reader
@@ -107,7 +114,7 @@ class Service
if (is_resource($input)) {
// Unfortunately the XMLReader doesn't support streams. When it
// does, we can optimize this.
- $input = stream_get_contents($input);
+ $input = (string) stream_get_contents($input);
// If input is an empty string, then its safe to throw exception
if ('' === $input) {
@@ -116,7 +123,7 @@ class Service
}
$r = $this->getReader();
$r->contextUri = $contextUri;
- $r->xml($input);
+ $r->XML($input, null, $this->options);
$result = $r->parse();
$rootElementName = $result['name'];
@@ -140,7 +147,6 @@ class Service
*
* @param string|string[] $rootElementName
* @param string|resource $input
- * @param string|null $contextUri
*
* @throws ParseException
*
@@ -151,7 +157,7 @@ class Service
if (is_resource($input)) {
// Unfortunately the XMLReader doesn't support streams. When it
// does, we can optimize this.
- $input = stream_get_contents($input);
+ $input = (string) stream_get_contents($input);
// If input is empty string, then its safe to throw exception
if ('' === $input) {
@@ -160,7 +166,7 @@ class Service
}
$r = $this->getReader();
$r->contextUri = $contextUri;
- $r->xml($input);
+ $r->XML($input, null, $this->options);
$rootElementName = (array) $rootElementName;
@@ -172,7 +178,7 @@ class Service
$result = $r->parse();
if (!in_array($result['name'], $rootElementName, true)) {
- throw new ParseException('Expected '.implode(' or ', (array) $rootElementName).' but received '.$result['name'].' as the root element');
+ throw new ParseException('Expected '.implode(' or ', $rootElementName).' but received '.$result['name'].' as the root element');
}
return $result['value'];
@@ -192,7 +198,7 @@ class Service
* This allows an implementor to easily create URI's relative to the root
* of the domain.
*
- * @param string|array|XmlSerializable $value
+ * @param string|array|object|XmlSerializable $value
*
* @return string
*/
diff --git a/vendor/sabre/xml/lib/Version.php b/vendor/sabre/xml/lib/Version.php
index 65706ec42..cf2810c2a 100644
--- a/vendor/sabre/xml/lib/Version.php
+++ b/vendor/sabre/xml/lib/Version.php
@@ -16,5 +16,5 @@ class Version
/**
* Full version number.
*/
- const VERSION = '2.1.1';
+ const VERSION = '2.2.0';
}
diff --git a/vendor/sabre/xml/lib/Writer.php b/vendor/sabre/xml/lib/Writer.php
index f5957bbce..e3238a7ed 100644
--- a/vendor/sabre/xml/lib/Writer.php
+++ b/vendor/sabre/xml/lib/Writer.php
@@ -182,8 +182,6 @@ class Writer extends XMLWriter
* XMLWriter::startElement doesn't either.
*
* @param array|string|object|null $content
- *
- * @return bool
*/
public function writeElement($name, $content = null): bool
{