aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/lib/Parser
diff options
context:
space:
mode:
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, 170 insertions, 257 deletions
diff --git a/vendor/sabre/vobject/lib/Parser/Json.php b/vendor/sabre/vobject/lib/Parser/Json.php
index a77258a2e..3fd307e97 100644
--- a/vendor/sabre/vobject/lib/Parser/Json.php
+++ b/vendor/sabre/vobject/lib/Parser/Json.php
@@ -4,6 +4,7 @@ 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;
@@ -16,8 +17,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.
*
@@ -41,12 +42,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
*/
- function parse($input = null, $options = 0) {
-
+ public function parse($input = null, $options = 0)
+ {
if (!is_null($input)) {
$this->setInput($input);
}
@@ -59,28 +60,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;
-
}
/**
@@ -90,35 +91,34 @@ class Json extends Parser {
*
* @return \Sabre\VObject\Component
*/
- function parseComponent(array $jComp) {
-
+ public 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
*/
- function parseProperty(array $jProp) {
-
+ public 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 ($defaultPropertyClass === 'Sabre\VObject\Property\FlatText') {
+ if ('Sabre\VObject\Property\FlatText' === $defaultPropertyClass) {
$defaultPropertyClass = 'Sabre\VObject\Property\Text';
}
@@ -168,22 +168,19 @@ 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
*/
- function setInput($input) {
-
+ public function setInput($input)
+ {
if (is_resource($input)) {
$input = stream_get_contents($input);
}
@@ -191,7 +188,5 @@ 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 742641236..10dcec89c 100644
--- a/vendor/sabre/vobject/lib/Parser/MimeDir.php
+++ b/vendor/sabre/vobject/lib/Parser/MimeDir.php
@@ -7,6 +7,7 @@ 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;
/**
@@ -22,8 +23,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.
*
@@ -70,12 +71,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
*/
- function parse($input = null, $options = 0) {
-
+ public function parse($input = null, $options = 0)
+ {
$this->root = null;
if (!is_null($input)) {
@@ -89,7 +90,6 @@ class MimeDir extends Parser {
$this->parseDocument();
return $this->root;
-
}
/**
@@ -104,24 +104,21 @@ class MimeDir extends Parser {
*
* @param string $charset
*/
- function setCharset($charset) {
-
+ public 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
*/
- function setInput($input) {
-
+ public function setInput($input)
+ {
// Resetting the parser
$this->lineIndex = 0;
$this->startLine = 0;
@@ -137,59 +134,53 @@ 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)
- && ord($line[0]) === 0xef
- && ord($line[1]) === 0xbb
- && ord($line[2]) === 0xbf) {
+ && 0xef === ord($line[0])
+ && 0xbb === ord($line[1])
+ && 0xbf === ord($line[2])) {
$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 (strtoupper(substr($line, 0, 4)) === 'END:') {
+ if ('END:' === strtoupper(substr($line, 0, 4))) {
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.'"');
}
-
}
/**
@@ -200,46 +191,40 @@ class MimeDir extends Parser {
*
* @return Node
*/
- protected function parseLine($line) {
-
+ protected function parseLine($line)
+ {
// Start of a new component
- if (strtoupper(substr($line, 0, 6)) === 'BEGIN:') {
-
+ if ('BEGIN:' === strtoupper(substr($line, 0, 6))) {
$component = $this->root->createComponent(substr($line, 6), [], false);
while (true) {
-
// Reading until we hit END:
$line = $this->readLine();
- if (strtoupper(substr($line, 0, 4)) === 'END:') {
+ if ('END:' === strtoupper(substr($line, 0, 4))) {
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;
+ return $property;
}
-
}
/**
@@ -248,7 +233,7 @@ class MimeDir extends Parser {
*
* If that was not the case, we store it here.
*
- * @var null|string
+ * @var string|null
*/
protected $lineBuffer;
@@ -281,8 +266,8 @@ class MimeDir extends Parser {
*
* @return string
*/
- protected function readLine() {
-
+ protected function readLine()
+ {
if (!\is_null($this->lineBuffer)) {
$rawLine = $this->lineBuffer;
$this->lineBuffer = null;
@@ -292,15 +277,15 @@ class MimeDir extends Parser {
$rawLine = \fgets($this->input);
- if ($eof || (\feof($this->input) && $rawLine === false)) {
+ if ($eof || (\feof($this->input) && false === $rawLine)) {
throw new EofException('End of document reached prematurely');
}
- if ($rawLine === false) {
+ if (false === $rawLine) {
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;
@@ -308,34 +293,30 @@ 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 ($nextLine[0] === "\t" || $nextLine[0] === " ") {
+ if ("\t" === $nextLine[0] || ' ' === $nextLine[0]) {
$curLine = \substr($nextLine, 1);
$line .= $curLine;
- $rawLine .= "\n " . $curLine;
+ $rawLine .= "\n ".$curLine;
} else {
$this->lineBuffer = $nextLine;
break;
}
-
}
$this->rawLine = $rawLine;
- return $line;
+ 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 {
@@ -360,17 +341,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
@@ -378,9 +359,8 @@ 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'];
@@ -389,7 +369,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;
@@ -398,7 +378,7 @@ class MimeDir extends Parser {
} else {
$property['parameters'][$lastParam] = [
$property['parameters'][$lastParam],
- $value
+ $value,
];
}
continue;
@@ -422,7 +402,6 @@ class MimeDir extends Parser {
// @codeCoverageIgnoreStart
throw new \LogicException('This code should not be reachable');
// @codeCoverageIgnoreEnd
-
}
if (is_null($property['value'])) {
@@ -432,11 +411,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 it's name.
+ // a value. We can deduce the value based on its name.
//
// Our parser will get those as parameters without a value instead, so
// we're filtering these parameters out first.
@@ -457,31 +436,30 @@ class MimeDir extends Parser {
$propObj->add(null, $namelessParameter);
}
- if (strtoupper($propObj['ENCODING']) === 'QUOTED-PRINTABLE') {
+ if ('QUOTED-PRINTABLE' === strtoupper($propObj['ENCODING'])) {
$propObj->setQuotedPrintableValue($this->extractQuotedPrintableValue());
} else {
$charset = $this->charset;
- if ($this->root->getDocumentType() === Document::VCARD21 && isset($propObj['CHARSET'])) {
+ if (Document::VCARD21 === $this->root->getDocumentType() && 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;
-
}
/**
@@ -546,11 +524,11 @@ class MimeDir extends Parser {
*
* @return string|string[]
*/
- static function unescapeValue($input, $delimiter = ';') {
-
+ public static function unescapeValue($input, $delimiter = ';')
+ {
$regex = '# (?: (\\\\ (?: \\\\ | N | n | ; | , ) )';
if ($delimiter) {
- $regex .= ' | (' . $delimiter . ')';
+ $regex .= ' | ('.$delimiter.')';
}
$regex .= ') #x';
@@ -560,36 +538,33 @@ 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;
+ return $delimiter ? $resultArray : $result;
}
/**
@@ -623,21 +598,19 @@ 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
@@ -658,8 +631,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
@@ -682,16 +655,14 @@ 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 ca8bc0add..b7b611430 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,12 +41,10 @@ abstract class Parser {
* Optionally, it's possible to parse the input stream here.
*
* @param mixed $input
- * @param int $options Any parser options (OPTION constants).
- *
- * @return void
+ * @param int $options any parser options (OPTION constants)
*/
- function __construct($input = null, $options = 0) {
-
+ public function __construct($input = null, $options = 0)
+ {
if (!is_null($input)) {
$this->setInput($input);
}
@@ -62,19 +60,16 @@ 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 function parse($input = null, $options = 0);
+ abstract public function parse($input = null, $options = 0);
/**
* Sets the input data.
*
* @param mixed $input
- *
- * @return void
*/
- abstract function setInput($input);
-
+ abstract public function setInput($input);
}
diff --git a/vendor/sabre/vobject/lib/Parser/XML.php b/vendor/sabre/vobject/lib/Parser/XML.php
index 5ac423984..90f262d9e 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,32 +50,29 @@ 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).
- *
- * @return void
+ * @param int $options any parser options (OPTION constants)
*/
- function __construct($input = null, $options = 0) {
-
+ public 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
*/
- function parse($input = null, $options = 0) {
-
+ public function parse($input = null, $options = 0)
+ {
if (!is_null($input)) {
$this->setInput($input);
}
@@ -89,29 +86,25 @@ 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;
@@ -121,15 +114,11 @@ 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);
@@ -141,35 +130,28 @@ 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
- *
- * @return void
+ * @param string $propertyNamePrefix
*/
- 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;
@@ -178,17 +160,16 @@ class XML extends Parser {
$propertyType = 'text';
// A property which is not part of the standard.
- if ($namespace !== self::XCAL_NAMESPACE
- && $namespace !== self::XCARD_NAMESPACE) {
-
+ if (self::XCAL_NAMESPACE !== $namespace
+ && self::XCARD_NAMESPACE !== $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];
@@ -204,8 +185,7 @@ class XML extends Parser {
}
// xCard group.
- if ($propertyName === 'group') {
-
+ if ('group' === $propertyName) {
if (!isset($xmlProperty['attributes']['name'])) {
continue;
}
@@ -213,24 +193,22 @@ 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) {
@@ -239,19 +217,16 @@ 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;
@@ -277,6 +252,7 @@ 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':
@@ -290,16 +266,12 @@ 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'];
}
}
@@ -320,29 +292,24 @@ 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,
@@ -354,24 +321,20 @@ 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
- *
- * @return void
+ * @param string $name
+ * @param array $parameters
+ * @param string $type
+ * @param mixed $value
*/
- protected function createProperty(Component $parentComponent, $name, $parameters, $type, $value) {
-
+ protected function createProperty(Component $parentComponent, $name, $parameters, $type, $value)
+ {
$property = $this->root->createProperty(
$name,
null,
@@ -380,36 +343,30 @@ class XML extends Parser {
);
$parentComponent->add($property);
$property->setXmlValue($value);
-
}
/**
* Sets the input data.
*
* @param resource|string $input
- *
- * @return void
*/
- function setInput($input) {
-
+ public 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;
-
}
/**
@@ -419,10 +376,10 @@ class XML extends Parser {
*
* @return string
*/
- protected static function getTagName($clarkedTagName) {
-
+ protected static function getTagName($clarkedTagName)
+ {
list(, $tagName) = SabreXml\Service::parseClarkNotation($clarkedTagName);
- return $tagName;
+ 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 14d798433..e26540036 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,11 +37,12 @@ class KeyValue extends SabreXml\Element\KeyValue {
*
* @return mixed
*/
- static function xmlDeserialize(SabreXml\Reader $reader) {
-
+ public static function xmlDeserialize(SabreXml\Reader $reader)
+ {
// If there's no children, we don't do anything.
if ($reader->isEmptyElement) {
$reader->next();
+
return [];
}
@@ -49,22 +50,16 @@ class KeyValue extends SabreXml\Element\KeyValue {
$reader->read();
do {
-
- if ($reader->nodeType === SabreXml\Reader::ELEMENT) {
-
+ if (SabreXml\Reader::ELEMENT === $reader->nodeType) {
$name = $reader->localName;
$values[$name] = $reader->parseCurrentElement()['value'];
-
} else {
$reader->read();
}
-
- } while ($reader->nodeType !== SabreXml\Reader::END_ELEMENT);
+ } while (SabreXml\Reader::END_ELEMENT !== $reader->nodeType);
$reader->read();
return $values;
-
}
-
}