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, 27 insertions, 73 deletions
diff --git a/vendor/sabre/xml/lib/ContextStackTrait.php b/vendor/sabre/xml/lib/ContextStackTrait.php
index 757088847..bc770ffad 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|null
+ * @var string
*/
public $contextUri;
diff --git a/vendor/sabre/xml/lib/Deserializer/functions.php b/vendor/sabre/xml/lib/Deserializer/functions.php
index c4f240970..0eff4b7e0 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[] = (string) $reader->getClark();
+ $values[] = $reader->getClark();
}
} while ($reader->depth >= $currentDepth && $reader->next());
@@ -316,44 +316,3 @@ 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 2644fbcd7..898a26457 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(
- (string) $reader->contextUri,
+ $reader->contextUri,
$reader->readText()
)
);
diff --git a/vendor/sabre/xml/lib/Element/XmlFragment.php b/vendor/sabre/xml/lib/Element/XmlFragment.php
index 12109e5c9..413e0f106 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(
- (string) $reader->getClark()
+ $reader->getClark()
);
$empty = $reader->isEmptyElement;
while ($reader->moveToNextAttribute()) {
@@ -97,7 +97,7 @@ XML;
// Skip namespace declarations
break;
default:
- $writer->writeAttribute((string) $reader->getClark(), $reader->value);
+ $writer->writeAttribute($reader->getClark(), $reader->value);
break;
}
}
diff --git a/vendor/sabre/xml/lib/LibXMLException.php b/vendor/sabre/xml/lib/LibXMLException.php
index ae136f57b..4701c304a 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,7 +30,8 @@ class LibXMLException extends ParseException
*
* You should pass a list of LibXMLError objects in its constructor.
*
- * @param LibXMLError[] $errors
+ * @param []LibXMLError $errors
+ * @param int $code
* @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 5980b5fc4..e237b8732 100644
--- a/vendor/sabre/xml/lib/ParseException.php
+++ b/vendor/sabre/xml/lib/ParseException.php
@@ -4,8 +4,7 @@ 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 a28cf8c3b..37e0c86dd 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|null
+ * @return array|string
*/
public function parseInnerTree(array $elementMap = null)
{
@@ -147,9 +147,7 @@ class Reader extends XMLReader
throw new ParseException('This should never happen (famous last words)');
}
- $keepOnParsing = true;
-
- while ($keepOnParsing) {
+ while (true) {
if (!$this->isValid()) {
$errors = libxml_get_errors();
@@ -171,8 +169,7 @@ class Reader extends XMLReader
case self::END_ELEMENT:
// Ensuring we are moving the cursor after the end element.
$this->read();
- $keepOnParsing = false;
- break;
+ break 2;
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:
@@ -226,7 +223,7 @@ class Reader extends XMLReader
}
$value = call_user_func(
- $this->getDeserializerForElementName((string) $name),
+ $this->getDeserializerForElementName($name),
$this
);
diff --git a/vendor/sabre/xml/lib/Serializer/functions.php b/vendor/sabre/xml/lib/Serializer/functions.php
index 8d0330558..3694d9791 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 $value
+ * @param string|int|float|bool|array|object
*/
function standardSerializer(Writer $writer, $value)
{
@@ -164,6 +164,8 @@ 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'.
@@ -202,7 +204,7 @@ function standardSerializer(Writer $writer, $value)
}
} elseif (is_object($value)) {
throw new InvalidArgumentException('The writer cannot serialize objects of class: '.get_class($value));
- } elseif (!is_null($value)) {
+ } else {
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 9a2c47794..882b2dc2c 100644
--- a/vendor/sabre/xml/lib/Service.php
+++ b/vendor/sabre/xml/lib/Service.php
@@ -61,13 +61,6 @@ class Service
public $classMap = [];
/**
- * A bitmask of the LIBXML_* constants.
- *
- * @var int
- */
- public $options = 0;
-
- /**
* Returns a fresh XML Reader.
*/
public function getReader(): Reader
@@ -114,7 +107,7 @@ class Service
if (is_resource($input)) {
// Unfortunately the XMLReader doesn't support streams. When it
// does, we can optimize this.
- $input = (string) stream_get_contents($input);
+ $input = stream_get_contents($input);
// If input is an empty string, then its safe to throw exception
if ('' === $input) {
@@ -123,7 +116,7 @@ class Service
}
$r = $this->getReader();
$r->contextUri = $contextUri;
- $r->XML($input, null, $this->options);
+ $r->xml($input);
$result = $r->parse();
$rootElementName = $result['name'];
@@ -147,6 +140,7 @@ class Service
*
* @param string|string[] $rootElementName
* @param string|resource $input
+ * @param string|null $contextUri
*
* @throws ParseException
*
@@ -157,7 +151,7 @@ class Service
if (is_resource($input)) {
// Unfortunately the XMLReader doesn't support streams. When it
// does, we can optimize this.
- $input = (string) stream_get_contents($input);
+ $input = stream_get_contents($input);
// If input is empty string, then its safe to throw exception
if ('' === $input) {
@@ -166,7 +160,7 @@ class Service
}
$r = $this->getReader();
$r->contextUri = $contextUri;
- $r->XML($input, null, $this->options);
+ $r->xml($input);
$rootElementName = (array) $rootElementName;
@@ -178,7 +172,7 @@ class Service
$result = $r->parse();
if (!in_array($result['name'], $rootElementName, true)) {
- throw new ParseException('Expected '.implode(' or ', $rootElementName).' but received '.$result['name'].' as the root element');
+ throw new ParseException('Expected '.implode(' or ', (array) $rootElementName).' but received '.$result['name'].' as the root element');
}
return $result['value'];
@@ -198,7 +192,7 @@ class Service
* This allows an implementor to easily create URI's relative to the root
* of the domain.
*
- * @param string|array|object|XmlSerializable $value
+ * @param string|array|XmlSerializable $value
*
* @return string
*/
diff --git a/vendor/sabre/xml/lib/Version.php b/vendor/sabre/xml/lib/Version.php
index cf2810c2a..65706ec42 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.2.0';
+ const VERSION = '2.1.1';
}
diff --git a/vendor/sabre/xml/lib/Writer.php b/vendor/sabre/xml/lib/Writer.php
index e3238a7ed..f5957bbce 100644
--- a/vendor/sabre/xml/lib/Writer.php
+++ b/vendor/sabre/xml/lib/Writer.php
@@ -182,6 +182,8 @@ class Writer extends XMLWriter
* XMLWriter::startElement doesn't either.
*
* @param array|string|object|null $content
+ *
+ * @return bool
*/
public function writeElement($name, $content = null): bool
{