diff options
Diffstat (limited to 'vendor/sabre/xml')
-rw-r--r-- | vendor/sabre/xml/.gitignore | 10 | ||||
-rw-r--r-- | vendor/sabre/xml/.php_cs.dist | 2 | ||||
-rw-r--r-- | vendor/sabre/xml/.travis.yml | 33 | ||||
-rw-r--r-- | vendor/sabre/xml/CHANGELOG.md | 18 | ||||
-rw-r--r-- | vendor/sabre/xml/composer.json | 23 | ||||
-rw-r--r-- | vendor/sabre/xml/lib/ContextStackTrait.php | 2 | ||||
-rw-r--r-- | vendor/sabre/xml/lib/Deserializer/functions.php | 43 | ||||
-rw-r--r-- | vendor/sabre/xml/lib/Element/Uri.php | 2 | ||||
-rw-r--r-- | vendor/sabre/xml/lib/Element/XmlFragment.php | 4 | ||||
-rw-r--r-- | vendor/sabre/xml/lib/LibXMLException.php | 5 | ||||
-rw-r--r-- | vendor/sabre/xml/lib/ParseException.php | 3 | ||||
-rw-r--r-- | vendor/sabre/xml/lib/Reader.php | 11 | ||||
-rw-r--r-- | vendor/sabre/xml/lib/Serializer/functions.php | 6 | ||||
-rw-r--r-- | vendor/sabre/xml/lib/Service.php | 38 | ||||
-rw-r--r-- | vendor/sabre/xml/lib/Version.php | 2 | ||||
-rw-r--r-- | vendor/sabre/xml/lib/Writer.php | 2 | ||||
-rw-r--r-- | vendor/sabre/xml/phpstan.neon | 6 |
17 files changed, 151 insertions, 59 deletions
diff --git a/vendor/sabre/xml/.gitignore b/vendor/sabre/xml/.gitignore index 51fc188bf..9715e9028 100644 --- a/vendor/sabre/xml/.gitignore +++ b/vendor/sabre/xml/.gitignore @@ -1,10 +1,8 @@ +# Composer vendor composer.lock + +# Tests tests/cov -.*.swp +tests/.phpunit.result.cache .php_cs.cache - -# Composer binaries -bin/phpunit -bin/php-cs-fixer -bin/sabre-cs-fixer 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..ebca5e837 100644 --- a/vendor/sabre/xml/.travis.yml +++ b/vendor/sabre/xml/.travis.yml @@ -1,31 +1,38 @@ 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: + - PREFER_LOWEST="" REPORT_COVERAGE="TRUE" WITH_COVERAGE="--coverage-clover=coverage.xml" + - PREFER_LOWEST="--prefer-lowest" REPORT_COVERAGE="FALSE" WITH_COVERAGE="" matrix: + include: + - name: 'PHPStan' + php: 7.4 + env: + - RUN_PHPSTAN="TRUE" + - REPORT_COVERAGE="FALSE" fast_finish: true cache: directories: - $HOME/.composer/cache -install: - - composer install +before_script: + - composer update $PREFER_LOWEST script: - - ./bin/phpunit --configuration tests/phpunit.xml.dist --coverage-clover=coverage.xml + - if [ $RUN_PHPSTAN == "FALSE" ]; then php vendor/bin/php-cs-fixer fix --dry-run --diff; fi + - if [ $RUN_PHPSTAN == "FALSE" ]; then php vendor/bin/phpunit --configuration tests/phpunit.xml $WITH_COVERAGE; fi + - if [ $RUN_PHPSTAN == "TRUE" ]; then composer phpstan; fi after_success: -- bash <(curl -s https://codecov.io/bash) - + - if [ $REPORT_COVERAGE == "TRUE" ]; then bash <(curl -s https://codecov.io/bash); fi diff --git a/vendor/sabre/xml/CHANGELOG.md b/vendor/sabre/xml/CHANGELOG.md index 1ad830124..9d70609f8 100644 --- a/vendor/sabre/xml/CHANGELOG.md +++ b/vendor/sabre/xml/CHANGELOG.md @@ -1,16 +1,34 @@ ChangeLog ========= +2.2.1 (2020-05-11) +------------------ + +* #183: fixed warning 'xml cannot be empty while reading', which might lead to a infinite-loop (@mrow4a) +* #179, #178, #177 #176: several build/continous integration related improvements (@phil-davis) + +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..40abe149b 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,9 +44,24 @@ } }, "require-dev": { - "phpunit/phpunit" : "^6" + "friendsofphp/php-cs-fixer": "~2.16.1", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0" }, - "config" : { - "bin-dir" : "bin/" + "scripts": { + "phpstan": [ + "phpstan analyse lib tests" + ], + "cs-fixer": [ + "php-cs-fixer fix" + ], + "phpunit": [ + "phpunit --configuration tests/phpunit.xml" + ], + "test": [ + "composer phpstan", + "composer cs-fixer", + "composer phpunit" + ] } } 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..596c93cc4 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,16 +114,17 @@ 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) { - throw new ParseException('The input element to parse is empty. Do not attempt to parse'); - } + // If input is empty, then its safe to throw exception + if (empty($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); + $r->XML($input, null, $this->options); $result = $r->parse(); $rootElementName = $result['name']; @@ -140,7 +148,6 @@ class Service * * @param string|string[] $rootElementName * @param string|resource $input - * @param string|null $contextUri * * @throws ParseException * @@ -151,16 +158,17 @@ 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) { - throw new ParseException('The input element to parse is empty. Do not attempt to parse'); - } + // If input is empty, then its safe to throw exception + if (empty($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); + $r->XML($input, null, $this->options); $rootElementName = (array) $rootElementName; @@ -172,7 +180,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 +200,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..56c5c5285 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.1'; } 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 { diff --git a/vendor/sabre/xml/phpstan.neon b/vendor/sabre/xml/phpstan.neon new file mode 100644 index 000000000..d6dd4e577 --- /dev/null +++ b/vendor/sabre/xml/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + level: 5 + ignoreErrors: + - + message: '!Parameter #3 \$uri of method XMLWriter::startElementNs\(\) expects string, null given.!' + path: lib/Writer.php |