aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/xml
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-10 12:49:51 +0000
committerMario <mario@mariovavti.com>2019-11-10 14:10:03 +0100
commit580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch)
tree82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/xml
parentd22766f458a8539a40a57f3946459a9be1f21cd6 (diff)
downloadvolse-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/xml')
-rw-r--r--vendor/sabre/xml/.gitignore1
-rw-r--r--vendor/sabre/xml/.php_cs.dist12
-rw-r--r--vendor/sabre/xml/.travis.yml23
-rw-r--r--vendor/sabre/xml/CHANGELOG.md29
-rw-r--r--vendor/sabre/xml/README.md2
-rw-r--r--vendor/sabre/xml/composer.json5
-rw-r--r--vendor/sabre/xml/lib/ContextStackTrait.php25
-rw-r--r--vendor/sabre/xml/lib/Deserializer/functions.php117
-rw-r--r--vendor/sabre/xml/lib/Element.php6
-rw-r--r--vendor/sabre/xml/lib/Element/Base.php31
-rw-r--r--vendor/sabre/xml/lib/Element/Cdata.php17
-rw-r--r--vendor/sabre/xml/lib/Element/Elements.php34
-rw-r--r--vendor/sabre/xml/lib/Element/KeyValue.php32
-rw-r--r--vendor/sabre/xml/lib/Element/Uri.php25
-rw-r--r--vendor/sabre/xml/lib/Element/XmlFragment.php61
-rw-r--r--vendor/sabre/xml/lib/LibXMLException.php35
-rw-r--r--vendor/sabre/xml/lib/ParseException.php9
-rw-r--r--vendor/sabre/xml/lib/Reader.php136
-rw-r--r--vendor/sabre/xml/lib/Serializer/functions.php75
-rw-r--r--vendor/sabre/xml/lib/Service.php110
-rw-r--r--vendor/sabre/xml/lib/Version.php11
-rw-r--r--vendor/sabre/xml/lib/Writer.php117
-rw-r--r--vendor/sabre/xml/lib/XmlDeserializable.php10
-rw-r--r--vendor/sabre/xml/lib/XmlSerializable.php12
24 files changed, 452 insertions, 483 deletions
diff --git a/vendor/sabre/xml/.gitignore b/vendor/sabre/xml/.gitignore
index accb586c7..51fc188bf 100644
--- a/vendor/sabre/xml/.gitignore
+++ b/vendor/sabre/xml/.gitignore
@@ -2,6 +2,7 @@ vendor
composer.lock
tests/cov
.*.swp
+.php_cs.cache
# Composer binaries
bin/phpunit
diff --git a/vendor/sabre/xml/.php_cs.dist b/vendor/sabre/xml/.php_cs.dist
new file mode 100644
index 000000000..8d61ee259
--- /dev/null
+++ b/vendor/sabre/xml/.php_cs.dist
@@ -0,0 +1,12 @@
+<?php
+
+$config = PhpCsFixer\Config::create();
+$config->getFinder()
+ ->exclude('vendor')
+ ->in(__DIR__);
+$config->setRules([
+ '@PSR1' => true,
+ '@Symfony' =>true
+]);
+
+return $config; \ No newline at end of file
diff --git a/vendor/sabre/xml/.travis.yml b/vendor/sabre/xml/.travis.yml
index 96396564e..49a0c9a22 100644
--- a/vendor/sabre/xml/.travis.yml
+++ b/vendor/sabre/xml/.travis.yml
@@ -1,26 +1,31 @@
language: php
+sudo: required
+dist: xenial
php:
- - 5.5
- - 5.6
- 7.0
- 7.1
+ - 7.2
+ - 7.3snapshot
+
+addons:
+ apt:
+ packages:
+ # required for php7.3
+ - libzip4
matrix:
fast_finish: true
-sudo: false
-
cache:
directories:
- $HOME/.composer/cache
-before_install:
- - phpenv config-rm xdebug.ini; true
-
install:
- composer install
script:
- - ./bin/phpunit --configuration tests/phpunit.xml.dist
- - ./bin/sabre-cs-fixer fix . --dry-run --diff
+ - ./bin/phpunit --configuration tests/phpunit.xml.dist --coverage-clover=coverage.xml
+
+after_success:
+- bash <(curl -s https://codecov.io/bash)
diff --git a/vendor/sabre/xml/CHANGELOG.md b/vendor/sabre/xml/CHANGELOG.md
index faeba20e5..1ad830124 100644
--- a/vendor/sabre/xml/CHANGELOG.md
+++ b/vendor/sabre/xml/CHANGELOG.md
@@ -1,11 +1,38 @@
ChangeLog
=========
-1.5.1 (2019-01-09)
+2.1.3 (2019-08-14)
+------------------
+
+* #166: Throw exception when empty inputs found
+
+2.1.2 (2019-01-09)
------------------
* #161: Prevent infinite loop on empty xml elements
+2.1.1 (2018-10-09)
+------------------
+
+* #149: Properly detect xml parse errors in `parseCurrentElement()` edge-cases
+
+
+2.1.0 (2018-02-08)
+------------------
+
+* #112: Added a `mixedContent` deserializer function, which might be useful
+ if you're parsing HTML-like documents with elements that contain both text
+ and other elements as siblings. (@staabm).
+
+
+2.0.0 (2016-11-15)
+------------------
+
+* Now requires PHP 7.
+* Uses typehints everywhere.
+* Fixed some minor strict typing-related issues.
+* Removed workaround for PHP bug [64230](https://bugs.php.net/bug.php?id=64230).
+
1.5.0 (2016-10-09)
------------------
diff --git a/vendor/sabre/xml/README.md b/vendor/sabre/xml/README.md
index e6fc4db5f..55af24fc6 100644
--- a/vendor/sabre/xml/README.md
+++ b/vendor/sabre/xml/README.md
@@ -1,7 +1,7 @@
sabre/xml
=========
-[![Build Status](https://secure.travis-ci.org/fruux/sabre-xml.svg?branch=master)](http://travis-ci.org/fruux/sabre-xml)
+[![Build Status](https://secure.travis-ci.org/sabre-io/xml.svg?branch=master)](http://travis-ci.org/sabre-io/xml)
The sabre/xml library is a specialized XML reader and writer.
diff --git a/vendor/sabre/xml/composer.json b/vendor/sabre/xml/composer.json
index 1b5760393..c782dbc5e 100644
--- a/vendor/sabre/xml/composer.json
+++ b/vendor/sabre/xml/composer.json
@@ -5,7 +5,7 @@
"homepage" : "https://sabre.io/xml/",
"license" : "BSD-3-Clause",
"require" : {
- "php" : ">=5.5.5",
+ "php" : ">=7.0",
"ext-xmlwriter" : "*",
"ext-xmlreader" : "*",
"ext-dom" : "*",
@@ -44,8 +44,7 @@
}
},
"require-dev": {
- "sabre/cs": "~1.0.0",
- "phpunit/phpunit" : "~4.8|~5.7"
+ "phpunit/phpunit" : "^6"
},
"config" : {
"bin-dir" : "bin/"
diff --git a/vendor/sabre/xml/lib/ContextStackTrait.php b/vendor/sabre/xml/lib/ContextStackTrait.php
index ee3a3baca..bc770ffad 100644
--- a/vendor/sabre/xml/lib/ContextStackTrait.php
+++ b/vendor/sabre/xml/lib/ContextStackTrait.php
@@ -1,9 +1,11 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml;
/**
- * Context Stack
+ * Context Stack.
*
* The Context maintains information about a document during either reading or
* writing.
@@ -19,8 +21,8 @@ namespace Sabre\Xml;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-trait ContextStackTrait {
-
+trait ContextStackTrait
+{
/**
* This is the element map. It contains a list of XML elements (in clark
* notation) as keys and PHP class names as values.
@@ -90,34 +92,27 @@ trait ContextStackTrait {
* This allows you to safely modify the elementMap, contextUri or
* namespaceMap. After you're done, you can restore the old data again
* with popContext.
- *
- * @return null
*/
- function pushContext() {
-
+ public function pushContext()
+ {
$this->contextStack[] = [
$this->elementMap,
$this->contextUri,
$this->namespaceMap,
- $this->classMap
+ $this->classMap,
];
-
}
/**
* Restore the previous "context".
- *
- * @return null
*/
- function popContext() {
-
+ public function popContext()
+ {
list(
$this->elementMap,
$this->contextUri,
$this->namespaceMap,
$this->classMap
) = array_pop($this->contextStack);
-
}
-
}
diff --git a/vendor/sabre/xml/lib/Deserializer/functions.php b/vendor/sabre/xml/lib/Deserializer/functions.php
index 07038d99a..0eff4b7e0 100644
--- a/vendor/sabre/xml/lib/Deserializer/functions.php
+++ b/vendor/sabre/xml/lib/Deserializer/functions.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml\Deserializer;
use Sabre\Xml\Reader;
@@ -52,17 +54,13 @@ use Sabre\Xml\Reader;
*
* Attributes will be removed from the top-level elements. If elements with
* the same name appear twice in the list, only the last one will be kept.
- *
- *
- * @param Reader $reader
- * @param string $namespace
- * @return array
*/
-function keyValue(Reader $reader, $namespace = null) {
-
+function keyValue(Reader $reader, string $namespace = null): array
+{
// If there's no children, we don't do anything.
if ($reader->isEmptyElement) {
$reader->next();
+
return [];
}
@@ -81,9 +79,8 @@ function keyValue(Reader $reader, $namespace = null) {
$values = [];
do {
-
- if ($reader->nodeType === Reader::ELEMENT) {
- if ($namespace !== null && $reader->namespaceURI === $namespace) {
+ if (Reader::ELEMENT === $reader->nodeType) {
+ if (null !== $namespace && $reader->namespaceURI === $namespace) {
$values[$reader->localName] = $reader->parseCurrentElement()['value'];
} else {
$clark = $reader->getClark();
@@ -94,12 +91,11 @@ function keyValue(Reader $reader, $namespace = null) {
break;
}
}
- } while ($reader->nodeType !== Reader::END_ELEMENT);
+ } while (Reader::END_ELEMENT !== $reader->nodeType);
$reader->read();
return $values;
-
}
/**
@@ -146,15 +142,14 @@ function keyValue(Reader $reader, $namespace = null) {
* "elem5",
* ];
*
- * @param Reader $reader
- * @param string $namespace
* @return string[]
*/
-function enum(Reader $reader, $namespace = null) {
-
+function enum(Reader $reader, string $namespace = null): array
+{
// If there's no children, we don't do anything.
if ($reader->isEmptyElement) {
$reader->next();
+
return [];
}
if (!$reader->read()) {
@@ -172,8 +167,7 @@ function enum(Reader $reader, $namespace = null) {
$values = [];
do {
-
- if ($reader->nodeType !== Reader::ELEMENT) {
+ if (Reader::ELEMENT !== $reader->nodeType) {
continue;
}
if (!is_null($namespace) && $namespace === $reader->namespaceURI) {
@@ -181,12 +175,11 @@ function enum(Reader $reader, $namespace = null) {
} else {
$values[] = $reader->getClark();
}
-
} while ($reader->depth >= $currentDepth && $reader->next());
$reader->next();
- return $values;
+ return $values;
}
/**
@@ -196,16 +189,14 @@ function enum(Reader $reader, $namespace = null) {
* This is primarily used by the mapValueObject function from the Service
* class, but it can also easily be used for more specific situations.
*
- * @param Reader $reader
- * @param string $className
- * @param string $namespace
* @return object
*/
-function valueObject(Reader $reader, $className, $namespace) {
-
+function valueObject(Reader $reader, string $className, string $namespace)
+{
$valueObject = new $className();
if ($reader->isEmptyElement) {
$reader->next();
+
return $valueObject;
}
@@ -213,9 +204,7 @@ function valueObject(Reader $reader, $className, $namespace) {
$reader->read();
do {
-
- if ($reader->nodeType === Reader::ELEMENT && $reader->namespaceURI == $namespace) {
-
+ if (Reader::ELEMENT === $reader->nodeType && $reader->namespaceURI == $namespace) {
if (property_exists($valueObject, $reader->localName)) {
if (is_array($defaultProperties[$reader->localName])) {
$valueObject->{$reader->localName}[] = $reader->parseCurrentElement()['value'];
@@ -231,16 +220,16 @@ function valueObject(Reader $reader, $className, $namespace) {
break;
}
}
- } while ($reader->nodeType !== Reader::END_ELEMENT);
+ } while (Reader::END_ELEMENT !== $reader->nodeType);
$reader->read();
- return $valueObject;
+ return $valueObject;
}
/**
* This deserializer helps you deserialize xml structures that look like
- * this:
+ * this:.
*
* <collection>
* <item>...</item>
@@ -248,7 +237,7 @@ function valueObject(Reader $reader, $className, $namespace) {
* <item>...</item>
* </collection>
*
- * Many XML documents use patterns like that, and this deserializer
+ * Many XML documents use patterns like that, and this deserializer
* allow you to get all the 'items' as an array.
*
* In that previous example, you would register the deserializer as such:
@@ -259,25 +248,71 @@ function valueObject(Reader $reader, $className, $namespace) {
*
* The repeatingElements deserializer simply returns everything as an array.
*
- * @param Reader $reader
- * @param string $childElementName Element name in clark-notation
- * @return array
+ * $childElementName must either be a a clark-notation element name, or if no
+ * namespace is used, the bare element name.
*/
-function repeatingElements(Reader $reader, $childElementName) {
-
- if ($childElementName[0] !== '{') {
- $childElementName = '{}' . $childElementName;
+function repeatingElements(Reader $reader, string $childElementName): array
+{
+ if ('{' !== $childElementName[0]) {
+ $childElementName = '{}'.$childElementName;
}
$result = [];
foreach ($reader->parseGetElements() as $element) {
-
if ($element['name'] === $childElementName) {
$result[] = $element['value'];
}
-
}
return $result;
+}
+
+/**
+ * This deserializer helps you to deserialize structures which contain mixed content like this:.
+ *
+ * <p>some text <extref>and a inline tag</extref>and even more text</p>
+ *
+ * The above example will return
+ *
+ * [
+ * 'some text',
+ * [
+ * 'name' => '{}extref',
+ * 'value' => 'and a inline tag',
+ * 'attributes' => []
+ * ],
+ * 'and even more text'
+ * ]
+ *
+ * In strict XML documents you wont find this kind of markup but in html this is a quite common pattern.
+ */
+function mixedContent(Reader $reader): array
+{
+ // If there's no children, we don't do anything.
+ if ($reader->isEmptyElement) {
+ $reader->next();
+
+ return [];
+ }
+
+ $previousDepth = $reader->depth;
+
+ $content = [];
+ $reader->read();
+ while (true) {
+ if (Reader::ELEMENT == $reader->nodeType) {
+ $content[] = $reader->parseCurrentElement();
+ } elseif ($reader->depth >= $previousDepth && in_array($reader->nodeType, [Reader::TEXT, Reader::CDATA, Reader::WHITESPACE])) {
+ $content[] = $reader->value;
+ $reader->read();
+ } elseif (Reader::END_ELEMENT == $reader->nodeType) {
+ // Ensuring we are moving the cursor after the end element.
+ $reader->read();
+ break;
+ } else {
+ $reader->read();
+ }
+ }
+ return $content;
}
diff --git a/vendor/sabre/xml/lib/Element.php b/vendor/sabre/xml/lib/Element.php
index dd89c5888..559eb54ea 100644
--- a/vendor/sabre/xml/lib/Element.php
+++ b/vendor/sabre/xml/lib/Element.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml;
/**
@@ -15,6 +17,6 @@ namespace Sabre\Xml;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface Element extends XmlSerializable, XmlDeserializable {
-
+interface Element extends XmlSerializable, XmlDeserializable
+{
}
diff --git a/vendor/sabre/xml/lib/Element/Base.php b/vendor/sabre/xml/lib/Element/Base.php
index f59ba49a0..a1ce7ea5a 100644
--- a/vendor/sabre/xml/lib/Element/Base.php
+++ b/vendor/sabre/xml/lib/Element/Base.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml\Element;
use Sabre\Xml;
@@ -15,8 +17,8 @@ use Sabre\Xml;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Base implements Xml\Element {
-
+class Base implements Xml\Element
+{
/**
* PHP value to serialize.
*
@@ -25,14 +27,11 @@ class Base implements Xml\Element {
protected $value;
/**
- * Constructor
- *
- * @param mixed $value
+ * Constructor.
*/
- function __construct($value = null) {
-
+ public function __construct($value = null)
+ {
$this->value = $value;
-
}
/**
@@ -50,14 +49,10 @@ class Base implements Xml\Element {
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
- *
- * @param Writer $writer
- * @return void
*/
- function xmlSerialize(Xml\Writer $writer) {
-
+ public function xmlSerialize(Xml\Writer $writer)
+ {
$writer->write($this->value);
-
}
/**
@@ -78,14 +73,12 @@ class Base implements Xml\Element {
* $reader->parseInnerTree() will parse the entire sub-tree, and advance to
* the next element.
*
- * @param Xml\Reader $reader
* @return mixed
*/
- static function xmlDeserialize(Xml\Reader $reader) {
-
+ public static function xmlDeserialize(Xml\Reader $reader)
+ {
$subTree = $reader->parseInnerTree();
- return $subTree;
+ return $subTree;
}
-
}
diff --git a/vendor/sabre/xml/lib/Element/Cdata.php b/vendor/sabre/xml/lib/Element/Cdata.php
index 5f42c4c6e..61d3213ff 100644
--- a/vendor/sabre/xml/lib/Element/Cdata.php
+++ b/vendor/sabre/xml/lib/Element/Cdata.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml\Element;
use Sabre\Xml;
@@ -27,11 +29,9 @@ class Cdata implements Xml\XmlSerializable
protected $value;
/**
- * Constructor
- *
- * @param string $value
+ * Constructor.
*/
- function __construct($value)
+ public function __construct(string $value)
{
$this->value = $value;
}
@@ -51,14 +51,9 @@ class Cdata implements Xml\XmlSerializable
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
- *
- * @param Writer $writer
- * @return void
*/
- function xmlSerialize(Xml\Writer $writer) {
-
+ public function xmlSerialize(Xml\Writer $writer)
+ {
$writer->writeCData($this->value);
-
}
-
}
diff --git a/vendor/sabre/xml/lib/Element/Elements.php b/vendor/sabre/xml/lib/Element/Elements.php
index 9eefd1bf8..e51179833 100644
--- a/vendor/sabre/xml/lib/Element/Elements.php
+++ b/vendor/sabre/xml/lib/Element/Elements.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml\Element;
use Sabre\Xml;
@@ -8,7 +10,7 @@ use Sabre\Xml\Serializer;
/**
* 'Elements' is a simple list of elements, without values or attributes.
- * For example, Elements will parse:
+ * For example, Elements will parse:.
*
* <?xml version="1.0"?>
* <s:root xmlns:s="http://sabredav.org/ns">
@@ -33,24 +35,21 @@ use Sabre\Xml\Serializer;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Elements implements Xml\Element {
-
+class Elements implements Xml\Element
+{
/**
- * Value to serialize
+ * Value to serialize.
*
* @var array
*/
protected $value;
/**
- * Constructor
- *
- * @param array $value
+ * Constructor.
*/
- function __construct(array $value = []) {
-
+ public function __construct(array $value = [])
+ {
$this->value = $value;
-
}
/**
@@ -68,14 +67,10 @@ class Elements implements Xml\Element {
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
- *
- * @param Writer $writer
- * @return void
*/
- function xmlSerialize(Xml\Writer $writer) {
-
+ public function xmlSerialize(Xml\Writer $writer)
+ {
Serializer\enum($writer, $this->value);
-
}
/**
@@ -96,13 +91,10 @@ class Elements implements Xml\Element {
* $reader->parseSubTree() will parse the entire sub-tree, and advance to
* the next element.
*
- * @param Xml\Reader $reader
* @return mixed
*/
- static function xmlDeserialize(Xml\Reader $reader) {
-
+ public static function xmlDeserialize(Xml\Reader $reader)
+ {
return Deserializer\enum($reader);
-
}
-
}
diff --git a/vendor/sabre/xml/lib/Element/KeyValue.php b/vendor/sabre/xml/lib/Element/KeyValue.php
index 7ce53bf4c..dacee000a 100644
--- a/vendor/sabre/xml/lib/Element/KeyValue.php
+++ b/vendor/sabre/xml/lib/Element/KeyValue.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml\Element;
use Sabre\Xml;
@@ -33,24 +35,21 @@ use Sabre\Xml\Deserializer;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class KeyValue implements Xml\Element {
-
+class KeyValue implements Xml\Element
+{
/**
- * Value to serialize
+ * Value to serialize.
*
* @var array
*/
protected $value;
/**
- * Constructor
- *
- * @param array $value
+ * Constructor.
*/
- function __construct(array $value = []) {
-
+ public function __construct(array $value = [])
+ {
$this->value = $value;
-
}
/**
@@ -68,14 +67,10 @@ class KeyValue implements Xml\Element {
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
- *
- * @param Writer $writer
- * @return void
*/
- function xmlSerialize(Xml\Writer $writer) {
-
+ public function xmlSerialize(Xml\Writer $writer)
+ {
$writer->write($this->value);
-
}
/**
@@ -96,13 +91,10 @@ class KeyValue implements Xml\Element {
* $reader->parseInnerTree() will parse the entire sub-tree, and advance to
* the next element.
*
- * @param Xml\Reader $reader
* @return mixed
*/
- static function xmlDeserialize(Xml\Reader $reader) {
-
+ public static function xmlDeserialize(Xml\Reader $reader)
+ {
return Deserializer\keyValue($reader);
-
}
-
}
diff --git a/vendor/sabre/xml/lib/Element/Uri.php b/vendor/sabre/xml/lib/Element/Uri.php
index 8f45c0027..898a26457 100644
--- a/vendor/sabre/xml/lib/Element/Uri.php
+++ b/vendor/sabre/xml/lib/Element/Uri.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml\Element;
use Sabre\Xml;
@@ -20,8 +22,8 @@ use Sabre\Xml;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Uri implements Xml\Element {
-
+class Uri implements Xml\Element
+{
/**
* Uri element value.
*
@@ -30,11 +32,11 @@ class Uri implements Xml\Element {
protected $value;
/**
- * Constructor
+ * Constructor.
*
* @param string $value
*/
- function __construct($value)
+ public function __construct($value)
{
$this->value = $value;
}
@@ -54,19 +56,15 @@ class Uri implements Xml\Element {
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
- *
- * @param Writer $writer
- * @return void
*/
- function xmlSerialize(Xml\Writer $writer) {
-
+ public function xmlSerialize(Xml\Writer $writer)
+ {
$writer->text(
\Sabre\Uri\resolve(
$writer->contextUri,
$this->value
)
);
-
}
/**
@@ -87,18 +85,15 @@ class Uri implements Xml\Element {
* $reader->parseSubTree() will parse the entire sub-tree, and advance to
* the next element.
*
- * @param Xml\Reader $reader
* @return mixed
*/
- static function xmlDeserialize(Xml\Reader $reader) {
-
+ public static function xmlDeserialize(Xml\Reader $reader)
+ {
return new self(
\Sabre\Uri\resolve(
$reader->contextUri,
$reader->readText()
)
);
-
}
-
}
diff --git a/vendor/sabre/xml/lib/Element/XmlFragment.php b/vendor/sabre/xml/lib/Element/XmlFragment.php
index 642241ca4..413e0f106 100644
--- a/vendor/sabre/xml/lib/Element/XmlFragment.php
+++ b/vendor/sabre/xml/lib/Element/XmlFragment.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml\Element;
use Sabre\Xml\Element;
@@ -20,20 +22,29 @@ use Sabre\Xml\Writer;
* 3. It will have all the relevant xmlns attributes.
* 4. It may not have a root element.
*/
-class XmlFragment implements Element {
-
+class XmlFragment implements Element
+{
+ /**
+ * The inner XML value.
+ *
+ * @var string
+ */
protected $xml;
- function __construct($xml) {
-
+ /**
+ * Constructor.
+ */
+ public function __construct(string $xml)
+ {
$this->xml = $xml;
-
}
- function getXml() {
-
+ /**
+ * Returns the inner XML document.
+ */
+ public function getXml(): string
+ {
return $this->xml;
-
}
/**
@@ -51,12 +62,9 @@ class XmlFragment implements Element {
* This allows serializers to be re-used for different element names.
*
* 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)
+ {
$reader = new Reader();
// Wrapping the xml in a container, so root-less values can still be
@@ -69,28 +77,26 @@ XML;
$reader->xml($xml);
while ($reader->read()) {
-
if ($reader->depth < 1) {
// Skipping the root node.
continue;
}
switch ($reader->nodeType) {
-
- case Reader::ELEMENT :
+ case Reader::ELEMENT:
$writer->startElement(
$reader->getClark()
);
$empty = $reader->isEmptyElement;
while ($reader->moveToNextAttribute()) {
switch ($reader->namespaceURI) {
- case '' :
+ case '':
$writer->writeAttribute($reader->localName, $reader->value);
break;
- case 'http://www.w3.org/2000/xmlns/' :
+ case 'http://www.w3.org/2000/xmlns/':
// Skip namespace declarations
break;
- default :
+ default:
$writer->writeAttribute($reader->getClark(), $reader->value);
break;
}
@@ -99,20 +105,17 @@ XML;
$writer->endElement();
}
break;
- case Reader::CDATA :
- case Reader::TEXT :
+ case Reader::CDATA:
+ case Reader::TEXT:
$writer->text(
$reader->value
);
break;
- case Reader::END_ELEMENT :
+ case Reader::END_ELEMENT:
$writer->endElement();
break;
-
}
-
}
-
}
/**
@@ -133,15 +136,13 @@ XML;
* $reader->parseInnerTree() will parse the entire sub-tree, and advance to
* the next element.
*
- * @param Reader $reader
* @return mixed
*/
- static function xmlDeserialize(Reader $reader) {
-
+ public static function xmlDeserialize(Reader $reader)
+ {
$result = new self($reader->readInnerXml());
$reader->next();
- return $result;
+ return $result;
}
-
}
diff --git a/vendor/sabre/xml/lib/LibXMLException.php b/vendor/sabre/xml/lib/LibXMLException.php
index f0190eb51..4701c304a 100644
--- a/vendor/sabre/xml/lib/LibXMLException.php
+++ b/vendor/sabre/xml/lib/LibXMLException.php
@@ -1,9 +1,11 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml;
-use
- LibXMLError;
+use LibXMLError;
+use Throwable;
/**
* This exception is thrown when the Readers runs into a parsing error.
@@ -14,12 +16,12 @@ use
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class LibXMLException extends ParseException {
-
+class LibXMLException extends ParseException
+{
/**
* The error list.
*
- * @var LibXMLError[]
+ * @var []LibXMLError
*/
protected $errors;
@@ -28,26 +30,21 @@ class LibXMLException extends ParseException {
*
* You should pass a list of LibXMLError objects in its constructor.
*
- * @param LibXMLError[] $errors
- * @param int $code
- * @param Exception $previousException
+ * @param []LibXMLError $errors
+ * @param int $code
+ * @param Throwable $previousException
*/
- function __construct(array $errors, $code = null, Exception $previousException = null) {
-
+ public function __construct(array $errors, int $code = 0, Throwable $previousException = null)
+ {
$this->errors = $errors;
- parent::__construct($errors[0]->message . ' on line ' . $errors[0]->line . ', column ' . $errors[0]->column, $code, $previousException);
-
+ parent::__construct($errors[0]->message.' on line '.$errors[0]->line.', column '.$errors[0]->column, $code, $previousException);
}
/**
- * Returns the LibXML errors
- *
- * @return void
+ * Returns the LibXML errors.
*/
- function getErrors() {
-
+ public function getErrors(): array
+ {
return $this->errors;
-
}
-
}
diff --git a/vendor/sabre/xml/lib/ParseException.php b/vendor/sabre/xml/lib/ParseException.php
index 3a6883b2f..e237b8732 100644
--- a/vendor/sabre/xml/lib/ParseException.php
+++ b/vendor/sabre/xml/lib/ParseException.php
@@ -1,9 +1,10 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml;
-use
- Exception;
+use Exception;
/**
* This is a base exception for any exception related to parsing xml files.
@@ -12,6 +13,6 @@ use
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class ParseException extends Exception {
-
+class ParseException extends Exception
+{
}
diff --git a/vendor/sabre/xml/lib/Reader.php b/vendor/sabre/xml/lib/Reader.php
index 92e5dba96..37e0c86dd 100644
--- a/vendor/sabre/xml/lib/Reader.php
+++ b/vendor/sabre/xml/lib/Reader.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml;
use XMLReader;
@@ -17,8 +19,8 @@ use XMLReader;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Reader extends XMLReader {
-
+class Reader extends XMLReader
+{
use ContextStackTrait;
/**
@@ -31,14 +33,13 @@ class Reader extends XMLReader {
*
* @return string|null
*/
- function getClark() {
-
- if (! $this->localName) {
+ public function getClark()
+ {
+ if (!$this->localName) {
return null;
}
- return '{' . $this->namespaceURI . '}' . $this->localName;
-
+ return '{'.$this->namespaceURI.'}'.$this->localName;
}
/**
@@ -51,31 +52,30 @@ class Reader extends XMLReader {
*
* This function will also disable the standard libxml error handler (which
* usually just results in PHP errors), and throw exceptions instead.
- *
- * @return array
*/
- function parse() {
-
+ public function parse(): array
+ {
$previousEntityState = libxml_disable_entity_loader(true);
$previousSetting = libxml_use_internal_errors(true);
try {
-
- // Really sorry about the silence operator, seems like I have no
- // choice. See:
- //
- // https://bugs.php.net/bug.php?id=64230
- while ($this->nodeType !== self::ELEMENT && @$this->read()) {
- // noop
+ while (self::ELEMENT !== $this->nodeType) {
+ if (!$this->read()) {
+ $errors = libxml_get_errors();
+ libxml_clear_errors();
+ if ($errors) {
+ throw new LibXMLException($errors);
+ }
+ }
}
$result = $this->parseCurrentElement();
+ // last line of defense in case errors did occur above
$errors = libxml_get_errors();
libxml_clear_errors();
if ($errors) {
throw new LibXMLException($errors);
}
-
} finally {
libxml_use_internal_errors($previousSetting);
libxml_disable_entity_loader($previousEntityState);
@@ -84,8 +84,6 @@ class Reader extends XMLReader {
return $result;
}
-
-
/**
* parseGetElements parses everything in the current sub-tree,
* and returns a an array of elements.
@@ -98,18 +96,15 @@ 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.
- *
- * @param array $elementMap
- * @return array
*/
- function parseGetElements(array $elementMap = null) {
-
+ public function parseGetElements(array $elementMap = null): array
+ {
$result = $this->parseInnerTree($elementMap);
if (!is_array($result)) {
return [];
}
- return $result;
+ return $result;
}
/**
@@ -123,17 +118,17 @@ 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.
*
- * @param array $elementMap
* @return array|string
*/
- function parseInnerTree(array $elementMap = null) {
-
+ public function parseInnerTree(array $elementMap = null)
+ {
$text = null;
$elements = [];
- if ($this->nodeType === self::ELEMENT && $this->isEmptyElement) {
+ if (self::ELEMENT === $this->nodeType && $this->isEmptyElement) {
// Easy!
$this->next();
+
return null;
}
@@ -143,12 +138,7 @@ class Reader extends XMLReader {
}
try {
-
- // Really sorry about the silence operator, seems like I have no
- // choice. See:
- //
- // https://bugs.php.net/bug.php?id=64230
- if (!@$this->read()) {
+ if (!$this->read()) {
$errors = libxml_get_errors();
libxml_clear_errors();
if ($errors) {
@@ -158,9 +148,7 @@ class Reader extends XMLReader {
}
while (true) {
-
if (!$this->isValid()) {
-
$errors = libxml_get_errors();
if ($errors) {
@@ -170,46 +158,40 @@ class Reader extends XMLReader {
}
switch ($this->nodeType) {
- case self::ELEMENT :
+ case self::ELEMENT:
$elements[] = $this->parseCurrentElement();
break;
- case self::TEXT :
- case self::CDATA :
+ case self::TEXT:
+ case self::CDATA:
$text .= $this->value;
$this->read();
break;
- case self::END_ELEMENT :
+ case self::END_ELEMENT:
// Ensuring we are moving the cursor after the end element.
$this->read();
break 2;
- case self::NONE :
+ 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 :
+ default:
// Advance to the next element
$this->read();
break;
}
-
}
-
} finally {
-
if (!is_null($elementMap)) {
$this->popContext();
}
-
}
- return ($elements ? $elements : $text);
+ return $elements ? $elements : $text;
}
/**
* Reads all text below the current element, and returns this as a string.
- *
- * @return string
*/
- function readText() {
-
+ public function readText(): string
+ {
$result = '';
$previousDepth = $this->depth;
@@ -218,8 +200,8 @@ class Reader extends XMLReader {
$result .= $this->value;
}
}
- return $result;
+ return $result;
}
/**
@@ -229,11 +211,9 @@ class Reader extends XMLReader {
* * name - A clark-notation XML element name.
* * value - The parsed value.
* * attributes - A key-value list of attributes.
- *
- * @return array
*/
- function parseCurrentElement() {
-
+ public function parseCurrentElement(): array
+ {
$name = $this->getClark();
$attributes = [];
@@ -248,13 +228,12 @@ class Reader extends XMLReader {
);
return [
- 'name' => $name,
- 'value' => $value,
+ 'name' => $name,
+ 'value' => $value,
'attributes' => $attributes,
];
}
-
/**
* Grabs all the attributes from the current element, and returns them as a
* key-value array.
@@ -262,24 +241,20 @@ class Reader extends XMLReader {
* If the attributes are part of the same namespace, they will simply be
* short keys. If they are defined on a different namespace, the attribute
* name will be retured in clark-notation.
- *
- * @return array
*/
- function parseAttributes() {
-
+ public function parseAttributes(): array
+ {
$attributes = [];
while ($this->moveToNextAttribute()) {
if ($this->namespaceURI) {
-
// Ignoring 'xmlns', it doesn't make any sense.
- if ($this->namespaceURI === 'http://www.w3.org/2000/xmlns/') {
+ if ('http://www.w3.org/2000/xmlns/' === $this->namespaceURI) {
continue;
}
$name = $this->getClark();
$attributes[$name] = $this->value;
-
} else {
$attributes[$this->localName] = $this->value;
}
@@ -287,21 +262,16 @@ class Reader extends XMLReader {
$this->moveToElement();
return $attributes;
-
}
/**
* Returns the function that should be used to parse the element identified
* by it's clark-notation name.
- *
- * @param string $name
- * @return callable
*/
- function getDeserializerForElementName($name) {
-
-
+ public function getDeserializerForElementName(string $name): callable
+ {
if (!array_key_exists($name, $this->elementMap)) {
- if (substr($name, 0, 2) == '{}' && array_key_exists(substr($name, 2), $this->elementMap)) {
+ if ('{}' == substr($name, 0, 2) && array_key_exists(substr($name, 2), $this->elementMap)) {
$name = substr($name, 2);
} else {
return ['Sabre\\Xml\\Element\\Base', 'xmlDeserialize'];
@@ -318,13 +288,11 @@ class Reader extends XMLReader {
}
$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 . ' for element: ' . $name);
-
+ throw new \LogicException('Could not use this type as a deserializer: '.$type.' for element: '.$name);
}
-
}
diff --git a/vendor/sabre/xml/lib/Serializer/functions.php b/vendor/sabre/xml/lib/Serializer/functions.php
index 21448017d..3694d9791 100644
--- a/vendor/sabre/xml/lib/Serializer/functions.php
+++ b/vendor/sabre/xml/lib/Serializer/functions.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml\Serializer;
use InvalidArgumentException;
@@ -34,12 +36,10 @@ use Sabre\Xml\XmlSerializable;
* <s:elem4>content</s:elem4>
* <s:elem5 attr="val" />
*
- * @param Writer $writer
* @param string[] $values
- * @return void
*/
-function enum(Writer $writer, array $values) {
-
+function enum(Writer $writer, array $values)
+{
foreach ($values as $value) {
$writer->writeElement($value);
}
@@ -54,29 +54,26 @@ function enum(Writer $writer, array $values) {
* Values that are set to null or an empty array are not serialized. To
* serialize empty properties, you must specify them as an empty string.
*
- * @param Writer $writer
* @param object $valueObject
- * @param string $namespace
*/
-function valueObject(Writer $writer, $valueObject, $namespace) {
+function valueObject(Writer $writer, $valueObject, string $namespace)
+{
foreach (get_object_vars($valueObject) as $key => $val) {
if (is_array($val)) {
// If $val is an array, it has a special meaning. We need to
// generate one child element for each item in $val
foreach ($val as $child) {
- $writer->writeElement('{' . $namespace . '}' . $key, $child);
+ $writer->writeElement('{'.$namespace.'}'.$key, $child);
}
-
- } elseif ($val !== null) {
- $writer->writeElement('{' . $namespace . '}' . $key, $val);
+ } elseif (null !== $val) {
+ $writer->writeElement('{'.$namespace.'}'.$key, $val);
}
}
}
-
/**
* This serializer helps you serialize xml structures that look like
- * this:
+ * this:.
*
* <collection>
* <item>...</item>
@@ -88,18 +85,12 @@ function valueObject(Writer $writer, $valueObject, $namespace) {
* and this could be called like this:
*
* repeatingElements($writer, $items, '{}item');
- *
- * @param Writer $writer
- * @param array $items A list of items sabre/xml can serialize.
- * @param string $childElementName Element name in clark-notation
- * @return void
*/
-function repeatingElements(Writer $writer, array $items, $childElementName) {
-
+function repeatingElements(Writer $writer, array $items, string $childElementName)
+{
foreach ($items as $item) {
$writer->writeElement($childElementName, $item);
}
-
}
/**
@@ -157,38 +148,25 @@ function repeatingElements(Writer $writer, array $items, $childElementName) {
*
* You can even mix the two array syntaxes.
*
- * @param Writer $writer
* @param string|int|float|bool|array|object
- * @return void
*/
-function standardSerializer(Writer $writer, $value) {
-
+function standardSerializer(Writer $writer, $value)
+{
if (is_scalar($value)) {
-
// String, integer, float, boolean
- $writer->text($value);
-
+ $writer->text((string) $value);
} elseif ($value instanceof XmlSerializable) {
-
// XmlSerializable classes or Element classes.
$value->xmlSerialize($writer);
-
} elseif (is_object($value) && isset($writer->classMap[get_class($value)])) {
-
// It's an object which class appears in the classmap.
$writer->classMap[get_class($value)]($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'.
@@ -200,19 +178,13 @@ function standardSerializer(Writer $writer, $value) {
$writer->writeAttributes($attributes);
$writer->write($value);
$writer->endElement();
-
} elseif (is_array($value)) {
-
foreach ($value as $name => $item) {
-
if (is_int($name)) {
-
// This item has a numeric index. We just loop through the
// array and throw it back in the writer.
standardSerializer($writer, $item);
-
} elseif (is_string($name) && is_array($item) && isset($item['attributes'])) {
-
// The key is used for a name, but $item has 'attributes' and
// possibly 'value'
$writer->startElement($name);
@@ -221,29 +193,18 @@ function standardSerializer(Writer $writer, $value) {
$writer->write($item['value']);
}
$writer->endElement();
-
} elseif (is_string($name)) {
-
// This was a plain key-value array.
$writer->startElement($name);
$writer->write($item);
$writer->endElement();
-
} else {
-
- throw new InvalidArgumentException('The writer does not know how to serialize arrays with keys of type: ' . gettype($name));
-
+ throw new InvalidArgumentException('The writer does not know how to serialize arrays with keys of type: '.gettype($name));
}
}
-
} elseif (is_object($value)) {
-
- throw new InvalidArgumentException('The writer cannot serialize objects of class: ' . get_class($value));
-
+ throw new InvalidArgumentException('The writer cannot serialize objects of class: '.get_class($value));
} else {
-
- throw new InvalidArgumentException('The writer cannot serialize values of type: ' . gettype($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 acea94ea9..882b2dc2c 100644
--- a/vendor/sabre/xml/lib/Service.php
+++ b/vendor/sabre/xml/lib/Service.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml;
/**
@@ -13,8 +15,8 @@ namespace Sabre\Xml;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Service {
-
+class Service
+{
/**
* This is the element map. It contains a list of XML elements (in clark
* notation) as keys and PHP class names as values.
@@ -59,30 +61,26 @@ class Service {
public $classMap = [];
/**
- * Returns a fresh XML Reader
- *
- * @return Reader
+ * Returns a fresh XML Reader.
*/
- function getReader() {
-
+ public function getReader(): Reader
+ {
$r = new Reader();
$r->elementMap = $this->elementMap;
- return $r;
+ return $r;
}
/**
- * Returns a fresh xml writer
- *
- * @return Writer
+ * Returns a fresh xml writer.
*/
- function getWriter() {
-
+ public function getWriter(): Writer
+ {
$w = new Writer();
$w->namespaceMap = $this->namespaceMap;
$w->classMap = $this->classMap;
- return $w;
+ return $w;
}
/**
@@ -99,17 +97,22 @@ class Service {
* with the root element name of the document.
*
* @param string|resource $input
- * @param string|null $contextUri
- * @param string|null $rootElementName
+ *
* @throws ParseException
+ *
* @return array|object|string
*/
- function parse($input, $contextUri = null, &$rootElementName = null) {
-
+ public function parse($input, string $contextUri = null, string &$rootElementName = null)
+ {
if (is_resource($input)) {
// Unfortunately the XMLReader doesn't support streams. When it
// does, we can optimize this.
$input = stream_get_contents($input);
+
+ // If input is an empty string, then its safe to throw exception
+ if ('' === $input) {
+ throw new ParseException('The input element to parse is empty. Do not attempt to parse');
+ }
}
$r = $this->getReader();
$r->contextUri = $contextUri;
@@ -117,8 +120,8 @@ class Service {
$result = $r->parse();
$rootElementName = $result['name'];
- return $result['value'];
+ return $result['value'];
}
/**
@@ -137,33 +140,42 @@ class Service {
*
* @param string|string[] $rootElementName
* @param string|resource $input
- * @param string|null $contextUri
+ * @param string|null $contextUri
+ *
* @throws ParseException
+ *
* @return array|object|string
*/
- function expect($rootElementName, $input, $contextUri = null) {
-
+ public function expect($rootElementName, $input, string $contextUri = null)
+ {
if (is_resource($input)) {
// Unfortunately the XMLReader doesn't support streams. When it
// does, we can optimize this.
$input = stream_get_contents($input);
+
+ // If input is empty string, then its safe to throw exception
+ if ('' === $input) {
+ throw new ParseException('The input element to parse is empty. Do not attempt to parse');
+ }
}
$r = $this->getReader();
$r->contextUri = $contextUri;
$r->xml($input);
- $rootElementName = (array)$rootElementName;
+ $rootElementName = (array) $rootElementName;
foreach ($rootElementName as &$rEl) {
- if ($rEl[0] !== '{') $rEl = '{}' . $rEl;
+ if ('{' !== $rEl[0]) {
+ $rEl = '{}'.$rEl;
+ }
}
$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 ', (array) $rootElementName).' but received '.$result['name'].' as the root element');
}
- return $result['value'];
+ return $result['value'];
}
/**
@@ -180,20 +192,20 @@ class Service {
* This allows an implementor to easily create URI's relative to the root
* of the domain.
*
- * @param string $rootElementName
* @param string|array|XmlSerializable $value
- * @param string|null $contextUri
+ *
+ * @return string
*/
- function write($rootElementName, $value, $contextUri = null) {
-
+ public function write(string $rootElementName, $value, string $contextUri = null)
+ {
$w = $this->getWriter();
$w->openMemory();
$w->contextUri = $contextUri;
$w->setIndent(true);
$w->startDocument();
$w->writeElement($rootElementName, $value);
- return $w->outputMemory();
+ return $w->outputMemory();
}
/**
@@ -219,18 +231,15 @@ class Service {
* These can easily be mapped by calling:
*
* $service->mapValueObject('{http://example.org}author', 'Author');
- *
- * @param string $elementName
- * @param object $className
- * @return void
*/
- function mapValueObject($elementName, $className) {
+ public function mapValueObject(string $elementName, string $className)
+ {
list($namespace) = self::parseClarkNotation($elementName);
- $this->elementMap[$elementName] = function(Reader $reader) use ($className, $namespace) {
+ $this->elementMap[$elementName] = function (Reader $reader) use ($className, $namespace) {
return \Sabre\Xml\Deserializer\valueObject($reader, $className, $namespace);
};
- $this->classMap[$className] = function(Writer $writer, $valueObject) use ($namespace) {
+ $this->classMap[$className] = function (Writer $writer, $valueObject) use ($namespace) {
return \Sabre\Xml\Serializer\valueObject($writer, $valueObject, $namespace);
};
$this->valueObjectMap[$className] = $elementName;
@@ -246,20 +255,20 @@ class Service {
* mapValueObject().
*
* @param object $object
- * @param string $contextUri
- * @return void
+ *
+ * @throws \InvalidArgumentException
*/
- function writeValueObject($object, $contextUri = null) {
-
+ public function writeValueObject($object, string $contextUri = null)
+ {
if (!isset($this->valueObjectMap[get_class($object)])) {
- throw new \InvalidArgumentException('"' . get_class($object) . '" is not a registered value object class. Register your class with mapValueObject.');
+ throw new \InvalidArgumentException('"'.get_class($object).'" is not a registered value object class. Register your class with mapValueObject.');
}
+
return $this->write(
$this->valueObjectMap[get_class($object)],
$object,
$contextUri
);
-
}
/**
@@ -268,22 +277,20 @@ class Service {
*
* If the string was invalid, it will throw an InvalidArgumentException.
*
- * @param string $str
- * @throws InvalidArgumentException
- * @return array
+ * @throws \InvalidArgumentException
*/
- static function parseClarkNotation($str) {
+ public static function parseClarkNotation(string $str): array
+ {
static $cache = [];
if (!isset($cache[$str])) {
-
if (!preg_match('/^{([^}]*)}(.*)$/', $str, $matches)) {
- throw new \InvalidArgumentException('\'' . $str . '\' is not a valid clark-notation formatted string');
+ throw new \InvalidArgumentException('\''.$str.'\' is not a valid clark-notation formatted string');
}
$cache[$str] = [
$matches[1],
- $matches[2]
+ $matches[2],
];
}
@@ -294,5 +301,4 @@ class Service {
* A list of classes and which XML elements they map to.
*/
protected $valueObjectMap = [];
-
}
diff --git a/vendor/sabre/xml/lib/Version.php b/vendor/sabre/xml/lib/Version.php
index 7edb40d67..65706ec42 100644
--- a/vendor/sabre/xml/lib/Version.php
+++ b/vendor/sabre/xml/lib/Version.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml;
/**
@@ -9,11 +11,10 @@ namespace Sabre\Xml;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/
*/
-class Version {
-
+class Version
+{
/**
- * Full version number
+ * Full version number.
*/
- const VERSION = '1.5.0';
-
+ const VERSION = '2.1.1';
}
diff --git a/vendor/sabre/xml/lib/Writer.php b/vendor/sabre/xml/lib/Writer.php
index 09d4cb321..f5957bbce 100644
--- a/vendor/sabre/xml/lib/Writer.php
+++ b/vendor/sabre/xml/lib/Writer.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml;
use XMLWriter;
@@ -28,8 +30,8 @@ use XMLWriter;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Writer extends XMLWriter {
-
+class Writer extends XMLWriter
+{
use ContextStackTrait;
/**
@@ -93,12 +95,10 @@ class Writer extends XMLWriter {
* ]
*
* @param mixed $value
- * @return void
*/
- function write($value) {
-
+ public function write($value)
+ {
Serializer\standardSerializer($this, $value);
-
}
/**
@@ -115,52 +115,48 @@ class Writer extends XMLWriter {
*
* <entry xmlns="http://w3.org/2005/Atom">
*
+ * Note: this function doesn't have the string typehint, because PHP's
+ * XMLWriter::startElement doesn't either.
+ *
* @param string $name
- * @return bool
*/
- function startElement($name) {
-
- if ($name[0] === '{') {
-
+ public function startElement($name): bool
+ {
+ if ('{' === $name[0]) {
list($namespace, $localName) =
Service::parseClarkNotation($name);
if (array_key_exists($namespace, $this->namespaceMap)) {
$result = $this->startElementNS(
- $this->namespaceMap[$namespace] === '' ? null : $this->namespaceMap[$namespace],
+ '' === $this->namespaceMap[$namespace] ? null : $this->namespaceMap[$namespace],
$localName,
null
);
} else {
-
// An empty namespace means it's the global namespace. This is
// allowed, but it mustn't get a prefix.
- if ($namespace === "" || $namespace === null) {
+ if ('' === $namespace || null === $namespace) {
$result = $this->startElement($localName);
$this->writeAttribute('xmlns', '');
} else {
if (!isset($this->adhocNamespaces[$namespace])) {
- $this->adhocNamespaces[$namespace] = 'x' . (count($this->adhocNamespaces) + 1);
+ $this->adhocNamespaces[$namespace] = 'x'.(count($this->adhocNamespaces) + 1);
}
$result = $this->startElementNS($this->adhocNamespaces[$namespace], $localName, $namespace);
}
}
-
} else {
$result = parent::startElement($name);
}
if (!$this->namespacesWritten) {
-
foreach ($this->namespaceMap as $namespace => $prefix) {
- $this->writeAttribute(($prefix ? 'xmlns:' . $prefix : 'xmlns'), $namespace);
+ $this->writeAttribute(($prefix ? 'xmlns:'.$prefix : 'xmlns'), $namespace);
}
$this->namespacesWritten = true;
-
}
return $result;
-
}
/**
@@ -182,18 +178,22 @@ class Writer extends XMLWriter {
* becomes:
* <author xmlns="http://www.w3.org/2005" /><name>Evert Pot</name></author>
*
- * @param string $name
- * @param string $content
+ * Note: this function doesn't have the string typehint, because PHP's
+ * XMLWriter::startElement doesn't either.
+ *
+ * @param array|string|object|null $content
+ *
* @return bool
*/
- function writeElement($name, $content = null) {
-
+ public function writeElement($name, $content = null): bool
+ {
$this->startElement($name);
if (!is_null($content)) {
$this->write($content);
}
$this->endElement();
+ return true;
}
/**
@@ -204,16 +204,12 @@ class Writer extends XMLWriter {
* The key is an attribute name. If the key is a 'localName', the current
* xml namespace is assumed. If it's a 'clark notation key', this namespace
* will be used instead.
- *
- * @param array $attributes
- * @return void
*/
- function writeAttributes(array $attributes) {
-
+ public function writeAttributes(array $attributes)
+ {
foreach ($attributes as $name => $value) {
$this->writeAttribute($name, $value);
}
-
}
/**
@@ -223,44 +219,41 @@ class Writer extends XMLWriter {
*
* Returns true when successful.
*
+ * Note: this function doesn't have typehints, because for some reason
+ * PHP's XMLWriter::writeAttribute doesn't either.
+ *
* @param string $name
* @param string $value
- * @return bool
*/
- function writeAttribute($name, $value) {
-
- if ($name[0] === '{') {
-
- list(
- $namespace,
- $localName
- ) = Service::parseClarkNotation($name);
-
- if (array_key_exists($namespace, $this->namespaceMap)) {
- // It's an attribute with a namespace we know
- $this->writeAttribute(
- $this->namespaceMap[$namespace] . ':' . $localName,
- $value
- );
- } else {
-
- // We don't know the namespace, we must add it in-line
- if (!isset($this->adhocNamespaces[$namespace])) {
- $this->adhocNamespaces[$namespace] = 'x' . (count($this->adhocNamespaces) + 1);
- }
- $this->writeAttributeNS(
- $this->adhocNamespaces[$namespace],
- $localName,
- $namespace,
- $value
- );
+ public function writeAttribute($name, $value): bool
+ {
+ if ('{' !== $name[0]) {
+ return parent::writeAttribute($name, $value);
+ }
- }
+ list(
+ $namespace,
+ $localName
+ ) = Service::parseClarkNotation($name);
+
+ if (array_key_exists($namespace, $this->namespaceMap)) {
+ // It's an attribute with a namespace we know
+ return $this->writeAttribute(
+ $this->namespaceMap[$namespace].':'.$localName,
+ $value
+ );
+ }
- } else {
- return parent::writeAttribute($name, $value);
+ // We don't know the namespace, we must add it in-line
+ if (!isset($this->adhocNamespaces[$namespace])) {
+ $this->adhocNamespaces[$namespace] = 'x'.(count($this->adhocNamespaces) + 1);
}
+ return $this->writeAttributeNS(
+ $this->adhocNamespaces[$namespace],
+ $localName,
+ $namespace,
+ $value
+ );
}
-
}
diff --git a/vendor/sabre/xml/lib/XmlDeserializable.php b/vendor/sabre/xml/lib/XmlDeserializable.php
index fa857e82c..83f33db1e 100644
--- a/vendor/sabre/xml/lib/XmlDeserializable.php
+++ b/vendor/sabre/xml/lib/XmlDeserializable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml;
/**
@@ -10,8 +12,8 @@ namespace Sabre\Xml;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface XmlDeserializable {
-
+interface XmlDeserializable
+{
/**
* The deserialize method is called during xml parsing.
*
@@ -30,9 +32,7 @@ interface XmlDeserializable {
* $reader->parseInnerTree() will parse the entire sub-tree, and advance to
* the next element.
*
- * @param Reader $reader
* @return mixed
*/
- static function xmlDeserialize(Reader $reader);
-
+ public static function xmlDeserialize(Reader $reader);
}
diff --git a/vendor/sabre/xml/lib/XmlSerializable.php b/vendor/sabre/xml/lib/XmlSerializable.php
index 3e2c528b9..b22f8d5e8 100644
--- a/vendor/sabre/xml/lib/XmlSerializable.php
+++ b/vendor/sabre/xml/lib/XmlSerializable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\Xml;
/**
@@ -10,8 +12,8 @@ namespace Sabre\Xml;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface XmlSerializable {
-
+interface XmlSerializable
+{
/**
* The xmlSerialize method is called during xml writing.
*
@@ -27,10 +29,6 @@ interface XmlSerializable {
* This allows serializers to be re-used for different element names.
*
* 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);
}