From dbfe748d274f6843fc91a3071df7be45c4ab5b00 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 7 May 2020 15:22:25 +0000 Subject: composer updates --- vendor/sabre/xml/.gitignore | 16 +++++++-- vendor/sabre/xml/.php_cs.dist | 2 +- vendor/sabre/xml/.travis.yml | 27 +++++++++------- vendor/sabre/xml/CHANGELOG.md | 12 +++++++ vendor/sabre/xml/composer.json | 5 +-- vendor/sabre/xml/lib/ContextStackTrait.php | 2 +- vendor/sabre/xml/lib/Deserializer/functions.php | 43 ++++++++++++++++++++++++- vendor/sabre/xml/lib/Element/Uri.php | 2 +- vendor/sabre/xml/lib/Element/XmlFragment.php | 4 +-- vendor/sabre/xml/lib/LibXMLException.php | 5 ++- vendor/sabre/xml/lib/ParseException.php | 3 +- vendor/sabre/xml/lib/Reader.php | 11 ++++--- vendor/sabre/xml/lib/Serializer/functions.php | 6 ++-- vendor/sabre/xml/lib/Service.php | 20 ++++++++---- vendor/sabre/xml/lib/Version.php | 2 +- vendor/sabre/xml/lib/Writer.php | 2 -- 16 files changed, 119 insertions(+), 43 deletions(-) (limited to 'vendor/sabre/xml') diff --git a/vendor/sabre/xml/.gitignore b/vendor/sabre/xml/.gitignore index 51fc188bf..a85591183 100644 --- a/vendor/sabre/xml/.gitignore +++ b/vendor/sabre/xml/.gitignore @@ -1,10 +1,22 @@ +# Composer vendor composer.lock + +# Tests tests/cov +tests/.phpunit.result.cache .*.swp -.php_cs.cache # Composer binaries bin/phpunit bin/php-cs-fixer -bin/sabre-cs-fixer +bin/phpstan +bin/phpstan.phar + +# Vim +.*.swp + +# IDEs +/.idea + +.php_cs.cache diff --git a/vendor/sabre/xml/.php_cs.dist b/vendor/sabre/xml/.php_cs.dist index 8d61ee259..c5c78a971 100644 --- a/vendor/sabre/xml/.php_cs.dist +++ b/vendor/sabre/xml/.php_cs.dist @@ -6,7 +6,7 @@ $config->getFinder() ->in(__DIR__); $config->setRules([ '@PSR1' => true, - '@Symfony' =>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 49a0c9a22..953c2a60b 100644 --- a/vendor/sabre/xml/.travis.yml +++ b/vendor/sabre/xml/.travis.yml @@ -1,19 +1,20 @@ language: php sudo: required -dist: xenial php: - - 7.0 - 7.1 - 7.2 - - 7.3snapshot + - 7.3 + - 7.4 -addons: - apt: - packages: - # required for php7.3 - - libzip4 +env: + global: + - RUN_PHPSTAN="FALSE" matrix: + include: + - name: 'PHPStan' + php: 7.2 + env: RUN_PHPSTAN="TRUE" fast_finish: true cache: @@ -21,11 +22,15 @@ cache: - $HOME/.composer/cache install: + - if [ $RUN_PHPSTAN == "TRUE" ]; then composer require --dev phpstan/phpstan:^0.12; fi + +before_script: - composer install script: - - ./bin/phpunit --configuration tests/phpunit.xml.dist --coverage-clover=coverage.xml + - if [ $RUN_PHPSTAN == "FALSE" ]; then ./bin/php-cs-fixer fix --dry-run --diff; fi + - if [ $RUN_PHPSTAN == "FALSE" ]; then ./bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml; fi + - if [ $RUN_PHPSTAN == "TRUE" ]; then php ./bin/phpstan analyse -c phpstan.neon lib; fi after_success: -- bash <(curl -s https://codecov.io/bash) - + - bash <(curl -s https://codecov.io/bash) diff --git a/vendor/sabre/xml/CHANGELOG.md b/vendor/sabre/xml/CHANGELOG.md index 1ad830124..bbfc8ddec 100644 --- a/vendor/sabre/xml/CHANGELOG.md +++ b/vendor/sabre/xml/CHANGELOG.md @@ -1,16 +1,28 @@ ChangeLog ========= +2.2.0 (2020-01-31) +------------------ + +* #171: Added Support for PHP 7.4, dropped Support for PHP 7.0 (@staabm, @phil-davis) +* #174: Update testsuite to phpunit8 (@phil-davis) +* Added phpstan coverage (@phil-davis) +* #144: Added a new `functionCaller` deserializer function for executing a callable when reading a XML +element (@vsouz4) + + 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) ------------------ diff --git a/vendor/sabre/xml/composer.json b/vendor/sabre/xml/composer.json index c782dbc5e..2af0dd458 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" : ">=7.0", + "php" : "^7.1", "ext-xmlwriter" : "*", "ext-xmlreader" : "*", "ext-dom" : "*", @@ -44,7 +44,8 @@ } }, "require-dev": { - "phpunit/phpunit" : "^6" + "friendsofphp/php-cs-fixer": "~2.16.1", + "phpunit/phpunit" : "^7 || ^8" }, "config" : { "bin-dir" : "bin/" 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 @@ -60,6 +60,13 @@ class Service */ public $classMap = []; + /** + * A bitmask of the LIBXML_* constants. + * + * @var int + */ + public $options = 0; + /** * Returns a fresh XML 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 { -- cgit v1.2.3