From f1c07977809ce3221286d53e99f0d91145b1166f Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 25 Apr 2019 11:24:09 +0200 Subject: Revert "update composer libs" This reverts commit e779335d060b3a51d6a144d23af4097ae6801473 --- vendor/sabre/vobject/lib/Document.php | 94 +++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 44 deletions(-) (limited to 'vendor/sabre/vobject/lib/Document.php') diff --git a/vendor/sabre/vobject/lib/Document.php b/vendor/sabre/vobject/lib/Document.php index 0cb2e0978..03252ab06 100644 --- a/vendor/sabre/vobject/lib/Document.php +++ b/vendor/sabre/vobject/lib/Document.php @@ -16,8 +16,8 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Document extends Component -{ +abstract class Document extends Component { + /** * Unknown document type. */ @@ -55,28 +55,28 @@ abstract class Document extends Component * * @var string */ - public static $defaultName; + static $defaultName; /** * List of properties, and which classes they map to. * * @var array */ - public static $propertyMap = []; + static $propertyMap = []; /** * List of components, along with which classes they map to. * * @var array */ - public static $componentMap = []; + static $componentMap = []; /** * List of value-types, and which classes they map to. * * @var array */ - public static $valueMap = []; + static $valueMap = []; /** * Creates a new document. @@ -91,20 +91,20 @@ abstract class Document extends Component * * new Document(array $children = [], $defaults = true); * new Document(string $name, array $children = [], $defaults = true) + * + * @return void */ - public function __construct() - { + function __construct() { + $args = func_get_args(); - $name = static::$defaultName; - if (0 === count($args) || is_array($args[0])) { - $children = isset($args[0]) ? $args[0] : []; - $defaults = isset($args[1]) ? $args[1] : true; + if (count($args) === 0 || is_array($args[0])) { + array_unshift($args, $this, static::$defaultName); + call_user_func_array(['parent', '__construct'], $args); } else { - $name = $args[0]; - $children = isset($args[1]) ? $args[1] : []; - $defaults = isset($args[2]) ? $args[2] : true; + array_unshift($args, $this); + call_user_func_array(['parent', '__construct'], $args); } - parent::__construct($this, $name, $children, $defaults); + } /** @@ -112,9 +112,10 @@ abstract class Document extends Component * * @return int */ - public function getDocumentType() - { + function getDocumentType() { + return self::UNKNOWN; + } /** @@ -128,13 +129,18 @@ abstract class Document extends Component * * @return mixed */ - public function create($name) - { + function create($name) { + if (isset(static::$componentMap[strtoupper($name)])) { + return call_user_func_array([$this, 'createComponent'], func_get_args()); + } else { + return call_user_func_array([$this, 'createProperty'], func_get_args()); + } + } /** @@ -152,24 +158,22 @@ abstract class Document extends Component * ensure that this does not happen, set $defaults to false. * * @param string $name - * @param array $children - * @param bool $defaults + * @param array $children + * @param bool $defaults * * @return Component */ - public function createComponent($name, array $children = null, $defaults = true) - { + function createComponent($name, array $children = null, $defaults = true) { + $name = strtoupper($name); $class = 'Sabre\\VObject\\Component'; if (isset(static::$componentMap[$name])) { $class = static::$componentMap[$name]; } - if (is_null($children)) { - $children = []; - } - + if (is_null($children)) $children = []; return new $class($this, $name, $children, $defaults); + } /** @@ -183,16 +187,16 @@ abstract class Document extends Component * Parameter objects. * * @param string $name - * @param mixed $value - * @param array $parameters - * @param string $valueType Force a specific valuetype, such as URI or TEXT + * @param mixed $value + * @param array $parameters + * @param string $valueType Force a specific valuetype, such as URI or TEXT * * @return Property */ - public function createProperty($name, $value = null, array $parameters = null, $valueType = null) - { + function createProperty($name, $value = null, array $parameters = null, $valueType = null) { + // If there's a . in the name, it means it's prefixed by a groupname. - if (false !== ($i = strpos($name, '.'))) { + if (($i = strpos($name, '.')) !== false) { $group = substr($name, 0, $i); $name = strtoupper(substr($name, $i + 1)); } else { @@ -213,17 +217,17 @@ abstract class Document extends Component if (isset($parameters['VALUE'])) { $class = $this->getClassNameForPropertyValue($parameters['VALUE']); if (is_null($class)) { - throw new InvalidDataException('Unsupported VALUE parameter for '.$name.' property. You supplied "'.$parameters['VALUE'].'"'); + throw new InvalidDataException('Unsupported VALUE parameter for ' . $name . ' property. You supplied "' . $parameters['VALUE'] . '"'); } - } else { + } + else { $class = $this->getClassNameForPropertyName($name); } } - if (is_null($parameters)) { - $parameters = []; - } + if (is_null($parameters)) $parameters = []; return new $class($this, $name, $value, $parameters, $group); + } /** @@ -235,15 +239,15 @@ abstract class Document extends Component * This method returns null if we don't have a specialized class. * * @param string $valueParam - * * @return string|null */ - public function getClassNameForPropertyValue($valueParam) - { + function getClassNameForPropertyValue($valueParam) { + $valueParam = strtoupper($valueParam); if (isset(static::$valueMap[$valueParam])) { return static::$valueMap[$valueParam]; } + } /** @@ -253,12 +257,14 @@ abstract class Document extends Component * * @return string */ - public function getClassNameForPropertyName($propertyName) - { + function getClassNameForPropertyName($propertyName) { + if (isset(static::$propertyMap[$propertyName])) { return static::$propertyMap[$propertyName]; } else { return 'Sabre\\VObject\\Property\\Unknown'; } + } + } -- cgit v1.2.3