diff --git a/snappymail/v/0.0.0/app/libraries/Sabre/Xml/Deserializer/functions.php b/snappymail/v/0.0.0/app/libraries/Sabre/Xml/Deserializer/functions.php index 237e42627..96fffa853 100644 --- a/snappymail/v/0.0.0/app/libraries/Sabre/Xml/Deserializer/functions.php +++ b/snappymail/v/0.0.0/app/libraries/Sabre/Xml/Deserializer/functions.php @@ -232,138 +232,3 @@ function valueObject(Reader $reader, string $className, string $namespace): obje return $valueObject; } - -/** - * This deserializer helps you deserialize xml structures that look like - * this:. - * - * - * ... - * ... - * ... - * - * - * 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: - * - * $reader->elementMap['{}collection'] = function($reader) { - * return repeatingElements($reader, '{}item'); - * } - * - * The repeatingElements deserializer simply returns everything as an array. - * - * $childElementName must either be a a clark-notation element name, or if no - * namespace is used, the bare element name. - * - * @phpstan-return list - */ -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. - * - *

some text and a inline tagand even more text

- * - * 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. - * - * @return array - */ -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; -} - -/** - * 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/snappymail/v/0.0.0/app/libraries/Sabre/Xml/Serializer/functions.php b/snappymail/v/0.0.0/app/libraries/Sabre/Xml/Serializer/functions.php index 389f6f62d..a11e56cc9 100644 --- a/snappymail/v/0.0.0/app/libraries/Sabre/Xml/Serializer/functions.php +++ b/snappymail/v/0.0.0/app/libraries/Sabre/Xml/Serializer/functions.php @@ -69,30 +69,6 @@ function valueObject(Writer $writer, object $valueObject, string $namespace): vo } } -/** - * This serializer helps you serialize xml structures that look like - * this:. - * - * - * ... - * ... - * ... - * - * - * In that previous example, this serializer just serializes the item element, - * and this could be called like this: - * - * repeatingElements($writer, $items, '{}item'); - * - * @param array $items - */ -function repeatingElements(Writer $writer, array $items, string $childElementName): void -{ - foreach ($items as $item) { - $writer->writeElement($childElementName, $item); - } -} - /** * This function is the 'default' serializer that is able to serialize most * things, and delegates to other serializers if needed.