diff options
author | Mario <mario@mariovavti.com> | 2019-12-04 10:25:11 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-12-04 10:25:11 +0000 |
commit | bde429cff649237984903a252ba1a718e6d74f53 (patch) | |
tree | b2b2570159cfb37689e6ce3b96c3b1b988d676cc /vendor/sabre/xml/lib/Element/XmlFragment.php | |
parent | cc9f41df5f83bcab435d6fb941b5a8f5b1457037 (diff) | |
parent | 4c8d33d1eb2a804aa70a7bc677d6c73d0d94816b (diff) | |
download | volse-hubzilla-4.6.tar.gz volse-hubzilla-4.6.tar.bz2 volse-hubzilla-4.6.zip |
Merge branch '4.6RC'4.6
Diffstat (limited to 'vendor/sabre/xml/lib/Element/XmlFragment.php')
-rw-r--r-- | vendor/sabre/xml/lib/Element/XmlFragment.php | 61 |
1 files changed, 31 insertions, 30 deletions
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; } - } |