mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Sabre/Xml v4.0.5
This commit is contained in:
parent
9e3d6c6e23
commit
1ac4f05d91
|
@ -57,7 +57,7 @@ use Sabre\Xml\Reader;
|
|||
*
|
||||
* @phpstan-return array<string, mixed>
|
||||
*/
|
||||
function keyValue(Reader $reader, string $namespace = null): array
|
||||
function keyValue(Reader $reader, ?string $namespace = null): array
|
||||
{
|
||||
// If there's no children, we don't do anything.
|
||||
if ($reader->isEmptyElement) {
|
||||
|
@ -148,7 +148,7 @@ function keyValue(Reader $reader, string $namespace = null): array
|
|||
*
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
function enum(Reader $reader, string $namespace = null): array
|
||||
function enum(Reader $reader, ?string $namespace = null): array
|
||||
{
|
||||
// If there's no children, we don't do anything.
|
||||
if ($reader->isEmptyElement) {
|
||||
|
@ -223,6 +223,9 @@ function valueObject(Reader $reader, string $className, string $namespace): obje
|
|||
// Ignore property
|
||||
$reader->next();
|
||||
}
|
||||
} elseif (Reader::ELEMENT === $reader->nodeType) {
|
||||
// Skipping element from different namespace
|
||||
$reader->next();
|
||||
} else {
|
||||
if (Reader::END_ELEMENT !== $reader->nodeType && !$reader->read()) {
|
||||
break;
|
||||
|
|
|
@ -31,7 +31,7 @@ class LibXMLException extends ParseException
|
|||
*
|
||||
* @param \LibXMLError[] $errors
|
||||
*/
|
||||
public function __construct(array $errors, int $code = 0, \Throwable $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);
|
||||
|
|
|
@ -107,7 +107,7 @@ class Reader extends \XMLReader
|
|||
*
|
||||
* @return array<int,array<string, mixed>>
|
||||
*/
|
||||
public function parseGetElements(array $elementMap = null): array
|
||||
public function parseGetElements(?array $elementMap = null): array
|
||||
{
|
||||
$result = $this->parseInnerTree($elementMap);
|
||||
if (!is_array($result)) {
|
||||
|
@ -132,7 +132,7 @@ class Reader extends \XMLReader
|
|||
*
|
||||
* @return array<int,array<string, mixed>>|string|null
|
||||
*/
|
||||
public function parseInnerTree(array $elementMap = null)
|
||||
public function parseInnerTree(?array $elementMap = null)
|
||||
{
|
||||
$text = null;
|
||||
$elements = [];
|
||||
|
|
|
@ -107,7 +107,7 @@ class Service
|
|||
*
|
||||
* @throws ParseException
|
||||
*/
|
||||
public function parse($input, string $contextUri = null, string &$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
|
||||
|
@ -151,7 +151,7 @@ class Service
|
|||
*
|
||||
* @throws ParseException
|
||||
*/
|
||||
public function expect($rootElementName, $input, string $contextUri = null)
|
||||
public function expect($rootElementName, $input, ?string $contextUri = null)
|
||||
{
|
||||
if (is_resource($input)) {
|
||||
// Unfortunately the XMLReader doesn't support streams. When it
|
||||
|
@ -200,7 +200,7 @@ class Service
|
|||
*
|
||||
* @param string|array<int|string, mixed>|object|XmlSerializable $value
|
||||
*/
|
||||
public function write(string $rootElementName, $value, string $contextUri = null): string
|
||||
public function write(string $rootElementName, $value, ?string $contextUri = null): string
|
||||
{
|
||||
$w = $this->getWriter();
|
||||
$w->openMemory();
|
||||
|
@ -241,7 +241,6 @@ class Service
|
|||
public function mapValueObject(string $elementName, string $className): void
|
||||
{
|
||||
list($namespace) = self::parseClarkNotation($elementName);
|
||||
$namespace = $namespace ?? '';
|
||||
|
||||
require_once __DIR__ . '/Deserializer/functions.php';
|
||||
$this->elementMap[$elementName] = function (Reader $reader) use ($className, $namespace) {
|
||||
|
@ -265,7 +264,7 @@ class Service
|
|||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function writeValueObject(object $object, string $contextUri = null): string
|
||||
public function writeValueObject(object $object, ?string $contextUri = null): string
|
||||
{
|
||||
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.');
|
||||
|
@ -284,7 +283,7 @@ class Service
|
|||
*
|
||||
* If the string was invalid, it will throw an InvalidArgumentException.
|
||||
*
|
||||
* @return array{string|null, string}
|
||||
* @return array{string, string}
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
|
|
|
@ -16,5 +16,5 @@ class Version
|
|||
/**
|
||||
* Full version number.
|
||||
*/
|
||||
public const VERSION = '4.0.4';
|
||||
public const VERSION = '4.0.5';
|
||||
}
|
||||
|
|
|
@ -125,7 +125,6 @@ class Writer extends \XMLWriter
|
|||
if ('{' === $name[0]) {
|
||||
list($namespace, $localName) =
|
||||
Service::parseClarkNotation($name);
|
||||
$namespace = $namespace ?? '';
|
||||
|
||||
if (array_key_exists($namespace, $this->namespaceMap)) {
|
||||
$result = $this->startElementNS(
|
||||
|
@ -240,7 +239,6 @@ class Writer extends \XMLWriter
|
|||
$localName
|
||||
) = Service::parseClarkNotation($name);
|
||||
|
||||
$namespace = $namespace ?? '';
|
||||
if (array_key_exists($namespace, $this->namespaceMap)) {
|
||||
// It's an attribute with a namespace we know
|
||||
return $this->writeAttribute(
|
||||
|
|
Loading…
Reference in a new issue