diff options
Diffstat (limited to 'vendor/sabre/dav/lib/DAVACL/Xml/Property')
5 files changed, 137 insertions, 167 deletions
diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php index 0e1c30ccf..372f62ab3 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\DAV; @@ -25,10 +27,10 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Acl implements Element, HtmlOutput { - +class Acl implements Element, HtmlOutput +{ /** - * List of privileges + * List of privileges. * * @var array */ @@ -43,7 +45,7 @@ class Acl implements Element, HtmlOutput { protected $prefixBaseUrl; /** - * Constructor + * Constructor. * * This object requires a structure similar to the return value from * Sabre\DAVACL\Plugin::getACL(). @@ -57,24 +59,22 @@ class Acl implements Element, HtmlOutput { * will automatically be prefixed. * * @param array $privileges - * @param bool $prefixBaseUrl + * @param bool $prefixBaseUrl */ - function __construct(array $privileges, $prefixBaseUrl = true) { - + public function __construct(array $privileges, $prefixBaseUrl = true) + { $this->privileges = $privileges; $this->prefixBaseUrl = $prefixBaseUrl; - } /** - * Returns the list of privileges for this property + * Returns the list of privileges for this property. * * @return array */ - function getPrivileges() { - + public function getPrivileges() + { return $this->privileges; - } /** @@ -94,16 +94,12 @@ class Acl implements Element, HtmlOutput { * 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) + { foreach ($this->privileges as $ace) { - $this->serializeAce($writer, $ace); - } - } /** @@ -118,32 +114,33 @@ class Acl implements Element, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { ob_start(); - echo "<table>"; - echo "<tr><th>Principal</th><th>Privilege</th><th></th></tr>"; + echo '<table>'; + echo '<tr><th>Principal</th><th>Privilege</th><th></th></tr>'; foreach ($this->privileges as $privilege) { - echo '<tr>'; // if it starts with a {, it's a special principal - if ($privilege['principal'][0] === '{') { + if ('{' === $privilege['principal'][0]) { echo '<td>', $html->xmlName($privilege['principal']), '</td>'; } else { echo '<td>', $html->link($privilege['principal']), '</td>'; } echo '<td>', $html->xmlName($privilege['privilege']), '</td>'; echo '<td>'; - if (!empty($privilege['protected'])) echo '(protected)'; + if (!empty($privilege['protected'])) { + echo '(protected)'; + } echo '</td>'; echo '</tr>'; - } - echo "</table>"; - return ob_get_clean(); + echo '</table>'; + return ob_get_clean(); } /** @@ -165,21 +162,21 @@ class Acl implements Element, HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elementMap = [ - '{DAV:}ace' => 'Sabre\Xml\Element\KeyValue', + '{DAV:}ace' => 'Sabre\Xml\Element\KeyValue', '{DAV:}privilege' => 'Sabre\Xml\Element\Elements', '{DAV:}principal' => 'Sabre\DAVACL\Xml\Property\Principal', ]; $privileges = []; - foreach ((array)$reader->parseInnerTree($elementMap) as $element) { - - if ($element['name'] !== '{DAV:}ace') { + foreach ((array) $reader->parseInnerTree($elementMap) as $element) { + if ('{DAV:}ace' !== $element['name']) { continue; } $ace = $element['value']; @@ -190,19 +187,18 @@ class Acl implements Element, HtmlOutput { $principal = $ace['{DAV:}principal']; switch ($principal->getType()) { - case Principal::HREF : + case Principal::HREF: $principal = $principal->getHref(); break; - case Principal::AUTHENTICATED : + case Principal::AUTHENTICATED: $principal = '{DAV:}authenticated'; break; - case Principal::UNAUTHENTICATED : + case Principal::UNAUTHENTICATED: $principal = '{DAV:}unauthenticated'; break; - case Principal::ALL : + case Principal::ALL: $principal = '{DAV:}all'; break; - } $protected = array_key_exists('{DAV:}protected', $ace); @@ -211,7 +207,7 @@ class Acl implements Element, HtmlOutput { throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported'); } foreach ($ace['{DAV:}grant'] as $elem) { - if ($elem['name'] !== '{DAV:}privilege') { + if ('{DAV:}privilege' !== $elem['name']) { continue; } @@ -222,34 +218,30 @@ class Acl implements Element, HtmlOutput { 'privilege' => $priv, ]; } - } - } return new self($privileges); - } /** * Serializes a single access control entry. * * @param Writer $writer - * @param array $ace - * @return void + * @param array $ace */ - private function serializeAce(Writer $writer, array $ace) { - + private function serializeAce(Writer $writer, array $ace) + { $writer->startElement('{DAV:}ace'); switch ($ace['principal']) { - case '{DAV:}authenticated' : + case '{DAV:}authenticated': $principal = new Principal(Principal::AUTHENTICATED); break; - case '{DAV:}unauthenticated' : + case '{DAV:}unauthenticated': $principal = new Principal(Principal::UNAUTHENTICATED); break; - case '{DAV:}all' : + case '{DAV:}all': $principal = new Principal(Principal::ALL); break; default: @@ -271,7 +263,5 @@ class Acl implements Element, HtmlOutput { } $writer->endElement(); // ace - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php index 8d5854c23..0bf16b431 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * AclRestrictions property + * AclRestrictions property. * * This property represents {DAV:}acl-restrictions, as defined in RFC3744. * @@ -14,8 +16,8 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AclRestrictions implements XmlSerializable { - +class AclRestrictions implements XmlSerializable +{ /** * The xmlSerialize method is called during xml writing. * @@ -33,13 +35,10 @@ class AclRestrictions implements XmlSerializable { * 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) + { $writer->writeElement('{DAV:}grant-only'); $writer->writeElement('{DAV:}no-invert'); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php index 74c09cee1..083856330 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -9,7 +11,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * CurrentUserPrivilegeSet + * CurrentUserPrivilegeSet. * * This class represents the current-user-privilege-set property. When * requested, it contain all the privileges a user has on a specific node. @@ -18,26 +20,25 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CurrentUserPrivilegeSet implements Element, HtmlOutput { - +class CurrentUserPrivilegeSet implements Element, HtmlOutput +{ /** - * List of privileges + * List of privileges. * * @var array */ private $privileges; /** - * Creates the object + * Creates the object. * * Pass the privileges in clark-notation * * @param array $privileges */ - function __construct(array $privileges) { - + public function __construct(array $privileges) + { $this->privileges = $privileges; - } /** @@ -57,19 +58,14 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * 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) + { foreach ($this->privileges as $privName) { - $writer->startElement('{DAV:}privilege'); $writer->writeElement($privName); $writer->endElement(); - } - - } /** @@ -77,12 +73,12 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * list. * * @param string $privilegeName + * * @return bool */ - function has($privilegeName) { - + public function has($privilegeName) + { return in_array($privilegeName, $this->privileges); - } /** @@ -90,10 +86,9 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * * @return array */ - function getValue() { - + public function getValue() + { return $this->privileges; - } /** @@ -115,21 +110,22 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $result = []; $tree = $reader->parseInnerTree(['{DAV:}privilege' => 'Sabre\\Xml\\Element\\Elements']); foreach ($tree as $element) { - if ($element['name'] !== '{DAV:}privilege') { + if ('{DAV:}privilege' !== $element['name']) { continue; } $result[] = $element['value'][0]; } - return new self($result); + return new self($result); } /** @@ -144,16 +140,14 @@ class CurrentUserPrivilegeSet implements Element, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { return implode( ', ', array_map([$html, 'xmlName'], $this->getValue()) ); - } - - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php index 04d22165d..e304a2aed 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\DAV; @@ -9,7 +11,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * Principal property + * Principal property. * * The principal property represents a principal from RFC3744 (ACL). * The property can be used to specify a principal or pseudo principals. @@ -18,30 +20,30 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Principal extends DAV\Xml\Property\Href { - +class Principal extends DAV\Xml\Property\Href +{ /** - * To specify a not-logged-in user, use the UNAUTHENTICATED principal + * To specify a not-logged-in user, use the UNAUTHENTICATED principal. */ const UNAUTHENTICATED = 1; /** - * To specify any principal that is logged in, use AUTHENTICATED + * To specify any principal that is logged in, use AUTHENTICATED. */ const AUTHENTICATED = 2; /** - * Specific principals can be specified with the HREF + * Specific principals can be specified with the HREF. */ const HREF = 3; /** - * Everybody, basically + * Everybody, basically. */ const ALL = 4; /** - * Principal-type + * Principal-type. * * Must be one of the UNAUTHENTICATED, AUTHENTICATED or HREF constants. * @@ -56,34 +58,31 @@ class Principal extends DAV\Xml\Property\Href { * * 'href' is only required for the HREF type. * - * @param int $type + * @param int $type * @param string|null $href */ - function __construct($type, $href = null) { - + public function __construct($type, $href = null) + { $this->type = $type; - if ($type === self::HREF && is_null($href)) { + if (self::HREF === $type && is_null($href)) { throw new DAV\Exception('The href argument must be specified for the HREF principal type.'); } if ($href) { - $href = rtrim($href, '/') . '/'; + $href = rtrim($href, '/').'/'; parent::__construct($href); } - } /** - * Returns the principal type + * Returns the principal type. * * @return int */ - function getType() { - + public function getType() + { return $this->type; - } - /** * The xmlSerialize method is called during xml writing. * @@ -101,26 +100,23 @@ class Principal extends DAV\Xml\Property\Href { * 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) + { switch ($this->type) { - - case self::UNAUTHENTICATED : + case self::UNAUTHENTICATED: $writer->writeElement('{DAV:}unauthenticated'); break; - case self::AUTHENTICATED : + case self::AUTHENTICATED: $writer->writeElement('{DAV:}authenticated'); break; - case self::HREF : + case self::HREF: parent::xmlSerialize($writer); break; - case self::ALL : + case self::ALL: $writer->writeElement('{DAV:}all'); break; } - } /** @@ -135,22 +131,21 @@ class Principal extends DAV\Xml\Property\Href { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { switch ($this->type) { - - case self::UNAUTHENTICATED : + case self::UNAUTHENTICATED: return '<em>unauthenticated</em>'; - case self::AUTHENTICATED : + case self::AUTHENTICATED: return '<em>authenticated</em>'; - case self::HREF : + case self::HREF: return parent::toHtml($html); - case self::ALL : + case self::ALL: return '<em>all</em>'; } - } /** @@ -172,25 +167,24 @@ class Principal extends DAV\Xml\Property\Href { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $tree = $reader->parseInnerTree()[0]; switch ($tree['name']) { - case '{DAV:}unauthenticated' : + case '{DAV:}unauthenticated': return new self(self::UNAUTHENTICATED); - case '{DAV:}authenticated' : + case '{DAV:}authenticated': return new self(self::AUTHENTICATED); case '{DAV:}href': return new self(self::HREF, $tree['value']); case '{DAV:}all': return new self(self::ALL); - default : - throw new BadRequest('Unknown or unsupported principal type: ' . $tree['name']); + default: + throw new BadRequest('Unknown or unsupported principal type: '.$tree['name']); } - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php index b963cc8c3..1762391d9 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -8,7 +10,7 @@ use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * SupportedPrivilegeSet property + * SupportedPrivilegeSet property. * * This property encodes the {DAV:}supported-privilege-set property, as defined * in rfc3744. Please consult the rfc for details about it's structure. @@ -21,24 +23,23 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { - +class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput +{ /** - * privileges + * privileges. * * @var array */ protected $privileges; /** - * Constructor + * Constructor. * * @param array $privileges */ - function __construct(array $privileges) { - + public function __construct(array $privileges) + { $this->privileges = $privileges; - } /** @@ -46,10 +47,9 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { * * @return array */ - function getValue() { - + public function getValue() + { return $this->privileges; - } /** @@ -69,12 +69,10 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { * 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) + { $this->serializePriv($writer, '{DAV:}all', ['aggregates' => $this->privileges]); - } /** @@ -89,52 +87,49 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - - $traverse = function($privName, $priv) use (&$traverse, $html) { - echo "<li>"; + public function toHtml(HtmlOutputHelper $html) + { + $traverse = function ($privName, $priv) use (&$traverse, $html) { + echo '<li>'; echo $html->xmlName($privName); if (isset($priv['abstract']) && $priv['abstract']) { - echo " <i>(abstract)</i>"; + echo ' <i>(abstract)</i>'; } if (isset($priv['description'])) { - echo " " . $html->h($priv['description']); + echo ' '.$html->h($priv['description']); } if (isset($priv['aggregates'])) { echo "\n<ul>\n"; foreach ($priv['aggregates'] as $subPrivName => $subPriv) { $traverse($subPrivName, $subPriv); } - echo "</ul>"; + echo '</ul>'; } echo "</li>\n"; }; ob_start(); - echo "<ul class=\"tree\">"; + echo '<ul class="tree">'; $traverse('{DAV:}all', ['aggregates' => $this->getValue()]); echo "</ul>\n"; return ob_get_clean(); - } - - /** - * Serializes a property + * Serializes a property. * * This is a recursive function. * * @param Writer $writer * @param string $privName - * @param array $privilege - * @return void + * @param array $privilege */ - private function serializePriv(Writer $writer, $privName, $privilege) { - + private function serializePriv(Writer $writer, $privName, $privilege) + { $writer->startElement('{DAV:}supported-privilege'); $writer->startElement('{DAV:}privilege'); @@ -154,7 +149,5 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { } $writer->endElement(); // supported-privilege - } - } |