aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/lib/Parser
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-04-25 11:24:09 +0200
committerMario <mario@mariovavti.com>2019-04-25 11:24:09 +0200
commitf1c07977809ce3221286d53e99f0d91145b1166f (patch)
tree4c067a3b701ea56f10070c386b26a30f93666eb0 /vendor/sabre/vobject/lib/Parser
parent701167bc125700efb3e6ce759b85bcb4d36ee42e (diff)
downloadvolse-hubzilla-f1c07977809ce3221286d53e99f0d91145b1166f.tar.gz
volse-hubzilla-f1c07977809ce3221286d53e99f0d91145b1166f.tar.bz2
volse-hubzilla-f1c07977809ce3221286d53e99f0d91145b1166f.zip
Revert "update composer libs"
This reverts commit e779335d060b3a51d6a144d23af4097ae6801473
Diffstat (limited to 'vendor/sabre/vobject/lib/Parser')
-rw-r--r--vendor/sabre/vobject/lib/Parser/Json.php63
-rw-r--r--vendor/sabre/vobject/lib/Parser/MimeDir.php187
-rw-r--r--vendor/sabre/vobject/lib/Parser/Parser.php21
-rw-r--r--vendor/sabre/vobject/lib/Parser/XML.php137
-rw-r--r--vendor/sabre/vobject/lib/Parser/XML/Element/KeyValue.php19
5 files changed, 257 insertions, 170 deletions
diff --git a/vendor/sabre/vobject/lib/Parser/Json.php b/vendor/sabre/vobject/lib/Parser/Json.php
index 3fd307e97..a77258a2e 100644
--- a/vendor/sabre/vobject/lib/Parser/Json.php
+++ b/vendor/sabre/vobject/lib/Parser/Json.php
@@ -4,7 +4,6 @@ namespace Sabre\VObject\Parser;
use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\Component\VCard;
-use Sabre\VObject\Document;
use Sabre\VObject\EofException;
use Sabre\VObject\ParseException;
@@ -17,8 +16,8 @@ use Sabre\VObject\ParseException;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Json extends Parser
-{
+class Json extends Parser {
+
/**
* The input data.
*
@@ -42,12 +41,12 @@ class Json extends Parser
* If either input or options are not supplied, the defaults will be used.
*
* @param resource|string|array|null $input
- * @param int $options
+ * @param int $options
*
- * @return \Sabre\VObject\Document
+ * @return Sabre\VObject\Document
*/
- public function parse($input = null, $options = 0)
- {
+ function parse($input = null, $options = 0) {
+
if (!is_null($input)) {
$this->setInput($input);
}
@@ -60,28 +59,28 @@ class Json extends Parser
}
switch ($this->input[0]) {
- case 'vcalendar':
+ case 'vcalendar' :
$this->root = new VCalendar([], false);
break;
- case 'vcard':
+ case 'vcard' :
$this->root = new VCard([], false);
break;
- default:
+ default :
throw new ParseException('The root component must either be a vcalendar, or a vcard');
+
}
foreach ($this->input[1] as $prop) {
$this->root->add($this->parseProperty($prop));
}
- if (isset($this->input[2])) {
- foreach ($this->input[2] as $comp) {
- $this->root->add($this->parseComponent($comp));
- }
+ if (isset($this->input[2])) foreach ($this->input[2] as $comp) {
+ $this->root->add($this->parseComponent($comp));
}
// Resetting the input so we can throw an feof exception the next time.
$this->input = null;
return $this->root;
+
}
/**
@@ -91,34 +90,35 @@ class Json extends Parser
*
* @return \Sabre\VObject\Component
*/
- public function parseComponent(array $jComp)
- {
+ function parseComponent(array $jComp) {
+
// We can remove $self from PHP 5.4 onward.
$self = $this;
$properties = array_map(
- function ($jProp) use ($self) {
+ function($jProp) use ($self) {
return $self->parseProperty($jProp);
},
$jComp[1]
);
if (isset($jComp[2])) {
+
$components = array_map(
- function ($jComp) use ($self) {
+ function($jComp) use ($self) {
return $self->parseComponent($jComp);
},
$jComp[2]
);
- } else {
- $components = [];
- }
+
+ } else $components = [];
return $this->root->createComponent(
$jComp[0],
array_merge($properties, $components),
$defaults = false
);
+
}
/**
@@ -128,8 +128,8 @@ class Json extends Parser
*
* @return \Sabre\VObject\Property
*/
- public function parseProperty(array $jProp)
- {
+ function parseProperty(array $jProp) {
+
list(
$propertyName,
$parameters,
@@ -142,14 +142,14 @@ class Json extends Parser
// value type. We're using this value later in this function.
$defaultPropertyClass = $this->root->getClassNameForPropertyName($propertyName);
- $parameters = (array) $parameters;
+ $parameters = (array)$parameters;
$value = array_slice($jProp, 3);
$valueType = strtoupper($valueType);
if (isset($parameters['group'])) {
- $propertyName = $parameters['group'].'.'.$propertyName;
+ $propertyName = $parameters['group'] . '.' . $propertyName;
unset($parameters['group']);
}
@@ -160,7 +160,7 @@ class Json extends Parser
// represents TEXT values. We have to normalize these here. In the
// future we can get rid of FlatText once we're allowed to break BC
// again.
- if ('Sabre\VObject\Property\FlatText' === $defaultPropertyClass) {
+ if ($defaultPropertyClass === 'Sabre\VObject\Property\FlatText') {
$defaultPropertyClass = 'Sabre\VObject\Property\Text';
}
@@ -168,19 +168,22 @@ class Json extends Parser
// type for the given property (e.g.: BDAY), we need to add a VALUE=
// parameter.
if ($defaultPropertyClass !== get_class($prop)) {
- $prop['VALUE'] = $valueType;
+ $prop["VALUE"] = $valueType;
}
return $prop;
+
}
/**
* Sets the input data.
*
* @param resource|string|array $input
+ *
+ * @return void
*/
- public function setInput($input)
- {
+ function setInput($input) {
+
if (is_resource($input)) {
$input = stream_get_contents($input);
}
@@ -188,5 +191,7 @@ class Json extends Parser
$input = json_decode($input);
}
$this->input = $input;
+
}
+
}
diff --git a/vendor/sabre/vobject/lib/Parser/MimeDir.php b/vendor/sabre/vobject/lib/Parser/MimeDir.php
index 10dcec89c..742641236 100644
--- a/vendor/sabre/vobject/lib/Parser/MimeDir.php
+++ b/vendor/sabre/vobject/lib/Parser/MimeDir.php
@@ -7,7 +7,6 @@ use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\Component\VCard;
use Sabre\VObject\Document;
use Sabre\VObject\EofException;
-use Sabre\VObject\Node;
use Sabre\VObject\ParseException;
/**
@@ -23,8 +22,8 @@ use Sabre\VObject\ParseException;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class MimeDir extends Parser
-{
+class MimeDir extends Parser {
+
/**
* The input stream.
*
@@ -71,12 +70,12 @@ class MimeDir extends Parser
* used.
*
* @param string|resource|null $input
- * @param int $options
+ * @param int $options
*
- * @return \Sabre\VObject\Document
+ * @return Sabre\VObject\Document
*/
- public function parse($input = null, $options = 0)
- {
+ function parse($input = null, $options = 0) {
+
$this->root = null;
if (!is_null($input)) {
@@ -90,6 +89,7 @@ class MimeDir extends Parser
$this->parseDocument();
return $this->root;
+
}
/**
@@ -104,21 +104,24 @@ class MimeDir extends Parser
*
* @param string $charset
*/
- public function setCharset($charset)
- {
+ function setCharset($charset) {
+
if (!in_array($charset, self::$SUPPORTED_CHARSETS)) {
- throw new \InvalidArgumentException('Unsupported encoding. (Supported encodings: '.implode(', ', self::$SUPPORTED_CHARSETS).')');
+ throw new \InvalidArgumentException('Unsupported encoding. (Supported encodings: ' . implode(', ', self::$SUPPORTED_CHARSETS) . ')');
}
$this->charset = $charset;
+
}
/**
* Sets the input buffer. Must be a string or stream.
*
* @param resource|string $input
+ *
+ * @return void
*/
- public function setInput($input)
- {
+ function setInput($input) {
+
// Resetting the parser
$this->lineIndex = 0;
$this->startLine = 0;
@@ -134,53 +137,59 @@ class MimeDir extends Parser
} else {
throw new \InvalidArgumentException('This parser can only read from strings or streams.');
}
+
}
/**
* Parses an entire document.
+ *
+ * @return void
*/
- protected function parseDocument()
- {
+ protected function parseDocument() {
+
$line = $this->readLine();
// BOM is ZERO WIDTH NO-BREAK SPACE (U+FEFF).
// It's 0xEF 0xBB 0xBF in UTF-8 hex.
if (3 <= strlen($line)
- && 0xef === ord($line[0])
- && 0xbb === ord($line[1])
- && 0xbf === ord($line[2])) {
+ && ord($line[0]) === 0xef
+ && ord($line[1]) === 0xbb
+ && ord($line[2]) === 0xbf) {
$line = substr($line, 3);
}
switch (strtoupper($line)) {
- case 'BEGIN:VCALENDAR':
+ case 'BEGIN:VCALENDAR' :
$class = VCalendar::$componentMap['VCALENDAR'];
break;
- case 'BEGIN:VCARD':
+ case 'BEGIN:VCARD' :
$class = VCard::$componentMap['VCARD'];
break;
- default:
+ default :
throw new ParseException('This parser only supports VCARD and VCALENDAR files');
}
$this->root = new $class([], false);
while (true) {
+
// Reading until we hit END:
$line = $this->readLine();
- if ('END:' === strtoupper(substr($line, 0, 4))) {
+ if (strtoupper(substr($line, 0, 4)) === 'END:') {
break;
}
$result = $this->parseLine($line);
if ($result) {
$this->root->add($result);
}
+
}
$name = strtoupper(substr($line, 4));
if ($name !== $this->root->name) {
- throw new ParseException('Invalid MimeDir file. expected: "END:'.$this->root->name.'" got: "END:'.$name.'"');
+ throw new ParseException('Invalid MimeDir file. expected: "END:' . $this->root->name . '" got: "END:' . $name . '"');
}
+
}
/**
@@ -191,40 +200,46 @@ class MimeDir extends Parser
*
* @return Node
*/
- protected function parseLine($line)
- {
+ protected function parseLine($line) {
+
// Start of a new component
- if ('BEGIN:' === strtoupper(substr($line, 0, 6))) {
+ if (strtoupper(substr($line, 0, 6)) === 'BEGIN:') {
+
$component = $this->root->createComponent(substr($line, 6), [], false);
while (true) {
+
// Reading until we hit END:
$line = $this->readLine();
- if ('END:' === strtoupper(substr($line, 0, 4))) {
+ if (strtoupper(substr($line, 0, 4)) === 'END:') {
break;
}
$result = $this->parseLine($line);
if ($result) {
$component->add($result);
}
+
}
$name = strtoupper(substr($line, 4));
if ($name !== $component->name) {
- throw new ParseException('Invalid MimeDir file. expected: "END:'.$component->name.'" got: "END:'.$name.'"');
+ throw new ParseException('Invalid MimeDir file. expected: "END:' . $component->name . '" got: "END:' . $name . '"');
}
return $component;
+
} else {
+
// Property reader
$property = $this->readProperty($line);
if (!$property) {
// Ignored line
return false;
}
-
return $property;
+
}
+
}
/**
@@ -233,7 +248,7 @@ class MimeDir extends Parser
*
* If that was not the case, we store it here.
*
- * @var string|null
+ * @var null|string
*/
protected $lineBuffer;
@@ -266,8 +281,8 @@ class MimeDir extends Parser
*
* @return string
*/
- protected function readLine()
- {
+ protected function readLine() {
+
if (!\is_null($this->lineBuffer)) {
$rawLine = $this->lineBuffer;
$this->lineBuffer = null;
@@ -277,15 +292,15 @@ class MimeDir extends Parser
$rawLine = \fgets($this->input);
- if ($eof || (\feof($this->input) && false === $rawLine)) {
+ if ($eof || (\feof($this->input) && $rawLine === false)) {
throw new EofException('End of document reached prematurely');
}
- if (false === $rawLine) {
+ if ($rawLine === false) {
throw new ParseException('Error reading from input stream');
}
$rawLine = \rtrim($rawLine, "\r\n");
- } while ('' === $rawLine); // Skipping empty lines
- ++$this->lineIndex;
+ } while ($rawLine === ''); // Skipping empty lines
+ $this->lineIndex++;
}
$line = $rawLine;
@@ -293,30 +308,34 @@ class MimeDir extends Parser
// Looking ahead for folded lines.
while (true) {
+
$nextLine = \rtrim(\fgets($this->input), "\r\n");
- ++$this->lineIndex;
+ $this->lineIndex++;
if (!$nextLine) {
break;
}
- if ("\t" === $nextLine[0] || ' ' === $nextLine[0]) {
+ if ($nextLine[0] === "\t" || $nextLine[0] === " ") {
$curLine = \substr($nextLine, 1);
$line .= $curLine;
- $rawLine .= "\n ".$curLine;
+ $rawLine .= "\n " . $curLine;
} else {
$this->lineBuffer = $nextLine;
break;
}
+
}
$this->rawLine = $rawLine;
-
return $line;
+
}
/**
* Reads a property or component from a line.
+ *
+ * @return void
*/
- protected function readProperty($line)
- {
+ protected function readProperty($line) {
+
if ($this->options & self::OPTION_FORGIVING) {
$propNameToken = 'A-Z0-9\-\._\\/';
} else {
@@ -341,17 +360,17 @@ class MimeDir extends Parser
/xi";
//echo $regex, "\n"; die();
- preg_match_all($regex, $line, $matches, PREG_SET_ORDER);
+ preg_match_all($regex, $line, $matches, PREG_SET_ORDER);
$property = [
- 'name' => null,
+ 'name' => null,
'parameters' => [],
- 'value' => null,
+ 'value' => null
];
$lastParam = null;
- /*
+ /**
* Looping through all the tokens.
*
* Note that we are looping through them in reverse order, because if a
@@ -359,8 +378,9 @@ class MimeDir extends Parser
* in the result.
*/
foreach ($matches as $match) {
+
if (isset($match['paramValue'])) {
- if ($match['paramValue'] && '"' === $match['paramValue'][0]) {
+ if ($match['paramValue'] && $match['paramValue'][0] === '"') {
$value = substr($match['paramValue'], 1, -1);
} else {
$value = $match['paramValue'];
@@ -369,7 +389,7 @@ class MimeDir extends Parser
$value = $this->unescapeParam($value);
if (is_null($lastParam)) {
- throw new ParseException('Invalid Mimedir file. Line starting at '.$this->startLine.' did not follow iCalendar/vCard conventions');
+ throw new ParseException('Invalid Mimedir file. Line starting at ' . $this->startLine . ' did not follow iCalendar/vCard conventions');
}
if (is_null($property['parameters'][$lastParam])) {
$property['parameters'][$lastParam] = $value;
@@ -378,7 +398,7 @@ class MimeDir extends Parser
} else {
$property['parameters'][$lastParam] = [
$property['parameters'][$lastParam],
- $value,
+ $value
];
}
continue;
@@ -402,6 +422,7 @@ class MimeDir extends Parser
// @codeCoverageIgnoreStart
throw new \LogicException('This code should not be reachable');
// @codeCoverageIgnoreEnd
+
}
if (is_null($property['value'])) {
@@ -411,11 +432,11 @@ class MimeDir extends Parser
if ($this->options & self::OPTION_IGNORE_INVALID_LINES) {
return false;
}
- throw new ParseException('Invalid Mimedir file. Line starting at '.$this->startLine.' did not follow iCalendar/vCard conventions');
+ throw new ParseException('Invalid Mimedir file. Line starting at ' . $this->startLine . ' did not follow iCalendar/vCard conventions');
}
// vCard 2.1 states that parameters may appear without a name, and only
- // a value. We can deduce the value based on its name.
+ // a value. We can deduce the value based on it's name.
//
// Our parser will get those as parameters without a value instead, so
// we're filtering these parameters out first.
@@ -436,30 +457,31 @@ class MimeDir extends Parser
$propObj->add(null, $namelessParameter);
}
- if ('QUOTED-PRINTABLE' === strtoupper($propObj['ENCODING'])) {
+ if (strtoupper($propObj['ENCODING']) === 'QUOTED-PRINTABLE') {
$propObj->setQuotedPrintableValue($this->extractQuotedPrintableValue());
} else {
$charset = $this->charset;
- if (Document::VCARD21 === $this->root->getDocumentType() && isset($propObj['CHARSET'])) {
+ if ($this->root->getDocumentType() === Document::VCARD21 && isset($propObj['CHARSET'])) {
// vCard 2.1 allows the character set to be specified per property.
- $charset = (string) $propObj['CHARSET'];
+ $charset = (string)$propObj['CHARSET'];
}
switch (strtolower($charset)) {
- case 'utf-8':
+ case 'utf-8' :
break;
- case 'iso-8859-1':
+ case 'iso-8859-1' :
$property['value'] = utf8_encode($property['value']);
break;
- case 'windows-1252':
+ case 'windows-1252' :
$property['value'] = mb_convert_encoding($property['value'], 'UTF-8', $charset);
break;
- default:
- throw new ParseException('Unsupported CHARSET: '.$propObj['CHARSET']);
+ default :
+ throw new ParseException('Unsupported CHARSET: ' . $propObj['CHARSET']);
}
$propObj->setRawMimeDirValue($property['value']);
}
return $propObj;
+
}
/**
@@ -524,11 +546,11 @@ class MimeDir extends Parser
*
* @return string|string[]
*/
- public static function unescapeValue($input, $delimiter = ';')
- {
+ static function unescapeValue($input, $delimiter = ';') {
+
$regex = '# (?: (\\\\ (?: \\\\ | N | n | ; | , ) )';
if ($delimiter) {
- $regex .= ' | ('.$delimiter.')';
+ $regex .= ' | (' . $delimiter . ')';
}
$regex .= ') #x';
@@ -538,33 +560,36 @@ class MimeDir extends Parser
$result = '';
foreach ($matches as $match) {
+
switch ($match) {
- case '\\\\':
+ case '\\\\' :
$result .= '\\';
break;
- case '\N':
- case '\n':
+ case '\N' :
+ case '\n' :
$result .= "\n";
break;
- case '\;':
+ case '\;' :
$result .= ';';
break;
- case '\,':
+ case '\,' :
$result .= ',';
break;
- case $delimiter:
+ case $delimiter :
$resultArray[] = $result;
$result = '';
break;
- default:
+ default :
$result .= $match;
break;
+
}
+
}
$resultArray[] = $result;
-
return $delimiter ? $resultArray : $result;
+
}
/**
@@ -598,19 +623,21 @@ class MimeDir extends Parser
* * " is encoded as ^'
*
* @param string $input
+ *
+ * @return void
*/
- private function unescapeParam($input)
- {
+ private function unescapeParam($input) {
+
return
preg_replace_callback(
'#(\^(\^|n|\'))#',
- function ($matches) {
+ function($matches) {
switch ($matches[2]) {
- case 'n':
+ case 'n' :
return "\n";
- case '^':
+ case '^' :
return '^';
- case '\'':
+ case '\'' :
return '"';
// @codeCoverageIgnoreStart
@@ -631,8 +658,8 @@ class MimeDir extends Parser
*
* @return string
*/
- private function extractQuotedPrintableValue()
- {
+ private function extractQuotedPrintableValue() {
+
// We need to parse the raw line again to get the start of the value.
//
// We are basically looking for the first colon (:), but we need to
@@ -655,14 +682,16 @@ class MimeDir extends Parser
// missing a whitespace. So if 'forgiving' is turned on, we will take
// those as well.
if ($this->options & self::OPTION_FORGIVING) {
- while ('=' === substr($value, -1)) {
+ while (substr($value, -1) === '=') {
// Reading the line
$this->readLine();
// Grabbing the raw form
- $value .= "\n".$this->rawLine;
+ $value .= "\n" . $this->rawLine;
}
}
return $value;
+
}
+
}
diff --git a/vendor/sabre/vobject/lib/Parser/Parser.php b/vendor/sabre/vobject/lib/Parser/Parser.php
index b7b611430..ca8bc0add 100644
--- a/vendor/sabre/vobject/lib/Parser/Parser.php
+++ b/vendor/sabre/vobject/lib/Parser/Parser.php
@@ -11,8 +11,8 @@ namespace Sabre\VObject\Parser;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-abstract class Parser
-{
+abstract class Parser {
+
/**
* Turning on this option makes the parser more forgiving.
*
@@ -41,10 +41,12 @@ abstract class Parser
* Optionally, it's possible to parse the input stream here.
*
* @param mixed $input
- * @param int $options any parser options (OPTION constants)
+ * @param int $options Any parser options (OPTION constants).
+ *
+ * @return void
*/
- public function __construct($input = null, $options = 0)
- {
+ function __construct($input = null, $options = 0) {
+
if (!is_null($input)) {
$this->setInput($input);
}
@@ -60,16 +62,19 @@ abstract class Parser
* If either input or options are not supplied, the defaults will be used.
*
* @param mixed $input
- * @param int $options
+ * @param int $options
*
* @return array
*/
- abstract public function parse($input = null, $options = 0);
+ abstract function parse($input = null, $options = 0);
/**
* Sets the input data.
*
* @param mixed $input
+ *
+ * @return void
*/
- abstract public function setInput($input);
+ abstract function setInput($input);
+
}
diff --git a/vendor/sabre/vobject/lib/Parser/XML.php b/vendor/sabre/vobject/lib/Parser/XML.php
index 90f262d9e..5ac423984 100644
--- a/vendor/sabre/vobject/lib/Parser/XML.php
+++ b/vendor/sabre/vobject/lib/Parser/XML.php
@@ -18,8 +18,8 @@ use Sabre\Xml as SabreXml;
* @author Ivan Enderlin
* @license http://sabre.io/license/ Modified BSD License
*/
-class XML extends Parser
-{
+class XML extends Parser {
+
const XCAL_NAMESPACE = 'urn:ietf:params:xml:ns:icalendar-2.0';
const XCARD_NAMESPACE = 'urn:ietf:params:xml:ns:vcard-4.0';
@@ -40,7 +40,7 @@ class XML extends Parser
/**
* Document, root component.
*
- * @var \Sabre\VObject\Document
+ * @var Sabre\VObject\Document
*/
protected $root;
@@ -50,29 +50,32 @@ class XML extends Parser
* Optionally, it's possible to parse the input stream here.
*
* @param mixed $input
- * @param int $options any parser options (OPTION constants)
+ * @param int $options Any parser options (OPTION constants).
+ *
+ * @return void
*/
- public function __construct($input = null, $options = 0)
- {
+ function __construct($input = null, $options = 0) {
+
if (0 === $options) {
$options = parent::OPTION_FORGIVING;
}
parent::__construct($input, $options);
+
}
/**
* Parse xCal or xCard.
*
* @param resource|string $input
- * @param int $options
+ * @param int $options
*
* @throws \Exception
*
- * @return \Sabre\VObject\Document
+ * @return Sabre\VObject\Document
*/
- public function parse($input = null, $options = 0)
- {
+ function parse($input = null, $options = 0) {
+
if (!is_null($input)) {
$this->setInput($input);
}
@@ -86,25 +89,29 @@ class XML extends Parser
}
switch ($this->input['name']) {
- case '{'.self::XCAL_NAMESPACE.'}icalendar':
+
+ case '{' . self::XCAL_NAMESPACE . '}icalendar':
$this->root = new VCalendar([], false);
$this->pointer = &$this->input['value'][0];
$this->parseVCalendarComponents($this->root);
break;
- case '{'.self::XCARD_NAMESPACE.'}vcards':
+ case '{' . self::XCARD_NAMESPACE . '}vcards':
foreach ($this->input['value'] as &$vCard) {
+
$this->root = new VCard(['version' => '4.0'], false);
$this->pointer = &$vCard;
$this->parseVCardComponents($this->root);
// We just parse the first <vcard /> element.
break;
+
}
break;
default:
throw new ParseException('Unsupported XML standard');
+
}
return $this->root;
@@ -114,11 +121,15 @@ class XML extends Parser
* Parse a xCalendar component.
*
* @param Component $parentComponent
+ *
+ * @return void
*/
- protected function parseVCalendarComponents(Component $parentComponent)
- {
+ protected function parseVCalendarComponents(Component $parentComponent) {
+
foreach ($this->pointer['value'] ?: [] as $children) {
+
switch (static::getTagName($children['name'])) {
+
case 'properties':
$this->pointer = &$children['value'];
$this->parseProperties($parentComponent);
@@ -130,28 +141,35 @@ class XML extends Parser
break;
}
}
+
}
/**
* Parse a xCard component.
*
* @param Component $parentComponent
+ *
+ * @return void
*/
- protected function parseVCardComponents(Component $parentComponent)
- {
+ protected function parseVCardComponents(Component $parentComponent) {
+
$this->pointer = &$this->pointer['value'];
$this->parseProperties($parentComponent);
+
}
/**
* Parse xCalendar and xCard properties.
*
* @param Component $parentComponent
- * @param string $propertyNamePrefix
+ * @param string $propertyNamePrefix
+ *
+ * @return void
*/
- protected function parseProperties(Component $parentComponent, $propertyNamePrefix = '')
- {
+ protected function parseProperties(Component $parentComponent, $propertyNamePrefix = '') {
+
foreach ($this->pointer ?: [] as $xmlProperty) {
+
list($namespace, $tagName) = SabreXml\Service::parseClarkNotation($xmlProperty['name']);
$propertyName = $tagName;
@@ -160,16 +178,17 @@ class XML extends Parser
$propertyType = 'text';
// A property which is not part of the standard.
- if (self::XCAL_NAMESPACE !== $namespace
- && self::XCARD_NAMESPACE !== $namespace) {
+ if ($namespace !== self::XCAL_NAMESPACE
+ && $namespace !== self::XCARD_NAMESPACE) {
+
$propertyName = 'xml';
- $value = '<'.$tagName.' xmlns="'.$namespace.'"';
+ $value = '<' . $tagName . ' xmlns="' . $namespace . '"';
foreach ($xmlProperty['attributes'] as $attributeName => $attributeValue) {
- $value .= ' '.$attributeName.'="'.str_replace('"', '\"', $attributeValue).'"';
+ $value .= ' ' . $attributeName . '="' . str_replace('"', '\"', $attributeValue) . '"';
}
- $value .= '>'.$xmlProperty['value'].'</'.$tagName.'>';
+ $value .= '>' . $xmlProperty['value'] . '</' . $tagName . '>';
$propertyValue = [$value];
@@ -185,7 +204,8 @@ class XML extends Parser
}
// xCard group.
- if ('group' === $propertyName) {
+ if ($propertyName === 'group') {
+
if (!isset($xmlProperty['attributes']['name'])) {
continue;
}
@@ -193,22 +213,24 @@ class XML extends Parser
$this->pointer = &$xmlProperty['value'];
$this->parseProperties(
$parentComponent,
- strtoupper($xmlProperty['attributes']['name']).'.'
+ strtoupper($xmlProperty['attributes']['name']) . '.'
);
continue;
+
}
// Collect parameters.
foreach ($xmlProperty['value'] as $i => $xmlPropertyChild) {
+
if (!is_array($xmlPropertyChild)
- || 'parameters' !== static::getTagName($xmlPropertyChild['name'])) {
+ || 'parameters' !== static::getTagName($xmlPropertyChild['name']))
continue;
- }
$xmlParameters = $xmlPropertyChild['value'];
foreach ($xmlParameters as $xmlParameter) {
+
$propertyParameterValues = [];
foreach ($xmlParameter['value'] as $xmlParameterValues) {
@@ -217,16 +239,19 @@ class XML extends Parser
$propertyParameters[static::getTagName($xmlParameter['name'])]
= implode(',', $propertyParameterValues);
+
}
array_splice($xmlProperty['value'], $i, 1);
+
}
$propertyNameExtended = ($this->root instanceof VCalendar
? 'xcal'
- : 'xcard').':'.$propertyName;
+ : 'xcard') . ':' . $propertyName;
switch ($propertyNameExtended) {
+
case 'xcal:geo':
$propertyType = 'float';
$propertyValue['latitude'] = 0;
@@ -252,7 +277,6 @@ class XML extends Parser
// We don't break because we only want to set
// another property type.
- // no break
case 'xcal:categories':
case 'xcal:resources':
case 'xcal:exdate':
@@ -266,12 +290,16 @@ class XML extends Parser
$propertyType = 'date-time';
foreach ($xmlProperty['value'] as $specialChild) {
+
$tagName = static::getTagName($specialChild['name']);
if ('period' === $tagName) {
+
$propertyParameters['value'] = 'PERIOD';
$propertyValue[] = implode('/', $specialChild['value']);
- } else {
+
+ }
+ else {
$propertyValue[] = $specialChild['value'];
}
}
@@ -292,24 +320,29 @@ class XML extends Parser
$this->createProperty(
$parentComponent,
- $propertyNamePrefix.$propertyName,
+ $propertyNamePrefix . $propertyName,
$propertyParameters,
$propertyType,
$propertyValue
);
+
}
+
}
/**
* Parse a component.
*
* @param Component $parentComponent
+ *
+ * @return void
*/
- protected function parseComponent(Component $parentComponent)
- {
+ protected function parseComponent(Component $parentComponent) {
+
$components = $this->pointer['value'] ?: [];
foreach ($components as $component) {
+
$componentName = static::getTagName($component['name']);
$currentComponent = $this->root->createComponent(
$componentName,
@@ -321,20 +354,24 @@ class XML extends Parser
$this->parseVCalendarComponents($currentComponent);
$parentComponent->add($currentComponent);
+
}
+
}
/**
* Create a property.
*
* @param Component $parentComponent
- * @param string $name
- * @param array $parameters
- * @param string $type
- * @param mixed $value
+ * @param string $name
+ * @param array $parameters
+ * @param string $type
+ * @param mixed $value
+ *
+ * @return void
*/
- protected function createProperty(Component $parentComponent, $name, $parameters, $type, $value)
- {
+ protected function createProperty(Component $parentComponent, $name, $parameters, $type, $value) {
+
$property = $this->root->createProperty(
$name,
null,
@@ -343,30 +380,36 @@ class XML extends Parser
);
$parentComponent->add($property);
$property->setXmlValue($value);
+
}
/**
* Sets the input data.
*
* @param resource|string $input
+ *
+ * @return void
*/
- public function setInput($input)
- {
+ function setInput($input) {
+
if (is_resource($input)) {
$input = stream_get_contents($input);
}
if (is_string($input)) {
+
$reader = new SabreXml\Reader();
- $reader->elementMap['{'.self::XCAL_NAMESPACE.'}period']
+ $reader->elementMap['{' . self::XCAL_NAMESPACE . '}period']
= 'Sabre\VObject\Parser\XML\Element\KeyValue';
- $reader->elementMap['{'.self::XCAL_NAMESPACE.'}recur']
+ $reader->elementMap['{' . self::XCAL_NAMESPACE . '}recur']
= 'Sabre\VObject\Parser\XML\Element\KeyValue';
$reader->xml($input);
$input = $reader->parse();
+
}
$this->input = $input;
+
}
/**
@@ -376,10 +419,10 @@ class XML extends Parser
*
* @return string
*/
- protected static function getTagName($clarkedTagName)
- {
- list(, $tagName) = SabreXml\Service::parseClarkNotation($clarkedTagName);
+ protected static function getTagName($clarkedTagName) {
+ list(, $tagName) = SabreXml\Service::parseClarkNotation($clarkedTagName);
return $tagName;
+
}
}
diff --git a/vendor/sabre/vobject/lib/Parser/XML/Element/KeyValue.php b/vendor/sabre/vobject/lib/Parser/XML/Element/KeyValue.php
index e26540036..14d798433 100644
--- a/vendor/sabre/vobject/lib/Parser/XML/Element/KeyValue.php
+++ b/vendor/sabre/vobject/lib/Parser/XML/Element/KeyValue.php
@@ -13,8 +13,8 @@ use Sabre\Xml as SabreXml;
* @author Ivan Enderlin
* @license http://sabre.io/license/ Modified BSD License
*/
-class KeyValue extends SabreXml\Element\KeyValue
-{
+class KeyValue extends SabreXml\Element\KeyValue {
+
/**
* The deserialize method is called during xml parsing.
*
@@ -37,12 +37,11 @@ class KeyValue extends SabreXml\Element\KeyValue
*
* @return mixed
*/
- public static function xmlDeserialize(SabreXml\Reader $reader)
- {
+ static function xmlDeserialize(SabreXml\Reader $reader) {
+
// If there's no children, we don't do anything.
if ($reader->isEmptyElement) {
$reader->next();
-
return [];
}
@@ -50,16 +49,22 @@ class KeyValue extends SabreXml\Element\KeyValue
$reader->read();
do {
- if (SabreXml\Reader::ELEMENT === $reader->nodeType) {
+
+ if ($reader->nodeType === SabreXml\Reader::ELEMENT) {
+
$name = $reader->localName;
$values[$name] = $reader->parseCurrentElement()['value'];
+
} else {
$reader->read();
}
- } while (SabreXml\Reader::END_ELEMENT !== $reader->nodeType);
+
+ } while ($reader->nodeType !== SabreXml\Reader::END_ELEMENT);
$reader->read();
return $values;
+
}
+
}