aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/lib/Property.php
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/Property.php
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/Property.php')
-rw-r--r--vendor/sabre/vobject/lib/Property.php268
1 files changed, 154 insertions, 114 deletions
diff --git a/vendor/sabre/vobject/lib/Property.php b/vendor/sabre/vobject/lib/Property.php
index 6105cb0f0..3d1775fa2 100644
--- a/vendor/sabre/vobject/lib/Property.php
+++ b/vendor/sabre/vobject/lib/Property.php
@@ -14,8 +14,8 @@ use Sabre\Xml;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-abstract class Property extends Node
-{
+abstract class Property extends Node {
+
/**
* Property name.
*
@@ -61,14 +61,16 @@ abstract class Property extends Node
*
* Parameters must be specified in key=>value syntax.
*
- * @param Component $root The root document
- * @param string $name
+ * @param Component $root The root document
+ * @param string $name
* @param string|array|null $value
- * @param array $parameters List of parameters
- * @param string $group The vcard property group
+ * @param array $parameters List of parameters
+ * @param string $group The vcard property group
+ *
+ * @return void
*/
- public function __construct(Component $root, $name, $value = null, array $parameters = [], $group = null)
- {
+ function __construct(Component $root, $name, $value = null, array $parameters = [], $group = null) {
+
$this->name = $name;
$this->group = $group;
@@ -81,6 +83,7 @@ abstract class Property extends Node
if (!is_null($value)) {
$this->setValue($value);
}
+
}
/**
@@ -89,10 +92,13 @@ abstract class Property extends Node
* This may be either a single, or multiple strings in an array.
*
* @param string|array $value
+ *
+ * @return void
*/
- public function setValue($value)
- {
+ function setValue($value) {
+
$this->value = $value;
+
}
/**
@@ -106,12 +112,12 @@ abstract class Property extends Node
*
* @return string
*/
- public function getValue()
- {
+ function getValue() {
+
if (is_array($this->value)) {
- if (0 == count($this->value)) {
+ if (count($this->value) == 0) {
return;
- } elseif (1 === count($this->value)) {
+ } elseif (count($this->value) === 1) {
return $this->value[0];
} else {
return $this->getRawMimeDirValue();
@@ -119,16 +125,20 @@ abstract class Property extends Node
} else {
return $this->value;
}
+
}
/**
* Sets a multi-valued property.
*
* @param array $parts
+ *
+ * @return void
*/
- public function setParts(array $parts)
- {
+ function setParts(array $parts) {
+
$this->value = $parts;
+
}
/**
@@ -139,8 +149,8 @@ abstract class Property extends Node
*
* @return array
*/
- public function getParts()
- {
+ function getParts() {
+
if (is_null($this->value)) {
return [];
} elseif (is_array($this->value)) {
@@ -148,6 +158,7 @@ abstract class Property extends Node
} else {
return [$this->value];
}
+
}
/**
@@ -155,22 +166,22 @@ abstract class Property extends Node
*
* If a parameter with same name already existed, the values will be
* combined.
- * If nameless parameter is added, we try to guess its name.
+ * If nameless parameter is added, we try to guess it's name.
*
- * @param string $name
- * @param string|array|null $value
+ * @param string $name
+ * @param string|null|array $value
*/
- public function add($name, $value = null)
- {
+ function add($name, $value = null) {
$noName = false;
- if (null === $name) {
+ if ($name === null) {
$name = Parameter::guessParameterNameByValue($value);
$noName = true;
}
if (isset($this->parameters[strtoupper($name)])) {
$this->parameters[strtoupper($name)]->addValue($value);
- } else {
+ }
+ else {
$param = new Parameter($this->root, $name, $value);
$param->noName = $noName;
$this->parameters[$param->name] = $param;
@@ -182,9 +193,10 @@ abstract class Property extends Node
*
* @return array
*/
- public function parameters()
- {
+ function parameters() {
+
return $this->parameters;
+
}
/**
@@ -195,7 +207,7 @@ abstract class Property extends Node
*
* @return string
*/
- abstract public function getValueType();
+ abstract function getValueType();
/**
* Sets a raw value coming from a mimedir (iCalendar/vCard) file.
@@ -204,33 +216,35 @@ abstract class Property extends Node
* not yet done, but parameters are not included.
*
* @param string $val
+ *
+ * @return void
*/
- abstract public function setRawMimeDirValue($val);
+ abstract function setRawMimeDirValue($val);
/**
* Returns a raw mime-dir representation of the value.
*
* @return string
*/
- abstract public function getRawMimeDirValue();
+ abstract function getRawMimeDirValue();
/**
* Turns the object back into a serialized blob.
*
* @return string
*/
- public function serialize()
- {
+ function serialize() {
+
$str = $this->name;
- if ($this->group) {
- $str = $this->group.'.'.$this->name;
- }
+ if ($this->group) $str = $this->group . '.' . $this->name;
foreach ($this->parameters() as $param) {
- $str .= ';'.$param->serialize();
+
+ $str .= ';' . $param->serialize();
+
}
- $str .= ':'.$this->getRawMimeDirValue();
+ $str .= ':' . $this->getRawMimeDirValue();
$str = \preg_replace(
'/(
@@ -244,6 +258,7 @@ abstract class Property extends Node
// remove single space after last CRLF
return \substr($str, 0, -1);
+
}
/**
@@ -253,9 +268,10 @@ abstract class Property extends Node
*
* @return array
*/
- public function getJsonValue()
- {
+ function getJsonValue() {
+
return $this->getParts();
+
}
/**
@@ -264,14 +280,17 @@ abstract class Property extends Node
* The value must always be an array.
*
* @param array $value
+ *
+ * @return void
*/
- public function setJsonValue(array $value)
- {
- if (1 === count($value)) {
+ function setJsonValue(array $value) {
+
+ if (count($value) === 1) {
$this->setValue(reset($value));
} else {
$this->setValue($value);
}
+
}
/**
@@ -280,12 +299,12 @@ abstract class Property extends Node
*
* @return array
*/
- public function jsonSerialize()
- {
+ function jsonSerialize() {
+
$parameters = [];
foreach ($this->parameters as $parameter) {
- if ('VALUE' === $parameter->name) {
+ if ($parameter->name === 'VALUE') {
continue;
}
$parameters[strtolower($parameter->name)] = $parameter->jsonSerialize();
@@ -299,7 +318,7 @@ abstract class Property extends Node
return array_merge(
[
strtolower($this->name),
- (object) $parameters,
+ (object)$parameters,
strtolower($this->getValueType()),
],
$this->getJsonValue()
@@ -311,63 +330,78 @@ abstract class Property extends Node
* object.
*
* @param array $value
+ *
+ * @return void
*/
- public function setXmlValue(array $value)
- {
+ function setXmlValue(array $value) {
+
$this->setJsonValue($value);
+
}
/**
* This method serializes the data into XML. This is used to create xCard or
* xCal documents.
*
- * @param Xml\Writer $writer XML writer
+ * @param Xml\Writer $writer XML writer.
+ *
+ * @return void
*/
- public function xmlSerialize(Xml\Writer $writer)
- {
+ function xmlSerialize(Xml\Writer $writer) {
+
$parameters = [];
foreach ($this->parameters as $parameter) {
- if ('VALUE' === $parameter->name) {
+
+ if ($parameter->name === 'VALUE') {
continue;
}
$parameters[] = $parameter;
+
}
$writer->startElement(strtolower($this->name));
if (!empty($parameters)) {
+
$writer->startElement('parameters');
foreach ($parameters as $parameter) {
+
$writer->startElement(strtolower($parameter->name));
$writer->write($parameter);
$writer->endElement();
+
}
$writer->endElement();
+
}
$this->xmlSerializeValue($writer);
$writer->endElement();
+
}
/**
* This method serializes only the value of a property. This is used to
* create xCard or xCal documents.
*
- * @param Xml\Writer $writer XML writer
+ * @param Xml\Writer $writer XML writer.
+ *
+ * @return void
*/
- protected function xmlSerializeValue(Xml\Writer $writer)
- {
+ protected function xmlSerializeValue(Xml\Writer $writer) {
+
$valueType = strtolower($this->getValueType());
foreach ($this->getJsonValue() as $values) {
- foreach ((array) $values as $value) {
+ foreach ((array)$values as $value) {
$writer->writeElement($valueType, $value);
}
}
+
}
/**
@@ -379,9 +413,10 @@ abstract class Property extends Node
*
* @return string
*/
- public function __toString()
- {
- return (string) $this->getValue();
+ function __toString() {
+
+ return (string)$this->getValue();
+
}
/* ArrayAccess interface {{{ */
@@ -393,21 +428,17 @@ abstract class Property extends Node
*
* @return bool
*/
- public function offsetExists($name)
- {
- if (is_int($name)) {
- return parent::offsetExists($name);
- }
+ function offsetExists($name) {
+
+ if (is_int($name)) return parent::offsetExists($name);
$name = strtoupper($name);
foreach ($this->parameters as $parameter) {
- if ($parameter->name == $name) {
- return true;
- }
+ if ($parameter->name == $name) return true;
}
-
return false;
+
}
/**
@@ -419,11 +450,9 @@ abstract class Property extends Node
*
* @return Node
*/
- public function offsetGet($name)
- {
- if (is_int($name)) {
- return parent::offsetGet($name);
- }
+ function offsetGet($name) {
+
+ if (is_int($name)) return parent::offsetGet($name);
$name = strtoupper($name);
if (!isset($this->parameters[$name])) {
@@ -431,16 +460,19 @@ abstract class Property extends Node
}
return $this->parameters[$name];
+
}
/**
* Creates a new parameter.
*
* @param string $name
- * @param mixed $value
+ * @param mixed $value
+ *
+ * @return void
*/
- public function offsetSet($name, $value)
- {
+ function offsetSet($name, $value) {
+
if (is_int($name)) {
parent::offsetSet($name, $value);
// @codeCoverageIgnoreStart
@@ -452,15 +484,18 @@ abstract class Property extends Node
$param = new Parameter($this->root, $name, $value);
$this->parameters[$param->name] = $param;
+
}
/**
* Removes one or more parameters with the specified name.
*
* @param string $name
+ *
+ * @return void
*/
- public function offsetUnset($name)
- {
+ function offsetUnset($name) {
+
if (is_int($name)) {
parent::offsetUnset($name);
// @codeCoverageIgnoreStart
@@ -471,20 +506,23 @@ abstract class Property extends Node
}
unset($this->parameters[strtoupper($name)]);
- }
+ }
/* }}} */
/**
* This method is automatically called when the object is cloned.
* Specifically, this will ensure all child elements are also cloned.
+ *
+ * @return void
*/
- public function __clone()
- {
+ function __clone() {
+
foreach ($this->parameters as $key => $child) {
$this->parameters[$key] = clone $child;
$this->parameters[$key]->parent = $this;
}
+
}
/**
@@ -505,12 +543,13 @@ abstract class Property extends Node
*
* @return array
*/
- public function validate($options = 0)
- {
+ function validate($options = 0) {
+
$warnings = [];
// Checking if our value is UTF-8
if (!StringUtil::isUTF8($this->getRawMimeDirValue())) {
+
$oldValue = $this->getRawMimeDirValue();
$level = 3;
if ($options & self::REPAIR) {
@@ -519,27 +558,29 @@ abstract class Property extends Node
$this->setRawMimeDirValue($newValue);
$level = 1;
}
+
}
+
if (preg_match('%([\x00-\x08\x0B-\x0C\x0E-\x1F\x7F])%', $oldValue, $matches)) {
- $message = 'Property contained a control character (0x'.bin2hex($matches[1]).')';
+ $message = 'Property contained a control character (0x' . bin2hex($matches[1]) . ')';
} else {
- $message = 'Property is not valid UTF-8! '.$oldValue;
+ $message = 'Property is not valid UTF-8! ' . $oldValue;
}
$warnings[] = [
- 'level' => $level,
+ 'level' => $level,
'message' => $message,
- 'node' => $this,
+ 'node' => $this,
];
}
// Checking if the propertyname does not contain any invalid bytes.
if (!preg_match('/^([A-Z0-9-]+)$/', $this->name)) {
$warnings[] = [
- 'level' => $options & self::REPAIR ? 1 : 3,
- 'message' => 'The propertyname: '.$this->name.' contains invalid characters. Only A-Z, 0-9 and - are allowed',
- 'node' => $this,
+ 'level' => $options & self::REPAIR ? 1 : 3,
+ 'message' => 'The propertyname: ' . $this->name . ' contains invalid characters. Only A-Z, 0-9 and - are allowed',
+ 'node' => $this,
];
if ($options & self::REPAIR) {
// Uppercasing and converting underscores to dashes.
@@ -548,52 +589,46 @@ abstract class Property extends Node
);
// Removing every other invalid character
$this->name = preg_replace('/([^A-Z0-9-])/u', '', $this->name);
+
}
+
}
if ($encoding = $this->offsetGet('ENCODING')) {
- if (Document::VCARD40 === $this->root->getDocumentType()) {
+
+ if ($this->root->getDocumentType() === Document::VCARD40) {
$warnings[] = [
- 'level' => 3,
+ 'level' => 3,
'message' => 'ENCODING parameter is not valid in vCard 4.',
- 'node' => $this,
+ 'node' => $this
];
} else {
- $encoding = (string) $encoding;
+
+ $encoding = (string)$encoding;
$allowedEncoding = [];
switch ($this->root->getDocumentType()) {
- case Document::ICALENDAR20:
+ case Document::ICALENDAR20 :
$allowedEncoding = ['8BIT', 'BASE64'];
break;
- case Document::VCARD21:
+ case Document::VCARD21 :
$allowedEncoding = ['QUOTED-PRINTABLE', 'BASE64', '8BIT'];
break;
- case Document::VCARD30:
+ case Document::VCARD30 :
$allowedEncoding = ['B'];
- //Repair vCard30 that use BASE64 encoding
- if ($options & self::REPAIR) {
- if ('BASE64' === strtoupper($encoding)) {
- $encoding = 'B';
- $this['ENCODING'] = $encoding;
- $warnings[] = [
- 'level' => 1,
- 'message' => 'ENCODING=BASE64 has been transformed to ENCODING=B.',
- 'node' => $this,
- ];
- }
- }
break;
+
}
if ($allowedEncoding && !in_array(strtoupper($encoding), $allowedEncoding)) {
$warnings[] = [
- 'level' => 3,
- 'message' => 'ENCODING='.strtoupper($encoding).' is not valid for this document type.',
- 'node' => $this,
+ 'level' => 3,
+ 'message' => 'ENCODING=' . strtoupper($encoding) . ' is not valid for this document type.',
+ 'node' => $this
];
}
}
+
}
// Validating inner parameters
@@ -602,6 +637,7 @@ abstract class Property extends Node
}
return $warnings;
+
}
/**
@@ -609,13 +645,17 @@ abstract class Property extends Node
*
* It's intended to remove all circular references, so PHP can easily clean
* it up.
+ *
+ * @return void
*/
- public function destroy()
- {
+ function destroy() {
+
parent::destroy();
foreach ($this->parameters as $param) {
$param->destroy();
}
$this->parameters = [];
+
}
+
}