diff options
Diffstat (limited to 'vendor/sabre/dav')
367 files changed, 12152 insertions, 13705 deletions
diff --git a/vendor/sabre/dav/.gitignore b/vendor/sabre/dav/.gitignore index 6cf245883..499f7b689 100644 --- a/vendor/sabre/dav/.gitignore +++ b/vendor/sabre/dav/.gitignore @@ -41,3 +41,5 @@ docs/wikidocs # Mac .DS_Store + +.php_cs.cache diff --git a/vendor/sabre/dav/.php_cs.dist b/vendor/sabre/dav/.php_cs.dist new file mode 100644 index 000000000..8d61ee259 --- /dev/null +++ b/vendor/sabre/dav/.php_cs.dist @@ -0,0 +1,12 @@ +<?php + +$config = PhpCsFixer\Config::create(); +$config->getFinder() + ->exclude('vendor') + ->in(__DIR__); +$config->setRules([ + '@PSR1' => true, + '@Symfony' =>true +]); + +return $config;
\ No newline at end of file diff --git a/vendor/sabre/dav/.travis.yml b/vendor/sabre/dav/.travis.yml index 85637048a..c98ea59ef 100644 --- a/vendor/sabre/dav/.travis.yml +++ b/vendor/sabre/dav/.travis.yml @@ -1,35 +1,51 @@ language: php +sudo: required php: - - 5.5 - - 5.6 - 7.0 - 7.1 - + - 7.2 + - 7.3 env: + global: + - SABRE_MYSQLUSER="root" + - SABRE_MYSQLPASS="" + - SABRE_MYSQLDSN="mysql:host=127.0.0.1;dbname=sabredav_test" + - RUN_PHPSTAN="FALSE" matrix: - - LOWEST_DEPS="" TEST_DEPS="" - - LOWEST_DEPS="--prefer-lowest" TEST_DEPS="tests/Sabre/" + - LOWEST_DEPS="" TEST_DEPS="" WITH_COVERAGE="--coverage-clover=coverage.xml" + - LOWEST_DEPS="--prefer-lowest" TEST_DEPS="tests/Sabre/" $WITH_COVERAGE="" + +matrix: + include: + - name: 'PHPStan' + php: 7.2 + env: RUN_PHPSTAN="TRUE" services: - mysql - postgresql -sudo: false +install: + - if [ $RUN_PHPSTAN == "TRUE" ]; then wget https://github.com/phpstan/phpstan/releases/download/0.11.8/phpstan.phar; fi before_script: - - mysql -e 'create database sabredav_test' +# - mysql -u root -h 127.0.0.1 sabredav_test -e 'SELECT VERSION();' +#- mysql -u root -h 127.0.0.1 -e 'create database sabredav_test' - psql -c "create database sabredav_test" -U postgres - psql -c "create user sabredav with PASSWORD 'sabredav';GRANT ALL PRIVILEGES ON DATABASE sabredav_test TO sabredav" -U postgres - # - composer self-update - composer update --prefer-dist $LOWEST_DEPS -# addons: -# postgresql: "9.5" +addons: + postgresql: "9.5" script: - - ./bin/phpunit --configuration tests/phpunit.xml.dist $TEST_DEPS - - ./bin/sabre-cs-fixer fix . --dry-run --diff + - if [ $RUN_PHPSTAN == "FALSE" ]; then ./bin/phpunit --verbose --configuration tests/phpunit.xml.dist $WITH_COVERAGE $TEST_DEPS; fi + - if [ $RUN_PHPSTAN == "FALSE" ]; then rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi + - if [ $RUN_PHPSTAN == "TRUE" ]; then php phpstan.phar analyse -c phpstan.neon lib; fi + +after_success: + - bash <(curl -s https://codecov.io/bash) cache: directories: diff --git a/vendor/sabre/dav/CHANGELOG.md b/vendor/sabre/dav/CHANGELOG.md index cda2564e1..455b3ae5e 100644 --- a/vendor/sabre/dav/CHANGELOG.md +++ b/vendor/sabre/dav/CHANGELOG.md @@ -1,11 +1,124 @@ ChangeLog ========= -3.2.3 (2018-10-19) +4.0.2 (2019-10-18) +------------------------- +* Fix error with PHP 7.4 +* CardDAV: Fix content-type for Thunderbird + + +4.0.1 (2019-08-20) +------------------------- +* TemporaryFileFilterPlugin: Fix Strict Error +* CalDAV\Plugin: Fix null path + + +4.0.0 (2019-07-01) +------------------------- +* Lock: Support lock timeout value Infinity +* Lock: Hide lock token in lock discovery when not set +* BrowserPlugin: Show display name of nodes +* FSExt: Fix folder (file) move issue if rename fails +* IMipPlugin: Add sender name in invite mail headers +* IMipPlugin: Fix email subject and recipient +* Fix issues with empty content-type header +* Apply new code style +* Fix for litmus test suite - test case: props propfind_invalid2 +* Depend on sabre/xml 2.0.1 +* Depend on sabre/http 5.0 +* Now supports PHP 7.3 +* Now requires PHP 7. +* Using `strict_types` in every php file. +* #896: Using the [sabre/event][evnt] `WildcardEmitter`. This allows event + handlers to listen to events using a wildcard. +* #896: Event listeners that in the past listened to `beforeMethod` or `method` + no longer get called. They must listen to `beforeMethod:*` and `method:*` now. +* #322: Imap authentication backend. (@c0d3z3r0). +* #889: Support for selective property querying in CardDAV's addressbook-query. + (@DeepDiver1975). +* #982: Make sure that files that are siblings of directories, are reported + as files (@nickvergessen) + + +4.0.0-beta1 (2019-05-08) +------------------------- +* Lock: Support lock timeout value Infinity +* Lock: Hide lock token in lock discovery when not set +* BrowserPlugin: Show display name of nodes +* FSExt: Fix folder (file) move issue if rename fails +* IMipPlugin: Add sender name in invite mail headers +* IMipPlugin: Fix email subject and recipient + + +4.0.0-alpha5 (2018-10-15) +------------------------- +* Fix issues with empty content-type header + + +4.0.0-alpha4 (2018-10-12) +------------------------- +* Apply new code style +* Fix for litmus test suite - test case: props propfind_invalid2 +* Depend on sabre/xml 2.0.1 + + +4.0.0-alpha3 (2018-10-05) +------------------------- +* Fixes for PHP 7.3 +* Depend on sabre/http 5.0 + + +4.0.0-alpha2 (2018-09-27) +------------------------- +* Now supports PHP 7.3 + + +4.0.0-alpha1 (2018-06-05) +------------------------- + +* Now requires PHP 7. +* Using `strict_types` in every php file. +* #896: Using the [sabre/event][evnt] `WildcardEmitter`. This allows event + handlers to listen to events using a wildcard. +* #896: Event listeners that in the past listened to `beforeMethod` or `method` + no longer get called. They must listen to `beforeMethod:*` and `method:*` now. +* #322: Imap authentication backend. (@c0d3z3r0). +* #889: Support for selective property querying in CardDAV's addressbook-query. + (@DeepDiver1975). +* #982: Make sure that files that are siblings of directories, are reported + as files (@nickvergessen) + + +3.3.0-alpha1 (2018-06-04) +------------------------- + +* SimpleCollection can now take arrays and strings as argument for super + simple tree creation. +* Added `Sabre\DAV\Server::start()`. This replaces `::exec()`. `::exec()` + is now deprecated, but we're keeping it around for a year or two to make + the transition easier. +* `getChildren()` function in any collection may now return an iterator + instead of an array. This can result in memory savings for large + collections. +* `Tree::getChildren()` now returns an Iterator instead of an array. +* Added `$overrideName` to all `Sabre\DAV\FS` and `Sabre\DAV\FSExt` classes, + so users can specify under what name these nodes show up in the tree. +* #889 Added support for filtering vCard properties in the addressbook-query + REPORT (@DeepDiver1975). +* #918: Add a lot of sqlite indexes. This should speed up sqlite-based + installations quite a bit. +* #982: Make sure that files that are siblings of directories, are reported + as files (@nickvergessen) +* #1058: Don't open file resource on HEAD request (@icewind1991) +* #1031: Fix copyNode for case of file named 0 (@phil-davis) + + +3.2.3 (????-??-??) ------------------ * #982: Make sure that files that are siblings of directories, are reported as files (@nickvergessen) + 3.2.2 (2017-02-14) ------------------ diff --git a/vendor/sabre/dav/CONTRIBUTING.md b/vendor/sabre/dav/CONTRIBUTING.md index 425ee19ba..b937db64f 100644 --- a/vendor/sabre/dav/CONTRIBUTING.md +++ b/vendor/sabre/dav/CONTRIBUTING.md @@ -78,6 +78,28 @@ to accept the patch, but we'd still really like your contribution! To run the testsuite jump into the directory `cd tests` and trigger `phpunit`. Make sure you did a `composer install` beforehand. +Release process +--------------- + +Generally, these are the steps taken to do releases. + +1. Update the changelog. Every repo will have a `CHANGELOG.md` file. This file + should have a new version, and contain all the changes since the last + release. I generally run a `git diff` to figure out if I missed any changes. + This file should also have the current date. +2. If there were BC breaks, this usually now means a major version bump. +3. Ensure that `lib/Version.php` or `lib/DAV/Version.php` also matches this + version number. +4. Tag the release (Example `git tag 3.0.1` and push the tag (`git push --tags`). +5. (only for the sabre/dav project), create a zip distribution. Run + `php bin/build.php`. +6. For the relevant project, go to github and click the 'releases' tab. On this + tab I create the release with the relevant version. I also set the + description of the release to the same information of the changelog. In the + case of the `sabre/dav` project I also upload the zip distribution here. +7. Write a blog post on sabre.io. This also automatically updates twitter. + + [1]: http://www.php-fig.org/psr/psr-1/ [2]: http://www.php-fig.org/psr/psr-4/ [3]: http://www.php-fig.org/psr/psr-2/ diff --git a/vendor/sabre/dav/README.md b/vendor/sabre/dav/README.md index 86a0fe9a6..a06805443 100644 --- a/vendor/sabre/dav/README.md +++ b/vendor/sabre/dav/README.md @@ -16,14 +16,14 @@ Build status | branch | status | minimum PHP version | | ------------ | ------ | ------------------- | -| master | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=master)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.5 | -| 3.1 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=3.0)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.5 | -| 3.0 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=3.0)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.4 | -| 2.1 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=2.1)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.4 | -| 2.0 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=2.0)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.4 | -| 1.8 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=1.8)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.3 | -| 1.7 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=1.7)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.3 | -| 1.6 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=1.6)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.3 | +| master | [![Build Status](https://travis-ci.org/sabre-io/dav.svg?branch=master)](https://travis-ci.org/sabre-io/dav) | PHP 7.0 | +| 3.1 | [![Build Status](https://travis-ci.org/sabre-io/dav.svg?branch=3.0)](https://travis-ci.org/sabre-io/dav) | PHP 5.5 | +| 3.0 | [![Build Status](https://travis-ci.org/sabre-io/dav.svg?branch=3.0)](https://travis-ci.org/sabre-io/dav) | PHP 5.4 | +| 2.1 | [![Build Status](https://travis-ci.org/sabre-io/dav.svg?branch=2.1)](https://travis-ci.org/sabre-io/dav) | PHP 5.4 | +| 2.0 | [![Build Status](https://travis-ci.org/sabre-io/dav.svg?branch=2.0)](https://travis-ci.org/sabre-io/dav) | PHP 5.4 | +| 1.8 | [![Build Status](https://travis-ci.org/sabre-io/dav.svg?branch=1.8)](https://travis-ci.org/sabre-io/dav) | PHP 5.3 | +| 1.7 | [![Build Status](https://travis-ci.org/sabre-io/dav.svg?branch=1.7)](https://travis-ci.org/sabre-io/dav) | PHP 5.3 | +| 1.6 | [![Build Status](https://travis-ci.org/sabre-io/dav.svg?branch=1.6)](https://travis-ci.org/sabre-io/dav) | PHP 5.3 | Documentation ------------- diff --git a/vendor/sabre/dav/bin/build.php b/vendor/sabre/dav/bin/build.php index c4ba20941..54174a777 100644 --- a/vendor/sabre/dav/bin/build.php +++ b/vendor/sabre/dav/bin/build.php @@ -2,7 +2,6 @@ <?php $tasks = [ - 'buildzip' => [ 'init', 'test', 'clean', ], @@ -10,25 +9,29 @@ $tasks = [ 'init', 'test', 'clean', ], 'clean' => [], - 'test' => [ + 'test' => [ 'composerupdate', ], - 'init' => [], + 'init' => [], 'composerupdate' => [], ]; $default = 'buildzip'; -$baseDir = __DIR__ . '/../'; +$baseDir = __DIR__.'/../'; chdir($baseDir); $currentTask = $default; -if ($argc > 1) $currentTask = $argv[1]; +if ($argc > 1) { + $currentTask = $argv[1]; +} $version = null; -if ($argc > 2) $version = $argv[2]; +if ($argc > 2) { + $version = $argv[2]; +} if (!isset($tasks[$currentTask])) { - echo "Task not found: ", $currentTask, "\n"; + echo 'Task not found: ', $currentTask, "\n"; die(1); } @@ -37,11 +40,9 @@ $newTaskList = []; $oldTaskList = [$currentTask => true]; while (count($oldTaskList) > 0) { - foreach ($oldTaskList as $task => $foo) { - if (!isset($tasks[$task])) { - echo "Dependency not found: " . $task, "\n"; + echo 'Dependency not found: '.$task, "\n"; die(1); } $dependencies = $tasks[$task]; @@ -55,82 +56,74 @@ while (count($oldTaskList) > 0) { $oldTaskList[$dependency] = true; $fullFilled = false; } - } if ($fullFilled) { unset($oldTaskList[$task]); $newTaskList[$task] = 1; } - } - } foreach (array_keys($newTaskList) as $task) { - - echo "task: " . $task, "\n"; + echo 'task: '.$task, "\n"; call_user_func($task); echo "\n"; - } -function init() { - +function init() +{ global $version; if (!$version) { - include __DIR__ . '/../vendor/autoload.php'; + include __DIR__.'/../vendor/autoload.php'; $version = Sabre\DAV\Version::VERSION; } - echo " Building sabre/dav " . $version, "\n"; - + echo ' Building sabre/dav '.$version, "\n"; } -function clean() { - +function clean() +{ global $baseDir; echo " Removing build files\n"; - $outputDir = $baseDir . '/build/SabreDAV'; + $outputDir = $baseDir.'/build/SabreDAV'; if (is_dir($outputDir)) { - system('rm -r ' . $baseDir . '/build/SabreDAV'); + system('rm -r '.$baseDir.'/build/SabreDAV'); } - } -function composerupdate() { - +function composerupdate() +{ global $baseDir; echo " Updating composer packages to latest version\n\n"; - system('cd ' . $baseDir . '; composer update'); + system('cd '.$baseDir.'; composer update'); } -function test() { - +function test() +{ global $baseDir; echo " Running all unittests.\n"; echo " This may take a while.\n\n"; - system(__DIR__ . '/phpunit --configuration ' . $baseDir . '/tests/phpunit.xml.dist --stop-on-failure', $code); - if ($code != 0) { + system(__DIR__.'/phpunit --configuration '.$baseDir.'/tests/phpunit.xml.dist --stop-on-failure', $code); + if (0 != $code) { echo "PHPUnit reported error code $code\n"; die(1); } - } -function buildzip() { - +function buildzip() +{ global $baseDir, $version; echo " Generating composer.json\n"; - $input = json_decode(file_get_contents(__DIR__ . '/../composer.json'), true); + $input = json_decode(file_get_contents(__DIR__.'/../composer.json'), true); $newComposer = [ - "require" => $input['require'], - "config" => [ - "bin-dir" => "./bin", + 'require' => $input['require'], + 'config' => [ + 'bin-dir' => './bin', ], - "prefer-stable" => true, - "minimum-stability" => "alpha", + 'prefer-stable' => true, + 'minimum-stability' => 'alpha', ]; unset( $newComposer['require']['sabre/vobject'], @@ -143,8 +136,8 @@ function buildzip() { file_put_contents('build/SabreDAV/composer.json', json_encode($newComposer, JSON_PRETTY_PRINT)); echo " Downloading dependencies\n"; - system("cd build/SabreDAV; composer install -n", $code); - if ($code !== 0) { + system('cd build/SabreDAV; composer install -n', $code); + if (0 !== $code) { echo "Composer reported error code $code\n"; die(1); } @@ -163,15 +156,14 @@ function buildzip() { ]; foreach ($fileNames as $fileName) { echo " $fileName\n"; - rename('build/SabreDAV/vendor/sabre/dav/' . $fileName, 'build/SabreDAV/' . $fileName); + rename('build/SabreDAV/vendor/sabre/dav/'.$fileName, 'build/SabreDAV/'.$fileName); } // <zip destfile="build/SabreDAV-${sabredav.version}.zip" basedir="build/SabreDAV" prefix="SabreDAV/" /> echo "\n"; echo "Zipping the sabredav distribution\n\n"; - system('cd build; zip -qr sabredav-' . $version . '.zip SabreDAV'); - - echo "Done."; + system('cd build; zip -qr sabredav-'.$version.'.zip SabreDAV'); + echo 'Done.'; } diff --git a/vendor/sabre/dav/bin/migrateto20.php b/vendor/sabre/dav/bin/migrateto20.php index 77236804f..c7a8d9e35 100644 --- a/vendor/sabre/dav/bin/migrateto20.php +++ b/vendor/sabre/dav/bin/migrateto20.php @@ -4,7 +4,6 @@ echo "SabreDAV migrate script for version 2.0\n"; if ($argc < 2) { - echo <<<HELLO This script help you migrate from a pre-2.0 database to 2.0 and later @@ -36,14 +35,13 @@ php {$argv[0]} sqlite:data/sabredav.db HELLO; exit(); - } // There's a bunch of places where the autoloader could be, so we'll try all of // them. $paths = [ - __DIR__ . '/../vendor/autoload.php', - __DIR__ . '/../../../autoload.php', + __DIR__.'/../vendor/autoload.php', + __DIR__.'/../../../autoload.php', ]; foreach ($paths as $path) { @@ -57,7 +55,7 @@ $dsn = $argv[1]; $user = isset($argv[2]) ? $argv[2] : null; $pass = isset($argv[3]) ? $argv[3] : null; -echo "Connecting to database: " . $dsn . "\n"; +echo 'Connecting to database: '.$dsn."\n"; $pdo = new PDO($dsn, $user, $pass); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -66,23 +64,21 @@ $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); switch ($driver) { - - case 'mysql' : + case 'mysql': echo "Detected MySQL.\n"; break; - case 'sqlite' : + case 'sqlite': echo "Detected SQLite.\n"; break; - default : - echo "Error: unsupported driver: " . $driver . "\n"; + default: + echo 'Error: unsupported driver: '.$driver."\n"; die(-1); } foreach (['calendar', 'addressbook'] as $itemType) { - - $tableName = $itemType . 's'; - $tableNameOld = $tableName . '_old'; - $changesTable = $itemType . 'changes'; + $tableName = $itemType.'s'; + $tableNameOld = $tableName.'_old'; + $changesTable = $itemType.'changes'; echo "Upgrading '$tableName'\n"; @@ -90,18 +86,16 @@ foreach (['calendar', 'addressbook'] as $itemType) { $row = $pdo->query("SELECT * FROM $tableName LIMIT 1")->fetch(); if (!$row) { - echo "No records were found in the '$tableName' table.\n"; echo "\n"; echo "We're going to rename the old table to $tableNameOld (just in case).\n"; echo "and re-create the new table.\n"; switch ($driver) { - - case 'mysql' : + case 'mysql': $pdo->exec("RENAME TABLE $tableName TO $tableNameOld"); switch ($itemType) { - case 'calendar' : + case 'calendar': $pdo->exec(" CREATE TABLE calendars ( id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, @@ -119,7 +113,7 @@ foreach (['calendar', 'addressbook'] as $itemType) { ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; "); break; - case 'addressbook' : + case 'addressbook': $pdo->exec(" CREATE TABLE addressbooks ( id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, @@ -135,13 +129,13 @@ foreach (['calendar', 'addressbook'] as $itemType) { } break; - case 'sqlite' : + case 'sqlite': $pdo->exec("ALTER TABLE $tableName RENAME TO $tableNameOld"); switch ($itemType) { - case 'calendar' : - $pdo->exec(" + case 'calendar': + $pdo->exec(' CREATE TABLE calendars ( id integer primary key asc, principaluri text, @@ -155,10 +149,10 @@ foreach (['calendar', 'addressbook'] as $itemType) { components text, transparent bool ); - "); + '); break; - case 'addressbook' : - $pdo->exec(" + case 'addressbook': + $pdo->exec(' CREATE TABLE addressbooks ( id integer primary key asc, principaluri text, @@ -167,45 +161,37 @@ foreach (['calendar', 'addressbook'] as $itemType) { description text, synctoken integer ); - "); + '); break; } break; - } echo "Creation of 2.0 $tableName table is complete\n"; - } else { - // Checking if there's a synctoken field already. if (array_key_exists('synctoken', $row)) { echo "The 'synctoken' field already exists in the $tableName table.\n"; echo "It's likely you already upgraded, so we're simply leaving\n"; echo "the $tableName table alone\n"; } else { - echo "1.8 table schema detected\n"; switch ($driver) { - - case 'mysql' : + case 'mysql': $pdo->exec("ALTER TABLE $tableName ADD synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1'"); $pdo->exec("ALTER TABLE $tableName DROP ctag"); $pdo->exec("UPDATE $tableName SET synctoken = '1'"); break; - case 'sqlite' : + case 'sqlite': $pdo->exec("ALTER TABLE $tableName ADD synctoken integer"); $pdo->exec("UPDATE $tableName SET synctoken = '1'"); echo "Note: there's no easy way to remove fields in sqlite.\n"; echo "The ctag field is no longer used, but it's kept in place\n"; break; - } echo "Upgraded '$tableName' to 2.0 schema.\n"; - } - } try { @@ -213,13 +199,11 @@ foreach (['calendar', 'addressbook'] as $itemType) { echo "'$changesTable' already exists. Assuming that this part of the\n"; echo "upgrade was already completed.\n"; - } catch (Exception $e) { echo "Creating '$changesTable' table.\n"; switch ($driver) { - - case 'mysql' : + case 'mysql': $pdo->exec(" CREATE TABLE $changesTable ( id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, @@ -232,7 +216,7 @@ foreach (['calendar', 'addressbook'] as $itemType) { "); break; - case 'sqlite' : + case 'sqlite': $pdo->exec(" CREATE TABLE $changesTable ( @@ -246,25 +230,20 @@ foreach (['calendar', 'addressbook'] as $itemType) { "); $pdo->exec("CREATE INDEX {$itemType}id_synctoken ON $changesTable ({$itemType}id, synctoken);"); break; - } - } - } try { - $pdo->query("SELECT * FROM calendarsubscriptions LIMIT 1"); + $pdo->query('SELECT * FROM calendarsubscriptions LIMIT 1'); echo "'calendarsubscriptions' already exists. Assuming that this part of the\n"; echo "upgrade was already completed.\n"; - } catch (Exception $e) { echo "Creating calendarsubscriptions table.\n"; switch ($driver) { - - case 'mysql' : + case 'mysql': $pdo->exec(" CREATE TABLE calendarsubscriptions ( id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, @@ -283,8 +262,8 @@ CREATE TABLE calendarsubscriptions ( ); "); break; - case 'sqlite' : - $pdo->exec(" + case 'sqlite': + $pdo->exec(' CREATE TABLE calendarsubscriptions ( id integer primary key asc, @@ -300,64 +279,57 @@ CREATE TABLE calendarsubscriptions ( stripattachments bool, lastmodified int ); - "); + '); - $pdo->exec("CREATE INDEX principaluri_uri ON calendarsubscriptions (principaluri, uri);"); + $pdo->exec('CREATE INDEX principaluri_uri ON calendarsubscriptions (principaluri, uri);'); break; - } - } try { - $pdo->query("SELECT * FROM propertystorage LIMIT 1"); + $pdo->query('SELECT * FROM propertystorage LIMIT 1'); echo "'propertystorage' already exists. Assuming that this part of the\n"; echo "upgrade was already completed.\n"; - } catch (Exception $e) { echo "Creating propertystorage table.\n"; switch ($driver) { - - case 'mysql' : - $pdo->exec(" + case 'mysql': + $pdo->exec(' CREATE TABLE propertystorage ( id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, path VARBINARY(1024) NOT NULL, name VARBINARY(100) NOT NULL, value MEDIUMBLOB ); - "); - $pdo->exec(" + '); + $pdo->exec(' CREATE UNIQUE INDEX path_property ON propertystorage (path(600), name(100)); - "); + '); break; - case 'sqlite' : - $pdo->exec(" + case 'sqlite': + $pdo->exec(' CREATE TABLE propertystorage ( id integer primary key asc, path TEXT, name TEXT, value TEXT ); - "); - $pdo->exec(" + '); + $pdo->exec(' CREATE UNIQUE INDEX path_property ON propertystorage (path, name); - "); + '); break; - } - } echo "Upgrading cards table to 2.0 schema\n"; try { - $create = false; - $row = $pdo->query("SELECT * FROM cards LIMIT 1")->fetch(); + $row = $pdo->query('SELECT * FROM cards LIMIT 1')->fetch(); if (!$row) { $random = mt_rand(1000, 9999); echo "There was no data in the cards table, so we're re-creating it\n"; @@ -366,28 +338,24 @@ try { $create = true; switch ($driver) { - case 'mysql' : + case 'mysql': $pdo->exec("RENAME TABLE cards TO cards_old$random"); break; - case 'sqlite' : + case 'sqlite': $pdo->exec("ALTER TABLE cards RENAME TO cards_old$random"); break; - } } - } catch (Exception $e) { - echo "Exception while checking cards table. Assuming that the table does not yet exist.\n"; - echo "Debug: ", $e->getMessage(), "\n"; + echo 'Debug: ', $e->getMessage(), "\n"; $create = true; - } if ($create) { switch ($driver) { - case 'mysql' : - $pdo->exec(" + case 'mysql': + $pdo->exec(' CREATE TABLE cards ( id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, addressbookid INT(11) UNSIGNED NOT NULL, @@ -398,12 +366,12 @@ CREATE TABLE cards ( size INT(11) UNSIGNED NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - "); + '); break; - case 'sqlite' : + case 'sqlite': - $pdo->exec(" + $pdo->exec(' CREATE TABLE cards ( id integer primary key asc, addressbookid integer, @@ -413,28 +381,26 @@ CREATE TABLE cards ( etag text, size integer ); - "); + '); break; - } } else { switch ($driver) { - case 'mysql' : - $pdo->exec(" + case 'mysql': + $pdo->exec(' ALTER TABLE cards ADD etag VARBINARY(32), ADD size INT(11) UNSIGNED NOT NULL; - "); + '); break; - case 'sqlite' : + case 'sqlite': - $pdo->exec(" + $pdo->exec(' ALTER TABLE cards ADD etag text; ALTER TABLE cards ADD size integer; - "); + '); break; - } echo "Reading all old vcards and populating etag and size fields.\n"; $result = $pdo->query('SELECT id, carddata FROM cards'); @@ -443,11 +409,9 @@ CREATE TABLE cards ( $stmt->execute([ md5($row['carddata']), strlen($row['carddata']), - $row['id'] + $row['id'], ]); } - - } echo "Upgrade to 2.0 schema completed.\n"; diff --git a/vendor/sabre/dav/bin/migrateto21.php b/vendor/sabre/dav/bin/migrateto21.php index c81ee5cca..909643583 100644 --- a/vendor/sabre/dav/bin/migrateto21.php +++ b/vendor/sabre/dav/bin/migrateto21.php @@ -4,7 +4,6 @@ echo "SabreDAV migrate script for version 2.1\n"; if ($argc < 2) { - echo <<<HELLO This script help you migrate from a pre-2.1 database to 2.1. @@ -37,14 +36,13 @@ php {$argv[0]} sqlite:data/sabredav.db HELLO; exit(); - } // There's a bunch of places where the autoloader could be, so we'll try all of // them. $paths = [ - __DIR__ . '/../vendor/autoload.php', - __DIR__ . '/../../../autoload.php', + __DIR__.'/../vendor/autoload.php', + __DIR__.'/../../../autoload.php', ]; foreach ($paths as $path) { @@ -58,7 +56,7 @@ $dsn = $argv[1]; $user = isset($argv[2]) ? $argv[2] : null; $pass = isset($argv[3]) ? $argv[3] : null; -echo "Connecting to database: " . $dsn . "\n"; +echo 'Connecting to database: '.$dsn."\n"; $pdo = new PDO($dsn, $user, $pass); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -67,15 +65,14 @@ $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); switch ($driver) { - - case 'mysql' : + case 'mysql': echo "Detected MySQL.\n"; break; - case 'sqlite' : + case 'sqlite': echo "Detected SQLite.\n"; break; - default : - echo "Error: unsupported driver: " . $driver . "\n"; + default: + echo 'Error: unsupported driver: '.$driver."\n"; die(-1); } @@ -95,19 +92,17 @@ try { echo "2.0 schema detected.\n"; $addUid = true; } - } catch (Exception $e) { echo "Could not find a calendarobjects table. Skipping this part of the\n"; echo "upgrade.\n"; } if ($addUid) { - switch ($driver) { - case 'mysql' : + case 'mysql': $pdo->exec('ALTER TABLE calendarobjects ADD uid VARCHAR(200)'); break; - case 'sqlite' : + case 'sqlite': $pdo->exec('ALTER TABLE calendarobjects ADD uid TEXT'); break; } @@ -117,7 +112,6 @@ if ($addUid) { $counter = 0; while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { - try { $vobj = \Sabre\VObject\Reader::read($row['calendardata']); } catch (\Exception $e) { @@ -130,19 +124,16 @@ if ($addUid) { echo "Warning! Item with id $item[id] does NOT have a UID property and this is required.\n"; continue; } - $uid = (string)$item->UID; + $uid = (string) $item->UID; $stmt->execute([$uid, $row['id']]); - $counter++; - + ++$counter; } - } echo "Creating 'schedulingobjects'\n"; switch ($driver) { - - case 'mysql' : + case 'mysql': $pdo->exec('CREATE TABLE IF NOT EXISTS schedulingobjects ( id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, @@ -156,8 +147,7 @@ switch ($driver) { '); break; - - case 'sqlite' : + case 'sqlite': $pdo->exec('CREATE TABLE IF NOT EXISTS schedulingobjects ( id integer primary key asc, principaluri text, diff --git a/vendor/sabre/dav/bin/migrateto30.php b/vendor/sabre/dav/bin/migrateto30.php index 9ca77c13c..25e544c2a 100644 --- a/vendor/sabre/dav/bin/migrateto30.php +++ b/vendor/sabre/dav/bin/migrateto30.php @@ -4,7 +4,6 @@ echo "SabreDAV migrate script for version 3.0\n"; if ($argc < 2) { - echo <<<HELLO This script help you migrate from a pre-3.0 database to 3.0 and later @@ -36,14 +35,13 @@ php {$argv[0]} sqlite:data/sabredav.db HELLO; exit(); - } // There's a bunch of places where the autoloader could be, so we'll try all of // them. $paths = [ - __DIR__ . '/../vendor/autoload.php', - __DIR__ . '/../../../autoload.php', + __DIR__.'/../vendor/autoload.php', + __DIR__.'/../../../autoload.php', ]; foreach ($paths as $path) { @@ -57,7 +55,7 @@ $dsn = $argv[1]; $user = isset($argv[2]) ? $argv[2] : null; $pass = isset($argv[3]) ? $argv[3] : null; -echo "Connecting to database: " . $dsn . "\n"; +echo 'Connecting to database: '.$dsn."\n"; $pdo = new PDO($dsn, $user, $pass); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -66,15 +64,14 @@ $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); switch ($driver) { - - case 'mysql' : + case 'mysql': echo "Detected MySQL.\n"; break; - case 'sqlite' : + case 'sqlite': echo "Detected SQLite.\n"; break; - default : - echo "Error: unsupported driver: " . $driver . "\n"; + default: + echo 'Error: unsupported driver: '.$driver."\n"; die(-1); } @@ -90,9 +87,8 @@ try { echo "Renaming propertystorage -> propertystorage_old$random and creating new table.\n"; switch ($driver) { - - case 'mysql' : - $pdo->exec('RENAME TABLE propertystorage TO propertystorage_old' . $random); + case 'mysql': + $pdo->exec('RENAME TABLE propertystorage TO propertystorage_old'.$random); $pdo->exec(' CREATE TABLE propertystorage ( id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, @@ -102,10 +98,10 @@ try { value MEDIUMBLOB ); '); - $pdo->exec('CREATE UNIQUE INDEX path_property_' . $random . ' ON propertystorage (path(600), name(100));'); + $pdo->exec('CREATE UNIQUE INDEX path_property_'.$random.' ON propertystorage (path(600), name(100));'); break; - case 'sqlite' : - $pdo->exec('ALTER TABLE propertystorage RENAME TO propertystorage_old' . $random); + case 'sqlite': + $pdo->exec('ALTER TABLE propertystorage RENAME TO propertystorage_old'.$random); $pdo->exec(' CREATE TABLE propertystorage ( id integer primary key asc, @@ -115,9 +111,8 @@ CREATE TABLE propertystorage ( value blob );'); - $pdo->exec('CREATE UNIQUE INDEX path_property_' . $random . ' ON propertystorage (path, name);'); + $pdo->exec('CREATE UNIQUE INDEX path_property_'.$random.' ON propertystorage (path, name);'); break; - } } elseif (array_key_exists('valuetype', $row)) { echo "valuetype field exists. Assuming that this part of the migration has\n"; @@ -126,7 +121,6 @@ CREATE TABLE propertystorage ( echo "2.1 schema detected. Going to perform upgrade.\n"; $addValueType = true; } - } catch (Exception $e) { echo "Could not find a propertystorage table. Skipping this part of the\n"; echo "upgrade.\n"; @@ -134,19 +128,17 @@ CREATE TABLE propertystorage ( } if ($addValueType) { - switch ($driver) { - case 'mysql' : + case 'mysql': $pdo->exec('ALTER TABLE propertystorage ADD valuetype INT UNSIGNED'); break; - case 'sqlite' : + case 'sqlite': $pdo->exec('ALTER TABLE propertystorage ADD valuetype INT'); break; } $pdo->exec('UPDATE propertystorage SET valuetype = 1 WHERE valuetype IS NULL '); - } echo "Migrating vcardurl\n"; @@ -155,16 +147,14 @@ $result = $pdo->query('SELECT id, uri, vcardurl FROM principals WHERE vcardurl I $stmt1 = $pdo->prepare('INSERT INTO propertystorage (path, name, valuetype, value) VALUES (?, ?, 3, ?)'); while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { - // Inserting the new record $stmt1->execute([ - 'addressbooks/' . basename($row['uri']), + 'addressbooks/'.basename($row['uri']), '{http://calendarserver.org/ns/}me-card', - serialize(new Sabre\DAV\Xml\Property\Href($row['vcardurl'])) + serialize(new Sabre\DAV\Xml\Property\Href($row['vcardurl'])), ]); echo serialize(new Sabre\DAV\Xml\Property\Href($row['vcardurl'])); - } echo "Done.\n"; diff --git a/vendor/sabre/dav/bin/migrateto32.php b/vendor/sabre/dav/bin/migrateto32.php index 7567aeb60..57fd35507 100644 --- a/vendor/sabre/dav/bin/migrateto32.php +++ b/vendor/sabre/dav/bin/migrateto32.php @@ -4,7 +4,6 @@ echo "SabreDAV migrate script for version 3.2\n"; if ($argc < 2) { - echo <<<HELLO This script help you migrate from a 3.1 database to 3.2 and later @@ -37,14 +36,13 @@ php {$argv[0]} sqlite:data/sabredav.db HELLO; exit(); - } // There's a bunch of places where the autoloader could be, so we'll try all of // them. $paths = [ - __DIR__ . '/../vendor/autoload.php', - __DIR__ . '/../../../autoload.php', + __DIR__.'/../vendor/autoload.php', + __DIR__.'/../../../autoload.php', ]; foreach ($paths as $path) { @@ -60,7 +58,7 @@ $pass = isset($argv[3]) ? $argv[3] : null; $backupPostfix = time(); -echo "Connecting to database: " . $dsn . "\n"; +echo 'Connecting to database: '.$dsn."\n"; $pdo = new PDO($dsn, $user, $pass); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -69,15 +67,14 @@ $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); switch ($driver) { - - case 'mysql' : + case 'mysql': echo "Detected MySQL.\n"; break; - case 'sqlite' : + case 'sqlite': echo "Detected SQLite.\n"; break; - default : - echo "Error: unsupported driver: " . $driver . "\n"; + default: + echo 'Error: unsupported driver: '.$driver."\n"; die(-1); } @@ -91,7 +88,7 @@ try { echo "calendarinstances does not yet exist. Creating table and migrating data.\n"; switch ($driver) { - case 'mysql' : + case 'mysql': $pdo->exec(<<<SQL CREATE TABLE calendarinstances ( id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, @@ -114,7 +111,7 @@ CREATE TABLE calendarinstances ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; SQL ); - $pdo->exec(" + $pdo->exec(' INSERT INTO calendarinstances ( calendarid, @@ -138,9 +135,9 @@ SELECT calendarcolor, transparent FROM calendars -"); +'); break; - case 'sqlite' : + case 'sqlite': $pdo->exec(<<<SQL CREATE TABLE calendarinstances ( id integer primary key asc NOT NULL, @@ -163,7 +160,7 @@ CREATE TABLE calendarinstances ( ); SQL ); - $pdo->exec(" + $pdo->exec(' INSERT INTO calendarinstances ( calendarid, @@ -187,10 +184,9 @@ SELECT calendarcolor, transparent FROM calendars -"); +'); break; } - } try { $result = $pdo->query('SELECT * FROM calendars LIMIT 1'); @@ -202,37 +198,34 @@ try { } $columnCount = count($row); - if ($columnCount === 3) { + if (3 === $columnCount) { echo "The calendars table has 3 columns already. Assuming this part of the migration was already done.\n"; $migrateCalendars = false; } else { - echo "The calendars table has " . $columnCount . " columns.\n"; + echo 'The calendars table has '.$columnCount." columns.\n"; $migrateCalendars = true; } - } catch (Exception $e) { echo "calendars table does not exist. This is a major problem. Exiting.\n"; exit(-1); } if ($migrateCalendars) { - - $calendarBackup = 'calendars_3_1_' . $backupPostfix; + $calendarBackup = 'calendars_3_1_'.$backupPostfix; echo "Backing up 'calendars' to '", $calendarBackup, "'\n"; switch ($driver) { - case 'mysql' : - $pdo->exec('RENAME TABLE calendars TO ' . $calendarBackup); + case 'mysql': + $pdo->exec('RENAME TABLE calendars TO '.$calendarBackup); break; - case 'sqlite' : - $pdo->exec('ALTER TABLE calendars RENAME TO ' . $calendarBackup); + case 'sqlite': + $pdo->exec('ALTER TABLE calendars RENAME TO '.$calendarBackup); break; - } echo "Creating new calendars table.\n"; switch ($driver) { - case 'mysql' : + case 'mysql': $pdo->exec(<<<SQL CREATE TABLE calendars ( id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, @@ -242,7 +235,7 @@ CREATE TABLE calendars ( SQL ); break; - case 'sqlite' : + case 'sqlite': $pdo->exec(<<<SQL CREATE TABLE calendars ( id integer primary key asc NOT NULL, @@ -252,7 +245,6 @@ CREATE TABLE calendars ( SQL ); break; - } echo "Migrating data from old to new table\n"; @@ -261,8 +253,6 @@ SQL INSERT INTO calendars (id, synctoken, components) SELECT id, synctoken, COALESCE(components,"VEVENT,VTODO,VJOURNAL") as components FROM $calendarBackup SQL ); - } - echo "Upgrade to 3.2 schema completed.\n"; diff --git a/vendor/sabre/dav/bin/sabredav.php b/vendor/sabre/dav/bin/sabredav.php index 950075d1a..28341b587 100644 --- a/vendor/sabre/dav/bin/sabredav.php +++ b/vendor/sabre/dav/bin/sabredav.php @@ -2,34 +2,32 @@ // SabreDAV test server. -class CliLog { - +class CliLog +{ protected $stream; - function __construct() { - + public function __construct() + { $this->stream = fopen('php://stdout', 'w'); - } - function log($msg) { - fwrite($this->stream, $msg . "\n"); + public function log($msg) + { + fwrite($this->stream, $msg."\n"); } - } $log = new CliLog(); -if (php_sapi_name() !== 'cli-server') { - die("This script is intended to run on the built-in php webserver"); +if ('cli-server' !== php_sapi_name()) { + die('This script is intended to run on the built-in php webserver'); } // Finding composer - $paths = [ - __DIR__ . '/../vendor/autoload.php', - __DIR__ . '/../../../autoload.php', + __DIR__.'/../vendor/autoload.php', + __DIR__.'/../../../autoload.php', ]; foreach ($paths as $path) { @@ -41,7 +39,7 @@ foreach ($paths as $path) { use Sabre\DAV; -// Root +// Root $root = new DAV\FS\Directory(getcwd()); // Setting up server. diff --git a/vendor/sabre/dav/composer.json b/vendor/sabre/dav/composer.json index fca0e07fb..226b2cb30 100644 --- a/vendor/sabre/dav/composer.json +++ b/vendor/sabre/dav/composer.json @@ -14,12 +14,12 @@ } ], "require": { - "php": ">=5.5.0", - "sabre/vobject": "^4.1.0", - "sabre/event" : ">=2.0.0, <4.0.0", - "sabre/xml" : "^1.4.0", - "sabre/http" : "^4.2.1", - "sabre/uri" : "^1.0.1", + "php": ">=7.0.0", + "sabre/vobject": "^4.2.0-alpha1", + "sabre/event" : "^5.0", + "sabre/xml" : "^2.0.1", + "sabre/http" : "^5.0", + "sabre/uri" : "^2.0", "ext-dom": "*", "ext-pcre": "*", "ext-spl": "*", @@ -29,17 +29,18 @@ "ext-date" : "*", "ext-iconv" : "*", "lib-libxml" : ">=2.7.0", - "psr/log": "^1.0" + "psr/log": "^1.0", + "ext-json": "*" }, "require-dev" : { - "phpunit/phpunit" : "> 4.8, <6.0.0", + "phpunit/phpunit" : "^6", "evert/phpdoc-md" : "~0.1.0", - "sabre/cs" : "^1.0.0", "monolog/monolog": "^1.18" }, "suggest" : { "ext-curl" : "*", - "ext-pdo" : "*" + "ext-pdo" : "*", + "ext-imap": "*" }, "autoload": { "psr-4" : { @@ -59,10 +60,5 @@ ], "config" : { "bin-dir" : "./bin" - }, - "extra" : { - "branch-alias": { - "dev-master": "3.1.0-dev" - } } } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php b/vendor/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php index 311b1c415..336e104c8 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\CalDAV; @@ -14,8 +16,8 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface { - +abstract class AbstractBackend implements BackendInterface +{ /** * Updates properties for a calendar. * @@ -28,12 +30,11 @@ abstract class AbstractBackend implements BackendInterface { * * Read the PropPatch documentation for more info and examples. * - * @param mixed $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) { - + public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) + { } /** @@ -46,14 +47,14 @@ abstract class AbstractBackend implements BackendInterface { * * @param mixed $calendarId * @param array $uris + * * @return array */ - function getMultipleCalendarObjects($calendarId, array $uris) { - - return array_map(function($uri) use ($calendarId) { + public function getMultipleCalendarObjects($calendarId, array $uris) + { + return array_map(function ($uri) use ($calendarId) { return $this->getCalendarObject($calendarId, $uri); }, $uris); - } /** @@ -103,23 +104,21 @@ abstract class AbstractBackend implements BackendInterface { * * @param mixed $calendarId * @param array $filters + * * @return array */ - function calendarQuery($calendarId, array $filters) { - + public function calendarQuery($calendarId, array $filters) + { $result = []; $objects = $this->getCalendarObjects($calendarId); foreach ($objects as $object) { - if ($this->validateFilterForObject($object, $filters)) { $result[] = $object['uri']; } - } return $result; - } /** @@ -128,10 +127,11 @@ abstract class AbstractBackend implements BackendInterface { * * @param array $object * @param array $filters + * * @return bool */ - protected function validateFilterForObject(array $object, array $filters) { - + protected function validateFilterForObject(array $object, array $filters) + { // Unfortunately, setting the 'calendardata' here is optional. If // it was excluded, we actually need another call to get this as // well. @@ -148,7 +148,6 @@ abstract class AbstractBackend implements BackendInterface { $vObject->destroy(); return $result; - } /** @@ -168,14 +167,14 @@ abstract class AbstractBackend implements BackendInterface { * * @param string $principalUri * @param string $uid + * * @return string|null */ - function getCalendarObjectByUID($principalUri, $uid) { - + public function getCalendarObjectByUID($principalUri, $uid) + { // Note: this is a super slow naive implementation of this method. You // are highly recommended to optimize it, if your backend allows it. foreach ($this->getCalendarsForUser($principalUri) as $calendar) { - // We must ignore calendars owned by other principals. if ($calendar['principaluri'] !== $principalUri) { continue; @@ -189,38 +188,35 @@ abstract class AbstractBackend implements BackendInterface { $results = $this->calendarQuery( $calendar['id'], [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'prop-filters' => [], 'comp-filters' => [ [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'is-not-defined' => false, - 'time-range' => null, - 'comp-filters' => [], - 'prop-filters' => [ + 'time-range' => null, + 'comp-filters' => [], + 'prop-filters' => [ [ - 'name' => 'UID', + 'name' => 'UID', 'is-not-defined' => false, - 'time-range' => null, - 'text-match' => [ - 'value' => $uid, + 'time-range' => null, + 'text-match' => [ + 'value' => $uid, 'negate-condition' => false, - 'collation' => 'i;octet', + 'collation' => 'i;octet', ], 'param-filters' => [], ], - ] - ] + ], + ], ], ] ); if ($results) { // We have a match - return $calendar['uri'] . '/' . $results[0]; + return $calendar['uri'].'/'.$results[0]; } - } - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php b/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php index bd8ee7602..7d125cf89 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; /** @@ -9,8 +11,8 @@ namespace Sabre\CalDAV\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * Returns a list of calendars for a principal. * @@ -34,9 +36,10 @@ interface BackendInterface { * ACL will automatically be put in read-only mode. * * @param string $principalUri + * * @return array */ - function getCalendarsForUser($principalUri); + public function getCalendarsForUser($principalUri); /** * Creates a new calendar for a principal. @@ -48,10 +51,11 @@ interface BackendInterface { * * @param string $principalUri * @param string $calendarUri - * @param array $properties + * @param array $properties + * * @return mixed */ - function createCalendar($principalUri, $calendarUri, array $properties); + public function createCalendar($principalUri, $calendarUri, array $properties); /** * Updates properties for a calendar. @@ -65,19 +69,17 @@ interface BackendInterface { * * Read the PropPatch documentation for more info and examples. * - * @param mixed $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch); + public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch); /** - * Delete a calendar and all its objects + * Delete a calendar and all its objects. * * @param mixed $calendarId - * @return void */ - function deleteCalendar($calendarId); + public function deleteCalendar($calendarId); /** * Returns all calendar objects within a calendar. @@ -108,9 +110,10 @@ interface BackendInterface { * amount of times this is needed is reduced by a great degree. * * @param mixed $calendarId + * * @return array */ - function getCalendarObjects($calendarId); + public function getCalendarObjects($calendarId); /** * Returns information from a single calendar object, based on it's object @@ -124,11 +127,12 @@ interface BackendInterface { * * This method must return null if the object did not exist. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri + * * @return array|null */ - function getCalendarObject($calendarId, $objectUri); + public function getCalendarObject($calendarId, $objectUri); /** * Returns a list of calendar objects. @@ -140,9 +144,10 @@ interface BackendInterface { * * @param mixed $calendarId * @param array $uris + * * @return array */ - function getMultipleCalendarObjects($calendarId, array $uris); + public function getMultipleCalendarObjects($calendarId, array $uris); /** * Creates a new calendar object. @@ -157,12 +162,13 @@ interface BackendInterface { * calendar-data. If the result of a subsequent GET to this object is not * the exact same as this request body, you should omit the ETag. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri * @param string $calendarData + * * @return string|null */ - function createCalendarObject($calendarId, $objectUri, $calendarData); + public function createCalendarObject($calendarId, $objectUri, $calendarData); /** * Updates an existing calendarobject, based on it's uri. @@ -177,23 +183,23 @@ interface BackendInterface { * calendar-data. If the result of a subsequent GET to this object is not * the exact same as this request body, you should omit the ETag. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri * @param string $calendarData + * * @return string|null */ - function updateCalendarObject($calendarId, $objectUri, $calendarData); + public function updateCalendarObject($calendarId, $objectUri, $calendarData); /** * Deletes an existing calendar object. * * The object uri is only the basename, or filename and not a full path. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri - * @return void */ - function deleteCalendarObject($calendarId, $objectUri); + public function deleteCalendarObject($calendarId, $objectUri); /** * Performs a calendar-query on the contents of this calendar. @@ -242,9 +248,10 @@ interface BackendInterface { * * @param mixed $calendarId * @param array $filters + * * @return array */ - function calendarQuery($calendarId, array $filters); + public function calendarQuery($calendarId, array $filters); /** * Searches through all of a users calendars and calendar objects to find @@ -263,8 +270,8 @@ interface BackendInterface { * * @param string $principalUri * @param string $uid + * * @return string|null */ - function getCalendarObjectByUID($principalUri, $uid); - + public function getCalendarObjectByUID($principalUri, $uid); } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/NotificationSupport.php b/vendor/sabre/dav/lib/CalDAV/Backend/NotificationSupport.php index bf2ef27a0..0ba493305 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/NotificationSupport.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/NotificationSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\CalDAV\Xml\Notification\NotificationInterface; @@ -22,26 +24,26 @@ use Sabre\CalDAV\Xml\Notification\NotificationInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface NotificationSupport extends BackendInterface { - +interface NotificationSupport extends BackendInterface +{ /** * Returns a list of notifications for a given principal url. * * @param string $principalUri + * * @return NotificationInterface[] */ - function getNotificationsForPrincipal($principalUri); + public function getNotificationsForPrincipal($principalUri); /** * This deletes a specific notifcation. * * This may be called by a client once it deems a notification handled. * - * @param string $principalUri + * @param string $principalUri * @param NotificationInterface $notification - * @return void */ - function deleteNotification($principalUri, NotificationInterface $notification); + public function deleteNotification($principalUri, NotificationInterface $notification); /** * This method is called when a user replied to a request to share. @@ -49,13 +51,13 @@ interface NotificationSupport extends BackendInterface { * If the user chose to accept the share, this method should return the * newly created calendar url. * - * @param string $href The sharee who is replying (often a mailto: address) - * @param int $status One of the SharingPlugin::STATUS_* constants + * @param string $href The sharee who is replying (often a mailto: address) + * @param int $status One of the SharingPlugin::STATUS_* constants * @param string $calendarUri The url to the calendar thats being shared - * @param string $inReplyTo The unique id this message is a response to - * @param string $summary A description of the reply - * @return null|string + * @param string $inReplyTo The unique id this message is a response to + * @param string $summary A description of the reply + * + * @return string|null */ - function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null); - + public function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null); } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php b/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php index 458440588..003dc1392 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\CalDAV; @@ -9,7 +11,7 @@ use Sabre\DAV\Xml\Element\Sharee; use Sabre\VObject; /** - * PDO CalDAV backend + * PDO CalDAV backend. * * This backend is used to store calendar-data in a PDO database, such as * sqlite or MySQL @@ -18,15 +20,10 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend - implements - SyncSupport, - SubscriptionSupport, - SchedulingSupport, - SharingSupport { - +class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, SchedulingSupport, SharingSupport +{ /** - * We need to specify a max date, because we need to stop *somewhere* + * We need to specify a max date, because we need to stop *somewhere*. * * On 32 bit system the maximum for a signed integer is 2147483647, so * MAX_DATE cannot be higher than date('Y-m-d', 2147483647) which results @@ -36,14 +33,14 @@ class PDO extends AbstractBackend const MAX_DATE = '2038-01-01'; /** - * pdo + * pdo. * * @var \PDO */ protected $pdo; /** - * The table name that will be used for calendars + * The table name that will be used for calendars. * * @var string */ @@ -60,7 +57,7 @@ class PDO extends AbstractBackend public $calendarInstancesTableName = 'calendarinstances'; /** - * The table name that will be used for calendar objects + * The table name that will be used for calendar objects. * * @var string */ @@ -96,11 +93,11 @@ class PDO extends AbstractBackend * @var array */ public $propertyMap = [ - '{DAV:}displayname' => 'displayname', + '{DAV:}displayname' => 'displayname', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'description', - '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => 'timezone', - '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', - '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', + '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => 'timezone', + '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', + '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', ]; /** @@ -109,24 +106,23 @@ class PDO extends AbstractBackend * @var array */ public $subscriptionPropertyMap = [ - '{DAV:}displayname' => 'displayname', - '{http://apple.com/ns/ical/}refreshrate' => 'refreshrate', - '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', - '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', - '{http://calendarserver.org/ns/}subscribed-strip-todos' => 'striptodos', - '{http://calendarserver.org/ns/}subscribed-strip-alarms' => 'stripalarms', + '{DAV:}displayname' => 'displayname', + '{http://apple.com/ns/ical/}refreshrate' => 'refreshrate', + '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', + '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', + '{http://calendarserver.org/ns/}subscribed-strip-todos' => 'striptodos', + '{http://calendarserver.org/ns/}subscribed-strip-alarms' => 'stripalarms', '{http://calendarserver.org/ns/}subscribed-strip-attachments' => 'stripattachments', ]; /** - * Creates the backend + * Creates the backend. * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -151,10 +147,11 @@ class PDO extends AbstractBackend * ACL will automatically be put in read-only mode. * * @param string $principalUri + * * @return array */ - function getCalendarsForUser($principalUri) { - + public function getCalendarsForUser($principalUri) + { $fields = array_values($this->propertyMap); $fields[] = 'calendarid'; $fields[] = 'uri'; @@ -177,24 +174,23 @@ SQL $calendars = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $components = []; if ($row['components']) { $components = explode(',', $row['components']); } $calendar = [ - 'id' => [(int)$row['calendarid'], (int)$row['id']], - 'uri' => $row['uri'], - 'principaluri' => $row['principaluri'], - '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken'] ? $row['synctoken'] : '0'), - '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', - '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet($components), - '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'), - 'share-resource-uri' => '/ns/share/' . $row['calendarid'], + 'id' => [(int) $row['calendarid'], (int) $row['id']], + 'uri' => $row['uri'], + 'principaluri' => $row['principaluri'], + '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'), + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', + '{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet($components), + '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'), + 'share-resource-uri' => '/ns/share/'.$row['calendarid'], ]; - $calendar['share-access'] = (int)$row['access']; + $calendar['share-access'] = (int) $row['access']; // 1 = owner, 2 = readonly, 3 = readwrite if ($row['access'] > 1) { // We need to find more information about the original owner. @@ -203,7 +199,7 @@ SQL // read-only is for backwards compatbility. Might go away in // the future. - $calendar['read-only'] = (int)$row['access'] === \Sabre\DAV\Sharing\Plugin::ACCESS_READ; + $calendar['read-only'] = \Sabre\DAV\Sharing\Plugin::ACCESS_READ === (int) $row['access']; } foreach ($this->propertyMap as $xmlName => $dbName) { @@ -211,11 +207,9 @@ SQL } $calendars[] = $calendar; - } return $calendars; - } /** @@ -226,11 +220,12 @@ SQL * * @param string $principalUri * @param string $calendarUri - * @param array $properties + * @param array $properties + * * @return string */ - function createCalendar($principalUri, $calendarUri, array $properties) { - + public function createCalendar($principalUri, $calendarUri, array $properties) + { $fieldNames = [ 'principaluri', 'uri', @@ -239,51 +234,48 @@ SQL ]; $values = [ ':principaluri' => $principalUri, - ':uri' => $calendarUri, - ':transparent' => 0, + ':uri' => $calendarUri, + ':transparent' => 0, ]; - $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; if (!isset($properties[$sccs])) { // Default value $components = 'VEVENT,VTODO'; } else { if (!($properties[$sccs] instanceof CalDAV\Xml\Property\SupportedCalendarComponentSet)) { - throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet'); + throw new DAV\Exception('The '.$sccs.' property must be of type: \Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet'); } $components = implode(',', $properties[$sccs]->getValue()); } - $transp = '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp'; + $transp = '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp'; if (isset($properties[$transp])) { - $values[':transparent'] = $properties[$transp]->getValue() === 'transparent' ? 1 : 0; + $values[':transparent'] = 'transparent' === $properties[$transp]->getValue() ? 1 : 0; } - $stmt = $this->pdo->prepare("INSERT INTO " . $this->calendarTableName . " (synctoken, components) VALUES (1, ?)"); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarTableName.' (synctoken, components) VALUES (1, ?)'); $stmt->execute([$components]); $calendarId = $this->pdo->lastInsertId( - $this->calendarTableName . '_id_seq' + $this->calendarTableName.'_id_seq' ); $values[':calendarid'] = $calendarId; foreach ($this->propertyMap as $xmlName => $dbName) { if (isset($properties[$xmlName])) { - - $values[':' . $dbName] = $properties[$xmlName]; + $values[':'.$dbName] = $properties[$xmlName]; $fieldNames[] = $dbName; } } - $stmt = $this->pdo->prepare("INSERT INTO " . $this->calendarInstancesTableName . " (" . implode(', ', $fieldNames) . ") VALUES (" . implode(', ', array_keys($values)) . ")"); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarInstancesTableName.' ('.implode(', ', $fieldNames).') VALUES ('.implode(', ', array_keys($values)).')'); $stmt->execute($values); return [ $calendarId, - $this->pdo->lastInsertId($this->calendarInstancesTableName . '_id_seq') + $this->pdo->lastInsertId($this->calendarInstancesTableName.'_id_seq'), ]; - } /** @@ -298,100 +290,88 @@ SQL * * Read the PropPatch documentation for more info and examples. * - * @param mixed $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) { - + public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } list($calendarId, $instanceId) = $calendarId; $supportedProperties = array_keys($this->propertyMap); - $supportedProperties[] = '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp'; + $supportedProperties[] = '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp'; - $propPatch->handle($supportedProperties, function($mutations) use ($calendarId, $instanceId) { + $propPatch->handle($supportedProperties, function ($mutations) use ($calendarId, $instanceId) { $newValues = []; foreach ($mutations as $propertyName => $propertyValue) { - switch ($propertyName) { - case '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' : + case '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp': $fieldName = 'transparent'; - $newValues[$fieldName] = $propertyValue->getValue() === 'transparent'; + $newValues[$fieldName] = 'transparent' === $propertyValue->getValue(); break; - default : + default: $fieldName = $this->propertyMap[$propertyName]; $newValues[$fieldName] = $propertyValue; break; } - } $valuesSql = []; foreach ($newValues as $fieldName => $value) { - $valuesSql[] = $fieldName . ' = ?'; + $valuesSql[] = $fieldName.' = ?'; } - $stmt = $this->pdo->prepare("UPDATE " . $this->calendarInstancesTableName . " SET " . implode(', ', $valuesSql) . " WHERE id = ?"); + $stmt = $this->pdo->prepare('UPDATE '.$this->calendarInstancesTableName.' SET '.implode(', ', $valuesSql).' WHERE id = ?'); $newValues['id'] = $instanceId; $stmt->execute(array_values($newValues)); - $this->addChange($calendarId, "", 2); + $this->addChange($calendarId, '', 2); return true; - }); - } /** - * Delete a calendar and all it's objects + * Delete a calendar and all it's objects. * * @param mixed $calendarId - * @return void */ - function deleteCalendar($calendarId) { - + public function deleteCalendar($calendarId) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } list($calendarId, $instanceId) = $calendarId; - $stmt = $this->pdo->prepare('SELECT access FROM ' . $this->calendarInstancesTableName . ' where id = ?'); + $stmt = $this->pdo->prepare('SELECT access FROM '.$this->calendarInstancesTableName.' where id = ?'); $stmt->execute([$instanceId]); - $access = (int)$stmt->fetchColumn(); - - if ($access === \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER) { + $access = (int) $stmt->fetchColumn(); + if (\Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER === $access) { /** * If the user is the owner of the calendar, we delete all data and all * instances. **/ - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?'); $stmt->execute([$calendarId]); - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarChangesTableName . ' WHERE calendarid = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarChangesTableName.' WHERE calendarid = ?'); $stmt->execute([$calendarId]); - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarInstancesTableName . ' WHERE calendarid = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarInstancesTableName.' WHERE calendarid = ?'); $stmt->execute([$calendarId]); - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarTableName . ' WHERE id = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarTableName.' WHERE id = ?'); $stmt->execute([$calendarId]); - } else { - /** * If it was an instance of a shared calendar, we only delete that * instance. */ - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarInstancesTableName . ' WHERE id = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarInstancesTableName.' WHERE id = ?'); $stmt->execute([$instanceId]); - } - - } /** @@ -423,32 +403,32 @@ SQL * amount of times this is needed is reduced by a great degree. * * @param mixed $calendarId + * * @return array */ - function getCalendarObjects($calendarId) { - + public function getCalendarObjects($calendarId) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } list($calendarId, $instanceId) = $calendarId; - $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, componenttype FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ?'); + $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, componenttype FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?'); $stmt->execute([$calendarId]); $result = []; foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { $result[] = [ - 'id' => $row['id'], - 'uri' => $row['uri'], - 'lastmodified' => (int)$row['lastmodified'], - 'etag' => '"' . $row['etag'] . '"', - 'size' => (int)$row['size'], - 'component' => strtolower($row['componenttype']), + 'id' => $row['id'], + 'uri' => $row['uri'], + 'lastmodified' => (int) $row['lastmodified'], + 'etag' => '"'.$row['etag'].'"', + 'size' => (int) $row['size'], + 'component' => strtolower($row['componenttype']), ]; } return $result; - } /** @@ -463,33 +443,35 @@ SQL * * This method must return null if the object did not exist. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri + * * @return array|null */ - function getCalendarObject($calendarId, $objectUri) { - + public function getCalendarObject($calendarId, $objectUri) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } list($calendarId, $instanceId) = $calendarId; - $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, calendardata, componenttype FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ? AND uri = ?'); + $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, calendardata, componenttype FROM '.$this->calendarObjectTableName.' WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarId, $objectUri]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if (!$row) return null; + if (!$row) { + return null; + } return [ - 'id' => $row['id'], - 'uri' => $row['uri'], - 'lastmodified' => (int)$row['lastmodified'], - 'etag' => '"' . $row['etag'] . '"', - 'size' => (int)$row['size'], + 'id' => $row['id'], + 'uri' => $row['uri'], + 'lastmodified' => (int) $row['lastmodified'], + 'etag' => '"'.$row['etag'].'"', + 'size' => (int) $row['size'], 'calendardata' => $row['calendardata'], - 'component' => strtolower($row['componenttype']), + 'component' => strtolower($row['componenttype']), ]; - } /** @@ -502,10 +484,11 @@ SQL * * @param mixed $calendarId * @param array $uris + * * @return array */ - function getMultipleCalendarObjects($calendarId, array $uris) { - + public function getMultipleCalendarObjects($calendarId, array $uris) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } @@ -513,7 +496,7 @@ SQL $result = []; foreach (array_chunk($uris, 900) as $chunk) { - $query = 'SELECT id, uri, lastmodified, etag, calendarid, size, calendardata, componenttype FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ? AND uri IN ('; + $query = 'SELECT id, uri, lastmodified, etag, calendarid, size, calendardata, componenttype FROM '.$this->calendarObjectTableName.' WHERE calendarid = ? AND uri IN ('; // Inserting a whole bunch of question marks $query .= implode(',', array_fill(0, count($chunk), '?')); $query .= ')'; @@ -522,24 +505,21 @@ SQL $stmt->execute(array_merge([$calendarId], $chunk)); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $result[] = [ - 'id' => $row['id'], - 'uri' => $row['uri'], - 'lastmodified' => (int)$row['lastmodified'], - 'etag' => '"' . $row['etag'] . '"', - 'size' => (int)$row['size'], + 'id' => $row['id'], + 'uri' => $row['uri'], + 'lastmodified' => (int) $row['lastmodified'], + 'etag' => '"'.$row['etag'].'"', + 'size' => (int) $row['size'], 'calendardata' => $row['calendardata'], - 'component' => strtolower($row['componenttype']), + 'component' => strtolower($row['componenttype']), ]; - } } - return $result; + return $result; } - /** * Creates a new calendar object. * @@ -553,13 +533,14 @@ SQL * calendar-data. If the result of a subsequent GET to this object is not * the exact same as this request body, you should omit the ETag. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri * @param string $calendarData + * * @return string|null */ - function createCalendarObject($calendarId, $objectUri, $calendarData) { - + public function createCalendarObject($calendarId, $objectUri, $calendarData) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } @@ -567,7 +548,7 @@ SQL $extraData = $this->getDenormalizedData($calendarData); - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->calendarObjectTableName . ' (calendarid, uri, calendardata, lastmodified, etag, size, componenttype, firstoccurence, lastoccurence, uid) VALUES (?,?,?,?,?,?,?,?,?,?)'); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarObjectTableName.' (calendarid, uri, calendardata, lastmodified, etag, size, componenttype, firstoccurence, lastoccurence, uid) VALUES (?,?,?,?,?,?,?,?,?,?)'); $stmt->execute([ $calendarId, $objectUri, @@ -582,8 +563,7 @@ SQL ]); $this->addChange($calendarId, $objectUri, 1); - return '"' . $extraData['etag'] . '"'; - + return '"'.$extraData['etag'].'"'; } /** @@ -599,13 +579,14 @@ SQL * calendar-data. If the result of a subsequent GET to this object is not * the exact same as this request body, you should omit the ETag. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri * @param string $calendarData + * * @return string|null */ - function updateCalendarObject($calendarId, $objectUri, $calendarData) { - + public function updateCalendarObject($calendarId, $objectUri, $calendarData) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } @@ -613,13 +594,12 @@ SQL $extraData = $this->getDenormalizedData($calendarData); - $stmt = $this->pdo->prepare('UPDATE ' . $this->calendarObjectTableName . ' SET calendardata = ?, lastmodified = ?, etag = ?, size = ?, componenttype = ?, firstoccurence = ?, lastoccurence = ?, uid = ? WHERE calendarid = ? AND uri = ?'); + $stmt = $this->pdo->prepare('UPDATE '.$this->calendarObjectTableName.' SET calendardata = ?, lastmodified = ?, etag = ?, size = ?, componenttype = ?, firstoccurence = ?, lastoccurence = ?, uid = ? WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarData, time(), $extraData['etag'], $extraData['size'], $extraData['componentType'], $extraData['firstOccurence'], $extraData['lastOccurence'], $extraData['uid'], $calendarId, $objectUri]); $this->addChange($calendarId, $objectUri, 2); - return '"' . $extraData['etag'] . '"'; - + return '"'.$extraData['etag'].'"'; } /** @@ -635,10 +615,11 @@ SQL * * uid - value of the UID property * * @param string $calendarData + * * @return array */ - protected function getDenormalizedData($calendarData) { - + protected function getDenormalizedData($calendarData) + { $vObject = VObject\Reader::read($calendarData); $componentType = null; $component = null; @@ -646,16 +627,16 @@ SQL $lastOccurence = null; $uid = null; foreach ($vObject->getComponents() as $component) { - if ($component->name !== 'VTIMEZONE') { + if ('VTIMEZONE' !== $component->name) { $componentType = $component->name; - $uid = (string)$component->UID; + $uid = (string) $component->UID; break; } } if (!$componentType) { throw new \Sabre\DAV\Exception\BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component'); } - if ($componentType === 'VEVENT') { + if ('VEVENT' === $componentType) { $firstOccurence = $component->DTSTART->getDateTime()->getTimeStamp(); // Finding the last occurence is a bit harder if (!isset($component->RRULE)) { @@ -673,7 +654,7 @@ SQL $lastOccurence = $firstOccurence; } } else { - $it = new VObject\Recur\EventIterator($vObject, (string)$component->UID); + $it = new VObject\Recur\EventIterator($vObject, (string) $component->UID); $maxDate = new \DateTime(self::MAX_DATE); if ($it->isInfinite()) { $lastOccurence = $maxDate->getTimeStamp(); @@ -682,30 +663,31 @@ SQL while ($it->valid() && $end < $maxDate) { $end = $it->getDtEnd(); $it->next(); - } $lastOccurence = $end->getTimeStamp(); } - } // Ensure Occurence values are positive - if ($firstOccurence < 0) $firstOccurence = 0; - if ($lastOccurence < 0) $lastOccurence = 0; + if ($firstOccurence < 0) { + $firstOccurence = 0; + } + if ($lastOccurence < 0) { + $lastOccurence = 0; + } } // Destroy circular references to PHP will GC the object. $vObject->destroy(); return [ - 'etag' => md5($calendarData), - 'size' => strlen($calendarData), - 'componentType' => $componentType, + 'etag' => md5($calendarData), + 'size' => strlen($calendarData), + 'componentType' => $componentType, 'firstOccurence' => $firstOccurence, - 'lastOccurence' => $lastOccurence, - 'uid' => $uid, + 'lastOccurence' => $lastOccurence, + 'uid' => $uid, ]; - } /** @@ -713,22 +695,20 @@ SQL * * The object uri is only the basename, or filename and not a full path. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri - * @return void */ - function deleteCalendarObject($calendarId, $objectUri) { - + public function deleteCalendarObject($calendarId, $objectUri) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } list($calendarId, $instanceId) = $calendarId; - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ? AND uri = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarObjectTableName.' WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarId, $objectUri]); $this->addChange($calendarId, $objectUri, 3); - } /** @@ -781,10 +761,11 @@ SQL * * @param mixed $calendarId * @param array $filters + * * @return array */ - function calendarQuery($calendarId, array $filters) { - + public function calendarQuery($calendarId, array $filters) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } @@ -808,7 +789,7 @@ SQL $requirePostFilter = false; } // There was a time-range filter - if ($componentType == 'VEVENT' && isset($filters['comp-filters'][0]['time-range'])) { + if ('VEVENT' == $componentType && isset($filters['comp-filters'][0]['time-range'])) { $timeRange = $filters['comp-filters'][0]['time-range']; // If start time OR the end time is not specified, we can do a @@ -817,13 +798,12 @@ SQL $requirePostFilter = false; } } - } if ($requirePostFilter) { - $query = "SELECT uri, calendardata FROM " . $this->calendarObjectTableName . " WHERE calendarid = :calendarid"; + $query = 'SELECT uri, calendardata FROM '.$this->calendarObjectTableName.' WHERE calendarid = :calendarid'; } else { - $query = "SELECT uri FROM " . $this->calendarObjectTableName . " WHERE calendarid = :calendarid"; + $query = 'SELECT uri FROM '.$this->calendarObjectTableName.' WHERE calendarid = :calendarid'; } $values = [ @@ -831,16 +811,16 @@ SQL ]; if ($componentType) { - $query .= " AND componenttype = :componenttype"; + $query .= ' AND componenttype = :componenttype'; $values['componenttype'] = $componentType; } if ($timeRange && $timeRange['start']) { - $query .= " AND lastoccurence > :startdate"; + $query .= ' AND lastoccurence > :startdate'; $values['startdate'] = $timeRange['start']->getTimeStamp(); } if ($timeRange && $timeRange['end']) { - $query .= " AND firstoccurence < :enddate"; + $query .= ' AND firstoccurence < :enddate'; $values['enddate'] = $timeRange['end']->getTimeStamp(); } @@ -855,11 +835,9 @@ SQL } } $result[] = $row['uri']; - } return $result; - } /** @@ -879,10 +857,11 @@ SQL * * @param string $principalUri * @param string $uid + * * @return string|null */ - function getCalendarObjectByUID($principalUri, $uid) { - + public function getCalendarObjectByUID($principalUri, $uid) + { $query = <<<SQL SELECT calendar_instances.uri AS calendaruri, calendarobjects.uri as objecturi @@ -901,9 +880,8 @@ SQL; $stmt->execute([$principalUri, $uid]); if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - return $row['calendaruri'] . '/' . $row['objecturi']; + return $row['calendaruri'].'/'.$row['objecturi']; } - } /** @@ -956,37 +934,41 @@ SQL; * * The limit is 'suggestive'. You are free to ignore it. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $syncToken - * @param int $syncLevel - * @param int $limit + * @param int $syncLevel + * @param int $limit + * * @return array */ - function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) { - + public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } list($calendarId, $instanceId) = $calendarId; // Current synctoken - $stmt = $this->pdo->prepare('SELECT synctoken FROM ' . $this->calendarTableName . ' WHERE id = ?'); + $stmt = $this->pdo->prepare('SELECT synctoken FROM '.$this->calendarTableName.' WHERE id = ?'); $stmt->execute([$calendarId]); $currentToken = $stmt->fetchColumn(0); - if (is_null($currentToken)) return null; + if (is_null($currentToken)) { + return null; + } $result = [ 'syncToken' => $currentToken, - 'added' => [], - 'modified' => [], - 'deleted' => [], + 'added' => [], + 'modified' => [], + 'deleted' => [], ]; if ($syncToken) { - - $query = "SELECT uri, operation FROM " . $this->calendarChangesTableName . " WHERE synctoken >= ? AND synctoken < ? AND calendarid = ? ORDER BY synctoken"; - if ($limit > 0) $query .= " LIMIT " . (int)$limit; + $query = 'SELECT uri, operation FROM '.$this->calendarChangesTableName.' WHERE synctoken >= ? AND synctoken < ? AND calendarid = ? ORDER BY synctoken'; + if ($limit > 0) { + $query .= ' LIMIT '.(int) $limit; + } // Fetching all changes $stmt = $this->pdo->prepare($query); @@ -997,60 +979,54 @@ SQL; // This loop ensures that any duplicates are overwritten, only the // last change on a node is relevant. while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $changes[$row['uri']] = $row['operation']; - } foreach ($changes as $uri => $operation) { - switch ($operation) { - case 1 : + case 1: $result['added'][] = $uri; break; - case 2 : + case 2: $result['modified'][] = $uri; break; - case 3 : + case 3: $result['deleted'][] = $uri; break; } - } } else { // No synctoken supplied, this is the initial sync. - $query = "SELECT uri FROM " . $this->calendarObjectTableName . " WHERE calendarid = ?"; + $query = 'SELECT uri FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?'; $stmt = $this->pdo->prepare($query); $stmt->execute([$calendarId]); $result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN); } - return $result; + return $result; } /** * Adds a change record to the calendarchanges table. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri - * @param int $operation 1 = add, 2 = modify, 3 = delete. - * @return void + * @param int $operation 1 = add, 2 = modify, 3 = delete */ - protected function addChange($calendarId, $objectUri, $operation) { - - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->calendarChangesTableName . ' (uri, synctoken, calendarid, operation) SELECT ?, synctoken, ?, ? FROM ' . $this->calendarTableName . ' WHERE id = ?'); + protected function addChange($calendarId, $objectUri, $operation) + { + $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarChangesTableName.' (uri, synctoken, calendarid, operation) SELECT ?, synctoken, ?, ? FROM '.$this->calendarTableName.' WHERE id = ?'); $stmt->execute([ $objectUri, $calendarId, $operation, - $calendarId + $calendarId, ]); - $stmt = $this->pdo->prepare('UPDATE ' . $this->calendarTableName . ' SET synctoken = synctoken + 1 WHERE id = ?'); + $stmt = $this->pdo->prepare('UPDATE '.$this->calendarTableName.' SET synctoken = synctoken + 1 WHERE id = ?'); $stmt->execute([ - $calendarId + $calendarId, ]); - } /** @@ -1082,10 +1058,11 @@ SQL; * default components). * * @param string $principalUri + * * @return array */ - function getSubscriptionsForUser($principalUri) { - + public function getSubscriptionsForUser($principalUri) + { $fields = array_values($this->subscriptionPropertyMap); $fields[] = 'id'; $fields[] = 'uri'; @@ -1095,20 +1072,19 @@ SQL; // Making fields a comma-delimited list $fields = implode(', ', $fields); - $stmt = $this->pdo->prepare("SELECT " . $fields . " FROM " . $this->calendarSubscriptionsTableName . " WHERE principaluri = ? ORDER BY calendarorder ASC"); + $stmt = $this->pdo->prepare('SELECT '.$fields.' FROM '.$this->calendarSubscriptionsTableName.' WHERE principaluri = ? ORDER BY calendarorder ASC'); $stmt->execute([$principalUri]); $subscriptions = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $subscription = [ - 'id' => $row['id'], - 'uri' => $row['uri'], + 'id' => $row['id'], + 'uri' => $row['uri'], 'principaluri' => $row['principaluri'], - 'source' => $row['source'], + 'source' => $row['source'], 'lastmodified' => $row['lastmodified'], - '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VTODO', 'VEVENT']), + '{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VTODO', 'VEVENT']), ]; foreach ($this->subscriptionPropertyMap as $xmlName => $dbName) { @@ -1118,11 +1094,9 @@ SQL; } $subscriptions[] = $subscription; - } return $subscriptions; - } /** @@ -1133,11 +1107,12 @@ SQL; * * @param string $principalUri * @param string $uri - * @param array $properties + * @param array $properties + * * @return mixed */ - function createSubscription($principalUri, $uri, array $properties) { - + public function createSubscription($principalUri, $uri, array $properties) + { $fieldNames = [ 'principaluri', 'uri', @@ -1151,30 +1126,28 @@ SQL; $values = [ ':principaluri' => $principalUri, - ':uri' => $uri, - ':source' => $properties['{http://calendarserver.org/ns/}source']->getHref(), + ':uri' => $uri, + ':source' => $properties['{http://calendarserver.org/ns/}source']->getHref(), ':lastmodified' => time(), ]; foreach ($this->subscriptionPropertyMap as $xmlName => $dbName) { if (isset($properties[$xmlName])) { - - $values[':' . $dbName] = $properties[$xmlName]; + $values[':'.$dbName] = $properties[$xmlName]; $fieldNames[] = $dbName; } } - $stmt = $this->pdo->prepare("INSERT INTO " . $this->calendarSubscriptionsTableName . " (" . implode(', ', $fieldNames) . ") VALUES (" . implode(', ', array_keys($values)) . ")"); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarSubscriptionsTableName.' ('.implode(', ', $fieldNames).') VALUES ('.implode(', ', array_keys($values)).')'); $stmt->execute($values); return $this->pdo->lastInsertId( - $this->calendarSubscriptionsTableName . '_id_seq' + $this->calendarSubscriptionsTableName.'_id_seq' ); - } /** - * Updates a subscription + * Updates a subscription. * * The list of mutations is stored in a Sabre\DAV\PropPatch object. * To do the actual updates, you must tell this object which properties @@ -1185,58 +1158,50 @@ SQL; * * Read the PropPatch documentation for more info and examples. * - * @param mixed $subscriptionId + * @param mixed $subscriptionId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateSubscription($subscriptionId, DAV\PropPatch $propPatch) { - + public function updateSubscription($subscriptionId, DAV\PropPatch $propPatch) + { $supportedProperties = array_keys($this->subscriptionPropertyMap); $supportedProperties[] = '{http://calendarserver.org/ns/}source'; - $propPatch->handle($supportedProperties, function($mutations) use ($subscriptionId) { - + $propPatch->handle($supportedProperties, function ($mutations) use ($subscriptionId) { $newValues = []; foreach ($mutations as $propertyName => $propertyValue) { - - if ($propertyName === '{http://calendarserver.org/ns/}source') { + if ('{http://calendarserver.org/ns/}source' === $propertyName) { $newValues['source'] = $propertyValue->getHref(); } else { $fieldName = $this->subscriptionPropertyMap[$propertyName]; $newValues[$fieldName] = $propertyValue; } - } // Now we're generating the sql query. $valuesSql = []; foreach ($newValues as $fieldName => $value) { - $valuesSql[] = $fieldName . ' = ?'; + $valuesSql[] = $fieldName.' = ?'; } - $stmt = $this->pdo->prepare("UPDATE " . $this->calendarSubscriptionsTableName . " SET " . implode(', ', $valuesSql) . ", lastmodified = ? WHERE id = ?"); + $stmt = $this->pdo->prepare('UPDATE '.$this->calendarSubscriptionsTableName.' SET '.implode(', ', $valuesSql).', lastmodified = ? WHERE id = ?'); $newValues['lastmodified'] = time(); $newValues['id'] = $subscriptionId; $stmt->execute(array_values($newValues)); return true; - }); - } /** - * Deletes a subscription + * Deletes a subscription. * * @param mixed $subscriptionId - * @return void */ - function deleteSubscription($subscriptionId) { - - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarSubscriptionsTableName . ' WHERE id = ?'); + public function deleteSubscription($subscriptionId) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarSubscriptionsTableName.' WHERE id = ?'); $stmt->execute([$subscriptionId]); - } /** @@ -1253,24 +1218,26 @@ SQL; * * @param string $principalUri * @param string $objectUri + * * @return array */ - function getSchedulingObject($principalUri, $objectUri) { - - $stmt = $this->pdo->prepare('SELECT uri, calendardata, lastmodified, etag, size FROM ' . $this->schedulingObjectTableName . ' WHERE principaluri = ? AND uri = ?'); + public function getSchedulingObject($principalUri, $objectUri) + { + $stmt = $this->pdo->prepare('SELECT uri, calendardata, lastmodified, etag, size FROM '.$this->schedulingObjectTableName.' WHERE principaluri = ? AND uri = ?'); $stmt->execute([$principalUri, $objectUri]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if (!$row) return null; + if (!$row) { + return null; + } return [ - 'uri' => $row['uri'], + 'uri' => $row['uri'], 'calendardata' => $row['calendardata'], 'lastmodified' => $row['lastmodified'], - 'etag' => '"' . $row['etag'] . '"', - 'size' => (int)$row['size'], + 'etag' => '"'.$row['etag'].'"', + 'size' => (int) $row['size'], ]; - } /** @@ -1282,40 +1249,38 @@ SQL; * The main difference is that 'calendardata' is optional. * * @param string $principalUri + * * @return array */ - function getSchedulingObjects($principalUri) { - - $stmt = $this->pdo->prepare('SELECT id, calendardata, uri, lastmodified, etag, size FROM ' . $this->schedulingObjectTableName . ' WHERE principaluri = ?'); + public function getSchedulingObjects($principalUri) + { + $stmt = $this->pdo->prepare('SELECT id, calendardata, uri, lastmodified, etag, size FROM '.$this->schedulingObjectTableName.' WHERE principaluri = ?'); $stmt->execute([$principalUri]); $result = []; foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { $result[] = [ 'calendardata' => $row['calendardata'], - 'uri' => $row['uri'], + 'uri' => $row['uri'], 'lastmodified' => $row['lastmodified'], - 'etag' => '"' . $row['etag'] . '"', - 'size' => (int)$row['size'], + 'etag' => '"'.$row['etag'].'"', + 'size' => (int) $row['size'], ]; } return $result; - } /** - * Deletes a scheduling object + * Deletes a scheduling object. * * @param string $principalUri * @param string $objectUri - * @return void */ - function deleteSchedulingObject($principalUri, $objectUri) { - - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->schedulingObjectTableName . ' WHERE principaluri = ? AND uri = ?'); + public function deleteSchedulingObject($principalUri, $objectUri) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->schedulingObjectTableName.' WHERE principaluri = ? AND uri = ?'); $stmt->execute([$principalUri, $objectUri]); - } /** @@ -1324,35 +1289,32 @@ SQL; * @param string $principalUri * @param string $objectUri * @param string $objectData - * @return void */ - function createSchedulingObject($principalUri, $objectUri, $objectData) { - - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->schedulingObjectTableName . ' (principaluri, calendardata, uri, lastmodified, etag, size) VALUES (?, ?, ?, ?, ?, ?)'); + public function createSchedulingObject($principalUri, $objectUri, $objectData) + { + $stmt = $this->pdo->prepare('INSERT INTO '.$this->schedulingObjectTableName.' (principaluri, calendardata, uri, lastmodified, etag, size) VALUES (?, ?, ?, ?, ?, ?)'); $stmt->execute([$principalUri, $objectData, $objectUri, time(), md5($objectData), strlen($objectData)]); - } /** * Updates the list of shares. * - * @param mixed $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees - * @return void */ - function updateInvites($calendarId, array $sharees) { - + public function updateInvites($calendarId, array $sharees) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); } $currentInvites = $this->getInvites($calendarId); list($calendarId, $instanceId) = $calendarId; - $removeStmt = $this->pdo->prepare("DELETE FROM " . $this->calendarInstancesTableName . " WHERE calendarid = ? AND share_href = ? AND access IN (2,3)"); - $updateStmt = $this->pdo->prepare("UPDATE " . $this->calendarInstancesTableName . " SET access = ?, share_displayname = ?, share_invitestatus = ? WHERE calendarid = ? AND share_href = ?"); + $removeStmt = $this->pdo->prepare('DELETE FROM '.$this->calendarInstancesTableName.' WHERE calendarid = ? AND share_href = ? AND access IN (2,3)'); + $updateStmt = $this->pdo->prepare('UPDATE '.$this->calendarInstancesTableName.' SET access = ?, share_displayname = ?, share_invitestatus = ? WHERE calendarid = ? AND share_href = ?'); $insertStmt = $this->pdo->prepare(' -INSERT INTO ' . $this->calendarInstancesTableName . ' +INSERT INTO '.$this->calendarInstancesTableName.' ( calendarid, principaluri, @@ -1382,11 +1344,10 @@ INSERT INTO ' . $this->calendarInstancesTableName . ' ?, ?, ? - FROM ' . $this->calendarInstancesTableName . ' WHERE id = ?'); + FROM '.$this->calendarInstancesTableName.' WHERE id = ?'); foreach ($sharees as $sharee) { - - if ($sharee->access === \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS) { + if (\Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS === $sharee->access) { // if access was set no NOACCESS, it means access for an // existing sharee was removed. $removeStmt->execute([$calendarId, $sharee->href]); @@ -1404,7 +1365,6 @@ INSERT INTO ' . $this->calendarInstancesTableName . ' } foreach ($currentInvites as $oldSharee) { - if ($oldSharee->href === $sharee->href) { // This is an update $sharee->properties = array_merge( @@ -1416,11 +1376,10 @@ INSERT INTO ' . $this->calendarInstancesTableName . ' isset($sharee->properties['{DAV:}displayname']) ? $sharee->properties['{DAV:}displayname'] : null, $sharee->inviteStatus ?: $oldSharee->inviteStatus, $calendarId, - $sharee->href + $sharee->href, ]); continue 2; } - } // If we got here, it means it was a new sharee $insertStmt->execute([ @@ -1431,11 +1390,9 @@ INSERT INTO ' . $this->calendarInstancesTableName . ' $sharee->href, isset($sharee->properties['{DAV:}displayname']) ? $sharee->properties['{DAV:}displayname'] : null, $sharee->inviteStatus ?: \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE, - $instanceId + $instanceId, ]); - } - } /** @@ -1451,10 +1408,11 @@ INSERT INTO ' . $this->calendarInstancesTableName . ' * $properties * * @param mixed $calendarId + * * @return \Sabre\DAV\Xml\Element\Sharee[] */ - function getInvites($calendarId) { - + public function getInvites($calendarId) + { if (!is_array($calendarId)) { throw new \InvalidArgumentException('The value passed to getInvites() is expected to be an array with a calendarId and an instanceId'); } @@ -1477,35 +1435,29 @@ SQL; $result = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $result[] = new Sharee([ - 'href' => isset($row['share_href']) ? $row['share_href'] : \Sabre\HTTP\encodePath($row['principaluri']), - 'access' => (int)$row['access'], + 'href' => isset($row['share_href']) ? $row['share_href'] : \Sabre\HTTP\encodePath($row['principaluri']), + 'access' => (int) $row['access'], /// Everyone is always immediately accepted, for now. - 'inviteStatus' => (int)$row['share_invitestatus'], - 'properties' => - !empty($row['share_displayname']) + 'inviteStatus' => (int) $row['share_invitestatus'], + 'properties' => !empty($row['share_displayname']) ? ['{DAV:}displayname' => $row['share_displayname']] : [], 'principal' => $row['principaluri'], ]); - } - return $result; + return $result; } /** - * Publishes a calendar + * Publishes a calendar. * * @param mixed $calendarId - * @param bool $value - * @return void + * @param bool $value */ - function setPublishStatus($calendarId, $value) { - + public function setPublishStatus($calendarId, $value) + { throw new DAV\Exception\NotImplemented('Not implemented'); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/SchedulingSupport.php b/vendor/sabre/dav/lib/CalDAV/Backend/SchedulingSupport.php index 6ec0bf06b..7986d8c33 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/SchedulingSupport.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/SchedulingSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; /** @@ -10,8 +12,8 @@ namespace Sabre\CalDAV\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface SchedulingSupport extends BackendInterface { - +interface SchedulingSupport extends BackendInterface +{ /** * Returns a single scheduling object for the inbox collection. * @@ -26,9 +28,10 @@ interface SchedulingSupport extends BackendInterface { * * @param string $principalUri * @param string $objectUri + * * @return array */ - function getSchedulingObject($principalUri, $objectUri); + public function getSchedulingObject($principalUri, $objectUri); /** * Returns all scheduling objects for the inbox collection. @@ -39,18 +42,18 @@ interface SchedulingSupport extends BackendInterface { * The main difference is that 'calendardata' is optional. * * @param string $principalUri + * * @return array */ - function getSchedulingObjects($principalUri); + public function getSchedulingObjects($principalUri); /** * Deletes a scheduling object from the inbox collection. * * @param string $principalUri * @param string $objectUri - * @return void */ - function deleteSchedulingObject($principalUri, $objectUri); + public function deleteSchedulingObject($principalUri, $objectUri); /** * Creates a new scheduling object. This should land in a users' inbox. @@ -58,8 +61,6 @@ interface SchedulingSupport extends BackendInterface { * @param string $principalUri * @param string $objectUri * @param string $objectData - * @return void */ - function createSchedulingObject($principalUri, $objectUri, $objectData); - + public function createSchedulingObject($principalUri, $objectUri, $objectData); } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/SharingSupport.php b/vendor/sabre/dav/lib/CalDAV/Backend/SharingSupport.php index 278ec2564..ce6105990 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/SharingSupport.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/SharingSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; /** @@ -20,16 +22,15 @@ namespace Sabre\CalDAV\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface SharingSupport extends BackendInterface { - +interface SharingSupport extends BackendInterface +{ /** * Updates the list of shares. * - * @param mixed $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees - * @return void */ - function updateInvites($calendarId, array $sharees); + public function updateInvites($calendarId, array $sharees); /** * Returns the list of people whom this calendar is shared with. @@ -44,17 +45,16 @@ interface SharingSupport extends BackendInterface { * $properties * * @param mixed $calendarId + * * @return \Sabre\DAV\Xml\Element\Sharee[] */ - function getInvites($calendarId); + public function getInvites($calendarId); /** - * Publishes a calendar + * Publishes a calendar. * * @param mixed $calendarId - * @param bool $value - * @return void + * @param bool $value */ - function setPublishStatus($calendarId, $value); - + public function setPublishStatus($calendarId, $value); } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/SimplePDO.php b/vendor/sabre/dav/lib/CalDAV/Backend/SimplePDO.php index d21f7f916..b6f3c8bef 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/SimplePDO.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/SimplePDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\CalDAV; @@ -31,24 +33,23 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SimplePDO extends AbstractBackend { - +class SimplePDO extends AbstractBackend +{ /** - * pdo + * pdo. * * @var \PDO */ protected $pdo; /** - * Creates the backend + * Creates the backend. * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -73,27 +74,25 @@ class SimplePDO extends AbstractBackend { * ACL will automatically be put in read-only mode. * * @param string $principalUri + * * @return array */ - function getCalendarsForUser($principalUri) { - + public function getCalendarsForUser($principalUri) + { // Making fields a comma-delimited list - $stmt = $this->pdo->prepare("SELECT id, uri FROM simple_calendars WHERE principaluri = ? ORDER BY id ASC"); + $stmt = $this->pdo->prepare('SELECT id, uri FROM simple_calendars WHERE principaluri = ? ORDER BY id ASC'); $stmt->execute([$principalUri]); $calendars = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $calendars[] = [ - 'id' => $row['id'], - 'uri' => $row['uri'], + 'id' => $row['id'], + 'uri' => $row['uri'], 'principaluri' => $principalUri, ]; - } return $calendars; - } /** @@ -104,32 +103,30 @@ class SimplePDO extends AbstractBackend { * * @param string $principalUri * @param string $calendarUri - * @param array $properties + * @param array $properties + * * @return string */ - function createCalendar($principalUri, $calendarUri, array $properties) { - - $stmt = $this->pdo->prepare("INSERT INTO simple_calendars (principaluri, uri) VALUES (?, ?)"); + public function createCalendar($principalUri, $calendarUri, array $properties) + { + $stmt = $this->pdo->prepare('INSERT INTO simple_calendars (principaluri, uri) VALUES (?, ?)'); $stmt->execute([$principalUri, $calendarUri]); return $this->pdo->lastInsertId(); - } /** - * Delete a calendar and all it's objects + * Delete a calendar and all it's objects. * * @param string $calendarId - * @return void */ - function deleteCalendar($calendarId) { - + public function deleteCalendar($calendarId) + { $stmt = $this->pdo->prepare('DELETE FROM simple_calendarobjects WHERE calendarid = ?'); $stmt->execute([$calendarId]); $stmt = $this->pdo->prepare('DELETE FROM simple_calendars WHERE id = ?'); $stmt->execute([$calendarId]); - } /** @@ -161,27 +158,27 @@ class SimplePDO extends AbstractBackend { * amount of times this is needed is reduced by a great degree. * * @param string $calendarId + * * @return array */ - function getCalendarObjects($calendarId) { - + public function getCalendarObjects($calendarId) + { $stmt = $this->pdo->prepare('SELECT id, uri, calendardata FROM simple_calendarobjects WHERE calendarid = ?'); $stmt->execute([$calendarId]); $result = []; foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { $result[] = [ - 'id' => $row['id'], - 'uri' => $row['uri'], - 'etag' => '"' . md5($row['calendardata']) . '"', - 'calendarid' => $calendarId, - 'size' => strlen($row['calendardata']), + 'id' => $row['id'], + 'uri' => $row['uri'], + 'etag' => '"'.md5($row['calendardata']).'"', + 'calendarid' => $calendarId, + 'size' => strlen($row['calendardata']), 'calendardata' => $row['calendardata'], ]; } return $result; - } /** @@ -198,25 +195,27 @@ class SimplePDO extends AbstractBackend { * * @param string $calendarId * @param string $objectUri + * * @return array|null */ - function getCalendarObject($calendarId, $objectUri) { - + public function getCalendarObject($calendarId, $objectUri) + { $stmt = $this->pdo->prepare('SELECT id, uri, calendardata FROM simple_calendarobjects WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarId, $objectUri]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if (!$row) return null; + if (!$row) { + return null; + } return [ - 'id' => $row['id'], - 'uri' => $row['uri'], - 'etag' => '"' . md5($row['calendardata']) . '"', - 'calendarid' => $calendarId, - 'size' => strlen($row['calendardata']), + 'id' => $row['id'], + 'uri' => $row['uri'], + 'etag' => '"'.md5($row['calendardata']).'"', + 'calendarid' => $calendarId, + 'size' => strlen($row['calendardata']), 'calendardata' => $row['calendardata'], ]; - } /** @@ -232,22 +231,22 @@ class SimplePDO extends AbstractBackend { * calendar-data. If the result of a subsequent GET to this object is not * the exact same as this request body, you should omit the ETag. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri * @param string $calendarData + * * @return string|null */ - function createCalendarObject($calendarId, $objectUri, $calendarData) { - + public function createCalendarObject($calendarId, $objectUri, $calendarData) + { $stmt = $this->pdo->prepare('INSERT INTO simple_calendarobjects (calendarid, uri, calendardata) VALUES (?,?,?)'); $stmt->execute([ $calendarId, $objectUri, - $calendarData + $calendarData, ]); - return '"' . md5($calendarData) . '"'; - + return '"'.md5($calendarData).'"'; } /** @@ -263,18 +262,18 @@ class SimplePDO extends AbstractBackend { * calendar-data. If the result of a subsequent GET to this object is not * the exact same as this request body, you should omit the ETag. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri * @param string $calendarData + * * @return string|null */ - function updateCalendarObject($calendarId, $objectUri, $calendarData) { - + public function updateCalendarObject($calendarId, $objectUri, $calendarData) + { $stmt = $this->pdo->prepare('UPDATE simple_calendarobjects SET calendardata = ? WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarData, $calendarId, $objectUri]); - return '"' . md5($calendarData) . '"'; - + return '"'.md5($calendarData).'"'; } /** @@ -284,13 +283,10 @@ class SimplePDO extends AbstractBackend { * * @param string $calendarId * @param string $objectUri - * @return void */ - function deleteCalendarObject($calendarId, $objectUri) { - + public function deleteCalendarObject($calendarId, $objectUri) + { $stmt = $this->pdo->prepare('DELETE FROM simple_calendarobjects WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarId, $objectUri]); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/SubscriptionSupport.php b/vendor/sabre/dav/lib/CalDAV/Backend/SubscriptionSupport.php index d77a2fe0f..2aaf95cdb 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/SubscriptionSupport.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/SubscriptionSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\DAV; @@ -11,8 +13,8 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface SubscriptionSupport extends BackendInterface { - +interface SubscriptionSupport extends BackendInterface +{ /** * Returns a list of subscriptions for a principal. * @@ -43,9 +45,10 @@ interface SubscriptionSupport extends BackendInterface { * default components). * * @param string $principalUri + * * @return array */ - function getSubscriptionsForUser($principalUri); + public function getSubscriptionsForUser($principalUri); /** * Creates a new subscription for a principal. @@ -55,13 +58,14 @@ interface SubscriptionSupport extends BackendInterface { * * @param string $principalUri * @param string $uri - * @param array $properties + * @param array $properties + * * @return mixed */ - function createSubscription($principalUri, $uri, array $properties); + public function createSubscription($principalUri, $uri, array $properties); /** - * Updates a subscription + * Updates a subscription. * * The list of mutations is stored in a Sabre\DAV\PropPatch object. * To do the actual updates, you must tell this object which properties @@ -72,18 +76,15 @@ interface SubscriptionSupport extends BackendInterface { * * Read the PropPatch documentation for more info and examples. * - * @param mixed $subscriptionId + * @param mixed $subscriptionId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateSubscription($subscriptionId, DAV\PropPatch $propPatch); + public function updateSubscription($subscriptionId, DAV\PropPatch $propPatch); /** * Deletes a subscription. * * @param mixed $subscriptionId - * @return void */ - function deleteSubscription($subscriptionId); - + public function deleteSubscription($subscriptionId); } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/SyncSupport.php b/vendor/sabre/dav/lib/CalDAV/Backend/SyncSupport.php index a934505f9..c7f67d176 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/SyncSupport.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/SyncSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; /** @@ -18,8 +20,8 @@ namespace Sabre\CalDAV\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface SyncSupport extends BackendInterface { - +interface SyncSupport extends BackendInterface +{ /** * The getChanges method returns all the changes that have happened, since * the specified syncToken in the specified calendar. @@ -72,10 +74,10 @@ interface SyncSupport extends BackendInterface { * * @param string $calendarId * @param string $syncToken - * @param int $syncLevel - * @param int $limit + * @param int $syncLevel + * @param int $limit + * * @return array */ - function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null); - + public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null); } diff --git a/vendor/sabre/dav/lib/CalDAV/Calendar.php b/vendor/sabre/dav/lib/CalDAV/Calendar.php index 7467900cc..717f04f94 100644 --- a/vendor/sabre/dav/lib/CalDAV/Calendar.php +++ b/vendor/sabre/dav/lib/CalDAV/Calendar.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; @@ -16,46 +18,44 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, DAV\IMultiGet { - +class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, DAV\IMultiGet +{ use DAVACL\ACLTrait; /** - * This is an array with calendar information + * This is an array with calendar information. * * @var array */ protected $calendarInfo; /** - * CalDAV backend + * CalDAV backend. * * @var Backend\BackendInterface */ protected $caldavBackend; /** - * Constructor + * Constructor. * * @param Backend\BackendInterface $caldavBackend - * @param array $calendarInfo + * @param array $calendarInfo */ - function __construct(Backend\BackendInterface $caldavBackend, $calendarInfo) { - + public function __construct(Backend\BackendInterface $caldavBackend, $calendarInfo) + { $this->caldavBackend = $caldavBackend; $this->calendarInfo = $calendarInfo; - } /** - * Returns the name of the calendar + * Returns the name of the calendar. * * @return string */ - function getName() { - + public function getName() + { return $this->calendarInfo['uri']; - } /** @@ -68,69 +68,68 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * Read the PropPatch documentation for more information. * * @param PropPatch $propPatch - * @return void */ - function propPatch(PropPatch $propPatch) { - + public function propPatch(PropPatch $propPatch) + { return $this->caldavBackend->updateCalendar($this->calendarInfo['id'], $propPatch); - } /** - * Returns the list of properties + * Returns the list of properties. * * @param array $requestedProperties + * * @return array */ - function getProperties($requestedProperties) { - + public function getProperties($requestedProperties) + { $response = []; foreach ($this->calendarInfo as $propName => $propValue) { - - if (!is_null($propValue) && $propName[0] === '{') + if (!is_null($propValue) && '{' === $propName[0]) { $response[$propName] = $this->calendarInfo[$propName]; - + } } - return $response; + return $response; } /** - * Returns a calendar object + * Returns a calendar object. * * The contained calendar objects are for example Events or Todo's. * * @param string $name + * * @return \Sabre\CalDAV\ICalendarObject */ - function getChild($name) { - + public function getChild($name) + { $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); - if (!$obj) throw new DAV\Exception\NotFound('Calendar object not found'); - + if (!$obj) { + throw new DAV\Exception\NotFound('Calendar object not found'); + } $obj['acl'] = $this->getChildACL(); return new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); - } /** - * Returns the full list of calendar objects + * Returns the full list of calendar objects. * * @return array */ - function getChildren() { - + public function getChildren() + { $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']); $children = []; foreach ($objs as $obj) { $obj['acl'] = $this->getChildACL(); $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); } - return $children; + return $children; } /** @@ -140,77 +139,75 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * If any children are not found, you do not have to return them. * * @param string[] $paths + * * @return array */ - function getMultipleChildren(array $paths) { - + public function getMultipleChildren(array $paths) + { $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths); $children = []; foreach ($objs as $obj) { $obj['acl'] = $this->getChildACL(); $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); } - return $children; + return $children; } /** * Checks if a child-node exists. * * @param string $name + * * @return bool */ - function childExists($name) { - + public function childExists($name) + { $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); - if (!$obj) + if (!$obj) { return false; - else + } else { return true; - + } } /** - * Creates a new directory + * Creates a new directory. * * We actually block this, as subdirectories are not allowed in calendars. * * @param string $name - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed'); - } /** - * Creates a new file + * Creates a new file. * * The contents of the new file must be a valid ICalendar string. * - * @param string $name + * @param string $name * @param resource $calendarData + * * @return string|null */ - function createFile($name, $calendarData = null) { - + public function createFile($name, $calendarData = null) + { if (is_resource($calendarData)) { $calendarData = stream_get_contents($calendarData); } - return $this->caldavBackend->createCalendarObject($this->calendarInfo['id'], $name, $calendarData); + return $this->caldavBackend->createCalendarObject($this->calendarInfo['id'], $name, $calendarData); } /** * Deletes the calendar. - * - * @return void */ - function delete() { - + public function delete() + { $this->caldavBackend->deleteCalendar($this->calendarInfo['id']); - } /** @@ -218,36 +215,30 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * {DAV:}displayname to display a name to display a name. * * @param string $newName - * @return void */ - function setName($newName) { - + public function setName($newName) + { throw new DAV\Exception\MethodNotAllowed('Renaming calendars is not yet supported'); - } /** * Returns the last modification date as a unix timestamp. - * - * @return null */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->calendarInfo['principaluri']; - } /** @@ -262,8 +253,8 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * * @return array */ - function getACL() { - + public function getACL() + { $acl = [ [ 'privilege' => '{DAV:}read', @@ -272,20 +263,19 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-read', + 'principal' => $this->getOwner().'/calendar-proxy-read', 'protected' => true, ], [ - 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', + 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true, ], - ]; if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) { $acl[] = [ @@ -295,13 +285,12 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, ]; $acl[] = [ 'privilege' => '{DAV:}write', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ]; } return $acl; - } /** @@ -311,8 +300,8 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * * @return array */ - function getChildACL() { - + public function getChildACL() + { $acl = [ [ 'privilege' => '{DAV:}read', @@ -322,15 +311,14 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-read', + 'principal' => $this->getOwner().'/calendar-proxy-read', 'protected' => true, ], - ]; if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) { $acl[] = [ @@ -340,16 +328,14 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, ]; $acl[] = [ 'privilege' => '{DAV:}write', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ]; - } - return $acl; + return $acl; } - /** * Performs a calendar-query on the contents of this calendar. * @@ -365,12 +351,12 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * documented by Sabre\CalDAV\CalendarQueryParser. * * @param array $filters + * * @return array */ - function calendarQuery(array $filters) { - + public function calendarQuery(array $filters) + { return $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters); - } /** @@ -382,8 +368,8 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * * @return string|null */ - function getSyncToken() { - + public function getSyncToken() + { if ( $this->caldavBackend instanceof Backend\SyncSupport && isset($this->calendarInfo['{DAV:}sync-token']) @@ -396,7 +382,6 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, ) { return $this->calendarInfo['{http://sabredav.org/ns}sync-token']; } - } /** @@ -450,12 +435,13 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * The limit is 'suggestive'. You are free to ignore it. * * @param string $syncToken - * @param int $syncLevel - * @param int $limit + * @param int $syncLevel + * @param int $limit + * * @return array */ - function getChanges($syncToken, $syncLevel, $limit = null) { - + public function getChanges($syncToken, $syncLevel, $limit = null) + { if (!$this->caldavBackend instanceof Backend\SyncSupport) { return null; } @@ -466,7 +452,5 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, $syncLevel, $limit ); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/CalendarHome.php b/vendor/sabre/dav/lib/CalDAV/CalendarHome.php index ffd7f72fb..663d449bf 100644 --- a/vendor/sabre/dav/lib/CalDAV/CalendarHome.php +++ b/vendor/sabre/dav/lib/CalDAV/CalendarHome.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; use Sabre\DAV\Exception\NotFound; use Sabre\DAV\MkCol; use Sabre\DAVACL; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** * The CalendarHome represents a node that is usually in a users' @@ -20,81 +22,74 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { - +class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL +{ use DAVACL\ACLTrait; /** - * CalDAV backend + * CalDAV backend. * * @var Backend\BackendInterface */ protected $caldavBackend; /** - * Principal information + * Principal information. * * @var array */ protected $principalInfo; /** - * Constructor + * Constructor. * * @param Backend\BackendInterface $caldavBackend - * @param array $principalInfo + * @param array $principalInfo */ - function __construct(Backend\BackendInterface $caldavBackend, $principalInfo) { - + public function __construct(Backend\BackendInterface $caldavBackend, $principalInfo) + { $this->caldavBackend = $caldavBackend; $this->principalInfo = $principalInfo; - } /** - * Returns the name of this object + * Returns the name of this object. * * @return string */ - function getName() { + public function getName() + { + list(, $name) = Uri\split($this->principalInfo['uri']); - list(, $name) = URLUtil::splitPath($this->principalInfo['uri']); return $name; - } /** - * Updates the name of this object + * Updates the name of this object. * * @param string $name - * @return void */ - function setName($name) { - + public function setName($name) + { throw new DAV\Exception\Forbidden(); - } /** - * Deletes this object - * - * @return void + * Deletes this object. */ - function delete() { - + public function delete() + { throw new DAV\Exception\Forbidden(); - } /** - * Returns the last modification date + * Returns the last modification date. * * @return int */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** @@ -102,14 +97,12 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { * * This is currently not allowed * - * @param string $filename + * @param string $filename * @param resource $data - * @return void */ - function createFile($filename, $data = null) { - + public function createFile($filename, $data = null) + { throw new DAV\Exception\MethodNotAllowed('Creating new files in this collection is not supported'); - } /** @@ -118,30 +111,29 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { * This is currently not allowed. * * @param string $filename - * @return void */ - function createDirectory($filename) { - + public function createDirectory($filename) + { throw new DAV\Exception\MethodNotAllowed('Creating new collections in this collection is not supported'); - } /** - * Returns a single calendar, by name + * Returns a single calendar, by name. * * @param string $name + * * @return Calendar */ - function getChild($name) { - + public function getChild($name) + { // Special nodes - if ($name === 'inbox' && $this->caldavBackend instanceof Backend\SchedulingSupport) { + if ('inbox' === $name && $this->caldavBackend instanceof Backend\SchedulingSupport) { return new Schedule\Inbox($this->caldavBackend, $this->principalInfo['uri']); } - if ($name === 'outbox' && $this->caldavBackend instanceof Backend\SchedulingSupport) { + if ('outbox' === $name && $this->caldavBackend instanceof Backend\SchedulingSupport) { return new Schedule\Outbox($this->principalInfo['uri']); } - if ($name === 'notifications' && $this->caldavBackend instanceof Backend\NotificationSupport) { + if ('notifications' === $name && $this->caldavBackend instanceof Backend\NotificationSupport) { return new Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); } @@ -162,36 +154,34 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { return new Subscriptions\Subscription($this->caldavBackend, $subscription); } } - } - throw new NotFound('Node with name \'' . $name . '\' could not be found'); - + throw new NotFound('Node with name \''.$name.'\' could not be found'); } /** * Checks if a calendar exists. * * @param string $name + * * @return bool */ - function childExists($name) { - + public function childExists($name) + { try { - return !!$this->getChild($name); + return (bool) $this->getChild($name); } catch (NotFound $e) { return false; } - } /** - * Returns a list of calendars + * Returns a list of calendars. * * @return array */ - function getChildren() { - + public function getChildren() + { $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); $objs = []; foreach ($calendars as $calendar) { @@ -220,35 +210,34 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { } return $objs; - } /** * Creates a new calendar or subscription. * * @param string $name - * @param MkCol $mkCol + * @param MkCol $mkCol + * * @throws DAV\Exception\InvalidResourceType - * @return void */ - function createExtendedCollection($name, MkCol $mkCol) { - + public function createExtendedCollection($name, MkCol $mkCol) + { $isCalendar = false; $isSubscription = false; foreach ($mkCol->getResourceType() as $rt) { switch ($rt) { - case '{DAV:}collection' : - case '{http://calendarserver.org/ns/}shared-owner' : + case '{DAV:}collection': + case '{http://calendarserver.org/ns/}shared-owner': // ignore break; - case '{urn:ietf:params:xml:ns:caldav}calendar' : + case '{urn:ietf:params:xml:ns:caldav}calendar': $isCalendar = true; break; - case '{http://calendarserver.org/ns/}subscribed' : + case '{http://calendarserver.org/ns/}subscribed': $isSubscription = true; break; - default : - throw new DAV\Exception\InvalidResourceType('Unknown resourceType: ' . $rt); + default: + throw new DAV\Exception\InvalidResourceType('Unknown resourceType: '.$rt); } } @@ -260,15 +249,11 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { throw new DAV\Exception\InvalidResourceType('This backend does not support subscriptions'); } $this->caldavBackend->createSubscription($this->principalInfo['uri'], $name, $properties); - } elseif ($isCalendar) { $this->caldavBackend->createCalendar($this->principalInfo['uri'], $name, $properties); - } else { throw new DAV\Exception\InvalidResourceType('You can only create calendars and subscriptions in this collection'); - } - } /** @@ -276,10 +261,9 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { * * @return string */ - function getOwner() { - + public function getOwner() + { return $this->principalInfo['uri']; - } /** @@ -294,8 +278,8 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ 'privilege' => '{DAV:}read', @@ -309,46 +293,43 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-write', + 'principal' => $this->principalInfo['uri'].'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}write', - 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-write', + 'principal' => $this->principalInfo['uri'].'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-read', + 'principal' => $this->principalInfo['uri'].'/calendar-proxy-read', 'protected' => true, ], - ]; - } - /** * This method is called when a user replied to a request to share. * * This method should return the url of the newly created calendar if the * share was accepted. * - * @param string $href The sharee who is replying (often a mailto: address) - * @param int $status One of the SharingPlugin::STATUS_* constants + * @param string $href The sharee who is replying (often a mailto: address) + * @param int $status One of the SharingPlugin::STATUS_* constants * @param string $calendarUri The url to the calendar thats being shared - * @param string $inReplyTo The unique id this message is a response to - * @param string $summary A description of the reply - * @return null|string + * @param string $inReplyTo The unique id this message is a response to + * @param string $summary A description of the reply + * + * @return string|null */ - function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null) { - + public function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null) + { if (!$this->caldavBackend instanceof Backend\SharingSupport) { throw new DAV\Exception\NotImplemented('Sharing support is not implemented by this backend.'); } return $this->caldavBackend->shareReply($href, $status, $calendarUri, $inReplyTo, $summary); - } /** @@ -367,12 +348,11 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { * collection should be ignored. * * @param string $uid + * * @return string|null */ - function getCalendarObjectByUID($uid) { - + public function getCalendarObjectByUID($uid) + { return $this->caldavBackend->getCalendarObjectByUID($this->principalInfo['uri'], $uid); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/CalendarObject.php b/vendor/sabre/dav/lib/CalDAV/CalendarObject.php index 9d6532a35..3f28ee7f7 100644 --- a/vendor/sabre/dav/lib/CalDAV/CalendarObject.php +++ b/vendor/sabre/dav/lib/CalDAV/CalendarObject.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; /** @@ -9,33 +11,33 @@ namespace Sabre\CalDAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\DAVACL\IACL { - +class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\DAVACL\IACL +{ use \Sabre\DAVACL\ACLTrait; /** - * Sabre\CalDAV\Backend\BackendInterface + * Sabre\CalDAV\Backend\BackendInterface. * * @var Backend\AbstractBackend */ protected $caldavBackend; /** - * Array with information about this CalendarObject + * Array with information about this CalendarObject. * * @var array */ protected $objectData; /** - * Array with information about the containing calendar + * Array with information about the containing calendar. * * @var array */ protected $calendarInfo; /** - * Constructor + * Constructor. * * The following properties may be passed within $objectData: * @@ -49,11 +51,11 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ * * acl - (optional) Use this to override the default ACL for the node. * * @param Backend\BackendInterface $caldavBackend - * @param array $calendarInfo - * @param array $objectData + * @param array $calendarInfo + * @param array $objectData */ - function __construct(Backend\BackendInterface $caldavBackend, array $calendarInfo, array $objectData) { - + public function __construct(Backend\BackendInterface $caldavBackend, array $calendarInfo, array $objectData) + { $this->caldavBackend = $caldavBackend; if (!isset($objectData['uri'])) { @@ -62,44 +64,43 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ $this->calendarInfo = $calendarInfo; $this->objectData = $objectData; - } /** - * Returns the uri for this object + * Returns the uri for this object. * * @return string */ - function getName() { - + public function getName() + { return $this->objectData['uri']; - } /** - * Returns the ICalendar-formatted object + * Returns the ICalendar-formatted object. * * @return string */ - function get() { - + public function get() + { // Pre-populating the 'calendardata' is optional, if we don't have it // already we fetch it from the backend. if (!isset($this->objectData['calendardata'])) { $this->objectData = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $this->objectData['uri']); } - return $this->objectData['calendardata']; + return $this->objectData['calendardata']; } /** - * Updates the ICalendar-formatted object + * Updates the ICalendar-formatted object. * * @param string|resource $calendarData + * * @return string */ - function put($calendarData) { - + public function put($calendarData) + { if (is_resource($calendarData)) { $calendarData = stream_get_contents($calendarData); } @@ -108,33 +109,29 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ $this->objectData['etag'] = $etag; return $etag; - } /** - * Deletes the calendar object - * - * @return void + * Deletes the calendar object. */ - function delete() { - + public function delete() + { $this->caldavBackend->deleteCalendarObject($this->calendarInfo['id'], $this->objectData['uri']); - } /** - * Returns the mime content-type + * Returns the mime content-type. * * @return string */ - function getContentType() { - + public function getContentType() + { $mime = 'text/calendar; charset=utf-8'; if (isset($this->objectData['component']) && $this->objectData['component']) { - $mime .= '; component=' . $this->objectData['component']; + $mime .= '; component='.$this->objectData['component']; } - return $mime; + return $mime; } /** @@ -144,53 +141,49 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ * * @return string */ - function getETag() { - + public function getETag() + { if (isset($this->objectData['etag'])) { return $this->objectData['etag']; } else { - return '"' . md5($this->get()) . '"'; + return '"'.md5($this->get()).'"'; } - } /** - * Returns the last modification date as a unix timestamp + * Returns the last modification date as a unix timestamp. * * @return int */ - function getLastModified() { - + public function getLastModified() + { return $this->objectData['lastmodified']; - } /** - * Returns the size of this object in bytes + * Returns the size of this object in bytes. * * @return int */ - function getSize() { - + public function getSize() + { if (array_key_exists('size', $this->objectData)) { return $this->objectData['size']; } else { return strlen($this->get()); } - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->calendarInfo['principaluri']; - } /** @@ -205,8 +198,8 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ * * @return array */ - function getACL() { - + public function getACL() + { // An alternative acl may be specified in the object data. if (isset($this->objectData['acl'])) { return $this->objectData['acl']; @@ -221,17 +214,14 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ ], [ 'privilege' => '{DAV:}all', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read', 'protected' => true, ], - ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php b/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php index df8008fe2..0e7f1307d 100644 --- a/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php +++ b/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use DateTime; use Sabre\VObject; /** - * CalendarQuery Validator + * CalendarQuery Validator. * * This class is responsible for checking if an iCalendar object matches a set * of filters. The main function to do this is 'validate'. @@ -18,19 +20,20 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CalendarQueryValidator { - +class CalendarQueryValidator +{ /** - * Verify if a list of filters applies to the calendar data object + * Verify if a list of filters applies to the calendar data object. * * The list of filters must be formatted as parsed by \Sabre\CalDAV\CalendarQueryParser * * @param VObject\Component\VCalendar $vObject - * @param array $filters + * @param array $filters + * * @return bool */ - function validate(VObject\Component\VCalendar $vObject, array $filters) { - + public function validate(VObject\Component\VCalendar $vObject, array $filters) + { // The top level object is always a component filter. // We'll parse it manually, as it's pretty simple. if ($vObject->name !== $filters['name']) { @@ -40,8 +43,6 @@ class CalendarQueryValidator { return $this->validateCompFilters($vObject, $filters['comp-filters']) && $this->validatePropFilters($vObject, $filters['prop-filters']); - - } /** @@ -52,23 +53,21 @@ class CalendarQueryValidator { * itself. * * @param VObject\Component $parent - * @param array $filters + * @param array $filters + * * @return bool */ - protected function validateCompFilters(VObject\Component $parent, array $filters) { - + protected function validateCompFilters(VObject\Component $parent, array $filters) + { foreach ($filters as $filter) { - $isDefined = isset($parent->{$filter['name']}); if ($filter['is-not-defined']) { - if ($isDefined) { return false; } else { continue; } - } if (!$isDefined) { return false; @@ -80,6 +79,7 @@ class CalendarQueryValidator { continue 2; } } + return false; } @@ -90,27 +90,23 @@ class CalendarQueryValidator { // If there are sub-filters, we need to find at least one component // for which the subfilters hold true. foreach ($parent->{$filter['name']} as $subComponent) { - if ( $this->validateCompFilters($subComponent, $filter['comp-filters']) && $this->validatePropFilters($subComponent, $filter['prop-filters'])) { - // We had a match, so this comp-filter succeeds - continue 2; + // We had a match, so this comp-filter succeeds + continue 2; } - } // If we got here it means there were sub-comp-filters or // sub-prop-filters and there was no match. This means this filter // needs to return false. return false; - } // If we got here it means we got through all comp-filters alive so the // filters were all true. return true; - } /** @@ -121,23 +117,21 @@ class CalendarQueryValidator { * itself. * * @param VObject\Component $parent - * @param array $filters + * @param array $filters + * * @return bool */ - protected function validatePropFilters(VObject\Component $parent, array $filters) { - + protected function validatePropFilters(VObject\Component $parent, array $filters) + { foreach ($filters as $filter) { - $isDefined = isset($parent->{$filter['name']}); if ($filter['is-not-defined']) { - if ($isDefined) { return false; } else { continue; } - } if (!$isDefined) { return false; @@ -149,6 +143,7 @@ class CalendarQueryValidator { continue 2; } } + return false; } @@ -159,7 +154,6 @@ class CalendarQueryValidator { // If there are sub-filters, we need to find at least one property // for which the subfilters hold true. foreach ($parent->{$filter['name']} as $subComponent) { - if ( $this->validateParamFilters($subComponent, $filter['param-filters']) && (!$filter['text-match'] || $this->validateTextMatch($subComponent, $filter['text-match'])) @@ -167,20 +161,17 @@ class CalendarQueryValidator { // We had a match, so this prop-filter succeeds continue 2; } - } // If we got here it means there were sub-param-filters or // text-match filters and there was no match. This means the // filter needs to return false. return false; - } // If we got here it means we got through all prop-filters alive so the // filters were all true. return true; - } /** @@ -191,23 +182,21 @@ class CalendarQueryValidator { * itself. * * @param VObject\Property $parent - * @param array $filters + * @param array $filters + * * @return bool */ - protected function validateParamFilters(VObject\Property $parent, array $filters) { - + protected function validateParamFilters(VObject\Property $parent, array $filters) + { foreach ($filters as $filter) { - $isDefined = isset($parent[$filter['name']]); if ($filter['is-not-defined']) { - if ($isDefined) { return false; } else { continue; } - } if (!$isDefined) { return false; @@ -220,24 +209,20 @@ class CalendarQueryValidator { // If there are sub-filters, we need to find at least one parameter // for which the subfilters hold true. foreach ($parent[$filter['name']]->getParts() as $paramPart) { - if ($this->validateTextMatch($paramPart, $filter['text-match'])) { // We had a match, so this param-filter succeeds continue 2; } - } // If we got here it means there was a text-match filter and there // were no matches. This means the filter needs to return false. return false; - } // If we got here it means we got through all param-filters alive so the // filters were all true. return true; - } /** @@ -246,20 +231,20 @@ class CalendarQueryValidator { * A single text-match should be specified as well as the specific property * or parameter we need to validate. * - * @param VObject\Node|string $check Value to check against. - * @param array $textMatch + * @param VObject\Node|string $check value to check against + * @param array $textMatch + * * @return bool */ - protected function validateTextMatch($check, array $textMatch) { - + protected function validateTextMatch($check, array $textMatch) + { if ($check instanceof VObject\Node) { $check = $check->getValue(); } $isMatching = \Sabre\DAV\StringUtil::textMatch($check, $textMatch['value'], $textMatch['collation']); - return ($textMatch['negate-condition'] xor $isMatching); - + return $textMatch['negate-condition'] xor $isMatching; } /** @@ -269,12 +254,13 @@ class CalendarQueryValidator { * complex. * * @param VObject\Node $component - * @param DateTime $start - * @param DateTime $end + * @param DateTime $start + * @param DateTime $end + * * @return bool */ - protected function validateTimeRange(VObject\Node $component, $start, $end) { - + protected function validateTimeRange(VObject\Node $component, $start, $end) + { if (is_null($start)) { $start = new DateTime('1900-01-01'); } @@ -283,14 +269,13 @@ class CalendarQueryValidator { } switch ($component->name) { - - case 'VEVENT' : - case 'VTODO' : - case 'VJOURNAL' : + case 'VEVENT': + case 'VTODO': + case 'VJOURNAL': return $component->isInTimeRange($start, $end); - case 'VALARM' : + case 'VALARM': // If the valarm is wrapped in a recurring event, we need to // expand the recursions, and validate each. @@ -298,10 +283,9 @@ class CalendarQueryValidator { // Our datamodel doesn't easily allow us to do this straight // in the VALARM component code, so this is a hack, and an // expensive one too. - if ($component->parent->name === 'VEVENT' && $component->parent->RRULE) { - + if ('VEVENT' === $component->parent->name && $component->parent->RRULE) { // Fire up the iterator! - $it = new VObject\Recur\EventIterator($component->parent->parent, (string)$component->parent->UID); + $it = new VObject\Recur\EventIterator($component->parent->parent, (string) $component->parent->UID); while ($it->valid()) { $expandedEvent = $it->getEventObject(); @@ -309,15 +293,14 @@ class CalendarQueryValidator { // one is the first to trigger. Based on this, we can // determine if we can 'give up' expanding events. $firstAlarm = null; - if ($expandedEvent->VALARM !== null) { + if (null !== $expandedEvent->VALARM) { foreach ($expandedEvent->VALARM as $expandedAlarm) { - $effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime(); if ($expandedAlarm->isInTimeRange($start, $end)) { return true; } - if ((string)$expandedAlarm->TRIGGER['VALUE'] === 'DATE-TIME') { + if ('DATE-TIME' === (string) $expandedAlarm->TRIGGER['VALUE']) { // This is an alarm with a non-relative trigger // time, likely created by a buggy client. The // implication is that every alarm in this @@ -346,30 +329,26 @@ class CalendarQueryValidator { } $it->next(); } + return false; } else { return $component->isInTimeRange($start, $end); } - case 'VFREEBUSY' : - throw new \Sabre\DAV\Exception\NotImplemented('time-range filters are currently not supported on ' . $component->name . ' components'); - - case 'COMPLETED' : - case 'CREATED' : - case 'DTEND' : - case 'DTSTAMP' : - case 'DTSTART' : - case 'DUE' : - case 'LAST-MODIFIED' : - return ($start <= $component->getDateTime() && $end >= $component->getDateTime()); - - - - default : - throw new \Sabre\DAV\Exception\BadRequest('You cannot create a time-range filter on a ' . $component->name . ' component'); - + // no break + case 'VFREEBUSY': + throw new \Sabre\DAV\Exception\NotImplemented('time-range filters are currently not supported on '.$component->name.' components'); + case 'COMPLETED': + case 'CREATED': + case 'DTEND': + case 'DTSTAMP': + case 'DTSTART': + case 'DUE': + case 'LAST-MODIFIED': + return $start <= $component->getDateTime() && $end >= $component->getDateTime(); + + default: + throw new \Sabre\DAV\Exception\BadRequest('You cannot create a time-range filter on a '.$component->name.' component'); } - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/CalendarRoot.php b/vendor/sabre/dav/lib/CalDAV/CalendarRoot.php index 1d6b2ac9f..42f1a44d5 100644 --- a/vendor/sabre/dav/lib/CalDAV/CalendarRoot.php +++ b/vendor/sabre/dav/lib/CalDAV/CalendarRoot.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAVACL\PrincipalBackend; /** - * Calendars collection + * Calendars collection. * * This object is responsible for generating a list of calendar-homes for each * user. @@ -17,17 +19,17 @@ use Sabre\DAVACL\PrincipalBackend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CalendarRoot extends \Sabre\DAVACL\AbstractPrincipalCollection { - +class CalendarRoot extends \Sabre\DAVACL\AbstractPrincipalCollection +{ /** - * CalDAV backend + * CalDAV backend. * * @var Backend\BackendInterface */ protected $caldavBackend; /** - * Constructor + * Constructor. * * This constructor needs both an authentication and a caldav backend. * @@ -37,28 +39,26 @@ class CalendarRoot extends \Sabre\DAVACL\AbstractPrincipalCollection { * to override this. * * @param PrincipalBackend\BackendInterface $principalBackend - * @param Backend\BackendInterface $caldavBackend - * @param string $principalPrefix + * @param Backend\BackendInterface $caldavBackend + * @param string $principalPrefix */ - function __construct(PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $caldavBackend, $principalPrefix = 'principals') { - + public function __construct(PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $caldavBackend, $principalPrefix = 'principals') + { parent::__construct($principalBackend, $principalPrefix); $this->caldavBackend = $caldavBackend; - } /** - * Returns the nodename + * Returns the nodename. * * We're overriding this, because the default will be the 'principalPrefix', * and we want it to be Sabre\CalDAV\Plugin::CALENDAR_ROOT * * @return string */ - function getName() { - + public function getName() + { return Plugin::CALENDAR_ROOT; - } /** @@ -69,12 +69,11 @@ class CalendarRoot extends \Sabre\DAVACL\AbstractPrincipalCollection { * supplied by the authentication backend. * * @param array $principal + * * @return \Sabre\DAV\INode */ - function getChildForPrincipal(array $principal) { - + public function getChildForPrincipal(array $principal) + { return new CalendarHome($this->caldavBackend, $principal); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Exception/InvalidComponentType.php b/vendor/sabre/dav/lib/CalDAV/Exception/InvalidComponentType.php index 7aff2edab..3385ad8fe 100644 --- a/vendor/sabre/dav/lib/CalDAV/Exception/InvalidComponentType.php +++ b/vendor/sabre/dav/lib/CalDAV/Exception/InvalidComponentType.php @@ -1,35 +1,34 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Exception; use Sabre\CalDAV; use Sabre\DAV; /** - * InvalidComponentType + * InvalidComponentType. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InvalidComponentType extends DAV\Exception\Forbidden { - +class InvalidComponentType extends DAV\Exception\Forbidden +{ /** * Adds in extra information in the xml response. * * This method adds the {CALDAV:}supported-calendar-component as defined in rfc4791 * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS(CalDAV\Plugin::NS_CALDAV, 'cal:supported-calendar-component'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php b/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php index fc8b971f3..717d3a9c9 100644 --- a/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php +++ b/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use DateTime; @@ -11,7 +13,7 @@ use Sabre\HTTP\ResponseInterface; use Sabre\VObject; /** - * ICS Exporter + * ICS Exporter. * * This plugin adds the ability to export entire calendars as .ics files. * This is useful for clients that don't support CalDAV yet. They often do @@ -44,44 +46,49 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ICSExportPlugin extends DAV\ServerPlugin { - +class ICSExportPlugin extends DAV\ServerPlugin +{ /** - * Reference to Server class + * Reference to Server class. * * @var \Sabre\DAV\Server */ protected $server; /** - * Initializes the plugin and registers event handlers + * Initializes the plugin and registers event handlers. * * @param \Sabre\DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $server->on('method:GET', [$this, 'httpGet'], 90); - $server->on('browserButtonActions', function($path, $node, &$actions) { + $server->on('browserButtonActions', function ($path, $node, &$actions) { if ($node instanceof ICalendar) { - $actions .= '<a href="' . htmlspecialchars($path, ENT_QUOTES, 'UTF-8') . '?export"><span class="oi" data-glyph="calendar"></span></a>'; + $actions .= '<a href="'.htmlspecialchars($path, ENT_QUOTES, 'UTF-8').'?export"><span class="oi" data-glyph="calendar"></span></a>'; } }); - } /** * Intercepts GET requests on calendar urls ending with ?export. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * + * @throws BadRequest + * @throws DAV\Exception\NotFound + * @throws VObject\InvalidDataException + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $queryParams = $request->getQueryParameters(); - if (!array_key_exists('export', $queryParams)) return; + if (!array_key_exists('export', $queryParams)) { + return; + } $path = $request->getPath(); @@ -93,7 +100,7 @@ class ICSExportPlugin extends DAV\ServerPlugin { '{http://apple.com/ns/ical/}calendar-color', ]); - if (!isset($node['{DAV:}resourcetype']) || !$node['{DAV:}resourcetype']->is('{' . Plugin::NS_CALDAV . '}calendar')) { + if (!isset($node['{DAV:}resourcetype']) || !$node['{DAV:}resourcetype']->is('{'.Plugin::NS_CALDAV.'}calendar')) { return; } // Marking the transactionType, for logging purposes. @@ -117,7 +124,7 @@ class ICSExportPlugin extends DAV\ServerPlugin { } $end = DateTime::createFromFormat('U', $queryParams['end']); } - if (isset($queryParams['expand']) && !!$queryParams['expand']) { + if (isset($queryParams['expand']) && (bool) $queryParams['expand']) { if (!$start || !$end) { throw new BadRequest('If you\'d like to expand recurrences, you must specify both a start= and end= parameter.'); } @@ -126,12 +133,12 @@ class ICSExportPlugin extends DAV\ServerPlugin { } if (isset($queryParams['componentType'])) { if (!in_array($queryParams['componentType'], ['VEVENT', 'VTODO', 'VJOURNAL'])) { - throw new BadRequest('You are not allowed to search for components of type: ' . $queryParams['componentType'] . ' here'); + throw new BadRequest('You are not allowed to search for components of type: '.$queryParams['componentType'].' here'); } $componentType = $queryParams['componentType']; } - $format = \Sabre\HTTP\Util::Negotiate( + $format = \Sabre\HTTP\negotiateContentType( $request->getHeader('Accept'), [ 'text/calendar', @@ -140,7 +147,7 @@ class ICSExportPlugin extends DAV\ServerPlugin { ); if (isset($queryParams['accept'])) { - if ($queryParams['accept'] === 'application/calendar+json' || $queryParams['accept'] === 'jcal') { + if ('application/calendar+json' === $queryParams['accept'] || 'jcal' === $queryParams['accept']) { $format = 'application/calendar+json'; } } @@ -152,61 +159,61 @@ class ICSExportPlugin extends DAV\ServerPlugin { // Returning false to break the event chain return false; - } /** * This method is responsible for generating the actual, full response. * - * @param string $path - * @param DateTime|null $start - * @param DateTime|null $end - * @param bool $expand - * @param string $componentType - * @param string $format - * @param array $properties + * @param string $path + * @param DateTime|null $start + * @param DateTime|null $end + * @param bool $expand + * @param string $componentType + * @param string $format + * @param array $properties * @param ResponseInterface $response + * + * @throws DAV\Exception\NotFound + * @throws VObject\InvalidDataException */ - protected function generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, ResponseInterface $response) { - - $calDataProp = '{' . Plugin::NS_CALDAV . '}calendar-data'; + protected function generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, ResponseInterface $response) + { + $calDataProp = '{'.Plugin::NS_CALDAV.'}calendar-data'; $calendarNode = $this->server->tree->getNodeForPath($path); $blobs = []; if ($start || $end || $componentType) { - // If there was a start or end filter, we need to enlist // calendarQuery for speed. $queryResult = $calendarNode->calendarQuery([ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => $componentType, - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => $componentType, + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => $start, - 'end' => $end, + 'end' => $end, ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]); // queryResult is just a list of base urls. We need to prefix the // calendar path. $queryResult = array_map( - function($item) use ($path) { - return $path . '/' . $item; + function ($item) use ($path) { + return $path.'/'.$item; }, $queryResult ); $nodes = $this->server->getPropertiesForMultiplePaths($queryResult, [$calDataProp]); unset($queryResult); - } else { $nodes = $this->server->getPropertiesForPath($path, [$calDataProp], 1); } @@ -228,7 +235,7 @@ class ICSExportPlugin extends DAV\ServerPlugin { $calendarTimeZone = null; // We're expanding, and for that we need to figure out the // calendar's timezone. - $tzProp = '{' . Plugin::NS_CALDAV . '}calendar-timezone'; + $tzProp = '{'.Plugin::NS_CALDAV.'}calendar-timezone'; $tzResult = $this->server->getProperties($path, [$tzProp]); if (isset($tzResult[$tzProp])) { // This property contains a VCALENDAR with a single @@ -249,11 +256,11 @@ class ICSExportPlugin extends DAV\ServerPlugin { $filenameExtension = '.ics'; switch ($format) { - case 'text/calendar' : + case 'text/calendar': $mergedCalendar = $mergedCalendar->serialize(); $filenameExtension = '.ics'; break; - case 'application/calendar+json' : + case 'application/calendar+json': $mergedCalendar = json_encode($mergedCalendar->jsonSerialize()); $filenameExtension = '.json'; break; @@ -264,29 +271,29 @@ class ICSExportPlugin extends DAV\ServerPlugin { '', $calendarNode->getName() ); - $filename .= '-' . date('Y-m-d') . $filenameExtension; + $filename .= '-'.date('Y-m-d').$filenameExtension; - $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); + $response->setHeader('Content-Disposition', 'attachment; filename="'.$filename.'"'); $response->setHeader('Content-Type', $format); $response->setStatus(200); $response->setBody($mergedCalendar); - } /** * Merges all calendar objects, and builds one big iCalendar blob. * - * @param array $properties Some CalDAV properties + * @param array $properties Some CalDAV properties * @param array $inputObjects + * * @return VObject\Component\VCalendar */ - function mergeObjects(array $properties, array $inputObjects) { - + public function mergeObjects(array $properties, array $inputObjects) + { $calendar = new VObject\Component\VCalendar(); $calendar->VERSION = '2.0'; if (DAV\Server::$exposeVersion) { - $calendar->PRODID = '-//SabreDAV//SabreDAV ' . DAV\Version::VERSION . '//EN'; + $calendar->PRODID = '-//SabreDAV//SabreDAV '.DAV\Version::VERSION.'//EN'; } else { $calendar->PRODID = '-//SabreDAV//SabreDAV//EN'; } @@ -303,41 +310,41 @@ class ICSExportPlugin extends DAV\ServerPlugin { $objects = []; foreach ($inputObjects as $href => $inputObject) { - $nodeComp = VObject\Reader::read($inputObject); foreach ($nodeComp->children() as $child) { - switch ($child->name) { - case 'VEVENT' : - case 'VTODO' : - case 'VJOURNAL' : + case 'VEVENT': + case 'VTODO': + case 'VJOURNAL': $objects[] = clone $child; break; // VTIMEZONE is special, because we need to filter out the duplicates - case 'VTIMEZONE' : + case 'VTIMEZONE': // Naively just checking tzid. - if (in_array((string)$child->TZID, $collectedTimezones)) continue; + if (in_array((string) $child->TZID, $collectedTimezones)) { + break; + } $timezones[] = clone $child; $collectedTimezones[] = $child->TZID; break; - } - } // Destroy circular references to PHP will GC the object. $nodeComp->destroy(); unset($nodeComp); - } - foreach ($timezones as $tz) $calendar->add($tz); - foreach ($objects as $obj) $calendar->add($obj); + foreach ($timezones as $tz) { + $calendar->add($tz); + } + foreach ($objects as $obj) { + $calendar->add($obj); + } return $calendar; - } /** @@ -348,10 +355,9 @@ class ICSExportPlugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'ics-export'; - } /** @@ -365,14 +371,12 @@ class ICSExportPlugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds the ability to export CalDAV calendars as a single iCalendar file.', - 'link' => 'http://sabre.io/dav/ics-export-plugin/', + 'link' => 'http://sabre.io/dav/ics-export-plugin/', ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/ICalendar.php b/vendor/sabre/dav/lib/CalDAV/ICalendar.php index 7cf4b1256..8636e0bae 100644 --- a/vendor/sabre/dav/lib/CalDAV/ICalendar.php +++ b/vendor/sabre/dav/lib/CalDAV/ICalendar.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAVACL; /** - * Calendar interface + * Calendar interface. * * Implement this interface to allow a node to be recognized as an calendar. * @@ -13,6 +15,6 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ICalendar extends ICalendarObjectContainer, DAVACL\IACL { - +interface ICalendar extends ICalendarObjectContainer, DAVACL\IACL +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/ICalendarObject.php b/vendor/sabre/dav/lib/CalDAV/ICalendarObject.php index b3a767b74..86d9be634 100644 --- a/vendor/sabre/dav/lib/CalDAV/ICalendarObject.php +++ b/vendor/sabre/dav/lib/CalDAV/ICalendarObject.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; /** - * CalendarObject interface + * CalendarObject interface. * * Extend the ICalendarObject interface to allow your custom nodes to be picked up as * CalendarObjects. @@ -16,6 +18,6 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ICalendarObject extends DAV\IFile { - +interface ICalendarObject extends DAV\IFile +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/ICalendarObjectContainer.php b/vendor/sabre/dav/lib/CalDAV/ICalendarObjectContainer.php index 0308b8a55..d9346f311 100644 --- a/vendor/sabre/dav/lib/CalDAV/ICalendarObjectContainer.php +++ b/vendor/sabre/dav/lib/CalDAV/ICalendarObjectContainer.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; /** @@ -15,8 +17,8 @@ namespace Sabre\CalDAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ICalendarObjectContainer extends \Sabre\DAV\ICollection { - +interface ICalendarObjectContainer extends \Sabre\DAV\ICollection +{ /** * Performs a calendar-query on the contents of this calendar. * @@ -32,8 +34,8 @@ interface ICalendarObjectContainer extends \Sabre\DAV\ICollection { * documented by \Sabre\CalDAV\CalendarQueryParser. * * @param array $filters + * * @return array */ - function calendarQuery(array $filters); - + public function calendarQuery(array $filters); } diff --git a/vendor/sabre/dav/lib/CalDAV/ISharedCalendar.php b/vendor/sabre/dav/lib/CalDAV/ISharedCalendar.php index 15f3b5335..e3e9a7314 100644 --- a/vendor/sabre/dav/lib/CalDAV/ISharedCalendar.php +++ b/vendor/sabre/dav/lib/CalDAV/ISharedCalendar.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV\Sharing\ISharedNode; @@ -11,8 +13,8 @@ use Sabre\DAV\Sharing\ISharedNode; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ISharedCalendar extends ISharedNode { - +interface ISharedCalendar extends ISharedNode +{ /** * Marks this calendar as published. * @@ -20,7 +22,6 @@ interface ISharedCalendar extends ISharedNode { * subscribable calendar. * * @param bool $value - * @return void */ - function setPublishStatus($value); + public function setPublishStatus($value); } diff --git a/vendor/sabre/dav/lib/CalDAV/Notifications/Collection.php b/vendor/sabre/dav/lib/CalDAV/Notifications/Collection.php index 557832a5a..884f205e4 100644 --- a/vendor/sabre/dav/lib/CalDAV/Notifications/Collection.php +++ b/vendor/sabre/dav/lib/CalDAV/Notifications/Collection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Notifications; use Sabre\CalDAV; @@ -20,49 +22,47 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Collection extends DAV\Collection implements ICollection, DAVACL\IACL { - +class Collection extends DAV\Collection implements ICollection, DAVACL\IACL +{ use DAVACL\ACLTrait; /** - * The notification backend + * The notification backend. * * @var CalDAV\Backend\NotificationSupport */ protected $caldavBackend; /** - * Principal uri + * Principal uri. * * @var string */ protected $principalUri; /** - * Constructor + * Constructor. * * @param CalDAV\Backend\NotificationSupport $caldavBackend - * @param string $principalUri + * @param string $principalUri */ - function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri) { - + public function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri) + { $this->caldavBackend = $caldavBackend; $this->principalUri = $principalUri; - } /** - * Returns all notifications for a principal + * Returns all notifications for a principal. * * @return array */ - function getChildren() { - + public function getChildren() + { $children = []; $notifications = $this->caldavBackend->getNotificationsForPrincipal($this->principalUri); foreach ($notifications as $notification) { - $children[] = new Node( $this->caldavBackend, $this->principalUri, @@ -71,31 +71,27 @@ class Collection extends DAV\Collection implements ICollection, DAVACL\IACL { } return $children; - } /** - * Returns the name of this object + * Returns the name of this object. * * @return string */ - function getName() { - + public function getName() + { return 'notifications'; - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->principalUri; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Notifications/ICollection.php b/vendor/sabre/dav/lib/CalDAV/Notifications/ICollection.php index 008e87435..b12fb3909 100644 --- a/vendor/sabre/dav/lib/CalDAV/Notifications/ICollection.php +++ b/vendor/sabre/dav/lib/CalDAV/Notifications/ICollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Notifications; use Sabre\DAV; @@ -18,6 +20,6 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ICollection extends DAV\ICollection { - +interface ICollection extends DAV\ICollection +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Notifications/INode.php b/vendor/sabre/dav/lib/CalDAV/Notifications/INode.php index 783b92be9..c5897ef4e 100644 --- a/vendor/sabre/dav/lib/CalDAV/Notifications/INode.php +++ b/vendor/sabre/dav/lib/CalDAV/Notifications/INode.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Notifications; use Sabre\CalDAV\Xml\Notification\NotificationInterface; @@ -18,15 +20,15 @@ use Sabre\CalDAV\Xml\Notification\NotificationInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface INode { - +interface INode +{ /** * This method must return an xml element, using the * Sabre\CalDAV\Xml\Notification\NotificationInterface classes. * * @return NotificationInterface */ - function getNotificationType(); + public function getNotificationType(); /** * Returns the etag for the notification. @@ -35,6 +37,5 @@ interface INode { * * @return string */ - function getETag(); - + public function getETag(); } diff --git a/vendor/sabre/dav/lib/CalDAV/Notifications/Node.php b/vendor/sabre/dav/lib/CalDAV/Notifications/Node.php index ad7ddf8f5..b1ec13ff4 100644 --- a/vendor/sabre/dav/lib/CalDAV/Notifications/Node.php +++ b/vendor/sabre/dav/lib/CalDAV/Notifications/Node.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Notifications; use Sabre\CalDAV; @@ -18,55 +20,53 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Node extends DAV\File implements INode, DAVACL\IACL { - +class Node extends DAV\File implements INode, DAVACL\IACL +{ use DAVACL\ACLTrait; /** - * The notification backend + * The notification backend. * * @var CalDAV\Backend\NotificationSupport */ protected $caldavBackend; /** - * The actual notification + * The actual notification. * * @var NotificationInterface */ protected $notification; /** - * Owner principal of the notification + * Owner principal of the notification. * * @var string */ protected $principalUri; /** - * Constructor + * Constructor. * * @param CalDAV\Backend\NotificationSupport $caldavBackend - * @param string $principalUri - * @param NotificationInterface $notification + * @param string $principalUri + * @param NotificationInterface $notification */ - function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri, NotificationInterface $notification) { - + public function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri, NotificationInterface $notification) + { $this->caldavBackend = $caldavBackend; $this->principalUri = $principalUri; $this->notification = $notification; - } /** - * Returns the path name for this notification + * Returns the path name for this notification. * * @return string */ - function getName() { - - return $this->notification->getId() . '.xml'; - + public function getName() + { + return $this->notification->getId().'.xml'; } /** @@ -76,10 +76,9 @@ class Node extends DAV\File implements INode, DAVACL\IACL { * * @return string */ - function getETag() { - + public function getETag() + { return $this->notification->getETag(); - } /** @@ -88,34 +87,28 @@ class Node extends DAV\File implements INode, DAVACL\IACL { * * @return NotificationInterface */ - function getNotificationType() { - + public function getNotificationType() + { return $this->notification; - } /** - * Deletes this notification - * - * @return void + * Deletes this notification. */ - function delete() { - + public function delete() + { $this->caldavBackend->deleteNotification($this->getOwner(), $this->notification); - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->principalUri; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Notifications/Plugin.php b/vendor/sabre/dav/lib/CalDAV/Notifications/Plugin.php index e742351f5..182b70c8e 100644 --- a/vendor/sabre/dav/lib/CalDAV/Notifications/Plugin.php +++ b/vendor/sabre/dav/lib/CalDAV/Notifications/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Notifications; use Sabre\DAV; @@ -12,7 +14,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * Notifications plugin + * Notifications plugin. * * This plugin implements several features required by the caldav-notification * draft specification. @@ -24,10 +26,10 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ /** - * This is the namespace for the proprietary calendarserver extensions + * This is the namespace for the proprietary calendarserver extensions. */ const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'; @@ -46,10 +48,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'notifications'; - } /** @@ -61,58 +62,49 @@ class Plugin extends ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; $server->on('method:GET', [$this, 'httpGet'], 90); - $server->on('propFind', [$this, 'propFind']); + $server->on('propFind', [$this, 'propFind']); $server->xml->namespaceMap[self::NS_CALENDARSERVER] = 'cs'; - $server->resourceTypeMapping['\\Sabre\\CalDAV\\Notifications\\ICollection'] = '{' . self::NS_CALENDARSERVER . '}notification'; + $server->resourceTypeMapping['\\Sabre\\CalDAV\\Notifications\\ICollection'] = '{'.self::NS_CALENDARSERVER.'}notification'; array_push($server->protectedProperties, - '{' . self::NS_CALENDARSERVER . '}notification-URL', - '{' . self::NS_CALENDARSERVER . '}notificationtype' + '{'.self::NS_CALENDARSERVER.'}notification-URL', + '{'.self::NS_CALENDARSERVER.'}notificationtype' ); - } /** - * PropFind + * PropFind. * - * @param PropFind $propFind + * @param PropFind $propFind * @param BaseINode $node - * @return void */ - function propFind(PropFind $propFind, BaseINode $node) { - + public function propFind(PropFind $propFind, BaseINode $node) + { $caldavPlugin = $this->server->getPlugin('caldav'); if ($node instanceof DAVACL\IPrincipal) { - $principalUrl = $node->getPrincipalUrl(); // notification-URL property - $propFind->handle('{' . self::NS_CALENDARSERVER . '}notification-URL', function() use ($principalUrl, $caldavPlugin) { + $propFind->handle('{'.self::NS_CALENDARSERVER.'}notification-URL', function () use ($principalUrl, $caldavPlugin) { + $notificationPath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl).'/notifications/'; - $notificationPath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl) . '/notifications/'; return new DAV\Xml\Property\Href($notificationPath); - }); - } if ($node instanceof INode) { - $propFind->handle( - '{' . self::NS_CALENDARSERVER . '}notificationtype', + '{'.self::NS_CALENDARSERVER.'}notificationtype', [$node, 'getNotificationType'] ); - } - } /** @@ -121,12 +113,11 @@ class Plugin extends ServerPlugin { * We use this to intercept GET calls to notification nodes, and return the * proper response. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); try { @@ -135,8 +126,9 @@ class Plugin extends ServerPlugin { return; } - if (!$node instanceof INode) + if (!$node instanceof INode) { return; + } $writer = $this->server->xml->getWriter(); $writer->contextUri = $this->server->getBaseUri(); @@ -153,7 +145,6 @@ class Plugin extends ServerPlugin { // Return false to break the event chain. return false; - } /** @@ -167,14 +158,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds support for caldav-notifications, which is required to enable caldav-sharing.', - 'link' => 'http://sabre.io/dav/caldav-sharing/', + 'link' => 'http://sabre.io/dav/caldav-sharing/', ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Plugin.php b/vendor/sabre/dav/lib/CalDAV/Plugin.php index def11d52d..04eaedf73 100644 --- a/vendor/sabre/dav/lib/CalDAV/Plugin.php +++ b/vendor/sabre/dav/lib/CalDAV/Plugin.php @@ -1,8 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use DateTimeZone; +use Sabre\CalDAV\Xml\Request\CalendarMultiGetReport; use Sabre\DAV; use Sabre\DAV\Exception\BadRequest; use Sabre\DAV\INode; @@ -16,7 +19,7 @@ use Sabre\Uri; use Sabre\VObject; /** - * CalDAV plugin + * CalDAV plugin. * * This plugin provides functionality added by CalDAV (RFC 4791) * It implements new reports, and the MKCALENDAR method. @@ -25,26 +28,26 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * This is the official CalDAV namespace + * This is the official CalDAV namespace. */ const NS_CALDAV = 'urn:ietf:params:xml:ns:caldav'; /** - * This is the namespace for the proprietary calendarserver extensions + * This is the namespace for the proprietary calendarserver extensions. */ const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'; /** * The hardcoded root for calendar objects. It is unfortunate - * that we're stuck with it, but it will have to do for now + * that we're stuck with it, but it will have to do for now. */ const CALENDAR_ROOT = 'calendars'; /** - * Reference to server object + * Reference to server object. * * @var DAV\Server */ @@ -65,14 +68,19 @@ class Plugin extends DAV\ServerPlugin { * available for the specified uri. * * @param string $uri + * * @return array */ - function getHTTPMethods($uri) { - + public function getHTTPMethods($uri) + { // The MKCALENDAR is only available on unmapped uri's, whose // parents extend IExtendedCollection list($parent, $name) = Uri\split($uri); + if ('' === $uri) { + $parent = ''; + } + $node = $this->server->tree->getNodeForPath($parent); if ($node instanceof DAV\IExtendedCollection) { @@ -82,8 +90,8 @@ class Plugin extends DAV\ServerPlugin { return ['MKCALENDAR']; } } - return []; + return []; } /** @@ -94,10 +102,11 @@ class Plugin extends DAV\ServerPlugin { * a calendar home. * * @param string $principalUrl + * * @return string */ - function getCalendarHomeForPrincipal($principalUrl) { - + public function getCalendarHomeForPrincipal($principalUrl) + { // The default behavior for most sabre/dav servers is that there is a // principals root node, which contains users directly under it. // @@ -106,11 +115,14 @@ class Plugin extends DAV\ServerPlugin { // excludes things like the calendar-proxy-read principal (which it // should). $parts = explode('/', trim($principalUrl, '/')); - if (count($parts) !== 2) return; - if ($parts[0] !== 'principals') return; - - return self::CALENDAR_ROOT . '/' . $parts[1]; + if (2 !== count($parts)) { + return; + } + if ('principals' !== $parts[0]) { + return; + } + return self::CALENDAR_ROOT.'/'.$parts[1]; } /** @@ -118,10 +130,9 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['calendar-access', 'calendar-proxy']; - } /** @@ -132,10 +143,9 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'caldav'; - } /** @@ -146,19 +156,20 @@ class Plugin extends DAV\ServerPlugin { * implement them * * @param string $uri + * * @return array */ - function getSupportedReportSet($uri) { - + public function getSupportedReportSet($uri) + { $node = $this->server->tree->getNodeForPath($uri); $reports = []; if ($node instanceof ICalendarObjectContainer || $node instanceof ICalendarObject) { - $reports[] = '{' . self::NS_CALDAV . '}calendar-multiget'; - $reports[] = '{' . self::NS_CALDAV . '}calendar-query'; + $reports[] = '{'.self::NS_CALDAV.'}calendar-multiget'; + $reports[] = '{'.self::NS_CALDAV.'}calendar-query'; } if ($node instanceof ICalendar) { - $reports[] = '{' . self::NS_CALDAV . '}free-busy-query'; + $reports[] = '{'.self::NS_CALDAV.'}free-busy-query'; } // iCal has a bug where it assumes that sync support is enabled, only // if we say we support it on the calendar-home, even though this is @@ -166,39 +177,38 @@ class Plugin extends DAV\ServerPlugin { if ($node instanceof CalendarHome && $this->server->getPlugin('sync')) { $reports[] = '{DAV:}sync-collection'; } - return $reports; + return $reports; } /** - * Initializes the plugin + * Initializes the plugin. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; - $server->on('method:MKCALENDAR', [$this, 'httpMkCalendar']); - $server->on('report', [$this, 'report']); - $server->on('propFind', [$this, 'propFind']); - $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); - $server->on('beforeCreateFile', [$this, 'beforeCreateFile']); - $server->on('beforeWriteContent', [$this, 'beforeWriteContent']); - $server->on('afterMethod:GET', [$this, 'httpAfterGET']); + $server->on('method:MKCALENDAR', [$this, 'httpMkCalendar']); + $server->on('report', [$this, 'report']); + $server->on('propFind', [$this, 'propFind']); + $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); + $server->on('beforeCreateFile', [$this, 'beforeCreateFile']); + $server->on('beforeWriteContent', [$this, 'beforeWriteContent']); + $server->on('afterMethod:GET', [$this, 'httpAfterGET']); $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']); $server->xml->namespaceMap[self::NS_CALDAV] = 'cal'; $server->xml->namespaceMap[self::NS_CALENDARSERVER] = 'cs'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}supported-calendar-component-set'] = 'Sabre\\CalDAV\\Xml\\Property\\SupportedCalendarComponentSet'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}calendar-query'] = 'Sabre\\CalDAV\\Xml\\Request\\CalendarQueryReport'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}calendar-multiget'] = 'Sabre\\CalDAV\\Xml\\Request\\CalendarMultiGetReport'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}free-busy-query'] = 'Sabre\\CalDAV\\Xml\\Request\\FreeBusyQueryReport'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}mkcalendar'] = 'Sabre\\CalDAV\\Xml\\Request\\MkCalendar'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}schedule-calendar-transp'] = 'Sabre\\CalDAV\\Xml\\Property\\ScheduleCalendarTransp'; - $server->xml->elementMap['{' . self::NS_CALDAV . '}supported-calendar-component-set'] = 'Sabre\\CalDAV\\Xml\\Property\\SupportedCalendarComponentSet'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}supported-calendar-component-set'] = 'Sabre\\CalDAV\\Xml\\Property\\SupportedCalendarComponentSet'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}calendar-query'] = 'Sabre\\CalDAV\\Xml\\Request\\CalendarQueryReport'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}calendar-multiget'] = 'Sabre\\CalDAV\\Xml\\Request\\CalendarMultiGetReport'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}free-busy-query'] = 'Sabre\\CalDAV\\Xml\\Request\\FreeBusyQueryReport'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}mkcalendar'] = 'Sabre\\CalDAV\\Xml\\Request\\MkCalendar'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}schedule-calendar-transp'] = 'Sabre\\CalDAV\\Xml\\Property\\ScheduleCalendarTransp'; + $server->xml->elementMap['{'.self::NS_CALDAV.'}supported-calendar-component-set'] = 'Sabre\\CalDAV\\Xml\\Property\\SupportedCalendarComponentSet'; $server->resourceTypeMapping['\\Sabre\\CalDAV\\ICalendar'] = '{urn:ietf:params:xml:ns:caldav}calendar'; @@ -206,86 +216,84 @@ class Plugin extends DAV\ServerPlugin { $server->resourceTypeMapping['\\Sabre\\CalDAV\\Principal\\IProxyWrite'] = '{http://calendarserver.org/ns/}calendar-proxy-write'; array_push($server->protectedProperties, - - '{' . self::NS_CALDAV . '}supported-calendar-component-set', - '{' . self::NS_CALDAV . '}supported-calendar-data', - '{' . self::NS_CALDAV . '}max-resource-size', - '{' . self::NS_CALDAV . '}min-date-time', - '{' . self::NS_CALDAV . '}max-date-time', - '{' . self::NS_CALDAV . '}max-instances', - '{' . self::NS_CALDAV . '}max-attendees-per-instance', - '{' . self::NS_CALDAV . '}calendar-home-set', - '{' . self::NS_CALDAV . '}supported-collation-set', - '{' . self::NS_CALDAV . '}calendar-data', + '{'.self::NS_CALDAV.'}supported-calendar-component-set', + '{'.self::NS_CALDAV.'}supported-calendar-data', + '{'.self::NS_CALDAV.'}max-resource-size', + '{'.self::NS_CALDAV.'}min-date-time', + '{'.self::NS_CALDAV.'}max-date-time', + '{'.self::NS_CALDAV.'}max-instances', + '{'.self::NS_CALDAV.'}max-attendees-per-instance', + '{'.self::NS_CALDAV.'}calendar-home-set', + '{'.self::NS_CALDAV.'}supported-collation-set', + '{'.self::NS_CALDAV.'}calendar-data', // CalendarServer extensions - '{' . self::NS_CALENDARSERVER . '}getctag', - '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for', - '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for' - + '{'.self::NS_CALENDARSERVER.'}getctag', + '{'.self::NS_CALENDARSERVER.'}calendar-proxy-read-for', + '{'.self::NS_CALENDARSERVER.'}calendar-proxy-write-for' ); if ($aclPlugin = $server->getPlugin('acl')) { - $aclPlugin->principalSearchPropertySet['{' . self::NS_CALDAV . '}calendar-user-address-set'] = 'Calendar address'; + $aclPlugin->principalSearchPropertySet['{'.self::NS_CALDAV.'}calendar-user-address-set'] = 'Calendar address'; } } /** - * This functions handles REPORT requests specific to CalDAV + * This functions handles REPORT requests specific to CalDAV. * * @param string $reportName - * @param mixed $report - * @param mixed $path + * @param mixed $report + * @param mixed $path + * * @return bool */ - function report($reportName, $report, $path) { - + public function report($reportName, $report, $path) + { switch ($reportName) { - case '{' . self::NS_CALDAV . '}calendar-multiget' : + case '{'.self::NS_CALDAV.'}calendar-multiget': $this->server->transactionType = 'report-calendar-multiget'; $this->calendarMultiGetReport($report); + return false; - case '{' . self::NS_CALDAV . '}calendar-query' : + case '{'.self::NS_CALDAV.'}calendar-query': $this->server->transactionType = 'report-calendar-query'; $this->calendarQueryReport($report); + return false; - case '{' . self::NS_CALDAV . '}free-busy-query' : + case '{'.self::NS_CALDAV.'}free-busy-query': $this->server->transactionType = 'report-free-busy-query'; $this->freeBusyQueryReport($report); - return false; + return false; } - - } /** * This function handles the MKCALENDAR HTTP method, which creates * a new calendar. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpMkCalendar(RequestInterface $request, ResponseInterface $response) { - + public function httpMkCalendar(RequestInterface $request, ResponseInterface $response) + { $body = $request->getBodyAsString(); $path = $request->getPath(); $properties = []; if ($body) { - try { $mkcalendar = $this->server->xml->expect( '{urn:ietf:params:xml:ns:caldav}mkcalendar', $body ); } catch (\Sabre\Xml\ParseException $e) { - throw new BadRequest($e->getMessage(), null, $e); + throw new BadRequest($e->getMessage(), 0, $e); } $properties = $mkcalendar->getProperties(); - } // iCal abuses MKCALENDAR since iCal 10.9.2 to create server-stored @@ -297,7 +305,7 @@ class Plugin extends DAV\ServerPlugin { if (isset($properties['{DAV:}resourcetype'])) { $resourceType = $properties['{DAV:}resourcetype']->getValue(); } else { - $resourceType = ['{DAV:}collection','{urn:ietf:params:xml:ns:caldav}calendar']; + $resourceType = ['{DAV:}collection', '{urn:ietf:params:xml:ns:caldav}calendar']; } $this->server->createCollection($path, new MkCol($resourceType, $properties)); @@ -310,80 +318,77 @@ class Plugin extends DAV\ServerPlugin { } /** - * PropFind + * PropFind. * * This method handler is invoked before any after properties for a * resource are fetched. This allows us to add in any CalDAV specific * properties. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFind(DAV\PropFind $propFind, DAV\INode $node) { - - $ns = '{' . self::NS_CALDAV . '}'; + public function propFind(DAV\PropFind $propFind, DAV\INode $node) + { + $ns = '{'.self::NS_CALDAV.'}'; if ($node instanceof ICalendarObjectContainer) { - - $propFind->handle($ns . 'max-resource-size', $this->maxResourceSize); - $propFind->handle($ns . 'supported-calendar-data', function() { + $propFind->handle($ns.'max-resource-size', $this->maxResourceSize); + $propFind->handle($ns.'supported-calendar-data', function () { return new Xml\Property\SupportedCalendarData(); }); - $propFind->handle($ns . 'supported-collation-set', function() { + $propFind->handle($ns.'supported-collation-set', function () { return new Xml\Property\SupportedCollationSet(); }); - } if ($node instanceof DAVACL\IPrincipal) { - $principalUrl = $node->getPrincipalUrl(); - $propFind->handle('{' . self::NS_CALDAV . '}calendar-home-set', function() use ($principalUrl) { - + $propFind->handle('{'.self::NS_CALDAV.'}calendar-home-set', function () use ($principalUrl) { $calendarHomePath = $this->getCalendarHomeForPrincipal($principalUrl); - if (is_null($calendarHomePath)) return null; - return new LocalHref($calendarHomePath . '/'); + if (is_null($calendarHomePath)) { + return null; + } + return new LocalHref($calendarHomePath.'/'); }); // The calendar-user-address-set property is basically mapped to // the {DAV:}alternate-URI-set property. - $propFind->handle('{' . self::NS_CALDAV . '}calendar-user-address-set', function() use ($node) { + $propFind->handle('{'.self::NS_CALDAV.'}calendar-user-address-set', function () use ($node) { $addresses = $node->getAlternateUriSet(); - $addresses[] = $this->server->getBaseUri() . $node->getPrincipalUrl() . '/'; + $addresses[] = $this->server->getBaseUri().$node->getPrincipalUrl().'/'; + return new LocalHref($addresses); }); // For some reason somebody thought it was a good idea to add // another one of these properties. We're supporting it too. - $propFind->handle('{' . self::NS_CALENDARSERVER . '}email-address-set', function() use ($node) { + $propFind->handle('{'.self::NS_CALENDARSERVER.'}email-address-set', function () use ($node) { $addresses = $node->getAlternateUriSet(); $emails = []; foreach ($addresses as $address) { - if (substr($address, 0, 7) === 'mailto:') { + if ('mailto:' === substr($address, 0, 7)) { $emails[] = substr($address, 7); } } + return new Xml\Property\EmailAddressSet($emails); }); // These two properties are shortcuts for ical to easily find // other principals this principal has access to. - $propRead = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for'; - $propWrite = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for'; - - if ($propFind->getStatus($propRead) === 404 || $propFind->getStatus($propWrite) === 404) { + $propRead = '{'.self::NS_CALENDARSERVER.'}calendar-proxy-read-for'; + $propWrite = '{'.self::NS_CALENDARSERVER.'}calendar-proxy-write-for'; + if (404 === $propFind->getStatus($propRead) || 404 === $propFind->getStatus($propWrite)) { $aclPlugin = $this->server->getPlugin('acl'); $membership = $aclPlugin->getPrincipalMembership($propFind->getPath()); $readList = []; $writeList = []; foreach ($membership as $group) { - $groupNode = $this->server->tree->getNodeForPath($group); - $listItem = Uri\split($group)[0] . '/'; + $listItem = Uri\split($group)[0].'/'; // If the node is either ap proxy-read or proxy-write // group, we grab the parent principal and add it to the @@ -394,33 +399,27 @@ class Plugin extends DAV\ServerPlugin { if ($groupNode instanceof Principal\IProxyWrite) { $writeList[] = $listItem; } - } $propFind->set($propRead, new LocalHref($readList)); $propFind->set($propWrite, new LocalHref($writeList)); - } - } // instanceof IPrincipal if ($node instanceof ICalendarObject) { - // The calendar-data property is not supposed to be a 'real' // property, but in large chunks of the spec it does act as such. // Therefore we simply expose it as a property. - $propFind->handle('{' . self::NS_CALDAV . '}calendar-data', function() use ($node) { + $propFind->handle('{'.self::NS_CALDAV.'}calendar-data', function () use ($node) { $val = $node->get(); - if (is_resource($val)) + if (is_resource($val)) { $val = stream_get_contents($val); + } // Taking out \r to not screw up the xml output - return str_replace("\r", "", $val); - + return str_replace("\r", '', $val); }); - } - } /** @@ -430,11 +429,10 @@ class Plugin extends DAV\ServerPlugin { * of urls. Effectively avoiding a lot of redundant requests. * * @param CalendarMultiGetReport $report - * @return void */ - function calendarMultiGetReport($report) { - - $needsJson = $report->contentType === 'application/calendar+json'; + public function calendarMultiGetReport($report) + { + $needsJson = 'application/calendar+json' === $report->contentType; $timeZones = []; $propertyList = []; @@ -445,9 +443,8 @@ class Plugin extends DAV\ServerPlugin { ); foreach ($this->server->getPropertiesForMultiplePaths($paths, $report->properties) as $uri => $objProps) { - - if (($needsJson || $report->expand) && isset($objProps[200]['{' . self::NS_CALDAV . '}calendar-data'])) { - $vObject = VObject\Reader::read($objProps[200]['{' . self::NS_CALDAV . '}calendar-data']); + if (($needsJson || $report->expand) && isset($objProps[200]['{'.self::NS_CALDAV.'}calendar-data'])) { + $vObject = VObject\Reader::read($objProps[200]['{'.self::NS_CALDAV.'}calendar-data']); if ($report->expand) { // We're expanding, and for that we need to figure out the @@ -455,7 +452,7 @@ class Plugin extends DAV\ServerPlugin { list($calendarPath) = Uri\split($uri); if (!isset($timeZones[$calendarPath])) { // Checking the calendar-timezone property. - $tzProp = '{' . self::NS_CALDAV . '}calendar-timezone'; + $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone'; $tzResult = $this->server->getProperties($calendarPath, [$tzProp]); if (isset($tzResult[$tzProp])) { // This property contains a VCALENDAR with a single @@ -472,9 +469,9 @@ class Plugin extends DAV\ServerPlugin { $vObject = $vObject->expand($report->expand['start'], $report->expand['end'], $timeZones[$calendarPath]); } if ($needsJson) { - $objProps[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize()); + $objProps[200]['{'.self::NS_CALDAV.'}calendar-data'] = json_encode($vObject->jsonSerialize()); } else { - $objProps[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize(); + $objProps[200]['{'.self::NS_CALDAV.'}calendar-data'] = $vObject->serialize(); } // Destroy circular references so PHP will garbage collect the // object. @@ -482,7 +479,6 @@ class Plugin extends DAV\ServerPlugin { } $propertyList[] = $objProps; - } $prefer = $this->server->getHTTPPrefer(); @@ -490,24 +486,22 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer'); - $this->server->httpResponse->setBody($this->server->generateMultiStatus($propertyList, $prefer['return'] === 'minimal')); - + $this->server->httpResponse->setBody($this->server->generateMultiStatus($propertyList, 'minimal' === $prefer['return'])); } /** - * This function handles the calendar-query REPORT + * This function handles the calendar-query REPORT. * * This report is used by clients to request calendar objects based on * complex conditions. * * @param Xml\Request\CalendarQueryReport $report - * @return void */ - function calendarQueryReport($report) { - + public function calendarQueryReport($report) + { $path = $this->server->getRequestUri(); - $needsJson = $report->contentType === 'application/calendar+json'; + $needsJson = 'application/calendar+json' === $report->contentType; $node = $this->server->tree->getNodeForPath($this->server->getRequestUri()); $depth = $this->server->getHTTPDepth(0); @@ -519,7 +513,7 @@ class Plugin extends DAV\ServerPlugin { if ($report->expand) { // We're expanding, and for that we need to figure out the // calendar's timezone. - $tzProp = '{' . self::NS_CALDAV . '}calendar-timezone'; + $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone'; $tzResult = $this->server->getProperties($path, [$tzProp]); if (isset($tzResult[$tzProp])) { // This property contains a VCALENDAR with a single @@ -538,13 +532,11 @@ class Plugin extends DAV\ServerPlugin { // The calendarobject was requested directly. In this case we handle // this locally. - if ($depth == 0 && $node instanceof ICalendarObject) { - + if (0 == $depth && $node instanceof ICalendarObject) { $requestedCalendarData = true; $requestedProperties = $report->properties; if (!in_array('{urn:ietf:params:xml:ns:caldav}calendar-data', $requestedProperties)) { - // We always retrieve calendar-data, as we need it for filtering. $requestedProperties[] = '{urn:ietf:params:xml:ns:caldav}calendar-data'; @@ -566,43 +558,35 @@ class Plugin extends DAV\ServerPlugin { // If there wasn't any calendar-data returned somehow, we ignore // this. if (isset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data'])) { - $validator = new CalendarQueryValidator(); $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); if ($validator->validate($vObject, $report->filters)) { - // If the client didn't require the calendar-data property, // we won't give it back. if (!$requestedCalendarData) { unset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); } else { - - if ($report->expand) { $vObject = $vObject->expand($report->expand['start'], $report->expand['end'], $calendarTimeZone); } if ($needsJson) { - $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize()); + $properties[200]['{'.self::NS_CALDAV.'}calendar-data'] = json_encode($vObject->jsonSerialize()); } elseif ($report->expand) { - $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize(); + $properties[200]['{'.self::NS_CALDAV.'}calendar-data'] = $vObject->serialize(); } } $result = [$properties]; - } // Destroy circular references so PHP will garbage collect the // object. $vObject->destroy(); - } - } - if ($node instanceof ICalendarObjectContainer && $depth === 0) { - - if (strpos($this->server->httpRequest->getHeader('User-Agent'), 'MSFT-') === 0) { + if ($node instanceof ICalendarObjectContainer && 0 === $depth) { + if (0 === strpos((string) $this->server->httpRequest->getHeader('User-Agent'), 'MSFT-')) { // Microsoft clients incorrectly supplied depth as 0, when it actually // should have set depth to 1. We're implementing a workaround here // to deal with this. @@ -614,31 +598,28 @@ class Plugin extends DAV\ServerPlugin { } else { throw new BadRequest('A calendar-query REPORT on a calendar with a Depth: 0 is undefined. Set Depth to 1'); } - } // If we're dealing with a calendar, the calendar itself is responsible // for the calendar-query. - if ($node instanceof ICalendarObjectContainer && $depth == 1) { - + if ($node instanceof ICalendarObjectContainer && 1 == $depth) { $nodePaths = $node->calendarQuery($report->filters); foreach ($nodePaths as $path) { - list($properties) = - $this->server->getPropertiesForPath($this->server->getRequestUri() . '/' . $path, $report->properties); + $this->server->getPropertiesForPath($this->server->getRequestUri().'/'.$path, $report->properties); if (($needsJson || $report->expand)) { - $vObject = VObject\Reader::read($properties[200]['{' . self::NS_CALDAV . '}calendar-data']); + $vObject = VObject\Reader::read($properties[200]['{'.self::NS_CALDAV.'}calendar-data']); if ($report->expand) { $vObject = $vObject->expand($report->expand['start'], $report->expand['end'], $calendarTimeZone); } if ($needsJson) { - $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize()); + $properties[200]['{'.self::NS_CALDAV.'}calendar-data'] = json_encode($vObject->jsonSerialize()); } else { - $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize(); + $properties[200]['{'.self::NS_CALDAV.'}calendar-data'] = $vObject->serialize(); } // Destroy circular references so PHP will garbage collect the @@ -646,9 +627,7 @@ class Plugin extends DAV\ServerPlugin { $vObject->destroy(); } $result[] = $properties; - } - } $prefer = $this->server->getHTTPPrefer(); @@ -656,8 +635,7 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer'); - $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, $prefer['return'] === 'minimal')); - + $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, 'minimal' === $prefer['return'])); } /** @@ -665,15 +643,14 @@ class Plugin extends DAV\ServerPlugin { * response for the CALDAV:free-busy-query REPORT. * * @param Xml\Request\FreeBusyQueryReport $report - * @return void */ - protected function freeBusyQueryReport(Xml\Request\FreeBusyQueryReport $report) { - + protected function freeBusyQueryReport(Xml\Request\FreeBusyQueryReport $report) + { $uri = $this->server->getRequestUri(); $acl = $this->server->getPlugin('acl'); if ($acl) { - $acl->checkPrivileges($uri, '{' . self::NS_CALDAV . '}read-free-busy'); + $acl->checkPrivileges($uri, '{'.self::NS_CALDAV.'}read-free-busy'); } $calendar = $this->server->tree->getNodeForPath($uri); @@ -681,7 +658,7 @@ class Plugin extends DAV\ServerPlugin { throw new DAV\Exception\NotImplemented('The free-busy-query REPORT is only implemented on calendars'); } - $tzProp = '{' . self::NS_CALDAV . '}calendar-timezone'; + $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone'; // Figuring out the default timezone for the calendar, for floating // times. @@ -699,26 +676,27 @@ class Plugin extends DAV\ServerPlugin { // Doing a calendar-query first, to make sure we get the most // performance. $urls = $calendar->calendarQuery([ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => $report->start, - 'end' => $report->end, + 'end' => $report->end, ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]); - $objects = array_map(function($url) use ($calendar) { + $objects = array_map(function ($url) use ($calendar) { $obj = $calendar->getChild($url)->get(); + return $obj; }, $urls); @@ -733,7 +711,6 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setHeader('Content-Type', 'text/calendar'); $this->server->httpResponse->setHeader('Content-Length', strlen($result)); $this->server->httpResponse->setBody($result); - } /** @@ -742,17 +719,17 @@ class Plugin extends DAV\ServerPlugin { * This plugin uses this method to ensure that CalDAV objects receive * valid calendar data. * - * @param string $path + * @param string $path * @param DAV\IFile $node - * @param resource $data - * @param bool $modified Should be set to true, if this event handler - * changed &$data. - * @return void + * @param resource $data + * @param bool $modified should be set to true, if this event handler + * changed &$data */ - function beforeWriteContent($path, DAV\IFile $node, &$data, &$modified) { - - if (!$node instanceof ICalendarObject) + public function beforeWriteContent($path, DAV\IFile $node, &$data, &$modified) + { + if (!$node instanceof ICalendarObject) { return; + } // We're onyl interested in ICalendarObject nodes that are inside of a // real calendar. This is to avoid triggering validation and scheduling @@ -760,8 +737,9 @@ class Plugin extends DAV\ServerPlugin { list($parent) = Uri\split($path); $parentNode = $this->server->tree->getNodeForPath($parent); - if (!$parentNode instanceof ICalendar) + if (!$parentNode instanceof ICalendar) { return; + } $this->validateICalendar( $data, @@ -771,7 +749,6 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse, false ); - } /** @@ -780,17 +757,17 @@ class Plugin extends DAV\ServerPlugin { * This plugin uses this method to ensure that newly created calendar * objects contain valid calendar data. * - * @param string $path - * @param resource $data + * @param string $path + * @param resource $data * @param DAV\ICollection $parentNode - * @param bool $modified Should be set to true, if this event handler - * changed &$data. - * @return void + * @param bool $modified should be set to true, if this event handler + * changed &$data */ - function beforeCreateFile($path, &$data, DAV\ICollection $parentNode, &$modified) { - - if (!$parentNode instanceof ICalendar) + public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode, &$modified) + { + if (!$parentNode instanceof ICalendar) { return; + } $this->validateICalendar( $data, @@ -800,7 +777,6 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse, true ); - } /** @@ -808,17 +784,16 @@ class Plugin extends DAV\ServerPlugin { * * An exception is thrown if it's not. * - * @param resource|string $data - * @param string $path - * @param bool $modified Should be set to true, if this event handler - * changed &$data. - * @param RequestInterface $request The http request. - * @param ResponseInterface $response The http response. - * @param bool $isNew Is the item a new one, or an update. - * @return void + * @param resource|string $data + * @param string $path + * @param bool $modified should be set to true, if this event handler + * changed &$data + * @param RequestInterface $request the http request + * @param ResponseInterface $response the http response + * @param bool $isNew is the item a new one, or an update */ - protected function validateICalendar(&$data, $path, &$modified, RequestInterface $request, ResponseInterface $response, $isNew) { - + protected function validateICalendar(&$data, $path, &$modified, RequestInterface $request, ResponseInterface $response, $isNew) + { // If it's a stream, we convert it to a string first. if (is_resource($data)) { $data = stream_get_contents($data); @@ -827,10 +802,9 @@ class Plugin extends DAV\ServerPlugin { $before = $data; try { - // If the data starts with a [, we can reasonably assume we're dealing // with a jCal object. - if (substr($data, 0, 1) === '[') { + if ('[' === substr($data, 0, 1)) { $vobj = VObject\Reader::readJson($data); // Converting $data back to iCalendar, as that's what we @@ -840,14 +814,11 @@ class Plugin extends DAV\ServerPlugin { } else { $vobj = VObject\Reader::read($data); } - } catch (VObject\ParseException $e) { - - throw new DAV\Exception\UnsupportedMediaType('This resource only supports valid iCalendar 2.0 data. Parse error: ' . $e->getMessage()); - + throw new DAV\Exception\UnsupportedMediaType('This resource only supports valid iCalendar 2.0 data. Parse error: '.$e->getMessage()); } - if ($vobj->name !== 'VCALENDAR') { + if ('VCALENDAR' !== $vobj->name) { throw new DAV\Exception\UnsupportedMediaType('This collection can only support iCalendar objects.'); } @@ -867,25 +838,24 @@ class Plugin extends DAV\ServerPlugin { foreach ($vobj->getComponents() as $component) { switch ($component->name) { - case 'VTIMEZONE' : + case 'VTIMEZONE': continue 2; - case 'VEVENT' : - case 'VTODO' : - case 'VJOURNAL' : + case 'VEVENT': + case 'VTODO': + case 'VJOURNAL': $foundType = $component->name; break; } - } if (!$foundType || !in_array($foundType, $supportedComponents)) { - throw new Exception\InvalidComponentType('iCalendar objects must at least have a component of type ' . implode(', ', $supportedComponents)); + throw new Exception\InvalidComponentType('iCalendar objects must at least have a component of type '.implode(', ', $supportedComponents)); } $options = VObject\Node::PROFILE_CALDAV; $prefer = $this->server->getHTTPPrefer(); - if ($prefer['handling'] !== 'strict') { + if ('strict' !== $prefer['handling']) { $options |= VObject\Node::REPAIR; } @@ -897,32 +867,28 @@ class Plugin extends DAV\ServerPlugin { // $messages contains a list of problems with the vcard, along with // their severity. foreach ($messages as $message) { - if ($message['level'] > $highestLevel) { // Recording the highest reported error level. $highestLevel = $message['level']; $warningMessage = $message['message']; } switch ($message['level']) { - - case 1 : + case 1: // Level 1 means that there was a problem, but it was repaired. $modified = true; break; - case 2 : + case 2: // Level 2 means a warning, but not critical break; - case 3 : + case 3: // Level 3 means a critical error - throw new DAV\Exception\UnsupportedMediaType('Validation error in iCalendar: ' . $message['message']); - + throw new DAV\Exception\UnsupportedMediaType('Validation error in iCalendar: '.$message['message']); } - } if ($warningMessage) { $response->setHeader( 'X-Sabre-Ew-Gross', - 'iCalendar validation warning: ' . $warningMessage + 'iCalendar validation warning: '.$warningMessage ); } @@ -940,7 +906,7 @@ class Plugin extends DAV\ServerPlugin { $vobj, $parentPath, &$subModified, - $isNew + $isNew, ] ); @@ -949,15 +915,13 @@ class Plugin extends DAV\ServerPlugin { $data = $vobj->serialize(); // Using md5 to figure out if there was an *actual* change. - if (!$modified && strcmp($data, $before) !== 0) { + if (!$modified && 0 !== strcmp($data, $before)) { $modified = true; } - } // Destroy circular references so PHP will garbage collect the object. $vobj->destroy(); - } /** @@ -967,11 +931,11 @@ class Plugin extends DAV\ServerPlugin { * @param INode $node * @param array $supportedPrivilegeSet */ - function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) { - + public function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) + { if ($node instanceof ICalendar) { - $supportedPrivilegeSet['{DAV:}read']['aggregates']['{' . self::NS_CALDAV . '}read-free-busy'] = [ - 'abstract' => false, + $supportedPrivilegeSet['{DAV:}read']['aggregates']['{'.self::NS_CALDAV.'}read-free-busy'] = [ + 'abstract' => false, 'aggregates' => [], ]; } @@ -983,18 +947,20 @@ class Plugin extends DAV\ServerPlugin { * can use to create new calendars. * * @param DAV\INode $node - * @param string $output + * @param string $output + * * @return bool */ - function htmlActionsPanel(DAV\INode $node, &$output) { - - if (!$node instanceof CalendarHome) + public function htmlActionsPanel(DAV\INode $node, &$output) + { + if (!$node instanceof CalendarHome) { return; + } $output .= '<tr><td colspan="2"><form method="post" action=""> <h3>Create new calendar</h3> <input type="hidden" name="sabreAction" value="mkcol" /> - <input type="hidden" name="resourceType" value="{DAV:}collection,{' . self::NS_CALDAV . '}calendar" /> + <input type="hidden" name="resourceType" value="{DAV:}collection,{'.self::NS_CALDAV.'}calendar" /> <label>Name (uri):</label> <input type="text" name="name" /><br /> <label>Display name:</label> <input type="text" name="{DAV:}displayname" /><br /> <input type="submit" value="create" /> @@ -1002,7 +968,6 @@ class Plugin extends DAV\ServerPlugin { </td></tr>'; return false; - } /** @@ -1010,22 +975,22 @@ class Plugin extends DAV\ServerPlugin { * * This is used to transform data into jCal, if this was requested. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpAfterGet(RequestInterface $request, ResponseInterface $response) { - - if (strpos($response->getHeader('Content-Type'), 'text/calendar') === false) { + public function httpAfterGet(RequestInterface $request, ResponseInterface $response) + { + $contentType = $response->getHeader('Content-Type'); + if (null === $contentType || false === strpos($contentType, 'text/calendar')) { return; } - $result = HTTP\Util::negotiate( + $result = HTTP\negotiateContentType( $request->getHeader('Accept'), ['text/calendar', 'application/calendar+json'] ); - if ($result !== 'application/calendar+json') { + if ('application/calendar+json' !== $result) { // Do nothing return; } @@ -1041,7 +1006,6 @@ class Plugin extends DAV\ServerPlugin { $response->setHeader('Content-Type', 'application/calendar+json'); $response->setHeader('Content-Length', strlen($jsonBody)); - } /** @@ -1055,14 +1019,12 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds support for CalDAV (rfc4791)', - 'link' => 'http://sabre.io/dav/caldav/', + 'link' => 'http://sabre.io/dav/caldav/', ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Principal/Collection.php b/vendor/sabre/dav/lib/CalDAV/Principal/Collection.php index e19719a76..cae29c752 100644 --- a/vendor/sabre/dav/lib/CalDAV/Principal/Collection.php +++ b/vendor/sabre/dav/lib/CalDAV/Principal/Collection.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAVACL; /** - * Principal collection + * Principal collection. * * This is an alternative collection to the standard ACL principal collection. * This collection adds support for the calendar-proxy-read and @@ -16,18 +18,17 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Collection extends DAVACL\PrincipalCollection { - +class Collection extends DAVACL\PrincipalCollection +{ /** - * Returns a child object based on principal information + * Returns a child object based on principal information. * * @param array $principalInfo + * * @return User */ - function getChildForPrincipal(array $principalInfo) { - + public function getChildForPrincipal(array $principalInfo) + { return new User($this->principalBackend, $principalInfo); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Principal/IProxyRead.php b/vendor/sabre/dav/lib/CalDAV/Principal/IProxyRead.php index 7dd375932..96e6991c5 100644 --- a/vendor/sabre/dav/lib/CalDAV/Principal/IProxyRead.php +++ b/vendor/sabre/dav/lib/CalDAV/Principal/IProxyRead.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAVACL; /** - * ProxyRead principal interface + * ProxyRead principal interface. * * Any principal node implementing this interface will be picked up as a 'proxy * principal group'. @@ -14,6 +16,6 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IProxyRead extends DAVACL\IPrincipal { - +interface IProxyRead extends DAVACL\IPrincipal +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Principal/IProxyWrite.php b/vendor/sabre/dav/lib/CalDAV/Principal/IProxyWrite.php index eda87a4ff..2556039ca 100644 --- a/vendor/sabre/dav/lib/CalDAV/Principal/IProxyWrite.php +++ b/vendor/sabre/dav/lib/CalDAV/Principal/IProxyWrite.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAVACL; /** - * ProxyWrite principal interface + * ProxyWrite principal interface. * * Any principal node implementing this interface will be picked up as a 'proxy * principal group'. @@ -14,6 +16,6 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IProxyWrite extends DAVACL\IPrincipal { - +interface IProxyWrite extends DAVACL\IPrincipal +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Principal/ProxyRead.php b/vendor/sabre/dav/lib/CalDAV/Principal/ProxyRead.php index e3881831e..1b24984bd 100644 --- a/vendor/sabre/dav/lib/CalDAV/Principal/ProxyRead.php +++ b/vendor/sabre/dav/lib/CalDAV/Principal/ProxyRead.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAV; use Sabre\DAVACL; /** - * ProxyRead principal + * ProxyRead principal. * * This class represents a principal group, hosted under the main principal. * This is needed to implement 'Calendar delegation' support. This class is @@ -16,8 +18,8 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ProxyRead implements IProxyRead { - +class ProxyRead implements IProxyRead +{ /** * Principal information from the parent principal. * @@ -26,7 +28,7 @@ class ProxyRead implements IProxyRead { protected $principalInfo; /** - * Principal backend + * Principal backend. * * @var DAVACL\PrincipalBackend\BackendInterface */ @@ -38,13 +40,12 @@ class ProxyRead implements IProxyRead { * Note that you MUST supply the parent principal information. * * @param DAVACL\PrincipalBackend\BackendInterface $principalBackend - * @param array $principalInfo + * @param array $principalInfo */ - function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) { - + public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) + { $this->principalInfo = $principalInfo; $this->principalBackend = $principalBackend; - } /** @@ -52,103 +53,91 @@ class ProxyRead implements IProxyRead { * * @return string */ - function getName() { - + public function getName() + { return 'calendar-proxy-read'; - } /** - * Returns the last modification time - * - * @return null + * Returns the last modification time. */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** - * Deletes the current node + * Deletes the current node. * * @throws DAV\Exception\Forbidden - * @return void */ - function delete() { - + public function delete() + { throw new DAV\Exception\Forbidden('Permission denied to delete node'); - } /** - * Renames the node + * Renames the node. * * @param string $name The new name + * * @throws DAV\Exception\Forbidden - * @return void */ - function setName($name) { - + public function setName($name) + { throw new DAV\Exception\Forbidden('Permission denied to rename file'); - } - /** - * Returns a list of alternative urls for a principal + * Returns a list of alternative urls for a principal. * * This can for example be an email address, or ldap url. * * @return array */ - function getAlternateUriSet() { - + public function getAlternateUriSet() + { return []; - } /** - * Returns the full principal url + * Returns the full principal url. * * @return string */ - function getPrincipalUrl() { - - return $this->principalInfo['uri'] . '/' . $this->getName(); - + public function getPrincipalUrl() + { + return $this->principalInfo['uri'].'/'.$this->getName(); } /** - * Returns the list of group members + * Returns the list of group members. * * If this principal is a group, this function should return * all member principal uri's for the group. * * @return array */ - function getGroupMemberSet() { - + public function getGroupMemberSet() + { return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl()); - } /** - * Returns the list of groups this principal is member of + * Returns the list of groups this principal is member of. * * If this principal is a member of a (list of) groups, this function * should return a list of principal uri's for it's members. * * @return array */ - function getGroupMembership() { - + public function getGroupMembership() + { return $this->principalBackend->getGroupMembership($this->getPrincipalUrl()); - } /** - * Sets a list of group members + * Sets a list of group members. * * If this principal is a group, this method sets all the group members. * The list of members is always overwritten, never appended to. @@ -156,26 +145,22 @@ class ProxyRead implements IProxyRead { * This method should throw an exception if the members could not be set. * * @param array $principals - * @return void */ - function setGroupMemberSet(array $principals) { - + public function setGroupMemberSet(array $principals) + { $this->principalBackend->setGroupMemberSet($this->getPrincipalUrl(), $principals); - } /** - * Returns the displayname + * Returns the displayname. * * This should be a human readable name for the principal. * If none is available, return the nodename. * * @return string */ - function getDisplayName() { - + public function getDisplayName() + { return $this->getName(); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Principal/ProxyWrite.php b/vendor/sabre/dav/lib/CalDAV/Principal/ProxyWrite.php index 43dd9bf07..7b9c78e0a 100644 --- a/vendor/sabre/dav/lib/CalDAV/Principal/ProxyWrite.php +++ b/vendor/sabre/dav/lib/CalDAV/Principal/ProxyWrite.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAV; use Sabre\DAVACL; /** - * ProxyWrite principal + * ProxyWrite principal. * * This class represents a principal group, hosted under the main principal. * This is needed to implement 'Calendar delegation' support. This class is @@ -16,35 +18,34 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ProxyWrite implements IProxyWrite { - +class ProxyWrite implements IProxyWrite +{ /** - * Parent principal information + * Parent principal information. * * @var array */ protected $principalInfo; /** - * Principal Backend + * Principal Backend. * * @var DAVACL\PrincipalBackend\BackendInterface */ protected $principalBackend; /** - * Creates the object + * Creates the object. * * Note that you MUST supply the parent principal information. * * @param DAVACL\PrincipalBackend\BackendInterface $principalBackend - * @param array $principalInfo + * @param array $principalInfo */ - function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) { - + public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) + { $this->principalInfo = $principalInfo; $this->principalBackend = $principalBackend; - } /** @@ -52,103 +53,91 @@ class ProxyWrite implements IProxyWrite { * * @return string */ - function getName() { - + public function getName() + { return 'calendar-proxy-write'; - } /** - * Returns the last modification time - * - * @return null + * Returns the last modification time. */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** - * Deletes the current node + * Deletes the current node. * * @throws DAV\Exception\Forbidden - * @return void */ - function delete() { - + public function delete() + { throw new DAV\Exception\Forbidden('Permission denied to delete node'); - } /** - * Renames the node + * Renames the node. * * @param string $name The new name + * * @throws DAV\Exception\Forbidden - * @return void */ - function setName($name) { - + public function setName($name) + { throw new DAV\Exception\Forbidden('Permission denied to rename file'); - } - /** - * Returns a list of alternative urls for a principal + * Returns a list of alternative urls for a principal. * * This can for example be an email address, or ldap url. * * @return array */ - function getAlternateUriSet() { - + public function getAlternateUriSet() + { return []; - } /** - * Returns the full principal url + * Returns the full principal url. * * @return string */ - function getPrincipalUrl() { - - return $this->principalInfo['uri'] . '/' . $this->getName(); - + public function getPrincipalUrl() + { + return $this->principalInfo['uri'].'/'.$this->getName(); } /** - * Returns the list of group members + * Returns the list of group members. * * If this principal is a group, this function should return * all member principal uri's for the group. * * @return array */ - function getGroupMemberSet() { - + public function getGroupMemberSet() + { return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl()); - } /** - * Returns the list of groups this principal is member of + * Returns the list of groups this principal is member of. * * If this principal is a member of a (list of) groups, this function * should return a list of principal uri's for it's members. * * @return array */ - function getGroupMembership() { - + public function getGroupMembership() + { return $this->principalBackend->getGroupMembership($this->getPrincipalUrl()); - } /** - * Sets a list of group members + * Sets a list of group members. * * If this principal is a group, this method sets all the group members. * The list of members is always overwritten, never appended to. @@ -156,26 +145,22 @@ class ProxyWrite implements IProxyWrite { * This method should throw an exception if the members could not be set. * * @param array $principals - * @return void */ - function setGroupMemberSet(array $principals) { - + public function setGroupMemberSet(array $principals) + { $this->principalBackend->setGroupMemberSet($this->getPrincipalUrl(), $principals); - } /** - * Returns the displayname + * Returns the displayname. * * This should be a human readable name for the principal. * If none is available, return the nodename. * * @return string */ - function getDisplayName() { - + public function getDisplayName() + { return $this->getName(); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Principal/User.php b/vendor/sabre/dav/lib/CalDAV/Principal/User.php index 6e97e7cca..88bf4b4f7 100644 --- a/vendor/sabre/dav/lib/CalDAV/Principal/User.php +++ b/vendor/sabre/dav/lib/CalDAV/Principal/User.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAV; use Sabre\DAVACL; /** - * CalDAV principal + * CalDAV principal. * * This is a standard user-principal for CalDAV. This principal is also a * collection and returns the caldav-proxy-read and caldav-proxy-write child @@ -16,91 +18,91 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class User extends DAVACL\Principal implements DAV\ICollection { - +class User extends DAVACL\Principal implements DAV\ICollection +{ /** - * Creates a new file in the directory + * Creates a new file in the directory. + * + * @param string $name Name of the file + * @param resource $data initial payload, passed as a readable stream resource * - * @param string $name Name of the file - * @param resource $data Initial payload, passed as a readable stream resource. * @throws DAV\Exception\Forbidden - * @return void */ - function createFile($name, $data = null) { - - throw new DAV\Exception\Forbidden('Permission denied to create file (filename ' . $name . ')'); - + public function createFile($name, $data = null) + { + throw new DAV\Exception\Forbidden('Permission denied to create file (filename '.$name.')'); } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name + * * @throws DAV\Exception\Forbidden - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { throw new DAV\Exception\Forbidden('Permission denied to create directory'); - } /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * @param string $name + * * @return DAV\INode */ - function getChild($name) { - - $principal = $this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/' . $name); + public function getChild($name) + { + $principal = $this->principalBackend->getPrincipalByPath($this->getPrincipalURL().'/'.$name); if (!$principal) { - throw new DAV\Exception\NotFound('Node with name ' . $name . ' was not found'); + throw new DAV\Exception\NotFound('Node with name '.$name.' was not found'); } - if ($name === 'calendar-proxy-read') + if ('calendar-proxy-read' === $name) { return new ProxyRead($this->principalBackend, $this->principalProperties); + } - if ($name === 'calendar-proxy-write') + if ('calendar-proxy-write' === $name) { return new ProxyWrite($this->principalBackend, $this->principalProperties); + } - throw new DAV\Exception\NotFound('Node with name ' . $name . ' was not found'); - + throw new DAV\Exception\NotFound('Node with name '.$name.' was not found'); } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return DAV\INode[] */ - function getChildren() { - + public function getChildren() + { $r = []; - if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-read')) { + if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL().'/calendar-proxy-read')) { $r[] = new ProxyRead($this->principalBackend, $this->principalProperties); } - if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-write')) { + if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL().'/calendar-proxy-write')) { $r[] = new ProxyWrite($this->principalBackend, $this->principalProperties); } return $r; - } /** - * Returns whether or not the child node exists + * Returns whether or not the child node exists. * * @param string $name + * * @return bool */ - function childExists($name) { - + public function childExists($name) + { try { $this->getChild($name); + return true; } catch (DAV\Exception\NotFound $e) { return false; } - } /** @@ -115,21 +117,20 @@ class User extends DAVACL\Principal implements DAV\ICollection { * * @return array */ - function getACL() { - + public function getACL() + { $acl = parent::getACL(); $acl[] = [ 'privilege' => '{DAV:}read', - 'principal' => $this->principalProperties['uri'] . '/calendar-proxy-read', + 'principal' => $this->principalProperties['uri'].'/calendar-proxy-read', 'protected' => true, ]; $acl[] = [ 'privilege' => '{DAV:}read', - 'principal' => $this->principalProperties['uri'] . '/calendar-proxy-write', + 'principal' => $this->principalProperties['uri'].'/calendar-proxy-write', 'protected' => true, ]; - return $acl; + return $acl; } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php index c9fd77d93..64a94becc 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; /** @@ -10,6 +12,6 @@ namespace Sabre\CalDAV\Schedule; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IInbox extends \Sabre\CalDAV\ICalendarObjectContainer, \Sabre\DAVACL\IACL { - +interface IInbox extends \Sabre\CalDAV\ICalendarObjectContainer, \Sabre\DAVACL\IACL +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php b/vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php index 6f5acb29a..d71b3c0f8 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; use Sabre\DAV; @@ -19,8 +21,8 @@ use Sabre\VObject\ITip; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class IMipPlugin extends DAV\ServerPlugin { - +class IMipPlugin extends DAV\ServerPlugin +{ /** * Email address used in From: header. * @@ -29,7 +31,7 @@ class IMipPlugin extends DAV\ServerPlugin { protected $senderEmail; /** - * ITipMessage + * ITipMessage. * * @var ITip\Message */ @@ -43,10 +45,9 @@ class IMipPlugin extends DAV\ServerPlugin { * generally be some kind of no-reply email * address you own. */ - function __construct($senderEmail) { - + public function __construct($senderEmail) + { $this->senderEmail = $senderEmail; - } /* @@ -60,10 +61,9 @@ class IMipPlugin extends DAV\ServerPlugin { * @param DAV\Server $server * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $server->on('schedule', [$this, 'schedule'], 120); - } /** @@ -74,67 +74,68 @@ class IMipPlugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'imip'; - } /** * Event handler for the 'schedule' event. * * @param ITip\Message $iTipMessage - * @return void */ - function schedule(ITip\Message $iTipMessage) { - + public function schedule(ITip\Message $iTipMessage) + { // Not sending any emails if the system considers the update // insignificant. if (!$iTipMessage->significantChange) { if (!$iTipMessage->scheduleStatus) { $iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email'; } + return; } $summary = $iTipMessage->message->VEVENT->SUMMARY; - if (parse_url($iTipMessage->sender, PHP_URL_SCHEME) !== 'mailto') + if ('mailto' !== parse_url($iTipMessage->sender, PHP_URL_SCHEME)) { return; + } - if (parse_url($iTipMessage->recipient, PHP_URL_SCHEME) !== 'mailto') + if ('mailto' !== parse_url($iTipMessage->recipient, PHP_URL_SCHEME)) { return; + } $sender = substr($iTipMessage->sender, 7); $recipient = substr($iTipMessage->recipient, 7); if ($iTipMessage->senderName) { - $sender = $iTipMessage->senderName . ' <' . $sender . '>'; + $sender = $iTipMessage->senderName.' <'.$sender.'>'; } - if ($iTipMessage->recipientName) { - $recipient = $iTipMessage->recipientName . ' <' . $recipient . '>'; + if ($iTipMessage->recipientName && $iTipMessage->recipientName != $recipient) { + $recipient = $iTipMessage->recipientName.' <'.$recipient.'>'; } $subject = 'SabreDAV iTIP message'; switch (strtoupper($iTipMessage->method)) { - case 'REPLY' : - $subject = 'Re: ' . $summary; + case 'REPLY': + $subject = 'Re: '.$summary; break; - case 'REQUEST' : - $subject = $summary; + case 'REQUEST': + $subject = 'Invitation: '.$summary; break; - case 'CANCEL' : - $subject = 'Cancelled: ' . $summary; + case 'CANCEL': + $subject = 'Cancelled: '.$summary; break; } $headers = [ - 'Reply-To: ' . $sender, - 'From: ' . $this->senderEmail, - 'Content-Type: text/calendar; charset=UTF-8; method=' . $iTipMessage->method, + 'Reply-To: '.$sender, + 'From: '.$iTipMessage->senderName.' <'.$this->senderEmail.'>', + 'Content-Type: text/calendar; charset=UTF-8; method='.$iTipMessage->method, ]; if (DAV\Server::$exposeVersion) { - $headers[] = 'X-Sabre-Version: ' . DAV\Version::VERSION; + $headers[] = 'X-Sabre-Version: '.DAV\Version::VERSION; } $this->mail( $recipient, @@ -143,7 +144,6 @@ class IMipPlugin extends DAV\ServerPlugin { $headers ); $iTipMessage->scheduleStatus = '1.1; Scheduling message is sent via iMip'; - } // @codeCoverageIgnoreStart @@ -152,16 +152,14 @@ class IMipPlugin extends DAV\ServerPlugin { /** * This function is responsible for sending the actual email. * - * @param string $to Recipient email address + * @param string $to Recipient email address * @param string $subject Subject of the email - * @param string $body iCalendar body - * @param array $headers List of headers - * @return void + * @param string $body iCalendar body + * @param array $headers List of headers */ - protected function mail($to, $subject, $body, array $headers) { - + protected function mail($to, $subject, $body, array $headers) + { mail($to, $subject, $body, implode("\r\n", $headers)); - } // @codeCoverageIgnoreEnd @@ -177,14 +175,12 @@ class IMipPlugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Email delivery (rfc6047) for CalDAV scheduling', - 'link' => 'http://sabre.io/dav/scheduling/', + 'link' => 'http://sabre.io/dav/scheduling/', ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php index 88fbdc411..384b503df 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; /** @@ -10,6 +12,6 @@ namespace Sabre\CalDAV\Schedule; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IOutbox extends \Sabre\DAV\ICollection, \Sabre\DAVACL\IACL { - +interface IOutbox extends \Sabre\DAV\ICollection, \Sabre\DAVACL\IACL +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php b/vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php index b37cb40a1..345b55d9f 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; /** - * The SchedulingObject represents a scheduling object in the Inbox collection + * The SchedulingObject represents a scheduling object in the Inbox collection. * * @license http://sabre.io/license/ Modified BSD License * @copyright Copyright (C) fruux GmbH (https://fruux.com/) */ -interface ISchedulingObject extends \Sabre\CalDAV\ICalendarObject { - +interface ISchedulingObject extends \Sabre\CalDAV\ICalendarObject +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php index 81b017307..d92f1dd4c 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; use Sabre\CalDAV; @@ -9,41 +11,40 @@ use Sabre\DAVACL; use Sabre\VObject; /** - * The CalDAV scheduling inbox + * The CalDAV scheduling inbox. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Inbox extends DAV\Collection implements IInbox { - +class Inbox extends DAV\Collection implements IInbox +{ use DAVACL\ACLTrait; /** - * CalDAV backend + * CalDAV backend. * * @var Backend\BackendInterface */ protected $caldavBackend; /** - * The principal Uri + * The principal Uri. * * @var string */ protected $principalUri; /** - * Constructor + * Constructor. * * @param Backend\SchedulingSupport $caldavBackend - * @param string $principalUri + * @param string $principalUri */ - function __construct(Backend\SchedulingSupport $caldavBackend, $principalUri) { - + public function __construct(Backend\SchedulingSupport $caldavBackend, $principalUri) + { $this->caldavBackend = $caldavBackend; $this->principalUri = $principalUri; - } /** @@ -53,19 +54,18 @@ class Inbox extends DAV\Collection implements IInbox { * * @return string */ - function getName() { - + public function getName() + { return 'inbox'; - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return \Sabre\DAV\INode[] */ - function getChildren() { - + public function getChildren() + { $objs = $this->caldavBackend->getSchedulingObjects($this->principalUri); $children = []; foreach ($objs as $obj) { @@ -73,12 +73,12 @@ class Inbox extends DAV\Collection implements IInbox { $obj['principaluri'] = $this->principalUri; $children[] = new SchedulingObject($this->caldavBackend, $obj); } - return $children; + return $children; } /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -97,27 +97,26 @@ class Inbox extends DAV\Collection implements IInbox { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - + public function createFile($name, $data = null) + { $this->caldavBackend->createSchedulingObject($this->principalUri, $name, $data); - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->principalUri; - } /** @@ -132,8 +131,8 @@ class Inbox extends DAV\Collection implements IInbox { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ 'privilege' => '{DAV:}read', @@ -152,16 +151,15 @@ class Inbox extends DAV\Collection implements IInbox { ], [ 'privilege' => '{DAV:}unbind', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ], [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-deliver', + 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-deliver', 'principal' => '{DAV:}authenticated', 'protected' => true, ], ]; - } /** @@ -179,10 +177,11 @@ class Inbox extends DAV\Collection implements IInbox { * documented by \Sabre\CalDAV\CalendarQueryParser. * * @param array $filters + * * @return array */ - function calendarQuery(array $filters) { - + public function calendarQuery(array $filters) + { $result = []; $validator = new CalDAV\CalendarQueryValidator(); @@ -196,8 +195,7 @@ class Inbox extends DAV\Collection implements IInbox { // Destroy circular references to PHP will GC the object. $vObject->destroy(); } - return $result; + return $result; } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php index 888ea3086..1442c4cc6 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; use Sabre\CalDAV; @@ -7,7 +9,7 @@ use Sabre\DAV; use Sabre\DAVACL; /** - * The CalDAV scheduling outbox + * The CalDAV scheduling outbox. * * The outbox is mainly used as an endpoint in the tree for a client to do * free-busy requests. This functionality is completely handled by the @@ -17,26 +19,25 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Outbox extends DAV\Collection implements IOutbox { - +class Outbox extends DAV\Collection implements IOutbox +{ use DAVACL\ACLTrait; /** - * The principal Uri + * The principal Uri. * * @var string */ protected $principalUri; /** - * Constructor + * Constructor. * * @param string $principalUri */ - function __construct($principalUri) { - + public function __construct($principalUri) + { $this->principalUri = $principalUri; - } /** @@ -46,34 +47,31 @@ class Outbox extends DAV\Collection implements IOutbox { * * @return string */ - function getName() { - + public function getName() + { return 'outbox'; - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return \Sabre\DAV\INode[] */ - function getChildren() { - + public function getChildren() + { return []; - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->principalUri; - } /** @@ -88,11 +86,11 @@ class Outbox extends DAV\Collection implements IOutbox { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send', + 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send', 'principal' => $this->getOwner(), 'protected' => true, ], @@ -102,22 +100,20 @@ class Outbox extends DAV\Collection implements IOutbox { 'protected' => true, ], [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-read', + 'principal' => $this->getOwner().'/calendar-proxy-read', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ], ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php b/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php index 0b991e619..d2c9b68e9 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; use DateTimeZone; @@ -28,7 +30,7 @@ use Sabre\VObject\Reader; /** * CalDAV scheduling plugin. - * ========================= + * =========================. * * This plugin provides the functionality added by the "Scheduling Extensions * to CalDAV" standard, as defined in RFC6638. @@ -53,10 +55,10 @@ use Sabre\VObject\Reader; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ /** - * This is the official CalDAV namespace + * This is the official CalDAV namespace. */ const NS_CALDAV = 'urn:ietf:params:xml:ns:caldav'; @@ -72,10 +74,9 @@ class Plugin extends ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['calendar-auto-schedule', 'calendar-availability']; - } /** @@ -86,49 +87,46 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'caldav-schedule'; - } /** - * Initializes the plugin + * Initializes the plugin. * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; - $server->on('method:POST', [$this, 'httpPost']); - $server->on('propFind', [$this, 'propFind']); - $server->on('propPatch', [$this, 'propPatch']); - $server->on('calendarObjectChange', [$this, 'calendarObjectChange']); - $server->on('beforeUnbind', [$this, 'beforeUnbind']); - $server->on('schedule', [$this, 'scheduleLocalDelivery']); + $server->on('method:POST', [$this, 'httpPost']); + $server->on('propFind', [$this, 'propFind']); + $server->on('propPatch', [$this, 'propPatch']); + $server->on('calendarObjectChange', [$this, 'calendarObjectChange']); + $server->on('beforeUnbind', [$this, 'beforeUnbind']); + $server->on('schedule', [$this, 'scheduleLocalDelivery']); $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']); - $ns = '{' . self::NS_CALDAV . '}'; + $ns = '{'.self::NS_CALDAV.'}'; - /** + /* * This information ensures that the {DAV:}resourcetype property has * the correct values. */ - $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IOutbox'] = $ns . 'schedule-outbox'; - $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IInbox'] = $ns . 'schedule-inbox'; + $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IOutbox'] = $ns.'schedule-outbox'; + $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IInbox'] = $ns.'schedule-inbox'; - /** + /* * Properties we protect are made read-only by the server. */ array_push($server->protectedProperties, - $ns . 'schedule-inbox-URL', - $ns . 'schedule-outbox-URL', - $ns . 'calendar-user-address-set', - $ns . 'calendar-user-type', - $ns . 'schedule-default-calendar-URL' + $ns.'schedule-inbox-URL', + $ns.'schedule-outbox-URL', + $ns.'calendar-user-address-set', + $ns.'calendar-user-type', + $ns.'schedule-default-calendar-URL' ); - } /** @@ -139,10 +137,11 @@ class Plugin extends ServerPlugin { * available for the specified uri. * * @param string $uri + * * @return array */ - function getHTTPMethods($uri) { - + public function getHTTPMethods($uri) + { try { $node = $this->server->tree->getNodeForPath($uri); } catch (NotFound $e) { @@ -154,21 +153,21 @@ class Plugin extends ServerPlugin { } return []; - } /** * This method handles POST request for the outbox. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpPost(RequestInterface $request, ResponseInterface $response) { - + public function httpPost(RequestInterface $request, ResponseInterface $response) + { // Checking if this is a text/calendar content type $contentType = $request->getHeader('Content-Type'); - if (strpos($contentType, 'text/calendar') !== 0) { + if (!$contentType || 0 !== strpos($contentType, 'text/calendar')) { return; } @@ -180,8 +179,9 @@ class Plugin extends ServerPlugin { } catch (NotFound $e) { return; } - if (!$node instanceof IOutbox) + if (!$node instanceof IOutbox) { return; + } $this->server->transactionType = 'post-caldav-outbox'; $this->outboxRequest($node, $request, $response); @@ -189,7 +189,6 @@ class Plugin extends ServerPlugin { // Returning false breaks the event chain and tells the server we've // handled the request. return false; - } /** @@ -198,43 +197,36 @@ class Plugin extends ServerPlugin { * We use this event to add calendar-auto-schedule-specific properties. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - + public function propFind(PropFind $propFind, INode $node) + { if ($node instanceof DAVACL\IPrincipal) { - $caldavPlugin = $this->server->getPlugin('caldav'); $principalUrl = $node->getPrincipalUrl(); // schedule-outbox-URL property - $propFind->handle('{' . self::NS_CALDAV . '}schedule-outbox-URL', function() use ($principalUrl, $caldavPlugin) { - + $propFind->handle('{'.self::NS_CALDAV.'}schedule-outbox-URL', function () use ($principalUrl, $caldavPlugin) { $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl); if (!$calendarHomePath) { return null; } - $outboxPath = $calendarHomePath . '/outbox/'; + $outboxPath = $calendarHomePath.'/outbox/'; return new LocalHref($outboxPath); - }); // schedule-inbox-URL property - $propFind->handle('{' . self::NS_CALDAV . '}schedule-inbox-URL', function() use ($principalUrl, $caldavPlugin) { - + $propFind->handle('{'.self::NS_CALDAV.'}schedule-inbox-URL', function () use ($principalUrl, $caldavPlugin) { $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl); if (!$calendarHomePath) { return null; } - $inboxPath = $calendarHomePath . '/inbox/'; + $inboxPath = $calendarHomePath.'/inbox/'; return new LocalHref($inboxPath); - }); - $propFind->handle('{' . self::NS_CALDAV . '}schedule-default-calendar-URL', function() use ($principalUrl, $caldavPlugin) { - + $propFind->handle('{'.self::NS_CALDAV.'}schedule-default-calendar-URL', function () use ($principalUrl, $caldavPlugin) { // We don't support customizing this property yet, so in the // meantime we just grab the first calendar in the home-set. $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl); @@ -243,7 +235,7 @@ class Plugin extends ServerPlugin { return null; } - $sccs = '{' . self::NS_CALDAV . '}supported-calendar-component-set'; + $sccs = '{'.self::NS_CALDAV.'}supported-calendar-component-set'; $result = $this->server->getPropertiesForPath($calendarHomePath, [ '{DAV:}resourcetype', @@ -252,18 +244,17 @@ class Plugin extends ServerPlugin { ], 1); foreach ($result as $child) { - if (!isset($child[200]['{DAV:}resourcetype']) || !$child[200]['{DAV:}resourcetype']->is('{' . self::NS_CALDAV . '}calendar')) { + if (!isset($child[200]['{DAV:}resourcetype']) || !$child[200]['{DAV:}resourcetype']->is('{'.self::NS_CALDAV.'}calendar')) { // Node is either not a calendar continue; } if (isset($child[200]['{DAV:}share-access'])) { $shareAccess = $child[200]['{DAV:}share-access']->getValue(); - if ($shareAccess !== Sharing\Plugin::ACCESS_NOTSHARED && $shareAccess !== Sharing\Plugin::ACCESS_SHAREDOWNER) { + if (Sharing\Plugin::ACCESS_NOTSHARED !== $shareAccess && Sharing\Plugin::ACCESS_SHAREDOWNER !== $shareAccess) { // Node is a shared node, not owned by the relevant // user. continue; } - } if (!isset($child[200][$sccs]) || in_array('VEVENT', $child[200][$sccs]->getValue())) { // Either there is no supported-calendar-component-set @@ -271,82 +262,70 @@ class Plugin extends ServerPlugin { return new LocalHref($child['href']); } } - }); // The server currently reports every principal to be of type // 'INDIVIDUAL' - $propFind->handle('{' . self::NS_CALDAV . '}calendar-user-type', function() { - + $propFind->handle('{'.self::NS_CALDAV.'}calendar-user-type', function () { return 'INDIVIDUAL'; - }); - } // Mapping the old property to the new property. - $propFind->handle('{http://calendarserver.org/ns/}calendar-availability', function() use ($propFind, $node) { - - // In case it wasn't clear, the only difference is that we map the + $propFind->handle('{http://calendarserver.org/ns/}calendar-availability', function () use ($propFind, $node) { + // In case it wasn't clear, the only difference is that we map the // old property to a different namespace. - $availProp = '{' . self::NS_CALDAV . '}calendar-availability'; - $subPropFind = new PropFind( + $availProp = '{'.self::NS_CALDAV.'}calendar-availability'; + $subPropFind = new PropFind( $propFind->getPath(), [$availProp] ); - $this->server->getPropertiesByNode( + $this->server->getPropertiesByNode( $subPropFind, $node ); - $propFind->set( + $propFind->set( '{http://calendarserver.org/ns/}calendar-availability', $subPropFind->get($availProp), $subPropFind->getStatus($availProp) ); - }); - } /** * This method is called during property updates. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch) { - + public function propPatch($path, PropPatch $propPatch) + { // Mapping the old property to the new property. - $propPatch->handle('{http://calendarserver.org/ns/}calendar-availability', function($value) use ($path) { - - $availProp = '{' . self::NS_CALDAV . '}calendar-availability'; + $propPatch->handle('{http://calendarserver.org/ns/}calendar-availability', function ($value) use ($path) { + $availProp = '{'.self::NS_CALDAV.'}calendar-availability'; $subPropPatch = new PropPatch([$availProp => $value]); $this->server->emit('propPatch', [$path, $subPropPatch]); $subPropPatch->commit(); return $subPropPatch->getResult()[$availProp]; - }); - } /** * This method is triggered whenever there was a calendar object gets * created or updated. * - * @param RequestInterface $request HTTP request - * @param ResponseInterface $response HTTP Response - * @param VCalendar $vCal Parsed iCalendar object - * @param mixed $calendarPath Path to calendar collection - * @param mixed $modified The iCalendar object has been touched. - * @param mixed $isNew Whether this was a new item or we're updating one - * @return void + * @param RequestInterface $request HTTP request + * @param ResponseInterface $response HTTP Response + * @param VCalendar $vCal Parsed iCalendar object + * @param mixed $calendarPath Path to calendar collection + * @param mixed $modified the iCalendar object has been touched + * @param mixed $isNew Whether this was a new item or we're updating one */ - function calendarObjectChange(RequestInterface $request, ResponseInterface $response, VCalendar $vCal, $calendarPath, &$modified, $isNew) { - + public function calendarObjectChange(RequestInterface $request, ResponseInterface $response, VCalendar $vCal, $calendarPath, &$modified, $isNew) + { if (!$this->scheduleReply($this->server->httpRequest)) { return; } @@ -370,17 +349,15 @@ class Plugin extends ServerPlugin { // Destroy circular references so PHP will GC the object. $oldObj->destroy(); } - } /** * This method is responsible for delivering the ITip message. * * @param ITip\Message $iTipMessage - * @return void */ - function deliver(ITip\Message $iTipMessage) { - + public function deliver(ITip\Message $iTipMessage) + { $this->server->emit('schedule', [$iTipMessage]); if (!$iTipMessage->scheduleStatus) { $iTipMessage->scheduleStatus = '5.2;There was no system capable of delivering the scheduling message'; @@ -391,7 +368,6 @@ class Plugin extends ServerPlugin { if (!$iTipMessage->significantChange && in_array($baseCode, ['3', '5'])) { $iTipMessage->scheduleStatus = null; } - } /** @@ -401,13 +377,14 @@ class Plugin extends ServerPlugin { * cancellations, and organizers get 'DECLINED' statuses. * * @param string $path - * @return void */ - function beforeUnbind($path) { - + public function beforeUnbind($path) + { // FIXME: We shouldn't trigger this functionality when we're issuing a // MOVE. This is a hack. - if ($this->server->httpRequest->getMethod() === 'MOVE') return; + if ('MOVE' === $this->server->httpRequest->getMethod()) { + return; + } $node = $this->server->tree->getNodeForPath($path); @@ -429,7 +406,6 @@ class Plugin extends ServerPlugin { foreach ($messages as $message) { $this->deliver($message); } - } /** @@ -439,10 +415,9 @@ class Plugin extends ServerPlugin { * scheduling object. * * @param ITip\Message $iTipMessage - * @return void */ - function scheduleLocalDelivery(ITip\Message $iTipMessage) { - + public function scheduleLocalDelivery(ITip\Message $iTipMessage) + { $aclPlugin = $this->server->getPlugin('acl'); // Local delivery is not available if the ACL plugin is not loaded. @@ -450,11 +425,12 @@ class Plugin extends ServerPlugin { return; } - $caldavNS = '{' . self::NS_CALDAV . '}'; + $caldavNS = '{'.self::NS_CALDAV.'}'; $principalUri = $aclPlugin->getPrincipalByUri($iTipMessage->recipient); if (!$principalUri) { $iTipMessage->scheduleStatus = '3.7;Could not find principal.'; + return; } @@ -470,9 +446,9 @@ class Plugin extends ServerPlugin { $principalUri, [ '{DAV:}principal-URL', - $caldavNS . 'calendar-home-set', - $caldavNS . 'schedule-inbox-URL', - $caldavNS . 'schedule-default-calendar-URL', + $caldavNS.'calendar-home-set', + $caldavNS.'schedule-inbox-URL', + $caldavNS.'schedule-default-calendar-URL', '{http://sabredav.org/ns}email-address', ] ); @@ -480,31 +456,35 @@ class Plugin extends ServerPlugin { // Re-registering the ACL event $this->server->on('propFind', [$aclPlugin, 'propFind'], 20); - if (!isset($result[$caldavNS . 'schedule-inbox-URL'])) { + if (!isset($result[$caldavNS.'schedule-inbox-URL'])) { $iTipMessage->scheduleStatus = '5.2;Could not find local inbox'; + return; } - if (!isset($result[$caldavNS . 'calendar-home-set'])) { + if (!isset($result[$caldavNS.'calendar-home-set'])) { $iTipMessage->scheduleStatus = '5.2;Could not locate a calendar-home-set'; + return; } - if (!isset($result[$caldavNS . 'schedule-default-calendar-URL'])) { + if (!isset($result[$caldavNS.'schedule-default-calendar-URL'])) { $iTipMessage->scheduleStatus = '5.2;Could not find a schedule-default-calendar-URL property'; + return; } - $calendarPath = $result[$caldavNS . 'schedule-default-calendar-URL']->getHref(); - $homePath = $result[$caldavNS . 'calendar-home-set']->getHref(); - $inboxPath = $result[$caldavNS . 'schedule-inbox-URL']->getHref(); + $calendarPath = $result[$caldavNS.'schedule-default-calendar-URL']->getHref(); + $homePath = $result[$caldavNS.'calendar-home-set']->getHref(); + $inboxPath = $result[$caldavNS.'schedule-inbox-URL']->getHref(); - if ($iTipMessage->method === 'REPLY') { + if ('REPLY' === $iTipMessage->method) { $privilege = 'schedule-deliver-reply'; } else { $privilege = 'schedule-deliver-invite'; } - if (!$aclPlugin->checkPrivileges($inboxPath, $caldavNS . $privilege, DAVACL\Plugin::R_PARENT, false)) { - $iTipMessage->scheduleStatus = '3.8;insufficient privileges: ' . $privilege . ' is required on the recipient schedule inbox.'; + if (!$aclPlugin->checkPrivileges($inboxPath, $caldavNS.$privilege, DAVACL\Plugin::R_PARENT, false)) { + $iTipMessage->scheduleStatus = '3.8;insufficient privileges: '.$privilege.' is required on the recipient schedule inbox.'; + return; } @@ -512,7 +492,7 @@ class Plugin extends ServerPlugin { // the users' calendars. $uid = $iTipMessage->uid; - $newFileName = 'sabredav-' . \Sabre\DAV\UUIDUtil::getUUID() . '.ics'; + $newFileName = 'sabredav-'.\Sabre\DAV\UUIDUtil::getUUID().'.ics'; $home = $this->server->tree->getNodeForPath($homePath); $inbox = $this->server->tree->getNodeForPath($inboxPath); @@ -524,7 +504,7 @@ class Plugin extends ServerPlugin { $result = $home->getCalendarObjectByUID($uid); if ($result) { // There was an existing object, we need to update probably. - $objectPath = $homePath . '/' . $result; + $objectPath = $homePath.'/'.$result; $objectNode = $this->server->tree->getNodeForPath($objectPath); $oldICalendarData = $objectNode->get(); $currentObject = Reader::read($oldICalendarData); @@ -545,6 +525,7 @@ class Plugin extends ServerPlugin { // The implication is that processMessage did not understand the // iTip message. $iTipMessage->scheduleStatus = '5.0;iTip message was not processed by the server, likely because we didn\'t understand it.'; + return; } @@ -558,7 +539,7 @@ class Plugin extends ServerPlugin { // If the message was a reply, we may have to inform other // attendees of this attendees status. Therefore we're shooting off // another itipMessage. - if ($iTipMessage->method === 'REPLY') { + if ('REPLY' === $iTipMessage->method) { $this->processICalendarChange( $oldICalendarData, $newObject, @@ -569,7 +550,6 @@ class Plugin extends ServerPlugin { $objectNode->put($newObject->serialize()); } $iTipMessage->scheduleStatus = '1.2;Message delivered locally'; - } /** @@ -581,54 +561,53 @@ class Plugin extends ServerPlugin { * @param INode $node * @param array $supportedPrivilegeSet */ - function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) { - - $ns = '{' . self::NS_CALDAV . '}'; + public function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) + { + $ns = '{'.self::NS_CALDAV.'}'; if ($node instanceof IOutbox) { - $supportedPrivilegeSet[$ns . 'schedule-send'] = [ - 'abstract' => false, + $supportedPrivilegeSet[$ns.'schedule-send'] = [ + 'abstract' => false, 'aggregates' => [ - $ns . 'schedule-send-invite' => [ - 'abstract' => false, + $ns.'schedule-send-invite' => [ + 'abstract' => false, 'aggregates' => [], ], - $ns . 'schedule-send-reply' => [ - 'abstract' => false, + $ns.'schedule-send-reply' => [ + 'abstract' => false, 'aggregates' => [], ], - $ns . 'schedule-send-freebusy' => [ - 'abstract' => false, + $ns.'schedule-send-freebusy' => [ + 'abstract' => false, 'aggregates' => [], ], // Privilege from an earlier scheduling draft, but still // used by some clients. - $ns . 'schedule-post-vevent' => [ - 'abstract' => false, + $ns.'schedule-post-vevent' => [ + 'abstract' => false, 'aggregates' => [], ], - ] + ], ]; } if ($node instanceof IInbox) { - $supportedPrivilegeSet[$ns . 'schedule-deliver'] = [ - 'abstract' => false, + $supportedPrivilegeSet[$ns.'schedule-deliver'] = [ + 'abstract' => false, 'aggregates' => [ - $ns . 'schedule-deliver-invite' => [ - 'abstract' => false, + $ns.'schedule-deliver-invite' => [ + 'abstract' => false, 'aggregates' => [], ], - $ns . 'schedule-deliver-reply' => [ - 'abstract' => false, + $ns.'schedule-deliver-reply' => [ + 'abstract' => false, 'aggregates' => [], ], - $ns . 'schedule-query-freebusy' => [ - 'abstract' => false, + $ns.'schedule-query-freebusy' => [ + 'abstract' => false, 'aggregates' => [], ], - ] + ], ]; } - } /** @@ -642,22 +621,22 @@ class Plugin extends ServerPlugin { * This method may update $newObject to add any status changes. * * @param VCalendar|string $oldObject - * @param VCalendar $newObject - * @param array $addresses - * @param array $ignore Any addresses to not send messages to. - * @param bool $modified A marker to indicate that the original object - * modified by this process. - * @return void + * @param VCalendar $newObject + * @param array $addresses + * @param array $ignore any addresses to not send messages to + * @param bool $modified a marker to indicate that the original object + * modified by this process */ - protected function processICalendarChange($oldObject = null, VCalendar $newObject, array $addresses, array $ignore = [], &$modified = false) { - + protected function processICalendarChange($oldObject = null, VCalendar $newObject, array $addresses, array $ignore = [], &$modified = false) + { $broker = new ITip\Broker(); $messages = $broker->parseEvent($newObject, $addresses, $oldObject); - if ($messages) $modified = true; + if ($messages) { + $modified = true; + } foreach ($messages as $message) { - if (in_array($message->recipient, $ignore)) { continue; } @@ -669,36 +648,32 @@ class Plugin extends ServerPlugin { $newObject->VEVENT->ORGANIZER['SCHEDULE-STATUS'] = $message->getScheduleStatus(); } unset($newObject->VEVENT->ORGANIZER['SCHEDULE-FORCE-SEND']); - } else { - - if (isset($newObject->VEVENT->ATTENDEE)) foreach ($newObject->VEVENT->ATTENDEE as $attendee) { - - if ($attendee->getNormalizedValue() === $message->recipient) { - if ($message->scheduleStatus) { - $attendee['SCHEDULE-STATUS'] = $message->getScheduleStatus(); + if (isset($newObject->VEVENT->ATTENDEE)) { + foreach ($newObject->VEVENT->ATTENDEE as $attendee) { + if ($attendee->getNormalizedValue() === $message->recipient) { + if ($message->scheduleStatus) { + $attendee['SCHEDULE-STATUS'] = $message->getScheduleStatus(); + } + unset($attendee['SCHEDULE-FORCE-SEND']); + break; } - unset($attendee['SCHEDULE-FORCE-SEND']); - break; } - } - } - } - } /** * Returns a list of addresses that are associated with a principal. * * @param string $principal + * * @return array */ - protected function getAddressesForPrincipal($principal) { - - $CUAS = '{' . self::NS_CALDAV . '}calendar-user-address-set'; + protected function getAddressesForPrincipal($principal) + { + $CUAS = '{'.self::NS_CALDAV.'}calendar-user-address-set'; $properties = $this->server->getProperties( $principal, @@ -707,12 +682,12 @@ class Plugin extends ServerPlugin { // If we can't find this information, we'll stop processing if (!isset($properties[$CUAS])) { - return; + return []; } $addresses = $properties[$CUAS]->getHrefs(); - return $addresses; + return $addresses; } /** @@ -726,20 +701,19 @@ class Plugin extends ServerPlugin { * extensions, but iCal depends on a feature from that spec, so we * implement it. * - * @param IOutbox $outboxNode - * @param RequestInterface $request + * @param IOutbox $outboxNode + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function outboxRequest(IOutbox $outboxNode, RequestInterface $request, ResponseInterface $response) { - + public function outboxRequest(IOutbox $outboxNode, RequestInterface $request, ResponseInterface $response) + { $outboxPath = $request->getPath(); // Parsing the request body try { $vObject = VObject\Reader::read($request->getBody()); } catch (VObject\ParseException $e) { - throw new BadRequest('The request body must be a valid iCalendar object. Parse error: ' . $e->getMessage()); + throw new BadRequest('The request body must be a valid iCalendar object. Parse error: '.$e->getMessage()); } // The incoming iCalendar object must have a METHOD property, and a @@ -747,7 +721,7 @@ class Plugin extends ServerPlugin { // this is. $componentType = null; foreach ($vObject->getComponents() as $component) { - if ($component->name !== 'VTIMEZONE') { + if ('VTIMEZONE' !== $component->name) { $componentType = $component->name; break; } @@ -757,7 +731,7 @@ class Plugin extends ServerPlugin { } // Validating the METHOD - $method = strtoupper((string)$vObject->METHOD); + $method = strtoupper((string) $vObject->METHOD); if (!$method) { throw new BadRequest('A METHOD property must be specified in iTIP messages'); } @@ -768,46 +742,42 @@ class Plugin extends ServerPlugin { $acl = $this->server->getPlugin('acl'); - if ($componentType === 'VFREEBUSY' && $method === 'REQUEST') { - - $acl && $acl->checkPrivileges($outboxPath, '{' . self::NS_CALDAV . '}schedule-send-freebusy'); + if ('VFREEBUSY' === $componentType && 'REQUEST' === $method) { + $acl && $acl->checkPrivileges($outboxPath, '{'.self::NS_CALDAV.'}schedule-send-freebusy'); $this->handleFreeBusyRequest($outboxNode, $vObject, $request, $response); // Destroy circular references so PHP can GC the object. $vObject->destroy(); unset($vObject); - } else { - throw new NotImplemented('We only support VFREEBUSY (REQUEST) on this endpoint'); - } - } /** * This method is responsible for parsing a free-busy query request and * returning it's result. * - * @param IOutbox $outbox + * @param IOutbox $outbox * @param VObject\Component $vObject - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return string */ - protected function handleFreeBusyRequest(IOutbox $outbox, VObject\Component $vObject, RequestInterface $request, ResponseInterface $response) { - + protected function handleFreeBusyRequest(IOutbox $outbox, VObject\Component $vObject, RequestInterface $request, ResponseInterface $response) + { $vFreeBusy = $vObject->VFREEBUSY; $organizer = $vFreeBusy->ORGANIZER; - $organizer = (string)$organizer; + $organizer = (string) $organizer; // Validating if the organizer matches the owner of the inbox. $owner = $outbox->getOwner(); - $caldavNS = '{' . self::NS_CALDAV . '}'; + $caldavNS = '{'.self::NS_CALDAV.'}'; - $uas = $caldavNS . 'calendar-user-address-set'; + $uas = $caldavNS.'calendar-user-address-set'; $props = $this->server->getProperties($owner, [$uas]); if (empty($props[$uas]) || !in_array($organizer, $props[$uas]->getHrefs())) { @@ -820,10 +790,9 @@ class Plugin extends ServerPlugin { $attendees = []; foreach ($vFreeBusy->ATTENDEE as $attendee) { - $attendees[] = (string)$attendee; + $attendees[] = (string) $attendee; } - if (!isset($vFreeBusy->DTSTART) || !isset($vFreeBusy->DTEND)) { throw new BadRequest('DTSTART and DTEND must both be specified'); } @@ -840,9 +809,7 @@ class Plugin extends ServerPlugin { $dom->formatOutput = true; $scheduleResponse = $dom->createElement('cal:schedule-response'); foreach ($this->server->xml->namespaceMap as $namespace => $prefix) { - - $scheduleResponse->setAttribute('xmlns:' . $prefix, $namespace); - + $scheduleResponse->setAttribute('xmlns:'.$prefix, $namespace); } $dom->appendChild($scheduleResponse); @@ -861,11 +828,9 @@ class Plugin extends ServerPlugin { $xresponse->appendChild($reqStatus); if (isset($result['calendar-data'])) { - $calendardata = $dom->createElement('cal:calendar-data'); $calendardata->appendChild($dom->createTextNode(str_replace("\r\n", "\n", $result['calendar-data']->serialize()))); $xresponse->appendChild($calendardata); - } $scheduleResponse->appendChild($xresponse); } @@ -873,12 +838,11 @@ class Plugin extends ServerPlugin { $response->setStatus(200); $response->setHeader('Content-Type', 'application/xml'); $response->setBody($dom->saveXML()); - } /** * Returns free-busy information for a specific address. The returned - * data is an array containing the following properties: + * data is an array containing the following properties:. * * calendar-data : A VFREEBUSY VObject * request-status : an iTip status code. @@ -888,54 +852,56 @@ class Plugin extends ServerPlugin { * * 2.0;description * * 3.7;description * - * @param string $email address + * @param string $email address * @param \DateTimeInterface $start * @param \DateTimeInterface $end - * @param VObject\Component $request + * @param VObject\Component $request + * * @return array */ - protected function getFreeBusyForEmail($email, \DateTimeInterface $start, \DateTimeInterface $end, VObject\Component $request) { - - $caldavNS = '{' . self::NS_CALDAV . '}'; + protected function getFreeBusyForEmail($email, \DateTimeInterface $start, \DateTimeInterface $end, VObject\Component $request) + { + $caldavNS = '{'.self::NS_CALDAV.'}'; $aclPlugin = $this->server->getPlugin('acl'); - if (substr($email, 0, 7) === 'mailto:') $email = substr($email, 7); + if ('mailto:' === substr($email, 0, 7)) { + $email = substr($email, 7); + } $result = $aclPlugin->principalSearch( ['{http://sabredav.org/ns}email-address' => $email], [ '{DAV:}principal-URL', - $caldavNS . 'calendar-home-set', - $caldavNS . 'schedule-inbox-URL', + $caldavNS.'calendar-home-set', + $caldavNS.'schedule-inbox-URL', '{http://sabredav.org/ns}email-address', - ] ); if (!count($result)) { return [ 'request-status' => '3.7;Could not find principal', - 'href' => 'mailto:' . $email, + 'href' => 'mailto:'.$email, ]; } - if (!isset($result[0][200][$caldavNS . 'calendar-home-set'])) { + if (!isset($result[0][200][$caldavNS.'calendar-home-set'])) { return [ 'request-status' => '3.7;No calendar-home-set property found', - 'href' => 'mailto:' . $email, + 'href' => 'mailto:'.$email, ]; } - if (!isset($result[0][200][$caldavNS . 'schedule-inbox-URL'])) { + if (!isset($result[0][200][$caldavNS.'schedule-inbox-URL'])) { return [ 'request-status' => '3.7;No schedule-inbox-URL property found', - 'href' => 'mailto:' . $email, + 'href' => 'mailto:'.$email, ]; } - $homeSet = $result[0][200][$caldavNS . 'calendar-home-set']->getHref(); - $inboxUrl = $result[0][200][$caldavNS . 'schedule-inbox-URL']->getHref(); + $homeSet = $result[0][200][$caldavNS.'calendar-home-set']->getHref(); + $inboxUrl = $result[0][200][$caldavNS.'schedule-inbox-URL']->getHref(); // Do we have permission? - $aclPlugin->checkPrivileges($inboxUrl, $caldavNS . 'schedule-query-freebusy'); + $aclPlugin->checkPrivileges($inboxUrl, $caldavNS.'schedule-query-freebusy'); // Grabbing the calendar list $objects = []; @@ -946,11 +912,11 @@ class Plugin extends ServerPlugin { continue; } - $sct = $caldavNS . 'schedule-calendar-transp'; - $ctz = $caldavNS . 'calendar-timezone'; + $sct = $caldavNS.'schedule-calendar-transp'; + $ctz = $caldavNS.'calendar-timezone'; $props = $node->getProperties([$sct, $ctz]); - if (isset($props[$sct]) && $props[$sct]->getValue() == ScheduleCalendarTransp::TRANSPARENT) { + if (isset($props[$sct]) && ScheduleCalendarTransp::TRANSPARENT == $props[$sct]->getValue()) { // If a calendar is marked as 'transparent', it means we must // ignore it for free-busy purposes. continue; @@ -962,41 +928,40 @@ class Plugin extends ServerPlugin { // Destroy circular references so PHP can garbage collect the object. $vtimezoneObj->destroy(); - } // Getting the list of object uris within the time-range $urls = $node->calendarQuery([ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => $start, - 'end' => $end, + 'end' => $end, ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]); - $calObjects = array_map(function($url) use ($node) { + $calObjects = array_map(function ($url) use ($node) { $obj = $node->getChild($url)->get(); + return $obj; }, $urls); $objects = array_merge($objects, $calObjects); - } $inboxProps = $this->server->getProperties( $inboxUrl, - $caldavNS . 'calendar-availability' + $caldavNS.'calendar-availability' ); $vcalendar = new VObject\Component\VCalendar(); @@ -1011,21 +976,21 @@ class Plugin extends ServerPlugin { if ($inboxProps) { $generator->setVAvailability( VObject\Reader::read( - $inboxProps[$caldavNS . 'calendar-availability'] + $inboxProps[$caldavNS.'calendar-availability'] ) ); } $result = $generator->getResult(); - $vcalendar->VFREEBUSY->ATTENDEE = 'mailto:' . $email; - $vcalendar->VFREEBUSY->UID = (string)$request->VFREEBUSY->UID; + $vcalendar->VFREEBUSY->ATTENDEE = 'mailto:'.$email; + $vcalendar->VFREEBUSY->UID = (string) $request->VFREEBUSY->UID; $vcalendar->VFREEBUSY->ORGANIZER = clone $request->VFREEBUSY->ORGANIZER; return [ - 'calendar-data' => $result, + 'calendar-data' => $result, 'request-status' => '2.0;Success', - 'href' => 'mailto:' . $email, + 'href' => 'mailto:'.$email, ]; } @@ -1034,13 +999,14 @@ class Plugin extends ServerPlugin { * and returns false if it's 'F', otherwise true. * * @param RequestInterface $request + * * @return bool */ - private function scheduleReply(RequestInterface $request) { - + private function scheduleReply(RequestInterface $request) + { $scheduleReply = $request->getHeader('Schedule-Reply'); - return $scheduleReply !== 'F'; + return 'F' !== $scheduleReply; } /** @@ -1054,13 +1020,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds calendar-auto-schedule, as defined in rfc6638', - 'link' => 'http://sabre.io/dav/scheduling/', + 'link' => 'http://sabre.io/dav/scheduling/', ]; - } } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php b/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php index 0cd05a965..d34c92327 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php @@ -1,35 +1,23 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; use Sabre\CalDAV\Backend; use Sabre\DAV\Exception\MethodNotAllowed; /** - * The SchedulingObject represents a scheduling object in the Inbox collection + * The SchedulingObject represents a scheduling object in the Inbox collection. * * @author Brett (https://github.com/bretten) * @license http://sabre.io/license/ Modified BSD License * @copyright Copyright (C) fruux GmbH (https://fruux.com/) */ -class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements ISchedulingObject { - - /** - /* The CalDAV backend - * - * @var Backend\SchedulingSupport - */ - protected $caldavBackend; - - /** - * Array with information about this SchedulingObject - * - * @var array - */ - protected $objectData; - +class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements ISchedulingObject +{ /** - * Constructor + * Constructor. * * The following properties may be passed within $objectData: * @@ -43,73 +31,65 @@ class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements IScheduli * * acl - (optional) Use this to override the default ACL for the node. * * @param Backend\SchedulingSupport $caldavBackend - * @param array $objectData + * @param array $objectData */ - function __construct(Backend\SchedulingSupport $caldavBackend, array $objectData) { - - $this->caldavBackend = $caldavBackend; + public function __construct(Backend\SchedulingSupport $caldavBackend, array $objectData) + { + parent::__construct($caldavBackend, [], $objectData); if (!isset($objectData['uri'])) { throw new \InvalidArgumentException('The objectData argument must contain an \'uri\' property'); } - - $this->objectData = $objectData; - } /** - * Returns the ICalendar-formatted object + * Returns the ICalendar-formatted object. * * @return string */ - function get() { - + public function get() + { // Pre-populating the 'calendardata' is optional, if we don't have it // already we fetch it from the backend. if (!isset($this->objectData['calendardata'])) { $this->objectData = $this->caldavBackend->getSchedulingObject($this->objectData['principaluri'], $this->objectData['uri']); } - return $this->objectData['calendardata']; + return $this->objectData['calendardata']; } /** - * Updates the ICalendar-formatted object + * Updates the ICalendar-formatted object. * * @param string|resource $calendarData + * * @return string */ - function put($calendarData) { - + public function put($calendarData) + { throw new MethodNotAllowed('Updating scheduling objects is not supported'); - } /** - * Deletes the scheduling message - * - * @return void + * Deletes the scheduling message. */ - function delete() { - + public function delete() + { $this->caldavBackend->deleteSchedulingObject($this->objectData['principaluri'], $this->objectData['uri']); - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->objectData['principaluri']; - } - /** * Returns a list of ACE's for this node. * @@ -122,8 +102,8 @@ class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements IScheduli * * @return array */ - function getACL() { - + public function getACL() + { // An alternative acl may be specified in the object data. // @@ -140,16 +120,14 @@ class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements IScheduli ], [ 'privilege' => '{DAV:}all', - 'principal' => $this->objectData['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->objectData['principaluri'].'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->objectData['principaluri'] . '/calendar-proxy-read', + 'principal' => $this->objectData['principaluri'].'/calendar-proxy-read', 'protected' => true, ], ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php b/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php index 7a77616e3..818392f57 100644 --- a/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php +++ b/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV\Sharing\Plugin as SPlugin; @@ -11,8 +13,8 @@ use Sabre\DAV\Sharing\Plugin as SPlugin; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SharedCalendar extends Calendar implements ISharedCalendar { - +class SharedCalendar extends Calendar implements ISharedCalendar +{ /** * Returns the 'access level' for the instance of this shared resource. * @@ -21,10 +23,9 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * * @return int */ - function getShareAccess() { - + public function getShareAccess() + { return isset($this->calendarInfo['share-access']) ? $this->calendarInfo['share-access'] : SPlugin::ACCESS_NOTSHARED; - } /** @@ -38,10 +39,9 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * * @return string */ - function getShareResourceUri() { - + public function getShareResourceUri() + { return $this->calendarInfo['share-resource-uri']; - } /** @@ -50,12 +50,10 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * Every item must be a Sharee object. * * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees - * @return void */ - function updateInvites(array $sharees) { - + public function updateInvites(array $sharees) + { $this->caldavBackend->updateInvites($this->calendarInfo['id'], $sharees); - } /** @@ -74,10 +72,9 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * * @return \Sabre\DAV\Xml\Element\Sharee[] */ - function getInvites() { - + public function getInvites() + { return $this->caldavBackend->getInvites($this->calendarInfo['id']); - } /** @@ -87,12 +84,10 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * subscribable calendar. * * @param bool $value - * @return void */ - function setPublishStatus($value) { - + public function setPublishStatus($value) + { $this->caldavBackend->setPublishStatus($this->calendarInfo['id'], $value); - } /** @@ -107,13 +102,13 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * * @return array */ - function getACL() { - + public function getACL() + { $acl = []; switch ($this->getShareAccess()) { - case SPlugin::ACCESS_NOTSHARED : - case SPlugin::ACCESS_SHAREDOWNER : + case SPlugin::ACCESS_NOTSHARED: + case SPlugin::ACCESS_SHAREDOWNER: $acl[] = [ 'privilege' => '{DAV:}share', 'principal' => $this->calendarInfo['principaluri'], @@ -121,11 +116,11 @@ class SharedCalendar extends Calendar implements ISharedCalendar { ]; $acl[] = [ 'privilege' => '{DAV:}share', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ]; - // No break intentional! - case SPlugin::ACCESS_READWRITE : + // no break intentional! + case SPlugin::ACCESS_READWRITE: $acl[] = [ 'privilege' => '{DAV:}write', 'principal' => $this->calendarInfo['principaluri'], @@ -133,11 +128,11 @@ class SharedCalendar extends Calendar implements ISharedCalendar { ]; $acl[] = [ 'privilege' => '{DAV:}write', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ]; - // No break intentional! - case SPlugin::ACCESS_READ : + // no break intentional! + case SPlugin::ACCESS_READ: $acl[] = [ 'privilege' => '{DAV:}write-properties', 'principal' => $this->calendarInfo['principaluri'], @@ -145,7 +140,7 @@ class SharedCalendar extends Calendar implements ISharedCalendar { ]; $acl[] = [ 'privilege' => '{DAV:}write-properties', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ]; $acl[] = [ @@ -155,26 +150,25 @@ class SharedCalendar extends Calendar implements ISharedCalendar { ]; $acl[] = [ 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read', 'protected' => true, ]; $acl[] = [ 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ]; $acl[] = [ - 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', + 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true, ]; break; } - return $acl; + return $acl; } - /** * This method returns the ACL's for calendar objects in this calendar. * The result of this method automatically gets passed to the @@ -182,15 +176,13 @@ class SharedCalendar extends Calendar implements ISharedCalendar { * * @return array */ - function getChildACL() { - + public function getChildACL() + { $acl = []; switch ($this->getShareAccess()) { - case SPlugin::ACCESS_NOTSHARED : - // No break intentional - case SPlugin::ACCESS_SHAREDOWNER : - // No break intentional + case SPlugin::ACCESS_NOTSHARED: + case SPlugin::ACCESS_SHAREDOWNER: case SPlugin::ACCESS_READWRITE: $acl[] = [ 'privilege' => '{DAV:}write', @@ -199,10 +191,10 @@ class SharedCalendar extends Calendar implements ISharedCalendar { ]; $acl[] = [ 'privilege' => '{DAV:}write', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ]; - // No break intentional + // no break intentional case SPlugin::ACCESS_READ: $acl[] = [ 'privilege' => '{DAV:}read', @@ -211,19 +203,17 @@ class SharedCalendar extends Calendar implements ISharedCalendar { ]; $acl[] = [ 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write', 'protected' => true, ]; $acl[] = [ 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read', + 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read', 'protected' => true, ]; break; } return $acl; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php b/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php index 5cce79678..be8c46a9e 100644 --- a/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php +++ b/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; @@ -23,8 +25,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SharingPlugin extends DAV\ServerPlugin { - +class SharingPlugin extends DAV\ServerPlugin +{ /** * Reference to SabreDAV server object. * @@ -40,10 +42,9 @@ class SharingPlugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['calendarserver-sharing']; - } /** @@ -54,10 +55,9 @@ class SharingPlugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'caldav-sharing'; - } /** @@ -69,10 +69,9 @@ class SharingPlugin extends DAV\ServerPlugin { * This method should set up the required event subscriptions. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; if (is_null($this->server->getPlugin('sharing'))) { @@ -81,19 +80,18 @@ class SharingPlugin extends DAV\ServerPlugin { array_push( $this->server->protectedProperties, - '{' . Plugin::NS_CALENDARSERVER . '}invite', - '{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes', - '{' . Plugin::NS_CALENDARSERVER . '}shared-url' + '{'.Plugin::NS_CALENDARSERVER.'}invite', + '{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes', + '{'.Plugin::NS_CALENDARSERVER.'}shared-url' ); - $this->server->xml->elementMap['{' . Plugin::NS_CALENDARSERVER . '}share'] = 'Sabre\\CalDAV\\Xml\\Request\\Share'; - $this->server->xml->elementMap['{' . Plugin::NS_CALENDARSERVER . '}invite-reply'] = 'Sabre\\CalDAV\\Xml\\Request\\InviteReply'; - - $this->server->on('propFind', [$this, 'propFindEarly']); - $this->server->on('propFind', [$this, 'propFindLate'], 150); - $this->server->on('propPatch', [$this, 'propPatch'], 40); - $this->server->on('method:POST', [$this, 'httpPost']); + $this->server->xml->elementMap['{'.Plugin::NS_CALENDARSERVER.'}share'] = 'Sabre\\CalDAV\\Xml\\Request\\Share'; + $this->server->xml->elementMap['{'.Plugin::NS_CALENDARSERVER.'}invite-reply'] = 'Sabre\\CalDAV\\Xml\\Request\\InviteReply'; + $this->server->on('propFind', [$this, 'propFindEarly']); + $this->server->on('propFind', [$this, 'propFindLate'], 150); + $this->server->on('propPatch', [$this, 'propPatch'], 40); + $this->server->on('method:POST', [$this, 'httpPost']); } /** @@ -103,47 +101,17 @@ class SharingPlugin extends DAV\ServerPlugin { * This allows us to inject any properties early. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFindEarly(DAV\PropFind $propFind, DAV\INode $node) { - + public function propFindEarly(DAV\PropFind $propFind, DAV\INode $node) + { if ($node instanceof ISharedCalendar) { - - $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}invite', function() use ($node) { - - // Fetching owner information - $props = $this->server->getPropertiesForPath($node->getOwner(), [ - '{http://sabredav.org/ns}email-address', - '{DAV:}displayname', - ], 0); - - $ownerInfo = [ - 'href' => $node->getOwner(), - ]; - - if (isset($props[0][200])) { - - // We're mapping the internal webdav properties to the - // elements caldav-sharing expects. - if (isset($props[0][200]['{http://sabredav.org/ns}email-address'])) { - $ownerInfo['href'] = 'mailto:' . $props[0][200]['{http://sabredav.org/ns}email-address']; - } - if (isset($props[0][200]['{DAV:}displayname'])) { - $ownerInfo['commonName'] = $props[0][200]['{DAV:}displayname']; - } - - } - + $propFind->handle('{'.Plugin::NS_CALENDARSERVER.'}invite', function () use ($node) { return new Xml\Property\Invite( - $node->getInvites(), - $ownerInfo + $node->getInvites() ); - }); - } - } /** @@ -152,31 +120,27 @@ class SharingPlugin extends DAV\ServerPlugin { * have been shared. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFindLate(DAV\PropFind $propFind, DAV\INode $node) { - + public function propFindLate(DAV\PropFind $propFind, DAV\INode $node) + { if ($node instanceof ISharedCalendar) { $shareAccess = $node->getShareAccess(); if ($rt = $propFind->get('{DAV:}resourcetype')) { switch ($shareAccess) { - case \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER : - $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared-owner'); + case \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER: + $rt->add('{'.Plugin::NS_CALENDARSERVER.'}shared-owner'); break; - case \Sabre\DAV\Sharing\Plugin::ACCESS_READ : - case \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE : - $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared'); + case \Sabre\DAV\Sharing\Plugin::ACCESS_READ: + case \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE: + $rt->add('{'.Plugin::NS_CALENDARSERVER.'}shared'); break; - } } - $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes', function() { + $propFind->handle('{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes', function () { return new Xml\Property\AllowedSharingModes(true, false); }); - } - } /** @@ -190,20 +154,21 @@ class SharingPlugin extends DAV\ServerPlugin { * Even though this is no longer in the current spec, we keep this around * because OS X 10.7 may still make use of this feature. * - * @param string $path + * @param string $path * @param DAV\PropPatch $propPatch - * @return void */ - function propPatch($path, DAV\PropPatch $propPatch) { - + public function propPatch($path, DAV\PropPatch $propPatch) + { $node = $this->server->tree->getNodeForPath($path); - if (!$node instanceof ISharedCalendar) + if (!$node instanceof ISharedCalendar) { return; + } - if ($node->getShareAccess() === \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER || $node->getShareAccess() === \Sabre\DAV\Sharing\Plugin::ACCESS_NOTSHARED) { - - $propPatch->handle('{DAV:}resourcetype', function($value) use ($node) { - if ($value->is('{' . Plugin::NS_CALENDARSERVER . '}shared-owner')) return false; + if (\Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER === $node->getShareAccess() || \Sabre\DAV\Sharing\Plugin::ACCESS_NOTSHARED === $node->getShareAccess()) { + $propPatch->handle('{DAV:}resourcetype', function ($value) use ($node) { + if ($value->is('{'.Plugin::NS_CALENDARSERVER.'}shared-owner')) { + return false; + } $shares = $node->getInvites(); foreach ($shares as $share) { $share->access = DAV\Sharing\Plugin::ACCESS_NOACCESS; @@ -211,28 +176,30 @@ class SharingPlugin extends DAV\ServerPlugin { $node->updateInvites($shares); return true; - }); - } - } /** * We intercept this to handle POST requests on calendars. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return null|bool + * + * @return bool|null */ - function httpPost(RequestInterface $request, ResponseInterface $response) { - + public function httpPost(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); // Only handling xml $contentType = $request->getHeader('Content-Type'); - if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) + if (null === $contentType) { return; + } + if (false === strpos($contentType, 'application/xml') && false === strpos($contentType, 'text/xml')) { + return; + } // Making sure the node exists try { @@ -255,10 +222,9 @@ class SharingPlugin extends DAV\ServerPlugin { $message = $this->server->xml->parse($requestBody, $request->getUrl(), $documentType); switch ($documentType) { - // Both the DAV:share-resource and CALENDARSERVER:share requests // behave identically. - case '{' . Plugin::NS_CALENDARSERVER . '}share' : + case '{'.Plugin::NS_CALENDARSERVER.'}share': $sharingPlugin = $this->server->getPlugin('sharing'); $sharingPlugin->shareResource($path, $message->sharees); @@ -273,7 +239,7 @@ class SharingPlugin extends DAV\ServerPlugin { // The invite-reply document is sent when the user replies to an // invitation of a calendar share. - case '{' . Plugin::NS_CALENDARSERVER . '}invite-reply' : + case '{'.Plugin::NS_CALENDARSERVER.'}invite-reply': // This only works on the calendar-home-root node. if (!$node instanceof CalendarHome) { @@ -304,20 +270,20 @@ class SharingPlugin extends DAV\ServerPlugin { if ($url) { $writer = $this->server->xml->getWriter(); + $writer->contextUri = $request->getUrl(); $writer->openMemory(); $writer->startDocument(); - $writer->startElement('{' . Plugin::NS_CALENDARSERVER . '}shared-as'); + $writer->startElement('{'.Plugin::NS_CALENDARSERVER.'}shared-as'); $writer->write(new LocalHref($url)); $writer->endElement(); $response->setHeader('Content-Type', 'application/xml'); $response->setBody($writer->outputMemory()); - } // Breaking the event chain return false; - case '{' . Plugin::NS_CALENDARSERVER . '}publish-calendar' : + case '{'.Plugin::NS_CALENDARSERVER.'}publish-calendar': // We can only deal with IShareableCalendar objects if (!$node instanceof ISharedCalendar) { @@ -345,7 +311,7 @@ class SharingPlugin extends DAV\ServerPlugin { // Breaking the event chain return false; - case '{' . Plugin::NS_CALENDARSERVER . '}unpublish-calendar' : + case '{'.Plugin::NS_CALENDARSERVER.'}unpublish-calendar': // We can only deal with IShareableCalendar objects if (!$node instanceof ISharedCalendar) { @@ -371,11 +337,7 @@ class SharingPlugin extends DAV\ServerPlugin { // Breaking the event chain return false; - } - - - } /** @@ -389,13 +351,12 @@ class SharingPlugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds support for caldav-sharing.', - 'link' => 'http://sabre.io/dav/caldav-sharing/', + 'link' => 'http://sabre.io/dav/caldav-sharing/', ]; - } } diff --git a/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php b/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php index 7ba259c7b..e83082c52 100644 --- a/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php +++ b/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Subscriptions; use Sabre\DAV\ICollection; use Sabre\DAV\IProperties; /** - * ISubscription + * ISubscription. * * Nodes implementing this interface represent calendar subscriptions. * @@ -34,7 +36,6 @@ use Sabre\DAV\IProperties; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ISubscription extends ICollection, IProperties { - - +interface ISubscription extends ICollection, IProperties +{ } diff --git a/vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php index 877d96c6c..238866894 100644 --- a/vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php +++ b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Subscriptions; use Sabre\DAV\INode; @@ -17,8 +19,8 @@ use Sabre\DAV\ServerPlugin; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ /** * This initializes the plugin. * @@ -28,10 +30,9 @@ class Plugin extends ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $server->resourceTypeMapping['Sabre\\CalDAV\\Subscriptions\\ISubscription'] = '{http://calendarserver.org/ns/}subscribed'; @@ -39,7 +40,6 @@ class Plugin extends ServerPlugin { 'Sabre\\DAV\\Xml\\Property\\Href'; $server->on('propFind', [$this, 'propFind'], 150); - } /** @@ -50,21 +50,19 @@ class Plugin extends ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['calendarserver-subscribed']; - } /** * Triggered after properties have been fetched. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - + public function propFind(PropFind $propFind, INode $node) + { // There's a bunch of properties that must appear as a self-closing // xml-element. This event handler ensures that this will be the case. $props = [ @@ -74,13 +72,10 @@ class Plugin extends ServerPlugin { ]; foreach ($props as $prop) { - - if ($propFind->getStatus($prop) === 200) { + if (200 === $propFind->getStatus($prop)) { $propFind->set($prop, '', 200); } - } - } /** @@ -91,10 +86,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'subscriptions'; - } /** @@ -108,13 +102,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'This plugin allows users to store iCalendar subscriptions in their calendar-home.', - 'link' => null, + 'link' => null, ]; - } } diff --git a/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php index 6a1851ed8..0b0282abe 100644 --- a/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php +++ b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Subscriptions; use Sabre\CalDAV\Backend\SubscriptionSupport; @@ -10,7 +12,7 @@ use Sabre\DAVACL\ACLTrait; use Sabre\DAVACL\IACL; /** - * Subscription Node + * Subscription Node. * * This node represents a subscription. * @@ -18,32 +20,32 @@ use Sabre\DAVACL\IACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Subscription extends Collection implements ISubscription, IACL { - +class Subscription extends Collection implements ISubscription, IACL +{ use ACLTrait; /** - * caldavBackend + * caldavBackend. * * @var SubscriptionSupport */ protected $caldavBackend; /** - * subscriptionInfo + * subscriptionInfo. * * @var array */ protected $subscriptionInfo; /** - * Constructor + * Constructor. * * @param SubscriptionSupport $caldavBackend - * @param array $subscriptionInfo + * @param array $subscriptionInfo */ - function __construct(SubscriptionSupport $caldavBackend, array $subscriptionInfo) { - + public function __construct(SubscriptionSupport $caldavBackend, array $subscriptionInfo) + { $this->caldavBackend = $caldavBackend; $this->subscriptionInfo = $subscriptionInfo; @@ -56,10 +58,9 @@ class Subscription extends Collection implements ISubscription, IACL { foreach ($required as $r) { if (!isset($subscriptionInfo[$r])) { - throw new \InvalidArgumentException('The ' . $r . ' field is required when creating a subscription node'); + throw new \InvalidArgumentException('The '.$r.' field is required when creating a subscription node'); } } - } /** @@ -69,47 +70,41 @@ class Subscription extends Collection implements ISubscription, IACL { * * @return string */ - function getName() { - + public function getName() + { return $this->subscriptionInfo['uri']; - } /** - * Returns the last modification time + * Returns the last modification time. * * @return int */ - function getLastModified() { - + public function getLastModified() + { if (isset($this->subscriptionInfo['lastmodified'])) { return $this->subscriptionInfo['lastmodified']; } - } /** - * Deletes the current node - * - * @return void + * Deletes the current node. */ - function delete() { - + public function delete() + { $this->caldavBackend->deleteSubscription( $this->subscriptionInfo['id'] ); - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return \Sabre\DAV\INode[] */ - function getChildren() { - + public function getChildren() + { return []; - } /** @@ -122,15 +117,13 @@ class Subscription extends Collection implements ISubscription, IACL { * Read the PropPatch documentation for more information. * * @param PropPatch $propPatch - * @return void */ - function propPatch(PropPatch $propPatch) { - + public function propPatch(PropPatch $propPatch) + { return $this->caldavBackend->updateSubscription( $this->subscriptionInfo['id'], $propPatch ); - } /** @@ -146,29 +139,27 @@ class Subscription extends Collection implements ISubscription, IACL { * The Server class will filter out the extra. * * @param array $properties + * * @return array */ - function getProperties($properties) { - + public function getProperties($properties) + { $r = []; foreach ($properties as $prop) { - switch ($prop) { - case '{http://calendarserver.org/ns/}source' : + case '{http://calendarserver.org/ns/}source': $r[$prop] = new Href($this->subscriptionInfo['source']); break; - default : + default: if (array_key_exists($prop, $this->subscriptionInfo)) { $r[$prop] = $this->subscriptionInfo[$prop]; } break; } - } return $r; - } /** @@ -178,10 +169,9 @@ class Subscription extends Collection implements ISubscription, IACL { * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->subscriptionInfo['principaluri']; - } /** @@ -196,8 +186,8 @@ class Subscription extends Collection implements ISubscription, IACL { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ 'privilege' => '{DAV:}all', @@ -206,16 +196,14 @@ class Subscription extends Collection implements ISubscription, IACL { ], [ 'privilege' => '{DAV:}all', - 'principal' => $this->getOwner() . '/calendar-proxy-write', + 'principal' => $this->getOwner().'/calendar-proxy-write', 'protected' => true, ], [ 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-read', + 'principal' => $this->getOwner().'/calendar-proxy-read', 'protected' => true, - ] + ], ]; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CalendarData.php b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CalendarData.php index 9669be304..0d53aeda3 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CalendarData.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CalendarData.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Filter; use Sabre\CalDAV\Plugin; @@ -25,8 +27,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class CalendarData implements XmlDeserializable { - +class CalendarData implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -46,24 +48,24 @@ class CalendarData implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $result = [ 'contentType' => $reader->getAttribute('content-type') ?: 'text/calendar', - 'version' => $reader->getAttribute('version') ?: '2.0', + 'version' => $reader->getAttribute('version') ?: '2.0', ]; - $elems = (array)$reader->parseInnerTree(); + $elems = (array) $reader->parseInnerTree(); foreach ($elems as $elem) { - switch ($elem['name']) { - case '{' . Plugin::NS_CALDAV . '}expand' : + case '{'.Plugin::NS_CALDAV.'}expand': $result['expand'] = [ 'start' => isset($elem['attributes']['start']) ? DateTimeParser::parseDateTime($elem['attributes']['start']) : null, - 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null, + 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null, ]; if (!$result['expand']['start'] || !$result['expand']['end']) { @@ -74,11 +76,8 @@ class CalendarData implements XmlDeserializable { } break; } - } return $result; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CompFilter.php b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CompFilter.php index c21ede66b..832346eea 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CompFilter.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CompFilter.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Filter; use Sabre\CalDAV\Plugin; @@ -22,8 +24,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class CompFilter implements XmlDeserializable { - +class CompFilter implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -43,16 +45,17 @@ class CompFilter implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $result = [ - 'name' => null, + 'name' => null, 'is-not-defined' => false, - 'comp-filters' => [], - 'prop-filters' => [], - 'time-range' => false, + 'comp-filters' => [], + 'prop-filters' => [], + 'time-range' => false, ]; $att = $reader->parseAttributes(); @@ -60,38 +63,34 @@ class CompFilter implements XmlDeserializable { $elems = $reader->parseInnerTree(); - if (is_array($elems)) foreach ($elems as $elem) { - - switch ($elem['name']) { - - case '{' . Plugin::NS_CALDAV . '}comp-filter' : + if (is_array($elems)) { + foreach ($elems as $elem) { + switch ($elem['name']) { + case '{'.Plugin::NS_CALDAV.'}comp-filter': $result['comp-filters'][] = $elem['value']; break; - case '{' . Plugin::NS_CALDAV . '}prop-filter' : + case '{'.Plugin::NS_CALDAV.'}prop-filter': $result['prop-filters'][] = $elem['value']; break; - case '{' . Plugin::NS_CALDAV . '}is-not-defined' : + case '{'.Plugin::NS_CALDAV.'}is-not-defined': $result['is-not-defined'] = true; break; - case '{' . Plugin::NS_CALDAV . '}time-range' : - if ($result['name'] === 'VCALENDAR') { + case '{'.Plugin::NS_CALDAV.'}time-range': + if ('VCALENDAR' === $result['name']) { throw new BadRequest('You cannot add time-range filters on the VCALENDAR component'); } $result['time-range'] = [ 'start' => isset($elem['attributes']['start']) ? DateTimeParser::parseDateTime($elem['attributes']['start']) : null, - 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null, + 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null, ]; if ($result['time-range']['start'] && $result['time-range']['end'] && $result['time-range']['end'] <= $result['time-range']['start']) { throw new BadRequest('The end-date must be larger than the start-date'); } break; - } - + } } return $result; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/ParamFilter.php b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/ParamFilter.php index bf422cf05..ec9ff753c 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/ParamFilter.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/ParamFilter.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Filter; use Sabre\CalDAV\Plugin; @@ -20,8 +22,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class ParamFilter implements XmlDeserializable { - +class ParamFilter implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -41,14 +43,15 @@ class ParamFilter implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $result = [ - 'name' => null, + 'name' => null, 'is-not-defined' => false, - 'text-match' => null, + 'text-match' => null, ]; $att = $reader->parseAttributes(); @@ -56,27 +59,23 @@ class ParamFilter implements XmlDeserializable { $elems = $reader->parseInnerTree(); - if (is_array($elems)) foreach ($elems as $elem) { - - switch ($elem['name']) { - - case '{' . Plugin::NS_CALDAV . '}is-not-defined' : + if (is_array($elems)) { + foreach ($elems as $elem) { + switch ($elem['name']) { + case '{'.Plugin::NS_CALDAV.'}is-not-defined': $result['is-not-defined'] = true; break; - case '{' . Plugin::NS_CALDAV . '}text-match' : + case '{'.Plugin::NS_CALDAV.'}text-match': $result['text-match'] = [ - 'negate-condition' => isset($elem['attributes']['negate-condition']) && $elem['attributes']['negate-condition'] === 'yes', - 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;ascii-casemap', - 'value' => $elem['value'], + 'negate-condition' => isset($elem['attributes']['negate-condition']) && 'yes' === $elem['attributes']['negate-condition'], + 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;ascii-casemap', + 'value' => $elem['value'], ]; break; - } - + } } return $result; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php index db9207295..f4600574e 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Filter; use Sabre\CalDAV\Plugin; @@ -22,8 +24,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class PropFilter implements XmlDeserializable { - +class PropFilter implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -43,16 +45,17 @@ class PropFilter implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $result = [ - 'name' => null, + 'name' => null, 'is-not-defined' => false, - 'param-filters' => [], - 'text-match' => null, - 'time-range' => false, + 'param-filters' => [], + 'text-match' => null, + 'time-range' => false, ]; $att = $reader->parseAttributes(); @@ -60,39 +63,35 @@ class PropFilter implements XmlDeserializable { $elems = $reader->parseInnerTree(); - if (is_array($elems)) foreach ($elems as $elem) { - - switch ($elem['name']) { - - case '{' . Plugin::NS_CALDAV . '}param-filter' : + if (is_array($elems)) { + foreach ($elems as $elem) { + switch ($elem['name']) { + case '{'.Plugin::NS_CALDAV.'}param-filter': $result['param-filters'][] = $elem['value']; break; - case '{' . Plugin::NS_CALDAV . '}is-not-defined' : + case '{'.Plugin::NS_CALDAV.'}is-not-defined': $result['is-not-defined'] = true; break; - case '{' . Plugin::NS_CALDAV . '}time-range' : + case '{'.Plugin::NS_CALDAV.'}time-range': $result['time-range'] = [ 'start' => isset($elem['attributes']['start']) ? DateTimeParser::parseDateTime($elem['attributes']['start']) : null, - 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null, + 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null, ]; if ($result['time-range']['start'] && $result['time-range']['end'] && $result['time-range']['end'] <= $result['time-range']['start']) { throw new BadRequest('The end-date must be larger than the start-date'); } break; - case '{' . Plugin::NS_CALDAV . '}text-match' : + case '{'.Plugin::NS_CALDAV.'}text-match': $result['text-match'] = [ - 'negate-condition' => isset($elem['attributes']['negate-condition']) && $elem['attributes']['negate-condition'] === 'yes', - 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;ascii-casemap', - 'value' => $elem['value'], + 'negate-condition' => isset($elem['attributes']['negate-condition']) && 'yes' === $elem['attributes']['negate-condition'], + 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;ascii-casemap', + 'value' => $elem['value'], ]; break; - } - + } } return $result; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php index 92a9ac7b7..926656674 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Notification; use Sabre\CalDAV; @@ -17,19 +19,19 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Invite implements NotificationInterface { - +class Invite implements NotificationInterface +{ /** - * A unique id for the message + * A unique id for the message. * * @var string */ protected $id; /** - * Timestamp of the notification + * Timestamp of the notification. * - * @var DateTime + * @var \DateTime */ protected $dtStamp; @@ -63,7 +65,7 @@ class Invite implements NotificationInterface { protected $hostUrl; /** - * Url to the sharer of the calendar + * Url to the sharer of the calendar. * * @var string */ @@ -91,21 +93,21 @@ class Invite implements NotificationInterface { protected $lastName; /** - * A description of the share request + * A description of the share request. * * @var string */ protected $summary; /** - * The Etag for the notification + * The Etag for the notification. * * @var string */ protected $etag; /** - * The list of supported components + * The list of supported components. * * @var CalDAV\Xml\Property\SupportedCalendarComponentSet */ @@ -138,8 +140,8 @@ class Invite implements NotificationInterface { * * @param array $values All the options */ - function __construct(array $values) { - + public function __construct(array $values) + { $required = [ 'id', 'etag', @@ -152,17 +154,16 @@ class Invite implements NotificationInterface { ]; foreach ($required as $item) { if (!isset($values[$item])) { - throw new \InvalidArgumentException($item . ' is a required constructor option'); + throw new \InvalidArgumentException($item.' is a required constructor option'); } } foreach ($values as $key => $value) { if (!property_exists($this, $key)) { - throw new \InvalidArgumentException('Unknown option: ' . $key); + throw new \InvalidArgumentException('Unknown option: '.$key); } $this->$key = $value; } - } /** @@ -182,12 +183,10 @@ class Invite implements NotificationInterface { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - - $writer->writeElement('{' . CalDAV\Plugin::NS_CALENDARSERVER . '}invite-notification'); - + public function xmlSerialize(Writer $writer) + { + $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-notification'); } /** @@ -195,95 +194,90 @@ class Invite implements NotificationInterface { * response body. * * @param Writer $writer - * @return void */ - function xmlSerializeFull(Writer $writer) { + public function xmlSerializeFull(Writer $writer) + { + $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; - $cs = '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}'; + $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); + $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); - $this->dtStamp->setTimezone(new \DateTimezone('GMT')); - $writer->writeElement($cs . 'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); + $writer->startElement($cs.'invite-notification'); - $writer->startElement($cs . 'invite-notification'); - - $writer->writeElement($cs . 'uid', $this->id); + $writer->writeElement($cs.'uid', $this->id); $writer->writeElement('{DAV:}href', $this->href); switch ($this->type) { - - case DAV\Sharing\Plugin::INVITE_ACCEPTED : - $writer->writeElement($cs . 'invite-accepted'); + case DAV\Sharing\Plugin::INVITE_ACCEPTED: + $writer->writeElement($cs.'invite-accepted'); break; - case DAV\Sharing\Plugin::INVITE_NORESPONSE : - $writer->writeElement($cs . 'invite-noresponse'); + case DAV\Sharing\Plugin::INVITE_NORESPONSE: + $writer->writeElement($cs.'invite-noresponse'); break; - } - $writer->writeElement($cs . 'hosturl', [ - '{DAV:}href' => $writer->contextUri . $this->hostUrl + $writer->writeElement($cs.'hosturl', [ + '{DAV:}href' => $writer->contextUri.$this->hostUrl, ]); if ($this->summary) { - $writer->writeElement($cs . 'summary', $this->summary); + $writer->writeElement($cs.'summary', $this->summary); } - $writer->startElement($cs . 'access'); + $writer->startElement($cs.'access'); if ($this->readOnly) { - $writer->writeElement($cs . 'read'); + $writer->writeElement($cs.'read'); } else { - $writer->writeElement($cs . 'read-write'); + $writer->writeElement($cs.'read-write'); } $writer->endElement(); // access - $writer->startElement($cs . 'organizer'); + $writer->startElement($cs.'organizer'); // If the organizer contains a 'mailto:' part, it means it should be // treated as absolute. - if (strtolower(substr($this->organizer, 0, 7)) === 'mailto:') { + if ('mailto:' === strtolower(substr($this->organizer, 0, 7))) { $writer->writeElement('{DAV:}href', $this->organizer); } else { - $writer->writeElement('{DAV:}href', $writer->contextUri . $this->organizer); + $writer->writeElement('{DAV:}href', $writer->contextUri.$this->organizer); } if ($this->commonName) { - $writer->writeElement($cs . 'common-name', $this->commonName); + $writer->writeElement($cs.'common-name', $this->commonName); } if ($this->firstName) { - $writer->writeElement($cs . 'first-name', $this->firstName); + $writer->writeElement($cs.'first-name', $this->firstName); } if ($this->lastName) { - $writer->writeElement($cs . 'last-name', $this->lastName); + $writer->writeElement($cs.'last-name', $this->lastName); } $writer->endElement(); // organizer if ($this->commonName) { - $writer->writeElement($cs . 'organizer-cn', $this->commonName); + $writer->writeElement($cs.'organizer-cn', $this->commonName); } if ($this->firstName) { - $writer->writeElement($cs . 'organizer-first', $this->firstName); + $writer->writeElement($cs.'organizer-first', $this->firstName); } if ($this->lastName) { - $writer->writeElement($cs . 'organizer-last', $this->lastName); + $writer->writeElement($cs.'organizer-last', $this->lastName); } if ($this->supportedComponents) { - $writer->writeElement('{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set', $this->supportedComponents); + $writer->writeElement('{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set', $this->supportedComponents); } $writer->endElement(); // invite-notification - } /** - * Returns a unique id for this notification + * Returns a unique id for this notification. * * This is just the base url. This should generally be some kind of unique * id. * * @return string */ - function getId() { - + public function getId() + { return $this->id; - } /** @@ -293,10 +287,8 @@ class Invite implements NotificationInterface { * * @return string */ - function getETag() { - + public function getETag() + { return $this->etag; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php index f4b10a396..abcbde151 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Notification; use Sabre\CalDAV; @@ -14,19 +16,19 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InviteReply implements NotificationInterface { - +class InviteReply implements NotificationInterface +{ /** - * A unique id for the message + * A unique id for the message. * * @var string */ protected $id; /** - * Timestamp of the notification + * Timestamp of the notification. * - * @var DateTime + * @var \DateTime */ protected $dtStamp; @@ -59,14 +61,14 @@ class InviteReply implements NotificationInterface { protected $hostUrl; /** - * A description of the share request + * A description of the share request. * * @var string */ protected $summary; /** - * Notification Etag + * Notification Etag. * * @var string */ @@ -90,8 +92,8 @@ class InviteReply implements NotificationInterface { * * @param array $values */ - function __construct(array $values) { - + public function __construct(array $values) + { $required = [ 'id', 'etag', @@ -103,17 +105,16 @@ class InviteReply implements NotificationInterface { ]; foreach ($required as $item) { if (!isset($values[$item])) { - throw new \InvalidArgumentException($item . ' is a required constructor option'); + throw new \InvalidArgumentException($item.' is a required constructor option'); } } foreach ($values as $key => $value) { if (!property_exists($this, $key)) { - throw new \InvalidArgumentException('Unknown option: ' . $key); + throw new \InvalidArgumentException('Unknown option: '.$key); } $this->$key = $value; } - } /** @@ -133,12 +134,10 @@ class InviteReply implements NotificationInterface { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - - $writer->writeElement('{' . CalDAV\Plugin::NS_CALENDARSERVER . '}invite-reply'); - + public function xmlSerialize(Writer $writer) + { + $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-reply'); } /** @@ -146,55 +145,50 @@ class InviteReply implements NotificationInterface { * response body. * * @param Writer $writer - * @return void */ - function xmlSerializeFull(Writer $writer) { + public function xmlSerializeFull(Writer $writer) + { + $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; - $cs = '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}'; + $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); + $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); - $this->dtStamp->setTimezone(new \DateTimezone('GMT')); - $writer->writeElement($cs . 'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); + $writer->startElement($cs.'invite-reply'); - $writer->startElement($cs . 'invite-reply'); - - $writer->writeElement($cs . 'uid', $this->id); - $writer->writeElement($cs . 'in-reply-to', $this->inReplyTo); + $writer->writeElement($cs.'uid', $this->id); + $writer->writeElement($cs.'in-reply-to', $this->inReplyTo); $writer->writeElement('{DAV:}href', $this->href); switch ($this->type) { - - case DAV\Sharing\Plugin::INVITE_ACCEPTED : - $writer->writeElement($cs . 'invite-accepted'); + case DAV\Sharing\Plugin::INVITE_ACCEPTED: + $writer->writeElement($cs.'invite-accepted'); break; - case DAV\Sharing\Plugin::INVITE_DECLINED : - $writer->writeElement($cs . 'invite-declined'); + case DAV\Sharing\Plugin::INVITE_DECLINED: + $writer->writeElement($cs.'invite-declined'); break; - } - $writer->writeElement($cs . 'hosturl', [ - '{DAV:}href' => $writer->contextUri . $this->hostUrl + $writer->writeElement($cs.'hosturl', [ + '{DAV:}href' => $writer->contextUri.$this->hostUrl, ]); if ($this->summary) { - $writer->writeElement($cs . 'summary', $this->summary); + $writer->writeElement($cs.'summary', $this->summary); } $writer->endElement(); // invite-reply - } /** - * Returns a unique id for this notification + * Returns a unique id for this notification. * * This is just the base url. This should generally be some kind of unique * id. * * @return string */ - function getId() { - + public function getId() + { return $this->id; - } /** @@ -204,10 +198,8 @@ class InviteReply implements NotificationInterface { * * @return string */ - function getETag() { - + public function getETag() + { return $this->etag; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/NotificationInterface.php b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/NotificationInterface.php index b98f9c888..be7490533 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/NotificationInterface.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/NotificationInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Notification; use Sabre\Xml\Writer; @@ -12,26 +14,25 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface NotificationInterface extends XmlSerializable { - +interface NotificationInterface extends XmlSerializable +{ /** * This method serializes the entire notification, as it is used in the * response body. * * @param Writer $writer - * @return void */ - function xmlSerializeFull(Writer $writer); + public function xmlSerializeFull(Writer $writer); /** - * Returns a unique id for this notification + * Returns a unique id for this notification. * * This is just the base url. This should generally be some kind of unique * id. * * @return string */ - function getId(); + public function getId(); /** * Returns the ETag for this notification. @@ -40,6 +41,5 @@ interface NotificationInterface extends XmlSerializable { * * @return string */ - function getETag(); - + public function getETag(); } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/SystemStatus.php b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/SystemStatus.php index 8c945dd68..3c656df34 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/SystemStatus.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/SystemStatus.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Notification; use Sabre\CalDAV\Plugin; use Sabre\Xml\Writer; /** - * SystemStatus notification + * SystemStatus notification. * * This notification can be used to indicate to the user that the system is * down. @@ -15,14 +17,14 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SystemStatus implements NotificationInterface { - +class SystemStatus implements NotificationInterface +{ const TYPE_LOW = 1; const TYPE_MEDIUM = 2; const TYPE_HIGH = 3; /** - * A unique id + * A unique id. * * @var string */ @@ -50,7 +52,7 @@ class SystemStatus implements NotificationInterface { protected $href; /** - * Notification Etag + * Notification Etag. * * @var string */ @@ -64,18 +66,17 @@ class SystemStatus implements NotificationInterface { * * @param string $id * @param string $etag - * @param int $type + * @param int $type * @param string $description * @param string $href */ - function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) { - + public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) + { $this->id = $id; $this->type = $type; $this->description = $description; $this->href = $href; $this->etag = $etag; - } /** @@ -91,27 +92,25 @@ class SystemStatus implements NotificationInterface { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { switch ($this->type) { - case self::TYPE_LOW : + case self::TYPE_LOW: $type = 'low'; break; - case self::TYPE_MEDIUM : + case self::TYPE_MEDIUM: $type = 'medium'; break; - default : - case self::TYPE_HIGH : + default: + case self::TYPE_HIGH: $type = 'high'; break; } - $writer->startElement('{' . Plugin::NS_CALENDARSERVER . '}systemstatus'); + $writer->startElement('{'.Plugin::NS_CALENDARSERVER.'}systemstatus'); $writer->writeAttribute('type', $type); $writer->endElement(); - } /** @@ -119,51 +118,47 @@ class SystemStatus implements NotificationInterface { * response body. * * @param Writer $writer - * @return void */ - function xmlSerializeFull(Writer $writer) { - - $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; + public function xmlSerializeFull(Writer $writer) + { + $cs = '{'.Plugin::NS_CALENDARSERVER.'}'; switch ($this->type) { - case self::TYPE_LOW : + case self::TYPE_LOW: $type = 'low'; break; - case self::TYPE_MEDIUM : + case self::TYPE_MEDIUM: $type = 'medium'; break; - default : - case self::TYPE_HIGH : + default: + case self::TYPE_HIGH: $type = 'high'; break; } - $writer->startElement($cs . 'systemstatus'); + $writer->startElement($cs.'systemstatus'); $writer->writeAttribute('type', $type); - if ($this->description) { - $writer->writeElement($cs . 'description', $this->description); + $writer->writeElement($cs.'description', $this->description); } if ($this->href) { $writer->writeElement('{DAV:}href', $this->href); } $writer->endElement(); // systemstatus - } /** - * Returns a unique id for this notification + * Returns a unique id for this notification. * * This is just the base url. This should generally be some kind of unique * id. * * @return string */ - function getId() { - + public function getId() + { return $this->id; - } /* @@ -173,10 +168,8 @@ class SystemStatus implements NotificationInterface { * * @return string */ - function getETag() { - + public function getETag() + { return $this->etag; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php index 54e5a116a..224f52c96 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\CalDAV\Plugin; @@ -7,7 +9,7 @@ use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * AllowedSharingModes + * AllowedSharingModes. * * This property encodes the 'allowed-sharing-modes' property, as defined by * the 'caldav-sharing-02' spec, in the http://calendarserver.org/ns/ @@ -18,14 +20,15 @@ use Sabre\Xml\XmlSerializable; * such as VEVENT, VTODO * * @see https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-sharing-02.txt + * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class AllowedSharingModes implements XmlSerializable { - +class AllowedSharingModes implements XmlSerializable +{ /** - * Whether or not a calendar can be shared with another user + * Whether or not a calendar can be shared with another user. * * @var bool */ @@ -39,17 +42,15 @@ class AllowedSharingModes implements XmlSerializable { protected $canBePublished; /** - * Constructor + * Constructor. * * @param bool $canBeShared * @param bool $canBePublished - * @return void */ - function __construct($canBeShared, $canBePublished) { - + public function __construct($canBeShared, $canBePublished) + { $this->canBeShared = $canBeShared; $this->canBePublished = $canBePublished; - } /** @@ -69,19 +70,14 @@ class AllowedSharingModes 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) + { if ($this->canBeShared) { - $writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-shared'); + $writer->writeElement('{'.Plugin::NS_CALENDARSERVER.'}can-be-shared'); } if ($this->canBePublished) { - $writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-published'); + $writer->writeElement('{'.Plugin::NS_CALENDARSERVER.'}can-be-published'); } - } - - - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php index fc6f1d505..6b28d5df2 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * email-address-set property + * email-address-set property. * * This property represents the email-address-set property in the * http://calendarserver.org/ns/ namespace. @@ -17,35 +19,33 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class EmailAddressSet implements XmlSerializable { - +class EmailAddressSet implements XmlSerializable +{ /** - * emails + * emails. * * @var array */ private $emails; /** - * __construct + * __construct. * * @param array $emails */ - function __construct(array $emails) { - + public function __construct(array $emails) + { $this->emails = $emails; - } /** - * Returns the email addresses + * Returns the email addresses. * * @return array */ - function getValue() { - + public function getValue() + { return $this->emails; - } /** @@ -65,16 +65,11 @@ class EmailAddressSet 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) + { foreach ($this->emails as $email) { - $writer->writeElement('{http://calendarserver.org/ns/}email-address', $email); - } - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php index 4f33c464c..db456617c 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\CalDAV\Plugin; @@ -9,19 +11,20 @@ use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * Invite property + * Invite property. * * This property encodes the 'invite' property, as defined by * the 'caldav-sharing-02' spec, in the http://calendarserver.org/ns/ * namespace. * * @see https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-sharing-02.txt + * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Invite implements XmlSerializable { - +class Invite implements XmlSerializable +{ /** * The list of users a calendar has been shared to. * @@ -34,10 +37,9 @@ class Invite implements XmlSerializable { * * @param Sharee[] $sharees */ - function __construct(array $sharees) { - + public function __construct(array $sharees) + { $this->sharees = $sharees; - } /** @@ -45,10 +47,9 @@ class Invite implements XmlSerializable { * * @return array */ - function getValue() { - + public function getValue() + { return $this->sharees; - } /** @@ -68,61 +69,54 @@ class Invite implements XmlSerializable { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - - $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; + public function xmlSerialize(Writer $writer) + { + $cs = '{'.Plugin::NS_CALENDARSERVER.'}'; foreach ($this->sharees as $sharee) { - - if ($sharee->access === DAV\Sharing\Plugin::ACCESS_SHAREDOWNER) { - $writer->startElement($cs . 'organizer'); + if (DAV\Sharing\Plugin::ACCESS_SHAREDOWNER === $sharee->access) { + $writer->startElement($cs.'organizer'); } else { - $writer->startElement($cs . 'user'); + $writer->startElement($cs.'user'); switch ($sharee->inviteStatus) { - case DAV\Sharing\Plugin::INVITE_ACCEPTED : - $writer->writeElement($cs . 'invite-accepted'); + case DAV\Sharing\Plugin::INVITE_ACCEPTED: + $writer->writeElement($cs.'invite-accepted'); break; - case DAV\Sharing\Plugin::INVITE_DECLINED : - $writer->writeElement($cs . 'invite-declined'); + case DAV\Sharing\Plugin::INVITE_DECLINED: + $writer->writeElement($cs.'invite-declined'); break; - case DAV\Sharing\Plugin::INVITE_NORESPONSE : - $writer->writeElement($cs . 'invite-noresponse'); + case DAV\Sharing\Plugin::INVITE_NORESPONSE: + $writer->writeElement($cs.'invite-noresponse'); break; - case DAV\Sharing\Plugin::INVITE_INVALID : - $writer->writeElement($cs . 'invite-invalid'); + case DAV\Sharing\Plugin::INVITE_INVALID: + $writer->writeElement($cs.'invite-invalid'); break; } - $writer->startElement($cs . 'access'); + $writer->startElement($cs.'access'); switch ($sharee->access) { - case DAV\Sharing\Plugin::ACCESS_READWRITE : - $writer->writeElement($cs . 'read-write'); + case DAV\Sharing\Plugin::ACCESS_READWRITE: + $writer->writeElement($cs.'read-write'); break; - case DAV\Sharing\Plugin::ACCESS_READ : - $writer->writeElement($cs . 'read'); + case DAV\Sharing\Plugin::ACCESS_READ: + $writer->writeElement($cs.'read'); break; - } $writer->endElement(); // access - } $href = new DAV\Xml\Property\Href($sharee->href); $href->xmlSerialize($writer); if (isset($sharee->properties['{DAV:}displayname'])) { - $writer->writeElement($cs . 'common-name', $sharee->properties['{DAV:}displayname']); + $writer->writeElement($cs.'common-name', $sharee->properties['{DAV:}displayname']); } if ($sharee->comment) { - $writer->writeElement($cs . 'summary', $sharee->comment); + $writer->writeElement($cs.'summary', $sharee->comment); } $writer->endElement(); // organizer or user - } - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php index 10c20be55..780907169 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\CalDAV\Plugin; @@ -24,41 +26,39 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class ScheduleCalendarTransp implements Element { - +class ScheduleCalendarTransp implements Element +{ const TRANSPARENT = 'transparent'; const OPAQUE = 'opaque'; /** - * value + * value. * * @var string */ protected $value; /** - * Creates the property + * Creates the property. * * @param string $value */ - function __construct($value) { - - if ($value !== self::TRANSPARENT && $value !== self::OPAQUE) { + public function __construct($value) + { + if (self::TRANSPARENT !== $value && self::OPAQUE !== $value) { throw new \InvalidArgumentException('The value must either be specified as "transparent" or "opaque"'); } $this->value = $value; - } /** - * Returns the current value + * Returns the current value. * * @return string */ - function getValue() { - + public function getValue() + { return $this->value; - } /** @@ -78,19 +78,17 @@ class ScheduleCalendarTransp implements Element { * 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->value) { - case self::TRANSPARENT : - $writer->writeElement('{' . Plugin::NS_CALDAV . '}transparent'); + case self::TRANSPARENT: + $writer->writeElement('{'.Plugin::NS_CALDAV.'}transparent'); break; - case self::OPAQUE : - $writer->writeElement('{' . Plugin::NS_CALDAV . '}opaque'); + case self::OPAQUE: + $writer->writeElement('{'.Plugin::NS_CALDAV.'}opaque'); break; } - } /** @@ -112,10 +110,11 @@ class ScheduleCalendarTransp implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = Deserializer\enum($reader, Plugin::NS_CALDAV); if (in_array('transparent', $elems)) { @@ -123,8 +122,7 @@ class ScheduleCalendarTransp implements Element { } else { $value = self::OPAQUE; } - return new self($value); + return new self($value); } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php index 7fc25c5f0..56fa61b13 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\CalDAV\Plugin; @@ -21,8 +23,8 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedCalendarComponentSet implements Element { - +class SupportedCalendarComponentSet implements Element +{ /** * List of supported components. * @@ -37,21 +39,19 @@ class SupportedCalendarComponentSet implements Element { * * @param array $components */ - function __construct(array $components) { - + public function __construct(array $components) + { $this->components = $components; - } /** - * Returns the list of supported components + * Returns the list of supported components. * * @return array */ - function getValue() { - + public function getValue() + { return $this->components; - } /** @@ -71,18 +71,14 @@ class SupportedCalendarComponentSet implements Element { * 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->components as $component) { - - $writer->startElement('{' . Plugin::NS_CALDAV . '}comp'); + $writer->startElement('{'.Plugin::NS_CALDAV.'}comp'); $writer->writeAttributes(['name' => $component]); $writer->endElement(); - } - } /** @@ -104,16 +100,17 @@ class SupportedCalendarComponentSet implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree(); $components = []; - foreach ((array)$elems as $elem) { - if ($elem['name'] === '{' . Plugin::NS_CALDAV . '}comp') { + foreach ((array) $elems as $elem) { + if ($elem['name'] === '{'.Plugin::NS_CALDAV.'}comp') { $components[] = $elem['attributes']['name']; } } @@ -123,7 +120,5 @@ class SupportedCalendarComponentSet implements Element { } return new self($components); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarData.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarData.php index d123ba4c0..1c9c4779f 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarData.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarData.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\CalDAV\Plugin; @@ -7,7 +9,7 @@ use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * Supported-calendar-data property + * Supported-calendar-data property. * * This property is a representation of the supported-calendar-data property * in the CalDAV namespace. SabreDAV only has support for text/calendar;2.0 @@ -20,8 +22,8 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedCalendarData implements XmlSerializable { - +class SupportedCalendarData implements XmlSerializable +{ /** * The xmlSerialize method is called during xml writing. * @@ -39,22 +41,19 @@ class SupportedCalendarData implements XmlSerializable { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - - $writer->startElement('{' . Plugin::NS_CALDAV . '}calendar-data'); + public function xmlSerialize(Writer $writer) + { + $writer->startElement('{'.Plugin::NS_CALDAV.'}calendar-data'); $writer->writeAttributes([ 'content-type' => 'text/calendar', - 'version' => '2.0', + 'version' => '2.0', ]); $writer->endElement(); // calendar-data - $writer->startElement('{' . Plugin::NS_CALDAV . '}calendar-data'); + $writer->startElement('{'.Plugin::NS_CALDAV.'}calendar-data'); $writer->writeAttributes([ 'content-type' => 'application/calendar+json', ]); $writer->endElement(); // calendar-data - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCollationSet.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCollationSet.php index af10860d0..b88cd0d92 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCollationSet.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCollationSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Property; use Sabre\CalDAV\Plugin; @@ -7,7 +9,7 @@ use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * supported-collation-set property + * supported-collation-set property. * * This property is a representation of the supported-collation-set property * in the CalDAV namespace. @@ -19,8 +21,8 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedCollationSet implements XmlSerializable { - +class SupportedCollationSet implements XmlSerializable +{ /** * The xmlSerialize method is called during xml writing. * @@ -38,20 +40,17 @@ class SupportedCollationSet 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) + { $collations = [ 'i;ascii-casemap', 'i;octet', - 'i;unicode-casemap' + 'i;unicode-casemap', ]; foreach ($collations as $collation) { - $writer->writeElement('{' . Plugin::NS_CALDAV . '}supported-collation', $collation); + $writer->writeElement('{'.Plugin::NS_CALDAV.'}supported-collation', $collation); } - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php index 6d3c5d508..8231de6bd 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Request; use Sabre\CalDAV\Plugin; @@ -19,8 +21,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class CalendarMultiGetReport implements XmlDeserializable { - +class CalendarMultiGetReport implements XmlDeserializable +{ /** * An array with requested properties. * @@ -80,36 +82,33 @@ class CalendarMultiGetReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree([ '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', ]); $newProps = [ - 'hrefs' => [], + 'hrefs' => [], 'properties' => [], ]; foreach ($elems as $elem) { - switch ($elem['name']) { - - case '{DAV:}prop' : + case '{DAV:}prop': $newProps['properties'] = array_keys($elem['value']); - if (isset($elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data'])) { - $newProps += $elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data']; + if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) { + $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data']; } break; - case '{DAV:}href' : + case '{DAV:}href': $newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']); break; - } - } $obj = new self(); @@ -118,7 +117,5 @@ class CalendarMultiGetReport implements XmlDeserializable { } return $obj; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarQueryReport.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarQueryReport.php index e0b1c7950..e85eccd2d 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarQueryReport.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarQueryReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Request; use Sabre\CalDAV\Plugin; @@ -19,8 +21,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class CalendarQueryReport implements XmlDeserializable { - +class CalendarQueryReport implements XmlDeserializable +{ /** * An array with requested properties. * @@ -80,38 +82,39 @@ class CalendarQueryReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree([ - '{urn:ietf:params:xml:ns:caldav}comp-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\CompFilter', - '{urn:ietf:params:xml:ns:caldav}prop-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\PropFilter', - '{urn:ietf:params:xml:ns:caldav}param-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\ParamFilter', + '{urn:ietf:params:xml:ns:caldav}comp-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\CompFilter', + '{urn:ietf:params:xml:ns:caldav}prop-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\PropFilter', + '{urn:ietf:params:xml:ns:caldav}param-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\ParamFilter', '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', ]); $newProps = [ - 'filters' => null, + 'filters' => null, 'properties' => [], ]; - if (!is_array($elems)) $elems = []; + if (!is_array($elems)) { + $elems = []; + } foreach ($elems as $elem) { - switch ($elem['name']) { - - case '{DAV:}prop' : + case '{DAV:}prop': $newProps['properties'] = array_keys($elem['value']); - if (isset($elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data'])) { - $newProps += $elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data']; + if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) { + $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data']; } break; - case '{' . Plugin::NS_CALDAV . '}filter' : + case '{'.Plugin::NS_CALDAV.'}filter': foreach ($elem['value'] as $subElem) { - if ($subElem['name'] === '{' . Plugin::NS_CALDAV . '}comp-filter') { + if ($subElem['name'] === '{'.Plugin::NS_CALDAV.'}comp-filter') { if (!is_null($newProps['filters'])) { throw new BadRequest('Only one top-level comp-filter may be defined'); } @@ -119,21 +122,18 @@ class CalendarQueryReport implements XmlDeserializable { } } break; - } - } if (is_null($newProps['filters'])) { - throw new BadRequest('The {' . Plugin::NS_CALDAV . '}filter element is required for this request'); + throw new BadRequest('The {'.Plugin::NS_CALDAV.'}filter element is required for this request'); } $obj = new self(); foreach ($newProps as $key => $value) { $obj->$key = $value; } - return $obj; + return $obj; } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php index 0f6c1e074..a4d98a8d4 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Request; use Sabre\CalDAV\Plugin; @@ -9,7 +11,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\XmlDeserializable; /** - * FreeBusyQueryReport + * FreeBusyQueryReport. * * This class parses the {DAV:}free-busy-query REPORT, as defined in: * @@ -19,19 +21,19 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class FreeBusyQueryReport implements XmlDeserializable { - +class FreeBusyQueryReport implements XmlDeserializable +{ /** - * Starttime of report + * Starttime of report. * - * @var DateTime|null + * @var \DateTime|null */ public $start; /** - * End time of report + * End time of report. * - * @var DateTime|null + * @var \DateTime|null */ public $end; @@ -54,22 +56,23 @@ class FreeBusyQueryReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - - $timeRange = '{' . Plugin::NS_CALDAV . '}time-range'; + public static function xmlDeserialize(Reader $reader) + { + $timeRange = '{'.Plugin::NS_CALDAV.'}time-range'; $start = null; $end = null; - foreach ((array)$reader->parseInnerTree([]) as $elem) { - - if ($elem['name'] !== $timeRange) continue; + foreach ((array) $reader->parseInnerTree([]) as $elem) { + if ($elem['name'] !== $timeRange) { + continue; + } $start = empty($elem['attributes']['start']) ?: $elem['attributes']['start']; $end = empty($elem['attributes']['end']) ?: $elem['attributes']['end']; - } if (!$start && !$end) { throw new BadRequest('The freebusy report must have a time-range element'); @@ -85,7 +88,5 @@ class FreeBusyQueryReport implements XmlDeserializable { $result->end = $end; return $result; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php index db32cc6a5..710095bb2 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Request; use Sabre\CalDAV\Plugin; @@ -11,7 +13,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\XmlDeserializable; /** - * Invite-reply POST request parser + * Invite-reply POST request parser. * * This class parses the invite-reply POST request, as defined in: * @@ -21,8 +23,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InviteReply implements XmlDeserializable { - +class InviteReply implements XmlDeserializable +{ /** * The sharee calendar user address. * @@ -40,14 +42,14 @@ class InviteReply implements XmlDeserializable { public $calendarUri; /** - * The id of the invite message that's being responded to + * The id of the invite message that's being responded to. * * @var string */ public $inReplyTo; /** - * An optional message + * An optional message. * * @var string */ @@ -61,22 +63,21 @@ class InviteReply implements XmlDeserializable { public $status; /** - * Constructor + * Constructor. * * @param string $href * @param string $calendarUri * @param string $inReplyTo * @param string $summary - * @param int $status + * @param int $status */ - function __construct($href, $calendarUri, $inReplyTo, $summary, $status) { - + public function __construct($href, $calendarUri, $inReplyTo, $summary, $status) + { $this->href = $href; $this->calendarUri = $calendarUri; $this->inReplyTo = $inReplyTo; $this->summary = $summary; $this->status = $status; - } /** @@ -98,10 +99,11 @@ class InviteReply implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = KeyValue::xmlDeserialize($reader); $href = null; @@ -111,40 +113,35 @@ class InviteReply implements XmlDeserializable { $status = null; foreach ($elems as $name => $value) { - switch ($name) { - - case '{' . Plugin::NS_CALENDARSERVER . '}hosturl' : + case '{'.Plugin::NS_CALENDARSERVER.'}hosturl': foreach ($value as $bla) { - if ($bla['name'] === '{DAV:}href') { + if ('{DAV:}href' === $bla['name']) { $calendarUri = $bla['value']; } } break; - case '{' . Plugin::NS_CALENDARSERVER . '}invite-accepted' : + case '{'.Plugin::NS_CALENDARSERVER.'}invite-accepted': $status = DAV\Sharing\Plugin::INVITE_ACCEPTED; break; - case '{' . Plugin::NS_CALENDARSERVER . '}invite-declined' : + case '{'.Plugin::NS_CALENDARSERVER.'}invite-declined': $status = DAV\Sharing\Plugin::INVITE_DECLINED; break; - case '{' . Plugin::NS_CALENDARSERVER . '}in-reply-to' : + case '{'.Plugin::NS_CALENDARSERVER.'}in-reply-to': $inReplyTo = $value; break; - case '{' . Plugin::NS_CALENDARSERVER . '}summary' : + case '{'.Plugin::NS_CALENDARSERVER.'}summary': $summary = $value; break; - case '{DAV:}href' : + case '{DAV:}href': $href = $value; break; } - } if (is_null($calendarUri)) { throw new BadRequest('The {http://calendarserver.org/ns/}hosturl/{DAV:}href element must exist'); } return new self($href, $calendarUri, $inReplyTo, $summary, $status); - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/MkCalendar.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/MkCalendar.php index ce7fafde9..7cad98da5 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/MkCalendar.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/MkCalendar.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Request; use Sabre\Xml\Reader; @@ -16,8 +18,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MkCalendar implements XmlDeserializable { - +class MkCalendar implements XmlDeserializable +{ /** * The list of properties that will be set. * @@ -30,10 +32,9 @@ class MkCalendar implements XmlDeserializable { * * @return array */ - function getProperties() { - + public function getProperties() + { return $this->properties; - } /** @@ -55,10 +56,11 @@ class MkCalendar implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $elementMap = $reader->elementMap; @@ -67,13 +69,11 @@ class MkCalendar implements XmlDeserializable { $elems = $reader->parseInnerTree($elementMap); foreach ($elems as $elem) { - if ($elem['name'] === '{DAV:}set') { + if ('{DAV:}set' === $elem['name']) { $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); } } return $self; - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php index e0bd8e0af..60bd579d5 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Xml\Request; use Sabre\CalDAV\Plugin; @@ -8,7 +10,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\XmlDeserializable; /** - * Share POST request parser + * Share POST request parser. * * This class parses the share POST request, as defined in: * @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Share implements XmlDeserializable { - +class Share implements XmlDeserializable +{ /** * The list of new people added or updated or removed from the share. * @@ -28,14 +30,13 @@ class Share implements XmlDeserializable { public $sharees = []; /** - * Constructor + * Constructor. * * @param Sharee[] $sharees */ - function __construct(array $sharees) { - + public function __construct(array $sharees) + { $this->sharees = $sharees; - } /** @@ -57,55 +58,52 @@ class Share implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseGetElements([ - '{' . Plugin::NS_CALENDARSERVER . '}set' => 'Sabre\\Xml\\Element\\KeyValue', - '{' . Plugin::NS_CALENDARSERVER . '}remove' => 'Sabre\\Xml\\Element\\KeyValue', + '{'.Plugin::NS_CALENDARSERVER.'}set' => 'Sabre\\Xml\\Element\\KeyValue', + '{'.Plugin::NS_CALENDARSERVER.'}remove' => 'Sabre\\Xml\\Element\\KeyValue', ]); $sharees = []; foreach ($elems as $elem) { switch ($elem['name']) { - - case '{' . Plugin::NS_CALENDARSERVER . '}set' : + case '{'.Plugin::NS_CALENDARSERVER.'}set': $sharee = $elem['value']; - $sumElem = '{' . Plugin::NS_CALENDARSERVER . '}summary'; - $commonName = '{' . Plugin::NS_CALENDARSERVER . '}common-name'; + $sumElem = '{'.Plugin::NS_CALENDARSERVER.'}summary'; + $commonName = '{'.Plugin::NS_CALENDARSERVER.'}common-name'; $properties = []; if (isset($sharee[$commonName])) { $properties['{DAV:}displayname'] = $sharee[$commonName]; } - $access = array_key_exists('{' . Plugin::NS_CALENDARSERVER . '}read-write', $sharee) + $access = array_key_exists('{'.Plugin::NS_CALENDARSERVER.'}read-write', $sharee) ? \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE : \Sabre\DAV\Sharing\Plugin::ACCESS_READ; $sharees[] = new Sharee([ - 'href' => $sharee['{DAV:}href'], + 'href' => $sharee['{DAV:}href'], 'properties' => $properties, - 'access' => $access, - 'comment' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null + 'access' => $access, + 'comment' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null, ]); break; - case '{' . Plugin::NS_CALENDARSERVER . '}remove' : + case '{'.Plugin::NS_CALENDARSERVER.'}remove': $sharees[] = new Sharee([ - 'href' => $elem['value']['{DAV:}href'], - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS + 'href' => $elem['value']['{DAV:}href'], + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS, ]); break; - } } return new self($sharees); - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/AddressBook.php b/vendor/sabre/dav/lib/CardDAV/AddressBook.php index c9d28a091..434801554 100644 --- a/vendor/sabre/dav/lib/CardDAV/AddressBook.php +++ b/vendor/sabre/dav/lib/CardDAV/AddressBook.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; use Sabre\DAVACL; /** - * The AddressBook class represents a CardDAV addressbook, owned by a specific user + * The AddressBook class represents a CardDAV addressbook, owned by a specific user. * * The AddressBook can contain multiple vcards * @@ -14,77 +16,78 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AddressBook extends DAV\Collection implements IAddressBook, DAV\IProperties, DAVACL\IACL, DAV\Sync\ISyncCollection, DAV\IMultiGet { - +class AddressBook extends DAV\Collection implements IAddressBook, DAV\IProperties, DAVACL\IACL, DAV\Sync\ISyncCollection, DAV\IMultiGet +{ use DAVACL\ACLTrait; /** - * This is an array with addressbook information + * This is an array with addressbook information. * * @var array */ protected $addressBookInfo; /** - * CardDAV backend + * CardDAV backend. * * @var Backend\BackendInterface */ protected $carddavBackend; /** - * Constructor + * Constructor. * * @param Backend\BackendInterface $carddavBackend - * @param array $addressBookInfo + * @param array $addressBookInfo */ - function __construct(Backend\BackendInterface $carddavBackend, array $addressBookInfo) { - + public function __construct(Backend\BackendInterface $carddavBackend, array $addressBookInfo) + { $this->carddavBackend = $carddavBackend; $this->addressBookInfo = $addressBookInfo; - } /** - * Returns the name of the addressbook + * Returns the name of the addressbook. * * @return string */ - function getName() { - + public function getName() + { return $this->addressBookInfo['uri']; - } /** - * Returns a card + * Returns a card. * * @param string $name + * * @return Card */ - function getChild($name) { - + public function getChild($name) + { $obj = $this->carddavBackend->getCard($this->addressBookInfo['id'], $name); - if (!$obj) throw new DAV\Exception\NotFound('Card not found'); - return new Card($this->carddavBackend, $this->addressBookInfo, $obj); + if (!$obj) { + throw new DAV\Exception\NotFound('Card not found'); + } + return new Card($this->carddavBackend, $this->addressBookInfo, $obj); } /** - * Returns the full list of cards + * Returns the full list of cards. * * @return array */ - function getChildren() { - + public function getChildren() + { $objs = $this->carddavBackend->getCards($this->addressBookInfo['id']); $children = []; foreach ($objs as $obj) { $obj['acl'] = $this->getChildACL(); $children[] = new Card($this->carddavBackend, $this->addressBookInfo, $obj); } - return $children; + return $children; } /** @@ -94,47 +97,47 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * If any children are not found, you do not have to return them. * * @param string[] $paths + * * @return array */ - function getMultipleChildren(array $paths) { - + public function getMultipleChildren(array $paths) + { $objs = $this->carddavBackend->getMultipleCards($this->addressBookInfo['id'], $paths); $children = []; foreach ($objs as $obj) { $obj['acl'] = $this->getChildACL(); $children[] = new Card($this->carddavBackend, $this->addressBookInfo, $obj); } - return $children; + return $children; } /** - * Creates a new directory + * Creates a new directory. * * We actually block this, as subdirectories are not allowed in addressbooks. * * @param string $name - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { throw new DAV\Exception\MethodNotAllowed('Creating collections in addressbooks is not allowed'); - } /** - * Creates a new file + * Creates a new file. * * The contents of the new file must be a valid VCARD. * * This method may return an ETag. * - * @param string $name + * @param string $name * @param resource $vcardData + * * @return string|null */ - function createFile($name, $vcardData = null) { - + public function createFile($name, $vcardData = null) + { if (is_resource($vcardData)) { $vcardData = stream_get_contents($vcardData); } @@ -142,41 +145,32 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie $vcardData = DAV\StringUtil::ensureUTF8($vcardData); return $this->carddavBackend->createCard($this->addressBookInfo['id'], $name, $vcardData); - } /** * Deletes the entire addressbook. - * - * @return void */ - function delete() { - + public function delete() + { $this->carddavBackend->deleteAddressBook($this->addressBookInfo['id']); - } /** - * Renames the addressbook + * Renames the addressbook. * * @param string $newName - * @return void */ - function setName($newName) { - + public function setName($newName) + { throw new DAV\Exception\MethodNotAllowed('Renaming addressbooks is not yet supported'); - } /** * Returns the last modification date as a unix timestamp. - * - * @return void */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** @@ -189,12 +183,10 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * Read the PropPatch documentation for more information. * * @param DAV\PropPatch $propPatch - * @return void */ - function propPatch(DAV\PropPatch $propPatch) { - + public function propPatch(DAV\PropPatch $propPatch) + { return $this->carddavBackend->updateAddressBook($this->addressBookInfo['id'], $propPatch); - } /** @@ -206,39 +198,33 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * If the array is empty, it means 'all properties' were requested. * * @param array $properties + * * @return array */ - function getProperties($properties) { - + public function getProperties($properties) + { $response = []; foreach ($properties as $propertyName) { - if (isset($this->addressBookInfo[$propertyName])) { - $response[$propertyName] = $this->addressBookInfo[$propertyName]; - } - } return $response; - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->addressBookInfo['principaluri']; - } - /** * This method returns the ACL's for card nodes in this address book. * The result of this method automatically gets passed to the @@ -246,8 +232,8 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * * @return array */ - function getChildACL() { - + public function getChildACL() + { return [ [ 'privilege' => '{DAV:}all', @@ -255,10 +241,8 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie 'protected' => true, ], ]; - } - /** * This method returns the current sync-token for this collection. * This can be any string. @@ -268,8 +252,8 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * * @return string|null */ - function getSyncToken() { - + public function getSyncToken() + { if ( $this->carddavBackend instanceof Backend\SyncSupport && isset($this->addressBookInfo['{DAV:}sync-token']) @@ -282,7 +266,6 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie ) { return $this->addressBookInfo['{http://sabredav.org/ns}sync-token']; } - } /** @@ -336,12 +319,13 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * The limit is 'suggestive'. You are free to ignore it. * * @param string $syncToken - * @param int $syncLevel - * @param int $limit + * @param int $syncLevel + * @param int $limit + * * @return array */ - function getChanges($syncToken, $syncLevel, $limit = null) { - + public function getChanges($syncToken, $syncLevel, $limit = null) + { if (!$this->carddavBackend instanceof Backend\SyncSupport) { return null; } @@ -352,6 +336,5 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie $syncLevel, $limit ); - } } diff --git a/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php b/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php index d770c0ffe..fb03000aa 100644 --- a/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php +++ b/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; @@ -8,7 +10,7 @@ use Sabre\DAVACL; use Sabre\Uri; /** - * AddressBook Home class + * AddressBook Home class. * * This collection contains a list of addressbooks associated with one user. * @@ -16,81 +18,74 @@ use Sabre\Uri; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AddressBookHome extends DAV\Collection implements DAV\IExtendedCollection, DAVACL\IACL { - +class AddressBookHome extends DAV\Collection implements DAV\IExtendedCollection, DAVACL\IACL +{ use DAVACL\ACLTrait; /** - * Principal uri + * Principal uri. * * @var array */ protected $principalUri; /** - * carddavBackend + * carddavBackend. * * @var Backend\BackendInterface */ protected $carddavBackend; /** - * Constructor + * Constructor. * * @param Backend\BackendInterface $carddavBackend - * @param string $principalUri + * @param string $principalUri */ - function __construct(Backend\BackendInterface $carddavBackend, $principalUri) { - + public function __construct(Backend\BackendInterface $carddavBackend, $principalUri) + { $this->carddavBackend = $carddavBackend; $this->principalUri = $principalUri; - } /** - * Returns the name of this object + * Returns the name of this object. * * @return string */ - function getName() { - + public function getName() + { list(, $name) = Uri\split($this->principalUri); - return $name; + return $name; } /** - * Updates the name of this object + * Updates the name of this object. * * @param string $name - * @return void */ - function setName($name) { - + public function setName($name) + { throw new DAV\Exception\MethodNotAllowed(); - } /** - * Deletes this object - * - * @return void + * Deletes this object. */ - function delete() { - + public function delete() + { throw new DAV\Exception\MethodNotAllowed(); - } /** - * Returns the last modification date + * Returns the last modification date. * * @return int */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** @@ -98,14 +93,12 @@ class AddressBookHome extends DAV\Collection implements DAV\IExtendedCollection, * * This is currently not allowed * - * @param string $filename + * @param string $filename * @param resource $data - * @return void */ - function createFile($filename, $data = null) { - + public function createFile($filename, $data = null) + { throw new DAV\Exception\MethodNotAllowed('Creating new files in this collection is not supported'); - } /** @@ -114,78 +107,74 @@ class AddressBookHome extends DAV\Collection implements DAV\IExtendedCollection, * This is currently not allowed. * * @param string $filename - * @return void */ - function createDirectory($filename) { - + public function createDirectory($filename) + { throw new DAV\Exception\MethodNotAllowed('Creating new collections in this collection is not supported'); - } /** - * Returns a single addressbook, by name + * Returns a single addressbook, by name. * * @param string $name + * * @todo needs optimizing + * * @return AddressBook */ - function getChild($name) { - + public function getChild($name) + { foreach ($this->getChildren() as $child) { - if ($name == $child->getName()) + if ($name == $child->getName()) { return $child; - + } } - throw new DAV\Exception\NotFound('Addressbook with name \'' . $name . '\' could not be found'); - + throw new DAV\Exception\NotFound('Addressbook with name \''.$name.'\' could not be found'); } /** - * Returns a list of addressbooks + * Returns a list of addressbooks. * * @return array */ - function getChildren() { - + public function getChildren() + { $addressbooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri); $objs = []; foreach ($addressbooks as $addressbook) { $objs[] = new AddressBook($this->carddavBackend, $addressbook); } - return $objs; + return $objs; } /** * Creates a new address book. * * @param string $name - * @param MkCol $mkCol + * @param MkCol $mkCol + * * @throws DAV\Exception\InvalidResourceType - * @return void */ - function createExtendedCollection($name, MkCol $mkCol) { - - if (!$mkCol->hasResourceType('{' . Plugin::NS_CARDDAV . '}addressbook')) { + public function createExtendedCollection($name, MkCol $mkCol) + { + if (!$mkCol->hasResourceType('{'.Plugin::NS_CARDDAV.'}addressbook')) { throw new DAV\Exception\InvalidResourceType('Unknown resourceType for this collection'); } $properties = $mkCol->getRemainingValues(); $mkCol->setRemainingResultCode(201); $this->carddavBackend->createAddressBook($this->principalUri, $name, $properties); - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->principalUri; - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/AddressBookRoot.php b/vendor/sabre/dav/lib/CardDAV/AddressBookRoot.php index a9f1183da..219f98906 100644 --- a/vendor/sabre/dav/lib/CardDAV/AddressBookRoot.php +++ b/vendor/sabre/dav/lib/CardDAV/AddressBookRoot.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAVACL; /** - * AddressBook rootnode + * AddressBook rootnode. * * This object lists a collection of users, which can contain addressbooks. * @@ -13,24 +15,24 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AddressBookRoot extends DAVACL\AbstractPrincipalCollection { - +class AddressBookRoot extends DAVACL\AbstractPrincipalCollection +{ /** - * Principal Backend + * Principal Backend. * * @var DAVACL\PrincipalBackend\BackendInterface */ protected $principalBackend; /** - * CardDAV backend + * CardDAV backend. * * @var Backend\BackendInterface */ protected $carddavBackend; /** - * Constructor + * Constructor. * * This constructor needs both a principal and a carddav backend. * @@ -40,25 +42,23 @@ class AddressBookRoot extends DAVACL\AbstractPrincipalCollection { * to override this. * * @param DAVACL\PrincipalBackend\BackendInterface $principalBackend - * @param Backend\BackendInterface $carddavBackend - * @param string $principalPrefix + * @param Backend\BackendInterface $carddavBackend + * @param string $principalPrefix */ - function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $carddavBackend, $principalPrefix = 'principals') { - + public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $carddavBackend, $principalPrefix = 'principals') + { $this->carddavBackend = $carddavBackend; parent::__construct($principalBackend, $principalPrefix); - } /** - * Returns the name of the node + * Returns the name of the node. * * @return string */ - function getName() { - + public function getName() + { return Plugin::ADDRESSBOOK_ROOT; - } /** @@ -69,12 +69,11 @@ class AddressBookRoot extends DAVACL\AbstractPrincipalCollection { * supplied by the authentication backend. * * @param array $principal + * * @return \Sabre\DAV\INode */ - function getChildForPrincipal(array $principal) { - + public function getChildForPrincipal(array $principal) + { return new AddressBookHome($this->carddavBackend, $principal['uri']); - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/Backend/AbstractBackend.php b/vendor/sabre/dav/lib/CardDAV/Backend/AbstractBackend.php index 03d2346da..6b041ade4 100644 --- a/vendor/sabre/dav/lib/CardDAV/Backend/AbstractBackend.php +++ b/vendor/sabre/dav/lib/CardDAV/Backend/AbstractBackend.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV\Backend; /** - * CardDAV abstract Backend + * CardDAV abstract Backend. * * This class serves as a base-class for addressbook backends * @@ -13,8 +15,8 @@ namespace Sabre\CardDAV\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface { - +abstract class AbstractBackend implements BackendInterface +{ /** * Returns a list of cards. * @@ -25,14 +27,13 @@ abstract class AbstractBackend implements BackendInterface { * * @param mixed $addressBookId * @param array $uris + * * @return array */ - function getMultipleCards($addressBookId, array $uris) { - - return array_map(function($uri) use ($addressBookId) { + public function getMultipleCards($addressBookId, array $uris) + { + return array_map(function ($uri) use ($addressBookId) { return $this->getCard($addressBookId, $uri); }, $uris); - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php b/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php index 18c0c0a99..804f09a36 100644 --- a/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV\Backend; /** - * CardDAV Backend Interface + * CardDAV Backend Interface. * * Any CardDAV backend must implement this interface. * @@ -15,8 +17,8 @@ namespace Sabre\CardDAV\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * Returns the list of addressbooks for a specific user. * @@ -32,9 +34,10 @@ interface BackendInterface { * {http://calendarserver.org/ns/}getctag * * @param string $principalUri + * * @return array */ - function getAddressBooksForUser($principalUri); + public function getAddressBooksForUser($principalUri); /** * Updates properties for an address book. @@ -48,11 +51,10 @@ interface BackendInterface { * * Read the PropPatch documentation for more info and examples. * - * @param string $addressBookId + * @param string $addressBookId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch); + public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch); /** * Creates a new address book. @@ -61,19 +63,19 @@ interface BackendInterface { * in any format, including ints, strings, arrays or objects. * * @param string $principalUri - * @param string $url Just the 'basename' of the url. - * @param array $properties + * @param string $url just the 'basename' of the url + * @param array $properties + * * @return mixed */ - function createAddressBook($principalUri, $url, array $properties); + public function createAddressBook($principalUri, $url, array $properties); /** - * Deletes an entire addressbook and all its contents + * Deletes an entire addressbook and all its contents. * * @param mixed $addressBookId - * @return void */ - function deleteAddressBook($addressBookId); + public function deleteAddressBook($addressBookId); /** * Returns all cards for a specific addressbook id. @@ -92,9 +94,10 @@ interface BackendInterface { * This may speed up certain requests, especially with large cards. * * @param mixed $addressbookId + * * @return array */ - function getCards($addressbookId); + public function getCards($addressbookId); /** * Returns a specfic card. @@ -104,11 +107,12 @@ interface BackendInterface { * * If the card does not exist, you must return false. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri + * * @return array */ - function getCard($addressBookId, $cardUri); + public function getCard($addressBookId, $cardUri); /** * Returns a list of cards. @@ -120,9 +124,10 @@ interface BackendInterface { * * @param mixed $addressBookId * @param array $uris + * * @return array */ - function getMultipleCards($addressBookId, array $uris); + public function getMultipleCards($addressBookId, array $uris); /** * Creates a new card. @@ -144,12 +149,13 @@ interface BackendInterface { * * If you don't return an ETag, you can just return null. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri * @param string $cardData + * * @return string|null */ - function createCard($addressBookId, $cardUri, $cardData); + public function createCard($addressBookId, $cardUri, $cardData); /** * Updates a card. @@ -171,20 +177,21 @@ interface BackendInterface { * * If you don't return an ETag, you can just return null. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri * @param string $cardData + * * @return string|null */ - function updateCard($addressBookId, $cardUri, $cardData); + public function updateCard($addressBookId, $cardUri, $cardData); /** - * Deletes a card + * Deletes a card. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri + * * @return bool */ - function deleteCard($addressBookId, $cardUri); - + public function deleteCard($addressBookId, $cardUri); } diff --git a/vendor/sabre/dav/lib/CardDAV/Backend/PDO.php b/vendor/sabre/dav/lib/CardDAV/Backend/PDO.php index 13487e9da..0659455e5 100644 --- a/vendor/sabre/dav/lib/CardDAV/Backend/PDO.php +++ b/vendor/sabre/dav/lib/CardDAV/Backend/PDO.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV\Backend; use Sabre\CardDAV; use Sabre\DAV; /** - * PDO CardDAV backend + * PDO CardDAV backend. * * This CardDAV backend uses PDO to store addressbooks * @@ -14,22 +16,22 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend implements SyncSupport { - +class PDO extends AbstractBackend implements SyncSupport +{ /** - * PDO connection + * PDO connection. * * @var PDO */ protected $pdo; /** - * The PDO table name used to store addressbooks + * The PDO table name used to store addressbooks. */ public $addressBooksTableName = 'addressbooks'; /** - * The PDO table name used to store cards + * The PDO table name used to store cards. */ public $cardsTableName = 'cards'; @@ -41,48 +43,44 @@ class PDO extends AbstractBackend implements SyncSupport { public $addressBookChangesTableName = 'addressbookchanges'; /** - * Sets up the object + * Sets up the object. * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** * Returns the list of addressbooks for a specific user. * * @param string $principalUri + * * @return array */ - function getAddressBooksForUser($principalUri) { - - $stmt = $this->pdo->prepare('SELECT id, uri, displayname, principaluri, description, synctoken FROM ' . $this->addressBooksTableName . ' WHERE principaluri = ?'); + public function getAddressBooksForUser($principalUri) + { + $stmt = $this->pdo->prepare('SELECT id, uri, displayname, principaluri, description, synctoken FROM '.$this->addressBooksTableName.' WHERE principaluri = ?'); $stmt->execute([$principalUri]); $addressBooks = []; foreach ($stmt->fetchAll() as $row) { - $addressBooks[] = [ - 'id' => $row['id'], - 'uri' => $row['uri'], - 'principaluri' => $row['principaluri'], - '{DAV:}displayname' => $row['displayname'], - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], - '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], - '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', + 'id' => $row['id'], + 'uri' => $row['uri'], + 'principaluri' => $row['principaluri'], + '{DAV:}displayname' => $row['displayname'], + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], + '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', ]; - } return $addressBooks; - } - /** * Updates properties for an address book. * @@ -95,32 +93,29 @@ class PDO extends AbstractBackend implements SyncSupport { * * Read the PropPatch documentation for more info and examples. * - * @param string $addressBookId + * @param string $addressBookId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) { - + public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) + { $supportedProperties = [ '{DAV:}displayname', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description', ]; - $propPatch->handle($supportedProperties, function($mutations) use ($addressBookId) { - + $propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) { $updates = []; foreach ($mutations as $property => $newValue) { - switch ($property) { - case '{DAV:}displayname' : + case '{DAV:}displayname': $updates['displayname'] = $newValue; break; - case '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' : + case '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description': $updates['description'] = $newValue; break; } } - $query = 'UPDATE ' . $this->addressBooksTableName . ' SET '; + $query = 'UPDATE '.$this->addressBooksTableName.' SET '; $first = true; foreach ($updates as $key => $value) { if ($first) { @@ -128,7 +123,7 @@ class PDO extends AbstractBackend implements SyncSupport { } else { $query .= ', '; } - $query .= ' ' . $key . ' = :' . $key . ' '; + $query .= ' '.$key.' = :'.$key.' '; } $query .= ' WHERE id = :addressbookid'; @@ -137,72 +132,67 @@ class PDO extends AbstractBackend implements SyncSupport { $stmt->execute($updates); - $this->addChange($addressBookId, "", 2); + $this->addChange($addressBookId, '', 2); return true; - }); - } /** - * Creates a new address book + * Creates a new address book. * * @param string $principalUri - * @param string $url Just the 'basename' of the url. - * @param array $properties + * @param string $url just the 'basename' of the url + * @param array $properties + * * @return int Last insert id */ - function createAddressBook($principalUri, $url, array $properties) { - + public function createAddressBook($principalUri, $url, array $properties) + { $values = [ - 'displayname' => null, - 'description' => null, + 'displayname' => null, + 'description' => null, 'principaluri' => $principalUri, - 'uri' => $url, + 'uri' => $url, ]; foreach ($properties as $property => $newValue) { - switch ($property) { - case '{DAV:}displayname' : + case '{DAV:}displayname': $values['displayname'] = $newValue; break; - case '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' : + case '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description': $values['description'] = $newValue; break; - default : - throw new DAV\Exception\BadRequest('Unknown property: ' . $property); + default: + throw new DAV\Exception\BadRequest('Unknown property: '.$property); } - } - $query = 'INSERT INTO ' . $this->addressBooksTableName . ' (uri, displayname, description, principaluri, synctoken) VALUES (:uri, :displayname, :description, :principaluri, 1)'; + $query = 'INSERT INTO '.$this->addressBooksTableName.' (uri, displayname, description, principaluri, synctoken) VALUES (:uri, :displayname, :description, :principaluri, 1)'; $stmt = $this->pdo->prepare($query); $stmt->execute($values); + return $this->pdo->lastInsertId( - $this->addressBooksTableName . '_id_seq' + $this->addressBooksTableName.'_id_seq' ); - } /** - * Deletes an entire addressbook and all its contents + * Deletes an entire addressbook and all its contents. * * @param int $addressBookId - * @return void */ - function deleteAddressBook($addressBookId) { - - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->cardsTableName . ' WHERE addressbookid = ?'); + public function deleteAddressBook($addressBookId) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->cardsTableName.' WHERE addressbookid = ?'); $stmt->execute([$addressBookId]); - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->addressBooksTableName . ' WHERE id = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->addressBooksTableName.' WHERE id = ?'); $stmt->execute([$addressBookId]); - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->addressBookChangesTableName . ' WHERE addressbookid = ?'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->addressBookChangesTableName.' WHERE addressbookid = ?'); $stmt->execute([$addressBookId]); - } /** @@ -222,21 +212,22 @@ class PDO extends AbstractBackend implements SyncSupport { * This may speed up certain requests, especially with large cards. * * @param mixed $addressbookId + * * @return array */ - function getCards($addressbookId) { - - $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, size FROM ' . $this->cardsTableName . ' WHERE addressbookid = ?'); + public function getCards($addressbookId) + { + $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, size FROM '.$this->cardsTableName.' WHERE addressbookid = ?'); $stmt->execute([$addressbookId]); $result = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $row['etag'] = '"' . $row['etag'] . '"'; - $row['lastmodified'] = (int)$row['lastmodified']; + $row['etag'] = '"'.$row['etag'].'"'; + $row['lastmodified'] = (int) $row['lastmodified']; $result[] = $row; } - return $result; + return $result; } /** @@ -247,23 +238,26 @@ class PDO extends AbstractBackend implements SyncSupport { * * If the card does not exist, you must return false. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri + * * @return array */ - function getCard($addressBookId, $cardUri) { - - $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified, etag, size FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND uri = ? LIMIT 1'); + public function getCard($addressBookId, $cardUri) + { + $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified, etag, size FROM '.$this->cardsTableName.' WHERE addressbookid = ? AND uri = ? LIMIT 1'); $stmt->execute([$addressBookId, $cardUri]); $result = $stmt->fetch(\PDO::FETCH_ASSOC); - if (!$result) return false; + if (!$result) { + return false; + } + + $result['etag'] = '"'.$result['etag'].'"'; + $result['lastmodified'] = (int) $result['lastmodified']; - $result['etag'] = '"' . $result['etag'] . '"'; - $result['lastmodified'] = (int)$result['lastmodified']; return $result; - } /** @@ -276,11 +270,12 @@ class PDO extends AbstractBackend implements SyncSupport { * * @param mixed $addressBookId * @param array $uris + * * @return array */ - function getMultipleCards($addressBookId, array $uris) { - - $query = 'SELECT id, uri, lastmodified, etag, size, carddata FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND uri IN ('; + public function getMultipleCards($addressBookId, array $uris) + { + $query = 'SELECT id, uri, lastmodified, etag, size, carddata FROM '.$this->cardsTableName.' WHERE addressbookid = ? AND uri IN ('; // Inserting a whole bunch of question marks $query .= implode(',', array_fill(0, count($uris), '?')); $query .= ')'; @@ -289,12 +284,12 @@ class PDO extends AbstractBackend implements SyncSupport { $stmt->execute(array_merge([$addressBookId], $uris)); $result = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $row['etag'] = '"' . $row['etag'] . '"'; - $row['lastmodified'] = (int)$row['lastmodified']; + $row['etag'] = '"'.$row['etag'].'"'; + $row['lastmodified'] = (int) $row['lastmodified']; $result[] = $row; } - return $result; + return $result; } /** @@ -317,14 +312,15 @@ class PDO extends AbstractBackend implements SyncSupport { * * If you don't return an ETag, you can just return null. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri * @param string $cardData + * * @return string|null */ - function createCard($addressBookId, $cardUri, $cardData) { - - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->cardsTableName . ' (carddata, uri, lastmodified, addressbookid, size, etag) VALUES (?, ?, ?, ?, ?, ?)'); + public function createCard($addressBookId, $cardUri, $cardData) + { + $stmt = $this->pdo->prepare('INSERT INTO '.$this->cardsTableName.' (carddata, uri, lastmodified, addressbookid, size, etag) VALUES (?, ?, ?, ?, ?, ?)'); $etag = md5($cardData); @@ -339,8 +335,7 @@ class PDO extends AbstractBackend implements SyncSupport { $this->addChange($addressBookId, $cardUri, 1); - return '"' . $etag . '"'; - + return '"'.$etag.'"'; } /** @@ -363,14 +358,15 @@ class PDO extends AbstractBackend implements SyncSupport { * * If you don't return an ETag, you can just return null. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri * @param string $cardData + * * @return string|null */ - function updateCard($addressBookId, $cardUri, $cardData) { - - $stmt = $this->pdo->prepare('UPDATE ' . $this->cardsTableName . ' SET carddata = ?, lastmodified = ?, size = ?, etag = ? WHERE uri = ? AND addressbookid =?'); + public function updateCard($addressBookId, $cardUri, $cardData) + { + $stmt = $this->pdo->prepare('UPDATE '.$this->cardsTableName.' SET carddata = ?, lastmodified = ?, size = ?, etag = ? WHERE uri = ? AND addressbookid =?'); $etag = md5($cardData); $stmt->execute([ @@ -379,31 +375,30 @@ class PDO extends AbstractBackend implements SyncSupport { strlen($cardData), $etag, $cardUri, - $addressBookId + $addressBookId, ]); $this->addChange($addressBookId, $cardUri, 2); - return '"' . $etag . '"'; - + return '"'.$etag.'"'; } /** - * Deletes a card + * Deletes a card. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri + * * @return bool */ - function deleteCard($addressBookId, $cardUri) { - - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND uri = ?'); + public function deleteCard($addressBookId, $cardUri) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->cardsTableName.' WHERE addressbookid = ? AND uri = ?'); $stmt->execute([$addressBookId, $cardUri]); $this->addChange($addressBookId, $cardUri, 3); - return $stmt->rowCount() === 1; - + return 1 === $stmt->rowCount(); } /** @@ -458,30 +453,34 @@ class PDO extends AbstractBackend implements SyncSupport { * * @param string $addressBookId * @param string $syncToken - * @param int $syncLevel - * @param int $limit + * @param int $syncLevel + * @param int $limit + * * @return array */ - function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) { - + public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) + { // Current synctoken - $stmt = $this->pdo->prepare('SELECT synctoken FROM ' . $this->addressBooksTableName . ' WHERE id = ?'); + $stmt = $this->pdo->prepare('SELECT synctoken FROM '.$this->addressBooksTableName.' WHERE id = ?'); $stmt->execute([$addressBookId]); $currentToken = $stmt->fetchColumn(0); - if (is_null($currentToken)) return null; + if (is_null($currentToken)) { + return null; + } $result = [ 'syncToken' => $currentToken, - 'added' => [], - 'modified' => [], - 'deleted' => [], + 'added' => [], + 'modified' => [], + 'deleted' => [], ]; if ($syncToken) { - - $query = "SELECT uri, operation FROM " . $this->addressBookChangesTableName . " WHERE synctoken >= ? AND synctoken < ? AND addressbookid = ? ORDER BY synctoken"; - if ($limit > 0) $query .= " LIMIT " . (int)$limit; + $query = 'SELECT uri, operation FROM '.$this->addressBookChangesTableName.' WHERE synctoken >= ? AND synctoken < ? AND addressbookid = ? ORDER BY synctoken'; + if ($limit > 0) { + $query .= ' LIMIT '.(int) $limit; + } // Fetching all changes $stmt = $this->pdo->prepare($query); @@ -492,13 +491,10 @@ class PDO extends AbstractBackend implements SyncSupport { // This loop ensures that any duplicates are overwritten, only the // last change on a node is relevant. while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $changes[$row['uri']] = $row['operation']; - } foreach ($changes as $uri => $operation) { - switch ($operation) { case 1: $result['added'][] = $uri; @@ -510,41 +506,38 @@ class PDO extends AbstractBackend implements SyncSupport { $result['deleted'][] = $uri; break; } - } } else { // No synctoken supplied, this is the initial sync. - $query = "SELECT uri FROM " . $this->cardsTableName . " WHERE addressbookid = ?"; + $query = 'SELECT uri FROM '.$this->cardsTableName.' WHERE addressbookid = ?'; $stmt = $this->pdo->prepare($query); $stmt->execute([$addressBookId]); $result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN); } - return $result; + return $result; } /** * Adds a change record to the addressbookchanges table. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $objectUri - * @param int $operation 1 = add, 2 = modify, 3 = delete - * @return void + * @param int $operation 1 = add, 2 = modify, 3 = delete */ - protected function addChange($addressBookId, $objectUri, $operation) { - - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->addressBookChangesTableName . ' (uri, synctoken, addressbookid, operation) SELECT ?, synctoken, ?, ? FROM ' . $this->addressBooksTableName . ' WHERE id = ?'); + protected function addChange($addressBookId, $objectUri, $operation) + { + $stmt = $this->pdo->prepare('INSERT INTO '.$this->addressBookChangesTableName.' (uri, synctoken, addressbookid, operation) SELECT ?, synctoken, ?, ? FROM '.$this->addressBooksTableName.' WHERE id = ?'); $stmt->execute([ $objectUri, $addressBookId, $operation, - $addressBookId + $addressBookId, ]); - $stmt = $this->pdo->prepare('UPDATE ' . $this->addressBooksTableName . ' SET synctoken = synctoken + 1 WHERE id = ?'); + $stmt = $this->pdo->prepare('UPDATE '.$this->addressBooksTableName.' SET synctoken = synctoken + 1 WHERE id = ?'); $stmt->execute([ - $addressBookId + $addressBookId, ]); - } } diff --git a/vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php b/vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php index f80618a8e..071361ed0 100644 --- a/vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php +++ b/vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV\Backend; /** @@ -18,8 +20,8 @@ namespace Sabre\CardDAV\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface SyncSupport extends BackendInterface { - +interface SyncSupport extends BackendInterface +{ /** * The getChanges method returns all the changes that have happened, since * the specified syncToken in the specified address book. @@ -72,10 +74,10 @@ interface SyncSupport extends BackendInterface { * * @param string $addressBookId * @param string $syncToken - * @param int $syncLevel - * @param int $limit + * @param int $syncLevel + * @param int $limit + * * @return array */ - function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null); - + public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null); } diff --git a/vendor/sabre/dav/lib/CardDAV/Card.php b/vendor/sabre/dav/lib/CardDAV/Card.php index 42a2d7b6a..1d544f4aa 100644 --- a/vendor/sabre/dav/lib/CardDAV/Card.php +++ b/vendor/sabre/dav/lib/CardDAV/Card.php @@ -1,94 +1,96 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; use Sabre\DAVACL; /** - * The Card object represents a single Card from an addressbook + * The Card object represents a single Card from an addressbook. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Card extends DAV\File implements ICard, DAVACL\IACL { - +class Card extends DAV\File implements ICard, DAVACL\IACL +{ use DAVACL\ACLTrait; /** - * CardDAV backend + * CardDAV backend. * * @var Backend\BackendInterface */ protected $carddavBackend; /** - * Array with information about this Card + * Array with information about this Card. * * @var array */ protected $cardData; /** - * Array with information about the containing addressbook + * Array with information about the containing addressbook. * * @var array */ protected $addressBookInfo; /** - * Constructor + * Constructor. * * @param Backend\BackendInterface $carddavBackend - * @param array $addressBookInfo - * @param array $cardData + * @param array $addressBookInfo + * @param array $cardData */ - function __construct(Backend\BackendInterface $carddavBackend, array $addressBookInfo, array $cardData) { - + public function __construct(Backend\BackendInterface $carddavBackend, array $addressBookInfo, array $cardData) + { $this->carddavBackend = $carddavBackend; $this->addressBookInfo = $addressBookInfo; $this->cardData = $cardData; - } /** - * Returns the uri for this object + * Returns the uri for this object. * * @return string */ - function getName() { - + public function getName() + { return $this->cardData['uri']; - } /** - * Returns the VCard-formatted object + * Returns the VCard-formatted object. * * @return string */ - function get() { - + public function get() + { // Pre-populating 'carddata' is optional. If we don't yet have it // already, we fetch it from the backend. if (!isset($this->cardData['carddata'])) { $this->cardData = $this->carddavBackend->getCard($this->addressBookInfo['id'], $this->cardData['uri']); } - return $this->cardData['carddata']; + return $this->cardData['carddata']; } /** - * Updates the VCard-formatted object + * Updates the VCard-formatted object. * * @param string $cardData + * * @return string|null */ - function put($cardData) { - - if (is_resource($cardData)) + public function put($cardData) + { + if (is_resource($cardData)) { $cardData = stream_get_contents($cardData); + } // Converting to UTF-8, if needed $cardData = DAV\StringUtil::ensureUTF8($cardData); @@ -98,92 +100,82 @@ class Card extends DAV\File implements ICard, DAVACL\IACL { $this->cardData['etag'] = $etag; return $etag; - } /** - * Deletes the card - * - * @return void + * Deletes the card. */ - function delete() { - + public function delete() + { $this->carddavBackend->deleteCard($this->addressBookInfo['id'], $this->cardData['uri']); - } /** - * Returns the mime content-type + * Returns the mime content-type. * * @return string */ - function getContentType() { - + public function getContentType() + { return 'text/vcard; charset=utf-8'; - } /** - * Returns an ETag for this object + * Returns an ETag for this object. * * @return string */ - function getETag() { - + public function getETag() + { if (isset($this->cardData['etag'])) { return $this->cardData['etag']; } else { $data = $this->get(); if (is_string($data)) { - return '"' . md5($data) . '"'; + return '"'.md5($data).'"'; } else { // We refuse to calculate the md5 if it's a stream. return null; } } - } /** - * Returns the last modification date as a unix timestamp + * Returns the last modification date as a unix timestamp. * * @return int */ - function getLastModified() { - + public function getLastModified() + { return isset($this->cardData['lastmodified']) ? $this->cardData['lastmodified'] : null; - } /** - * Returns the size of this object in bytes + * Returns the size of this object in bytes. * * @return int */ - function getSize() { - + public function getSize() + { if (array_key_exists('size', $this->cardData)) { return $this->cardData['size']; } else { return strlen($this->get()); } - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->addressBookInfo['principaluri']; - } - /** * Returns a list of ACE's for this node. * @@ -196,8 +188,8 @@ class Card extends DAV\File implements ICard, DAVACL\IACL { * * @return array */ - function getACL() { - + public function getACL() + { // An alternative acl may be specified through the cardData array. if (isset($this->cardData['acl'])) { return $this->cardData['acl']; @@ -210,7 +202,5 @@ class Card extends DAV\File implements ICard, DAVACL\IACL { 'protected' => true, ], ]; - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/IAddressBook.php b/vendor/sabre/dav/lib/CardDAV/IAddressBook.php index f80e05575..3f489f4e5 100644 --- a/vendor/sabre/dav/lib/CardDAV/IAddressBook.php +++ b/vendor/sabre/dav/lib/CardDAV/IAddressBook.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; /** - * AddressBook interface + * AddressBook interface. * * Implement this interface to allow a node to be recognized as an addressbook. * @@ -13,6 +15,6 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IAddressBook extends DAV\ICollection { - +interface IAddressBook extends DAV\ICollection +{ } diff --git a/vendor/sabre/dav/lib/CardDAV/ICard.php b/vendor/sabre/dav/lib/CardDAV/ICard.php index a974cbd8f..30e9d415e 100644 --- a/vendor/sabre/dav/lib/CardDAV/ICard.php +++ b/vendor/sabre/dav/lib/CardDAV/ICard.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; /** - * Card interface + * Card interface. * * Extend the ICard interface to allow your custom nodes to be picked up as * 'Cards'. @@ -14,6 +16,6 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ICard extends DAV\IFile { - +interface ICard extends DAV\IFile +{ } diff --git a/vendor/sabre/dav/lib/CardDAV/IDirectory.php b/vendor/sabre/dav/lib/CardDAV/IDirectory.php index d991a1cc8..05e6bef32 100644 --- a/vendor/sabre/dav/lib/CardDAV/IDirectory.php +++ b/vendor/sabre/dav/lib/CardDAV/IDirectory.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; /** - * IDirectory interface + * IDirectory interface. * * Implement this interface to have an addressbook marked as a 'directory'. A * directory is an (often) global addressbook. @@ -15,6 +17,6 @@ namespace Sabre\CardDAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IDirectory extends IAddressBook { - +interface IDirectory extends IAddressBook +{ } diff --git a/vendor/sabre/dav/lib/CardDAV/Plugin.php b/vendor/sabre/dav/lib/CardDAV/Plugin.php index 272ae71fa..10398a4d2 100644 --- a/vendor/sabre/dav/lib/CardDAV/Plugin.php +++ b/vendor/sabre/dav/lib/CardDAV/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; @@ -9,10 +11,11 @@ use Sabre\DAVACL; use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; +use Sabre\Uri; use Sabre\VObject; /** - * CardDAV plugin + * CardDAV plugin. * * The CardDAV plugin adds CardDAV functionality to the WebDAV server * @@ -20,15 +23,15 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * Url to the addressbooks + * Url to the addressbooks. */ const ADDRESSBOOK_ROOT = 'addressbooks'; /** - * xml namespace for CardDAV elements + * xml namespace for CardDAV elements. */ const NS_CARDDAV = 'urn:ietf:params:xml:ns:carddav'; @@ -41,7 +44,7 @@ class Plugin extends DAV\ServerPlugin { public $directories = []; /** - * Server class + * Server class. * * @var DAV\Server */ @@ -55,41 +58,39 @@ class Plugin extends DAV\ServerPlugin { protected $maxResourceSize = 10000000; /** - * Initializes the plugin + * Initializes the plugin. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { /* Events */ - $server->on('propFind', [$this, 'propFindEarly']); - $server->on('propFind', [$this, 'propFindLate'], 150); - $server->on('report', [$this, 'report']); - $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); - $server->on('beforeWriteContent', [$this, 'beforeWriteContent']); - $server->on('beforeCreateFile', [$this, 'beforeCreateFile']); - $server->on('afterMethod:GET', [$this, 'httpAfterGet']); + $server->on('propFind', [$this, 'propFindEarly']); + $server->on('propFind', [$this, 'propFindLate'], 150); + $server->on('report', [$this, 'report']); + $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); + $server->on('beforeWriteContent', [$this, 'beforeWriteContent']); + $server->on('beforeCreateFile', [$this, 'beforeCreateFile']); + $server->on('afterMethod:GET', [$this, 'httpAfterGet']); $server->xml->namespaceMap[self::NS_CARDDAV] = 'card'; - $server->xml->elementMap['{' . self::NS_CARDDAV . '}addressbook-query'] = 'Sabre\\CardDAV\\Xml\\Request\\AddressBookQueryReport'; - $server->xml->elementMap['{' . self::NS_CARDDAV . '}addressbook-multiget'] = 'Sabre\\CardDAV\\Xml\\Request\\AddressBookMultiGetReport'; + $server->xml->elementMap['{'.self::NS_CARDDAV.'}addressbook-query'] = 'Sabre\\CardDAV\\Xml\\Request\\AddressBookQueryReport'; + $server->xml->elementMap['{'.self::NS_CARDDAV.'}addressbook-multiget'] = 'Sabre\\CardDAV\\Xml\\Request\\AddressBookMultiGetReport'; /* Mapping Interfaces to {DAV:}resourcetype values */ - $server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook'] = '{' . self::NS_CARDDAV . '}addressbook'; - $server->resourceTypeMapping['Sabre\\CardDAV\\IDirectory'] = '{' . self::NS_CARDDAV . '}directory'; + $server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook'] = '{'.self::NS_CARDDAV.'}addressbook'; + $server->resourceTypeMapping['Sabre\\CardDAV\\IDirectory'] = '{'.self::NS_CARDDAV.'}directory'; /* Adding properties that may never be changed */ - $server->protectedProperties[] = '{' . self::NS_CARDDAV . '}supported-address-data'; - $server->protectedProperties[] = '{' . self::NS_CARDDAV . '}max-resource-size'; - $server->protectedProperties[] = '{' . self::NS_CARDDAV . '}addressbook-home-set'; - $server->protectedProperties[] = '{' . self::NS_CARDDAV . '}supported-collation-set'; + $server->protectedProperties[] = '{'.self::NS_CARDDAV.'}supported-address-data'; + $server->protectedProperties[] = '{'.self::NS_CARDDAV.'}max-resource-size'; + $server->protectedProperties[] = '{'.self::NS_CARDDAV.'}addressbook-home-set'; + $server->protectedProperties[] = '{'.self::NS_CARDDAV.'}supported-collation-set'; $server->xml->elementMap['{http://calendarserver.org/ns/}me-card'] = 'Sabre\\DAV\\Xml\\Property\\Href'; $this->server = $server; - } /** @@ -99,10 +100,9 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['addressbook']; - } /** @@ -113,117 +113,111 @@ class Plugin extends DAV\ServerPlugin { * implement them * * @param string $uri + * * @return array */ - function getSupportedReportSet($uri) { - + public function getSupportedReportSet($uri) + { $node = $this->server->tree->getNodeForPath($uri); if ($node instanceof IAddressBook || $node instanceof ICard) { return [ - '{' . self::NS_CARDDAV . '}addressbook-multiget', - '{' . self::NS_CARDDAV . '}addressbook-query', + '{'.self::NS_CARDDAV.'}addressbook-multiget', + '{'.self::NS_CARDDAV.'}addressbook-query', ]; } - return []; + return []; } - /** - * Adds all CardDAV-specific properties + * Adds all CardDAV-specific properties. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFindEarly(DAV\PropFind $propFind, DAV\INode $node) { - - $ns = '{' . self::NS_CARDDAV . '}'; + public function propFindEarly(DAV\PropFind $propFind, DAV\INode $node) + { + $ns = '{'.self::NS_CARDDAV.'}'; if ($node instanceof IAddressBook) { - - $propFind->handle($ns . 'max-resource-size', $this->maxResourceSize); - $propFind->handle($ns . 'supported-address-data', function() { + $propFind->handle($ns.'max-resource-size', $this->maxResourceSize); + $propFind->handle($ns.'supported-address-data', function () { return new Xml\Property\SupportedAddressData(); }); - $propFind->handle($ns . 'supported-collation-set', function() { + $propFind->handle($ns.'supported-collation-set', function () { return new Xml\Property\SupportedCollationSet(); }); - } if ($node instanceof DAVACL\IPrincipal) { - $path = $propFind->getPath(); - $propFind->handle('{' . self::NS_CARDDAV . '}addressbook-home-set', function() use ($path) { - return new LocalHref($this->getAddressBookHomeForPrincipal($path) . '/'); - }); - - if ($this->directories) $propFind->handle('{' . self::NS_CARDDAV . '}directory-gateway', function() { - return new LocalHref($this->directories); + $propFind->handle('{'.self::NS_CARDDAV.'}addressbook-home-set', function () use ($path) { + return new LocalHref($this->getAddressBookHomeForPrincipal($path).'/'); }); + if ($this->directories) { + $propFind->handle('{'.self::NS_CARDDAV.'}directory-gateway', function () { + return new LocalHref($this->directories); + }); + } } if ($node instanceof ICard) { - // The address-data property is not supposed to be a 'real' // property, but in large chunks of the spec it does act as such. // Therefore we simply expose it as a property. - $propFind->handle('{' . self::NS_CARDDAV . '}address-data', function() use ($node) { + $propFind->handle('{'.self::NS_CARDDAV.'}address-data', function () use ($node) { $val = $node->get(); - if (is_resource($val)) + if (is_resource($val)) { $val = stream_get_contents($val); + } return $val; - }); - } - } /** - * This functions handles REPORT requests specific to CardDAV + * This functions handles REPORT requests specific to CardDAV. * - * @param string $reportName + * @param string $reportName * @param \DOMNode $dom - * @param mixed $path + * @param mixed $path + * * @return bool */ - function report($reportName, $dom, $path) { - + public function report($reportName, $dom, $path) + { switch ($reportName) { - case '{' . self::NS_CARDDAV . '}addressbook-multiget' : + case '{'.self::NS_CARDDAV.'}addressbook-multiget': $this->server->transactionType = 'report-addressbook-multiget'; $this->addressbookMultiGetReport($dom); + return false; - case '{' . self::NS_CARDDAV . '}addressbook-query' : + case '{'.self::NS_CARDDAV.'}addressbook-query': $this->server->transactionType = 'report-addressbook-query'; $this->addressBookQueryReport($dom); + return false; - default : + default: return; - } - - } /** - * Returns the addressbook home for a given principal + * Returns the addressbook home for a given principal. * * @param string $principal + * * @return string */ - protected function getAddressbookHomeForPrincipal($principal) { - - list(, $principalId) = \Sabre\HTTP\URLUtil::splitPath($principal); - return self::ADDRESSBOOK_ROOT . '/' . $principalId; + protected function getAddressbookHomeForPrincipal($principal) + { + list(, $principalId) = Uri\split($principal); + return self::ADDRESSBOOK_ROOT.'/'.$principalId; } - /** * This function handles the addressbook-multiget REPORT. * @@ -231,14 +225,13 @@ class Plugin extends DAV\ServerPlugin { * of urls. Effectively avoiding a lot of redundant requests. * * @param Xml\Request\AddressBookMultiGetReport $report - * @return void */ - function addressbookMultiGetReport($report) { - + public function addressbookMultiGetReport($report) + { $contentType = $report->contentType; $version = $report->version; if ($version) { - $contentType .= '; version=' . $version; + $contentType .= '; version='.$version; } $vcardType = $this->negotiateVCard( @@ -251,17 +244,13 @@ class Plugin extends DAV\ServerPlugin { $report->hrefs ); foreach ($this->server->getPropertiesForMultiplePaths($paths, $report->properties) as $props) { - - if (isset($props['200']['{' . self::NS_CARDDAV . '}address-data'])) { - - $props['200']['{' . self::NS_CARDDAV . '}address-data'] = $this->convertVCard( - $props[200]['{' . self::NS_CARDDAV . '}address-data'], + if (isset($props['200']['{'.self::NS_CARDDAV.'}address-data'])) { + $props['200']['{'.self::NS_CARDDAV.'}address-data'] = $this->convertVCard( + $props[200]['{'.self::NS_CARDDAV.'}address-data'], $vcardType ); - } $propertyList[] = $props; - } $prefer = $this->server->getHTTPPrefer(); @@ -269,8 +258,7 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer'); - $this->server->httpResponse->setBody($this->server->generateMultiStatus($propertyList, $prefer['return'] === 'minimal')); - + $this->server->httpResponse->setBody($this->server->generateMultiStatus($propertyList, 'minimal' === $prefer['return'])); } /** @@ -279,20 +267,19 @@ class Plugin extends DAV\ServerPlugin { * This plugin uses this method to ensure that Card nodes receive valid * vcard data. * - * @param string $path + * @param string $path * @param DAV\IFile $node - * @param resource $data - * @param bool $modified Should be set to true, if this event handler - * changed &$data. - * @return void + * @param resource $data + * @param bool $modified should be set to true, if this event handler + * changed &$data */ - function beforeWriteContent($path, DAV\IFile $node, &$data, &$modified) { - - if (!$node instanceof ICard) + public function beforeWriteContent($path, DAV\IFile $node, &$data, &$modified) + { + if (!$node instanceof ICard) { return; + } $this->validateVCard($data, $modified); - } /** @@ -301,20 +288,19 @@ class Plugin extends DAV\ServerPlugin { * This plugin uses this method to ensure that Card nodes receive valid * vcard data. * - * @param string $path - * @param resource $data + * @param string $path + * @param resource $data * @param DAV\ICollection $parentNode - * @param bool $modified Should be set to true, if this event handler - * changed &$data. - * @return void + * @param bool $modified should be set to true, if this event handler + * changed &$data */ - function beforeCreateFile($path, &$data, DAV\ICollection $parentNode, &$modified) { - - if (!$parentNode instanceof IAddressBook) + public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode, &$modified) + { + if (!$parentNode instanceof IAddressBook) { return; + } $this->validateVCard($data, $modified); - } /** @@ -323,12 +309,11 @@ class Plugin extends DAV\ServerPlugin { * An exception is thrown if it's not. * * @param resource|string $data - * @param bool $modified Should be set to true, if this event handler - * changed &$data. - * @return void + * @param bool $modified should be set to true, if this event handler + * changed &$data */ - protected function validateVCard(&$data, &$modified) { - + protected function validateVCard(&$data, &$modified) + { // If it's a stream, we convert it to a string first. if (is_resource($data)) { $data = stream_get_contents($data); @@ -337,10 +322,9 @@ class Plugin extends DAV\ServerPlugin { $before = $data; try { - // If the data starts with a [, we can reasonably assume we're dealing // with a jCal object. - if (substr($data, 0, 1) === '[') { + if ('[' === substr($data, 0, 1)) { $vobj = VObject\Reader::readJson($data); // Converting $data back to iCalendar, as that's what we @@ -350,21 +334,18 @@ class Plugin extends DAV\ServerPlugin { } else { $vobj = VObject\Reader::read($data); } - } catch (VObject\ParseException $e) { - - throw new DAV\Exception\UnsupportedMediaType('This resource only supports valid vCard or jCard data. Parse error: ' . $e->getMessage()); - + throw new DAV\Exception\UnsupportedMediaType('This resource only supports valid vCard or jCard data. Parse error: '.$e->getMessage()); } - if ($vobj->name !== 'VCARD') { + if ('VCARD' !== $vobj->name) { throw new DAV\Exception\UnsupportedMediaType('This collection can only support vcard objects.'); } $options = VObject\Node::PROFILE_CARDDAV; $prefer = $this->server->getHTTPPrefer(); - if ($prefer['handling'] !== 'strict') { + if ('strict' !== $prefer['handling']) { $options |= VObject\Node::REPAIR; } @@ -376,7 +357,6 @@ class Plugin extends DAV\ServerPlugin { // $messages contains a list of problems with the vcard, along with // their severity. foreach ($messages as $message) { - if ($message['level'] > $highestLevel) { // Recording the highest reported error level. $highestLevel = $message['level']; @@ -384,30 +364,27 @@ class Plugin extends DAV\ServerPlugin { } switch ($message['level']) { - - case 1 : + case 1: // Level 1 means that there was a problem, but it was repaired. $modified = true; break; - case 2 : + case 2: // Level 2 means a warning, but not critical break; - case 3 : + case 3: // Level 3 means a critical error - throw new DAV\Exception\UnsupportedMediaType('Validation error in vCard: ' . $message['message']); - + throw new DAV\Exception\UnsupportedMediaType('Validation error in vCard: '.$message['message']); } - } if ($warningMessage) { $this->server->httpResponse->setHeader( 'X-Sabre-Ew-Gross', - 'vCard validation warning: ' . $warningMessage + 'vCard validation warning: '.$warningMessage ); // Re-serializing object. $data = $vobj->serialize(); - if (!$modified && strcmp($data, $before) !== 0) { + if (!$modified && 0 !== strcmp($data, $before)) { // This ensures that the system does not send an ETag back. $modified = true; } @@ -417,23 +394,21 @@ class Plugin extends DAV\ServerPlugin { $vobj->destroy(); } - /** - * This function handles the addressbook-query REPORT + * This function handles the addressbook-query REPORT. * * This report is used by the client to filter an addressbook based on a * complex query. * * @param Xml\Request\AddressBookQueryReport $report - * @return void */ - protected function addressbookQueryReport($report) { - + protected function addressbookQueryReport($report) + { $depth = $this->server->getHTTPDepth(0); - if ($depth == 0) { + if (0 == $depth) { $candidateNodes = [ - $this->server->tree->getNodeForPath($this->server->getRequestUri()) + $this->server->tree->getNodeForPath($this->server->getRequestUri()), ]; if (!$candidateNodes[0] instanceof ICard) { throw new ReportNotSupported('The addressbook-query report is not supported on this url with Depth: 0'); @@ -444,7 +419,7 @@ class Plugin extends DAV\ServerPlugin { $contentType = $report->contentType; if ($report->version) { - $contentType .= '; version=' . $report->version; + $contentType .= '; version='.$report->version; } $vcardType = $this->negotiateVCard( @@ -453,9 +428,9 @@ class Plugin extends DAV\ServerPlugin { $validNodes = []; foreach ($candidateNodes as $node) { - - if (!$node instanceof ICard) + if (!$node instanceof ICard) { continue; + } $blob = $node->get(); if (is_resource($blob)) { @@ -472,31 +447,26 @@ class Plugin extends DAV\ServerPlugin { // We hit the maximum number of items, we can stop now. break; } - } $result = []; foreach ($validNodes as $validNode) { - - if ($depth == 0) { + if (0 == $depth) { $href = $this->server->getRequestUri(); } else { - $href = $this->server->getRequestUri() . '/' . $validNode->getName(); + $href = $this->server->getRequestUri().'/'.$validNode->getName(); } list($props) = $this->server->getPropertiesForPath($href, $report->properties, 0); - if (isset($props[200]['{' . self::NS_CARDDAV . '}address-data'])) { - - $props[200]['{' . self::NS_CARDDAV . '}address-data'] = $this->convertVCard( - $props[200]['{' . self::NS_CARDDAV . '}address-data'], + if (isset($props[200]['{'.self::NS_CARDDAV.'}address-data'])) { + $props[200]['{'.self::NS_CARDDAV.'}address-data'] = $this->convertVCard( + $props[200]['{'.self::NS_CARDDAV.'}address-data'], $vcardType, $report->addressDataProperties ); - } $result[] = $props; - } $prefer = $this->server->getHTTPPrefer(); @@ -504,26 +474,26 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer'); - $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, $prefer['return'] === 'minimal')); - + $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, 'minimal' === $prefer['return'])); } /** * Validates if a vcard makes it throught a list of filters. * * @param string $vcardData - * @param array $filters - * @param string $test anyof or allof (which means OR or AND) + * @param array $filters + * @param string $test anyof or allof (which means OR or AND) + * * @return bool */ - function validateFilters($vcardData, array $filters, $test) { - - - if (!$filters) return true; + public function validateFilters($vcardData, array $filters, $test) + { + if (!$filters) { + return true; + } $vcard = VObject\Reader::read($vcardData); foreach ($filters as $filter) { - $isDefined = isset($vcard->{$filter['name']}); if ($filter['is-not-defined']) { if ($isDefined) { @@ -532,12 +502,9 @@ class Plugin extends DAV\ServerPlugin { $success = true; } } elseif ((!$filter['param-filters'] && !$filter['text-matches']) || !$isDefined) { - // We only need to check for existence $success = $isDefined; - } else { - $vProperties = $vcard->select($filter['name']); $results = []; @@ -546,44 +513,40 @@ class Plugin extends DAV\ServerPlugin { } if ($filter['text-matches']) { $texts = []; - foreach ($vProperties as $vProperty) + foreach ($vProperties as $vProperty) { $texts[] = $vProperty->getValue(); + } $results[] = $this->validateTextMatches($texts, $filter['text-matches'], $filter['test']); } - if (count($results) === 1) { + if (1 === count($results)) { $success = $results[0]; } else { - if ($filter['test'] === 'anyof') { + if ('anyof' === $filter['test']) { $success = $results[0] || $results[1]; } else { $success = $results[0] && $results[1]; } } - } // else // There are two conditions where we can already determine whether // or not this filter succeeds. - if ($test === 'anyof' && $success) { - + if ('anyof' === $test && $success) { // Destroy circular references to PHP will GC the object. $vcard->destroy(); return true; } - if ($test === 'allof' && !$success) { - + if ('allof' === $test && !$success) { // Destroy circular references to PHP will GC the object. $vcard->destroy(); return false; } - } // foreach - // Destroy circular references to PHP will GC the object. $vcard->destroy(); @@ -592,8 +555,7 @@ class Plugin extends DAV\ServerPlugin { // // This implies for 'anyof' that the test failed, and for 'allof' that // we succeeded. Sounds weird, but makes sense. - return $test === 'allof'; - + return 'allof' === $test; } /** @@ -602,19 +564,22 @@ class Plugin extends DAV\ServerPlugin { * @todo currently we're only validating the first parameter of the passed * property. Any subsequence parameters with the same name are * ignored. - * @param array $vProperties - * @param array $filters + * + * @param array $vProperties + * @param array $filters * @param string $test + * * @return bool */ - protected function validateParamFilters(array $vProperties, array $filters, $test) { - + protected function validateParamFilters(array $vProperties, array $filters, $test) + { foreach ($filters as $filter) { - $isDefined = false; foreach ($vProperties as $vProperty) { $isDefined = isset($vProperty[$filter['name']]); - if ($isDefined) break; + if ($isDefined) { + break; + } } if ($filter['is-not-defined']) { @@ -624,35 +589,32 @@ class Plugin extends DAV\ServerPlugin { $success = true; } - // If there's no text-match, we can just check for existence + // If there's no text-match, we can just check for existence } elseif (!$filter['text-match'] || !$isDefined) { - $success = $isDefined; - } else { - $success = false; foreach ($vProperties as $vProperty) { // If we got all the way here, we'll need to validate the // text-match filter. $success = DAV\StringUtil::textMatch($vProperty[$filter['name']]->getValue(), $filter['text-match']['value'], $filter['text-match']['collation'], $filter['text-match']['match-type']); - if ($success) break; + if ($success) { + break; + } } if ($filter['text-match']['negate-condition']) { $success = !$success; } - } // else // There are two conditions where we can already determine whether // or not this filter succeeds. - if ($test === 'anyof' && $success) { + if ('anyof' === $test && $success) { return true; } - if ($test === 'allof' && !$success) { + if ('allof' === $test && !$success) { return false; } - } // If we got all the way here, it means we haven't been able to @@ -660,40 +622,41 @@ class Plugin extends DAV\ServerPlugin { // // This implies for 'anyof' that the test failed, and for 'allof' that // we succeeded. Sounds weird, but makes sense. - return $test === 'allof'; - + return 'allof' === $test; } /** * Validates if a text-filter can be applied to a specific property. * - * @param array $texts - * @param array $filters + * @param array $texts + * @param array $filters * @param string $test + * * @return bool */ - protected function validateTextMatches(array $texts, array $filters, $test) { - + protected function validateTextMatches(array $texts, array $filters, $test) + { foreach ($filters as $filter) { - $success = false; foreach ($texts as $haystack) { $success = DAV\StringUtil::textMatch($haystack, $filter['value'], $filter['collation'], $filter['match-type']); // Breaking on the first match - if ($success) break; + if ($success) { + break; + } } if ($filter['negate-condition']) { $success = !$success; } - if ($success && $test === 'anyof') + if ($success && 'anyof' === $test) { return true; + } - if (!$success && $test == 'allof') + if (!$success && 'allof' == $test) { return false; - - + } } // If we got all the way here, it means we haven't been able to @@ -701,8 +664,7 @@ class Plugin extends DAV\ServerPlugin { // // This implies for 'anyof' that the test failed, and for 'allof' that // we succeeded. Sounds weird, but makes sense. - return $test === 'allof'; - + return 'allof' === $test; } /** @@ -712,24 +674,24 @@ class Plugin extends DAV\ServerPlugin { * propfind has been done. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFindLate(DAV\PropFind $propFind, DAV\INode $node) { - + public function propFindLate(DAV\PropFind $propFind, DAV\INode $node) + { // If the request was made using the SOGO connector, we must rewrite // the content-type property. By default SabreDAV will send back // text/x-vcard; charset=utf-8, but for SOGO we must strip that last // part. - if (strpos($this->server->httpRequest->getHeader('User-Agent'), 'Thunderbird') === false) { + if (false === strpos((string) $this->server->httpRequest->getHeader('User-Agent'), 'Thunderbird')) { return; } $contentType = $propFind->get('{DAV:}getcontenttype'); - list($part) = explode(';', $contentType); - if ($part === 'text/x-vcard' || $part === 'text/vcard') { - $propFind->set('{DAV:}getcontenttype', 'text/x-vcard'); + if (null !== $contentType) { + list($part) = explode(';', $contentType); + if ('text/x-vcard' === $part || 'text/vcard' === $part) { + $propFind->set('{DAV:}getcontenttype', 'text/x-vcard'); + } } - } /** @@ -738,18 +700,20 @@ class Plugin extends DAV\ServerPlugin { * can use to create new addressbooks. * * @param DAV\INode $node - * @param string $output + * @param string $output + * * @return bool */ - function htmlActionsPanel(DAV\INode $node, &$output) { - - if (!$node instanceof AddressBookHome) + public function htmlActionsPanel(DAV\INode $node, &$output) + { + if (!$node instanceof AddressBookHome) { return; + } $output .= '<tr><td colspan="2"><form method="post" action=""> <h3>Create new address book</h3> <input type="hidden" name="sabreAction" value="mkcol" /> - <input type="hidden" name="resourceType" value="{DAV:}collection,{' . self::NS_CARDDAV . '}addressbook" /> + <input type="hidden" name="resourceType" value="{DAV:}collection,{'.self::NS_CARDDAV.'}addressbook" /> <label>Name (uri):</label> <input type="text" name="name" /><br /> <label>Display name:</label> <input type="text" name="{DAV:}displayname" /><br /> <input type="submit" value="create" /> @@ -757,7 +721,6 @@ class Plugin extends DAV\ServerPlugin { </td></tr>'; return false; - } /** @@ -765,13 +728,13 @@ class Plugin extends DAV\ServerPlugin { * * This is used to transform data into jCal, if this was requested. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpAfterGet(RequestInterface $request, ResponseInterface $response) { - - if (strpos($response->getHeader('Content-Type'), 'text/vcard') === false) { + public function httpAfterGet(RequestInterface $request, ResponseInterface $response) + { + $contentType = $response->getHeader('Content-Type'); + if (null === $contentType || false === strpos($contentType, 'text/vcard')) { return; } @@ -783,9 +746,8 @@ class Plugin extends DAV\ServerPlugin { ); $response->setBody($newBody); - $response->setHeader('Content-Type', $mimeType . '; charset=utf-8'); + $response->setHeader('Content-Type', $mimeType.'; charset=utf-8'); $response->setHeader('Content-Length', strlen($newBody)); - } /** @@ -800,11 +762,12 @@ class Plugin extends DAV\ServerPlugin { * * @param string $input * @param string $mimeType + * * @return string */ - protected function negotiateVCard($input, &$mimeType = null) { - - $result = HTTP\Util::negotiate( + protected function negotiateVCard($input, &$mimeType = null) + { + $result = HTTP\negotiateContentType( $input, [ // Most often used mime-type. Version 3 @@ -823,41 +786,41 @@ class Plugin extends DAV\ServerPlugin { $mimeType = $result; switch ($result) { - - default : - case 'text/x-vcard' : - case 'text/vcard' : - case 'text/vcard; version=3.0' : + default: + case 'text/x-vcard': + case 'text/vcard': + case 'text/vcard; version=3.0': $mimeType = 'text/vcard'; + return 'vcard3'; - case 'text/vcard; version=4.0' : + case 'text/vcard; version=4.0': return 'vcard4'; - case 'application/vcard+json' : + case 'application/vcard+json': return 'jcard'; // @codeCoverageIgnoreStart } // @codeCoverageIgnoreEnd - } /** * Converts a vcard blob to a different version, or jcard. * * @param string|resource $data - * @param string $target - * @param array $propertiesFilter + * @param string $target + * @param array $propertiesFilter + * * @return string */ - protected function convertVCard($data, $target, array $propertiesFilter = null) { - + protected function convertVCard($data, $target, array $propertiesFilter = null) + { if (is_resource($data)) { $data = stream_get_contents($data); } $input = VObject\Reader::read($data); if (!empty($propertiesFilter)) { $propertiesFilter = array_merge(['UID', 'VERSION', 'FN'], $propertiesFilter); - $keys = array_unique(array_map(function($child) { + $keys = array_unique(array_map(function ($child) { return $child->name; }, $input->children())); $keys = array_diff($keys, $propertiesFilter); @@ -868,38 +831,36 @@ class Plugin extends DAV\ServerPlugin { } $output = null; try { - switch ($target) { - default : - case 'vcard3' : - if ($input->getDocumentType() === VObject\Document::VCARD30) { + default: + case 'vcard3': + if (VObject\Document::VCARD30 === $input->getDocumentType()) { // Do nothing return $data; } $output = $input->convert(VObject\Document::VCARD30); + return $output->serialize(); - case 'vcard4' : - if ($input->getDocumentType() === VObject\Document::VCARD40) { + case 'vcard4': + if (VObject\Document::VCARD40 === $input->getDocumentType()) { // Do nothing return $data; } $output = $input->convert(VObject\Document::VCARD40); + return $output->serialize(); - case 'jcard' : + case 'jcard': $output = $input->convert(VObject\Document::VCARD40); - return json_encode($output); + return json_encode($output); } - } finally { - // Destroy circular references to PHP will GC the object. $input->destroy(); if (!is_null($output)) { $output->destroy(); } } - } /** @@ -910,10 +871,9 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'carddav'; - } /** @@ -927,14 +887,12 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds support for CardDAV (rfc6352)', - 'link' => 'http://sabre.io/dav/carddav/', + 'link' => 'http://sabre.io/dav/carddav/', ]; - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php b/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php index 2d61db6ac..194927c53 100644 --- a/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php +++ b/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; @@ -8,7 +10,7 @@ use Sabre\HTTP\ResponseInterface; use Sabre\VObject; /** - * VCF Exporter + * VCF Exporter. * * This plugin adds the ability to export entire address books as .vcf files. * This is useful for clients that don't support CardDAV yet. They often do @@ -19,28 +21,27 @@ use Sabre\VObject; * @author Thomas Tanghus (http://tanghus.net/) * @license http://sabre.io/license/ Modified BSD License */ -class VCFExportPlugin extends DAV\ServerPlugin { - +class VCFExportPlugin extends DAV\ServerPlugin +{ /** - * Reference to Server class + * Reference to Server class. * * @var DAV\Server */ protected $server; /** - * Initializes the plugin and registers event handlers + * Initializes the plugin and registers event handlers. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->on('method:GET', [$this, 'httpGet'], 90); - $server->on('browserButtonActions', function($path, $node, &$actions) { + $server->on('browserButtonActions', function ($path, $node, &$actions) { if ($node instanceof IAddressBook) { - $actions .= '<a href="' . htmlspecialchars($path, ENT_QUOTES, 'UTF-8') . '?export"><span class="oi" data-glyph="book"></span></a>'; + $actions .= '<a href="'.htmlspecialchars($path, ENT_QUOTES, 'UTF-8').'?export"><span class="oi" data-glyph="book"></span></a>'; } }); } @@ -48,20 +49,25 @@ class VCFExportPlugin extends DAV\ServerPlugin { /** * Intercepts GET requests on addressbook urls ending with ?export. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $queryParams = $request->getQueryParameters(); - if (!array_key_exists('export', $queryParams)) return; + if (!array_key_exists('export', $queryParams)) { + return; + } $path = $request->getPath(); $node = $this->server->tree->getNodeForPath($path); - if (!($node instanceof IAddressBook)) return; + if (!($node instanceof IAddressBook)) { + return; + } $this->server->transactionType = 'get-addressbook-export'; @@ -71,7 +77,7 @@ class VCFExportPlugin extends DAV\ServerPlugin { } $nodes = $this->server->getPropertiesForPath($path, [ - '{' . Plugin::NS_CARDDAV . '}address-data', + '{'.Plugin::NS_CARDDAV.'}address-data', ], 1); $format = 'text/directory'; @@ -91,9 +97,9 @@ class VCFExportPlugin extends DAV\ServerPlugin { '', $node->getName() ); - $filename .= '-' . date('Y-m-d') . $filenameExtension; + $filename .= '-'.date('Y-m-d').$filenameExtension; - $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); + $response->setHeader('Content-Disposition', 'attachment; filename="'.$filename.'"'); $response->setHeader('Content-Type', $format); $response->setStatus(200); @@ -101,25 +107,24 @@ class VCFExportPlugin extends DAV\ServerPlugin { // Returning false to break the event chain return false; - } /** - * Merges all vcard objects, and builds one big vcf export + * Merges all vcard objects, and builds one big vcf export. * * @param array $nodes + * * @return string */ - function generateVCF(array $nodes) { - - $output = ""; + public function generateVCF(array $nodes) + { + $output = ''; foreach ($nodes as $node) { - - if (!isset($node[200]['{' . Plugin::NS_CARDDAV . '}address-data'])) { + if (!isset($node[200]['{'.Plugin::NS_CARDDAV.'}address-data'])) { continue; } - $nodeData = $node[200]['{' . Plugin::NS_CARDDAV . '}address-data']; + $nodeData = $node[200]['{'.Plugin::NS_CARDDAV.'}address-data']; // Parsing this node so VObject can clean up the output. $vcard = VObject\Reader::read($nodeData); @@ -127,11 +132,9 @@ class VCFExportPlugin extends DAV\ServerPlugin { // Destroy circular references to PHP will GC the object. $vcard->destroy(); - } return $output; - } /** @@ -142,10 +145,9 @@ class VCFExportPlugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'vcf-export'; - } /** @@ -159,14 +161,12 @@ class VCFExportPlugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds the ability to export CardDAV addressbooks as a single vCard file.', - 'link' => 'http://sabre.io/dav/vcf-export-plugin/', + 'link' => 'http://sabre.io/dav/vcf-export-plugin/', ]; - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Filter/AddressData.php b/vendor/sabre/dav/lib/CardDAV/Xml/Filter/AddressData.php index 5b7b2ee17..f1b651e76 100644 --- a/vendor/sabre/dav/lib/CardDAV/Xml/Filter/AddressData.php +++ b/vendor/sabre/dav/lib/CardDAV/Xml/Filter/AddressData.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV\Xml\Filter; use Sabre\Xml\Reader; @@ -21,8 +23,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class AddressData implements XmlDeserializable { - +class AddressData implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -42,25 +44,25 @@ class AddressData implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $result = [ 'contentType' => $reader->getAttribute('content-type') ?: 'text/vcard', - 'version' => $reader->getAttribute('version') ?: '3.0', + 'version' => $reader->getAttribute('version') ?: '3.0', ]; - $elems = (array)$reader->parseInnerTree(); - $elems = array_filter($elems, function($element) { - return $element['name'] === '{urn:ietf:params:xml:ns:carddav}prop' && + $elems = (array) $reader->parseInnerTree(); + $elems = array_filter($elems, function ($element) { + return '{urn:ietf:params:xml:ns:carddav}prop' === $element['name'] && isset($element['attributes']['name']); }); - $result['addressDataProperties'] = array_map(function($element) { + $result['addressDataProperties'] = array_map(function ($element) { return $element['attributes']['name']; }, $elems); return $result; } - } diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Filter/ParamFilter.php b/vendor/sabre/dav/lib/CardDAV/Xml/Filter/ParamFilter.php index 936e26917..2d39dea7f 100644 --- a/vendor/sabre/dav/lib/CardDAV/Xml/Filter/ParamFilter.php +++ b/vendor/sabre/dav/lib/CardDAV/Xml/Filter/ParamFilter.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV\Xml\Filter; use Sabre\CardDAV\Plugin; @@ -21,8 +23,8 @@ use Sabre\Xml\Reader; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class ParamFilter implements Element { - +abstract class ParamFilter implements Element +{ /** * The deserialize method is called during xml parsing. * @@ -42,14 +44,15 @@ abstract class ParamFilter implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $result = [ - 'name' => null, + 'name' => null, 'is-not-defined' => false, - 'text-match' => null, + 'text-match' => null, ]; $att = $reader->parseAttributes(); @@ -57,33 +60,29 @@ abstract class ParamFilter implements Element { $elems = $reader->parseInnerTree(); - if (is_array($elems)) foreach ($elems as $elem) { - - switch ($elem['name']) { - - case '{' . Plugin::NS_CARDDAV . '}is-not-defined' : + if (is_array($elems)) { + foreach ($elems as $elem) { + switch ($elem['name']) { + case '{'.Plugin::NS_CARDDAV.'}is-not-defined': $result['is-not-defined'] = true; break; - case '{' . Plugin::NS_CARDDAV . '}text-match' : + case '{'.Plugin::NS_CARDDAV.'}text-match': $matchType = isset($elem['attributes']['match-type']) ? $elem['attributes']['match-type'] : 'contains'; if (!in_array($matchType, ['contains', 'equals', 'starts-with', 'ends-with'])) { - throw new BadRequest('Unknown match-type: ' . $matchType); + throw new BadRequest('Unknown match-type: '.$matchType); } $result['text-match'] = [ - 'negate-condition' => isset($elem['attributes']['negate-condition']) && $elem['attributes']['negate-condition'] === 'yes', - 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;unicode-casemap', - 'value' => $elem['value'], - 'match-type' => $matchType, + 'negate-condition' => isset($elem['attributes']['negate-condition']) && 'yes' === $elem['attributes']['negate-condition'], + 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;unicode-casemap', + 'value' => $elem['value'], + 'match-type' => $matchType, ]; break; - } - + } } return $result; - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Filter/PropFilter.php b/vendor/sabre/dav/lib/CardDAV/Xml/Filter/PropFilter.php index d7799429d..a22a577c9 100644 --- a/vendor/sabre/dav/lib/CardDAV/Xml/Filter/PropFilter.php +++ b/vendor/sabre/dav/lib/CardDAV/Xml/Filter/PropFilter.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV\Xml\Filter; use Sabre\CardDAV\Plugin; @@ -21,8 +23,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PropFilter implements XmlDeserializable { - +class PropFilter implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -42,57 +44,54 @@ class PropFilter implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $result = [ - 'name' => null, - 'test' => 'anyof', + 'name' => null, + 'test' => 'anyof', 'is-not-defined' => false, - 'param-filters' => [], - 'text-matches' => [], + 'param-filters' => [], + 'text-matches' => [], ]; $att = $reader->parseAttributes(); $result['name'] = $att['name']; - if (isset($att['test']) && $att['test'] === 'allof') { + if (isset($att['test']) && 'allof' === $att['test']) { $result['test'] = 'allof'; } $elems = $reader->parseInnerTree(); - if (is_array($elems)) foreach ($elems as $elem) { - - switch ($elem['name']) { - - case '{' . Plugin::NS_CARDDAV . '}param-filter' : + if (is_array($elems)) { + foreach ($elems as $elem) { + switch ($elem['name']) { + case '{'.Plugin::NS_CARDDAV.'}param-filter': $result['param-filters'][] = $elem['value']; break; - case '{' . Plugin::NS_CARDDAV . '}is-not-defined' : + case '{'.Plugin::NS_CARDDAV.'}is-not-defined': $result['is-not-defined'] = true; break; - case '{' . Plugin::NS_CARDDAV . '}text-match' : + case '{'.Plugin::NS_CARDDAV.'}text-match': $matchType = isset($elem['attributes']['match-type']) ? $elem['attributes']['match-type'] : 'contains'; if (!in_array($matchType, ['contains', 'equals', 'starts-with', 'ends-with'])) { - throw new BadRequest('Unknown match-type: ' . $matchType); + throw new BadRequest('Unknown match-type: '.$matchType); } $result['text-matches'][] = [ - 'negate-condition' => isset($elem['attributes']['negate-condition']) && $elem['attributes']['negate-condition'] === 'yes', - 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;unicode-casemap', - 'value' => $elem['value'], - 'match-type' => $matchType, + 'negate-condition' => isset($elem['attributes']['negate-condition']) && 'yes' === $elem['attributes']['negate-condition'], + 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;unicode-casemap', + 'value' => $elem['value'], + 'match-type' => $matchType, ]; break; - } - + } } return $result; - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedAddressData.php b/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedAddressData.php index aecd8a09f..9d0051698 100644 --- a/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedAddressData.php +++ b/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedAddressData.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV\Xml\Property; use Sabre\CardDAV\Plugin; @@ -7,7 +9,7 @@ use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * Supported-address-data property + * Supported-address-data property. * * This property is a representation of the supported-address-data property * in the CardDAV namespace. @@ -20,22 +22,22 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedAddressData implements XmlSerializable { - +class SupportedAddressData implements XmlSerializable +{ /** - * supported versions + * supported versions. * * @var array */ protected $supportedData = []; /** - * Creates the property + * Creates the property. * * @param array|null $supportedData */ - function __construct(array $supportedData = null) { - + public function __construct(array $supportedData = null) + { if (is_null($supportedData)) { $supportedData = [ ['contentType' => 'text/vcard', 'version' => '3.0'], @@ -45,7 +47,6 @@ class SupportedAddressData implements XmlSerializable { } $this->supportedData = $supportedData; - } /** @@ -65,19 +66,16 @@ class SupportedAddressData 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) + { foreach ($this->supportedData as $supported) { - $writer->startElement('{' . Plugin::NS_CARDDAV . '}address-data-type'); + $writer->startElement('{'.Plugin::NS_CARDDAV.'}address-data-type'); $writer->writeAttributes([ 'content-type' => $supported['contentType'], - 'version' => $supported['version'] + 'version' => $supported['version'], ]); $writer->endElement(); // address-data-type } - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedCollationSet.php b/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedCollationSet.php index 778aa2b64..66e451a91 100644 --- a/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedCollationSet.php +++ b/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedCollationSet.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV\Xml\Property; use Sabre\Xml\Writer; use Sabre\Xml\XmlSerializable; /** - * supported-collation-set property + * supported-collation-set property. * * This property is a representation of the supported-collation-set property * in the CardDAV namespace. @@ -15,8 +17,8 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedCollationSet implements XmlSerializable { - +class SupportedCollationSet implements XmlSerializable +{ /** * The xmlSerialize method is called during xml writing. * @@ -34,14 +36,11 @@ class SupportedCollationSet 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) + { foreach (['i;ascii-casemap', 'i;octet', 'i;unicode-casemap'] as $coll) { $writer->writeElement('{urn:ietf:params:xml:ns:carddav}supported-collation', $coll); } - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php b/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php index 0115a0107..845796760 100644 --- a/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php +++ b/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV\Xml\Request; use Sabre\CardDAV\Plugin; @@ -19,8 +21,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class AddressBookMultiGetReport implements XmlDeserializable { - +class AddressBookMultiGetReport implements XmlDeserializable +{ /** * An array with requested properties. * @@ -70,44 +72,40 @@ class AddressBookMultiGetReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree([ '{urn:ietf:params:xml:ns:carddav}address-data' => 'Sabre\\CardDAV\\Xml\\Filter\\AddressData', - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', ]); $newProps = [ - 'hrefs' => [], - 'properties' => [] + 'hrefs' => [], + 'properties' => [], ]; foreach ($elems as $elem) { - switch ($elem['name']) { - - case '{DAV:}prop' : + case '{DAV:}prop': $newProps['properties'] = array_keys($elem['value']); - if (isset($elem['value']['{' . Plugin::NS_CARDDAV . '}address-data'])) { - $newProps += $elem['value']['{' . Plugin::NS_CARDDAV . '}address-data']; + if (isset($elem['value']['{'.Plugin::NS_CARDDAV.'}address-data'])) { + $newProps += $elem['value']['{'.Plugin::NS_CARDDAV.'}address-data']; } break; - case '{DAV:}href' : + case '{DAV:}href': $newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']); break; - } - } $obj = new self(); foreach ($newProps as $key => $value) { $obj->$key = $value; } - return $obj; + return $obj; } - } diff --git a/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookQueryReport.php b/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookQueryReport.php index 09fad008a..0e6f26d38 100644 --- a/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookQueryReport.php +++ b/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookQueryReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV\Xml\Request; use Sabre\CardDAV\Plugin; @@ -19,8 +21,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class AddressBookQueryReport implements XmlDeserializable { - +class AddressBookQueryReport implements XmlDeserializable +{ /** * An array with requested properties. * @@ -64,7 +66,7 @@ class AddressBookQueryReport implements XmlDeserializable { public $filters; /** - * The number of results the client wants + * The number of results the client wants. * * null means it wasn't specified, which in most cases means 'all results'. * @@ -73,7 +75,7 @@ class AddressBookQueryReport implements XmlDeserializable { public $limit; /** - * Either 'anyof' or 'allof' + * Either 'anyof' or 'allof'. * * @var string */ @@ -95,7 +97,6 @@ class AddressBookQueryReport implements XmlDeserializable { */ public $version = null; - /** * The deserialize method is called during xml parsing. * @@ -115,65 +116,64 @@ class AddressBookQueryReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - - $elems = (array)$reader->parseInnerTree([ - '{urn:ietf:params:xml:ns:carddav}prop-filter' => 'Sabre\\CardDAV\\Xml\\Filter\\PropFilter', + public static function xmlDeserialize(Reader $reader) + { + $elems = (array) $reader->parseInnerTree([ + '{urn:ietf:params:xml:ns:carddav}prop-filter' => 'Sabre\\CardDAV\\Xml\\Filter\\PropFilter', '{urn:ietf:params:xml:ns:carddav}param-filter' => 'Sabre\\CardDAV\\Xml\\Filter\\ParamFilter', '{urn:ietf:params:xml:ns:carddav}address-data' => 'Sabre\\CardDAV\\Xml\\Filter\\AddressData', - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', ]); $newProps = [ - 'filters' => null, + 'filters' => null, 'properties' => [], - 'test' => 'anyof', - 'limit' => null, + 'test' => 'anyof', + 'limit' => null, ]; - if (!is_array($elems)) $elems = []; + if (!is_array($elems)) { + $elems = []; + } foreach ($elems as $elem) { - switch ($elem['name']) { - - case '{DAV:}prop' : + case '{DAV:}prop': $newProps['properties'] = array_keys($elem['value']); - if (isset($elem['value']['{' . Plugin::NS_CARDDAV . '}address-data'])) { - $newProps += $elem['value']['{' . Plugin::NS_CARDDAV . '}address-data']; + if (isset($elem['value']['{'.Plugin::NS_CARDDAV.'}address-data'])) { + $newProps += $elem['value']['{'.Plugin::NS_CARDDAV.'}address-data']; } break; - case '{' . Plugin::NS_CARDDAV . '}filter' : + case '{'.Plugin::NS_CARDDAV.'}filter': if (!is_null($newProps['filters'])) { - throw new BadRequest('You can only include 1 {' . Plugin::NS_CARDDAV . '}filter element'); + throw new BadRequest('You can only include 1 {'.Plugin::NS_CARDDAV.'}filter element'); } if (isset($elem['attributes']['test'])) { $newProps['test'] = $elem['attributes']['test']; - if ($newProps['test'] !== 'allof' && $newProps['test'] !== 'anyof') { + if ('allof' !== $newProps['test'] && 'anyof' !== $newProps['test']) { throw new BadRequest('The "test" attribute must be one of "allof" or "anyof"'); } } $newProps['filters'] = []; - foreach ((array)$elem['value'] as $subElem) { - if ($subElem['name'] === '{' . Plugin::NS_CARDDAV . '}prop-filter') { + foreach ((array) $elem['value'] as $subElem) { + if ($subElem['name'] === '{'.Plugin::NS_CARDDAV.'}prop-filter') { $newProps['filters'][] = $subElem['value']; } } break; - case '{' . Plugin::NS_CARDDAV . '}limit' : + case '{'.Plugin::NS_CARDDAV.'}limit': foreach ($elem['value'] as $child) { - if ($child['name'] === '{' . Plugin::NS_CARDDAV . '}nresults') { - $newProps['limit'] = (int)$child['value']; + if ($child['name'] === '{'.Plugin::NS_CARDDAV.'}nresults') { + $newProps['limit'] = (int) $child['value']; } } break; - } - } if (is_null($newProps['filters'])) { @@ -184,7 +184,6 @@ class AddressBookQueryReport implements XmlDeserializable { */ //throw new BadRequest('The {' . Plugin::NS_CARDDAV . '}filter element is required for this request'); $newProps['filters'] = []; - } $obj = new self(); @@ -193,7 +192,5 @@ class AddressBookQueryReport implements XmlDeserializable { } return $obj; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php index 40a95f8bf..aa8b1f573 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php @@ -1,14 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * HTTP Basic authentication backend class + * HTTP Basic authentication backend class. * * This class can be used by authentication objects wishing to use HTTP Basic * Most of the digest logic is handled, implementors just need to worry about @@ -19,8 +20,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBasic implements BackendInterface { - +abstract class AbstractBasic implements BackendInterface +{ /** * Authentication Realm. * @@ -39,13 +40,14 @@ abstract class AbstractBasic implements BackendInterface { protected $principalPrefix = 'principals/'; /** - * Validates a username and password + * Validates a username and password. * * This method should return true or false depending on if login * succeeded. * * @param string $username * @param string $password + * * @return bool */ abstract protected function validateUserPass($username, $password); @@ -54,12 +56,10 @@ abstract class AbstractBasic implements BackendInterface { * Sets the authentication realm for this backend. * * @param string $realm - * @return void */ - function setRealm($realm) { - + public function setRealm($realm) + { $this->realm = $realm; - } /** @@ -86,12 +86,13 @@ abstract class AbstractBasic implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Basic( $this->realm, $request, @@ -103,10 +104,10 @@ abstract class AbstractBasic implements BackendInterface { return [false, "No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured"]; } if (!$this->validateUserPass($userpass[0], $userpass[1])) { - return [false, "Username or password was incorrect"]; + return [false, 'Username or password was incorrect']; } - return [true, $this->principalPrefix . $userpass[0]]; + return [true, $this->principalPrefix.$userpass[0]]; } /** @@ -126,19 +127,16 @@ abstract class AbstractBasic implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Basic( $this->realm, $request, $response ); $auth->requireLogin(); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php index ae7a8a12f..a2653b2b0 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php @@ -1,14 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * HTTP Bearer authentication backend class + * HTTP Bearer authentication backend class. * * This class can be used by authentication objects wishing to use HTTP Bearer * Most of the digest logic is handled, implementors just need to worry about @@ -20,8 +21,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBearer implements BackendInterface { - +abstract class AbstractBearer implements BackendInterface +{ /** * Authentication Realm. * @@ -33,12 +34,13 @@ abstract class AbstractBearer implements BackendInterface { protected $realm = 'sabre/dav'; /** - * Validates a Bearer token + * Validates a Bearer token. * * This method should return the full principal url, or false if the * token was incorrect. * * @param string $bearerToken + * * @return string|false */ abstract protected function validateBearerToken($bearerToken); @@ -47,12 +49,10 @@ abstract class AbstractBearer implements BackendInterface { * Sets the authentication realm for this backend. * * @param string $realm - * @return void */ - function setRealm($realm) { - + public function setRealm($realm) + { $this->realm = $realm; - } /** @@ -79,12 +79,13 @@ abstract class AbstractBearer implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Bearer( $this->realm, $request, @@ -97,10 +98,10 @@ abstract class AbstractBearer implements BackendInterface { } $principalUrl = $this->validateBearerToken($bearerToken); if (!$principalUrl) { - return [false, "Bearer token was incorrect"]; + return [false, 'Bearer token was incorrect']; } - return [true, $principalUrl]; + return [true, $principalUrl]; } /** @@ -120,19 +121,16 @@ abstract class AbstractBearer implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Bearer( $this->realm, $request, $response ); $auth->requireLogin(); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php index 4b47f56c9..06c9ed3a4 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\DAV; @@ -8,7 +10,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * HTTP Digest authentication backend class + * HTTP Digest authentication backend class. * * This class can be used by authentication objects wishing to use HTTP Digest * Most of the digest logic is handled, implementors just need to worry about @@ -18,8 +20,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractDigest implements BackendInterface { - +abstract class AbstractDigest implements BackendInterface +{ /** * Authentication Realm. * @@ -45,12 +47,10 @@ abstract class AbstractDigest implements BackendInterface { * existing hashes will break and nobody can authenticate. * * @param string $realm - * @return void */ - function setRealm($realm) { - + public function setRealm($realm) + { $this->realm = $realm; - } /** @@ -60,9 +60,10 @@ abstract class AbstractDigest implements BackendInterface { * * @param string $realm * @param string $username + * * @return string|null */ - abstract function getDigestHash($realm, $username); + abstract public function getDigestHash($realm, $username); /** * When this method is called, the backend must check if authentication was @@ -88,12 +89,13 @@ abstract class AbstractDigest implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { $digest = new HTTP\Auth\Digest( $this->realm, $request, @@ -110,8 +112,8 @@ abstract class AbstractDigest implements BackendInterface { $hash = $this->getDigestHash($this->realm, $username); // If this was false, the user account didn't exist - if ($hash === false || is_null($hash)) { - return [false, "Username or password was incorrect"]; + if (false === $hash || is_null($hash)) { + return [false, 'Username or password was incorrect']; } if (!is_string($hash)) { throw new DAV\Exception('The returned value from getDigestHash must be a string or null'); @@ -119,11 +121,10 @@ abstract class AbstractDigest implements BackendInterface { // If this was false, the password or part of the hash was incorrect. if (!$digest->validateA1($hash)) { - return [false, "Username or password was incorrect"]; + return [false, 'Username or password was incorrect']; } - return [true, $this->principalPrefix . $username]; - + return [true, $this->principalPrefix.$username]; } /** @@ -143,12 +144,11 @@ abstract class AbstractDigest implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { $auth = new HTTP\Auth\Digest( $this->realm, $request, @@ -162,7 +162,5 @@ abstract class AbstractDigest implements BackendInterface { // Preventing the digest utility from modifying the http status code, // this should be handled by the main plugin. $response->setStatus($oldStatus); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php index e203d2685..201fe615c 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php @@ -1,24 +1,26 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * Apache authenticator + * Apache (or NGINX) authenticator. * * This authentication backend assumes that authentication has been - * configured in apache, rather than within SabreDAV. + * configured in apache (or NGINX), rather than within SabreDAV. * - * Make sure apache is properly configured for this to work. + * Make sure apache (or NGINX) is properly configured for this to work. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Apache implements BackendInterface { - +class Apache implements BackendInterface +{ /** * This is the prefix that will be used to generate principal urls. * @@ -50,22 +52,25 @@ class Apache implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { $remoteUser = $request->getRawServerValue('REMOTE_USER'); if (is_null($remoteUser)) { $remoteUser = $request->getRawServerValue('REDIRECT_REMOTE_USER'); } if (is_null($remoteUser)) { - return [false, 'No REMOTE_USER property was found in the PHP $_SERVER super-global. This likely means your server is not configured correctly']; + $remoteUser = $request->getRawServerValue('PHP_AUTH_USER'); + } + if (is_null($remoteUser)) { + return [false, 'No REMOTE_USER, REDIRECT_REMOTE_USER, or PHP_AUTH_USER property was found in the PHP $_SERVER super-global. This likely means your server is not configured correctly']; } - return [true, $this->principalPrefix . $remoteUser]; - + return [true, $this->principalPrefix.$remoteUser]; } /** @@ -85,12 +90,10 @@ class Apache implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php index 0fb2210f4..8598791fb 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP\RequestInterface; @@ -12,8 +14,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * When this method is called, the backend must check if authentication was * successful. @@ -38,11 +40,12 @@ interface BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response); + public function check(RequestInterface $request, ResponseInterface $response); /** * This method is called when a user could not be authenticated, and @@ -61,10 +64,8 @@ interface BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response); - + public function challenge(RequestInterface $request, ResponseInterface $response); } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php index 7ad8f48b2..aab3c5e1c 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; /** @@ -14,10 +16,10 @@ namespace Sabre\DAV\Auth\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class BasicCallBack extends AbstractBasic { - +class BasicCallBack extends AbstractBasic +{ /** - * Callback + * Callback. * * @var callable */ @@ -30,29 +32,27 @@ class BasicCallBack extends AbstractBasic { * password. * * @param callable $callBack - * @return void */ - function __construct(callable $callBack) { - + public function __construct(callable $callBack) + { $this->callBack = $callBack; - } /** - * Validates a username and password + * Validates a username and password. * * This method should return true or false depending on if login * succeeded. * * @param string $username * @param string $password + * * @return bool */ - protected function validateUserPass($username, $password) { - + protected function validateUserPass($username, $password) + { $cb = $this->callBack; - return $cb($username, $password); + return $cb($username, $password); } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php index 3a687d747..ea2d39679 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\DAV; @@ -13,10 +15,10 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends AbstractDigest { - +class File extends AbstractDigest +{ /** - * List of users + * List of users. * * @var array */ @@ -29,11 +31,11 @@ class File extends AbstractDigest { * * @param string|null $filename */ - function __construct($filename = null) { - - if (!is_null($filename)) + public function __construct($filename = null) + { + if (!is_null($filename)) { $this->loadFile($filename); - + } } /** @@ -41,37 +43,32 @@ class File extends AbstractDigest { * more than 1 file is used. * * @param string $filename - * @return void */ - function loadFile($filename) { - + public function loadFile($filename) + { foreach (file($filename, FILE_IGNORE_NEW_LINES) as $line) { - - if (substr_count($line, ":") !== 2) + if (2 !== substr_count($line, ':')) { throw new DAV\Exception('Malformed htdigest file. Every line should contain 2 colons'); - + } list($username, $realm, $A1) = explode(':', $line); - if (!preg_match('/^[a-zA-Z0-9]{32}$/', $A1)) + if (!preg_match('/^[a-zA-Z0-9]{32}$/', $A1)) { throw new DAV\Exception('Malformed htdigest file. Invalid md5 hash'); - - $this->users[$realm . ':' . $username] = $A1; - + } + $this->users[$realm.':'.$username] = $A1; } - } /** - * Returns a users' information + * Returns a users' information. * * @param string $realm * @param string $username + * * @return string */ - function getDigestHash($realm, $username) { - - return isset($this->users[$realm . ':' . $username]) ? $this->users[$realm . ':' . $username] : false; - + public function getDigestHash($realm, $username) + { + return isset($this->users[$realm.':'.$username]) ? $this->users[$realm.':'.$username] : false; } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php new file mode 100644 index 000000000..3a1831116 --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php @@ -0,0 +1,82 @@ +<?php + +namespace Sabre\DAV\Auth\Backend; + +/** + * This is an authentication backend that uses imap. + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @author Michael Niewöhner (foss@mniewoehner.de) + * @author rosali (https://github.com/rosali) + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class IMAP extends AbstractBasic +{ + /** + * IMAP server in the form {host[:port][/flag1/flag2...]}. + * + * @see http://php.net/manual/en/function.imap-open.php + * + * @var string + */ + protected $mailbox; + + /** + * Creates the backend object. + * + * @param string $mailbox + */ + public function __construct($mailbox) + { + $this->mailbox = $mailbox; + } + + /** + * Connects to an IMAP server and tries to authenticate. + * + * @param string $username + * @param string $password + * + * @return bool + */ + protected function imapOpen($username, $password) + { + $success = false; + + try { + $imap = imap_open($this->mailbox, $username, $password, OP_HALFOPEN | OP_READONLY, 1); + if ($imap) { + $success = true; + } + } catch (\ErrorException $e) { + error_log($e->getMessage()); + } + + $errors = imap_errors(); + if ($errors) { + foreach ($errors as $error) { + error_log($error); + } + } + + if (isset($imap) && $imap) { + imap_close($imap); + } + + return $success; + } + + /** + * Validates a username and password by trying to authenticate against IMAP. + * + * @param string $username + * @param string $password + * + * @return bool + */ + protected function validateUserPass($username, $password) + { + return $this->imapOpen($username, $password); + } +} diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php index c2f6de974..87ead6fcd 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; /** @@ -9,23 +11,22 @@ namespace Sabre\DAV\Auth\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractDigest { - +class PDO extends AbstractDigest +{ /** - * Reference to PDO connection + * Reference to PDO connection. * * @var PDO */ protected $pdo; /** - * PDO table name we'll be using + * PDO table name we'll be using. * * @var string */ public $tableName = 'users'; - /** * Creates the backend object. * @@ -33,10 +34,9 @@ class PDO extends AbstractDigest { * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -44,14 +44,14 @@ class PDO extends AbstractDigest { * * @param string $realm * @param string $username + * * @return string|null */ - function getDigestHash($realm, $username) { - - $stmt = $this->pdo->prepare('SELECT digesta1 FROM ' . $this->tableName . ' WHERE username = ?'); + public function getDigestHash($realm, $username) + { + $stmt = $this->pdo->prepare('SELECT digesta1 FROM '.$this->tableName.' WHERE username = ?'); $stmt->execute([$username]); - return $stmt->fetchColumn() ?: null; + return $stmt->fetchColumn() ?: null; } - } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Plugin.php b/vendor/sabre/dav/lib/DAV/Auth/Plugin.php index bbb5d180d..9be90283f 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth; use Sabre\DAV\Exception\NotAuthenticated; @@ -22,8 +24,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ /** * By default this plugin will require that the user is authenticated, * and refuse any access if the user is not authenticated. @@ -39,7 +41,7 @@ class Plugin extends ServerPlugin { public $autoRequireLogin = true; /** - * authentication backends + * authentication backends. */ protected $backends; @@ -52,40 +54,35 @@ class Plugin extends ServerPlugin { protected $currentPrincipal; /** - * Creates the authentication plugin + * Creates the authentication plugin. * * @param Backend\BackendInterface $authBackend */ - function __construct(Backend\BackendInterface $authBackend = null) { - + public function __construct(Backend\BackendInterface $authBackend = null) + { if (!is_null($authBackend)) { $this->addBackend($authBackend); } - } /** * Adds an authentication backend to the plugin. * * @param Backend\BackendInterface $authBackend - * @return void */ - function addBackend(Backend\BackendInterface $authBackend) { - + public function addBackend(Backend\BackendInterface $authBackend) + { $this->backends[] = $authBackend; - } /** - * Initializes the plugin. This function is automatically called by the server + * Initializes the plugin. This function is automatically called by the server. * * @param Server $server - * @return void */ - function initialize(Server $server) { - - $server->on('beforeMethod', [$this, 'beforeMethod'], 10); - + public function initialize(Server $server) + { + $server->on('beforeMethod:*', [$this, 'beforeMethod'], 10); } /** @@ -96,10 +93,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'auth'; - } /** @@ -114,23 +110,22 @@ class Plugin extends ServerPlugin { * * @return string|null */ - function getCurrentPrincipal() { - + public function getCurrentPrincipal() + { return $this->currentPrincipal; - } /** - * This method is called before any HTTP method and forces users to be authenticated + * This method is called before any HTTP method and forces users to be authenticated. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function beforeMethod(RequestInterface $request, ResponseInterface $response) { - + public function beforeMethod(RequestInterface $request, ResponseInterface $response) + { if ($this->currentPrincipal) { - // We already have authentication information. This means that the // event has already fired earlier, and is now likely fired for a // sub-request. @@ -144,7 +139,6 @@ class Plugin extends ServerPlugin { // // See issue #580 for more information about that. return; - } $authResult = $this->check($request, $response); @@ -153,11 +147,10 @@ class Plugin extends ServerPlugin { // Auth was successful $this->currentPrincipal = $authResult[1]; $this->loginFailedReasons = null; + return; } - - // If we got here, it means that no authentication backend was // successful in authenticating the user. $this->currentPrincipal = null; @@ -167,7 +160,6 @@ class Plugin extends ServerPlugin { $this->challenge($request, $response); throw new NotAuthenticated(implode(', ', $authResult[1])); } - } /** @@ -184,24 +176,24 @@ class Plugin extends ServerPlugin { * unsuccessful. For every auth backend there will be one reason, so usually * there's just one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { if (!$this->backends) { throw new \Sabre\DAV\Exception('No authentication backends were configured on this server.'); } $reasons = []; foreach ($this->backends as $backend) { - $result = $backend->check( $request, $response ); - if (!is_array($result) || count($result) !== 2 || !is_bool($result[0]) || !is_string($result[1])) { + if (!is_array($result) || 2 !== count($result) || !is_bool($result[0]) || !is_string($result[1])) { throw new \Sabre\DAV\Exception('The authentication backend did not return a correct value from the check() method.'); } @@ -211,11 +203,9 @@ class Plugin extends ServerPlugin { return [true, $result[1]]; } $reasons[] = $result[1]; - } return [false, $reasons]; - } /** @@ -225,16 +215,16 @@ class Plugin extends ServerPlugin { * WWW-Authorization header, indicating to the client that it should * authenticate. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { foreach ($this->backends as $backend) { $backend->challenge($request, $response); } - } /** @@ -255,10 +245,9 @@ class Plugin extends ServerPlugin { * * @return string[]|null */ - function getLoginFailedReasons() { - + public function getLoginFailedReasons() + { return $this->loginFailedReasons; - } /** @@ -272,14 +261,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Generic authentication plugin', - 'link' => 'http://sabre.io/dav/authentication/', + 'link' => 'http://sabre.io/dav/authentication/', ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php b/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php index 3ba2aee25..7466babb3 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php +++ b/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php @@ -1,14 +1,16 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; -use Sabre\DAV\Inode; +use Sabre\DAV\INode; use Sabre\DAV\PropFind; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * GuessContentType plugin + * GuessContentType plugin. * * A lot of the built-in File objects just return application/octet-stream * as a content-type by default. This is a problem for some clients, because @@ -22,17 +24,16 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class GuessContentType extends DAV\ServerPlugin { - +class GuessContentType extends DAV\ServerPlugin +{ /** - * List of recognized file extensions + * List of recognized file extensions. * * Feel free to add more * * @var array */ public $extensionMap = [ - // images 'jpg' => 'image/jpeg', 'gif' => 'image/gif', @@ -44,58 +45,52 @@ class GuessContentType extends DAV\ServerPlugin { // text 'txt' => 'text/plain', - ]; /** - * Initializes the plugin + * Initializes the plugin. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { // Using a relatively low priority (200) to allow other extensions // to set the content-type first. $server->on('propFind', [$this, 'propFind'], 200); - } /** - * Our PROPFIND handler + * Our PROPFIND handler. * * Here we set a contenttype, if the node didn't already have one. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - - $propFind->handle('{DAV:}getcontenttype', function() use ($propFind) { + public function propFind(PropFind $propFind, INode $node) + { + $propFind->handle('{DAV:}getcontenttype', function () use ($propFind) { + list(, $fileName) = Uri\split($propFind->getPath()); - list(, $fileName) = URLUtil::splitPath($propFind->getPath()); return $this->getContentType($fileName); - }); - } /** - * Simple method to return the contenttype + * Simple method to return the contenttype. * * @param string $fileName + * * @return string */ - protected function getContentType($fileName) { - + protected function getContentType($fileName) + { // Just grabbing the extension $extension = strtolower(substr($fileName, strrpos($fileName, '.') + 1)); if (isset($this->extensionMap[$extension])) { return $this->extensionMap[$extension]; } - return 'application/octet-stream'; + return 'application/octet-stream'; } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php b/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php index f4be6b348..59b3f5604 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php +++ b/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; /** @@ -13,8 +15,8 @@ namespace Sabre\DAV\Browser; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface HtmlOutput { - +interface HtmlOutput +{ /** * Generate html representation for this value. * @@ -27,8 +29,8 @@ interface HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html); - + public function toHtml(HtmlOutputHelper $html); } diff --git a/vendor/sabre/dav/lib/DAV/Browser/HtmlOutputHelper.php b/vendor/sabre/dav/lib/DAV/Browser/HtmlOutputHelper.php index 249d54047..a7c747437 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/HtmlOutputHelper.php +++ b/vendor/sabre/dav/lib/DAV/Browser/HtmlOutputHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\Uri; @@ -13,8 +15,8 @@ use Sabre\Xml\Service as XmlService; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class HtmlOutputHelper { - +class HtmlOutputHelper +{ /** * Link to the root of the application. * @@ -40,13 +42,12 @@ class HtmlOutputHelper { * that can be used to make output a lot shorter. * * @param string $baseUri - * @param array $namespaceMap + * @param array $namespaceMap */ - function __construct($baseUri, array $namespaceMap) { - + public function __construct($baseUri, array $namespaceMap) + { $this->baseUri = $baseUri; $this->namespaceMap = $namespaceMap; - } /** @@ -58,24 +59,24 @@ class HtmlOutputHelper { * Absolute urls are left alone. * * @param string $path + * * @return string */ - function fullUrl($path) { - + public function fullUrl($path) + { return Uri\resolve($this->baseUri, $path); - } /** * Escape string for HTML output. * - * @param string $input + * @param scalar $input + * * @return string */ - function h($input) { - - return htmlspecialchars($input, ENT_COMPAT, 'UTF-8'); - + public function h($input) + { + return htmlspecialchars((string) $input, ENT_COMPAT, 'UTF-8'); } /** @@ -86,13 +87,14 @@ class HtmlOutputHelper { * * @param string $url * @param string $label + * * @return string */ - function link($url, $label = null) { - + public function link($url, $label = null) + { $url = $this->h($this->fullUrl($url)); - return '<a href="' . $url . '">' . ($label ? $this->h($label) : $url) . '</a>'; + return '<a href="'.$url.'">'.($label ? $this->h($label) : $url).'</a>'; } /** @@ -100,18 +102,18 @@ class HtmlOutputHelper { * shortened version with a prefix, if it was a known namespace. * * @param string $element + * * @return string */ - function xmlName($element) { - + public function xmlName($element) + { list($ns, $localName) = XmlService::parseClarkNotation($element); if (isset($this->namespaceMap[$ns])) { - $propName = $this->namespaceMap[$ns] . ':' . $localName; + $propName = $this->namespaceMap[$ns].':'.$localName; } else { $propName = $element; } - return "<span title=\"" . $this->h($element) . "\">" . $this->h($propName) . "</span>"; + return '<span title="'.$this->h($element).'">'.$this->h($propName).'</span>'; } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php b/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php index 61327c49a..25e061128 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php +++ b/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; @@ -16,45 +18,46 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MapGetToPropFind extends DAV\ServerPlugin { - +class MapGetToPropFind extends DAV\ServerPlugin +{ /** - * reference to server class + * reference to server class. * * @var DAV\Server */ protected $server; /** - * Initializes the plugin and subscribes to events + * Initializes the plugin and subscribes to events. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->on('method:GET', [$this, 'httpGet'], 90); } /** - * This method intercepts GET requests to non-files, and changes it into an HTTP PROPFIND request + * This method intercepts GET requests to non-files, and changes it into an HTTP PROPFIND request. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $node = $this->server->tree->getNodeForPath($request->getPath()); - if ($node instanceof DAV\IFile) return; + if ($node instanceof DAV\IFile) { + return; + } $subRequest = clone $request; $subRequest->setMethod('PROPFIND'); $this->server->invokeMethod($subRequest, $response); - return false; + return false; } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/Plugin.php b/vendor/sabre/dav/lib/DAV/Browser/Plugin.php index 545ad5633..e2fab4b79 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Browser/Plugin.php @@ -1,15 +1,18 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; use Sabre\DAV\MkCol; +use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * Browser Plugin + * Browser Plugin. * * This plugin provides a html representation, so that a WebDAV server may be accessed * using a browser. @@ -21,10 +24,10 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * reference to server class + * reference to server class. * * @var DAV\Server */ @@ -60,53 +63,54 @@ class Plugin extends DAV\ServerPlugin { * * @param bool $enablePost */ - function __construct($enablePost = true) { - + public function __construct($enablePost = true) + { $this->enablePost = $enablePost; - } /** - * Initializes the plugin and subscribes to events + * Initializes the plugin and subscribes to events. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->on('method:GET', [$this, 'httpGetEarly'], 90); $this->server->on('method:GET', [$this, 'httpGet'], 200); $this->server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel'], 200); - if ($this->enablePost) $this->server->on('method:POST', [$this, 'httpPOST']); + if ($this->enablePost) { + $this->server->on('method:POST', [$this, 'httpPOST']); + } } /** * This method intercepts GET requests that have ?sabreAction=info - * appended to the URL + * appended to the URL. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGetEarly(RequestInterface $request, ResponseInterface $response) { - + public function httpGetEarly(RequestInterface $request, ResponseInterface $response) + { $params = $request->getQueryParameters(); - if (isset($params['sabreAction']) && $params['sabreAction'] === 'info') { + if (isset($params['sabreAction']) && 'info' === $params['sabreAction']) { return $this->httpGet($request, $response); } - } /** - * This method intercepts GET requests to collections and returns the html + * This method intercepts GET requests to collections and returns the html. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { // We're not using straight-up $_GET, because we want everything to be // unit testable. $getVars = $request->getQueryParameters(); @@ -117,13 +121,13 @@ class Plugin extends DAV\ServerPlugin { $sabreAction = isset($getVars['sabreAction']) ? $getVars['sabreAction'] : null; switch ($sabreAction) { - - case 'asset' : + case 'asset': // Asset handling, such as images $this->serveAsset(isset($getVars['assetName']) ? $getVars['assetName'] : null); + return false; - default : - case 'info' : + default: + case 'info': try { $this->server->tree->getNodeForPath($request->getPath()); } catch (DAV\Exception\NotFound $e) { @@ -141,7 +145,7 @@ class Plugin extends DAV\ServerPlugin { return false; - case 'plugins' : + case 'plugins': $response->setStatus(200); $response->setHeader('Content-Type', 'text/html; charset=utf-8'); @@ -150,41 +154,39 @@ class Plugin extends DAV\ServerPlugin { ); return false; - } - } /** * Handles POST requests for tree operations. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpPOST(RequestInterface $request, ResponseInterface $response) { - + public function httpPOST(RequestInterface $request, ResponseInterface $response) + { $contentType = $request->getHeader('Content-Type'); list($contentType) = explode(';', $contentType); - if ($contentType !== 'application/x-www-form-urlencoded' && - $contentType !== 'multipart/form-data') { - return; + if ('application/x-www-form-urlencoded' !== $contentType && + 'multipart/form-data' !== $contentType) { + return; } $postVars = $request->getPostData(); - if (!isset($postVars['sabreAction'])) + if (!isset($postVars['sabreAction'])) { return; + } $uri = $request->getPath(); if ($this->server->emit('onBrowserPostAction', [$uri, $postVars['sabreAction'], $postVars])) { - switch ($postVars['sabreAction']) { - - case 'mkcol' : + case 'mkcol': if (isset($postVars['name']) && trim($postVars['name'])) { // Using basename() because we won't allow slashes - list(, $folderName) = URLUtil::splitPath(trim($postVars['name'])); + list(, $folderName) = Uri\split(trim($postVars['name'])); if (isset($postVars['resourceType'])) { $resourceType = explode(',', $postVars['resourceType']); @@ -196,7 +198,7 @@ class Plugin extends DAV\ServerPlugin { foreach ($postVars as $varName => $varValue) { // Any _POST variable in clark notation is treated // like a property. - if ($varName[0] === '{') { + if ('{' === $varName[0]) { // PHP will convert any dots to underscores. // This leaves us with no way to differentiate // the two. @@ -212,65 +214,67 @@ class Plugin extends DAV\ServerPlugin { $resourceType, $properties ); - $this->server->createCollection($uri . '/' . $folderName, $mkCol); + $this->server->createCollection($uri.'/'.$folderName, $mkCol); } break; // @codeCoverageIgnoreStart - case 'put' : + case 'put': - if ($_FILES) $file = current($_FILES); - else break; + if ($_FILES) { + $file = current($_FILES); + } else { + break; + } - list(, $newName) = URLUtil::splitPath(trim($file['name'])); - if (isset($postVars['name']) && trim($postVars['name'])) + list(, $newName) = Uri\split(trim($file['name'])); + if (isset($postVars['name']) && trim($postVars['name'])) { $newName = trim($postVars['name']); + } // Making sure we only have a 'basename' component - list(, $newName) = URLUtil::splitPath($newName); + list(, $newName) = Uri\split($newName); if (is_uploaded_file($file['tmp_name'])) { - $this->server->createFile($uri . '/' . $newName, fopen($file['tmp_name'], 'r')); + $this->server->createFile($uri.'/'.$newName, fopen($file['tmp_name'], 'r')); } break; // @codeCoverageIgnoreEnd - } - } $response->setHeader('Location', $request->getUrl()); $response->setStatus(302); - return false; + return false; } /** * Escapes a string for html. * * @param string $value + * * @return string */ - function escapeHTML($value) { - + public function escapeHTML($value) + { return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); - } /** - * Generates the html directory index for a given url + * Generates the html directory index for a given url. * * @param string $path + * * @return string */ - function generateDirectoryIndex($path) { - + public function generateDirectoryIndex($path) + { $html = $this->generateHeader($path ? $path : '/', $path); $node = $this->server->tree->getNodeForPath($path); if ($node instanceof DAV\ICollection) { - $html .= "<section><h1>Nodes</h1>\n"; - $html .= "<table class=\"nodeTable\">"; + $html .= '<table class="nodeTable">'; $subNodes = $this->server->getPropertiesForChildren($path, [ '{DAV:}displayname', @@ -281,10 +285,9 @@ class Plugin extends DAV\ServerPlugin { ]); foreach ($subNodes as $subPath => $subProps) { - $subNode = $this->server->tree->getNodeForPath($subPath); - $fullPath = $this->server->getBaseUri() . URLUtil::encodePath($subPath); - list(, $displayPath) = URLUtil::splitPath($subPath); + $fullPath = $this->server->getBaseUri().HTTP\encodePath($subPath); + list(, $displayPath) = Uri\split($subPath); $subNodes[$subPath]['subNode'] = $subNode; $subNodes[$subPath]['fullPath'] = $fullPath; @@ -295,43 +298,46 @@ class Plugin extends DAV\ServerPlugin { foreach ($subNodes as $subProps) { $type = [ 'string' => 'Unknown', - 'icon' => 'cog', + 'icon' => 'cog', ]; if (isset($subProps['{DAV:}resourcetype'])) { $type = $this->mapResourceType($subProps['{DAV:}resourcetype']->getValue(), $subProps['subNode']); } $html .= '<tr>'; - $html .= '<td class="nameColumn"><a href="' . $this->escapeHTML($subProps['fullPath']) . '"><span class="oi" data-glyph="' . $this->escapeHTML($type['icon']) . '"></span> ' . $this->escapeHTML($subProps['displayPath']) . '</a></td>'; - $html .= '<td class="typeColumn">' . $this->escapeHTML($type['string']) . '</td>'; + $html .= '<td class="nameColumn"><a href="'.$this->escapeHTML($subProps['fullPath']).'"><span class="oi" data-glyph="'.$this->escapeHTML($type['icon']).'"></span> '.$this->escapeHTML($subProps['displayPath']).'</a></td>'; + $html .= '<td class="typeColumn">'.$this->escapeHTML($type['string']).'</td>'; $html .= '<td>'; if (isset($subProps['{DAV:}getcontentlength'])) { - $html .= $this->escapeHTML($subProps['{DAV:}getcontentlength'] . ' bytes'); + $html .= $this->escapeHTML($subProps['{DAV:}getcontentlength'].' bytes'); } $html .= '</td><td>'; if (isset($subProps['{DAV:}getlastmodified'])) { $lastMod = $subProps['{DAV:}getlastmodified']->getTime(); $html .= $this->escapeHTML($lastMod->format('F j, Y, g:i a')); } + $html .= '</td><td>'; + if (isset($subProps['{DAV:}displayname'])) { + $html .= $this->escapeHTML($subProps['{DAV:}displayname']); + } $html .= '</td>'; $buttonActions = ''; if ($subProps['subNode'] instanceof DAV\IFile) { - $buttonActions = '<a href="' . $this->escapeHTML($subProps['fullPath']) . '?sabreAction=info"><span class="oi" data-glyph="info"></span></a>'; + $buttonActions = '<a href="'.$this->escapeHTML($subProps['fullPath']).'?sabreAction=info"><span class="oi" data-glyph="info"></span></a>'; } $this->server->emit('browserButtonActions', [$subProps['fullPath'], $subProps['subNode'], &$buttonActions]); - $html .= '<td>' . $buttonActions . '</td>'; + $html .= '<td>'.$buttonActions.'</td>'; $html .= '</tr>'; } $html .= '</table>'; - } - $html .= "</section>"; - $html .= "<section><h1>Properties</h1>"; - $html .= "<table class=\"propTable\">"; + $html .= '</section>'; + $html .= '<section><h1>Properties</h1>'; + $html .= '<table class="propTable">'; // Allprops request $propFind = new PropFindAll($path); @@ -343,12 +349,10 @@ class Plugin extends DAV\ServerPlugin { if (!in_array($propName, $this->uninterestingProperties)) { $html .= $this->drawPropertyRow($propName, $propValue); } - } - - $html .= "</table>"; - $html .= "</section>"; + $html .= '</table>'; + $html .= '</section>'; /* Start of generating actions */ @@ -358,8 +362,7 @@ class Plugin extends DAV\ServerPlugin { } if ($output) { - - $html .= "<section><h1>Actions</h1>"; + $html .= '<section><h1>Actions</h1>'; $html .= "<div class=\"actions\">\n"; $html .= $output; $html .= "</div>\n"; @@ -371,7 +374,6 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setHeader('Content-Security-Policy', "default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"); return $html; - } /** @@ -379,31 +381,30 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function generatePluginListing() { - + public function generatePluginListing() + { $html = $this->generateHeader('Plugins'); - $html .= "<section><h1>Plugins</h1>"; - $html .= "<table class=\"propTable\">"; + $html .= '<section><h1>Plugins</h1>'; + $html .= '<table class="propTable">'; foreach ($this->server->getPlugins() as $plugin) { $info = $plugin->getPluginInfo(); - $html .= '<tr><th>' . $info['name'] . '</th>'; - $html .= '<td>' . $info['description'] . '</td>'; + $html .= '<tr><th>'.$info['name'].'</th>'; + $html .= '<td>'.$info['description'].'</td>'; $html .= '<td>'; if (isset($info['link']) && $info['link']) { - $html .= '<a href="' . $this->escapeHTML($info['link']) . '"><span class="oi" data-glyph="book"></span></a>'; + $html .= '<a href="'.$this->escapeHTML($info['link']).'"><span class="oi" data-glyph="book"></span></a>'; } $html .= '</td></tr>'; } - $html .= "</table>"; - $html .= "</section>"; + $html .= '</table>'; + $html .= '</section>'; /* Start of generating actions */ $html .= $this->generateFooter(); return $html; - } /** @@ -414,22 +415,23 @@ class Plugin extends DAV\ServerPlugin { * * @param string $title * @param string $path + * * @return string */ - function generateHeader($title, $path = null) { - + public function generateHeader($title, $path = null) + { $version = ''; if (DAV\Server::$exposeVersion) { $version = DAV\Version::VERSION; } $vars = [ - 'title' => $this->escapeHTML($title), - 'favicon' => $this->escapeHTML($this->getAssetUrl('favicon.ico')), - 'style' => $this->escapeHTML($this->getAssetUrl('sabredav.css')), + 'title' => $this->escapeHTML($title), + 'favicon' => $this->escapeHTML($this->getAssetUrl('favicon.ico')), + 'style' => $this->escapeHTML($this->getAssetUrl('sabredav.css')), 'iconstyle' => $this->escapeHTML($this->getAssetUrl('openiconic/open-iconic.css')), - 'logo' => $this->escapeHTML($this->getAssetUrl('sabredav.png')), - 'baseUrl' => $this->server->getBaseUri(), + 'logo' => $this->escapeHTML($this->getAssetUrl('sabredav.png')), + 'baseUrl' => $this->server->getBaseUri(), ]; $html = <<<HTML @@ -453,20 +455,19 @@ class Plugin extends DAV\ServerPlugin { HTML; // If the path is empty, there's no parent. - if ($path) { - list($parentUri) = URLUtil::splitPath($path); - $fullPath = $this->server->getBaseUri() . URLUtil::encodePath($parentUri); - $html .= '<a href="' . $fullPath . '" class="btn">⇤ Go to parent</a>'; + if ($path) { + list($parentUri) = Uri\split($path); + $fullPath = $this->server->getBaseUri().HTTP\encodePath($parentUri); + $html .= '<a href="'.$fullPath.'" class="btn">⇤ Go to parent</a>'; } else { $html .= '<span class="btn disabled">⇤ Go to parent</span>'; } $html .= ' <a href="?sabreAction=plugins" class="btn"><span class="oi" data-glyph="puzzle-piece"></span> Plugins</a>'; - $html .= "</nav>"; + $html .= '</nav>'; return $html; - } /** @@ -476,18 +477,19 @@ HTML; * * @return string */ - function generateFooter() { - + public function generateFooter() + { $version = ''; if (DAV\Server::$exposeVersion) { $version = DAV\Version::VERSION; } + $year = date('Y'); + return <<<HTML -<footer>Generated by SabreDAV $version (c)2007-2016 <a href="http://sabre.io/">http://sabre.io/</a></footer> +<footer>Generated by SabreDAV $version (c)2007-$year <a href="http://sabre.io/">http://sabre.io/</a></footer> </body> </html> HTML; - } /** @@ -498,19 +500,20 @@ HTML; * creating new directories. * * @param DAV\INode $node - * @param mixed $output - * @param string $path - * @return void + * @param mixed $output + * @param string $path */ - function htmlActionsPanel(DAV\INode $node, &$output, $path) { - - if (!$node instanceof DAV\ICollection) + public function htmlActionsPanel(DAV\INode $node, &$output, $path) + { + if (!$node instanceof DAV\ICollection) { return; + } // We also know fairly certain that if an object is a non-extended // SimpleCollection, we won't need to show the panel either. - if (get_class($node) === 'Sabre\\DAV\\SimpleCollection') + if ('Sabre\\DAV\\SimpleCollection' === get_class($node)) { return; + } $output .= <<<HTML <form method="post" action=""> @@ -527,7 +530,6 @@ HTML; <input type="submit" value="upload" /> </form> HTML; - } /** @@ -535,32 +537,35 @@ HTML; * suiteable for http access. * * @param string $assetName + * * @return string */ - protected function getAssetUrl($assetName) { - - return $this->server->getBaseUri() . '?sabreAction=asset&assetName=' . urlencode($assetName); - + protected function getAssetUrl($assetName) + { + return $this->server->getBaseUri().'?sabreAction=asset&assetName='.urlencode($assetName); } /** * This method returns a local pathname to an asset. * * @param string $assetName + * * @throws DAV\Exception\NotFound + * * @return string */ - protected function getLocalAssetPath($assetName) { - - $assetDir = __DIR__ . '/assets/'; - $path = $assetDir . $assetName; + protected function getLocalAssetPath($assetName) + { + $assetDir = __DIR__.'/assets/'; + $path = $assetDir.$assetName; // Making sure people aren't trying to escape from the base path. $path = str_replace('\\', '/', $path); - if (strpos($path, '/../') !== false || strrchr($path, '/') === '/..') { + if (false !== strpos($path, '/../') || '/..' === strrchr($path, '/')) { throw new DAV\Exception\NotFound('Path does not exist, or escaping from the base path was detected'); } - if (strpos(realpath($path), realpath($assetDir)) === 0 && file_exists($path)) { + $realPath = realpath($path); + if ($realPath && 0 === strpos($realPath, realpath($assetDir)) && file_exists($path)) { return $path; } throw new DAV\Exception\NotFound('Path does not exist, or escaping from the base path was detected'); @@ -570,10 +575,9 @@ HTML; * This method reads an asset from disk and generates a full http response. * * @param string $assetName - * @return void */ - protected function serveAsset($assetName) { - + protected function serveAsset($assetName) + { $assetPath = $this->getLocalAssetPath($assetName); // Rudimentary mime type detection @@ -594,7 +598,6 @@ HTML; $this->server->httpResponse->setHeader('Cache-Control', 'public, max-age=1209600'); $this->server->httpResponse->setStatus(200); $this->server->httpResponse->setBody(fopen($assetPath, 'r')); - } /** @@ -603,10 +606,11 @@ HTML; * * @param array $a * @param array $b + * * @return int */ - protected function compareNodes($a, $b) { - + protected function compareNodes($a, $b) + { $typeA = (isset($a['{DAV:}resourcetype'])) ? (in_array('{DAV:}collection', $a['{DAV:}resourcetype']->getValue())) : false; @@ -619,29 +623,30 @@ HTML; if ($typeA === $typeB) { return strnatcasecmp($a['displayPath'], $b['displayPath']); } - return (($typeA < $typeB) ? 1 : -1); + return ($typeA < $typeB) ? 1 : -1; } /** * Maps a resource type to a human-readable string and icon. * - * @param array $resourceTypes + * @param array $resourceTypes * @param DAV\INode $node + * * @return array */ - private function mapResourceType(array $resourceTypes, $node) { - + private function mapResourceType(array $resourceTypes, $node) + { if (!$resourceTypes) { if ($node instanceof DAV\IFile) { return [ 'string' => 'File', - 'icon' => 'file', + 'icon' => 'file', ]; } else { return [ 'string' => 'Unknown', - 'icon' => 'cog', + 'icon' => 'cog', ]; } } @@ -649,53 +654,53 @@ HTML; $types = [ '{http://calendarserver.org/ns/}calendar-proxy-write' => [ 'string' => 'Proxy-Write', - 'icon' => 'people', + 'icon' => 'people', ], '{http://calendarserver.org/ns/}calendar-proxy-read' => [ 'string' => 'Proxy-Read', - 'icon' => 'people', + 'icon' => 'people', ], '{urn:ietf:params:xml:ns:caldav}schedule-outbox' => [ 'string' => 'Outbox', - 'icon' => 'inbox', + 'icon' => 'inbox', ], '{urn:ietf:params:xml:ns:caldav}schedule-inbox' => [ 'string' => 'Inbox', - 'icon' => 'inbox', + 'icon' => 'inbox', ], '{urn:ietf:params:xml:ns:caldav}calendar' => [ 'string' => 'Calendar', - 'icon' => 'calendar', + 'icon' => 'calendar', ], '{http://calendarserver.org/ns/}shared-owner' => [ 'string' => 'Shared', - 'icon' => 'calendar', + 'icon' => 'calendar', ], '{http://calendarserver.org/ns/}subscribed' => [ 'string' => 'Subscription', - 'icon' => 'calendar', + 'icon' => 'calendar', ], '{urn:ietf:params:xml:ns:carddav}directory' => [ 'string' => 'Directory', - 'icon' => 'globe', + 'icon' => 'globe', ], '{urn:ietf:params:xml:ns:carddav}addressbook' => [ 'string' => 'Address book', - 'icon' => 'book', + 'icon' => 'book', ], '{DAV:}principal' => [ 'string' => 'Principal', - 'icon' => 'person', + 'icon' => 'person', ], '{DAV:}collection' => [ 'string' => 'Collection', - 'icon' => 'folder', + 'icon' => 'folder', ], ]; $info = [ 'string' => [], - 'icon' => 'cog', + 'icon' => 'cog', ]; foreach ($resourceTypes as $k => $resourceType) { if (isset($types[$resourceType])) { @@ -713,42 +718,41 @@ HTML; $info['string'] = implode(', ', $info['string']); return $info; - } /** - * Draws a table row for a property + * Draws a table row for a property. * * @param string $name - * @param mixed $value + * @param mixed $value + * * @return string */ - private function drawPropertyRow($name, $value) { - + private function drawPropertyRow($name, $value) + { $html = new HtmlOutputHelper( $this->server->getBaseUri(), $this->server->xml->namespaceMap ); - return "<tr><th>" . $html->xmlName($name) . "</th><td>" . $this->drawPropertyValue($html, $value) . "</td></tr>"; - + return '<tr><th>'.$html->xmlName($name).'</th><td>'.$this->drawPropertyValue($html, $value).'</td></tr>'; } /** - * Draws a table row for a property + * Draws a table row for a property. * * @param HtmlOutputHelper $html - * @param mixed $value + * @param mixed $value + * * @return string */ - private function drawPropertyValue($html, $value) { - + private function drawPropertyValue($html, $value) + { if (is_scalar($value)) { return $html->h($value); } elseif ($value instanceof HtmlOutput) { return $value->toHtml($html); } elseif ($value instanceof \Sabre\Xml\XmlSerializable) { - // There's no default html output for this property, we're going // to output the actual xml serialization instead. $xml = $this->server->xml->write('{DAV:}root', $value, $this->server->getBaseUri()); @@ -756,12 +760,11 @@ HTML; // element. $xml = explode("\n", $xml); $xml = array_slice($xml, 2, -2); - return "<pre>" . $html->h(implode("\n", $xml)) . "</pre>"; + return '<pre>'.$html->h(implode("\n", $xml)).'</pre>'; } else { - return "<em>unknown</em>"; + return '<em>unknown</em>'; } - } /** @@ -772,10 +775,9 @@ HTML; * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'browser'; - } /** @@ -789,14 +791,12 @@ HTML; * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Generates HTML indexes and debug information for your sabre/dav server', - 'link' => 'http://sabre.io/dav/browser-plugin/', + 'link' => 'http://sabre.io/dav/browser-plugin/', ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Browser/PropFindAll.php b/vendor/sabre/dav/lib/DAV/Browser/PropFindAll.php index c14b7f2f9..34702bdd8 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/PropFindAll.php +++ b/vendor/sabre/dav/lib/DAV/Browser/PropFindAll.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV\PropFind; @@ -12,17 +14,16 @@ use Sabre\DAV\PropFind; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PropFindAll extends PropFind { - +class PropFindAll extends PropFind +{ /** - * Creates the PROPFIND object + * Creates the PROPFIND object. * * @param string $path */ - function __construct($path) { - + public function __construct($path) + { parent::__construct($path, []); - } /** @@ -44,11 +45,10 @@ class PropFindAll extends PropFind { * It's also possible to not pass a callback, but immediately pass a value * * @param string $propertyName - * @param mixed $valueOrCallBack - * @return void + * @param mixed $valueOrCallBack */ - function handle($propertyName, $valueOrCallBack) { - + public function handle($propertyName, $valueOrCallBack) + { if (is_callable($valueOrCallBack)) { $value = $valueOrCallBack(); } else { @@ -57,39 +57,36 @@ class PropFindAll extends PropFind { if (!is_null($value)) { $this->result[$propertyName] = [200, $value]; } - } /** - * Sets the value of the property + * Sets the value of the property. * * If status is not supplied, the status will default to 200 for non-null * properties, and 404 for null properties. * * @param string $propertyName - * @param mixed $value - * @param int $status - * @return void + * @param mixed $value + * @param int $status */ - function set($propertyName, $value, $status = null) { - + public function set($propertyName, $value, $status = null) + { if (is_null($status)) { $status = is_null($value) ? 404 : 200; } $this->result[$propertyName] = [$status, $value]; - } /** * Returns the current value for a property. * * @param string $propertyName + * * @return mixed */ - function get($propertyName) { - + public function get($propertyName) + { return isset($this->result[$propertyName]) ? $this->result[$propertyName][1] : null; - } /** @@ -99,12 +96,12 @@ class PropFindAll extends PropFind { * null will be returned. * * @param string $propertyName + * * @return int|null */ - function getStatus($propertyName) { - + public function getStatus($propertyName) + { return isset($this->result[$propertyName]) ? $this->result[$propertyName][0] : 404; - } /** @@ -113,11 +110,11 @@ class PropFindAll extends PropFind { * * @return array */ - function get404Properties() { - + public function get404Properties() + { $result = []; foreach ($this->result as $propertyName => $stuff) { - if ($stuff[0] === 404) { + if (404 === $stuff[0]) { $result[] = $propertyName; } } @@ -125,8 +122,7 @@ class PropFindAll extends PropFind { if (!$result) { $result[] = '{http://sabredav.org/ns}idk'; } - return $result; + return $result; } - } diff --git a/vendor/sabre/dav/lib/DAV/Client.php b/vendor/sabre/dav/lib/DAV/Client.php index 175ad1bc4..cfa24cd29 100644 --- a/vendor/sabre/dav/lib/DAV/Client.php +++ b/vendor/sabre/dav/lib/DAV/Client.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; use Sabre\Uri; /** - * SabreDAV DAV client + * SabreDAV DAV client. * * This client wraps around Curl to provide a convenient API to a WebDAV * server. @@ -17,8 +19,8 @@ use Sabre\Uri; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Client extends HTTP\Client { - +class Client extends HTTP\Client +{ /** * The xml service. * @@ -29,18 +31,19 @@ class Client extends HTTP\Client { public $xml; /** - * The elementMap + * The elementMap. * * This property is linked via reference to $this->xml->elementMap. * It's deprecated as of version 3.0.0, and should no longer be used. * * @deprecated + * * @var array */ public $propertyMap = []; /** - * Base URI + * Base URI. * * This URI will be used to resolve relative urls. * @@ -49,17 +52,17 @@ class Client extends HTTP\Client { protected $baseUri; /** - * Basic authentication + * Basic authentication. */ const AUTH_BASIC = 1; /** - * Digest authentication + * Digest authentication. */ const AUTH_DIGEST = 2; /** - * NTLM authentication + * NTLM authentication. */ const AUTH_NTLM = 4; @@ -69,12 +72,12 @@ class Client extends HTTP\Client { const ENCODING_IDENTITY = 1; /** - * Deflate encoding + * Deflate encoding. */ const ENCODING_DEFLATE = 2; /** - * Gzip encoding + * Gzip encoding. */ const ENCODING_GZIP = 4; @@ -84,14 +87,14 @@ class Client extends HTTP\Client { const ENCODING_ALL = 7; /** - * Content-encoding + * Content-encoding. * * @var int */ protected $encoding = self::ENCODING_IDENTITY; /** - * Constructor + * Constructor. * * Settings are provided through the 'settings' argument. The following * settings are supported: @@ -112,8 +115,8 @@ class Client extends HTTP\Client { * * @param array $settings */ - function __construct(array $settings) { - + public function __construct(array $settings) + { if (!isset($settings['baseUri'])) { throw new \InvalidArgumentException('A baseUri must be provided'); } @@ -146,8 +149,7 @@ class Client extends HTTP\Client { } $this->addCurlSetting(CURLOPT_HTTPAUTH, $curlType); - $this->addCurlSetting(CURLOPT_USERPWD, $userName . ':' . $password); - + $this->addCurlSetting(CURLOPT_USERPWD, $userName.':'.$password); } if (isset($settings['encoding'])) { @@ -166,16 +168,15 @@ class Client extends HTTP\Client { $this->addCurlSetting(CURLOPT_ENCODING, implode(',', $encodings)); } - $this->addCurlSetting(CURLOPT_USERAGENT, 'sabre-dav/' . Version::VERSION . ' (http://sabre.io/)'); + $this->addCurlSetting(CURLOPT_USERAGENT, 'sabre-dav/'.Version::VERSION.' (http://sabre.io/)'); $this->xml = new Xml\Service(); // BC - $this->propertyMap = & $this->xml->elementMap; - + $this->propertyMap = &$this->xml->elementMap; } /** - * Does a PROPFIND request + * Does a PROPFIND request. * * The list of requested properties must be specified as an array, in clark * notation. @@ -191,28 +192,28 @@ class Client extends HTTP\Client { * made to the server to also return all child resources. * * @param string $url - * @param array $properties - * @param int $depth + * @param array $properties + * @param int $depth + * * @return array */ - function propFind($url, array $properties, $depth = 0) { - + public function propFind($url, array $properties, $depth = 0) + { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->formatOutput = true; $root = $dom->createElementNS('DAV:', 'd:propfind'); $prop = $dom->createElement('d:prop'); foreach ($properties as $property) { - list( $namespace, $elementName ) = \Sabre\Xml\Service::parseClarkNotation($property); - if ($namespace === 'DAV:') { - $element = $dom->createElement('d:' . $elementName); + if ('DAV:' === $namespace) { + $element = $dom->createElement('d:'.$elementName); } else { - $element = $dom->createElementNS($namespace, 'x:' . $elementName); + $element = $dom->createElementNS($namespace, 'x:'.$elementName); } $prop->appendChild($element); @@ -224,49 +225,48 @@ class Client extends HTTP\Client { $url = $this->getAbsoluteUrl($url); $request = new HTTP\Request('PROPFIND', $url, [ - 'Depth' => $depth, - 'Content-Type' => 'application/xml' + 'Depth' => $depth, + 'Content-Type' => 'application/xml', ], $body); $response = $this->send($request); - if ((int)$response->getStatus() >= 400) { + if ((int) $response->getStatus() >= 400) { throw new HTTP\ClientHttpException($response); } $result = $this->parseMultiStatus($response->getBodyAsString()); // If depth was 0, we only return the top item - if ($depth === 0) { + if (0 === $depth) { reset($result); $result = current($result); + return isset($result[200]) ? $result[200] : []; } $newResult = []; foreach ($result as $href => $statusList) { - $newResult[$href] = isset($statusList[200]) ? $statusList[200] : []; - } return $newResult; - } /** - * Updates a list of properties on the server + * Updates a list of properties on the server. * * The list of properties must have clark-notation properties for the keys, * and the actual (string) value for the value. If the value is null, an * attempt is made to delete the property. * * @param string $url - * @param array $properties + * @param array $properties + * * @return bool */ - function propPatch($url, array $properties) { - + public function propPatch($url, array $properties) + { $propPatch = new Xml\Request\PropPatch(); $propPatch->properties = $properties; $xml = $this->xml->write( @@ -284,7 +284,7 @@ class Client extends HTTP\Client { throw new HTTP\ClientHttpException($response); } - if ($response->getStatus() === 207) { + if (207 === $response->getStatus()) { // If it's a 207, the request could still have failed, but the // information is hidden in the response body. $result = $this->parseMultiStatus($response->getBodyAsString()); @@ -292,26 +292,23 @@ class Client extends HTTP\Client { $errorProperties = []; foreach ($result as $href => $statusList) { foreach ($statusList as $status => $properties) { - if ($status >= 400) { foreach ($properties as $propName => $propValue) { - $errorProperties[] = $propName . ' (' . $status . ')'; + $errorProperties[] = $propName.' ('.$status.')'; } } - } } if ($errorProperties) { - - throw new HTTP\ClientException('PROPPATCH failed. The following properties errored: ' . implode(', ', $errorProperties)); + throw new HTTP\ClientException('PROPPATCH failed. The following properties errored: '.implode(', ', $errorProperties)); } } - return true; + return true; } /** - * Performs an HTTP options request + * Performs an HTTP options request. * * This method returns all the features from the 'DAV:' header as an array. * If there was no DAV header, or no contents this method will return an @@ -319,8 +316,8 @@ class Client extends HTTP\Client { * * @return array */ - function options() { - + public function options() + { $request = new HTTP\Request('OPTIONS', $this->getAbsoluteUrl('')); $response = $this->send($request); @@ -333,8 +330,8 @@ class Client extends HTTP\Client { foreach ($features as &$v) { $v = trim($v); } - return $features; + return $features; } /** @@ -359,24 +356,26 @@ class Client extends HTTP\Client { * Note that it is no longer recommended to use this method, use the send() * method instead. * - * @param string $method - * @param string $url + * @param string $method + * @param string $url * @param string|resource|null $body - * @param array $headers - * @throws ClientException, in case a curl error occurred. + * @param array $headers + * + * @throws clientException, in case a curl error occurred + * * @return array */ - function request($method, $url = '', $body = null, array $headers = []) { - + public function request($method, $url = '', $body = null, array $headers = []) + { $url = $this->getAbsoluteUrl($url); $response = $this->send(new HTTP\Request($method, $url, $headers, $body)); + return [ - 'body' => $response->getBodyAsString(), - 'statusCode' => (int)$response->getStatus(), - 'headers' => array_change_key_case($response->getHeaders()), + 'body' => $response->getBodyAsString(), + 'statusCode' => (int) $response->getStatus(), + 'headers' => array_change_key_case($response->getHeaders()), ]; - } /** @@ -384,19 +383,19 @@ class Client extends HTTP\Client { * urls are expanded based on the base url as given by the server. * * @param string $url + * * @return string */ - function getAbsoluteUrl($url) { - + public function getAbsoluteUrl($url) + { return Uri\resolve( $this->baseUri, $url ); - } /** - * Parses a WebDAV multistatus response body + * Parses a WebDAV multistatus response body. * * This method returns an array with the following structure * @@ -418,22 +417,19 @@ class Client extends HTTP\Client { * * * @param string $body xml body + * * @return array */ - function parseMultiStatus($body) { - + public function parseMultiStatus($body) + { $multistatus = $this->xml->expect('{DAV:}multistatus', $body); $result = []; foreach ($multistatus->getResponses() as $response) { - $result[$response->getHref()] = $response->getResponseProperties(); - } return $result; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Collection.php b/vendor/sabre/dav/lib/DAV/Collection.php index 35c90b5af..2728bb27e 100644 --- a/vendor/sabre/dav/lib/DAV/Collection.php +++ b/vendor/sabre/dav/lib/DAV/Collection.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * Collection class + * Collection class. * * This is a helper class, that should aid in getting collections classes setup. * Most of its methods are implemented, and throw permission denied exceptions @@ -12,8 +14,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Collection extends Node implements ICollection { - +abstract class Collection extends Node implements ICollection +{ /** * Returns a child object, by its name. * @@ -25,18 +27,19 @@ abstract class Collection extends Node implements ICollection { * exist. * * @param string $name + * * @throws Exception\NotFound + * * @return INode */ - function getChild($name) { - + public function getChild($name) + { foreach ($this->getChildren() as $child) { - - if ($child->getName() === $name) return $child; - + if ($child->getName() === $name) { + return $child; + } } - throw new Exception\NotFound('File not found: ' . $name); - + throw new Exception\NotFound('File not found: '.$name); } /** @@ -45,25 +48,22 @@ abstract class Collection extends Node implements ICollection { * It is generally a good idea to try and override this. Usually it can be optimized. * * @param string $name + * * @return bool */ - function childExists($name) { - + public function childExists($name) + { try { - $this->getChild($name); - return true; + return true; } catch (Exception\NotFound $e) { - return false; - } - } /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -82,28 +82,25 @@ abstract class Collection extends Node implements ICollection { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - - throw new Exception\Forbidden('Permission denied to create file (filename ' . $name . ')'); - + public function createFile($name, $data = null) + { + throw new Exception\Forbidden('Permission denied to create file (filename '.$name.')'); } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name + * * @throws Exception\Forbidden - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { throw new Exception\Forbidden('Permission denied to create directory'); - } - - } diff --git a/vendor/sabre/dav/lib/DAV/CorePlugin.php b/vendor/sabre/dav/lib/DAV/CorePlugin.php index 676cdd04a..ef1dfceb6 100644 --- a/vendor/sabre/dav/lib/DAV/CorePlugin.php +++ b/vendor/sabre/dav/lib/DAV/CorePlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\DAV\Exception\BadRequest; @@ -14,8 +16,8 @@ use Sabre\Xml\ParseException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CorePlugin extends ServerPlugin { - +class CorePlugin extends ServerPlugin +{ /** * Reference to server object. * @@ -24,34 +26,32 @@ class CorePlugin extends ServerPlugin { protected $server; /** - * Sets up the plugin + * Sets up the plugin. * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; - $server->on('method:GET', [$this, 'httpGet']); - $server->on('method:OPTIONS', [$this, 'httpOptions']); - $server->on('method:HEAD', [$this, 'httpHead']); - $server->on('method:DELETE', [$this, 'httpDelete']); - $server->on('method:PROPFIND', [$this, 'httpPropFind']); + $server->on('method:GET', [$this, 'httpGet']); + $server->on('method:OPTIONS', [$this, 'httpOptions']); + $server->on('method:HEAD', [$this, 'httpHead']); + $server->on('method:DELETE', [$this, 'httpDelete']); + $server->on('method:PROPFIND', [$this, 'httpPropFind']); $server->on('method:PROPPATCH', [$this, 'httpPropPatch']); - $server->on('method:PUT', [$this, 'httpPut']); - $server->on('method:MKCOL', [$this, 'httpMkcol']); - $server->on('method:MOVE', [$this, 'httpMove']); - $server->on('method:COPY', [$this, 'httpCopy']); - $server->on('method:REPORT', [$this, 'httpReport']); - - $server->on('propPatch', [$this, 'propPatchProtectedPropertyCheck'], 90); - $server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200); - $server->on('propFind', [$this, 'propFind']); - $server->on('propFind', [$this, 'propFindNode'], 120); - $server->on('propFind', [$this, 'propFindLate'], 200); - - $server->on('exception', [$this, 'exception']); - + $server->on('method:PUT', [$this, 'httpPut']); + $server->on('method:MKCOL', [$this, 'httpMkcol']); + $server->on('method:MOVE', [$this, 'httpMove']); + $server->on('method:COPY', [$this, 'httpCopy']); + $server->on('method:REPORT', [$this, 'httpReport']); + + $server->on('propPatch', [$this, 'propPatchProtectedPropertyCheck'], 90); + $server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200); + $server->on('propFind', [$this, 'propFind']); + $server->on('propFind', [$this, 'propFindNode'], 120); + $server->on('propFind', [$this, 'propFindLate'], 200); + + $server->on('exception', [$this, 'exception']); } /** @@ -62,34 +62,40 @@ class CorePlugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'core'; - } /** * This is the default implementation for the GET method. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $node = $this->server->tree->getNodeForPath($path); - if (!$node instanceof IFile) return; - - $body = $node->get(); + if (!$node instanceof IFile) { + return; + } - // Converting string into stream, if needed. - if (is_string($body)) { - $stream = fopen('php://temp', 'r+'); - fwrite($stream, $body); - rewind($stream); - $body = $stream; + if ('HEAD' === $request->getHeader('X-Sabre-Original-Method')) { + $body = ''; + } else { + $body = $node->get(); + + // Converting string into stream, if needed. + if (is_string($body)) { + $stream = fopen('php://temp', 'r+'); + fwrite($stream, $body); + rewind($stream); + $body = $stream; + } } /* @@ -105,14 +111,11 @@ class CorePlugin extends ServerPlugin { $httpHeaders['Content-Type'] = 'application/octet-stream'; } - if (isset($httpHeaders['Content-Length'])) { - $nodeSize = $httpHeaders['Content-Length']; // Need to unset Content-Length, because we'll handle that during figuring out the range unset($httpHeaders['Content-Length']); - } else { $nodeSize = null; } @@ -126,7 +129,6 @@ class CorePlugin extends ServerPlugin { // If ifRange is set, and range is specified, we first need to check // the precondition. if ($nodeSize && $range && $ifRange) { - // if IfRange is parsable as a date we'll treat it as a DateTime // otherwise, we must treat it as an etag. try { @@ -134,81 +136,87 @@ class CorePlugin extends ServerPlugin { // It's a date. We must check if the entity is modified since // the specified date. - if (!isset($httpHeaders['Last-Modified'])) $ignoreRangeHeader = true; - else { + if (!isset($httpHeaders['Last-Modified'])) { + $ignoreRangeHeader = true; + } else { $modified = new \DateTime($httpHeaders['Last-Modified']); - if ($modified > $ifRangeDate) $ignoreRangeHeader = true; + if ($modified > $ifRangeDate) { + $ignoreRangeHeader = true; + } } - } catch (\Exception $e) { - // It's an entity. We can do a simple comparison. - if (!isset($httpHeaders['ETag'])) $ignoreRangeHeader = true; - elseif ($httpHeaders['ETag'] !== $ifRange) $ignoreRangeHeader = true; + if (!isset($httpHeaders['ETag'])) { + $ignoreRangeHeader = true; + } elseif ($httpHeaders['ETag'] !== $ifRange) { + $ignoreRangeHeader = true; + } } } // We're only going to support HTTP ranges if the backend provided a filesize if (!$ignoreRangeHeader && $nodeSize && $range) { - // Determining the exact byte offsets if (!is_null($range[0])) { - $start = $range[0]; $end = $range[1] ? $range[1] : $nodeSize - 1; - if ($start >= $nodeSize) - throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $range[0] . ') exceeded the size of the entity (' . $nodeSize . ')'); - - if ($end < $start) throw new Exception\RequestedRangeNotSatisfiable('The end offset (' . $range[1] . ') is lower than the start offset (' . $range[0] . ')'); - if ($end >= $nodeSize) $end = $nodeSize - 1; - + if ($start >= $nodeSize) { + throw new Exception\RequestedRangeNotSatisfiable('The start offset ('.$range[0].') exceeded the size of the entity ('.$nodeSize.')'); + } + if ($end < $start) { + throw new Exception\RequestedRangeNotSatisfiable('The end offset ('.$range[1].') is lower than the start offset ('.$range[0].')'); + } + if ($end >= $nodeSize) { + $end = $nodeSize - 1; + } } else { - $start = $nodeSize - $range[1]; $end = $nodeSize - 1; - if ($start < 0) $start = 0; - + if ($start < 0) { + $start = 0; + } } // Streams may advertise themselves as seekable, but still not // actually allow fseek. We'll manually go forward in the stream // if fseek failed. - if (!stream_get_meta_data($body)['seekable'] || fseek($body, $start, SEEK_SET) === -1) { + if (!stream_get_meta_data($body)['seekable'] || -1 === fseek($body, $start, SEEK_SET)) { $consumeBlock = 8192; - for ($consumed = 0; $start - $consumed > 0;){ - if (feof($body)) throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $start . ') exceeded the size of the entity (' . $consumed . ')'); + for ($consumed = 0; $start - $consumed > 0;) { + if (feof($body)) { + throw new Exception\RequestedRangeNotSatisfiable('The start offset ('.$start.') exceeded the size of the entity ('.$consumed.')'); + } $consumed += strlen(fread($body, min($start - $consumed, $consumeBlock))); } } $response->setHeader('Content-Length', $end - $start + 1); - $response->setHeader('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $nodeSize); + $response->setHeader('Content-Range', 'bytes '.$start.'-'.$end.'/'.$nodeSize); $response->setStatus(206); $response->setBody($body); - } else { - - if ($nodeSize) $response->setHeader('Content-Length', $nodeSize); + if ($nodeSize) { + $response->setHeader('Content-Length', $nodeSize); + } $response->setStatus(200); $response->setBody($body); - } // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * HTTP OPTIONS + * HTTP OPTIONS. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpOptions(RequestInterface $request, ResponseInterface $response) { - + public function httpOptions(RequestInterface $request, ResponseInterface $response) + { $methods = $this->server->getAllowedMethods($request->getPath()); $response->setHeader('Allow', strtoupper(implode(', ', $methods))); @@ -227,31 +235,31 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * HTTP HEAD + * HTTP HEAD. * * This method is normally used to take a peak at a url, and only get the * HTTP response headers, without the body. This is used by clients to * determine if a remote file was changed, so they can use a local cached * version, instead of downloading it again * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpHead(RequestInterface $request, ResponseInterface $response) { - + public function httpHead(RequestInterface $request, ResponseInterface $response) + { // This is implemented by changing the HEAD request to a GET request, - // and dropping the response body. + // and telling the request handler that is doesn't need to create the body. $subRequest = clone $request; $subRequest->setMethod('GET'); + $subRequest->setHeader('X-Sabre-Original-Method', 'HEAD'); try { $this->server->invokeMethod($subRequest, $response, false); - $response->setBody(''); } catch (Exception\NotImplemented $e) { // Some clients may do HEAD requests on collections, however, GET // requests and HEAD requests _may_ not be defined on a collection, @@ -267,23 +275,23 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * HTTP Delete + * HTTP Delete. * * The HTTP delete method, deletes a given uri * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpDelete(RequestInterface $request, ResponseInterface $response) { - + public function httpDelete(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); - if (!$this->server->emit('beforeUnbind', [$path])) return false; + if (!$this->server->emit('beforeUnbind', [$path])) { + return false; + } $this->server->tree->delete($path); $this->server->emit('afterUnbind', [$path]); @@ -293,11 +301,10 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * WebDAV PROPFIND + * WebDAV PROPFIND. * * This WebDAV method requests information about an uri resource, or a list of resources * If a client wants to receive the properties for a single resource it will add an HTTP Depth: header with a 0 value @@ -308,12 +315,11 @@ class CorePlugin extends ServerPlugin { * * It has to return a HTTP 207 Multi-status status code * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpPropFind(RequestInterface $request, ResponseInterface $response) { - + public function httpPropFind(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $requestBody = $request->getBodyAsString(); @@ -321,7 +327,7 @@ class CorePlugin extends ServerPlugin { try { $propFindXml = $this->server->xml->expect('{DAV:}propfind', $requestBody); } catch (ParseException $e) { - throw new BadRequest($e->getMessage(), null, $e); + throw new BadRequest($e->getMessage(), 0, $e); } } else { $propFindXml = new Xml\Request\PropFind(); @@ -331,7 +337,9 @@ class CorePlugin extends ServerPlugin { $depth = $this->server->getHTTPDepth(1); // The only two options for the depth of a propfind is 0 or 1 - as long as depth infinity is not enabled - if (!$this->server->enablePropfindDepthInfinity && $depth != 0) $depth = 1; + if (!$this->server->enablePropfindDepthInfinity && 0 != $depth) { + $depth = 1; + } $newProperties = $this->server->getPropertiesIteratorForPath($path, $propFindXml->properties, $depth); @@ -350,7 +358,7 @@ class CorePlugin extends ServerPlugin { $response->setHeader('DAV', implode(', ', $features)); $prefer = $this->server->getHTTPPrefer(); - $minimal = $prefer['return'] === 'minimal'; + $minimal = 'minimal' === $prefer['return']; $data = $this->server->generateMultiStatus($newProperties, $minimal); $response->setBody($data); @@ -358,27 +366,27 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * WebDAV PROPPATCH + * WebDAV PROPPATCH. * * This method is called to update properties on a Node. The request is an XML body with all the mutations. * In this XML body it is specified which properties should be set/updated and/or deleted * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpPropPatch(RequestInterface $request, ResponseInterface $response) { - + public function httpPropPatch(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); try { $propPatch = $this->server->xml->expect('{DAV:}propertyupdate', $request->getBody()); } catch (ParseException $e) { - throw new BadRequest($e->getMessage(), null, $e); + throw new BadRequest($e->getMessage(), 0, $e); } $newProperties = $propPatch->properties; @@ -387,31 +395,27 @@ class CorePlugin extends ServerPlugin { $prefer = $this->server->getHTTPPrefer(); $response->setHeader('Vary', 'Brief,Prefer'); - if ($prefer['return'] === 'minimal') { - + if ('minimal' === $prefer['return']) { // If return-minimal is specified, we only have to check if the // request was successful, and don't need to return the // multi-status. $ok = true; foreach ($result as $prop => $code) { - if ((int)$code > 299) { + if ((int) $code > 299) { $ok = false; } } if ($ok) { - $response->setStatus(204); - return false; + return false; } - } $response->setStatus(207); $response->setHeader('Content-Type', 'application/xml; charset=utf-8'); - // Reorganizing the result for generateMultiStatus $multiStatus = []; foreach ($result as $propertyName => $code) { @@ -430,22 +434,22 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * HTTP PUT method + * HTTP PUT method. * * This HTTP method updates a file, or creates a new one. * * If a new resource was created, a 201 Created status code should be returned. If an existing resource is updated, it's a 204 No Content * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpPut(RequestInterface $request, ResponseInterface $response) { - + public function httpPut(RequestInterface $request, ResponseInterface $response) + { $body = $request->getBodyAsStream(); $path = $request->getPath(); @@ -463,7 +467,6 @@ class CorePlugin extends ServerPlugin { // Intercepting the Finder problem if (($expected = $request->getHeader('X-Expected-Entity-Length')) && $expected > 0) { - /* Many webservers will not cooperate well with Finder PUT requests, because it uses 'Chunked' transfer encoding for the request body. @@ -487,7 +490,7 @@ class CorePlugin extends ServerPlugin { // Only reading first byte $firstByte = fread($body, 1); - if (strlen($firstByte) !== 1) { + if (1 !== strlen($firstByte)) { throw new Exception\Forbidden('This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.'); } @@ -500,26 +503,25 @@ class CorePlugin extends ServerPlugin { rewind($newBody); $body = $newBody; - } if ($this->server->tree->nodeExists($path)) { - $node = $this->server->tree->getNodeForPath($path); // If the node is a collection, we'll deny it - if (!($node instanceof IFile)) throw new Exception\Conflict('PUT is not allowed on non-files.'); - + if (!($node instanceof IFile)) { + throw new Exception\Conflict('PUT is not allowed on non-files.'); + } if (!$this->server->updateFile($path, $body, $etag)) { return false; } $response->setHeader('Content-Length', '0'); - if ($etag) $response->setHeader('ETag', $etag); + if ($etag) { + $response->setHeader('ETag', $etag); + } $response->setStatus(204); - } else { - $etag = null; // If we got here, the resource didn't exist yet. if (!$this->server->createFile($path, $body, $etag)) { @@ -528,61 +530,55 @@ class CorePlugin extends ServerPlugin { } $response->setHeader('Content-Length', '0'); - if ($etag) $response->setHeader('ETag', $etag); + if ($etag) { + $response->setHeader('ETag', $etag); + } $response->setStatus(201); - } // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } - /** - * WebDAV MKCOL + * WebDAV MKCOL. * * The MKCOL method is used to create a new collection (directory) on the server * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpMkcol(RequestInterface $request, ResponseInterface $response) { - + public function httpMkcol(RequestInterface $request, ResponseInterface $response) + { $requestBody = $request->getBodyAsString(); $path = $request->getPath(); if ($requestBody) { - $contentType = $request->getHeader('Content-Type'); - if (strpos($contentType, 'application/xml') !== 0 && strpos($contentType, 'text/xml') !== 0) { - + if (null === $contentType || (0 !== strpos($contentType, 'application/xml') && 0 !== strpos($contentType, 'text/xml'))) { // We must throw 415 for unsupported mkcol bodies throw new Exception\UnsupportedMediaType('The request body for the MKCOL request must have an xml Content-Type'); - } try { $mkcol = $this->server->xml->expect('{DAV:}mkcol', $requestBody); } catch (\Sabre\Xml\ParseException $e) { - throw new Exception\BadRequest($e->getMessage(), null, $e); + throw new Exception\BadRequest($e->getMessage(), 0, $e); } $properties = $mkcol->getProperties(); - if (!isset($properties['{DAV:}resourcetype'])) + if (!isset($properties['{DAV:}resourcetype'])) { throw new Exception\BadRequest('The mkcol request must include a {DAV:}resourcetype property'); - + } $resourceType = $properties['{DAV:}resourcetype']->getValue(); unset($properties['{DAV:}resourcetype']); - } else { - $properties = []; $resourceType = ['{DAV:}collection']; - } $mkcol = new MkCol($resourceType, $properties); @@ -596,7 +592,6 @@ class CorePlugin extends ServerPlugin { $response->setBody( $this->server->generateMultiStatus([$result]) ); - } else { $response->setHeader('Content-Length', '0'); $response->setStatus(201); @@ -605,38 +600,42 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * WebDAV HTTP MOVE method + * WebDAV HTTP MOVE method. * * This method moves one uri to a different uri. A lot of the actual request processing is done in getCopyMoveInfo * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpMove(RequestInterface $request, ResponseInterface $response) { - + public function httpMove(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $moveInfo = $this->server->getCopyAndMoveInfo($request); if ($moveInfo['destinationExists']) { - - if (!$this->server->emit('beforeUnbind', [$moveInfo['destination']])) return false; - + if (!$this->server->emit('beforeUnbind', [$moveInfo['destination']])) { + return false; + } + } + if (!$this->server->emit('beforeUnbind', [$path])) { + return false; + } + if (!$this->server->emit('beforeBind', [$moveInfo['destination']])) { + return false; + } + if (!$this->server->emit('beforeMove', [$path, $moveInfo['destination']])) { + return false; } - if (!$this->server->emit('beforeUnbind', [$path])) return false; - if (!$this->server->emit('beforeBind', [$moveInfo['destination']])) return false; - if (!$this->server->emit('beforeMove', [$path, $moveInfo['destination']])) return false; if ($moveInfo['destinationExists']) { - $this->server->tree->delete($moveInfo['destination']); $this->server->emit('afterUnbind', [$moveInfo['destination']]); - } $this->server->tree->move($path, $moveInfo['destination']); @@ -656,28 +655,32 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** - * WebDAV HTTP COPY method + * WebDAV HTTP COPY method. * * This method copies one uri to a different uri, and works much like the MOVE request * A lot of the actual request processing is done in getCopyMoveInfo * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpCopy(RequestInterface $request, ResponseInterface $response) { - + public function httpCopy(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $copyInfo = $this->server->getCopyAndMoveInfo($request); - if (!$this->server->emit('beforeBind', [$copyInfo['destination']])) return false; + if (!$this->server->emit('beforeBind', [$copyInfo['destination']])) { + return false; + } if ($copyInfo['destinationExists']) { - if (!$this->server->emit('beforeUnbind', [$copyInfo['destination']])) return false; + if (!$this->server->emit('beforeUnbind', [$copyInfo['destination']])) { + return false; + } $this->server->tree->delete($copyInfo['destination']); } @@ -691,22 +694,21 @@ class CorePlugin extends ServerPlugin { // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - - } /** - * HTTP REPORT method implementation + * HTTP REPORT method implementation. * * Although the REPORT method is not part of the standard WebDAV spec (it's from rfc3253) * It's used in a lot of extensions, so it made sense to implement it into the core. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpReport(RequestInterface $request, ResponseInterface $response) { - + public function httpReport(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $result = $this->server->xml->parse( @@ -716,16 +718,13 @@ class CorePlugin extends ServerPlugin { ); if ($this->server->emit('report', [$rootElementName, $result, $path])) { - // If emit returned true, it means the report was not supported throw new Exception\ReportNotSupported(); - } // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false; - } /** @@ -734,12 +733,11 @@ class CorePlugin extends ServerPlugin { * Here we check if a user attempted to update a protected property and * ensure that the process fails if this is the case. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatchProtectedPropertyCheck($path, PropPatch $propPatch) { - + public function propPatchProtectedPropertyCheck($path, PropPatch $propPatch) + { // Comparing the mutation list to the list of protected properties. $mutations = $propPatch->getMutations(); @@ -751,7 +749,6 @@ class CorePlugin extends ServerPlugin { if ($protected) { $propPatch->setResultCode($protected, 403); } - } /** @@ -760,19 +757,17 @@ class CorePlugin extends ServerPlugin { * Here we check if a node implements IProperties and let the node handle * updating of (some) properties. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatchNodeUpdate($path, PropPatch $propPatch) { - + public function propPatchNodeUpdate($path, PropPatch $propPatch) + { // This should trigger a 404 if the node doesn't exist. $node = $this->server->tree->getNodeForPath($path); if ($node instanceof IProperties) { $node->propPatch($propPatch); } - } /** @@ -781,12 +776,11 @@ class CorePlugin extends ServerPlugin { * Here we add all the default properties. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - - $propFind->handle('{DAV:}getlastmodified', function() use ($node) { + public function propFind(PropFind $propFind, INode $node) + { + $propFind->handle('{DAV:}getlastmodified', function () use ($node) { $lm = $node->getLastModified(); if ($lm) { return new Xml\Property\GetLastModified($lm); @@ -801,34 +795,36 @@ class CorePlugin extends ServerPlugin { if ($node instanceof IQuota) { $quotaInfo = null; - $propFind->handle('{DAV:}quota-used-bytes', function() use (&$quotaInfo, $node) { + $propFind->handle('{DAV:}quota-used-bytes', function () use (&$quotaInfo, $node) { $quotaInfo = $node->getQuotaInfo(); + return $quotaInfo[0]; }); - $propFind->handle('{DAV:}quota-available-bytes', function() use (&$quotaInfo, $node) { + $propFind->handle('{DAV:}quota-available-bytes', function () use (&$quotaInfo, $node) { if (!$quotaInfo) { $quotaInfo = $node->getQuotaInfo(); } + return $quotaInfo[1]; }); } - $propFind->handle('{DAV:}supported-report-set', function() use ($propFind) { + $propFind->handle('{DAV:}supported-report-set', function () use ($propFind) { $reports = []; foreach ($this->server->getPlugins() as $plugin) { $reports = array_merge($reports, $plugin->getSupportedReportSet($propFind->getPath())); } + return new Xml\Property\SupportedReportSet($reports); }); - $propFind->handle('{DAV:}resourcetype', function() use ($node) { + $propFind->handle('{DAV:}resourcetype', function () use ($node) { return new Xml\Property\ResourceType($this->server->getResourceTypeForNode($node)); }); - $propFind->handle('{DAV:}supported-method-set', function() use ($propFind) { + $propFind->handle('{DAV:}supported-method-set', function () use ($propFind) { return new Xml\Property\SupportedMethodSet( $this->server->getAllowedMethods($propFind->getPath()) ); }); - } /** @@ -838,20 +834,16 @@ class CorePlugin extends ServerPlugin { * populate the result. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFindNode(PropFind $propFind, INode $node) { - + public function propFindNode(PropFind $propFind, INode $node) + { if ($node instanceof IProperties && $propertyNames = $propFind->get404Properties()) { - $nodeProperties = $node->getProperties($propertyNames); foreach ($nodeProperties as $propertyName => $propertyValue) { $propFind->set($propertyName, $propertyValue, 200); } - } - } /** @@ -861,17 +853,17 @@ class CorePlugin extends ServerPlugin { * want other systems to first have a chance to handle the properties. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFindLate(PropFind $propFind, INode $node) { - - $propFind->handle('{http://calendarserver.org/ns/}getctag', function() use ($propFind) { - + public function propFindLate(PropFind $propFind, INode $node) + { + $propFind->handle('{http://calendarserver.org/ns/}getctag', function () use ($propFind) { // If we already have a sync-token from the current propFind // request, we can re-use that. $val = $propFind->get('{http://sabredav.org/ns}sync-token'); - if ($val) return $val; + if ($val) { + return $val; + } $val = $propFind->get('{DAV:}sync-token'); if ($val && is_scalar($val)) { @@ -899,9 +891,7 @@ class CorePlugin extends ServerPlugin { return substr($val->getHref(), strlen(Sync\Plugin::SYNCTOKEN_PREFIX)); } } - }); - } /** @@ -909,8 +899,8 @@ class CorePlugin extends ServerPlugin { * * @param Exception $e */ - function exception($e) { - + public function exception($e) + { $logLevel = \Psr\Log\LogLevel::CRITICAL; if ($e instanceof \Sabre\DAV\Exception) { // If it's a standard sabre/dav exception, it means we have a http @@ -947,13 +937,12 @@ class CorePlugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'The Core plugin provides a lot of the basic functionality required by WebDAV, such as a default implementation for all HTTP and WebDAV methods.', - 'link' => null, + 'link' => null, ]; - } } diff --git a/vendor/sabre/dav/lib/DAV/Exception.php b/vendor/sabre/dav/lib/DAV/Exception.php index 14f5bab2a..e1d990623 100644 --- a/vendor/sabre/dav/lib/DAV/Exception.php +++ b/vendor/sabre/dav/lib/DAV/Exception.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -15,29 +17,26 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Exception extends \Exception { - +class Exception extends \Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 500; - } /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param Server $server + * @param Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(Server $server, \DOMElement $errorNode) { - - + public function serialize(Server $server, \DOMElement $errorNode) + { } /** @@ -46,12 +45,11 @@ class Exception extends \Exception { * The headers must be returned as an array. * * @param Server $server + * * @return array */ - function getHTTPHeaders(Server $server) { - + public function getHTTPHeaders(Server $server) + { return []; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/BadRequest.php b/vendor/sabre/dav/lib/DAV/Exception/BadRequest.php index c21f493da..569c63ba0 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/BadRequest.php +++ b/vendor/sabre/dav/lib/DAV/Exception/BadRequest.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * BadRequest + * BadRequest. * * The BadRequest is thrown when the user submitted an invalid HTTP request * BadRequest @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class BadRequest extends DAV\Exception { - +class BadRequest extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 400; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/Conflict.php b/vendor/sabre/dav/lib/DAV/Exception/Conflict.php index 4190e6082..2ec227feb 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/Conflict.php +++ b/vendor/sabre/dav/lib/DAV/Exception/Conflict.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * Conflict + * Conflict. * * A 409 Conflict is thrown when a user tried to make a directory over an existing * file or in a parent directory that doesn't exist. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Conflict extends DAV\Exception { - +class Conflict extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 409; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/ConflictingLock.php b/vendor/sabre/dav/lib/DAV/Exception/ConflictingLock.php index b2d2746c5..c1a4914ed 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/ConflictingLock.php +++ b/vendor/sabre/dav/lib/DAV/Exception/ConflictingLock.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * ConflictingLock + * ConflictingLock. * * Similar to the Locked exception, this exception thrown when a LOCK request * was made, on a resource which was already locked @@ -14,23 +16,20 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ConflictingLock extends Locked { - +class ConflictingLock extends Locked +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { if ($this->lock) { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:no-conflicting-lock'); $errorNode->appendChild($error); $error->appendChild($errorNode->ownerDocument->createElementNS('DAV:', 'd:href', $this->lock->uri)); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/Forbidden.php b/vendor/sabre/dav/lib/DAV/Exception/Forbidden.php index 77df7ca9e..2f882c396 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/Forbidden.php +++ b/vendor/sabre/dav/lib/DAV/Exception/Forbidden.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * Forbidden + * Forbidden. * * This exception is thrown whenever a user tries to do an operation he's not allowed to * @@ -13,17 +15,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Forbidden extends DAV\Exception { - +class Forbidden extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 403; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/InsufficientStorage.php b/vendor/sabre/dav/lib/DAV/Exception/InsufficientStorage.php index 96e1acc50..fe6e1268c 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/InsufficientStorage.php +++ b/vendor/sabre/dav/lib/DAV/Exception/InsufficientStorage.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * InsufficientStorage + * InsufficientStorage. * * This Exception can be thrown, when for example a harddisk is full or a quota is exceeded * @@ -13,17 +15,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InsufficientStorage extends DAV\Exception { - +class InsufficientStorage extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 507; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/InvalidResourceType.php b/vendor/sabre/dav/lib/DAV/Exception/InvalidResourceType.php index 6324d9f3a..99baeb8bc 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/InvalidResourceType.php +++ b/vendor/sabre/dav/lib/DAV/Exception/InvalidResourceType.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; /** - * InvalidResourceType + * InvalidResourceType. * * This exception is thrown when the user tried to create a new collection, with * a special resourcetype value that was not recognized by the server. @@ -14,20 +16,17 @@ namespace Sabre\DAV\Exception; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InvalidResourceType extends Forbidden { - +class InvalidResourceType extends Forbidden +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * * @param \Sabre\DAV\Server $server - * @param \DOMElement $errorNode - * @return void + * @param \DOMElement $errorNode */ - function serialize(\Sabre\DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(\Sabre\DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:valid-resourcetype'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php b/vendor/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php index 51a253b29..6c5f1c435 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php +++ b/vendor/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * InvalidSyncToken + * InvalidSyncToken. * * This exception is emited for the {DAV:}valid-sync-token pre-condition, as * defined in rfc6578, section 3.2. @@ -19,20 +21,17 @@ use Sabre\DAV; * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InvalidSyncToken extends Forbidden { - +class InvalidSyncToken extends Forbidden +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:valid-sync-token'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/LengthRequired.php b/vendor/sabre/dav/lib/DAV/Exception/LengthRequired.php index 989718558..9d26fcb10 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/LengthRequired.php +++ b/vendor/sabre/dav/lib/DAV/Exception/LengthRequired.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * LengthRequired + * LengthRequired. * * This exception is thrown when a request was made that required a * Content-Length header, but did not contain one. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class LengthRequired extends DAV\Exception { - +class LengthRequired extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 411; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/LockTokenMatchesRequestUri.php b/vendor/sabre/dav/lib/DAV/Exception/LockTokenMatchesRequestUri.php index 5f8c31868..1c7402384 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/LockTokenMatchesRequestUri.php +++ b/vendor/sabre/dav/lib/DAV/Exception/LockTokenMatchesRequestUri.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * LockTokenMatchesRequestUri + * LockTokenMatchesRequestUri. * * This exception is thrown by UNLOCK if a supplied lock-token is invalid * @@ -13,29 +15,25 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class LockTokenMatchesRequestUri extends Conflict { - +class LockTokenMatchesRequestUri extends Conflict +{ /** - * Creates the exception + * Creates the exception. */ - function __construct() { - - $this->message = 'The locktoken supplied does not match any locks on this entity'; - + public function __construct() + { + parent::__construct('The locktoken supplied does not match any locks on this entity'); } /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:lock-token-matches-request-uri'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/Locked.php b/vendor/sabre/dav/lib/DAV/Exception/Locked.php index 8176db46e..632bafc60 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/Locked.php +++ b/vendor/sabre/dav/lib/DAV/Exception/Locked.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * Locked + * Locked. * * The 423 is thrown when a client tried to access a resource that was locked, without supplying a valid lock token * @@ -13,49 +15,48 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Locked extends DAV\Exception { - +class Locked extends DAV\Exception +{ /** - * Lock information + * Lock information. * - * @var Sabre\DAV\Locks\LockInfo + * @var \Sabre\DAV\Locks\LockInfo */ protected $lock; /** - * Creates the exception + * Creates the exception. * * A LockInfo object should be passed if the user should be informed * which lock actually has the file locked. * * @param DAV\Locks\LockInfo $lock */ - function __construct(DAV\Locks\LockInfo $lock = null) { + public function __construct(DAV\Locks\LockInfo $lock = null) + { + parent::__construct(); $this->lock = $lock; - } /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 423; - } /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { if ($this->lock) { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:lock-token-submitted'); $errorNode->appendChild($error); @@ -66,7 +67,5 @@ class Locked extends DAV\Exception { $href ); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php b/vendor/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php index 30c1c2553..a3d9c56f2 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php +++ b/vendor/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * MethodNotAllowed + * MethodNotAllowed. * * The 405 is thrown when a client tried to create a directory on an already existing directory * @@ -13,17 +15,16 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MethodNotAllowed extends DAV\Exception { - +class MethodNotAllowed extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 405; - } /** @@ -32,16 +33,15 @@ class MethodNotAllowed extends DAV\Exception { * The headers must be returned as an array. * * @param \Sabre\DAV\Server $server + * * @return array */ - function getHTTPHeaders(\Sabre\DAV\Server $server) { - + public function getHTTPHeaders(\Sabre\DAV\Server $server) + { $methods = $server->getAllowedMethods($server->getRequestUri()); return [ 'Allow' => strtoupper(implode(', ', $methods)), ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/NotAuthenticated.php b/vendor/sabre/dav/lib/DAV/Exception/NotAuthenticated.php index e69a60c75..0a5ba9b5a 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/NotAuthenticated.php +++ b/vendor/sabre/dav/lib/DAV/Exception/NotAuthenticated.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * NotAuthenticated + * NotAuthenticated. * * This exception is thrown when the client did not provide valid * authentication credentials. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotAuthenticated extends DAV\Exception { - +class NotAuthenticated extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 401; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/NotFound.php b/vendor/sabre/dav/lib/DAV/Exception/NotFound.php index b0397446d..9cf837074 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/NotFound.php +++ b/vendor/sabre/dav/lib/DAV/Exception/NotFound.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * NotFound + * NotFound. * * This Exception is thrown when a Node couldn't be found. It returns HTTP error code 404 * @@ -13,17 +15,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotFound extends DAV\Exception { - +class NotFound extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 404; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/NotImplemented.php b/vendor/sabre/dav/lib/DAV/Exception/NotImplemented.php index 68f309222..cebb83363 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/NotImplemented.php +++ b/vendor/sabre/dav/lib/DAV/Exception/NotImplemented.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * NotImplemented + * NotImplemented. * * This exception is thrown when the client tried to call an unsupported HTTP method or other feature * @@ -13,17 +15,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotImplemented extends DAV\Exception { - +class NotImplemented extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 501; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/PaymentRequired.php b/vendor/sabre/dav/lib/DAV/Exception/PaymentRequired.php index 43e17344a..d237f906b 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/PaymentRequired.php +++ b/vendor/sabre/dav/lib/DAV/Exception/PaymentRequired.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * Payment Required + * Payment Required. * * The PaymentRequired exception may be thrown in a case where a user must pay * to access a certain resource or operation. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PaymentRequired extends DAV\Exception { - +class PaymentRequired extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 402; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/PreconditionFailed.php b/vendor/sabre/dav/lib/DAV/Exception/PreconditionFailed.php index 550360e5a..20d8a2a30 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/PreconditionFailed.php +++ b/vendor/sabre/dav/lib/DAV/Exception/PreconditionFailed.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * PreconditionFailed + * PreconditionFailed. * * This exception is normally thrown when a client submitted a conditional request, * like for example an If, If-None-Match or If-Match header, which caused the HTTP @@ -15,8 +17,8 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PreconditionFailed extends DAV\Exception { - +class PreconditionFailed extends DAV\Exception +{ /** * When this exception is thrown, the header-name might be set. * @@ -28,44 +30,39 @@ class PreconditionFailed extends DAV\Exception { public $header = null; /** - * Create the exception + * Create the exception. * * @param string $message * @param string $header */ - function __construct($message, $header = null) { - + public function __construct($message, $header = null) + { parent::__construct($message); $this->header = $header; - } /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 412; - } /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { if ($this->header) { $prop = $errorNode->ownerDocument->createElement('s:header'); $prop->nodeValue = $this->header; $errorNode->appendChild($prop); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/ReportNotSupported.php b/vendor/sabre/dav/lib/DAV/Exception/ReportNotSupported.php index a83695627..cecfec12d 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/ReportNotSupported.php +++ b/vendor/sabre/dav/lib/DAV/Exception/ReportNotSupported.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * ReportNotSupported + * ReportNotSupported. * * This exception is thrown when the client requested an unknown report through the REPORT method * @@ -13,20 +15,17 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ReportNotSupported extends UnsupportedMediaType { - +class ReportNotSupported extends UnsupportedMediaType +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:supported-report'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php b/vendor/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php index c8ccfc062..6ccb5b8c8 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php +++ b/vendor/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * RequestedRangeNotSatisfiable + * RequestedRangeNotSatisfiable. * * This exception is normally thrown when the user * request a range that is out of the entity bounds. @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class RequestedRangeNotSatisfiable extends DAV\Exception { - +class RequestedRangeNotSatisfiable extends DAV\Exception +{ /** - * returns the http statuscode for this exception + * returns the http statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 416; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/ServiceUnavailable.php b/vendor/sabre/dav/lib/DAV/Exception/ServiceUnavailable.php index 31df606e2..43c995c9c 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/ServiceUnavailable.php +++ b/vendor/sabre/dav/lib/DAV/Exception/ServiceUnavailable.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * ServiceUnavailable + * ServiceUnavailable. * * This exception is thrown in case the service * is currently not available (e.g. down for maintenance). @@ -14,17 +16,15 @@ use Sabre\DAV; * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ServiceUnavailable extends DAV\Exception { - +class ServiceUnavailable extends DAV\Exception +{ /** - * Returns the HTTP statuscode for this exception + * Returns the HTTP statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 503; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/TooManyMatches.php b/vendor/sabre/dav/lib/DAV/Exception/TooManyMatches.php index d0f0f84e8..7dbe878b9 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/TooManyMatches.php +++ b/vendor/sabre/dav/lib/DAV/Exception/TooManyMatches.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * TooManyMatches + * TooManyMatches. * * This exception is emited for the {DAV:}number-of-matches-within-limits * post-condition, as defined in rfc6578, section 3.2. @@ -19,20 +21,17 @@ use Sabre\DAV; * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @license http://sabre.io/license/ Modified BSD License */ -class TooManyMatches extends Forbidden { - +class TooManyMatches extends Forbidden +{ /** - * This method allows the exception to include additional information into the WebDAV error response + * This method allows the exception to include additional information into the WebDAV error response. * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:number-of-matches-within-limits'); $errorNode->appendChild($error); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php b/vendor/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php index f3d92842d..bc9da30da 100644 --- a/vendor/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php +++ b/vendor/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use Sabre\DAV; /** - * UnSupportedMediaType + * UnSupportedMediaType. * * The 415 Unsupported Media Type status code is generally sent back when the client * tried to call an HTTP method, with a body the server didn't understand @@ -14,17 +16,15 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class UnsupportedMediaType extends DAV\Exception { - +class UnsupportedMediaType extends DAV\Exception +{ /** - * returns the http statuscode for this exception + * returns the http statuscode for this exception. * * @return int */ - function getHTTPCode() { - + public function getHTTPCode() + { return 415; - } - } diff --git a/vendor/sabre/dav/lib/DAV/FS/Directory.php b/vendor/sabre/dav/lib/DAV/FS/Directory.php index 362f7a411..047692294 100644 --- a/vendor/sabre/dav/lib/DAV/FS/Directory.php +++ b/vendor/sabre/dav/lib/DAV/FS/Directory.php @@ -1,20 +1,22 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FS; use Sabre\DAV; /** - * Directory class + * Directory class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Directory extends Node implements DAV\ICollection, DAV\IQuota { - +class Directory extends Node implements DAV\ICollection, DAV\IQuota +{ /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -33,67 +35,63 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - - $newPath = $this->path . '/' . $name; + public function createFile($name, $data = null) + { + $newPath = $this->path.'/'.$name; file_put_contents($newPath, $data); clearstatcache(true, $newPath); - } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name - * @return void */ - function createDirectory($name) { - - $newPath = $this->path . '/' . $name; + public function createDirectory($name) + { + $newPath = $this->path.'/'.$name; mkdir($newPath); clearstatcache(true, $newPath); - } /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * This method must throw DAV\Exception\NotFound if the node does not * exist. * * @param string $name + * * @throws DAV\Exception\NotFound + * * @return DAV\INode */ - function getChild($name) { - - $path = $this->path . '/' . $name; - - if (!file_exists($path)) throw new DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); + public function getChild($name) + { + $path = $this->path.'/'.$name; + if (!file_exists($path)) { + throw new DAV\Exception\NotFound('File with name '.$path.' could not be located'); + } if (is_dir($path)) { - return new self($path); - } else { - return new File($path); - } - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return DAV\INode[] */ - function getChildren() { - + public function getChildren() + { $nodes = []; $iterator = new \FilesystemIterator( $this->path, @@ -101,51 +99,49 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota { | \FilesystemIterator::SKIP_DOTS ); foreach ($iterator as $entry) { - $nodes[] = $this->getChild($entry->getFilename()); - } - return $nodes; + return $nodes; } /** * Checks if a child exists. * * @param string $name + * * @return bool */ - function childExists($name) { + public function childExists($name) + { + $path = $this->path.'/'.$name; - $path = $this->path . '/' . $name; return file_exists($path); - } /** - * Deletes all files in this directory, and then itself - * - * @return void + * Deletes all files in this directory, and then itself. */ - function delete() { - - foreach ($this->getChildren() as $child) $child->delete(); + public function delete() + { + foreach ($this->getChildren() as $child) { + $child->delete(); + } rmdir($this->path); - } /** - * Returns available diskspace information + * Returns available diskspace information. * * @return array */ - function getQuotaInfo() { + public function getQuotaInfo() + { $absolute = realpath($this->path); + return [ disk_total_space($absolute) - disk_free_space($absolute), - disk_free_space($absolute) + disk_free_space($absolute), ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/FS/File.php b/vendor/sabre/dav/lib/DAV/FS/File.php index 4fc5af057..b78a80138 100644 --- a/vendor/sabre/dav/lib/DAV/FS/File.php +++ b/vendor/sabre/dav/lib/DAV/FS/File.php @@ -1,66 +1,61 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FS; use Sabre\DAV; /** - * File class + * File class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends Node implements DAV\IFile { - +class File extends Node implements DAV\IFile +{ /** - * Updates the data + * Updates the data. * * @param resource $data - * @return void */ - function put($data) { - + public function put($data) + { file_put_contents($this->path, $data); clearstatcache(true, $this->path); - } /** - * Returns the data + * Returns the data. * * @return resource */ - function get() { - + public function get() + { return fopen($this->path, 'r'); - } /** - * Delete the current file - * - * @return void + * Delete the current file. */ - function delete() { - + public function delete() + { unlink($this->path); - } /** - * Returns the size of the node, in bytes + * Returns the size of the node, in bytes. * * @return int */ - function getSize() { - + public function getSize() + { return filesize($this->path); - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. @@ -69,27 +64,24 @@ class File extends Node implements DAV\IFile { * * @return mixed */ - function getETag() { - - return '"' . sha1( - fileinode($this->path) . - filesize($this->path) . + public function getETag() + { + return '"'.sha1( + fileinode($this->path). + filesize($this->path). filemtime($this->path) - ) . '"'; - + ).'"'; } /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream * * @return mixed */ - function getContentType() { - + public function getContentType() + { return null; - } - } diff --git a/vendor/sabre/dav/lib/DAV/FS/Node.php b/vendor/sabre/dav/lib/DAV/FS/Node.php index 424718f96..32aa74755 100644 --- a/vendor/sabre/dav/lib/DAV/FS/Node.php +++ b/vendor/sabre/dav/lib/DAV/FS/Node.php @@ -1,12 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FS; -use Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\DAV\Exception\Forbidden; +use Sabre\DAV\INode; +use Sabre\Uri; /** - * Base node-class + * Base node-class. * * The node class implements the method used by both the File and the Directory classes * @@ -14,67 +17,80 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Node implements DAV\INode { - +abstract class Node implements INode +{ /** - * The path to the current node + * The path to the current node. * * @var string */ protected $path; /** - * Sets up the node, expects a full path name + * The overridden name of the node. * - * @param string $path + * @var string */ - function __construct($path) { + protected $overrideName; + /** + * Sets up the node, expects a full path name. + * + * If $overrideName is set, this node shows up in the tree under a + * different name. In this case setName() will be disabled. + * + * @param string $path + * @param string $overrideName + */ + public function __construct($path, $overrideName = null) + { $this->path = $path; - + $this->overrideName = $overrideName; } - - /** - * Returns the name of the node + * Returns the name of the node. * * @return string */ - function getName() { + public function getName() + { + if ($this->overrideName) { + return $this->overrideName; + } - list(, $name) = URLUtil::splitPath($this->path); - return $name; + list(, $name) = Uri\split($this->path); + return $name; } /** - * Renames the node + * Renames the node. * * @param string $name The new name - * @return void */ - function setName($name) { + public function setName($name) + { + if ($this->overrideName) { + throw new Forbidden('This node cannot be renamed'); + } - list($parentPath, ) = URLUtil::splitPath($this->path); - list(, $newName) = URLUtil::splitPath($name); + list($parentPath) = Uri\split($this->path); + list(, $newName) = Uri\split($name); - $newPath = $parentPath . '/' . $newName; + $newPath = $parentPath.'/'.$newName; rename($this->path, $newPath); $this->path = $newPath; - } /** - * Returns the last modification time, as a unix timestamp + * Returns the last modification time, as a unix timestamp. * * @return int */ - function getLastModified() { - + public function getLastModified() + { return filemtime($this->path); - } - } diff --git a/vendor/sabre/dav/lib/DAV/FSExt/Directory.php b/vendor/sabre/dav/lib/DAV/FSExt/Directory.php index dd5f992db..d6aea0094 100644 --- a/vendor/sabre/dav/lib/DAV/FSExt/Directory.php +++ b/vendor/sabre/dav/lib/DAV/FSExt/Directory.php @@ -1,21 +1,23 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FSExt; use Sabre\DAV; use Sabre\DAV\FS\Node; /** - * Directory class + * Directory class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTarget { - +class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTarget +{ /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -34,94 +36,97 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - + public function createFile($name, $data = null) + { // We're not allowing dots - if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..'); - $newPath = $this->path . '/' . $name; + if ('.' == $name || '..' == $name) { + throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + } + $newPath = $this->path.'/'.$name; file_put_contents($newPath, $data); clearstatcache(true, $newPath); - return '"' . sha1( - fileinode($newPath) . - filesize($newPath) . + return '"'.sha1( + fileinode($newPath). + filesize($newPath). filemtime($newPath) - ) . '"'; - + ).'"'; } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { // We're not allowing dots - if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..'); - $newPath = $this->path . '/' . $name; + if ('.' == $name || '..' == $name) { + throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + } + $newPath = $this->path.'/'.$name; mkdir($newPath); clearstatcache(true, $newPath); - } /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * This method must throw Sabre\DAV\Exception\NotFound if the node does not * exist. * * @param string $name + * * @throws DAV\Exception\NotFound + * * @return DAV\INode */ - function getChild($name) { - - $path = $this->path . '/' . $name; - - if (!file_exists($path)) throw new DAV\Exception\NotFound('File could not be located'); - if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + public function getChild($name) + { + $path = $this->path.'/'.$name; + if (!file_exists($path)) { + throw new DAV\Exception\NotFound('File could not be located'); + } + if ('.' == $name || '..' == $name) { + throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + } if (is_dir($path)) { - return new self($path); - } else { - return new File($path); - } - } /** * Checks if a child exists. * * @param string $name + * * @return bool */ - function childExists($name) { - - if ($name == '.' || $name == '..') + public function childExists($name) + { + if ('.' == $name || '..' == $name) { throw new DAV\Exception\Forbidden('Permission denied to . and ..'); + } + $path = $this->path.'/'.$name; - $path = $this->path . '/' . $name; return file_exists($path); - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return DAV\INode[] */ - function getChildren() { - + public function getChildren() + { $nodes = []; $iterator = new \FilesystemIterator( $this->path, @@ -130,44 +135,43 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa ); foreach ($iterator as $entry) { - $nodes[] = $this->getChild($entry->getFilename()); - } - return $nodes; + return $nodes; } /** - * Deletes all files in this directory, and then itself + * Deletes all files in this directory, and then itself. * * @return bool */ - function delete() { - + public function delete() + { // Deleting all children - foreach ($this->getChildren() as $child) $child->delete(); + foreach ($this->getChildren() as $child) { + $child->delete(); + } // Removing the directory itself rmdir($this->path); return true; - } /** - * Returns available diskspace information + * Returns available diskspace information. * * @return array */ - function getQuotaInfo() { - + public function getQuotaInfo() + { $total = disk_total_space(realpath($this->path)); $free = disk_free_space(realpath($this->path)); return [ $total - $free, - $free + $free, ]; } @@ -186,13 +190,14 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa * the move itself. If you return true from this function, the assumption * is that the move was successful. * - * @param string $targetName New local file/collection name. - * @param string $sourcePath Full path to source node + * @param string $targetName new local file/collection name + * @param string $sourcePath Full path to source node * @param DAV\INode $sourceNode Source node itself + * * @return bool */ - function moveInto($targetName, $sourcePath, DAV\INode $sourceNode) { - + public function moveInto($targetName, $sourcePath, DAV\INode $sourceNode) + { // We only support FSExt\Directory or FSExt\File objects, so // anything else we want to quickly reject. if (!$sourceNode instanceof self && !$sourceNode instanceof File) { @@ -200,12 +205,8 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa } // PHP allows us to access protected properties from other objects, as - // long as they are defined in a class that has a shared inheritence + // long as they are defined in a class that has a shared inheritance // with the current class. - rename($sourceNode->path, $this->path . '/' . $targetName); - - return true; - + return rename($sourceNode->path, $this->path.'/'.$targetName); } - } diff --git a/vendor/sabre/dav/lib/DAV/FSExt/File.php b/vendor/sabre/dav/lib/DAV/FSExt/File.php index eb5ae19fe..060ef5a48 100644 --- a/vendor/sabre/dav/lib/DAV/FSExt/File.php +++ b/vendor/sabre/dav/lib/DAV/FSExt/File.php @@ -1,33 +1,36 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FSExt; use Sabre\DAV; use Sabre\DAV\FS\Node; /** - * File class + * File class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends Node implements DAV\PartialUpdate\IPatchSupport { - +class File extends Node implements DAV\PartialUpdate\IPatchSupport +{ /** - * Updates the data + * Updates the data. * * Data is a readable stream resource. * * @param resource|string $data + * * @return string */ - function put($data) { - + public function put($data) + { file_put_contents($this->path, $data); clearstatcache(true, $this->path); - return $this->getETag(); + return $this->getETag(); } /** @@ -53,21 +56,22 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport { * time. * * @param resource|string $data - * @param int $rangeType - * @param int $offset + * @param int $rangeType + * @param int $offset + * * @return string|null */ - function patch($data, $rangeType, $offset = null) { - + public function patch($data, $rangeType, $offset = null) + { switch ($rangeType) { - case 1 : + case 1: $f = fopen($this->path, 'a'); break; - case 2 : + case 2: $f = fopen($this->path, 'c'); fseek($f, $offset); break; - case 3 : + case 3: $f = fopen($this->path, 'c'); fseek($f, $offset, SEEK_END); break; @@ -79,34 +83,32 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport { } fclose($f); clearstatcache(true, $this->path); - return $this->getETag(); + return $this->getETag(); } /** - * Returns the data + * Returns the data. * * @return resource */ - function get() { - + public function get() + { return fopen($this->path, 'r'); - } /** - * Delete the current file + * Delete the current file. * * @return bool */ - function delete() { - + public function delete() + { return unlink($this->path); - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. @@ -115,38 +117,34 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport { * * @return string|null */ - function getETag() { - - return '"' . sha1( - fileinode($this->path) . - filesize($this->path) . + public function getETag() + { + return '"'.sha1( + fileinode($this->path). + filesize($this->path). filemtime($this->path) - ) . '"'; - + ).'"'; } /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream * * @return string|null */ - function getContentType() { - + public function getContentType() + { return null; - } /** - * Returns the size of the file, in bytes + * Returns the size of the file, in bytes. * * @return int */ - function getSize() { - + public function getSize() + { return filesize($this->path); - } - } diff --git a/vendor/sabre/dav/lib/DAV/File.php b/vendor/sabre/dav/lib/DAV/File.php index 5161fbd51..daf83aa4d 100644 --- a/vendor/sabre/dav/lib/DAV/File.php +++ b/vendor/sabre/dav/lib/DAV/File.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * File class + * File class. * * This is a helper class, that should aid in getting file classes setup. * Most of its methods are implemented, and throw permission denied exceptions @@ -12,8 +14,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class File extends Node implements IFile { - +abstract class File extends Node implements IFile +{ /** * Replaces the contents of the file. * @@ -32,25 +34,24 @@ abstract class File extends Node implements IFile { * return an ETag, and just return null. * * @param string|resource $data + * * @return string|null */ - function put($data) { - + public function put($data) + { throw new Exception\Forbidden('Permission denied to change data'); - } /** - * Returns the data + * Returns the data. * * This method may either return a string or a readable stream resource * * @return mixed */ - function get() { - + public function get() + { throw new Exception\Forbidden('Permission denied to read this file'); - } /** @@ -58,14 +59,13 @@ abstract class File extends Node implements IFile { * * @return int */ - function getSize() { - + public function getSize() + { return 0; - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. @@ -74,23 +74,20 @@ abstract class File extends Node implements IFile { * * @return string|null */ - function getETag() { - + public function getETag() + { return null; - } /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream * * @return string|null */ - function getContentType() { - + public function getContentType() + { return null; - } - } diff --git a/vendor/sabre/dav/lib/DAV/ICollection.php b/vendor/sabre/dav/lib/DAV/ICollection.php index 7793070d3..c039dae56 100644 --- a/vendor/sabre/dav/lib/DAV/ICollection.php +++ b/vendor/sabre/dav/lib/DAV/ICollection.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * The ICollection Interface + * The ICollection Interface. * * This interface should be implemented by each class that represents a collection * @@ -11,10 +13,10 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ICollection extends INode { - +interface ICollection extends INode +{ /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -33,44 +35,45 @@ interface ICollection extends INode { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null); + public function createFile($name, $data = null); /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name - * @return void */ - function createDirectory($name); + public function createDirectory($name); /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * This method must throw Sabre\DAV\Exception\NotFound if the node does not * exist. * * @param string $name + * * @return INode */ - function getChild($name); + public function getChild($name); /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return INode[] */ - function getChildren(); + public function getChildren(); /** - * Checks if a child-node with the specified name exists + * Checks if a child-node with the specified name exists. * * @param string $name + * * @return bool */ - function childExists($name); - + public function childExists($name); } diff --git a/vendor/sabre/dav/lib/DAV/ICopyTarget.php b/vendor/sabre/dav/lib/DAV/ICopyTarget.php new file mode 100644 index 000000000..47227138a --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/ICopyTarget.php @@ -0,0 +1,38 @@ +<?php + +declare(strict_types=1); + +namespace Sabre\DAV; + +/** + * By implementing this interface, a collection can effectively say "other + * nodes may be copied into this collection". + * + * If a backend supports a better optimized copy operation, e.g. by avoiding + * copying the contents, this can trigger some huge speed gains. + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +interface ICopyTarget extends ICollection +{ + /** + * Copies a node into this collection. + * + * It is up to the implementors to: + * 1. Create the new resource. + * 2. Copy the data and any properties. + * + * If you return true from this function, the assumption + * is that the copy was successful. + * If you return false, sabre/dav will handle the copy itself. + * + * @param string $targetName new local file/collection name + * @param string $sourcePath Full path to source node + * @param INode $sourceNode Source node itself + * + * @return bool + */ + public function copyInto($targetName, $sourcePath, INode $sourceNode); +} diff --git a/vendor/sabre/dav/lib/DAV/IExtendedCollection.php b/vendor/sabre/dav/lib/DAV/IExtendedCollection.php index c561d7072..d43b44bcb 100644 --- a/vendor/sabre/dav/lib/DAV/IExtendedCollection.php +++ b/vendor/sabre/dav/lib/DAV/IExtendedCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -12,8 +14,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IExtendedCollection extends ICollection { - +interface IExtendedCollection extends ICollection +{ /** * Creates a new collection. * @@ -34,10 +36,9 @@ interface IExtendedCollection extends ICollection { * property for you. * * @param string $name - * @param MkCol $mkCol + * @param MkCol $mkCol + * * @throws Exception\InvalidResourceType - * @return void */ - function createExtendedCollection($name, MkCol $mkCol); - + public function createExtendedCollection($name, MkCol $mkCol); } diff --git a/vendor/sabre/dav/lib/DAV/IFile.php b/vendor/sabre/dav/lib/DAV/IFile.php index 19d8d8637..974aee00d 100644 --- a/vendor/sabre/dav/lib/DAV/IFile.php +++ b/vendor/sabre/dav/lib/DAV/IFile.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * This interface represents a file in the directory tree + * This interface represents a file in the directory tree. * * A file is a bit of a broad definition. In general it implies that on * this specific node a PUT or GET method may be performed, to either update, @@ -13,8 +15,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IFile extends INode { - +interface IFile extends INode +{ /** * Replaces the contents of the file. * @@ -33,30 +35,31 @@ interface IFile extends INode { * return an ETag, and just return null. * * @param resource|string $data + * * @return string|null */ - function put($data); + public function put($data); /** - * Returns the data + * Returns the data. * * This method may either return a string or a readable stream resource * * @return mixed */ - function get(); + public function get(); /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream * * @return string|null */ - function getContentType(); + public function getContentType(); /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * @@ -69,13 +72,12 @@ interface IFile extends INode { * * @return string|null */ - function getETag(); + public function getETag(); /** - * Returns the size of the node, in bytes + * Returns the size of the node, in bytes. * * @return int */ - function getSize(); - + public function getSize(); } diff --git a/vendor/sabre/dav/lib/DAV/IMoveTarget.php b/vendor/sabre/dav/lib/DAV/IMoveTarget.php index 92fde1d5c..18a24081e 100644 --- a/vendor/sabre/dav/lib/DAV/IMoveTarget.php +++ b/vendor/sabre/dav/lib/DAV/IMoveTarget.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -17,8 +19,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IMoveTarget extends ICollection { - +interface IMoveTarget extends ICollection +{ /** * Moves a node into this collection. * @@ -34,11 +36,11 @@ interface IMoveTarget extends ICollection { * the move itself. If you return true from this function, the assumption * is that the move was successful. * - * @param string $targetName New local file/collection name. + * @param string $targetName new local file/collection name * @param string $sourcePath Full path to source node - * @param INode $sourceNode Source node itself + * @param INode $sourceNode Source node itself + * * @return bool */ - function moveInto($targetName, $sourcePath, INode $sourceNode); - + public function moveInto($targetName, $sourcePath, INode $sourceNode); } diff --git a/vendor/sabre/dav/lib/DAV/IMultiGet.php b/vendor/sabre/dav/lib/DAV/IMultiGet.php index e26b457ef..445e761eb 100644 --- a/vendor/sabre/dav/lib/DAV/IMultiGet.php +++ b/vendor/sabre/dav/lib/DAV/IMultiGet.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * IMultiGet + * IMultiGet. * * This interface adds a tiny bit of functionality to collections. * @@ -20,8 +22,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IMultiGet extends ICollection { - +interface IMultiGet extends ICollection +{ /** * This method receives a list of paths in it's first argument. * It must return an array with Node objects. @@ -29,8 +31,8 @@ interface IMultiGet extends ICollection { * If any children are not found, you do not have to return them. * * @param string[] $paths + * * @return array */ - function getMultipleChildren(array $paths); - + public function getMultipleChildren(array $paths); } diff --git a/vendor/sabre/dav/lib/DAV/INode.php b/vendor/sabre/dav/lib/DAV/INode.php index bb884934d..f3e7e395b 100644 --- a/vendor/sabre/dav/lib/DAV/INode.php +++ b/vendor/sabre/dav/lib/DAV/INode.php @@ -1,22 +1,22 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * The INode interface is the base interface, and the parent class of both ICollection and IFile + * The INode interface is the base interface, and the parent class of both ICollection and IFile. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface INode { - +interface INode +{ /** - * Deleted the current node - * - * @return void + * Deleted the current node. */ - function delete(); + public function delete(); /** * Returns the name of the node. @@ -25,15 +25,14 @@ interface INode { * * @return string */ - function getName(); + public function getName(); /** - * Renames the node + * Renames the node. * * @param string $name The new name - * @return void */ - function setName($name); + public function setName($name); /** * Returns the last modification time, as a unix timestamp. Return null @@ -41,6 +40,5 @@ interface INode { * * @return int|null */ - function getLastModified(); - + public function getLastModified(); } diff --git a/vendor/sabre/dav/lib/DAV/IProperties.php b/vendor/sabre/dav/lib/DAV/IProperties.php index 00969c2c4..d50fdff20 100644 --- a/vendor/sabre/dav/lib/DAV/IProperties.php +++ b/vendor/sabre/dav/lib/DAV/IProperties.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * IProperties interface + * IProperties interface. * * Implement this interface to support custom WebDAV properties requested and sent from clients. * @@ -11,8 +13,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IProperties extends INode { - +interface IProperties extends INode +{ /** * Updates properties on this node. * @@ -23,9 +25,8 @@ interface IProperties extends INode { * Read the PropPatch documentation for more information. * * @param PropPatch $propPatch - * @return void */ - function propPatch(PropPatch $propPatch); + public function propPatch(PropPatch $propPatch); /** * Returns a list of properties for this nodes. @@ -40,8 +41,8 @@ interface IProperties extends INode { * The Server class will filter out the extra. * * @param array $properties + * * @return array */ - function getProperties($properties); - + public function getProperties($properties); } diff --git a/vendor/sabre/dav/lib/DAV/IQuota.php b/vendor/sabre/dav/lib/DAV/IQuota.php index e16f386b9..7d72e1174 100644 --- a/vendor/sabre/dav/lib/DAV/IQuota.php +++ b/vendor/sabre/dav/lib/DAV/IQuota.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * IQuota interface + * IQuota interface. * * Implement this interface to add the ability to return quota information. The ObjectTree * will check for quota information on any given node. If the information is not available it will @@ -13,14 +15,13 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IQuota extends ICollection { - +interface IQuota extends ICollection +{ /** - * Returns the quota information + * Returns the quota information. * * This method MUST return an array with 2 values, the first being the total used space, * the second the available space (in bytes) */ - function getQuotaInfo(); - + public function getQuotaInfo(); } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php index 044316cdb..a1bf48699 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; /** @@ -13,6 +15,6 @@ namespace Sabre\DAV\Locks\Backend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface { - +abstract class AbstractBackend implements BackendInterface +{ } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php index a2d2fe89c..9a6919f50 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; use Sabre\DAV\Locks; @@ -12,10 +14,10 @@ use Sabre\DAV\Locks; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** - * Returns a list of Sabre\DAV\Locks\LockInfo objects + * Returns a list of Sabre\DAV\Locks\LockInfo objects. * * This method should return all the locks for a particular uri, including * locks that might be set on a parent uri. @@ -24,27 +26,29 @@ interface BackendInterface { * any locks in the subtree of the uri for locks. * * @param string $uri - * @param bool $returnChildLocks + * @param bool $returnChildLocks + * * @return array */ - function getLocks($uri, $returnChildLocks); + public function getLocks($uri, $returnChildLocks); /** - * Locks a uri + * Locks a uri. * - * @param string $uri + * @param string $uri * @param Locks\LockInfo $lockInfo + * * @return bool */ - function lock($uri, Locks\LockInfo $lockInfo); + public function lock($uri, Locks\LockInfo $lockInfo); /** - * Removes a lock from a uri + * Removes a lock from a uri. * - * @param string $uri + * @param string $uri * @param Locks\LockInfo $lockInfo + * * @return bool */ - function unlock($uri, Locks\LockInfo $lockInfo); - + public function unlock($uri, Locks\LockInfo $lockInfo); } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php index 849539bee..5957f35dd 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; use Sabre\DAV\Locks\LockInfo; @@ -17,28 +19,27 @@ use Sabre\DAV\Locks\LockInfo; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends AbstractBackend { - +class File extends AbstractBackend +{ /** - * The storage file + * The storage file. * * @var string */ private $locksFile; /** - * Constructor + * Constructor. * * @param string $locksFile path to file */ - function __construct($locksFile) { - + public function __construct($locksFile) + { $this->locksFile = $locksFile; - } /** - * Returns a list of Sabre\DAV\Locks\LockInfo objects + * Returns a list of Sabre\DAV\Locks\LockInfo objects. * * This method should return all the locks for a particular uri, including * locks that might be set on a parent uri. @@ -47,47 +48,47 @@ class File extends AbstractBackend { * any locks in the subtree of the uri for locks. * * @param string $uri - * @param bool $returnChildLocks + * @param bool $returnChildLocks + * * @return array */ - function getLocks($uri, $returnChildLocks) { - + public function getLocks($uri, $returnChildLocks) + { $newLocks = []; $locks = $this->getData(); foreach ($locks as $lock) { - if ($lock->uri === $uri || //deep locks on parents - ($lock->depth != 0 && strpos($uri, $lock->uri . '/') === 0) || + (0 != $lock->depth && 0 === strpos($uri, $lock->uri.'/')) || // locks on children - ($returnChildLocks && (strpos($lock->uri, $uri . '/') === 0))) { - + ($returnChildLocks && (0 === strpos($lock->uri, $uri.'/')))) { $newLocks[] = $lock; - } - } // Checking if we can remove any of these locks foreach ($newLocks as $k => $lock) { - if (time() > $lock->timeout + $lock->created) unset($newLocks[$k]); + if (time() > $lock->timeout + $lock->created) { + unset($newLocks[$k]); + } } - return $newLocks; + return $newLocks; } /** - * Locks a uri + * Locks a uri. * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function lock($uri, LockInfo $lockInfo) { - + public function lock($uri, LockInfo $lockInfo) + { // We're making the lock timeout 30 minutes $lockInfo->timeout = 1800; $lockInfo->created = time(); @@ -105,32 +106,31 @@ class File extends AbstractBackend { } $locks[] = $lockInfo; $this->putData($locks); - return true; + return true; } /** - * Removes a lock from a uri + * Removes a lock from a uri. * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function unlock($uri, LockInfo $lockInfo) { - + public function unlock($uri, LockInfo $lockInfo) + { $locks = $this->getData(); foreach ($locks as $k => $lock) { - if ($lock->token == $lockInfo->token) { - unset($locks[$k]); $this->putData($locks); - return true; + return true; } } - return false; + return false; } /** @@ -138,9 +138,11 @@ class File extends AbstractBackend { * * @return array */ - protected function getData() { - - if (!file_exists($this->locksFile)) return []; + protected function getData() + { + if (!file_exists($this->locksFile)) { + return []; + } // opening up the file, and creating a shared lock $handle = fopen($this->locksFile, 'r'); @@ -155,19 +157,20 @@ class File extends AbstractBackend { // Unserializing and checking if the resource file contains data for this file $data = unserialize($data); - if (!$data) return []; - return $data; + if (!$data) { + return []; + } + return $data; } /** - * Saves the lockdata + * Saves the lockdata. * * @param array $newData - * @return void */ - protected function putData(array $newData) { - + protected function putData(array $newData) + { // opening up the file, and creating an exclusive lock $handle = fopen($this->locksFile, 'a+'); flock($handle, LOCK_EX); @@ -179,7 +182,5 @@ class File extends AbstractBackend { fwrite($handle, serialize($newData)); flock($handle, LOCK_UN); fclose($handle); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php index 510f266f7..36a12d1ab 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; use Sabre\DAV\Locks\LockInfo; @@ -14,8 +16,8 @@ use Sabre\DAV\Locks\LockInfo; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend { - +class PDO extends AbstractBackend +{ /** * The PDO tablename this backend uses. * @@ -24,25 +26,24 @@ class PDO extends AbstractBackend { public $tableName = 'locks'; /** - * The PDO connection object + * The PDO connection object. * * @var pdo */ protected $pdo; /** - * Constructor + * Constructor. * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** - * Returns a list of Sabre\DAV\Locks\LockInfo objects + * Returns a list of Sabre\DAV\Locks\LockInfo objects. * * This method should return all the locks for a particular uri, including * locks that might be set on a parent uri. @@ -51,16 +52,17 @@ class PDO extends AbstractBackend { * any locks in the subtree of the uri for locks. * * @param string $uri - * @param bool $returnChildLocks + * @param bool $returnChildLocks + * * @return array */ - function getLocks($uri, $returnChildLocks) { - + public function getLocks($uri, $returnChildLocks) + { // NOTE: the following 10 lines or so could be easily replaced by // pure sql. MySQL's non-standard string concatenation prevents us // from doing this though. - $query = 'SELECT owner, token, timeout, created, scope, depth, uri FROM ' . $this->tableName . ' WHERE (created > (? - timeout)) AND ((uri = ?)'; - $params = [time(),$uri]; + $query = 'SELECT owner, token, timeout, created, scope, depth, uri FROM '.$this->tableName.' WHERE (created > (? - timeout)) AND ((uri = ?)'; + $params = [time(), $uri]; // We need to check locks for every part in the uri. $uriParts = explode('/', $uri); @@ -71,20 +73,18 @@ class PDO extends AbstractBackend { $currentPath = ''; foreach ($uriParts as $part) { - - if ($currentPath) $currentPath .= '/'; + if ($currentPath) { + $currentPath .= '/'; + } $currentPath .= $part; $query .= ' OR (depth!=0 AND uri = ?)'; $params[] = $currentPath; - } if ($returnChildLocks) { - $query .= ' OR (uri LIKE ?)'; - $params[] = $uri . '/%'; - + $params[] = $uri.'/%'; } $query .= ')'; @@ -94,7 +94,6 @@ class PDO extends AbstractBackend { $lockList = []; foreach ($result as $row) { - $lockInfo = new LockInfo(); $lockInfo->owner = $row['owner']; $lockInfo->token = $row['token']; @@ -104,22 +103,21 @@ class PDO extends AbstractBackend { $lockInfo->depth = $row['depth']; $lockInfo->uri = $row['uri']; $lockList[] = $lockInfo; - } return $lockList; - } /** - * Locks a uri + * Locks a uri. * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function lock($uri, LockInfo $lockInfo) { - + public function lock($uri, LockInfo $lockInfo) + { // We're making the lock timeout 30 minutes $lockInfo->timeout = 30 * 60; $lockInfo->created = time(); @@ -128,11 +126,13 @@ class PDO extends AbstractBackend { $locks = $this->getLocks($uri, false); $exists = false; foreach ($locks as $lock) { - if ($lock->token == $lockInfo->token) $exists = true; + if ($lock->token == $lockInfo->token) { + $exists = true; + } } if ($exists) { - $stmt = $this->pdo->prepare('UPDATE ' . $this->tableName . ' SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?'); + $stmt = $this->pdo->prepare('UPDATE '.$this->tableName.' SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?'); $stmt->execute([ $lockInfo->owner, $lockInfo->timeout, @@ -140,10 +140,10 @@ class PDO extends AbstractBackend { $lockInfo->depth, $uri, $lockInfo->created, - $lockInfo->token + $lockInfo->token, ]); } else { - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->tableName . ' (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)'); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->tableName.' (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)'); $stmt->execute([ $lockInfo->owner, $lockInfo->timeout, @@ -151,30 +151,26 @@ class PDO extends AbstractBackend { $lockInfo->depth, $uri, $lockInfo->created, - $lockInfo->token + $lockInfo->token, ]); } return true; - } - - /** - * Removes a lock from a uri + * Removes a lock from a uri. * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function unlock($uri, LockInfo $lockInfo) { - - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->tableName . ' WHERE uri = ? AND token = ?'); + public function unlock($uri, LockInfo $lockInfo) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->tableName.' WHERE uri = ? AND token = ?'); $stmt->execute([$uri, $lockInfo->token]); - return $stmt->rowCount() === 1; - + return 1 === $stmt->rowCount(); } - } diff --git a/vendor/sabre/dav/lib/DAV/Locks/LockInfo.php b/vendor/sabre/dav/lib/DAV/Locks/LockInfo.php index 2c8cca0fe..df8227566 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/LockInfo.php +++ b/vendor/sabre/dav/lib/DAV/Locks/LockInfo.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks; /** - * LockInfo class + * LockInfo class. * * An object of the LockInfo class holds all the information relevant to a * single lock. @@ -12,69 +14,69 @@ namespace Sabre\DAV\Locks; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class LockInfo { - +class LockInfo +{ /** - * A shared lock + * A shared lock. */ const SHARED = 1; /** - * An exclusive lock + * An exclusive lock. */ const EXCLUSIVE = 2; /** - * A never expiring timeout + * A never expiring timeout. */ const TIMEOUT_INFINITE = -1; /** - * The owner of the lock + * The owner of the lock. * * @var string */ public $owner; /** - * The locktoken + * The locktoken. * * @var string */ public $token; /** - * How long till the lock is expiring + * How long till the lock is expiring. * * @var int */ public $timeout; /** - * UNIX Timestamp of when this lock was created + * UNIX Timestamp of when this lock was created. * * @var int */ public $created; /** - * Exclusive or shared lock + * Exclusive or shared lock. * * @var int */ public $scope = self::EXCLUSIVE; /** - * Depth of lock, can be 0 or Sabre\DAV\Server::DEPTH_INFINITY + * Depth of lock, can be 0 or Sabre\DAV\Server::DEPTH_INFINITY. */ public $depth = 0; /** - * The uri this lock locks + * The uri this lock locks. * * TODO: This value is not always set + * * @var mixed */ public $uri; - } diff --git a/vendor/sabre/dav/lib/DAV/Locks/Plugin.php b/vendor/sabre/dav/lib/DAV/Locks/Plugin.php index 41a3bf3fa..6d3e9b883 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks; use Sabre\DAV; @@ -7,7 +9,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * Locking plugin + * Locking plugin. * * This plugin provides locking support to a WebDAV server. * The easiest way to get started, is by hooking it up as such: @@ -20,53 +22,50 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * locksBackend + * locksBackend. * * @var Backend\BackendInterface */ protected $locksBackend; /** - * server + * server. * * @var DAV\Server */ protected $server; /** - * __construct + * __construct. * * @param Backend\BackendInterface $locksBackend */ - function __construct(Backend\BackendInterface $locksBackend) { - + public function __construct(Backend\BackendInterface $locksBackend) + { $this->locksBackend = $locksBackend; - } /** - * Initializes the plugin + * Initializes the plugin. * * This method is automatically called by the Server class after addPlugin. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->xml->elementMap['{DAV:}lockinfo'] = 'Sabre\\DAV\\Xml\\Request\\Lock'; - $server->on('method:LOCK', [$this, 'httpLock']); - $server->on('method:UNLOCK', [$this, 'httpUnlock']); + $server->on('method:LOCK', [$this, 'httpLock']); + $server->on('method:UNLOCK', [$this, 'httpUnlock']); $server->on('validateTokens', [$this, 'validateTokens']); - $server->on('propFind', [$this, 'propFind']); - $server->on('afterUnbind', [$this, 'afterUnbind']); - + $server->on('propFind', [$this, 'propFind']); + $server->on('afterUnbind', [$this, 'afterUnbind']); } /** @@ -77,31 +76,28 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'locks'; - } /** * This method is called after most properties have been found - * it allows us to add in any Lock-related properties + * it allows us to add in any Lock-related properties. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFind(DAV\PropFind $propFind, DAV\INode $node) { - - $propFind->handle('{DAV:}supportedlock', function() { + public function propFind(DAV\PropFind $propFind, DAV\INode $node) + { + $propFind->handle('{DAV:}supportedlock', function () { return new DAV\Xml\Property\SupportedLock(); }); - $propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) { + $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) { return new DAV\Xml\Property\LockDiscovery( $this->getLocks($propFind->getPath()) ); }); - } /** @@ -112,12 +108,12 @@ class Plugin extends DAV\ServerPlugin { * available for the specified uri. * * @param string $uri + * * @return array */ - function getHTTPMethods($uri) { - - return ['LOCK','UNLOCK']; - + public function getHTTPMethods($uri) + { + return ['LOCK', 'UNLOCK']; } /** @@ -128,14 +124,13 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return [2]; - } /** - * Returns all lock information on a particular uri + * Returns all lock information on a particular uri. * * This function should return an array with Sabre\DAV\Locks\LockInfo objects. If there are no locks on a file, return an empty array. * @@ -144,17 +139,17 @@ class Plugin extends DAV\ServerPlugin { * for any possible locks and return those as well. * * @param string $uri - * @param bool $returnChildLocks + * @param bool $returnChildLocks + * * @return array */ - function getLocks($uri, $returnChildLocks = false) { - + public function getLocks($uri, $returnChildLocks = false) + { return $this->locksBackend->getLocks($uri, $returnChildLocks); - } /** - * Locks an uri + * Locks an uri. * * The WebDAV lock request can be operated to either create a new lock on a file, or to refresh an existing lock * If a new lock is created, a full XML body should be supplied, containing information about the lock such as the type @@ -164,12 +159,13 @@ class Plugin extends DAV\ServerPlugin { * * Additionally, a lock can be requested for a non-existent file. In these case we're obligated to create an empty file as per RFC4918:S7.3 * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpLock(RequestInterface $request, ResponseInterface $response) { - + public function httpLock(RequestInterface $request, ResponseInterface $response) + { $uri = $request->getPath(); $existingLocks = $this->getLocks($uri); @@ -180,7 +176,7 @@ class Plugin extends DAV\ServerPlugin { $existingLock = null; // Checking if there's already non-shared locks on the uri. foreach ($existingLocks as $existingLock) { - if ($existingLock->scope === LockInfo::EXCLUSIVE) { + if (LockInfo::EXCLUSIVE === $existingLock->scope) { throw new DAV\Exception\ConflictingLock($existingLock); } } @@ -188,11 +184,10 @@ class Plugin extends DAV\ServerPlugin { $lockInfo = $this->parseLockRequest($body); $lockInfo->depth = $this->server->getHTTPDepth(); $lockInfo->uri = $uri; - if ($existingLock && $lockInfo->scope != LockInfo::SHARED) + if ($existingLock && LockInfo::SHARED != $lockInfo->scope) { throw new DAV\Exception\ConflictingLock($existingLock); - + } } else { - // Gonna check if this was a lock refresh. $existingLocks = $this->getLocks($uri); $conditions = $this->server->getIfConditions($request); @@ -201,7 +196,7 @@ class Plugin extends DAV\ServerPlugin { foreach ($existingLocks as $existingLock) { foreach ($conditions as $condition) { foreach ($condition['tokens'] as $token) { - if ($token['token'] === 'opaquelocktoken:' . $existingLock->token) { + if ($token['token'] === 'opaquelocktoken:'.$existingLock->token) { $found = $existingLock; break 3; } @@ -216,18 +211,20 @@ class Plugin extends DAV\ServerPlugin { } else { throw new DAV\Exception\BadRequest('An xml body is required for lock requests'); } - } // This must have been a lock refresh $lockInfo = $found; // The resource could have been locked through another uri. - if ($uri != $lockInfo->uri) $uri = $lockInfo->uri; - + if ($uri != $lockInfo->uri) { + $uri = $lockInfo->uri; + } } - if ($timeout = $this->getTimeoutHeader()) $lockInfo->timeout = $timeout; + if ($timeout = $this->getTimeoutHeader()) { + $lockInfo->timeout = $timeout; + } $newFile = false; @@ -240,56 +237,52 @@ class Plugin extends DAV\ServerPlugin { // // See Issue 222 // $this->server->emit('beforeWriteContent',array($uri)); - } catch (DAV\Exception\NotFound $e) { - // It didn't, lets create it $this->server->createFile($uri, fopen('php://memory', 'r')); $newFile = true; - } $this->lockNode($uri, $lockInfo); $response->setHeader('Content-Type', 'application/xml; charset=utf-8'); - $response->setHeader('Lock-Token', '<opaquelocktoken:' . $lockInfo->token . '>'); + $response->setHeader('Lock-Token', '<opaquelocktoken:'.$lockInfo->token.'>'); $response->setStatus($newFile ? 201 : 200); $response->setBody($this->generateLockResponse($lockInfo)); // Returning false will interrupt the event chain and mark this method // as 'handled'. return false; - } /** - * Unlocks a uri + * Unlocks a uri. * * This WebDAV method allows you to remove a lock from a node. The client should provide a valid locktoken through the Lock-token http header * The server should return 204 (No content) on success * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpUnlock(RequestInterface $request, ResponseInterface $response) { - + public function httpUnlock(RequestInterface $request, ResponseInterface $response) + { $lockToken = $request->getHeader('Lock-Token'); // If the locktoken header is not supplied, we need to throw a bad request exception - if (!$lockToken) throw new DAV\Exception\BadRequest('No lock token was supplied'); - + if (!$lockToken) { + throw new DAV\Exception\BadRequest('No lock token was supplied'); + } $path = $request->getPath(); $locks = $this->getLocks($path); // Windows sometimes forgets to include < and > in the Lock-Token // header - if ($lockToken[0] !== '<') $lockToken = '<' . $lockToken . '>'; + if ('<' !== $lockToken[0]) { + $lockToken = '<'.$lockToken.'>'; + } foreach ($locks as $lock) { - - if ('<opaquelocktoken:' . $lock->token . '>' == $lockToken) { - + if ('<opaquelocktoken:'.$lock->token.'>' == $lockToken) { $this->unlockNode($path, $lock); $response->setHeader('Content-Length', '0'); $response->setStatus(204); @@ -297,14 +290,11 @@ class Plugin extends DAV\ServerPlugin { // Returning false will break the method chain, and mark the // method as 'handled'. return false; - } - } // If we got here, it means the locktoken was invalid throw new DAV\Exception\LockTokenMatchesRequestUri(); - } /** @@ -313,51 +303,54 @@ class Plugin extends DAV\ServerPlugin { * We use this event to clean up any locks that still exist on the node. * * @param string $path - * @return void */ - function afterUnbind($path) { - + public function afterUnbind($path) + { $locks = $this->getLocks($path, $includeChildren = true); foreach ($locks as $lock) { $this->unlockNode($path, $lock); } - } /** - * Locks a uri + * Locks a uri. * * All the locking information is supplied in the lockInfo object. The object has a suggested timeout, but this can be safely ignored * It is important that if the existing timeout is ignored, the property is overwritten, as this needs to be sent back to the client * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function lockNode($uri, LockInfo $lockInfo) { + public function lockNode($uri, LockInfo $lockInfo) + { + if (!$this->server->emit('beforeLock', [$uri, $lockInfo])) { + return; + } - if (!$this->server->emit('beforeLock', [$uri, $lockInfo])) return; return $this->locksBackend->lock($uri, $lockInfo); - } /** - * Unlocks a uri + * Unlocks a uri. * * This method removes a lock from a uri. It is assumed all the supplied information is correct and verified * - * @param string $uri + * @param string $uri * @param LockInfo $lockInfo + * * @return bool */ - function unlockNode($uri, LockInfo $lockInfo) { + public function unlockNode($uri, LockInfo $lockInfo) + { + if (!$this->server->emit('beforeUnlock', [$uri, $lockInfo])) { + return; + } - if (!$this->server->emit('beforeUnlock', [$uri, $lockInfo])) return; return $this->locksBackend->unlock($uri, $lockInfo); - } - /** * Returns the contents of the HTTP Timeout header. * @@ -365,37 +358,36 @@ class Plugin extends DAV\ServerPlugin { * * @return int */ - function getTimeoutHeader() { - + public function getTimeoutHeader() + { $header = $this->server->httpRequest->getHeader('Timeout'); if ($header) { - - if (stripos($header, 'second-') === 0) $header = (int)(substr($header, 7)); - elseif (stripos($header, 'infinite') === 0) $header = LockInfo::TIMEOUT_INFINITE; - else throw new DAV\Exception\BadRequest('Invalid HTTP timeout header'); - + if (0 === stripos($header, 'second-')) { + $header = (int) (substr($header, 7)); + } elseif (0 === stripos($header, 'infinite')) { + $header = LockInfo::TIMEOUT_INFINITE; + } else { + throw new DAV\Exception\BadRequest('Invalid HTTP timeout header'); + } } else { - $header = 0; - } return $header; - } /** - * Generates the response for successful LOCK requests + * Generates the response for successful LOCK requests. * * @param LockInfo $lockInfo + * * @return string */ - protected function generateLockResponse(LockInfo $lockInfo) { - + protected function generateLockResponse(LockInfo $lockInfo) + { return $this->server->xml->write('{DAV:}prop', [ - '{DAV:}lockdiscovery' => - new DAV\Xml\Property\LockDiscovery([$lockInfo]) + '{DAV:}lockdiscovery' => new DAV\Xml\Property\LockDiscovery([$lockInfo]), ]); } @@ -410,11 +402,10 @@ class Plugin extends DAV\ServerPlugin { * tokens. * * @param RequestInterface $request - * @param mixed $conditions - * @return void + * @param mixed $conditions */ - function validateTokens(RequestInterface $request, &$conditions) { - + public function validateTokens(RequestInterface $request, &$conditions) + { // First we need to gather a list of locks that must be satisfied. $mustLocks = []; $method = $request->getMethod(); @@ -422,24 +413,23 @@ class Plugin extends DAV\ServerPlugin { // Methods not in that list are operations that doesn't alter any // resources, and we don't need to check the lock-states for. switch ($method) { - - case 'DELETE' : + case 'DELETE': $mustLocks = array_merge($mustLocks, $this->getLocks( $request->getPath(), true )); break; - case 'MKCOL' : - case 'MKCALENDAR' : - case 'PROPPATCH' : - case 'PUT' : - case 'PATCH' : + case 'MKCOL': + case 'MKCALENDAR': + case 'PROPPATCH': + case 'PUT': + case 'PATCH': $mustLocks = array_merge($mustLocks, $this->getLocks( $request->getPath(), false )); break; - case 'MOVE' : + case 'MOVE': $mustLocks = array_merge($mustLocks, $this->getLocks( $request->getPath(), true @@ -449,13 +439,13 @@ class Plugin extends DAV\ServerPlugin { false )); break; - case 'COPY' : + case 'COPY': $mustLocks = array_merge($mustLocks, $this->getLocks( $this->server->calculateUri($request->getHeader('Destination')), false )); break; - case 'LOCK' : + case 'LOCK': //Temporary measure.. figure out later why this is needed // Here we basically ignore all incoming tokens... foreach ($conditions as $ii => $condition) { @@ -463,31 +453,29 @@ class Plugin extends DAV\ServerPlugin { $conditions[$ii]['tokens'][$jj]['validToken'] = true; } } - return; + return; } // It's possible that there's identical locks, because of shared // parents. We're removing the duplicates here. $tmp = []; - foreach ($mustLocks as $lock) $tmp[$lock->token] = $lock; + foreach ($mustLocks as $lock) { + $tmp[$lock->token] = $lock; + } $mustLocks = array_values($tmp); foreach ($conditions as $kk => $condition) { - foreach ($condition['tokens'] as $ii => $token) { - // Lock tokens always start with opaquelocktoken: - if (substr($token['token'], 0, 16) !== 'opaquelocktoken:') { + if ('opaquelocktoken:' !== substr($token['token'], 0, 16)) { continue; } $checkToken = substr($token['token'], 16); // Looping through our list with locks. foreach ($mustLocks as $jj => $mustLock) { - if ($mustLock->token == $checkToken) { - // We have a match! // Removing this one from mustlocks unset($mustLocks[$jj]); @@ -497,9 +485,7 @@ class Plugin extends DAV\ServerPlugin { // Advancing to the next token continue 2; - } - } // If we got here, it means that there was a @@ -514,42 +500,34 @@ class Plugin extends DAV\ServerPlugin { // lock-token that was expired. $oddLocks = $this->getLocks($condition['uri']); foreach ($oddLocks as $oddLock) { - if ($oddLock->token === $checkToken) { - // We have a hit! $conditions[$kk]['tokens'][$ii]['validToken'] = true; continue 2; - } } // If we get all the way here, the lock-token was // really unknown. - - } - } // If there's any locks left in the 'mustLocks' array, it means that // the resource was locked and we must block it. if ($mustLocks) { - throw new DAV\Exception\Locked(reset($mustLocks)); - } - } /** - * Parses a webdav lock xml body, and returns a new Sabre\DAV\Locks\LockInfo object + * Parses a webdav lock xml body, and returns a new Sabre\DAV\Locks\LockInfo object. * * @param string $body + * * @return LockInfo */ - protected function parseLockRequest($body) { - + protected function parseLockRequest($body) + { $result = $this->server->xml->expect( '{DAV:}lockinfo', $body @@ -562,7 +540,6 @@ class Plugin extends DAV\ServerPlugin { $lockInfo->scope = $result->scope; return $lockInfo; - } /** @@ -576,14 +553,12 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'The locks plugin turns this server into a class-2 WebDAV server and adds support for LOCK and UNLOCK', - 'link' => 'http://sabre.io/dav/locks/', + 'link' => 'http://sabre.io/dav/locks/', ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/MkCol.php b/vendor/sabre/dav/lib/DAV/MkCol.php index 042e14bca..f3c5ea5c0 100644 --- a/vendor/sabre/dav/lib/DAV/MkCol.php +++ b/vendor/sabre/dav/lib/DAV/MkCol.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -20,8 +22,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MkCol extends PropPatch { - +class MkCol extends PropPatch +{ /** * A list of resource-types in clark-notation. * @@ -32,14 +34,13 @@ class MkCol extends PropPatch { /** * Creates the MKCOL object. * - * @param string[] $resourceType List of resourcetype values. - * @param array $mutations List of new properties values. + * @param string[] $resourceType list of resourcetype values + * @param array $mutations list of new properties values */ - function __construct(array $resourceType, array $mutations) { - + public function __construct(array $resourceType, array $mutations) + { $this->resourceType = $resourceType; parent::__construct($mutations); - } /** @@ -47,10 +48,9 @@ class MkCol extends PropPatch { * * @return string[] */ - function getResourceType() { - + public function getResourceType() + { return $this->resourceType; - } /** @@ -61,12 +61,11 @@ class MkCol extends PropPatch { * checked. * * @param string|string[] $resourceType + * * @return bool */ - function hasResourceType($resourceType) { - - return count(array_diff((array)$resourceType, $this->resourceType)) === 0; - + public function hasResourceType($resourceType) + { + return 0 === count(array_diff((array) $resourceType, $this->resourceType)); } - } diff --git a/vendor/sabre/dav/lib/DAV/Mount/Plugin.php b/vendor/sabre/dav/lib/DAV/Mount/Plugin.php index dc923ad85..5eaa4d462 100644 --- a/vendor/sabre/dav/lib/DAV/Mount/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Mount/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Mount; use Sabre\DAV; @@ -7,7 +9,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * This plugin provides support for RFC4709: Mounting WebDAV servers + * This plugin provides support for RFC4709: Mounting WebDAV servers. * * Simply append ?mount to any collection to generate the davmount response. * @@ -15,40 +17,41 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * Reference to Server class + * Reference to Server class. * * @var DAV\Server */ protected $server; /** - * Initializes the plugin and registers event handles + * Initializes the plugin and registers event handles. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $this->server->on('method:GET', [$this, 'httpGet'], 90); - } /** * 'beforeMethod' event handles. This event handles intercepts GET requests ending - * with ?mount + * with ?mount. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $response) { - + public function httpGet(RequestInterface $request, ResponseInterface $response) + { $queryParams = $request->getQueryParameters(); - if (!array_key_exists('mount', $queryParams)) return; + if (!array_key_exists('mount', $queryParams)) { + return; + } $currentUri = $request->getAbsoluteUrl(); @@ -59,28 +62,23 @@ class Plugin extends DAV\ServerPlugin { // Returning false to break the event chain return false; - } /** - * Generates the davmount response + * Generates the davmount response. * * @param ResponseInterface $response - * @param string $uri absolute uri - * @return void + * @param string $uri absolute uri */ - function davMount(ResponseInterface $response, $uri) { - + public function davMount(ResponseInterface $response, $uri) + { $response->setStatus(200); $response->setHeader('Content-Type', 'application/davmount+xml'); ob_start(); echo '<?xml version="1.0"?>', "\n"; echo "<dm:mount xmlns:dm=\"http://purl.org/NET/webdav/mount\">\n"; - echo " <dm:url>", htmlspecialchars($uri, ENT_NOQUOTES, 'UTF-8'), "</dm:url>\n"; - echo "</dm:mount>"; + echo ' <dm:url>', htmlspecialchars($uri, ENT_NOQUOTES, 'UTF-8'), "</dm:url>\n"; + echo '</dm:mount>'; $response->setBody(ob_get_clean()); - } - - } diff --git a/vendor/sabre/dav/lib/DAV/Node.php b/vendor/sabre/dav/lib/DAV/Node.php index ef6eea18e..948060d9a 100644 --- a/vendor/sabre/dav/lib/DAV/Node.php +++ b/vendor/sabre/dav/lib/DAV/Node.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * Node class + * Node class. * * This is a helper class, that should aid in getting nodes setup. * @@ -11,8 +13,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Node implements INode { - +abstract class Node implements INode +{ /** * Returns the last modification time as a unix timestamp. * @@ -20,35 +22,30 @@ abstract class Node implements INode { * * @return int */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** - * Deletes the current node + * Deletes the current node. * * @throws Exception\Forbidden - * @return void */ - function delete() { - + public function delete() + { throw new Exception\Forbidden('Permission denied to delete node'); - } /** - * Renames the node + * Renames the node. * * @param string $name The new name + * * @throws Exception\Forbidden - * @return void */ - function setName($name) { - + public function setName($name) + { throw new Exception\Forbidden('Permission denied to rename file'); - } - } diff --git a/vendor/sabre/dav/lib/DAV/PartialUpdate/IPatchSupport.php b/vendor/sabre/dav/lib/DAV/PartialUpdate/IPatchSupport.php index 97d24f9cb..e516f4d08 100644 --- a/vendor/sabre/dav/lib/DAV/PartialUpdate/IPatchSupport.php +++ b/vendor/sabre/dav/lib/DAV/PartialUpdate/IPatchSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PartialUpdate; use Sabre\DAV; @@ -7,14 +9,14 @@ use Sabre\DAV; /** * This interface provides a way to modify only part of a target resource * It may be used to update a file chunk, upload big a file into smaller - * chunks or resume an upload + * chunks or resume an upload. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Jean-Tiare LE BIGOT (http://www.jtlebi.fr/) * @license http://sabre.io/license/ Modified BSD License */ -interface IPatchSupport extends DAV\IFile { - +interface IPatchSupport extends DAV\IFile +{ /** * Updates the file based on a range specification. * @@ -38,10 +40,10 @@ interface IPatchSupport extends DAV\IFile { * time. * * @param resource|string $data - * @param int $rangeType - * @param int $offset + * @param int $rangeType + * @param int $offset + * * @return string|null */ - function patch($data, $rangeType, $offset = null); - + public function patch($data, $rangeType, $offset = null); } diff --git a/vendor/sabre/dav/lib/DAV/PartialUpdate/Plugin.php b/vendor/sabre/dav/lib/DAV/PartialUpdate/Plugin.php index 9c129d705..f8ffc3706 100644 --- a/vendor/sabre/dav/lib/DAV/PartialUpdate/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/PartialUpdate/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PartialUpdate; use Sabre\DAV; @@ -7,7 +9,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * Partial update plugin (Patch method) + * Partial update plugin (Patch method). * * This plugin provides a way to modify only part of a target resource * It may bu used to update a file chunk, upload big a file into smaller @@ -20,32 +22,30 @@ use Sabre\HTTP\ResponseInterface; * @author Jean-Tiare LE BIGOT (http://www.jtlebi.fr/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ const RANGE_APPEND = 1; const RANGE_START = 2; const RANGE_END = 3; /** - * Reference to server + * Reference to server. * * @var DAV\Server */ protected $server; /** - * Initializes the plugin + * Initializes the plugin. * * This method is automatically called by the Server class after addPlugin. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $server->on('method:PATCH', [$this, 'httpPatch']); - } /** @@ -56,10 +56,9 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'partialupdate'; - } /** @@ -74,10 +73,11 @@ class Plugin extends DAV\ServerPlugin { * - the node implements our partial update interface * * @param string $uri + * * @return array */ - function getHTTPMethods($uri) { - + public function getHTTPMethods($uri) + { $tree = $this->server->tree; if ($tree->nodeExists($uri)) { @@ -86,8 +86,8 @@ class Plugin extends DAV\ServerPlugin { return ['PATCH']; } } - return []; + return []; } /** @@ -95,25 +95,23 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['sabredav-partialupdate']; - } /** - * Patch an uri + * Patch an uri. * * The WebDAV patch request can be used to modify only a part of an * existing resource. If the resource does not exist yet and the first * offset is not 0, the request fails * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function httpPatch(RequestInterface $request, ResponseInterface $response) { - + public function httpPatch(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); // Get the node. Will throw a 404 if not found @@ -129,53 +127,55 @@ class Plugin extends DAV\ServerPlugin { } $contentType = strtolower( - $request->getHeader('Content-Type') + (string) $request->getHeader('Content-Type') ); - if ($contentType != 'application/x-sabredav-partialupdate') { - throw new DAV\Exception\UnsupportedMediaType('Unknown Content-Type header "' . $contentType . '"'); + if ('application/x-sabredav-partialupdate' != $contentType) { + throw new DAV\Exception\UnsupportedMediaType('Unknown Content-Type header "'.$contentType.'"'); } $len = $this->server->httpRequest->getHeader('Content-Length'); - if (!$len) throw new DAV\Exception\LengthRequired('A Content-Length header is required'); - + if (!$len) { + throw new DAV\Exception\LengthRequired('A Content-Length header is required'); + } switch ($range[0]) { - case self::RANGE_START : + case self::RANGE_START: // Calculate the end-range if it doesn't exist. if (!$range[2]) { $range[2] = $range[1] + $len - 1; } else { if ($range[2] < $range[1]) { - throw new DAV\Exception\RequestedRangeNotSatisfiable('The end offset (' . $range[2] . ') is lower than the start offset (' . $range[1] . ')'); + throw new DAV\Exception\RequestedRangeNotSatisfiable('The end offset ('.$range[2].') is lower than the start offset ('.$range[1].')'); } if ($range[2] - $range[1] + 1 != $len) { - throw new DAV\Exception\RequestedRangeNotSatisfiable('Actual data length (' . $len . ') is not consistent with begin (' . $range[1] . ') and end (' . $range[2] . ') offsets'); + throw new DAV\Exception\RequestedRangeNotSatisfiable('Actual data length ('.$len.') is not consistent with begin ('.$range[1].') and end ('.$range[2].') offsets'); } } break; } - if (!$this->server->emit('beforeWriteContent', [$path, $node, null])) + if (!$this->server->emit('beforeWriteContent', [$path, $node, null])) { return; + } $body = $this->server->httpRequest->getBody(); - $etag = $node->patch($body, $range[0], isset($range[1]) ? $range[1] : null); $this->server->emit('afterWriteContent', [$path, $node]); $response->setHeader('Content-Length', '0'); - if ($etag) $response->setHeader('ETag', $etag); + if ($etag) { + $response->setHeader('ETag', $etag); + } $response->setStatus(204); // Breaks the event chain return false; - } /** - * Returns the HTTP custom range update header + * Returns the HTTP custom range update header. * * This method returns null if there is no well-formed HTTP range request * header. It returns array(1) if it was an append request, array(2, @@ -192,24 +192,28 @@ class Plugin extends DAV\ServerPlugin { * [3,-5] - update from 5 bytes from the end of the file. * * @param RequestInterface $request + * * @return array|null */ - function getHTTPUpdateRange(RequestInterface $request) { - + public function getHTTPUpdateRange(RequestInterface $request) + { $range = $request->getHeader('X-Update-Range'); - if (is_null($range)) return null; + if (is_null($range)) { + return null; + } // Matching "Range: bytes=1234-5678: both numbers are optional - if (!preg_match('/^(append)|(?:bytes=([0-9]+)-([0-9]*))|(?:bytes=(-[0-9]+))$/i', $range, $matches)) return null; + if (!preg_match('/^(append)|(?:bytes=([0-9]+)-([0-9]*))|(?:bytes=(-[0-9]+))$/i', $range, $matches)) { + return null; + } - if ($matches[1] === 'append') { + if ('append' === $matches[1]) { return [self::RANGE_APPEND]; } elseif (strlen($matches[2]) > 0) { - return [self::RANGE_START, $matches[2], $matches[3] ?: null]; + return [self::RANGE_START, (int) $matches[2], (int) $matches[3] ?: null]; } else { - return [self::RANGE_END, $matches[4]]; + return [self::RANGE_END, (int) $matches[4]]; } - } } diff --git a/vendor/sabre/dav/lib/DAV/PropFind.php b/vendor/sabre/dav/lib/DAV/PropFind.php index 0940a1ce2..4b6fe28eb 100644 --- a/vendor/sabre/dav/lib/DAV/PropFind.php +++ b/vendor/sabre/dav/lib/DAV/PropFind.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -8,10 +10,10 @@ namespace Sabre\DAV; * It contains the type of PROPFIND request, which properties were requested * and also the returned items. */ -class PropFind { - +class PropFind +{ /** - * A normal propfind + * A normal propfind. */ const NORMAL = 0; @@ -33,21 +35,21 @@ class PropFind { const PROPNAME = 2; /** - * Creates the PROPFIND object + * Creates the PROPFIND object. * * @param string $path - * @param array $properties - * @param int $depth - * @param int $requestType + * @param array $properties + * @param int $depth + * @param int $requestType */ - function __construct($path, array $properties, $depth = 0, $requestType = self::NORMAL) { - + public function __construct($path, array $properties, $depth = 0, $requestType = self::NORMAL) + { $this->path = $path; $this->properties = $properties; $this->depth = $depth; $this->requestType = $requestType; - if ($requestType === self::ALLPROPS) { + if (self::ALLPROPS === $requestType) { $this->properties = [ '{DAV:}getlastmodified', '{DAV:}getcontentlength', @@ -60,13 +62,10 @@ class PropFind { } foreach ($this->properties as $propertyName) { - // Seeding properties with 404's. $this->result[$propertyName] = [404, null]; - } $this->itemsLeft = count($this->result); - } /** @@ -88,68 +87,65 @@ class PropFind { * It's also possible to not pass a callback, but immediately pass a value * * @param string $propertyName - * @param mixed $valueOrCallBack - * @return void + * @param mixed $valueOrCallBack */ - function handle($propertyName, $valueOrCallBack) { - - if ($this->itemsLeft && isset($this->result[$propertyName]) && $this->result[$propertyName][0] === 404) { + public function handle($propertyName, $valueOrCallBack) + { + if ($this->itemsLeft && isset($this->result[$propertyName]) && 404 === $this->result[$propertyName][0]) { if (is_callable($valueOrCallBack)) { $value = $valueOrCallBack(); } else { $value = $valueOrCallBack; } if (!is_null($value)) { - $this->itemsLeft--; + --$this->itemsLeft; $this->result[$propertyName] = [200, $value]; } } - } /** - * Sets the value of the property + * Sets the value of the property. * * If status is not supplied, the status will default to 200 for non-null * properties, and 404 for null properties. * * @param string $propertyName - * @param mixed $value - * @param int $status - * @return void + * @param mixed $value + * @param int $status */ - function set($propertyName, $value, $status = null) { - + public function set($propertyName, $value, $status = null) + { if (is_null($status)) { $status = is_null($value) ? 404 : 200; } // If this is an ALLPROPS request and the property is // unknown, add it to the result; else ignore it: if (!isset($this->result[$propertyName])) { - if ($this->requestType === self::ALLPROPS) { + if (self::ALLPROPS === $this->requestType) { $this->result[$propertyName] = [$status, $value]; } + return; } - if ($status !== 404 && $this->result[$propertyName][0] === 404) { - $this->itemsLeft--; - } elseif ($status === 404 && $this->result[$propertyName][0] !== 404) { - $this->itemsLeft++; + if (404 !== $status && 404 === $this->result[$propertyName][0]) { + --$this->itemsLeft; + } elseif (404 === $status && 404 !== $this->result[$propertyName][0]) { + ++$this->itemsLeft; } $this->result[$propertyName] = [$status, $value]; - } /** * Returns the current value for a property. * * @param string $propertyName + * * @return mixed */ - function get($propertyName) { - + public function get($propertyName) + { return isset($this->result[$propertyName]) ? $this->result[$propertyName][1] : null; - } /** @@ -159,24 +155,22 @@ class PropFind { * null will be returned. * * @param string $propertyName + * * @return int|null */ - function getStatus($propertyName) { - + public function getStatus($propertyName) + { return isset($this->result[$propertyName]) ? $this->result[$propertyName][0] : null; - } /** * Updates the path for this PROPFIND. * * @param string $path - * @return void */ - function setPath($path) { - + public function setPath($path) + { $this->path = $path; - } /** @@ -184,10 +178,9 @@ class PropFind { * * @return string */ - function getPath() { - + public function getPath() + { return $this->path; - } /** @@ -195,22 +188,19 @@ class PropFind { * * @return int */ - function getDepth() { - + public function getDepth() + { return $this->depth; - } /** * Updates the depth of this propfind request. * * @param int $depth - * @return void */ - function setDepth($depth) { - + public function setDepth($depth) + { $this->depth = $depth; - } /** @@ -219,19 +209,19 @@ class PropFind { * * @return array */ - function get404Properties() { - - if ($this->itemsLeft === 0) { + public function get404Properties() + { + if (0 === $this->itemsLeft) { return []; } $result = []; foreach ($this->result as $propertyName => $stuff) { - if ($stuff[0] === 404) { + if (404 === $stuff[0]) { $result[] = $propertyName; } } - return $result; + return $result; } /** @@ -241,10 +231,9 @@ class PropFind { * * @return array */ - function getRequestedProperties() { - + public function getRequestedProperties() + { return $this->properties; - } /** @@ -252,10 +241,9 @@ class PropFind { * * @return bool */ - function isAllProps() { - - return $this->requestType === self::ALLPROPS; - + public function isAllProps() + { + return self::ALLPROPS === $this->requestType; } /** @@ -270,8 +258,8 @@ class PropFind { * * @return array */ - function getResultForMultiStatus() { - + public function getResultForMultiStatus() + { $r = [ 200 => [], 404 => [], @@ -284,9 +272,11 @@ class PropFind { } } // Removing the 404's for multi-status requests. - if ($this->requestType === self::ALLPROPS) unset($r[404]); - return $r; + if (self::ALLPROPS === $this->requestType) { + unset($r[404]); + } + return $r; } /** @@ -307,12 +297,12 @@ class PropFind { protected $depth = 0; /** - * The type of request. See the TYPE constants + * The type of request. See the TYPE constants. */ protected $requestType; /** - * A list of requested properties + * A list of requested properties. * * @var array */ @@ -343,5 +333,4 @@ class PropFind { * @var int */ protected $itemsLeft; - } diff --git a/vendor/sabre/dav/lib/DAV/PropPatch.php b/vendor/sabre/dav/lib/DAV/PropPatch.php index 6d599dacc..160bdb1a8 100644 --- a/vendor/sabre/dav/lib/DAV/PropPatch.php +++ b/vendor/sabre/dav/lib/DAV/PropPatch.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use UnexpectedValueException; @@ -17,8 +19,8 @@ use UnexpectedValueException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PropPatch { - +class PropPatch +{ /** * Properties that are being updated. * @@ -52,14 +54,13 @@ class PropPatch { protected $failed = false; /** - * Constructor + * Constructor. * * @param array $mutations A list of updates */ - function __construct(array $mutations) { - + public function __construct(array $mutations) + { $this->mutations = $mutations; - } /** @@ -81,21 +82,17 @@ class PropPatch { * code associated with the operation. * * @param string|string[] $properties - * @param callable $callback - * @return void + * @param callable $callback */ - function handle($properties, callable $callback) { - + public function handle($properties, callable $callback) + { $usedProperties = []; - foreach ((array)$properties as $propertyName) { - + foreach ((array) $properties as $propertyName) { if (array_key_exists($propertyName, $this->mutations) && !isset($this->result[$propertyName])) { - $usedProperties[] = $propertyName; // HTTP Accepted $this->result[$propertyName] = 202; } - } // Only registering if there's any unhandled properties. @@ -107,9 +104,8 @@ class PropPatch { // to also make sure that it stays that way, so the commit function // knows how to format the arguments to the callback. is_string($properties) ? $properties : $usedProperties, - $callback + $callback, ]; - } /** @@ -118,10 +114,9 @@ class PropPatch { * this that you promise to process _all_ properties that are coming in. * * @param callable $callback - * @return void */ - function handleRemaining(callable $callback) { - + public function handleRemaining(callable $callback) + { $properties = $this->getRemainingMutations(); if (!$properties) { // Nothing to do, don't register callback @@ -134,44 +129,39 @@ class PropPatch { $this->propertyUpdateCallbacks[] = [ $properties, - $callback + $callback, ]; } - } /** * Sets the result code for one or more properties. * * @param string|string[] $properties - * @param int $resultCode - * @return void + * @param int $resultCode */ - function setResultCode($properties, $resultCode) { - - foreach ((array)$properties as $propertyName) { + public function setResultCode($properties, $resultCode) + { + foreach ((array) $properties as $propertyName) { $this->result[$propertyName] = $resultCode; } if ($resultCode >= 400) { $this->failed = true; } - } /** * Sets the result code for all properties that did not have a result yet. * * @param int $resultCode - * @return void */ - function setRemainingResultCode($resultCode) { - + public function setRemainingResultCode($resultCode) + { $this->setResultCode( $this->getRemainingMutations(), $resultCode ); - } /** @@ -181,8 +171,8 @@ class PropPatch { * * @return string[] */ - function getRemainingMutations() { - + public function getRemainingMutations() + { $remaining = []; foreach ($this->mutations as $propertyName => $propValue) { if (!isset($this->result[$propertyName])) { @@ -191,7 +181,6 @@ class PropPatch { } return $remaining; - } /** @@ -201,8 +190,8 @@ class PropPatch { * * @return array */ - function getRemainingValues() { - + public function getRemainingValues() + { $remaining = []; foreach ($this->mutations as $propertyName => $propValue) { if (!isset($this->result[$propertyName])) { @@ -211,7 +200,6 @@ class PropPatch { } return $remaining; - } /** @@ -222,20 +210,17 @@ class PropPatch { * * @return bool */ - function commit() { - + public function commit() + { // First we validate if every property has a handler foreach ($this->mutations as $propertyName => $value) { - if (!isset($this->result[$propertyName])) { $this->failed = true; $this->result[$propertyName] = 403; } - } foreach ($this->propertyUpdateCallbacks as $callbackInfo) { - if ($this->failed) { break; } @@ -244,37 +229,32 @@ class PropPatch { } else { $this->doCallbackMultiProp($callbackInfo[0], $callbackInfo[1]); } - } - /** + /* * If anywhere in this operation updating a property failed, we must * update all other properties accordingly. */ if ($this->failed) { - foreach ($this->result as $propertyName => $status) { - if ($status === 202) { + if (202 === $status) { // Failed dependency $this->result[$propertyName] = 424; } } - } return !$this->failed; - } /** * Executes a property callback with the single-property syntax. * - * @param string $propertyName + * @param string $propertyName * @param callable $callback - * @return void */ - private function doCallBackSingleProp($propertyName, callable $callback) { - + private function doCallBackSingleProp($propertyName, callable $callback) + { $result = $callback($this->mutations[$propertyName]); if (is_bool($result)) { if ($result) { @@ -297,18 +277,16 @@ class PropPatch { if ($result >= 400) { $this->failed = true; } - } /** * Executes a property callback with the multi-property syntax. * - * @param array $propertyList + * @param array $propertyList * @param callable $callback - * @return void */ - private function doCallBackMultiProp(array $propertyList, callable $callback) { - + private function doCallBackMultiProp(array $propertyList, callable $callback) + { $argument = []; foreach ($propertyList as $propertyName) { $argument[$propertyName] = $this->mutations[$propertyName]; @@ -327,16 +305,13 @@ class PropPatch { $this->failed = true; } $this->result[$propertyName] = $resultCode; - } - } elseif ($result === true) { - + } elseif (true === $result) { // Success foreach ($argument as $propertyName => $propertyValue) { $this->result[$propertyName] = is_null($propertyValue) ? 204 : 200; } - - } elseif ($result === false) { + } elseif (false === $result) { // Fail :( $this->failed = true; foreach ($propertyList as $propertyName) { @@ -345,7 +320,6 @@ class PropPatch { } else { throw new UnexpectedValueException('A callback sent to handle() did not return an array or a bool'); } - } /** @@ -353,21 +327,18 @@ class PropPatch { * * @return array */ - function getResult() { - + public function getResult() + { return $this->result; - } /** - * Returns the full list of mutations + * Returns the full list of mutations. * * @return array */ - function getMutations() { - + public function getMutations() + { return $this->mutations; - } - } diff --git a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php index b15d7fef9..4bdc44775 100644 --- a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PropertyStorage\Backend; use Sabre\DAV\PropFind; @@ -15,8 +17,8 @@ use Sabre\DAV\PropPatch; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * Fetches properties for a path. * @@ -30,14 +32,13 @@ interface BackendInterface { * However, you can also support the 'allprops' property here. In that * case, you should check for $propFind->isAllProps(). * - * @param string $path + * @param string $path * @param PropFind $propFind - * @return void */ - function propFind($path, PropFind $propFind); + public function propFind($path, PropFind $propFind); /** - * Updates properties for a path + * Updates properties for a path. * * This method received a PropPatch object, which contains all the * information about the update. @@ -45,11 +46,10 @@ interface BackendInterface { * Usually you would want to call 'handleRemaining' on this object, to get; * a list of all properties that need to be stored. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch); + public function propPatch($path, PropPatch $propPatch); /** * This method is called after a node is deleted. @@ -60,12 +60,11 @@ interface BackendInterface { * tree. * * @param string $path - * @return void */ - function delete($path); + public function delete($path); /** - * This method is called after a successful MOVE + * This method is called after a successful MOVE. * * This should be used to migrate all properties from one path to another. * Note that entire collections may be moved, so ensure that all properties @@ -73,8 +72,6 @@ interface BackendInterface { * * @param string $source * @param string $destination - * @return void */ - function move($source, $destination); - + public function move($source, $destination); } diff --git a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php index 6f3f1feaf..e640f420e 100644 --- a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php +++ b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PropertyStorage\Backend; use Sabre\DAV\PropFind; @@ -18,8 +20,8 @@ use Sabre\DAV\Xml\Property\Complex; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO implements BackendInterface { - +class PDO implements BackendInterface +{ /** * Value is stored as string. */ @@ -36,28 +38,27 @@ class PDO implements BackendInterface { const VT_OBJECT = 3; /** - * PDO + * PDO. * * @var \PDO */ protected $pdo; /** - * PDO table name we'll be using + * PDO table name we'll be using. * * @var string */ public $tableName = 'propertystorage'; /** - * Creates the PDO property storage engine + * Creates the PDO property storage engine. * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -73,42 +74,40 @@ class PDO implements BackendInterface { * However, you can also support the 'allprops' property here. In that * case, you should check for $propFind->isAllProps(). * - * @param string $path + * @param string $path * @param PropFind $propFind - * @return void */ - function propFind($path, PropFind $propFind) { - - if (!$propFind->isAllProps() && count($propFind->get404Properties()) === 0) { + public function propFind($path, PropFind $propFind) + { + if (!$propFind->isAllProps() && 0 === count($propFind->get404Properties())) { return; } - $query = 'SELECT name, value, valuetype FROM ' . $this->tableName . ' WHERE path = ?'; + $query = 'SELECT name, value, valuetype FROM '.$this->tableName.' WHERE path = ?'; $stmt = $this->pdo->prepare($query); $stmt->execute([$path]); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - if (gettype($row['value']) === 'resource') { + if ('resource' === gettype($row['value'])) { $row['value'] = stream_get_contents($row['value']); } switch ($row['valuetype']) { - case null : - case self::VT_STRING : + case null: + case self::VT_STRING: $propFind->set($row['name'], $row['value']); break; - case self::VT_XML : + case self::VT_XML: $propFind->set($row['name'], new Complex($row['value'])); break; - case self::VT_OBJECT : + case self::VT_OBJECT: $propFind->set($row['name'], unserialize($row['value'])); break; } } - } /** - * Updates properties for a path + * Updates properties for a path. * * This method received a PropPatch object, which contains all the * information about the update. @@ -116,38 +115,30 @@ class PDO implements BackendInterface { * Usually you would want to call 'handleRemaining' on this object, to get; * a list of all properties that need to be stored. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch) { - - $propPatch->handleRemaining(function($properties) use ($path) { - - - if ($this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'pgsql') { - + public function propPatch($path, PropPatch $propPatch) + { + $propPatch->handleRemaining(function ($properties) use ($path) { + if ('pgsql' === $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) { $updateSql = <<<SQL INSERT INTO {$this->tableName} (path, name, valuetype, value) VALUES (:path, :name, :valuetype, :value) ON CONFLICT (path, name) DO UPDATE SET valuetype = :valuetype, value = :value SQL; - - } else { $updateSql = <<<SQL REPLACE INTO {$this->tableName} (path, name, valuetype, value) VALUES (:path, :name, :valuetype, :value) SQL; - } $updateStmt = $this->pdo->prepare($updateSql); - $deleteStmt = $this->pdo->prepare("DELETE FROM " . $this->tableName . " WHERE path = ? AND name = ?"); + $deleteStmt = $this->pdo->prepare('DELETE FROM '.$this->tableName.' WHERE path = ? AND name = ?'); foreach ($properties as $name => $value) { - if (!is_null($value)) { if (is_scalar($value)) { $valueType = self::VT_STRING; @@ -165,17 +156,13 @@ SQL; $updateStmt->bindParam('value', $value, \PDO::PARAM_LOB); $updateStmt->execute(); - } else { $deleteStmt->execute([$path, $name]); } - } return true; - }); - } /** @@ -187,26 +174,24 @@ SQL; * tree. * * @param string $path - * @return void */ - function delete($path) { - - $stmt = $this->pdo->prepare("DELETE FROM " . $this->tableName . " WHERE path = ? OR path LIKE ? ESCAPE '='"); + public function delete($path) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->tableName." WHERE path = ? OR path LIKE ? ESCAPE '='"); $childPath = strtr( $path, [ '=' => '==', '%' => '=%', - '_' => '=_' + '_' => '=_', ] - ) . '/%'; + ).'/%'; $stmt->execute([$path, $childPath]); - } /** - * This method is called after a successful MOVE + * This method is called after a successful MOVE. * * This should be used to migrate all properties from one path to another. * Note that entire collections may be moved, so ensure that all properties @@ -214,33 +199,30 @@ SQL; * * @param string $source * @param string $destination - * @return void */ - function move($source, $destination) { - + public function move($source, $destination) + { // I don't know a way to write this all in a single sql query that's // also compatible across db engines, so we're letting PHP do all the // updates. Much slower, but it should still be pretty fast in most // cases. - $select = $this->pdo->prepare('SELECT id, path FROM ' . $this->tableName . ' WHERE path = ? OR path LIKE ?'); - $select->execute([$source, $source . '/%']); + $select = $this->pdo->prepare('SELECT id, path FROM '.$this->tableName.' WHERE path = ? OR path LIKE ?'); + $select->execute([$source, $source.'/%']); - $update = $this->pdo->prepare('UPDATE ' . $this->tableName . ' SET path = ? WHERE id = ?'); + $update = $this->pdo->prepare('UPDATE '.$this->tableName.' SET path = ? WHERE id = ?'); while ($row = $select->fetch(\PDO::FETCH_ASSOC)) { - // Sanity check. SQL may select too many records, such as records // with different cases. - if ($row['path'] !== $source && strpos($row['path'], $source . '/') !== 0) continue; + if ($row['path'] !== $source && 0 !== strpos($row['path'], $source.'/')) { + continue; + } $trailingPart = substr($row['path'], strlen($source) + 1); $newPath = $destination; if ($trailingPart) { - $newPath .= '/' . $trailingPart; + $newPath .= '/'.$trailingPart; } $update->execute([$newPath, $row['id']]); - } - } - } diff --git a/vendor/sabre/dav/lib/DAV/PropertyStorage/Plugin.php b/vendor/sabre/dav/lib/DAV/PropertyStorage/Plugin.php index a66a14113..aa8610eb8 100644 --- a/vendor/sabre/dav/lib/DAV/PropertyStorage/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/PropertyStorage/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PropertyStorage; use Sabre\DAV\INode; @@ -23,8 +25,8 @@ use Sabre\DAV\ServerPlugin; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ /** * If you only want this plugin to store properties for a limited set of * paths, you can use a pathFilter to do this. @@ -43,14 +45,13 @@ class Plugin extends ServerPlugin { public $backend; /** - * Creates the plugin + * Creates the plugin. * * @param Backend\BackendInterface $backend */ - function __construct(Backend\BackendInterface $backend) { - + public function __construct(Backend\BackendInterface $backend) + { $this->backend = $backend; - } /** @@ -62,15 +63,13 @@ class Plugin extends ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - function initialize(Server $server) { - - $server->on('propFind', [$this, 'propFind'], 130); - $server->on('propPatch', [$this, 'propPatch'], 300); - $server->on('afterMove', [$this, 'afterMove']); + public function initialize(Server $server) + { + $server->on('propFind', [$this, 'propFind'], 130); + $server->on('propPatch', [$this, 'propPatch'], 300); + $server->on('afterMove', [$this, 'afterMove']); $server->on('afterUnbind', [$this, 'afterUnbind']); - } /** @@ -80,34 +79,34 @@ class Plugin extends ServerPlugin { * plugin will look in the property storage backend to find them. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - + public function propFind(PropFind $propFind, INode $node) + { $path = $propFind->getPath(); $pathFilter = $this->pathFilter; - if ($pathFilter && !$pathFilter($path)) return; + if ($pathFilter && !$pathFilter($path)) { + return; + } $this->backend->propFind($propFind->getPath(), $propFind); - } /** - * Called during PROPPATCH operations + * Called during PROPPATCH operations. * * If there's any updated properties that haven't been stored, the * propertystorage backend can handle it. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch) { - + public function propPatch($path, PropPatch $propPatch) + { $pathFilter = $this->pathFilter; - if ($pathFilter && !$pathFilter($path)) return; + if ($pathFilter && !$pathFilter($path)) { + return; + } $this->backend->propPatch($path, $propPatch); - } /** @@ -117,14 +116,14 @@ class Plugin extends ServerPlugin { * database. * * @param string $path - * @return void */ - function afterUnbind($path) { - + public function afterUnbind($path) + { $pathFilter = $this->pathFilter; - if ($pathFilter && !$pathFilter($path)) return; + if ($pathFilter && !$pathFilter($path)) { + return; + } $this->backend->delete($path); - } /** @@ -134,18 +133,20 @@ class Plugin extends ServerPlugin { * * @param string $source * @param string $destination - * @return void */ - function afterMove($source, $destination) { - + public function afterMove($source, $destination) + { $pathFilter = $this->pathFilter; - if ($pathFilter && !$pathFilter($source)) return; + if ($pathFilter && !$pathFilter($source)) { + return; + } // If the destination is filtered, afterUnbind will handle cleaning up // the properties. - if ($pathFilter && !$pathFilter($destination)) return; + if ($pathFilter && !$pathFilter($destination)) { + return; + } $this->backend->move($source, $destination); - } /** @@ -156,10 +157,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'property-storage'; - } /** @@ -173,13 +173,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'This plugin allows any arbitrary WebDAV property to be set on any resource.', - 'link' => 'http://sabre.io/dav/property-storage/', + 'link' => 'http://sabre.io/dav/property-storage/', ]; - } } diff --git a/vendor/sabre/dav/lib/DAV/Server.php b/vendor/sabre/dav/lib/DAV/Server.php index f7fcf3057..09760e9d1 100644 --- a/vendor/sabre/dav/lib/DAV/Server.php +++ b/vendor/sabre/dav/lib/DAV/Server.php @@ -1,76 +1,79 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; -use Sabre\Event\EventEmitter; +use Sabre\Event\EmitterInterface; +use Sabre\Event\WildcardEmitterTrait; use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -use Sabre\HTTP\URLUtil; use Sabre\Uri; /** - * Main DAV server class + * Main DAV server class. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Server extends EventEmitter implements LoggerAwareInterface { - +class Server implements LoggerAwareInterface, EmitterInterface +{ + use WildcardEmitterTrait; use LoggerAwareTrait; /** - * Infinity is used for some request supporting the HTTP Depth header and indicates that the operation should traverse the entire tree + * Infinity is used for some request supporting the HTTP Depth header and indicates that the operation should traverse the entire tree. */ const DEPTH_INFINITY = -1; /** - * XML namespace for all SabreDAV related elements + * XML namespace for all SabreDAV related elements. */ const NS_SABREDAV = 'http://sabredav.org/ns'; /** - * The tree object + * The tree object. * * @var Tree */ public $tree; /** - * The base uri + * The base uri. * * @var string */ protected $baseUri = null; /** - * httpResponse + * httpResponse. * * @var HTTP\Response */ public $httpResponse; /** - * httpRequest + * httpRequest. * * @var HTTP\Request */ public $httpRequest; /** - * PHP HTTP Sapi + * PHP HTTP Sapi. * * @var HTTP\Sapi */ public $sapi; /** - * The list of plugins + * The list of plugins. * * @var array */ @@ -98,7 +101,6 @@ class Server extends EventEmitter implements LoggerAwareInterface { * @var string[] */ public $protectedProperties = [ - // RFC4918 '{DAV:}getcontentlength', '{DAV:}getetag', @@ -129,12 +131,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { // sabredav extensions '{http://sabredav.org/ns}sync-token', - ]; /** * This is a flag that allow or not showing file, line and code - * of the exception in the returned XML + * of the exception in the returned XML. * * @var bool */ @@ -181,10 +182,10 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @var bool */ - static $exposeVersion = true; + public static $exposeVersion = true; /** - * Sets up the server + * Sets up the server. * * If a Sabre\DAV\Tree object is passed as an argument, it will * use it as the directory tree. If a Sabre\DAV\INode is passed, it @@ -198,25 +199,15 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @param Tree|INode|array|null $treeOrNode The tree object */ - function __construct($treeOrNode = null) { - + public function __construct($treeOrNode = null) + { if ($treeOrNode instanceof Tree) { $this->tree = $treeOrNode; } elseif ($treeOrNode instanceof INode) { $this->tree = new Tree($treeOrNode); } elseif (is_array($treeOrNode)) { - - // If it's an array, a list of nodes was passed, and we need to - // create the root node. - foreach ($treeOrNode as $node) { - if (!($node instanceof INode)) { - throw new Exception('Invalid argument passed to constructor. If you\'re passing an array, all the values must implement Sabre\\DAV\\INode'); - } - } - $root = new SimpleCollection('root', $treeOrNode); $this->tree = new Tree($root); - } elseif (is_null($treeOrNode)) { $root = new SimpleCollection('root'); $this->tree = new Tree($root); @@ -229,18 +220,14 @@ class Server extends EventEmitter implements LoggerAwareInterface { $this->httpResponse = new HTTP\Response(); $this->httpRequest = $this->sapi->getRequest(); $this->addPlugin(new CorePlugin()); - } /** - * Starts the DAV Server - * - * @return void + * Starts the DAV Server. */ - function exec() { - + public function start() + { try { - // If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an // origin, we must make sure we send back HTTP/1.0 if this was // requested. @@ -252,9 +239,7 @@ class Server extends EventEmitter implements LoggerAwareInterface { // Setting the base url $this->httpRequest->setBaseUrl($this->getBaseUri()); $this->invokeMethod($this->httpRequest, $this->httpResponse); - - } catch (\Exception $e) { - + } catch (\Throwable $e) { try { $this->emit('exception', [$e]); } catch (\Exception $ignore) { @@ -266,10 +251,8 @@ class Server extends EventEmitter implements LoggerAwareInterface { $error->setAttribute('xmlns:s', self::NS_SABREDAV); $DOM->appendChild($error); - $h = function($v) { - - return htmlspecialchars($v, ENT_NOQUOTES, 'UTF-8'); - + $h = function ($v) { + return htmlspecialchars((string) $v, ENT_NOQUOTES, 'UTF-8'); }; if (self::$exposeVersion) { @@ -299,18 +282,13 @@ class Server extends EventEmitter implements LoggerAwareInterface { } } - if ($e instanceof Exception) { - $httpCode = $e->getHTTPCode(); $e->serialize($this, $error); $headers = $e->getHTTPHeaders($this); - } else { - $httpCode = 500; $headers = []; - } $headers['Content-Type'] = 'application/xml; charset=utf-8'; @@ -318,37 +296,46 @@ class Server extends EventEmitter implements LoggerAwareInterface { $this->httpResponse->setHeaders($headers); $this->httpResponse->setBody($DOM->saveXML()); $this->sapi->sendResponse($this->httpResponse); - } + } + /** + * Alias of start(). + * + * @deprecated + */ + public function exec() + { + $this->start(); } /** - * Sets the base server uri + * Sets the base server uri. * * @param string $uri - * @return void */ - function setBaseUri($uri) { - + public function setBaseUri($uri) + { // If the baseUri does not end with a slash, we must add it - if ($uri[strlen($uri) - 1] !== '/') + if ('/' !== $uri[strlen($uri) - 1]) { $uri .= '/'; + } $this->baseUri = $uri; - } /** - * Returns the base responding uri + * Returns the base responding uri. * * @return string */ - function getBaseUri() { + public function getBaseUri() + { + if (is_null($this->baseUri)) { + $this->baseUri = $this->guessBaseUri(); + } - if (is_null($this->baseUri)) $this->baseUri = $this->guessBaseUri(); return $this->baseUri; - } /** @@ -359,53 +346,50 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @return string */ - function guessBaseUri() { - + public function guessBaseUri() + { $pathInfo = $this->httpRequest->getRawServerValue('PATH_INFO'); $uri = $this->httpRequest->getRawServerValue('REQUEST_URI'); // If PATH_INFO is found, we can assume it's accurate. if (!empty($pathInfo)) { - // We need to make sure we ignore the QUERY_STRING part - if ($pos = strpos($uri, '?')) + if ($pos = strpos($uri, '?')) { $uri = substr($uri, 0, $pos); + } // PATH_INFO is only set for urls, such as: /example.php/path // in that case PATH_INFO contains '/path'. // Note that REQUEST_URI is percent encoded, while PATH_INFO is // not, Therefore they are only comparable if we first decode // REQUEST_INFO as well. - $decodedUri = URLUtil::decodePath($uri); + $decodedUri = HTTP\decodePath($uri); // A simple sanity check: if (substr($decodedUri, strlen($decodedUri) - strlen($pathInfo)) === $pathInfo) { $baseUri = substr($decodedUri, 0, strlen($decodedUri) - strlen($pathInfo)); - return rtrim($baseUri, '/') . '/'; - } - throw new Exception('The REQUEST_URI (' . $uri . ') did not end with the contents of PATH_INFO (' . $pathInfo . '). This server might be misconfigured.'); + return rtrim($baseUri, '/').'/'; + } + throw new Exception('The REQUEST_URI ('.$uri.') did not end with the contents of PATH_INFO ('.$pathInfo.'). This server might be misconfigured.'); } // The last fallback is that we're just going to assume the server root. return '/'; - } /** - * Adds a plugin to the server + * Adds a plugin to the server. * * For more information, console the documentation of Sabre\DAV\ServerPlugin * * @param ServerPlugin $plugin - * @return void */ - function addPlugin(ServerPlugin $plugin) { - + public function addPlugin(ServerPlugin $plugin) + { $this->plugins[$plugin->getPluginName()] = $plugin; $plugin->initialize($this); - } /** @@ -414,26 +398,26 @@ class Server extends EventEmitter implements LoggerAwareInterface { * This function returns null if the plugin was not found. * * @param string $name + * * @return ServerPlugin */ - function getPlugin($name) { - - if (isset($this->plugins[$name])) + public function getPlugin($name) + { + if (isset($this->plugins[$name])) { return $this->plugins[$name]; + } return null; - } /** - * Returns all plugins + * Returns all plugins. * * @return array */ - function getPlugins() { - + public function getPlugins() + { return $this->plugins; - } /** @@ -441,29 +425,29 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @return LoggerInterface */ - function getLogger() { - + public function getLogger() + { if (!$this->logger) { $this->logger = new NullLogger(); } - return $this->logger; + return $this->logger; } /** - * Handles a http request, and execute a method based on its name + * Handles a http request, and execute a method based on its name. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @param bool $sendResponse Whether to send the HTTP response to the DAV client. - * @return void + * @param bool $sendResponse whether to send the HTTP response to the DAV client */ - function invokeMethod(RequestInterface $request, ResponseInterface $response, $sendResponse = true) { - + public function invokeMethod(RequestInterface $request, ResponseInterface $response, $sendResponse = true) + { $method = $request->getMethod(); - if (!$this->emit('beforeMethod:' . $method, [$request, $response])) return; - if (!$this->emit('beforeMethod', [$request, $response])) return; + if (!$this->emit('beforeMethod:'.$method, [$request, $response])) { + return; + } if (self::$exposeVersion) { $response->setHeader('X-Sabre-Version', Version::VERSION); @@ -473,32 +457,31 @@ class Server extends EventEmitter implements LoggerAwareInterface { if (!$this->checkPreconditions($request, $response)) { $this->sapi->sendResponse($response); + return; } - if ($this->emit('method:' . $method, [$request, $response])) { - if ($this->emit('method', [$request, $response])) { - $exMessage = "There was no plugin in the system that was willing to handle this " . $method . " method."; - if ($method === "GET") { - $exMessage .= " Enable the Browser plugin to get a better result here."; - } - - // Unsupported method - throw new Exception\NotImplemented($exMessage); + if ($this->emit('method:'.$method, [$request, $response])) { + $exMessage = 'There was no plugin in the system that was willing to handle this '.$method.' method.'; + if ('GET' === $method) { + $exMessage .= ' Enable the Browser plugin to get a better result here.'; } + + // Unsupported method + throw new Exception\NotImplemented($exMessage); } - if (!$this->emit('afterMethod:' . $method, [$request, $response])) return; - if (!$this->emit('afterMethod', [$request, $response])) return; + if (!$this->emit('afterMethod:'.$method, [$request, $response])) { + return; + } - if ($response->getStatus() === null) { + if (null === $response->getStatus()) { throw new Exception('No subsystem set a valid HTTP status code. Something must have interrupted the request without providing further detail.'); } if ($sendResponse) { $this->sapi->sendResponse($response); $this->emit('afterResponse', [$request, $response]); } - } // {{{ HTTP/WebDAV protocol helpers @@ -507,10 +490,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { * Returns an array with all the supported HTTP methods for a specific uri. * * @param string $path + * * @return array */ - function getAllowedMethods($path) { - + public function getAllowedMethods($path) + { $methods = [ 'OPTIONS', 'GET', @@ -521,7 +505,7 @@ class Server extends EventEmitter implements LoggerAwareInterface { 'PROPPATCH', 'COPY', 'MOVE', - 'REPORT' + 'REPORT', ]; // The MKCOL is only allowed on an unmapped uri @@ -532,22 +516,22 @@ class Server extends EventEmitter implements LoggerAwareInterface { } // We're also checking if any of the plugins register any new methods - foreach ($this->plugins as $plugin) $methods = array_merge($methods, $plugin->getHTTPMethods($path)); + foreach ($this->plugins as $plugin) { + $methods = array_merge($methods, $plugin->getHTTPMethods($path)); + } array_unique($methods); return $methods; - } /** - * Gets the uri for the request, keeping the base uri into consideration + * Gets the uri for the request, keeping the base uri into consideration. * * @return string */ - function getRequestUri() { - + public function getRequestUri() + { return $this->calculateUri($this->httpRequest->getUrl()); - } /** @@ -559,66 +543,65 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * uri-decodes the path * * @param string $uri + * * @throws Exception\Forbidden A permission denied exception is thrown whenever there was an attempt to supply a uri outside of the base uri + * * @return string */ - function calculateUri($uri) { - - if ($uri[0] != '/' && strpos($uri, '://')) { - + public function calculateUri($uri) + { + if ('' != $uri && '/' != $uri[0] && strpos($uri, '://')) { $uri = parse_url($uri, PHP_URL_PATH); - } - $uri = Uri\normalize(str_replace('//', '/', $uri)); + $uri = Uri\normalize(preg_replace('|/+|', '/', $uri)); $baseUri = Uri\normalize($this->getBaseUri()); - if (strpos($uri, $baseUri) === 0) { - - return trim(URLUtil::decodePath(substr($uri, strlen($baseUri))), '/'); + if (0 === strpos($uri, $baseUri)) { + return trim(HTTP\decodePath(substr($uri, strlen($baseUri))), '/'); // A special case, if the baseUri was accessed without a trailing // slash, we'll accept it as well. - } elseif ($uri . '/' === $baseUri) { - + } elseif ($uri.'/' === $baseUri) { return ''; - } else { - - throw new Exception\Forbidden('Requested uri (' . $uri . ') is out of base uri (' . $this->getBaseUri() . ')'); - + throw new Exception\Forbidden('Requested uri ('.$uri.') is out of base uri ('.$this->getBaseUri().')'); } - } /** - * Returns the HTTP depth header + * Returns the HTTP depth header. * * This method returns the contents of the HTTP depth request header. If the depth header was 'infinity' it will return the Sabre\DAV\Server::DEPTH_INFINITY object * It is possible to supply a default depth value, which is used when the depth header has invalid content, or is completely non-existent * * @param mixed $default + * * @return int */ - function getHTTPDepth($default = self::DEPTH_INFINITY) { - + public function getHTTPDepth($default = self::DEPTH_INFINITY) + { // If its not set, we'll grab the default $depth = $this->httpRequest->getHeader('Depth'); - if (is_null($depth)) return $default; - - if ($depth == 'infinity') return self::DEPTH_INFINITY; + if (is_null($depth)) { + return $default; + } + if ('infinity' == $depth) { + return self::DEPTH_INFINITY; + } // If its an unknown value. we'll grab the default - if (!ctype_digit($depth)) return $default; - - return (int)$depth; + if (!ctype_digit($depth)) { + return $default; + } + return (int) $depth; } /** - * Returns the HTTP range header + * Returns the HTTP range header. * * This method returns null if there is no well-formed HTTP range request * header or array($start, $end). @@ -629,24 +612,29 @@ class Server extends EventEmitter implements LoggerAwareInterface { * If the second offset is null, it should be treated as the offset of the last byte of the entity * If the first offset is null, the second offset should be used to retrieve the last x bytes of the entity * - * @return array|null + * @return int[]|null */ - function getHTTPRange() { - + public function getHTTPRange() + { $range = $this->httpRequest->getHeader('range'); - if (is_null($range)) return null; + if (is_null($range)) { + return null; + } // Matching "Range: bytes=1234-5678: both numbers are optional - if (!preg_match('/^bytes=([0-9]*)-([0-9]*)$/i', $range, $matches)) return null; + if (!preg_match('/^bytes=([0-9]*)-([0-9]*)$/i', $range, $matches)) { + return null; + } - if ($matches[1] === '' && $matches[2] === '') return null; + if ('' === $matches[1] && '' === $matches[2]) { + return null; + } return [ - $matches[1] !== '' ? $matches[1] : null, - $matches[2] !== '' ? $matches[2] : null, + '' !== $matches[1] ? (int) $matches[1] : null, + '' !== $matches[2] ? (int) $matches[2] : null, ]; - } /** @@ -675,8 +663,8 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @return array */ - function getHTTPPrefer() { - + public function getHTTPPrefer() + { $result = [ // can be true or false 'respond-async' => false, @@ -689,23 +677,19 @@ class Server extends EventEmitter implements LoggerAwareInterface { ]; if ($prefer = $this->httpRequest->getHeader('Prefer')) { - $result = array_merge( $result, HTTP\parsePrefer($prefer) ); - - } elseif ($this->httpRequest->getHeader('Brief') == 't') { + } elseif ('t' == $this->httpRequest->getHeader('Brief')) { $result['return'] = 'minimal'; } return $result; - } - /** - * Returns information about Copy and Move requests + * Returns information about Copy and Move requests. * * This function is created to help getting information about the source and the destination for the * WebDAV MOVE and COPY HTTP request. It also validates a lot of information and throws proper exceptions @@ -715,74 +699,82 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * destinationExists - Whether or not the destination is an existing url (and should therefore be overwritten) * * @param RequestInterface $request - * @throws Exception\BadRequest upon missing or broken request headers + * + * @throws Exception\BadRequest upon missing or broken request headers * @throws Exception\UnsupportedMediaType when trying to copy into a - * non-collection. - * @throws Exception\PreconditionFailed If overwrite is set to false, but - * the destination exists. - * @throws Exception\Forbidden when source and destination paths are - * identical. - * @throws Exception\Conflict When trying to copy a node into its own - * subtree. + * non-collection + * @throws Exception\PreconditionFailed if overwrite is set to false, but + * the destination exists + * @throws Exception\Forbidden when source and destination paths are + * identical + * @throws Exception\Conflict when trying to copy a node into its own + * subtree + * * @return array */ - function getCopyAndMoveInfo(RequestInterface $request) { - + public function getCopyAndMoveInfo(RequestInterface $request) + { // Collecting the relevant HTTP headers - if (!$request->getHeader('Destination')) throw new Exception\BadRequest('The destination header was not supplied'); + if (!$request->getHeader('Destination')) { + throw new Exception\BadRequest('The destination header was not supplied'); + } $destination = $this->calculateUri($request->getHeader('Destination')); $overwrite = $request->getHeader('Overwrite'); - if (!$overwrite) $overwrite = 'T'; - if (strtoupper($overwrite) == 'T') $overwrite = true; - elseif (strtoupper($overwrite) == 'F') $overwrite = false; + if (!$overwrite) { + $overwrite = 'T'; + } + if ('T' == strtoupper($overwrite)) { + $overwrite = true; + } elseif ('F' == strtoupper($overwrite)) { + $overwrite = false; + } // We need to throw a bad request exception, if the header was invalid - else throw new Exception\BadRequest('The HTTP Overwrite header should be either T or F'); - - list($destinationDir) = URLUtil::splitPath($destination); + else { + throw new Exception\BadRequest('The HTTP Overwrite header should be either T or F'); + } + list($destinationDir) = Uri\split($destination); try { $destinationParent = $this->tree->getNodeForPath($destinationDir); - if (!($destinationParent instanceof ICollection)) throw new Exception\UnsupportedMediaType('The destination node is not a collection'); + if (!($destinationParent instanceof ICollection)) { + throw new Exception\UnsupportedMediaType('The destination node is not a collection'); + } } catch (Exception\NotFound $e) { - // If the destination parent node is not found, we throw a 409 throw new Exception\Conflict('The destination node is not found'); } try { - $destinationNode = $this->tree->getNodeForPath($destination); // If this succeeded, it means the destination already exists // we'll need to throw precondition failed in case overwrite is false - if (!$overwrite) throw new Exception\PreconditionFailed('The destination node already exists, and the overwrite header is set to false', 'Overwrite'); - + if (!$overwrite) { + throw new Exception\PreconditionFailed('The destination node already exists, and the overwrite header is set to false', 'Overwrite'); + } } catch (Exception\NotFound $e) { - // Destination didn't exist, we're all good $destinationNode = false; - } $requestPath = $request->getPath(); if ($destination === $requestPath) { throw new Exception\Forbidden('Source and destination uri are identical.'); } - if (substr($destination, 0, strlen($requestPath) + 1) === $requestPath . '/') { + if (substr($destination, 0, strlen($requestPath) + 1) === $requestPath.'/') { throw new Exception\Conflict('The destination may not be part of the same subtree as the source path.'); } // These are the three relevant properties we need to return return [ - 'destination' => $destination, - 'destinationExists' => !!$destinationNode, - 'destinationNode' => $destinationNode, + 'destination' => $destination, + 'destinationExists' => (bool) $destinationNode, + 'destinationNode' => $destinationNode, ]; - } /** - * Returns a list of properties for a path + * Returns a list of properties for a path. * * This is a simplified version getPropertiesForPath. If you aren't * interested in status codes, but you just want to have a flat list of @@ -793,18 +785,18 @@ class Server extends EventEmitter implements LoggerAwareInterface { * returned. * * @param string $path - * @param array $propertyNames + * @param array $propertyNames + * * @return array */ - function getProperties($path, $propertyNames) { - + public function getProperties($path, $propertyNames) + { $result = $this->getPropertiesForPath($path, $propertyNames, 0); if (isset($result[0][200])) { return $result[0][200]; } else { return []; } - } /** @@ -816,26 +808,27 @@ class Server extends EventEmitter implements LoggerAwareInterface { * The parent node will not be returned. * * @param string $path - * @param array $propertyNames + * @param array $propertyNames + * * @return array */ - function getPropertiesForChildren($path, $propertyNames) { - + public function getPropertiesForChildren($path, $propertyNames) + { $result = []; foreach ($this->getPropertiesForPath($path, $propertyNames, 1) as $k => $row) { - // Skipping the parent path - if ($k === 0) continue; + if (0 === $k) { + continue; + } $result[$row['href']] = $row[200]; - } - return $result; + return $result; } /** - * Returns a list of HTTP headers for a particular resource + * Returns a list of HTTP headers for a particular resource. * * The generated http headers are based on properties provided by the * resource. The method basically provides a simple mapping between @@ -844,61 +837,64 @@ class Server extends EventEmitter implements LoggerAwareInterface { * The headers are intended to be used for HEAD and GET requests. * * @param string $path + * * @return array */ - function getHTTPHeaders($path) { - + public function getHTTPHeaders($path) + { $propertyMap = [ - '{DAV:}getcontenttype' => 'Content-Type', + '{DAV:}getcontenttype' => 'Content-Type', '{DAV:}getcontentlength' => 'Content-Length', - '{DAV:}getlastmodified' => 'Last-Modified', - '{DAV:}getetag' => 'ETag', + '{DAV:}getlastmodified' => 'Last-Modified', + '{DAV:}getetag' => 'ETag', ]; $properties = $this->getProperties($path, array_keys($propertyMap)); $headers = []; foreach ($propertyMap as $property => $header) { - if (!isset($properties[$property])) continue; + if (!isset($properties[$property])) { + continue; + } if (is_scalar($properties[$property])) { $headers[$header] = $properties[$property]; // GetLastModified gets special cased } elseif ($properties[$property] instanceof Xml\Property\GetLastModified) { - $headers[$header] = HTTP\Util::toHTTPDate($properties[$property]->getTime()); + $headers[$header] = HTTP\toDate($properties[$property]->getTime()); } - } return $headers; - } /** * Small helper to support PROPFIND with DEPTH_INFINITY. * * @param PropFind $propFind - * @param array $yieldFirst - * @return \Iterator + * @param array $yieldFirst + * + * @return \Traversable */ - private function generatePathNodes(PropFind $propFind, array $yieldFirst = null) { - if ($yieldFirst !== null) { + private function generatePathNodes(PropFind $propFind, array $yieldFirst = null) + { + if (null !== $yieldFirst) { yield $yieldFirst; } $newDepth = $propFind->getDepth(); $path = $propFind->getPath(); - if ($newDepth !== self::DEPTH_INFINITY) { - $newDepth--; + if (self::DEPTH_INFINITY !== $newDepth) { + --$newDepth; } $propertyNames = $propFind->getRequestedProperties(); $propFindType = !empty($propertyNames) ? PropFind::NORMAL : PropFind::ALLPROPS; foreach ($this->tree->getChildren($path) as $childNode) { - if ($path !== '') { - $subPath = $path . '/' . $childNode->getName(); + if ('' !== $path) { + $subPath = $path.'/'.$childNode->getName(); } else { $subPath = $childNode->getName(); } @@ -906,20 +902,19 @@ class Server extends EventEmitter implements LoggerAwareInterface { yield [ $subPropFind, - $childNode + $childNode, ]; - if (($newDepth === self::DEPTH_INFINITY || $newDepth >= 1) && $childNode instanceof ICollection) { + if ((self::DEPTH_INFINITY === $newDepth || $newDepth >= 1) && $childNode instanceof ICollection) { foreach ($this->generatePathNodes($subPropFind) as $subItem) { yield $subItem; } } - } } /** - * Returns a list of properties for a given path + * Returns a list of properties for a given path. * * The path that should be supplied should have the baseUrl stripped out * The list of properties should be supplied in Clark notation. If the list is empty @@ -928,20 +923,21 @@ class Server extends EventEmitter implements LoggerAwareInterface { * If a depth of 1 is requested child elements will also be returned. * * @param string $path - * @param array $propertyNames - * @param int $depth + * @param array $propertyNames + * @param int $depth + * * @return array * * @deprecated Use getPropertiesIteratorForPath() instead (as it's more memory efficient) * @see getPropertiesIteratorForPath() */ - function getPropertiesForPath($path, $propertyNames = [], $depth = 0) { - + public function getPropertiesForPath($path, $propertyNames = [], $depth = 0) + { return iterator_to_array($this->getPropertiesIteratorForPath($path, $propertyNames, $depth)); - } + /** - * Returns a list of properties for a given path + * Returns a list of properties for a given path. * * The path that should be supplied should have the baseUrl stripped out * The list of properties should be supplied in Clark notation. If the list is empty @@ -950,33 +946,35 @@ class Server extends EventEmitter implements LoggerAwareInterface { * If a depth of 1 is requested child elements will also be returned. * * @param string $path - * @param array $propertyNames - * @param int $depth + * @param array $propertyNames + * @param int $depth + * * @return \Iterator */ - function getPropertiesIteratorForPath($path, $propertyNames = [], $depth = 0) { - + public function getPropertiesIteratorForPath($path, $propertyNames = [], $depth = 0) + { // The only two options for the depth of a propfind is 0 or 1 - as long as depth infinity is not enabled - if (!$this->enablePropfindDepthInfinity && $depth != 0) $depth = 1; + if (!$this->enablePropfindDepthInfinity && 0 != $depth) { + $depth = 1; + } $path = trim($path, '/'); $propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS; - $propFind = new PropFind($path, (array)$propertyNames, $depth, $propFindType); + $propFind = new PropFind($path, (array) $propertyNames, $depth, $propFindType); $parentNode = $this->tree->getNodeForPath($path); $propFindRequests = [[ $propFind, - $parentNode + $parentNode, ]]; - if (($depth > 0 || $depth === self::DEPTH_INFINITY) && $parentNode instanceof ICollection) { + if (($depth > 0 || self::DEPTH_INFINITY === $depth) && $parentNode instanceof ICollection) { $propFindRequests = $this->generatePathNodes(clone $propFind, current($propFindRequests)); } foreach ($propFindRequests as $propFindRequest) { - list($propFind, $node) = $propFindRequest; $r = $this->getPropertiesByNode($propFind, $node); if ($r) { @@ -993,9 +991,7 @@ class Server extends EventEmitter implements LoggerAwareInterface { } yield $result; } - } - } /** @@ -1010,17 +1006,17 @@ class Server extends EventEmitter implements LoggerAwareInterface { * * @param array $paths * @param array $propertyNames + * * @return array */ - function getPropertiesForMultiplePaths(array $paths, array $propertyNames = []) { - + public function getPropertiesForMultiplePaths(array $paths, array $propertyNames = []) + { $result = [ ]; $nodes = $this->tree->getMultipleNodes($paths); foreach ($nodes as $path => $node) { - $propFind = new PropFind($path, $propertyNames); $r = $this->getPropertiesByNode($propFind, $node); if ($r) { @@ -1032,14 +1028,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { $result[$path]['href'] .= '/'; } } - } return $result; - } - /** * Determines all properties for a node. * @@ -1051,13 +1044,13 @@ class Server extends EventEmitter implements LoggerAwareInterface { * list of properties. * * @param PropFind $propFind - * @param INode $node + * @param INode $node + * * @return bool */ - function getPropertiesByNode(PropFind $propFind, INode $node) { - + public function getPropertiesByNode(PropFind $propFind, INode $node) + { return $this->emit('propFind', [$propFind, $node]); - } /** @@ -1072,13 +1065,16 @@ class Server extends EventEmitter implements LoggerAwareInterface { * @param string $uri * @param resource $data * @param string $etag + * * @return bool */ - function createFile($uri, $data, &$etag = null) { + public function createFile($uri, $data, &$etag = null) + { + list($dir, $name) = Uri\split($uri); - list($dir, $name) = URLUtil::splitPath($uri); - - if (!$this->emit('beforeBind', [$uri])) return false; + if (!$this->emit('beforeBind', [$uri])) { + return false; + } $parent = $this->tree->getNodeForPath($dir); if (!$parent instanceof ICollection) { @@ -1091,13 +1087,17 @@ class Server extends EventEmitter implements LoggerAwareInterface { // // If $modified is true, we must not send back an ETag. $modified = false; - if (!$this->emit('beforeCreateFile', [$uri, &$data, $parent, &$modified])) return false; + if (!$this->emit('beforeCreateFile', [$uri, &$data, $parent, &$modified])) { + return false; + } $etag = $parent->createFile($name, $data); - if ($modified) $etag = null; + if ($modified) { + $etag = null; + } - $this->tree->markDirty($dir . '/' . $name); + $this->tree->markDirty($dir.'/'.$name); $this->emit('afterBind', [$uri]); $this->emit('afterCreateFile', [$uri, $parent]); @@ -1113,10 +1113,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { * @param string $uri * @param resource $data * @param string $etag + * * @return bool */ - function updateFile($uri, $data, &$etag = null) { - + public function updateFile($uri, $data, &$etag = null) + { $node = $this->tree->getNodeForPath($uri); // It is possible for an event handler to modify the content of the @@ -1125,47 +1126,46 @@ class Server extends EventEmitter implements LoggerAwareInterface { // // If $modified is true, we must not send back an ETag. $modified = false; - if (!$this->emit('beforeWriteContent', [$uri, $node, &$data, &$modified])) return false; + if (!$this->emit('beforeWriteContent', [$uri, $node, &$data, &$modified])) { + return false; + } $etag = $node->put($data); - if ($modified) $etag = null; + if ($modified) { + $etag = null; + } $this->emit('afterWriteContent', [$uri, $node]); return true; } - - /** * This method is invoked by sub-systems creating a new directory. * * @param string $uri - * @return void */ - function createDirectory($uri) { - + public function createDirectory($uri) + { $this->createCollection($uri, new MkCol(['{DAV:}collection'], [])); - } /** - * Use this method to create a new collection + * Use this method to create a new collection. + * + * @param string $uri The new uri + * @param MkCol $mkCol * - * @param string $uri The new uri - * @param MkCol $mkCol * @return array|null */ - function createCollection($uri, MkCol $mkCol) { - - list($parentUri, $newName) = URLUtil::splitPath($uri); + public function createCollection($uri, MkCol $mkCol) + { + list($parentUri, $newName) = Uri\split($uri); // Making sure the parent exists try { $parent = $this->tree->getNodeForPath($parentUri); - } catch (Exception\NotFound $e) { throw new Exception\Conflict('Parent node does not exist'); - } // Making sure the parent is a collection @@ -1179,26 +1179,23 @@ class Server extends EventEmitter implements LoggerAwareInterface { // If we got here.. it means there's already a node on that url, and we need to throw a 405 throw new Exception\MethodNotAllowed('The resource you tried to create already exists'); - } catch (Exception\NotFound $e) { // NotFound is the expected behavior. } - - if (!$this->emit('beforeBind', [$uri])) return; + if (!$this->emit('beforeBind', [$uri])) { + return; + } if ($parent instanceof IExtendedCollection) { - - /** + /* * If the parent is an instance of IExtendedCollection, it means that * we can pass the MkCol object directly as it may be able to store * properties immediately. */ $parent->createExtendedCollection($newName, $mkCol); - } else { - - /** + /* * If the parent is a standard ICollection, it means only * 'standard' collections can be created, so we should fail any * MKCOL operation that carries extra resourcetypes. @@ -1208,7 +1205,6 @@ class Server extends EventEmitter implements LoggerAwareInterface { } $parent->createDirectory($newName); - } // If there are any properties that have not been handled/stored, @@ -1227,23 +1223,21 @@ class Server extends EventEmitter implements LoggerAwareInterface { ]; foreach ($result as $propertyName => $status) { - if (!isset($formattedResult[$status])) { $formattedResult[$status] = []; } $formattedResult[$status][$propertyName] = null; - } + return $formattedResult; } $this->tree->markDirty($parentUri); $this->emit('afterBind', [$uri]); - } /** - * This method updates a resource's properties + * This method updates a resource's properties. * * The properties array must be a list of properties. Array-keys are * property names in clarknotation, array-values are it's values. @@ -1256,17 +1250,17 @@ class Server extends EventEmitter implements LoggerAwareInterface { * as their values. * * @param string $path - * @param array $properties + * @param array $properties + * * @return array */ - function updateProperties($path, array $properties) { - + public function updateProperties($path, array $properties) + { $propPatch = new PropPatch($properties); $this->emit('propPatch', [$path, $propPatch]); $propPatch->commit(); return $propPatch->getResult(); - } /** @@ -1287,19 +1281,19 @@ class Server extends EventEmitter implements LoggerAwareInterface { * related to If-None-Match, If-Match and If-Unmodified Since. It will * set the status to 304 Not Modified for If-Modified_since. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function checkPreconditions(RequestInterface $request, ResponseInterface $response) { - + public function checkPreconditions(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $node = null; $lastMod = null; $etag = null; if ($ifMatch = $request->getHeader('If-Match')) { - // If-Match contains an entity tag. Only if the entity-tag // matches we are allowed to make the request succeed. // If the entity-tag is '*' we are only allowed to make the @@ -1311,13 +1305,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { } // Only need to check entity tags if they are not * - if ($ifMatch !== '*') { - + if ('*' !== $ifMatch) { // There can be multiple ETags $ifMatch = explode(',', $ifMatch); $haveMatch = false; foreach ($ifMatch as $ifMatchItem) { - // Stripping any extra spaces $ifMatchItem = trim($ifMatchItem, ' '); @@ -1331,17 +1323,17 @@ class Server extends EventEmitter implements LoggerAwareInterface { $haveMatch = true; } } - } if (!$haveMatch) { - if ($etag) $response->setHeader('ETag', $etag); - throw new Exception\PreconditionFailed('An If-Match header was specified, but none of the specified the ETags matched.', 'If-Match'); + if ($etag) { + $response->setHeader('ETag', $etag); + } + throw new Exception\PreconditionFailed('An If-Match header was specified, but none of the specified ETags matched.', 'If-Match'); } } } if ($ifNoneMatch = $request->getHeader('If-None-Match')) { - // The If-None-Match header contains an ETag. // Only if the ETag does not match the current ETag, the request will succeed // The header can also contain *, in which case the request @@ -1356,46 +1348,46 @@ class Server extends EventEmitter implements LoggerAwareInterface { } if ($nodeExists) { $haveMatch = false; - if ($ifNoneMatch === '*') $haveMatch = true; - else { - + if ('*' === $ifNoneMatch) { + $haveMatch = true; + } else { // There might be multiple ETags $ifNoneMatch = explode(',', $ifNoneMatch); $etag = $node instanceof IFile ? $node->getETag() : null; foreach ($ifNoneMatch as $ifNoneMatchItem) { - // Stripping any extra spaces $ifNoneMatchItem = trim($ifNoneMatchItem, ' '); - if ($etag === $ifNoneMatchItem) $haveMatch = true; - + if ($etag === $ifNoneMatchItem) { + $haveMatch = true; + } } - } if ($haveMatch) { - if ($etag) $response->setHeader('ETag', $etag); - if ($request->getMethod() === 'GET') { + if ($etag) { + $response->setHeader('ETag', $etag); + } + if ('GET' === $request->getMethod()) { $response->setStatus(304); + return false; } else { throw new Exception\PreconditionFailed('An If-None-Match header was specified, but the ETag matched (or * was specified).', 'If-None-Match'); } } } - } if (!$ifNoneMatch && ($ifModifiedSince = $request->getHeader('If-Modified-Since'))) { - // The If-Modified-Since header contains a date. We // will only return the entity if it has been changed since // that date. If it hasn't been changed, we return a 304 // header // Note that this header only has to be checked if there was no If-None-Match header // as per the HTTP spec. - $date = HTTP\Util::parseHTTPDate($ifModifiedSince); + $date = HTTP\parseDate($ifModifiedSince); if ($date) { if (is_null($node)) { @@ -1403,10 +1395,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { } $lastMod = $node->getLastModified(); if ($lastMod) { - $lastMod = new \DateTime('@' . $lastMod); + $lastMod = new \DateTime('@'.$lastMod); if ($lastMod <= $date) { $response->setStatus(304); - $response->setHeader('Last-Modified', HTTP\Util::toHTTPDate($lastMod)); + $response->setHeader('Last-Modified', HTTP\toDate($lastMod)); + return false; } } @@ -1414,10 +1407,9 @@ class Server extends EventEmitter implements LoggerAwareInterface { } if ($ifUnmodifiedSince = $request->getHeader('If-Unmodified-Since')) { - // The If-Unmodified-Since will allow allow the request if the // entity has not changed since the specified date. - $date = HTTP\Util::parseHTTPDate($ifUnmodifiedSince); + $date = HTTP\parseDate($ifUnmodifiedSince); // We must only check the date if it's valid if ($date) { @@ -1426,13 +1418,12 @@ class Server extends EventEmitter implements LoggerAwareInterface { } $lastMod = $node->getLastModified(); if ($lastMod) { - $lastMod = new \DateTime('@' . $lastMod); + $lastMod = new \DateTime('@'.$lastMod); if ($lastMod > $date) { throw new Exception\PreconditionFailed('An If-Unmodified-Since header was specified, but the entity has been changed since the specified date.', 'If-Unmodified-Since'); } } } - } // Now the hardest, the If: header. The If: header can contain multiple @@ -1461,13 +1452,11 @@ class Server extends EventEmitter implements LoggerAwareInterface { // Every ifCondition needs to validate to true, so we exit as soon as // we have an invalid condition. foreach ($ifConditions as $ifCondition) { - $uri = $ifCondition['uri']; $tokens = $ifCondition['tokens']; // We only need 1 valid token for the condition to succeed. foreach ($tokens as $token) { - $tokenValid = $token['validToken'] || !$token['token']; $etagValid = false; @@ -1477,35 +1466,28 @@ class Server extends EventEmitter implements LoggerAwareInterface { // Checking the ETag, only if the token was already deemed // valid and there is one. if ($token['etag'] && $tokenValid) { - // The token was valid, and there was an ETag. We must // grab the current ETag and check it. $node = $this->tree->getNodeForPath($uri); $etagValid = $node instanceof IFile && $node->getETag() == $token['etag']; - } - if (($tokenValid && $etagValid) ^ $token['negate']) { // Both were valid, so we can go to the next condition. continue 2; } - - } // If we ended here, it means there was no valid ETag + token // combination found for the current condition. This means we fail! - throw new Exception\PreconditionFailed('Failed to find a valid token/etag combination for ' . $uri, 'If'); - + throw new Exception\PreconditionFailed('Failed to find a valid token/etag combination for '.$uri, 'If'); } return true; - } /** - * This method is created to extract information from the WebDAV HTTP 'If:' header + * This method is created to extract information from the WebDAV HTTP 'If:' header. * * The If header can be quite complex, and has a bunch of features. We're using a regex to extract all relevant information * The function will return an array, containing structs with the following keys @@ -1573,12 +1555,15 @@ class Server extends EventEmitter implements LoggerAwareInterface { * ] * * @param RequestInterface $request + * * @return array */ - function getIfConditions(RequestInterface $request) { - + public function getIfConditions(RequestInterface $request) + { $header = $request->getHeader('If'); - if (!$header) return []; + if (!$header) { + return []; + } $matches = []; @@ -1588,18 +1573,16 @@ class Server extends EventEmitter implements LoggerAwareInterface { $conditions = []; foreach ($matches as $match) { - // If there was no uri specified in this match, and there were // already conditions parsed, we add the condition to the list of // conditions for the previous uri. if (!$match['uri'] && count($conditions)) { $conditions[count($conditions) - 1]['tokens'][] = [ 'negate' => $match['not'] ? true : false, - 'token' => $match['token'], - 'etag' => isset($match['etag']) ? $match['etag'] : '' + 'token' => $match['token'], + 'etag' => isset($match['etag']) ? $match['etag'] : '', ]; } else { - if (!$match['uri']) { $realUri = $request->getPath(); } else { @@ -1607,55 +1590,55 @@ class Server extends EventEmitter implements LoggerAwareInterface { } $conditions[] = [ - 'uri' => $realUri, + 'uri' => $realUri, 'tokens' => [ [ 'negate' => $match['not'] ? true : false, - 'token' => $match['token'], - 'etag' => isset($match['etag']) ? $match['etag'] : '' - ] + 'token' => $match['token'], + 'etag' => isset($match['etag']) ? $match['etag'] : '', + ], ], - ]; } - } return $conditions; - } /** * Returns an array with resourcetypes for a node. * * @param INode $node + * * @return array */ - function getResourceTypeForNode(INode $node) { - + public function getResourceTypeForNode(INode $node) + { $result = []; foreach ($this->resourceTypeMapping as $className => $resourceType) { - if ($node instanceof $className) $result[] = $resourceType; + if ($node instanceof $className) { + $result[] = $resourceType; + } } - return $result; + return $result; } // }}} // {{{ XML Readers & Writers - /** * Generates a WebDAV propfind response body based on a list of nodes. * * If 'strip404s' is set to true, all 404 responses will be removed. * * @param array|\Traversable $fileProperties The list with nodes - * @param bool $strip404s + * @param bool $strip404s + * * @return string */ - function generateMultiStatus($fileProperties, $strip404s = false) { - + public function generateMultiStatus($fileProperties, $strip404s = false) + { $w = $this->xml->getWriter(); $w->openMemory(); $w->contextUri = $this->baseUri; @@ -1664,7 +1647,6 @@ class Server extends EventEmitter implements LoggerAwareInterface { $w->startElement('{DAV:}multistatus'); foreach ($fileProperties as $entry) { - $href = $entry['href']; unset($entry['href']); if ($strip404s) { @@ -1675,14 +1657,12 @@ class Server extends EventEmitter implements LoggerAwareInterface { $entry ); $w->write([ - 'name' => '{DAV:}response', - 'value' => $response + 'name' => '{DAV:}response', + 'value' => $response, ]); } $w->endElement(); return $w->outputMemory(); - } - } diff --git a/vendor/sabre/dav/lib/DAV/ServerPlugin.php b/vendor/sabre/dav/lib/DAV/ServerPlugin.php index b2c468ab3..9aefa7f72 100644 --- a/vendor/sabre/dav/lib/DAV/ServerPlugin.php +++ b/vendor/sabre/dav/lib/DAV/ServerPlugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -11,8 +13,8 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class ServerPlugin { - +abstract class ServerPlugin +{ /** * This initializes the plugin. * @@ -22,9 +24,8 @@ abstract class ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - abstract function initialize(Server $server); + abstract public function initialize(Server $server); /** * This method should return a list of server-features. @@ -34,10 +35,9 @@ abstract class ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return []; - } /** @@ -48,12 +48,12 @@ abstract class ServerPlugin { * available for the specified uri. * * @param string $path + * * @return array */ - function getHTTPMethods($path) { - + public function getHTTPMethods($path) + { return []; - } /** @@ -64,10 +64,9 @@ abstract class ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return get_class($this); - } /** @@ -78,12 +77,12 @@ abstract class ServerPlugin { * implement them * * @param string $uri + * * @return array */ - function getSupportedReportSet($uri) { - + public function getSupportedReportSet($uri) + { return []; - } /** @@ -97,14 +96,12 @@ abstract class ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => null, - 'link' => null, + 'link' => null, ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php b/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php index 034aefbdc..a746ac753 100644 --- a/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php +++ b/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Sharing; use Sabre\DAV\INode; @@ -13,8 +15,8 @@ use Sabre\DAV\INode; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ISharedNode extends INode { - +interface ISharedNode extends INode +{ /** * Returns the 'access level' for the instance of this shared resource. * @@ -23,7 +25,7 @@ interface ISharedNode extends INode { * * @return int */ - function getShareAccess(); + public function getShareAccess(); /** * This function must return a URI that uniquely identifies the shared @@ -36,7 +38,7 @@ interface ISharedNode extends INode { * * @return string */ - function getShareResourceUri(); + public function getShareResourceUri(); /** * Updates the list of sharees. @@ -44,9 +46,8 @@ interface ISharedNode extends INode { * Every item must be a Sharee object. * * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees - * @return void */ - function updateInvites(array $sharees); + public function updateInvites(array $sharees); /** * Returns the list of people whom this resource is shared with. @@ -64,6 +65,5 @@ interface ISharedNode extends INode { * * @return \Sabre\DAV\Xml\Element\Sharee[] */ - function getInvites(); - + public function getInvites(); } diff --git a/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php b/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php index ef5702c57..5706fabf1 100644 --- a/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Sharing; use Sabre\DAV\Exception\BadRequest; @@ -14,7 +16,7 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** - * This plugin implements HTTP requests and properties related to: + * This plugin implements HTTP requests and properties related to:. * * draft-pot-webdav-resource-sharing * @@ -24,8 +26,8 @@ use Sabre\HTTP\ResponseInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends ServerPlugin { - +class Plugin extends ServerPlugin +{ const ACCESS_NOTSHARED = 0; const ACCESS_SHAREDOWNER = 1; const ACCESS_READ = 2; @@ -52,10 +54,9 @@ class Plugin extends ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['resource-sharing']; - } /** @@ -66,10 +67,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'sharing'; - } /** @@ -81,10 +81,9 @@ class Plugin extends ServerPlugin { * This method should set up the required event subscriptions. * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; $server->xml->elementMap['{DAV:}share-resource'] = 'Sabre\\DAV\\Xml\\Request\\ShareResource'; @@ -94,12 +93,11 @@ class Plugin extends ServerPlugin { '{DAV:}share-mode' ); - $server->on('method:POST', [$this, 'httpPost']); - $server->on('propFind', [$this, 'propFind']); + $server->on('method:POST', [$this, 'httpPost']); + $server->on('propFind', [$this, 'propFind']); $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']); - $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); - $server->on('onBrowserPostAction', [$this, 'browserPostAction']); - + $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); + $server->on('onBrowserPostAction', [$this, 'browserPostAction']); } /** @@ -108,18 +106,15 @@ class Plugin extends ServerPlugin { * The sharees array is a list of people that are to be added modified * or removed in the list of shares. * - * @param string $path + * @param string $path * @param Sharee[] $sharees - * @return void */ - function shareResource($path, array $sharees) { - + public function shareResource($path, array $sharees) + { $node = $this->server->tree->getNodeForPath($path); if (!$node instanceof ISharedNode) { - throw new Forbidden('Sharing is not allowed on this node'); - } // Getting ACL info @@ -138,7 +133,6 @@ class Plugin extends ServerPlugin { $sharee->principal = $principal; } $node->updateInvites($sharees); - } /** @@ -147,47 +141,41 @@ class Plugin extends ServerPlugin { * This allows us to inject any sharings-specific properties. * * @param PropFind $propFind - * @param INode $node - * @return void + * @param INode $node */ - function propFind(PropFind $propFind, INode $node) { - + public function propFind(PropFind $propFind, INode $node) + { if ($node instanceof ISharedNode) { - - $propFind->handle('{DAV:}share-access', function() use ($node) { - + $propFind->handle('{DAV:}share-access', function () use ($node) { return new Property\ShareAccess($node->getShareAccess()); - }); - $propFind->handle('{DAV:}invite', function() use ($node) { - + $propFind->handle('{DAV:}invite', function () use ($node) { return new Property\Invite($node->getInvites()); - }); - $propFind->handle('{DAV:}share-resource-uri', function() use ($node) { - + $propFind->handle('{DAV:}share-resource-uri', function () use ($node) { return new Property\Href($node->getShareResourceUri()); - }); - } - } /** - * We intercept this to handle POST requests on shared resources + * We intercept this to handle POST requests on shared resources. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return null|bool + * + * @return bool|null */ - function httpPost(RequestInterface $request, ResponseInterface $response) { - + public function httpPost(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $contentType = $request->getHeader('Content-Type'); + if (null === $contentType) { + return; + } // We're only interested in the davsharing content type. - if (strpos($contentType, 'application/davsharing+xml') === false) { + if (false === strpos($contentType, 'application/davsharing+xml')) { return; } @@ -198,7 +186,6 @@ class Plugin extends ServerPlugin { ); switch ($documentType) { - case '{DAV:}share-resource': $this->shareResource($path, $message->sharees); @@ -210,11 +197,9 @@ class Plugin extends ServerPlugin { // Breaking the event chain return false; - default : - throw new BadRequest('Unexpected document type: ' . $documentType . ' for this Content-Type'); - + default: + throw new BadRequest('Unexpected document type: '.$documentType.' for this Content-Type'); } - } /** @@ -226,11 +211,11 @@ class Plugin extends ServerPlugin { * @param INode $node * @param array $supportedPrivilegeSet */ - function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) { - + public function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) + { if ($node instanceof ISharedNode) { $supportedPrivilegeSet['{DAV:}share'] = [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ]; } @@ -247,27 +232,27 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'This plugin implements WebDAV resource sharing', - 'link' => 'https://github.com/evert/webdav-sharing' + 'link' => 'https://github.com/evert/webdav-sharing', ]; - } /** * This method is used to generate HTML output for the * DAV\Browser\Plugin. * - * @param INode $node + * @param INode $node * @param string $output * @param string $path + * * @return bool|null */ - function htmlActionsPanel(INode $node, &$output, $path) { - + public function htmlActionsPanel(INode $node, &$output, $path) + { if (!$node instanceof ISharedNode) { return; } @@ -293,7 +278,6 @@ class Plugin extends ServerPlugin { <input type="submit" value="share" /> </form> </td></tr>'; - } /** @@ -302,11 +286,11 @@ class Plugin extends ServerPlugin { * * @param string $path * @param string $action - * @param array $postVars + * @param array $postVars */ - function browserPostAction($path, $action, $postVars) { - - if ($action !== 'share') { + public function browserPostAction($path, $action, $postVars) + { + if ('share' !== $action) { return; } @@ -319,7 +303,7 @@ class Plugin extends ServerPlugin { $accessMap = [ 'readwrite' => self::ACCESS_READWRITE, - 'read' => self::ACCESS_READ, + 'read' => self::ACCESS_READ, 'no-access' => self::ACCESS_NOACCESS, ]; @@ -327,7 +311,7 @@ class Plugin extends ServerPlugin { throw new BadRequest('The "access" POST must be readwrite, read or no-access'); } $sharee = new Sharee([ - 'href' => $postVars['href'], + 'href' => $postVars['href'], 'access' => $accessMap[$postVars['access']], ]); @@ -335,8 +319,7 @@ class Plugin extends ServerPlugin { $path, [$sharee] ); - return false; + return false; } - } diff --git a/vendor/sabre/dav/lib/DAV/SimpleCollection.php b/vendor/sabre/dav/lib/DAV/SimpleCollection.php index 998cfcbff..1fbb6982d 100644 --- a/vendor/sabre/dav/lib/DAV/SimpleCollection.php +++ b/vendor/sabre/dav/lib/DAV/SimpleCollection.php @@ -1,9 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; +use InvalidArgumentException; + /** - * SimpleCollection + * SimpleCollection. * * The SimpleCollection is used to quickly setup static directory structures. * Just create the object with a proper name, and add children to use it. @@ -12,64 +16,64 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SimpleCollection extends Collection { - +class SimpleCollection extends Collection +{ /** - * List of childnodes + * List of childnodes. * * @var INode[] */ protected $children = []; /** - * Name of this resource + * Name of this resource. * * @var string */ protected $name; /** - * Creates this node + * Creates this node. * * The name of the node must be passed, child nodes can also be passed. * This nodes must be instances of INode * - * @param string $name + * @param string $name * @param INode[] $children */ - function __construct($name, array $children = []) { - + public function __construct($name, array $children = []) + { $this->name = $name; - foreach ($children as $child) { - - if (!($child instanceof INode)) throw new Exception('Only instances of Sabre\DAV\INode are allowed to be passed in the children argument'); + foreach ($children as $key => $child) { + if (is_string($child)) { + $child = new SimpleFile($key, $child); + } elseif (is_array($child)) { + $child = new self($key, $child); + } elseif (!$child instanceof INode) { + throw new InvalidArgumentException('Children must be specified as strings, arrays or instances of Sabre\DAV\INode'); + } $this->addChild($child); - } - } /** - * Adds a new childnode to this collection + * Adds a new childnode to this collection. * * @param INode $child - * @return void */ - function addChild(INode $child) { - + public function addChild(INode $child) + { $this->children[$child->getName()] = $child; - } /** - * Returns the name of the collection + * Returns the name of the collection. * * @return string */ - function getName() { - + public function getName() + { return $this->name; - } /** @@ -82,26 +86,26 @@ class SimpleCollection extends Collection { * exist. * * @param string $name + * * @throws Exception\NotFound + * * @return INode */ - function getChild($name) { - - if (isset($this->children[$name])) return $this->children[$name]; - throw new Exception\NotFound('File not found: ' . $name . ' in \'' . $this->getName() . '\''); - + public function getChild($name) + { + if (isset($this->children[$name])) { + return $this->children[$name]; + } + throw new Exception\NotFound('File not found: '.$name.' in \''.$this->getName().'\''); } /** - * Returns a list of children for this collection + * Returns a list of children for this collection. * * @return INode[] */ - function getChildren() { - + public function getChildren() + { return array_values($this->children); - } - - } diff --git a/vendor/sabre/dav/lib/DAV/SimpleFile.php b/vendor/sabre/dav/lib/DAV/SimpleFile.php index bcad786f3..ca808b672 100644 --- a/vendor/sabre/dav/lib/DAV/SimpleFile.php +++ b/vendor/sabre/dav/lib/DAV/SimpleFile.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * SimpleFile + * SimpleFile. * * The 'SimpleFile' class is used to easily add read-only immutable files to * the directory structure. One usecase would be to add a 'readme.txt' to a @@ -13,45 +15,44 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SimpleFile extends File { - +class SimpleFile extends File +{ /** - * File contents + * File contents. * * @var string */ protected $contents = []; /** - * Name of this resource + * Name of this resource. * * @var string */ protected $name; /** - * A mimetype, such as 'text/plain' or 'text/html' + * A mimetype, such as 'text/plain' or 'text/html'. * * @var string */ protected $mimeType; /** - * Creates this node + * Creates this node. * * The name of the node must be passed, as well as the contents of the * file. * - * @param string $name - * @param string $contents + * @param string $name + * @param string $contents * @param string|null $mimeType */ - function __construct($name, $contents, $mimeType = null) { - + public function __construct($name, $contents, $mimeType = null) + { $this->name = $name; $this->contents = $contents; $this->mimeType = $mimeType; - } /** @@ -61,23 +62,21 @@ class SimpleFile extends File { * * @return string */ - function getName() { - + public function getName() + { return $this->name; - } /** - * Returns the data + * Returns the data. * * This method may either return a string or a readable stream resource * * @return mixed */ - function get() { - + public function get() + { return $this->contents; - } /** @@ -85,37 +84,35 @@ class SimpleFile extends File { * * @return int */ - function getSize() { - + public function getSize() + { return strlen($this->contents); - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. * * Return null if the ETag can not effectively be determined + * * @return string */ - function getETag() { - - return '"' . sha1($this->contents) . '"'; - + public function getETag() + { + return '"'.sha1($this->contents).'"'; } /** - * Returns the mime-type for a file + * Returns the mime-type for a file. * * If null is returned, we'll assume application/octet-stream + * * @return string */ - function getContentType() { - + public function getContentType() + { return $this->mimeType; - } - } diff --git a/vendor/sabre/dav/lib/DAV/StringUtil.php b/vendor/sabre/dav/lib/DAV/StringUtil.php index 10eecebfd..13a4399e3 100644 --- a/vendor/sabre/dav/lib/DAV/StringUtil.php +++ b/vendor/sabre/dav/lib/DAV/StringUtil.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * String utility + * String utility. * * This class is mainly used to implement the 'text-match' filter, used by both * the CalDAV calendar-query REPORT, and CardDAV addressbook-query REPORT. @@ -13,79 +15,74 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class StringUtil { - +class StringUtil +{ /** - * Checks if a needle occurs in a haystack ;) + * Checks if a needle occurs in a haystack ;). * * @param string $haystack * @param string $needle * @param string $collation * @param string $matchType + * * @return bool */ - static function textMatch($haystack, $needle, $collation, $matchType = 'contains') { - + public static function textMatch($haystack, $needle, $collation, $matchType = 'contains') + { switch ($collation) { - - case 'i;ascii-casemap' : + case 'i;ascii-casemap': // default strtolower takes locale into consideration // we don't want this. $haystack = str_replace(range('a', 'z'), range('A', 'Z'), $haystack); $needle = str_replace(range('a', 'z'), range('A', 'Z'), $needle); break; - case 'i;octet' : + case 'i;octet': // Do nothing break; - case 'i;unicode-casemap' : + case 'i;unicode-casemap': $haystack = mb_strtoupper($haystack, 'UTF-8'); $needle = mb_strtoupper($needle, 'UTF-8'); break; - default : - throw new Exception\BadRequest('Collation type: ' . $collation . ' is not supported'); - + default: + throw new Exception\BadRequest('Collation type: '.$collation.' is not supported'); } switch ($matchType) { - - case 'contains' : - return strpos($haystack, $needle) !== false; - case 'equals' : + case 'contains': + return false !== strpos($haystack, $needle); + case 'equals': return $haystack === $needle; - case 'starts-with' : - return strpos($haystack, $needle) === 0; - case 'ends-with' : + case 'starts-with': + return 0 === strpos($haystack, $needle); + case 'ends-with': return strrpos($haystack, $needle) === strlen($haystack) - strlen($needle); - default : - throw new Exception\BadRequest('Match-type: ' . $matchType . ' is not supported'); - + default: + throw new Exception\BadRequest('Match-type: '.$matchType.' is not supported'); } - } /** * This method takes an input string, checks if it's not valid UTF-8 and * attempts to convert it to UTF-8 if it's not. * - * Note that currently this can only convert ISO-8559-1 to UTF-8 (latin-1), + * Note that currently this can only convert ISO-8859-1 to UTF-8 (latin-1), * anything else will likely fail. * * @param string $input + * * @return string */ - static function ensureUTF8($input) { - + public static function ensureUTF8($input) + { $encoding = mb_detect_encoding($input, ['UTF-8', 'ISO-8859-1'], true); - if ($encoding === 'ISO-8859-1') { + if ('ISO-8859-1' === $encoding) { return utf8_encode($input); } else { return $input; } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php b/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php index d3dc28a80..4ca69dc89 100644 --- a/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php +++ b/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Sync; use Sabre\DAV; @@ -15,8 +17,8 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ISyncCollection extends DAV\ICollection { - +interface ISyncCollection extends DAV\ICollection +{ /** * This method returns the current sync-token for this collection. * This can be any string. @@ -26,7 +28,7 @@ interface ISyncCollection extends DAV\ICollection { * * @return string|null */ - function getSyncToken(); + public function getSyncToken(); /** * The getChanges method returns all the changes that have happened, since @@ -79,10 +81,10 @@ interface ISyncCollection extends DAV\ICollection { * The limit is 'suggestive'. You are free to ignore it. * * @param string $syncToken - * @param int $syncLevel - * @param int $limit + * @param int $syncLevel + * @param int $limit + * * @return array */ - function getChanges($syncToken, $syncLevel, $limit = null); - + public function getChanges($syncToken, $syncLevel, $limit = null); } diff --git a/vendor/sabre/dav/lib/DAV/Sync/Plugin.php b/vendor/sabre/dav/lib/DAV/Sync/Plugin.php index 8e4b1aa64..f76827fe3 100644 --- a/vendor/sabre/dav/lib/DAV/Sync/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Sync/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Sync; use Sabre\DAV; @@ -18,10 +20,10 @@ use Sabre\HTTP\RequestInterface; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * Reference to server object + * Reference to server object. * * @var DAV\Server */ @@ -37,10 +39,9 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'sync'; - } /** @@ -49,28 +50,25 @@ class Plugin extends DAV\ServerPlugin { * This is when the plugin registers it's hooks. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { $this->server = $server; $server->xml->elementMap['{DAV:}sync-collection'] = 'Sabre\\DAV\\Xml\\Request\\SyncCollectionReport'; $self = $this; - $server->on('report', function($reportName, $dom, $uri) use ($self) { - - if ($reportName === '{DAV:}sync-collection') { + $server->on('report', function ($reportName, $dom, $uri) use ($self) { + if ('{DAV:}sync-collection' === $reportName) { $this->server->transactionType = 'report-sync-collection'; $self->syncCollection($uri, $dom); + return false; } - }); - $server->on('propFind', [$this, 'propFind']); + $server->on('propFind', [$this, 'propFind']); $server->on('validateTokens', [$this, 'validateTokens']); - } /** @@ -81,10 +79,11 @@ class Plugin extends DAV\ServerPlugin { * implement them * * @param string $uri + * * @return array */ - function getSupportedReportSet($uri) { - + public function getSupportedReportSet($uri) + { $node = $this->server->tree->getNodeForPath($uri); if ($node instanceof ISyncCollection && $node->getSyncToken()) { return [ @@ -93,19 +92,16 @@ class Plugin extends DAV\ServerPlugin { } return []; - } - /** * This method handles the {DAV:}sync-collection HTTP REPORT. * - * @param string $uri + * @param string $uri * @param SyncCollectionReport $report - * @return void */ - function syncCollection($uri, SyncCollectionReport $report) { - + public function syncCollection($uri, SyncCollectionReport $report) + { // Getting the data $node = $this->server->tree->getNodeForPath($uri); if (!$node instanceof ISyncCollection) { @@ -119,19 +115,16 @@ class Plugin extends DAV\ServerPlugin { $syncToken = $report->syncToken; if (!is_null($syncToken)) { // Sync-token must start with our prefix - if (substr($syncToken, 0, strlen(self::SYNCTOKEN_PREFIX)) !== self::SYNCTOKEN_PREFIX) { + if (self::SYNCTOKEN_PREFIX !== substr($syncToken, 0, strlen(self::SYNCTOKEN_PREFIX))) { throw new DAV\Exception\InvalidSyncToken('Invalid or unknown sync token'); } $syncToken = substr($syncToken, strlen(self::SYNCTOKEN_PREFIX)); - } $changeInfo = $node->getChanges($syncToken, $report->syncLevel, $report->limit); if (is_null($changeInfo)) { - throw new DAV\Exception\InvalidSyncToken('Invalid or unknown sync token'); - } // Encoding the response @@ -143,7 +136,6 @@ class Plugin extends DAV\ServerPlugin { $changeInfo['deleted'], $report->properties ); - } /** @@ -151,50 +143,41 @@ class Plugin extends DAV\ServerPlugin { * * @param string $syncToken * @param string $collectionUrl - * @param array $added - * @param array $modified - * @param array $deleted - * @param array $properties - * @return void + * @param array $added + * @param array $modified + * @param array $deleted + * @param array $properties */ - protected function sendSyncCollectionResponse($syncToken, $collectionUrl, array $added, array $modified, array $deleted, array $properties) { - - + protected function sendSyncCollectionResponse($syncToken, $collectionUrl, array $added, array $modified, array $deleted, array $properties) + { $fullPaths = []; // Pre-fetching children, if this is possible. foreach (array_merge($added, $modified) as $item) { - $fullPath = $collectionUrl . '/' . $item; + $fullPath = $collectionUrl.'/'.$item; $fullPaths[] = $fullPath; } $responses = []; foreach ($this->server->getPropertiesForMultiplePaths($fullPaths, $properties) as $fullPath => $props) { - // The 'Property_Response' class is responsible for generating a // single {DAV:}response xml element. $responses[] = new DAV\Xml\Element\Response($fullPath, $props); - } - - // Deleted items also show up as 'responses'. They have no properties, // and a single {DAV:}status element set as 'HTTP/1.1 404 Not Found'. foreach ($deleted as $item) { - - $fullPath = $collectionUrl . '/' . $item; + $fullPath = $collectionUrl.'/'.$item; $responses[] = new DAV\Xml\Element\Response($fullPath, [], 404); - } - $multiStatus = new DAV\Xml\Response\MultiStatus($responses, self::SYNCTOKEN_PREFIX . $syncToken); + $multiStatus = new DAV\Xml\Response\MultiStatus($responses, self::SYNCTOKEN_PREFIX.$syncToken); $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setBody( $this->server->xml->write('{DAV:}multistatus', $multiStatus, $this->server->getBaseUri()) ); - } /** @@ -202,18 +185,17 @@ class Plugin extends DAV\ServerPlugin { * We intercept this to see if we must return a {DAV:}sync-token. * * @param DAV\PropFind $propFind - * @param DAV\INode $node - * @return void + * @param DAV\INode $node */ - function propFind(DAV\PropFind $propFind, DAV\INode $node) { - - $propFind->handle('{DAV:}sync-token', function() use ($node) { + public function propFind(DAV\PropFind $propFind, DAV\INode $node) + { + $propFind->handle('{DAV:}sync-token', function () use ($node) { if (!$node instanceof ISyncCollection || !$token = $node->getSyncToken()) { return; } - return self::SYNCTOKEN_PREFIX . $token; - }); + return self::SYNCTOKEN_PREFIX.$token; + }); } /** @@ -223,17 +205,14 @@ class Plugin extends DAV\ServerPlugin { * in the If: header, and check if they are valid. * * @param RequestInterface $request - * @param array $conditions - * @return void + * @param array $conditions */ - function validateTokens(RequestInterface $request, &$conditions) { - + public function validateTokens(RequestInterface $request, &$conditions) + { foreach ($conditions as $kk => $condition) { - foreach ($condition['tokens'] as $ii => $token) { - // Sync-tokens must always start with our designated prefix. - if (substr($token['token'], 0, strlen(self::SYNCTOKEN_PREFIX)) !== self::SYNCTOKEN_PREFIX) { + if (self::SYNCTOKEN_PREFIX !== substr($token['token'], 0, strlen(self::SYNCTOKEN_PREFIX))) { continue; } @@ -246,11 +225,8 @@ class Plugin extends DAV\ServerPlugin { ) { $conditions[$kk]['tokens'][$ii]['validToken'] = true; } - } - } - } /** @@ -264,14 +240,12 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds support for WebDAV Collection Sync (rfc6578)', - 'link' => 'http://sabre.io/dav/sync/', + 'link' => 'http://sabre.io/dav/sync/', ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/TemporaryFileFilterPlugin.php b/vendor/sabre/dav/lib/DAV/TemporaryFileFilterPlugin.php index 7b453d105..6cf772f44 100644 --- a/vendor/sabre/dav/lib/DAV/TemporaryFileFilterPlugin.php +++ b/vendor/sabre/dav/lib/DAV/TemporaryFileFilterPlugin.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * Temporary File Filter Plugin + * Temporary File Filter Plugin. * * The purpose of this filter is to intercept some of the garbage files * operation systems and applications tend to generate when mounting @@ -30,8 +32,8 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class TemporaryFileFilterPlugin extends ServerPlugin { - +class TemporaryFileFilterPlugin extends ServerPlugin +{ /** * This is the list of patterns we intercept. * If new patterns are added, they must be valid patterns for preg_match. @@ -49,7 +51,7 @@ class TemporaryFileFilterPlugin extends ServerPlugin { ]; /** - * A reference to the main Server class + * A reference to the main Server class. * * @var \Sabre\DAV\Server */ @@ -72,58 +74,61 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * * @param string|null $dataDir */ - function __construct($dataDir = null) { - - if (!$dataDir) $dataDir = ini_get('session.save_path') . '/sabredav/'; - if (!is_dir($dataDir)) mkdir($dataDir); + public function __construct($dataDir = null) + { + if (!$dataDir) { + $dataDir = ini_get('session.save_path').'/sabredav/'; + } + if (!is_dir($dataDir)) { + mkdir($dataDir); + } $this->dataDir = $dataDir; - } /** - * Initialize the plugin + * Initialize the plugin. * * This is called automatically be the Server class after this plugin is * added with Sabre\DAV\Server::addPlugin() * * @param Server $server - * @return void */ - function initialize(Server $server) { - + public function initialize(Server $server) + { $this->server = $server; - $server->on('beforeMethod', [$this, 'beforeMethod']); + $server->on('beforeMethod:*', [$this, 'beforeMethod']); $server->on('beforeCreateFile', [$this, 'beforeCreateFile']); - } /** - * This method is called before any HTTP method handler + * This method is called before any HTTP method handler. * * This method intercepts any GET, DELETE, PUT and PROPFIND calls to * filenames that are known to match the 'temporary file' regex. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function beforeMethod(RequestInterface $request, ResponseInterface $response) { - - if (!$tempLocation = $this->isTempFile($request->getPath())) + public function beforeMethod(RequestInterface $request, ResponseInterface $response) + { + if (!$tempLocation = $this->isTempFile($request->getPath())) { return; + } switch ($request->getMethod()) { - case 'GET' : + case 'GET': return $this->httpGet($request, $response, $tempLocation); - case 'PUT' : + case 'PUT': return $this->httpPut($request, $response, $tempLocation); - case 'PROPFIND' : + case 'PROPFIND': return $this->httpPropfind($request, $response, $tempLocation); - case 'DELETE' : + case 'DELETE': return $this->httpDelete($request, $response, $tempLocation); } - return; + return; } /** @@ -132,24 +137,25 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * This is used to deal with HTTP LOCK requests which create a new * file. * - * @param string $uri - * @param resource $data + * @param string $uri + * @param resource $data * @param ICollection $parent - * @param bool $modified Should be set to true, if this event handler - * changed &$data. + * @param bool $modified should be set to true, if this event handler + * changed &$data + * * @return bool */ - function beforeCreateFile($uri, $data, ICollection $parent, $modified) { - + public function beforeCreateFile($uri, $data, ICollection $parent, $modified) + { if ($tempPath = $this->isTempFile($uri)) { - $hR = $this->server->httpResponse; $hR->setHeader('X-Sabre-Temp', 'true'); file_put_contents($tempPath, $data); + return false; } - return; + return; } /** @@ -158,71 +164,76 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * temporary file storage. * * @param string $path + * * @return bool|string */ - protected function isTempFile($path) { - + protected function isTempFile($path) + { // We're only interested in the basename. - list(, $tempPath) = URLUtil::splitPath($path); + list(, $tempPath) = Uri\split($path); - foreach ($this->temporaryFilePatterns as $tempFile) { + if (null === $tempPath) { + return false; + } + foreach ($this->temporaryFilePatterns as $tempFile) { if (preg_match($tempFile, $tempPath)) { - return $this->getDataDir() . '/sabredav_' . md5($path) . '.tempfile'; + return $this->getDataDir().'/sabredav_'.md5($path).'.tempfile'; } - } return false; - } - /** * This method handles the GET method for temporary files. * If the file doesn't exist, it will return false which will kick in * the regular system for the GET method. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $hR - * @param string $tempLocation + * @param string $tempLocation + * * @return bool */ - function httpGet(RequestInterface $request, ResponseInterface $hR, $tempLocation) { - - if (!file_exists($tempLocation)) return; + public function httpGet(RequestInterface $request, ResponseInterface $hR, $tempLocation) + { + if (!file_exists($tempLocation)) { + return; + } $hR->setHeader('Content-Type', 'application/octet-stream'); $hR->setHeader('Content-Length', filesize($tempLocation)); $hR->setHeader('X-Sabre-Temp', 'true'); $hR->setStatus(200); $hR->setBody(fopen($tempLocation, 'r')); - return false; + return false; } /** * This method handles the PUT method. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $hR - * @param string $tempLocation + * @param string $tempLocation + * * @return bool */ - function httpPut(RequestInterface $request, ResponseInterface $hR, $tempLocation) { - + public function httpPut(RequestInterface $request, ResponseInterface $hR, $tempLocation) + { $hR->setHeader('X-Sabre-Temp', 'true'); $newFile = !file_exists($tempLocation); if (!$newFile && ($this->server->httpRequest->getHeader('If-None-Match'))) { - throw new Exception\PreconditionFailed('The resource already exists, and an If-None-Match header was supplied'); + throw new Exception\PreconditionFailed('The resource already exists, and an If-None-Match header was supplied'); } file_put_contents($tempLocation, $this->server->httpRequest->getBody()); $hR->setStatus($newFile ? 201 : 200); - return false; + return false; } /** @@ -231,20 +242,23 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * If the file didn't exist, it will return false, which will make the * standard HTTP DELETE handler kick in. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $hR - * @param string $tempLocation + * @param string $tempLocation + * * @return bool */ - function httpDelete(RequestInterface $request, ResponseInterface $hR, $tempLocation) { - - if (!file_exists($tempLocation)) return; + public function httpDelete(RequestInterface $request, ResponseInterface $hR, $tempLocation) + { + if (!file_exists($tempLocation)) { + return; + } unlink($tempLocation); $hR->setHeader('X-Sabre-Temp', 'true'); $hR->setStatus(204); - return false; + return false; } /** @@ -254,14 +268,17 @@ class TemporaryFileFilterPlugin extends ServerPlugin { * for which properties were requested, and just sends back a default * set of properties. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $hR - * @param string $tempLocation + * @param string $tempLocation + * * @return bool */ - function httpPropfind(RequestInterface $request, ResponseInterface $hR, $tempLocation) { - - if (!file_exists($tempLocation)) return; + public function httpPropfind(RequestInterface $request, ResponseInterface $hR, $tempLocation) + { + if (!file_exists($tempLocation)) { + return; + } $hR->setHeader('X-Sabre-Temp', 'true'); $hR->setStatus(207); @@ -269,22 +286,20 @@ class TemporaryFileFilterPlugin extends ServerPlugin { $properties = [ 'href' => $request->getPath(), - 200 => [ - '{DAV:}getlastmodified' => new Xml\Property\GetLastModified(filemtime($tempLocation)), - '{DAV:}getcontentlength' => filesize($tempLocation), - '{DAV:}resourcetype' => new Xml\Property\ResourceType(null), - '{' . Server::NS_SABREDAV . '}tempFile' => true, - + 200 => [ + '{DAV:}getlastmodified' => new Xml\Property\GetLastModified(filemtime($tempLocation)), + '{DAV:}getcontentlength' => filesize($tempLocation), + '{DAV:}resourcetype' => new Xml\Property\ResourceType(null), + '{'.Server::NS_SABREDAV.'}tempFile' => true, ], ]; $data = $this->server->generateMultiStatus([$properties]); $hR->setBody($data); - return false; + return false; } - /** * This method returns the directory where the temporary files should be stored. * diff --git a/vendor/sabre/dav/lib/DAV/Tree.php b/vendor/sabre/dav/lib/DAV/Tree.php index 7c04f0915..7a5a25f87 100644 --- a/vendor/sabre/dav/lib/DAV/Tree.php +++ b/vendor/sabre/dav/lib/DAV/Tree.php @@ -1,8 +1,10 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** * The tree object is responsible for basic tree operations. @@ -14,10 +16,10 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Tree { - +class Tree +{ /** - * The root node + * The root node. * * @var ICollection */ @@ -32,28 +34,30 @@ class Tree { protected $cache = []; /** - * Creates the object + * Creates the object. * * This method expects the rootObject to be passed as a parameter * * @param ICollection $rootNode */ - function __construct(ICollection $rootNode) { - + public function __construct(ICollection $rootNode) + { $this->rootNode = $rootNode; - } /** - * Returns the INode object for the requested path + * Returns the INode object for the requested path. * * @param string $path + * * @return INode */ - function getNodeForPath($path) { - + public function getNodeForPath($path) + { $path = trim($path, '/'); - if (isset($this->cache[$path])) return $this->cache[$path]; + if (isset($this->cache[$path])) { + return $this->cache[$path]; + } // Is it the root node? if (!strlen($path)) { @@ -61,25 +65,24 @@ class Tree { } // Attempting to fetch its parent - list($parentName, $baseName) = URLUtil::splitPath($path); + list($parentName, $baseName) = Uri\split($path); // If there was no parent, we must simply ask it from the root node. - if ($parentName === "") { + if ('' === $parentName) { $node = $this->rootNode->getChild($baseName); } else { // Otherwise, we recursively grab the parent and ask him/her. $parent = $this->getNodeForPath($parentName); - if (!($parent instanceof ICollection)) - throw new Exception\NotFound('Could not find node at path: ' . $path); - + if (!($parent instanceof ICollection)) { + throw new Exception\NotFound('Could not find node at path: '.$path); + } $node = $parent->getChild($baseName); - } $this->cache[$path] = $node; - return $node; + return $node; } /** @@ -89,61 +92,64 @@ class Tree { * it cheaper. * * @param string $path + * * @return bool */ - function nodeExists($path) { - + public function nodeExists($path) + { try { - // The root always exists - if ($path === '') return true; + if ('' === $path) { + return true; + } - list($parent, $base) = URLUtil::splitPath($path); + list($parent, $base) = Uri\split($path); $parentNode = $this->getNodeForPath($parent); - if (!$parentNode instanceof ICollection) return false; - return $parentNode->childExists($base); + if (!$parentNode instanceof ICollection) { + return false; + } + return $parentNode->childExists($base); } catch (Exception\NotFound $e) { - return false; - } - } /** - * Copies a file from path to another + * Copies a file from path to another. * - * @param string $sourcePath The source location + * @param string $sourcePath The source location * @param string $destinationPath The full destination path - * @return void */ - function copy($sourcePath, $destinationPath) { - + public function copy($sourcePath, $destinationPath) + { $sourceNode = $this->getNodeForPath($sourcePath); // grab the dirname and basename components - list($destinationDir, $destinationName) = URLUtil::splitPath($destinationPath); + list($destinationDir, $destinationName) = Uri\split($destinationPath); $destinationParent = $this->getNodeForPath($destinationDir); - $this->copyNode($sourceNode, $destinationParent, $destinationName); + // Check if the target can handle the copy itself. If not, we do it ourselves. + if (!$destinationParent instanceof ICopyTarget || !$destinationParent->copyInto($destinationName, $sourcePath, $sourceNode)) { + $this->copyNode($sourceNode, $destinationParent, $destinationName); + } $this->markDirty($destinationDir); - } /** - * Moves a file from one location to another + * Moves a file from one location to another. * - * @param string $sourcePath The path to the file which should be moved + * @param string $sourcePath The path to the file which should be moved * @param string $destinationPath The full destination path, so not just the destination parent node + * * @return int */ - function move($sourcePath, $destinationPath) { - - list($sourceDir) = URLUtil::splitPath($sourcePath); - list($destinationDir, $destinationName) = URLUtil::splitPath($destinationPath); + public function move($sourcePath, $destinationPath) + { + list($sourceDir) = Uri\split($sourcePath); + list($destinationDir, $destinationName) = Uri\split($destinationPath); if ($sourceDir === $destinationDir) { // If this is a 'local' rename, it means we can just trigger a rename. @@ -164,49 +170,45 @@ class Tree { } $this->markDirty($sourceDir); $this->markDirty($destinationDir); - } /** - * Deletes a node from the tree + * Deletes a node from the tree. * * @param string $path - * @return void */ - function delete($path) { - + public function delete($path) + { $node = $this->getNodeForPath($path); $node->delete(); - list($parent) = URLUtil::splitPath($path); + list($parent) = Uri\split($path); $this->markDirty($parent); - } /** * Returns a list of childnodes for a given path. * * @param string $path - * @return array + * + * @return \Traversable */ - function getChildren($path) { - + public function getChildren($path) + { $node = $this->getNodeForPath($path); - $children = $node->getChildren(); $basePath = trim($path, '/'); - if ($basePath !== '') $basePath .= '/'; - - foreach ($children as $child) { - - $this->cache[$basePath . $child->getName()] = $child; - + if ('' !== $basePath) { + $basePath .= '/'; } - return $children; + foreach ($node->getChildren() as $child) { + $this->cache[$basePath.$child->getName()] = $child; + yield $child; + } } /** - * This method is called with every tree update + * This method is called with every tree update. * * Examples of tree updates are: * * node deletions @@ -221,19 +223,17 @@ class Tree { * If a path is passed, it is assumed that the entire subtree is dirty * * @param string $path - * @return void */ - function markDirty($path) { - + public function markDirty($path) + { // We don't care enough about sub-paths // flushing the entire cache $path = trim($path, '/'); foreach ($this->cache as $nodePath => $node) { - if ($path === '' || $nodePath == $path || strpos($nodePath, $path . '/') === 0) + if ('' === $path || $nodePath == $path || 0 === strpos($nodePath, $path.'/')) { unset($this->cache[$nodePath]); - + } } - } /** @@ -247,15 +247,16 @@ class Tree { * This method returns an array with the found nodes. It's keys are the * original paths. The result may be out of order. * - * @param array $paths List of nodes that must be fetched. + * @param array $paths list of nodes that must be fetched + * * @return array */ - function getMultipleNodes($paths) { - + public function getMultipleNodes($paths) + { // Finding common parents $parents = []; foreach ($paths as $path) { - list($parent, $node) = URLUtil::splitPath($path); + list($parent, $node) = Uri\split($path); if (!isset($parents[$parent])) { $parents[$parent] = [$node]; } else { @@ -266,44 +267,38 @@ class Tree { $result = []; foreach ($parents as $parent => $children) { - $parentNode = $this->getNodeForPath($parent); if ($parentNode instanceof IMultiGet) { foreach ($parentNode->getMultipleChildren($children) as $childNode) { - $fullPath = $parent . '/' . $childNode->getName(); + $fullPath = $parent.'/'.$childNode->getName(); $result[$fullPath] = $childNode; $this->cache[$fullPath] = $childNode; } } else { foreach ($children as $child) { - $fullPath = $parent . '/' . $child; + $fullPath = $parent.'/'.$child; $result[$fullPath] = $this->getNodeForPath($fullPath); } } - } return $result; - } - /** - * copyNode + * copyNode. * - * @param INode $source + * @param INode $source * @param ICollection $destinationParent - * @param string $destinationName - * @return void + * @param string $destinationName */ - protected function copyNode(INode $source, ICollection $destinationParent, $destinationName = null) { - - if ((string)$destinationName === '') { + protected function copyNode(INode $source, ICollection $destinationParent, $destinationName = null) + { + if ('' === (string) $destinationName) { $destinationName = $source->getName(); } if ($source instanceof IFile) { - $data = $source->get(); // If the body was a string, we need to convert it to a stream @@ -315,28 +310,19 @@ class Tree { } $destinationParent->createFile($destinationName, $data); $destination = $destinationParent->getChild($destinationName); - } elseif ($source instanceof ICollection) { - $destinationParent->createDirectory($destinationName); $destination = $destinationParent->getChild($destinationName); foreach ($source->getChildren() as $child) { - $this->copyNode($child, $destination); - } - } if ($source instanceof IProperties && $destination instanceof IProperties) { - $props = $source->getProperties([]); $propPatch = new PropPatch($props); $destination->propPatch($propPatch); $propPatch->commit(); - } - } - } diff --git a/vendor/sabre/dav/lib/DAV/UUIDUtil.php b/vendor/sabre/dav/lib/DAV/UUIDUtil.php index 177adafd3..8c36e1b0b 100644 --- a/vendor/sabre/dav/lib/DAV/UUIDUtil.php +++ b/vendor/sabre/dav/lib/DAV/UUIDUtil.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** - * UUID Utility + * UUID Utility. * * This class has static methods to generate and validate UUID's. * UUIDs are used a decent amount within various *DAV standards, so it made @@ -13,18 +15,19 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class UUIDUtil { - +class UUIDUtil +{ /** - * Returns a pseudo-random v4 UUID + * Returns a pseudo-random v4 UUID. * * This function is based on a comment by Andrew Moore on php.net * * @see http://www.php.net/manual/en/function.uniqid.php#94959 + * * @return string */ - static function getUUID() { - + public static function getUUID() + { return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low" mt_rand(0, 0xffff), mt_rand(0, 0xffff), @@ -50,15 +53,14 @@ class UUIDUtil { * Checks if a string is a valid UUID. * * @param string $uuid + * * @return bool */ - static function validateUUID($uuid) { - - return preg_match( + public static function validateUUID($uuid) + { + return 0 !== preg_match( '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i', $uuid - ) !== 0; - + ); } - } diff --git a/vendor/sabre/dav/lib/DAV/Version.php b/vendor/sabre/dav/lib/DAV/Version.php index 89918e5bc..c00255881 100644 --- a/vendor/sabre/dav/lib/DAV/Version.php +++ b/vendor/sabre/dav/lib/DAV/Version.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; /** @@ -9,11 +11,10 @@ namespace Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Version { - +class Version +{ /** - * Full version number + * Full version number. */ - const VERSION = '3.2.2'; - + const VERSION = '4.0.2'; } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Prop.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Prop.php index 71ef03e3f..52a04cf08 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Element/Prop.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Prop.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Element; use Sabre\DAV\Xml\Property\Complex; @@ -17,8 +19,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Prop implements XmlDeserializable { - +class Prop implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -38,13 +40,15 @@ class Prop implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { // If there's no children, we don't do anything. if ($reader->isEmptyElement) { $reader->next(); + return []; } @@ -52,22 +56,17 @@ class Prop implements XmlDeserializable { $reader->read(); do { - - if ($reader->nodeType === Reader::ELEMENT) { - + if (Reader::ELEMENT === $reader->nodeType) { $clark = $reader->getClark(); $values[$clark] = self::parseCurrentElement($reader)['value']; - } else { $reader->read(); } - - } while ($reader->nodeType !== Reader::END_ELEMENT); + } while (Reader::END_ELEMENT !== $reader->nodeType); $reader->read(); return $values; - } /** @@ -81,10 +80,11 @@ class Prop implements XmlDeserializable { * * value - The parsed value. * * @param Reader $reader + * * @return array */ - private static function parseCurrentElement(Reader $reader) { - + private static function parseCurrentElement(Reader $reader) + { $name = $reader->getClark(); if (array_key_exists($name, $reader->elementMap)) { @@ -95,22 +95,20 @@ class Prop implements XmlDeserializable { $value = call_user_func($deserializer, $reader); } else { $type = gettype($deserializer); - if ($type === 'string') { - $type .= ' (' . $deserializer . ')'; - } elseif ($type === 'object') { - $type .= ' (' . get_class($deserializer) . ')'; + if ('string' === $type) { + $type .= ' ('.$deserializer.')'; + } elseif ('object' === $type) { + $type .= ' ('.get_class($deserializer).')'; } - throw new \LogicException('Could not use this type as a deserializer: ' . $type); + throw new \LogicException('Could not use this type as a deserializer: '.$type); } } else { $value = Complex::xmlDeserialize($reader); } return [ - 'name' => $name, + 'name' => $name, 'value' => $value, ]; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php index ce97ae943..a11091809 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Element; use Sabre\Xml\Element; @@ -7,7 +9,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * WebDAV {DAV:}response parser + * WebDAV {DAV:}response parser. * * This class parses the {DAV:}response element, as defined in: * @@ -17,17 +19,17 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class Response implements Element { - +class Response implements Element +{ /** - * Url for the response + * Url for the response. * * @var string */ protected $href; /** - * Propertylist, ordered by HTTP status code + * Propertylist, ordered by HTTP status code. * * @var array */ @@ -57,51 +59,46 @@ class Response implements Element { * deleted. * * @param string $href - * @param array $responseProperties + * @param array $responseProperties * @param string $httpStatus */ - function __construct($href, array $responseProperties, $httpStatus = null) { - + public function __construct($href, array $responseProperties, $httpStatus = null) + { $this->href = $href; $this->responseProperties = $responseProperties; $this->httpStatus = $httpStatus; - } /** - * Returns the url + * Returns the url. * * @return string */ - function getHref() { - + public function getHref() + { return $this->href; - } /** - * Returns the httpStatus value + * Returns the httpStatus value. * * @return string */ - function getHttpStatus() { - + public function getHttpStatus() + { return $this->httpStatus; - } /** - * Returns the property list + * Returns the property list. * * @return array */ - function getResponseProperties() { - + public function getResponseProperties() + { return $this->responseProperties; - } - /** * The serialize method is called during xml writing. * @@ -115,19 +112,17 @@ class Response implements Element { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { if ($status = $this->getHTTPStatus()) { - $writer->writeElement('{DAV:}status', 'HTTP/1.1 ' . $status . ' ' . \Sabre\HTTP\Response::$statusCodes[$status]); + $writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$status.' '.\Sabre\HTTP\Response::$statusCodes[$status]); } - $writer->writeElement('{DAV:}href', $writer->contextUri . \Sabre\HTTP\encodePath($this->getHref())); + $writer->writeElement('{DAV:}href', $writer->contextUri.\Sabre\HTTP\encodePath($this->getHref())); $empty = true; foreach ($this->getResponseProperties() as $status => $properties) { - // Skipping empty lists if (!$properties || (!ctype_digit($status) && !is_int($status))) { continue; @@ -135,9 +130,8 @@ class Response implements Element { $empty = false; $writer->startElement('{DAV:}propstat'); $writer->writeElement('{DAV:}prop', $properties); - $writer->writeElement('{DAV:}status', 'HTTP/1.1 ' . $status . ' ' . \Sabre\HTTP\Response::$statusCodes[$status]); + $writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$status.' '.\Sabre\HTTP\Response::$statusCodes[$status]); $writer->endElement(); // {DAV:}propstat - } if ($empty) { /* @@ -149,12 +143,10 @@ class Response implements Element { * no properties. */ $writer->writeElement('{DAV:}propstat', [ - '{DAV:}prop' => [], - '{DAV:}status' => 'HTTP/1.1 418 ' . \Sabre\HTTP\Response::$statusCodes[418] + '{DAV:}prop' => [], + '{DAV:}status' => 'HTTP/1.1 418 '.\Sabre\HTTP\Response::$statusCodes[418], ]); - } - } /** @@ -176,10 +168,11 @@ class Response implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $reader->pushContext(); $reader->elementMap['{DAV:}propstat'] = 'Sabre\\Xml\\Element\\KeyValue'; @@ -192,16 +185,16 @@ class Response implements Element { // called. But we don't want this, because a singular element without // child-elements implies 'no value' in {DAV:}prop, so we want to skip // deserializers and just set null for those. - $reader->elementMap['{DAV:}prop'] = function(Reader $reader) { - + $reader->elementMap['{DAV:}prop'] = function (Reader $reader) { if ($reader->isEmptyElement) { $reader->next(); + return []; } $values = []; $reader->read(); do { - if ($reader->nodeType === Reader::ELEMENT) { + if (Reader::ELEMENT === $reader->nodeType) { $clark = $reader->getClark(); if ($reader->isEmptyElement) { @@ -213,10 +206,10 @@ class Response implements Element { } else { $reader->read(); } - } while ($reader->nodeType !== Reader::END_ELEMENT); + } while (Reader::END_ELEMENT !== $reader->nodeType); $reader->read(); - return $values; + return $values; }; $elems = $reader->parseInnerTree(); $reader->popContext(); @@ -226,28 +219,24 @@ class Response implements Element { $statusCode = null; foreach ($elems as $elem) { - switch ($elem['name']) { - - case '{DAV:}href' : + case '{DAV:}href': $href = $elem['value']; break; - case '{DAV:}propstat' : + case '{DAV:}propstat': $status = $elem['value']['{DAV:}status']; - list(, $status, ) = explode(' ', $status, 3); + list(, $status) = explode(' ', $status, 3); $properties = isset($elem['value']['{DAV:}prop']) ? $elem['value']['{DAV:}prop'] : []; - if ($properties) $propertyLists[$status] = $properties; + if ($properties) { + $propertyLists[$status] = $properties; + } break; - case '{DAV:}status' : - list(, $statusCode, ) = explode(' ', $elem['value'], 3); + case '{DAV:}status': + list(, $statusCode) = explode(' ', $elem['value'], 3); break; - } - } return new self($href, $propertyLists, $statusCode); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php index e187bf11c..e0db3bf37 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Element; use Sabre\DAV\Exception\BadRequest; @@ -18,8 +20,8 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Sharee implements Element { - +class Sharee implements Element +{ /** * A URL. Usually a mailto: address, could also be a principal url. * This uniquely identifies the sharee. @@ -79,24 +81,21 @@ class Sharee implements Element { public $inviteStatus; /** - * Creates the object + * Creates the object. * * $properties will be used to populate all internal properties. * * @param array $properties */ - function __construct(array $properties = []) { - + public function __construct(array $properties = []) + { foreach ($properties as $k => $v) { - if (property_exists($this, $k)) { $this->$k = $v; } else { - throw new \InvalidArgumentException('Unknown property: ' . $k); + throw new \InvalidArgumentException('Unknown property: '.$k); } - } - } /** @@ -116,31 +115,28 @@ class Sharee implements Element { * 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->write([ new Href($this->href), - '{DAV:}prop' => $this->properties, + '{DAV:}prop' => $this->properties, '{DAV:}share-access' => new ShareAccess($this->access), ]); switch ($this->inviteStatus) { - case Plugin::INVITE_NORESPONSE : + case Plugin::INVITE_NORESPONSE: $writer->writeElement('{DAV:}invite-noresponse'); break; - case Plugin::INVITE_ACCEPTED : + case Plugin::INVITE_ACCEPTED: $writer->writeElement('{DAV:}invite-accepted'); break; - case Plugin::INVITE_DECLINED : + case Plugin::INVITE_DECLINED: $writer->writeElement('{DAV:}invite-declined'); break; - case Plugin::INVITE_INVALID : + case Plugin::INVITE_INVALID: $writer->writeElement('{DAV:}invite-invalid'); break; } - } /** @@ -162,10 +158,11 @@ class Sharee implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { // Temporarily override configuration $reader->pushContext(); $reader->elementMap['{DAV:}share-access'] = 'Sabre\DAV\Xml\Property\ShareAccess'; @@ -192,8 +189,7 @@ class Sharee implements Element { throw new BadRequest('Every {DAV:}sharee must have a {DAV:}share-access child element'); } $sharee->access = $elems['share-access']->getValue(); - return $sharee; + return $sharee; } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php index 258806e4a..990302054 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\Xml\Element\XmlFragment; @@ -15,8 +17,8 @@ use Sabre\Xml\Reader; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Complex extends XmlFragment { - +class Complex extends XmlFragment +{ /** * The deserialize method is called during xml parsing. * @@ -36,15 +38,17 @@ class Complex extends XmlFragment { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $xml = $reader->readInnerXml(); - if ($reader->nodeType === Reader::ELEMENT && $reader->isEmptyElement) { + if (Reader::ELEMENT === $reader->nodeType && $reader->isEmptyElement) { // Easy! $reader->next(); + return null; } // Now we have a copy of the inner xml, we need to traverse it to get @@ -56,21 +60,19 @@ class Complex extends XmlFragment { $text = ''; while (true) { - switch ($reader->nodeType) { - case Reader::ELEMENT : + case Reader::ELEMENT: $nonText = true; $reader->next(); continue 2; - case Reader::TEXT : - case Reader::CDATA : + case Reader::TEXT: + case Reader::CDATA: $text .= $reader->value; break; - case Reader::END_ELEMENT : + case Reader::END_ELEMENT: break 2; } $reader->read(); - } // Make sure we advance the cursor one step further. @@ -78,12 +80,10 @@ class Complex extends XmlFragment { if ($nonText) { $new = new self($xml); + return $new; } else { return $text; } - } - - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php b/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php index 101a0f0c9..05a00c5e5 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use DateTime; @@ -19,42 +21,40 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class GetLastModified implements Element { - +class GetLastModified implements Element +{ /** - * time + * time. * * @var DateTime */ public $time; /** - * Constructor + * Constructor. * * @param int|DateTime $time */ - function __construct($time) { - + public function __construct($time) + { if ($time instanceof DateTime) { $this->time = clone $time; } else { - $this->time = new DateTime('@' . $time); + $this->time = new DateTime('@'.$time); } // Setting timezone to UTC $this->time->setTimezone(new DateTimeZone('UTC')); - } /** - * getTime + * getTime. * * @return DateTime */ - function getTime() { - + public function getTime() + { return $this->time; - } /** @@ -70,14 +70,12 @@ class GetLastModified implements Element { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { $writer->write( - HTTP\Util::toHTTPDate($this->time) + HTTP\toDate($this->time) ); - } /** @@ -99,12 +97,12 @@ class GetLastModified implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { return new self(new DateTime($reader->parseInnerTree())); - } } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php index 6c4f11b87..c479c1602 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -10,7 +12,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * Href property + * Href property. * * This class represents any WebDAV property that contains a {DAV:}href * element, and there are many. @@ -23,17 +25,17 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class Href implements Element, HtmlOutput { - +class Href implements Element, HtmlOutput +{ /** - * List of uris + * List of uris. * * @var array */ protected $hrefs; /** - * Constructor + * Constructor. * * You must either pass a string for a single href, or an array of hrefs. * @@ -42,35 +44,32 @@ class Href implements Element, HtmlOutput { * * @param string|string[] $hrefs */ - function __construct($hrefs) { - + public function __construct($hrefs) + { if (is_string($hrefs)) { $hrefs = [$hrefs]; } $this->hrefs = $hrefs; - } /** * Returns the first Href. * - * @return string + * @return string|null */ - function getHref() { - - return $this->hrefs[0]; - + public function getHref() + { + return $this->hrefs[0] ?? null; } /** - * Returns the hrefs as an array + * Returns the hrefs as an array. * * @return array */ - function getHrefs() { - + public function getHrefs() + { return $this->hrefs; - } /** @@ -90,15 +89,13 @@ class Href 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->getHrefs() as $href) { $href = Uri\resolve($writer->contextUri, $href); $writer->writeElement('{DAV:}href', $href); } - } /** @@ -113,16 +110,17 @@ class Href implements Element, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { $links = []; foreach ($this->getHrefs() as $href) { $links[] = $html->link($href); } - return implode('<br />', $links); + return implode('<br />', $links); } /** @@ -144,22 +142,21 @@ class Href implements Element, HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $hrefs = []; - foreach ((array)$reader->parseInnerTree() as $elem) { - if ($elem['name'] !== '{DAV:}href') + foreach ((array) $reader->parseInnerTree() as $elem) { + if ('{DAV:}href' !== $elem['name']) { continue; + } $hrefs[] = $elem['value']; - } if ($hrefs) { - return new self($hrefs, false); + return new self($hrefs); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php index 6adad3650..b5e2dae46 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Xml\Element\Sharee; @@ -20,10 +22,10 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Invite implements XmlSerializable { - +class Invite implements XmlSerializable +{ /** - * A list of sharees + * A list of sharees. * * @var Sharee[] */ @@ -34,10 +36,9 @@ class Invite implements XmlSerializable { * * @param Sharee[] $sharees */ - function __construct(array $sharees) { - + public function __construct(array $sharees) + { $this->sharees = $sharees; - } /** @@ -57,14 +58,11 @@ class Invite 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) + { foreach ($this->sharees as $sharee) { $writer->writeElement('{DAV:}sharee', $sharee); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php b/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php index 00d2fa708..cb794974f 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\HTTP; /** - * LocalHref property + * LocalHref property. * * Like the Href property, this element represents {DAV:}href. The difference * is that this is used strictly for paths on the server. The LocalHref property @@ -22,10 +24,10 @@ use Sabre\HTTP; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class LocalHref extends Href { - +class LocalHref extends Href +{ /** - * Constructor + * Constructor. * * You must either pass a string for a single href, or an array of hrefs. * @@ -34,15 +36,13 @@ class LocalHref extends Href { * * @param string|string[] $hrefs */ - function __construct($hrefs) { - + public function __construct($hrefs) + { parent::__construct(array_map( - function($href) { + function ($href) { return \Sabre\HTTP\encodePath($href); }, - (array)$hrefs + (array) $hrefs )); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php b/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php index f4b692219..c33812b3e 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV; @@ -20,10 +22,10 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class LockDiscovery implements XmlSerializable { - +class LockDiscovery implements XmlSerializable +{ /** - * locks + * locks. * * @var LockInfo[] */ @@ -37,17 +39,16 @@ class LockDiscovery implements XmlSerializable { * * @var bool */ - static $hideLockRoot = false; + public static $hideLockRoot = false; /** - * __construct + * __construct. * * @param LockInfo[] $locks */ - function __construct($locks) { - + public function __construct($locks) + { $this->locks = $locks; - } /** @@ -63,16 +64,14 @@ class LockDiscovery implements XmlSerializable { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->locks as $lock) { - $writer->startElement('{DAV:}activelock'); $writer->startElement('{DAV:}lockscope'); - if ($lock->scope === LockInfo::SHARED) { + if (LockInfo::SHARED === $lock->scope) { $writer->writeElement('{DAV:}shared'); } else { $writer->writeElement('{DAV:}exclusive'); @@ -86,21 +85,23 @@ class LockDiscovery implements XmlSerializable { if (!self::$hideLockRoot) { $writer->startElement('{DAV:}lockroot'); - $writer->writeElement('{DAV:}href', $writer->contextUri . $lock->uri); + $writer->writeElement('{DAV:}href', $writer->contextUri.$lock->uri); $writer->endElement(); // {DAV:}lockroot } - $writer->writeElement('{DAV:}depth', ($lock->depth == DAV\Server::DEPTH_INFINITY ? 'infinity' : $lock->depth)); - $writer->writeElement('{DAV:}timeout', 'Second-' . $lock->timeout); - - $writer->startElement('{DAV:}locktoken'); - $writer->writeElement('{DAV:}href', 'opaquelocktoken:' . $lock->token); - $writer->endElement(); // {DAV:}locktoken + $writer->writeElement('{DAV:}depth', (DAV\Server::DEPTH_INFINITY == $lock->depth ? 'infinity' : $lock->depth)); + $writer->writeElement('{DAV:}timeout', (LockInfo::TIMEOUT_INFINITE === $lock->timeout ? 'Infinite' : 'Second-'.$lock->timeout)); + + // optional according to https://tools.ietf.org/html/rfc4918#section-6.5 + if (null !== $lock->token && '' !== $lock->token) { + $writer->startElement('{DAV:}locktoken'); + $writer->writeElement('{DAV:}href', 'opaquelocktoken:'.$lock->token); + $writer->endElement(); // {DAV:}locktoken + } - $writer->writeElement('{DAV:}owner', new XmlFragment($lock->owner)); + if ($lock->owner) { + $writer->writeElement('{DAV:}owner', new XmlFragment($lock->owner)); + } $writer->endElement(); // {DAV:}activelock - } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php b/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php index ce640ff32..ce07d4382 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -8,7 +10,7 @@ use Sabre\Xml\Element; use Sabre\Xml\Reader; /** - * {DAV:}resourcetype property + * {DAV:}resourcetype property. * * This class represents the {DAV:}resourcetype property, as defined in: * @@ -18,10 +20,10 @@ use Sabre\Xml\Reader; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ResourceType extends Element\Elements implements HtmlOutput { - +class ResourceType extends Element\Elements implements HtmlOutput +{ /** - * Constructor + * Constructor. * * You can either pass null (for no resourcetype), a string (for a single * resourcetype) or an array (for multiple). @@ -30,48 +32,44 @@ class ResourceType extends Element\Elements implements HtmlOutput { * * @param array|string|null $resourceTypes */ - function __construct($resourceTypes = null) { - - parent::__construct((array)$resourceTypes); - + public function __construct($resourceTypes = null) + { + parent::__construct((array) $resourceTypes); } /** - * Returns the values in clark-notation + * Returns the values in clark-notation. * * For example array('{DAV:}collection') * * @return array */ - function getValue() { - + public function getValue() + { return $this->value; - } /** - * Checks if the principal contains a certain value + * Checks if the principal contains a certain value. * * @param string $type + * * @return bool */ - function is($type) { - + public function is($type) + { return in_array($type, $this->value); - } /** - * Adds a resourcetype value to this property + * Adds a resourcetype value to this property. * * @param string $type - * @return void */ - function add($type) { - + public function add($type) + { $this->value[] = $type; $this->value = array_unique($this->value); - } /** @@ -93,13 +91,13 @@ class ResourceType extends Element\Elements implements HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { return new self(parent::xmlDeserialize($reader)); - } /** @@ -114,15 +112,14 @@ class ResourceType extends Element\Elements implements 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/DAV/Xml/Property/ShareAccess.php b/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php index 939062f76..95175053a 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Exception\BadRequest; @@ -22,10 +24,10 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ShareAccess implements Element { - +class ShareAccess implements Element +{ /** - * Either SHARED or SHAREDOWNER + * Either SHARED or SHAREDOWNER. * * @var int */ @@ -39,10 +41,9 @@ class ShareAccess implements Element { * * @param int $shareAccess */ - function __construct($shareAccess) { - + public function __construct($shareAccess) + { $this->value = $shareAccess; - } /** @@ -50,10 +51,9 @@ class ShareAccess implements Element { * * @return int */ - function getValue() { - + public function getValue() + { return $this->value; - } /** @@ -73,30 +73,26 @@ class ShareAccess implements Element { * 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->value) { - - case SharingPlugin::ACCESS_NOTSHARED : + case SharingPlugin::ACCESS_NOTSHARED: $writer->writeElement('{DAV:}not-shared'); break; - case SharingPlugin::ACCESS_SHAREDOWNER : + case SharingPlugin::ACCESS_SHAREDOWNER: $writer->writeElement('{DAV:}shared-owner'); break; - case SharingPlugin::ACCESS_READ : + case SharingPlugin::ACCESS_READ: $writer->writeElement('{DAV:}read'); break; - case SharingPlugin::ACCESS_READWRITE : + case SharingPlugin::ACCESS_READWRITE: $writer->writeElement('{DAV:}read-write'); break; - case SharingPlugin::ACCESS_NOACCESS : + case SharingPlugin::ACCESS_NOACCESS: $writer->writeElement('{DAV:}no-access'); break; - } - } /** @@ -118,26 +114,26 @@ class ShareAccess implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree(); foreach ($elems as $elem) { switch ($elem['name']) { - case '{DAV:}not-shared' : + case '{DAV:}not-shared': return new self(SharingPlugin::ACCESS_NOTSHARED); - case '{DAV:}shared-owner' : + case '{DAV:}shared-owner': return new self(SharingPlugin::ACCESS_SHAREDOWNER); - case '{DAV:}read' : + case '{DAV:}read': return new self(SharingPlugin::ACCESS_READ); - case '{DAV:}read-write' : + case '{DAV:}read-write': return new self(SharingPlugin::ACCESS_READWRITE); - case '{DAV:}no-access' : + case '{DAV:}no-access': return new self(SharingPlugin::ACCESS_NOACCESS); } } throw new BadRequest('Invalid value for {DAV:}share-access element'); - } } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php index 677fdde4b..26e7d646e 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\Xml\Writer; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedLock implements XmlSerializable { - +class SupportedLock implements XmlSerializable +{ /** * The xmlSerialize method is called during xml writing. * @@ -37,18 +39,16 @@ class SupportedLock 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:}lockentry', [ '{DAV:}lockscope' => ['{DAV:}exclusive' => null], - '{DAV:}locktype' => ['{DAV:}write' => null], + '{DAV:}locktype' => ['{DAV:}write' => null], ]); $writer->writeElement('{DAV:}lockentry', [ '{DAV:}lockscope' => ['{DAV:}shared' => null], - '{DAV:}locktype' => ['{DAV:}write' => null], + '{DAV:}locktype' => ['{DAV:}write' => null], ]); - } } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php index 1a3878ef7..06ab28c94 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -20,24 +22,23 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedMethodSet implements XmlSerializable, HtmlOutput { - +class SupportedMethodSet implements XmlSerializable, HtmlOutput +{ /** - * List of methods + * List of methods. * * @var string[] */ protected $methods = []; /** - * Creates the property + * Creates the property. * * @param string[] $methods */ - function __construct(array $methods) { - + public function __construct(array $methods) + { $this->methods = $methods; - } /** @@ -45,25 +46,24 @@ class SupportedMethodSet implements XmlSerializable, HtmlOutput { * * @return string[] */ - function getValue() { - + public function getValue() + { return $this->methods; - } /** * Returns true or false if the property contains a specific method. * * @param string $methodName + * * @return bool */ - function has($methodName) { - + public function has($methodName) + { return in_array( $methodName, $this->methods ); - } /** @@ -83,16 +83,14 @@ class SupportedMethodSet 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) + { foreach ($this->getValue() as $val) { $writer->startElement('{DAV:}supported-method'); $writer->writeAttribute('name', $val); $writer->endElement(); } - } /** @@ -107,15 +105,14 @@ class SupportedMethodSet implements XmlSerializable, 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, 'h'], $this->getValue()) ); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php index 96383ec96..4c25d23d9 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV; @@ -21,17 +23,17 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedReportSet implements XmlSerializable, HtmlOutput { - +class SupportedReportSet implements XmlSerializable, HtmlOutput +{ /** - * List of reports + * List of reports. * * @var array */ protected $reports = []; /** - * Creates the property + * Creates the property. * * Any reports passed in the constructor * should be valid report-types in clark-notation. @@ -40,61 +42,56 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { * * @param string|string[] $reports */ - function __construct($reports = null) { - - if (!is_null($reports)) + public function __construct($reports = null) + { + if (!is_null($reports)) { $this->addReport($reports); - + } } /** - * Adds a report to this property + * Adds a report to this property. * * The report must be a string in clark-notation. * Multiple reports can be specified as an array. * * @param mixed $report - * @return void */ - function addReport($report) { - - $report = (array)$report; + public function addReport($report) + { + $report = (array) $report; foreach ($report as $r) { - - if (!preg_match('/^{([^}]*)}(.*)$/', $r)) + if (!preg_match('/^{([^}]*)}(.*)$/', $r)) { throw new DAV\Exception('Reportname must be in clark-notation'); - + } $this->reports[] = $r; - } - } /** - * Returns the list of supported reports + * Returns the list of supported reports. * * @return string[] */ - function getValue() { - + public function getValue() + { return $this->reports; - } /** * Returns true or false if the property contains a specific report. * * @param string $reportName + * * @return bool */ - function has($reportName) { - + public function has($reportName) + { return in_array( $reportName, $this->reports ); - } /** @@ -114,10 +111,9 @@ class SupportedReportSet 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) + { foreach ($this->getValue() as $val) { $writer->startElement('{DAV:}supported-report'); $writer->startElement('{DAV:}report'); @@ -125,7 +121,6 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { $writer->endElement(); $writer->endElement(); } - } /** @@ -140,15 +135,14 @@ class SupportedReportSet implements XmlSerializable, 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/DAV/Xml/Request/Lock.php b/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php index c315a9a45..8d9348162 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\DAV\Locks\LockInfo; @@ -18,10 +20,10 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Lock implements XmlDeserializable { - +class Lock implements XmlDeserializable +{ /** - * Owner of the lock + * Owner of the lock. * * @var string */ @@ -31,6 +33,7 @@ class Lock implements XmlDeserializable { * Scope of the lock. * * Either LockInfo::SHARED or LockInfo::EXCLUSIVE + * * @var int */ public $scope; @@ -54,10 +57,11 @@ class Lock implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $reader->pushContext(); $reader->elementMap['{DAV:}owner'] = 'Sabre\\Xml\\Element\\XmlFragment'; @@ -71,11 +75,12 @@ class Lock implements XmlDeserializable { if (isset($values['{DAV:}lockscope'])) { foreach ($values['{DAV:}lockscope'] as $elem) { - if ($elem['name'] === '{DAV:}exclusive') $new->scope = LockInfo::EXCLUSIVE; + if ('{DAV:}exclusive' === $elem['name']) { + $new->scope = LockInfo::EXCLUSIVE; + } } } - return $new; + return $new; } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php b/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php index 9490bf58c..7713646ea 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\Xml\Reader; @@ -16,8 +18,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MkCol implements XmlDeserializable { - +class MkCol implements XmlDeserializable +{ /** * The list of properties that will be set. * @@ -31,10 +33,9 @@ class MkCol implements XmlDeserializable { * * @return array */ - function getProperties() { - + public function getProperties() + { return $this->properties; - } /** @@ -56,10 +57,11 @@ class MkCol implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $elementMap = $reader->elementMap; @@ -70,13 +72,11 @@ class MkCol implements XmlDeserializable { $elems = $reader->parseInnerTree($elementMap); foreach ($elems as $elem) { - if ($elem['name'] === '{DAV:}set') { + if ('{DAV:}set' === $elem['name']) { $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); } } return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php b/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php index f1b5b6fdc..b4cce423e 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\Xml\Element\KeyValue; @@ -17,8 +19,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class PropFind implements XmlDeserializable { - +class PropFind implements XmlDeserializable +{ /** * If this is set to true, this was an 'allprop' request. * @@ -27,9 +29,9 @@ class PropFind implements XmlDeserializable { public $allProp = false; /** - * The property list + * The property list. * - * @var null|array + * @var array|null */ public $properties; @@ -52,32 +54,28 @@ class PropFind implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $reader->pushContext(); $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements'; foreach (KeyValue::xmlDeserialize($reader) as $k => $v) { - switch ($k) { - case '{DAV:}prop' : + case '{DAV:}prop': $self->properties = $v; break; - case '{DAV:}allprop' : + case '{DAV:}allprop': $self->allProp = true; - } - } $reader->popContext(); return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php b/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php index 821b9e047..55e154ec7 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\Xml\Element; @@ -17,8 +19,8 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class PropPatch implements Element { - +class PropPatch implements Element +{ /** * The list of properties that will be updated and removed. * @@ -45,24 +47,20 @@ class PropPatch implements Element { * 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->properties as $propertyName => $propertyValue) { - if (is_null($propertyValue)) { - $writer->startElement("{DAV:}remove"); + $writer->startElement('{DAV:}remove'); $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); $writer->endElement(); } else { - $writer->startElement("{DAV:}set"); + $writer->startElement('{DAV:}set'); $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); $writer->endElement(); } - } - } /** @@ -84,10 +82,11 @@ class PropPatch implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $elementMap = $reader->elementMap; @@ -98,21 +97,17 @@ class PropPatch implements Element { $elems = $reader->parseInnerTree($elementMap); foreach ($elems as $elem) { - if ($elem['name'] === '{DAV:}set') { + if ('{DAV:}set' === $elem['name']) { $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); } - if ($elem['name'] === '{DAV:}remove') { - + if ('{DAV:}remove' === $elem['name']) { // Ensuring there are no values. foreach ($elem['value']['{DAV:}prop'] as $remove => $value) { $self->properties[$remove] = null; } - } } return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php b/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php index 526a4eb6f..e1985b8c3 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\DAV\Xml\Element\Sharee; @@ -17,8 +19,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class ShareResource implements XmlDeserializable { - +class ShareResource implements XmlDeserializable +{ /** * The list of new people added or updated or removed from the share. * @@ -27,14 +29,13 @@ class ShareResource implements XmlDeserializable { public $sharees = []; /** - * Constructor + * Constructor. * * @param Sharee[] $sharees */ - function __construct(array $sharees) { - + public function __construct(array $sharees) + { $this->sharees = $sharees; - } /** @@ -56,26 +57,26 @@ class ShareResource implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree([ - '{DAV:}sharee' => 'Sabre\DAV\Xml\Element\Sharee', + '{DAV:}sharee' => 'Sabre\DAV\Xml\Element\Sharee', '{DAV:}share-access' => 'Sabre\DAV\Xml\Property\ShareAccess', - '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue', + '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue', ]); $sharees = []; foreach ($elems as $elem) { - if ($elem['name'] !== '{DAV:}sharee') continue; + if ('{DAV:}sharee' !== $elem['name']) { + continue; + } $sharees[] = $elem['value']; - } return new self($sharees); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php b/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php index 830293a01..acf0039ce 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Request; use Sabre\DAV\Exception\BadRequest; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SyncCollectionReport implements XmlDeserializable { - +class SyncCollectionReport implements XmlDeserializable +{ /** * The sync-token the client supplied for the report. * @@ -44,7 +46,7 @@ class SyncCollectionReport implements XmlDeserializable { /** * The list of properties that are being requested for every change. * - * @var null|array + * @var array|null */ public $properties; @@ -67,10 +69,11 @@ class SyncCollectionReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $reader->pushContext(); @@ -87,36 +90,31 @@ class SyncCollectionReport implements XmlDeserializable { foreach ($required as $elem) { if (!array_key_exists($elem, $elems)) { - throw new BadRequest('The ' . $elem . ' element in the {DAV:}sync-collection report is required'); + throw new BadRequest('The '.$elem.' element in the {DAV:}sync-collection report is required'); } } - $self->properties = $elems['{DAV:}prop']; $self->syncToken = $elems['{DAV:}sync-token']; if (isset($elems['{DAV:}limit'])) { $nresults = null; foreach ($elems['{DAV:}limit'] as $child) { - if ($child['name'] === '{DAV:}nresults') { - $nresults = (int)$child['value']; + if ('{DAV:}nresults' === $child['name']) { + $nresults = (int) $child['value']; } } $self->limit = $nresults; } if (isset($elems['{DAV:}sync-level'])) { - $value = $elems['{DAV:}sync-level']; - if ($value === 'infinity') { + if ('infinity' === $value) { $value = \Sabre\DAV\Server::DEPTH_INFINITY; } $self->syncLevel = $value; - } return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Response/MultiStatus.php b/vendor/sabre/dav/lib/DAV/Xml/Response/MultiStatus.php index cf5a0453b..423d0b569 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Response/MultiStatus.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Response/MultiStatus.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Response; use Sabre\Xml\Element; @@ -7,7 +9,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * WebDAV MultiStatus parser + * WebDAV MultiStatus parser. * * This class parses the {DAV:}multistatus response, as defined in: * https://tools.ietf.org/html/rfc4918#section-14.16 @@ -19,10 +21,10 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MultiStatus implements Element { - +class MultiStatus implements Element +{ /** - * The responses + * The responses. * * @var \Sabre\DAV\Xml\Element\Response[] */ @@ -36,16 +38,15 @@ class MultiStatus implements Element { protected $syncToken; /** - * Constructor + * Constructor. * * @param \Sabre\DAV\Xml\Element\Response[] $responses - * @param string $syncToken + * @param string $syncToken */ - function __construct(array $responses, $syncToken = null) { - + public function __construct(array $responses, $syncToken = null) + { $this->responses = $responses; $this->syncToken = $syncToken; - } /** @@ -53,10 +54,9 @@ class MultiStatus implements Element { * * @return \Sabre\DAV\Xml\Element\Response[] */ - function getResponses() { - + public function getResponses() + { return $this->responses; - } /** @@ -64,10 +64,9 @@ class MultiStatus implements Element { * * @return string|null */ - function getSyncToken() { - + public function getSyncToken() + { return $this->syncToken; - } /** @@ -83,17 +82,15 @@ class MultiStatus implements Element { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->getResponses() as $response) { $writer->writeElement('{DAV:}response', $response); } if ($syncToken = $this->getSyncToken()) { $writer->writeElement('{DAV:}sync-token', $syncToken); } - } /** @@ -115,10 +112,11 @@ class MultiStatus implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elementMap = $reader->elementMap; $elementMap['{DAV:}prop'] = 'Sabre\\DAV\\Xml\\Element\\Prop'; $elements = $reader->parseInnerTree($elementMap); @@ -126,17 +124,17 @@ class MultiStatus implements Element { $responses = []; $syncToken = null; - if ($elements) foreach ($elements as $elem) { - if ($elem['name'] === '{DAV:}response') { - $responses[] = $elem['value']; - } - if ($elem['name'] === '{DAV:}sync-token') { - $syncToken = $elem['value']; + if ($elements) { + foreach ($elements as $elem) { + if ('{DAV:}response' === $elem['name']) { + $responses[] = $elem['value']; + } + if ('{DAV:}sync-token' === $elem['name']) { + $syncToken = $elem['value']; + } } } return new self($responses, $syncToken); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Service.php b/vendor/sabre/dav/lib/DAV/Xml/Service.php index f41ed984a..4406b022d 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Service.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Service.php @@ -1,16 +1,18 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml; /** - * XML service for WebDAV + * XML service for WebDAV. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Service extends \Sabre\Xml\Service { - +class Service extends \Sabre\Xml\Service +{ /** * This is a list of XML elements that we automatically map to PHP classes. * @@ -19,16 +21,15 @@ class Service extends \Sabre\Xml\Service { */ public $elementMap = [ '{DAV:}multistatus' => 'Sabre\\DAV\\Xml\\Response\\MultiStatus', - '{DAV:}response' => 'Sabre\\DAV\\Xml\\Element\\Response', + '{DAV:}response' => 'Sabre\\DAV\\Xml\\Element\\Response', // Requests - '{DAV:}propfind' => 'Sabre\\DAV\\Xml\\Request\\PropFind', + '{DAV:}propfind' => 'Sabre\\DAV\\Xml\\Request\\PropFind', '{DAV:}propertyupdate' => 'Sabre\\DAV\\Xml\\Request\\PropPatch', - '{DAV:}mkcol' => 'Sabre\\DAV\\Xml\\Request\\MkCol', + '{DAV:}mkcol' => 'Sabre\\DAV\\Xml\\Request\\MkCol', // Properties '{DAV:}resourcetype' => 'Sabre\\DAV\\Xml\\Property\\ResourceType', - ]; /** @@ -40,8 +41,7 @@ class Service extends \Sabre\Xml\Service { * @var array */ public $namespaceMap = [ - 'DAV:' => 'd', + 'DAV:' => 'd', 'http://sabredav.org/ns' => 's', ]; - } diff --git a/vendor/sabre/dav/lib/DAVACL/ACLTrait.php b/vendor/sabre/dav/lib/DAVACL/ACLTrait.php index 602654a2e..d9bf4e1e0 100644 --- a/vendor/sabre/dav/lib/DAVACL/ACLTrait.php +++ b/vendor/sabre/dav/lib/DAVACL/ACLTrait.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; /** @@ -14,32 +16,30 @@ namespace Sabre\DAVACL; * @author Evert Pot (https://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -trait ACLTrait { - +trait ACLTrait +{ /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return null; - } /** - * Returns a group principal + * Returns a group principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getGroup() { - + public function getGroup() + { return null; - } /** @@ -54,28 +54,26 @@ trait ACLTrait { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ 'privilege' => '{DAV:}all', 'principal' => '{DAV:}owner', 'protected' => true, - ] + ], ]; - } /** - * Updates the ACL + * Updates the ACL. * * This method will receive a list of new ACE's as an array argument. * * @param array $acl - * @return void */ - function setACL(array $acl) { - + public function setACL(array $acl) + { throw new \Sabre\DAV\Exception\Forbidden('Setting ACL is not supported on this node'); } @@ -91,10 +89,8 @@ trait ACLTrait { * * @return array|null */ - function getSupportedPrivilegeSet() { - + public function getSupportedPrivilegeSet() + { return null; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php b/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php index 9d2026380..1160dd7ac 100644 --- a/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * Principals Collection + * Principals Collection. * * This is a helper class that easily allows you to create a collection that * has a childnode for every principal. @@ -17,10 +19,10 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractPrincipalCollection extends DAV\Collection implements IPrincipalCollection { - +abstract class AbstractPrincipalCollection extends DAV\Collection implements IPrincipalCollection +{ /** - * Principal backend + * Principal backend. * * @var PrincipalBackend\BackendInterface */ @@ -42,7 +44,7 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr public $disableListing = false; /** - * Creates the object + * Creates the object. * * This object must be passed the principal backend. This object will * filter all principals from a specified prefix ($principalPrefix). The @@ -51,13 +53,12 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * * * @param PrincipalBackend\BackendInterface $principalBackend - * @param string $principalPrefix + * @param string $principalPrefix */ - function __construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix = 'principals') { - + public function __construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix = 'principals') + { $this->principalPrefix = $principalPrefix; $this->principalBackend = $principalBackend; - } /** @@ -68,56 +69,58 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * supplied by the authentication backend. * * @param array $principalInfo - * @return IPrincipal + * + * @return DAV\INode */ - abstract function getChildForPrincipal(array $principalInfo); + abstract public function getChildForPrincipal(array $principalInfo); /** * Returns the name of this collection. * * @return string */ - function getName() { + public function getName() + { + list(, $name) = Uri\split($this->principalPrefix); - list(, $name) = URLUtil::splitPath($this->principalPrefix); return $name; - } /** - * Return the list of users + * Return the list of users. * * @return array */ - function getChildren() { - - if ($this->disableListing) + public function getChildren() + { + if ($this->disableListing) { throw new DAV\Exception\MethodNotAllowed('Listing members of this collection is disabled'); - + } $children = []; foreach ($this->principalBackend->getPrincipalsByPrefix($this->principalPrefix) as $principalInfo) { - $children[] = $this->getChildForPrincipal($principalInfo); - - } - return $children; + return $children; } /** * Returns a child object, by its name. * * @param string $name + * * @throws DAV\Exception\NotFound + * * @return DAV\INode */ - function getChild($name) { + public function getChild($name) + { + $principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix.'/'.$name); + if (!$principalInfo) { + throw new DAV\Exception\NotFound('Principal with name '.$name.' not found'); + } - $principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix . '/' . $name); - if (!$principalInfo) throw new DAV\Exception\NotFound('Principal with name ' . $name . ' not found'); return $this->getChildForPrincipal($principalInfo); - } /** @@ -139,21 +142,21 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * This method should simply return a list of 'child names', which may be * used to call $this->getChild in the future. * - * @param array $searchProperties + * @param array $searchProperties * @param string $test + * * @return array */ - function searchPrincipals(array $searchProperties, $test = 'allof') { - + public function searchPrincipals(array $searchProperties, $test = 'allof') + { $result = $this->principalBackend->searchPrincipals($this->principalPrefix, $searchProperties, $test); $r = []; foreach ($result as $row) { - list(, $r[]) = URLUtil::splitPath($row); + list(, $r[]) = Uri\split($row); } return $r; - } /** @@ -170,12 +173,11 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * principal was not found or you refuse to find it. * * @param string $uri + * * @return string */ - function findByUri($uri) { - + public function findByUri($uri) + { return $this->principalBackend->findByUri($uri, $this->principalPrefix); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php b/vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php index 22450b4a6..7756d4728 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; @@ -12,24 +14,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AceConflict extends DAV\Exception\Conflict { - +class AceConflict extends DAV\Exception\Conflict +{ /** * Adds in extra information in the xml response. * * This method adds the {DAV:}no-ace-conflict element as defined in rfc3744 * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:no-ace-conflict'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php b/vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php index 5624fd22f..19e0dac9d 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; /** - * NeedPrivileges + * NeedPrivileges. * * The 403-need privileges is thrown when a user didn't have the appropriate * permissions to perform an operation @@ -14,10 +16,10 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NeedPrivileges extends DAV\Exception\Forbidden { - +class NeedPrivileges extends DAV\Exception\Forbidden +{ /** - * The relevant uri + * The relevant uri. * * @var string */ @@ -31,18 +33,17 @@ class NeedPrivileges extends DAV\Exception\Forbidden { protected $privileges; /** - * Constructor + * Constructor. * * @param string $uri - * @param array $privileges + * @param array $privileges */ - function __construct($uri, array $privileges) { - + public function __construct($uri, array $privileges) + { $this->uri = $uri; $this->privileges = $privileges; - parent::__construct('User did not have the required privileges (' . implode(',', $privileges) . ') for path "' . $uri . '"'); - + parent::__construct('User did not have the required privileges ('.implode(',', $privileges).') for path "'.$uri.'"'); } /** @@ -50,33 +51,27 @@ class NeedPrivileges extends DAV\Exception\Forbidden { * * This method adds the {DAV:}need-privileges element as defined in rfc3744 * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:need-privileges'); $errorNode->appendChild($np); foreach ($this->privileges as $privilege) { - $resource = $doc->createElementNS('DAV:', 'd:resource'); $np->appendChild($resource); - $resource->appendChild($doc->createElementNS('DAV:', 'd:href', $server->getBaseUri() . $this->uri)); + $resource->appendChild($doc->createElementNS('DAV:', 'd:href', $server->getBaseUri().$this->uri)); $priv = $doc->createElementNS('DAV:', 'd:privilege'); $resource->appendChild($priv); preg_match('/^{([^}]*)}(.*)$/', $privilege, $privilegeParts); - $priv->appendChild($doc->createElementNS($privilegeParts[1], 'd:' . $privilegeParts[2])); - - + $priv->appendChild($doc->createElementNS($privilegeParts[1], 'd:'.$privilegeParts[2])); } - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php b/vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php index a2363b174..d90b01ffd 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; @@ -12,24 +14,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NoAbstract extends DAV\Exception\PreconditionFailed { - +class NoAbstract extends DAV\Exception\PreconditionFailed +{ /** * Adds in extra information in the xml response. * * This method adds the {DAV:}no-abstract element as defined in rfc3744 * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:no-abstract'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php b/vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php index d7ae188ae..b005c55d8 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; @@ -12,24 +14,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotRecognizedPrincipal extends DAV\Exception\PreconditionFailed { - +class NotRecognizedPrincipal extends DAV\Exception\PreconditionFailed +{ /** * Adds in extra information in the xml response. * * This method adds the {DAV:}recognized-principal element as defined in rfc3744 * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:recognized-principal'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php b/vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php index 73b81190d..dda2e6281 100644 --- a/vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php +++ b/vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; @@ -12,24 +14,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class NotSupportedPrivilege extends DAV\Exception\PreconditionFailed { - +class NotSupportedPrivilege extends DAV\Exception\PreconditionFailed +{ /** * Adds in extra information in the xml response. * * This method adds the {DAV:}not-supported-privilege element as defined in rfc3744 * - * @param DAV\Server $server + * @param DAV\Server $server * @param \DOMElement $errorNode - * @return void */ - function serialize(DAV\Server $server, \DOMElement $errorNode) { - + public function serialize(DAV\Server $server, \DOMElement $errorNode) + { $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:', 'd:not-supported-privilege'); $errorNode->appendChild($np); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/FS/Collection.php b/vendor/sabre/dav/lib/DAVACL/FS/Collection.php index b4fe7a1b0..85b04e2bd 100644 --- a/vendor/sabre/dav/lib/DAVACL/FS/Collection.php +++ b/vendor/sabre/dav/lib/DAVACL/FS/Collection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\FS; use Sabre\DAV\Exception\Forbidden; @@ -15,8 +17,8 @@ use Sabre\DAVACL\IACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Collection extends BaseCollection implements IACL { - +class Collection extends BaseCollection implements IACL +{ use ACLTrait; /** @@ -34,60 +36,58 @@ class Collection extends BaseCollection implements IACL { protected $owner; /** - * Constructor + * Constructor. * - * @param string $path on-disk path. - * @param array $acl ACL rules. - * @param string|null $owner principal owner string. + * @param string $path on-disk path + * @param array $acl ACL rules + * @param string|null $owner principal owner string */ - function __construct($path, array $acl, $owner = null) { - + public function __construct($path, array $acl, $owner = null) + { parent::__construct($path); $this->acl = $acl; $this->owner = $owner; - } /** - * Returns a specific child node, referenced by its name + * Returns a specific child node, referenced by its name. * * This method must throw Sabre\DAV\Exception\NotFound if the node does not * exist. * * @param string $name + * * @throws NotFound + * * @return \Sabre\DAV\INode */ - function getChild($name) { - - $path = $this->path . '/' . $name; - - if (!file_exists($path)) throw new NotFound('File could not be located'); - if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..'); + public function getChild($name) + { + $path = $this->path.'/'.$name; + if (!file_exists($path)) { + throw new NotFound('File could not be located'); + } + if ('.' == $name || '..' == $name) { + throw new Forbidden('Permission denied to . and ..'); + } if (is_dir($path)) { - return new self($path, $this->acl, $this->owner); - } else { - return new File($path, $this->acl, $this->owner); - } - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->owner; - } /** @@ -102,10 +102,8 @@ class Collection extends BaseCollection implements IACL { * * @return array */ - function getACL() { - + public function getACL() + { return $this->acl; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/FS/File.php b/vendor/sabre/dav/lib/DAVACL/FS/File.php index aaf2ae148..5506aa2c1 100644 --- a/vendor/sabre/dav/lib/DAVACL/FS/File.php +++ b/vendor/sabre/dav/lib/DAVACL/FS/File.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\FS; use Sabre\DAV\FSExt\File as BaseFile; @@ -13,8 +15,8 @@ use Sabre\DAVACL\IACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends BaseFile implements IACL { - +class File extends BaseFile implements IACL +{ use ACLTrait; /** @@ -32,31 +34,29 @@ class File extends BaseFile implements IACL { protected $owner; /** - * Constructor + * Constructor. * - * @param string $path on-disk path. - * @param array $acl ACL rules. - * @param string|null $owner principal owner string. + * @param string $path on-disk path + * @param array $acl ACL rules + * @param string|null $owner principal owner string */ - function __construct($path, array $acl, $owner = null) { - + public function __construct($path, array $acl, $owner = null) + { parent::__construct($path); $this->acl = $acl; $this->owner = $owner; - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->owner; - } /** @@ -71,10 +71,8 @@ class File extends BaseFile implements IACL { * * @return array */ - function getACL() { - + public function getACL() + { return $this->acl; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php b/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php index 201235e5a..c896d8e25 100644 --- a/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\FS; use Sabre\DAVACL\AbstractPrincipalCollection; @@ -19,8 +21,8 @@ use Sabre\Uri; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class HomeCollection extends AbstractPrincipalCollection implements IACL { - +class HomeCollection extends AbstractPrincipalCollection implements IACL +{ use ACLTrait; /** @@ -41,14 +43,13 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * Creates the home collection. * * @param BackendInterface $principalBackend - * @param string $storagePath Where the actual files are stored. - * @param string $principalPrefix list of principals to iterate. + * @param string $storagePath where the actual files are stored + * @param string $principalPrefix list of principals to iterate */ - function __construct(BackendInterface $principalBackend, $storagePath, $principalPrefix = 'principals') { - + public function __construct(BackendInterface $principalBackend, $storagePath, $principalPrefix = 'principals') + { parent::__construct($principalBackend, $principalPrefix); $this->storagePath = $storagePath; - } /** @@ -58,10 +59,9 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * * @return string */ - function getName() { - + public function getName() + { return $this->collectionName; - } /** @@ -72,10 +72,11 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * supplied by the authentication backend. * * @param array $principalInfo + * * @return \Sabre\DAV\INode */ - function getChildForPrincipal(array $principalInfo) { - + public function getChildForPrincipal(array $principalInfo) + { $owner = $principalInfo['uri']; $acl = [ [ @@ -87,20 +88,19 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { list(, $principalBaseName) = Uri\split($owner); - $path = $this->storagePath . '/' . $principalBaseName; + $path = $this->storagePath.'/'.$principalBaseName; if (!is_dir($path)) { mkdir($path, 0777, true); } + return new Collection( $path, $acl, $owner ); - } - /** * Returns a list of ACE's for this node. * @@ -113,16 +113,14 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * * @return array */ - function getACL() { - + public function getACL() + { return [ [ 'principal' => '{DAV:}authenticated', 'privilege' => '{DAV:}read', 'protected' => true, - ] + ], ]; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/IACL.php b/vendor/sabre/dav/lib/DAVACL/IACL.php index f7a138665..d19a075be 100644 --- a/vendor/sabre/dav/lib/DAVACL/IACL.php +++ b/vendor/sabre/dav/lib/DAVACL/IACL.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; /** - * ACL-enabled node + * ACL-enabled node. * * If you want to add WebDAV ACL to a node, you must implement this class * @@ -13,25 +15,25 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IACL extends DAV\INode { - +interface IACL extends DAV\INode +{ /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner(); + public function getOwner(); /** - * Returns a group principal + * Returns a group principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getGroup(); + public function getGroup(); /** * Returns a list of ACE's for this node. @@ -45,17 +47,16 @@ interface IACL extends DAV\INode { * * @return array */ - function getACL(); + public function getACL(); /** - * Updates the ACL + * Updates the ACL. * * This method will receive a list of new ACE's as an array argument. * * @param array $acl - * @return void */ - function setACL(array $acl); + public function setACL(array $acl); /** * Returns the list of supported privileges for this node. @@ -69,6 +70,5 @@ interface IACL extends DAV\INode { * * @return array|null */ - function getSupportedPrivilegeSet(); - + public function getSupportedPrivilegeSet(); } diff --git a/vendor/sabre/dav/lib/DAVACL/IPrincipal.php b/vendor/sabre/dav/lib/DAVACL/IPrincipal.php index 13728471e..c804096de 100644 --- a/vendor/sabre/dav/lib/DAVACL/IPrincipal.php +++ b/vendor/sabre/dav/lib/DAVACL/IPrincipal.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; /** - * IPrincipal interface + * IPrincipal interface. * * Implement this interface to define your own principals * @@ -13,46 +15,46 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IPrincipal extends DAV\INode { - +interface IPrincipal extends DAV\INode +{ /** - * Returns a list of alternative urls for a principal + * Returns a list of alternative urls for a principal. * * This can for example be an email address, or ldap url. * * @return array */ - function getAlternateUriSet(); + public function getAlternateUriSet(); /** - * Returns the full principal url + * Returns the full principal url. * * @return string */ - function getPrincipalUrl(); + public function getPrincipalUrl(); /** - * Returns the list of group members + * Returns the list of group members. * * If this principal is a group, this function should return * all member principal uri's for the group. * * @return array */ - function getGroupMemberSet(); + public function getGroupMemberSet(); /** - * Returns the list of groups this principal is member of + * Returns the list of groups this principal is member of. * * If this principal is a member of a (list of) groups, this function * should return a list of principal uri's for it's members. * * @return array */ - function getGroupMembership(); + public function getGroupMembership(); /** - * Sets a list of group members + * Sets a list of group members. * * If this principal is a group, this method sets all the group members. * The list of members is always overwritten, never appended to. @@ -60,18 +62,16 @@ interface IPrincipal extends DAV\INode { * This method should throw an exception if the members could not be set. * * @param array $principals - * @return void */ - function setGroupMemberSet(array $principals); + public function setGroupMemberSet(array $principals); /** - * Returns the displayname + * Returns the displayname. * * This should be a human readable name for the principal. * If none is available, return the nodename. * * @return string */ - function getDisplayName(); - + public function getDisplayName(); } diff --git a/vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php b/vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php index 3ab8382fa..1003730d6 100644 --- a/vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -14,8 +16,8 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface IPrincipalCollection extends DAV\ICollection { - +interface IPrincipalCollection extends DAV\ICollection +{ /** * This method is used to search for principals matching a set of * properties. @@ -35,11 +37,12 @@ interface IPrincipalCollection extends DAV\ICollection { * This method should simply return a list of 'child names', which may be * used to call $this->getChild in the future. * - * @param array $searchProperties + * @param array $searchProperties * @param string $test + * * @return array */ - function searchPrincipals(array $searchProperties, $test = 'allof'); + public function searchPrincipals(array $searchProperties, $test = 'allof'); /** * Finds a principal by its URI. @@ -55,8 +58,8 @@ interface IPrincipalCollection extends DAV\ICollection { * principal was not found or you refuse to find it. * * @param string $uri + * * @return string */ - function findByUri($uri); - + public function findByUri($uri); } diff --git a/vendor/sabre/dav/lib/DAVACL/Plugin.php b/vendor/sabre/dav/lib/DAVACL/Plugin.php index a2aa118d7..c1ea6027c 100644 --- a/vendor/sabre/dav/lib/DAVACL/Plugin.php +++ b/vendor/sabre/dav/lib/DAVACL/Plugin.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -15,7 +17,7 @@ use Sabre\HTTP\ResponseInterface; use Sabre\Uri; /** - * SabreDAV ACL Plugin + * SabreDAV ACL Plugin. * * This plugin provides functionality to enforce ACL permissions. * ACL is defined in RFC3744. @@ -28,24 +30,24 @@ use Sabre\Uri; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin { - +class Plugin extends DAV\ServerPlugin +{ /** - * Recursion constants + * Recursion constants. * * This only checks the base node */ const R_PARENT = 1; /** - * Recursion constants + * Recursion constants. * * This checks every node in the tree */ const R_RECURSIVE = 2; /** - * Recursion constants + * Recursion constants. * * This checks every parentnode in the tree, but not leaf-nodes. */ @@ -70,7 +72,7 @@ class Plugin extends DAV\ServerPlugin { /** * By default nodes that are inaccessible by the user, can still be seen - * in directory listings (PROPFIND on parent with Depth: 1) + * in directory listings (PROPFIND on parent with Depth: 1). * * In certain cases it's desirable to hide inaccessible nodes. Setting this * to true will cause these nodes to be hidden from directory listings. @@ -88,7 +90,7 @@ class Plugin extends DAV\ServerPlugin { * @var array */ public $principalSearchPropertySet = [ - '{DAV:}displayname' => 'Display name', + '{DAV:}displayname' => 'Display name', '{http://sabredav.org/ns}email-address' => 'Email address', ]; @@ -120,22 +122,21 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getFeatures() { - + public function getFeatures() + { return ['access-control', 'calendarserver-principal-property-search']; - } /** - * Returns a list of available methods for a given url + * Returns a list of available methods for a given url. * * @param string $uri + * * @return array */ - function getMethods($uri) { - + public function getMethods($uri) + { return ['ACL']; - } /** @@ -146,10 +147,9 @@ class Plugin extends DAV\ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'acl'; - } /** @@ -160,20 +160,19 @@ class Plugin extends DAV\ServerPlugin { * implement them * * @param string $uri + * * @return array */ - function getSupportedReportSet($uri) { - + public function getSupportedReportSet($uri) + { return [ '{DAV:}expand-property', '{DAV:}principal-match', '{DAV:}principal-property-search', '{DAV:}principal-search-property-set', ]; - } - /** * Checks if the current user has the specified privilege(s). * @@ -181,27 +180,29 @@ class Plugin extends DAV\ServerPlugin { * This method will throw an exception if the privilege is not available * and return true otherwise. * - * @param string $uri + * @param string $uri * @param array|string $privileges - * @param int $recursion - * @param bool $throwExceptions if set to false, this method won't throw exceptions. + * @param int $recursion + * @param bool $throwExceptions if set to false, this method won't throw exceptions + * * @throws NeedPrivileges * @throws NotAuthenticated + * * @return bool */ - function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, $throwExceptions = true) { - - if (!is_array($privileges)) $privileges = [$privileges]; + public function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, $throwExceptions = true) + { + if (!is_array($privileges)) { + $privileges = [$privileges]; + } $acl = $this->getCurrentUserPrivilegeSet($uri); $failed = []; foreach ($privileges as $priv) { - if (!in_array($priv, $acl)) { $failed[] = $priv; } - } if ($failed) { @@ -213,17 +214,16 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpRequest, $this->server->httpResponse ); - throw new notAuthenticated(implode(', ', $reasons) . '. Login was needed for privilege: ' . implode(', ', $failed) . ' on ' . $uri); + throw new notAuthenticated(implode(', ', $reasons).'. Login was needed for privilege: '.implode(', ', $failed).' on '.$uri); } if ($throwExceptions) { - throw new NeedPrivileges($uri, $failed); } else { return false; } } - return true; + return true; } /** @@ -234,35 +234,35 @@ class Plugin extends DAV\ServerPlugin { * * @return string|null */ - function getCurrentUserPrincipal() { - + public function getCurrentUserPrincipal() + { /** @var $authPlugin \Sabre\DAV\Auth\Plugin */ $authPlugin = $this->server->getPlugin('auth'); if (!$authPlugin) { return null; } - return $authPlugin->getCurrentPrincipal(); + return $authPlugin->getCurrentPrincipal(); } - /** * Returns a list of principals that's associated to the current * user, either directly or through group membership. * * @return array */ - function getCurrentUserPrincipals() { - + public function getCurrentUserPrincipals() + { $currentUser = $this->getCurrentUserPrincipal(); - if (is_null($currentUser)) return []; + if (is_null($currentUser)) { + return []; + } return array_merge( [$currentUser], $this->getPrincipalMembership($currentUser) ); - } /** @@ -271,12 +271,10 @@ class Plugin extends DAV\ServerPlugin { * These rules are used for all nodes that don't implement the IACL interface. * * @param array $acl - * @return void */ - function setDefaultAcl(array $acl) { - + public function setDefaultAcl(array $acl) + { $this->defaultAcl = $acl; - } /** @@ -286,10 +284,9 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getDefaultAcl() { - + public function getDefaultAcl() + { return $this->defaultAcl; - } /** @@ -317,15 +314,15 @@ class Plugin extends DAV\ServerPlugin { */ protected $principalMembershipCache = []; - /** * Returns all the principal groups the specified principal is a member of. * * @param string $mainPrincipal + * * @return array */ - function getPrincipalMembership($mainPrincipal) { - + public function getPrincipalMembership($mainPrincipal) + { // First check our cache if (isset($this->principalMembershipCache[$mainPrincipal])) { return $this->principalMembershipCache[$mainPrincipal]; @@ -335,31 +332,23 @@ class Plugin extends DAV\ServerPlugin { $principals = []; while (count($check)) { - $principal = array_shift($check); $node = $this->server->tree->getNodeForPath($principal); if ($node instanceof IPrincipal) { foreach ($node->getGroupMembership() as $groupMember) { - if (!in_array($groupMember, $principals)) { - $check[] = $groupMember; $principals[] = $groupMember; - } - } - } - } // Store the result in the cache $this->principalMembershipCache[$mainPrincipal] = $principals; return $principals; - } /** @@ -381,24 +370,27 @@ class Plugin extends DAV\ServerPlugin { * * @param string $checkPrincipal * @param string $currentPrincipal + * * @return bool */ - function principalMatchesPrincipal($checkPrincipal, $currentPrincipal = null) { - + public function principalMatchesPrincipal($checkPrincipal, $currentPrincipal = null) + { if (is_null($currentPrincipal)) { $currentPrincipal = $this->getCurrentUserPrincipal(); } if ($currentPrincipal === $checkPrincipal) { return true; } + if (is_null($currentPrincipal)) { + return false; + } + return in_array( $checkPrincipal, $this->getPrincipalMembership($currentPrincipal) ); - } - /** * Returns a tree of supported privileges for a resource. * @@ -436,10 +428,11 @@ class Plugin extends DAV\ServerPlugin { * ] * * @param string|INode $node + * * @return array */ - function getSupportedPrivilegeSet($node) { - + public function getSupportedPrivilegeSet($node) + { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } @@ -450,35 +443,34 @@ class Plugin extends DAV\ServerPlugin { } if (is_null($supportedPrivileges)) { - // Default $supportedPrivileges = [ '{DAV:}read' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [ '{DAV:}read-acl' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], '{DAV:}read-current-user-privilege-set' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], ], ], '{DAV:}write' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [ '{DAV:}write-properties' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], '{DAV:}write-content' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], '{DAV:}unlock' => [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ], ], @@ -486,21 +478,20 @@ class Plugin extends DAV\ServerPlugin { ]; if ($node instanceof DAV\ICollection) { $supportedPrivileges['{DAV:}write']['aggregates']['{DAV:}bind'] = [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ]; $supportedPrivileges['{DAV:}write']['aggregates']['{DAV:}unbind'] = [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ]; } if ($node instanceof IACL) { $supportedPrivileges['{DAV:}write']['aggregates']['{DAV:}write-acl'] = [ - 'abstract' => false, + 'abstract' => false, 'aggregates' => [], ]; } - } $this->server->emit( @@ -509,11 +500,10 @@ class Plugin extends DAV\ServerPlugin { ); return $supportedPrivileges; - } /** - * Returns the supported privilege set as a flat list + * Returns the supported privilege set as a flat list. * * This is much easier to parse. * @@ -524,54 +514,44 @@ class Plugin extends DAV\ServerPlugin { * - concrete * * @param string|INode $node + * * @return array */ - final function getFlatPrivilegeSet($node) { - + final public function getFlatPrivilegeSet($node) + { $privs = [ - 'abstract' => false, - 'aggregates' => $this->getSupportedPrivilegeSet($node) + 'abstract' => false, + 'aggregates' => $this->getSupportedPrivilegeSet($node), ]; $fpsTraverse = null; - $fpsTraverse = function($privName, $privInfo, $concrete, &$flat) use (&$fpsTraverse) { - + $fpsTraverse = function ($privName, $privInfo, $concrete, &$flat) use (&$fpsTraverse) { $myPriv = [ - 'privilege' => $privName, - 'abstract' => isset($privInfo['abstract']) && $privInfo['abstract'], + 'privilege' => $privName, + 'abstract' => isset($privInfo['abstract']) && $privInfo['abstract'], 'aggregates' => [], - 'concrete' => isset($privInfo['abstract']) && $privInfo['abstract'] ? $concrete : $privName, + 'concrete' => isset($privInfo['abstract']) && $privInfo['abstract'] ? $concrete : $privName, ]; if (isset($privInfo['aggregates'])) { - foreach ($privInfo['aggregates'] as $subPrivName => $subPrivInfo) { - $myPriv['aggregates'][] = $subPrivName; - } - } $flat[$privName] = $myPriv; if (isset($privInfo['aggregates'])) { - foreach ($privInfo['aggregates'] as $subPrivName => $subPrivInfo) { - $fpsTraverse($subPrivName, $subPrivInfo, $myPriv['concrete'], $flat); - } - } - }; $flat = []; $fpsTraverse('{DAV:}all', $privs, null, $flat); return $flat; - } /** @@ -582,10 +562,11 @@ class Plugin extends DAV\ServerPlugin { * null will be returned if the node doesn't support ACLs. * * @param string|DAV\INode $node + * * @return array */ - function getAcl($node) { - + public function getAcl($node) + { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } @@ -600,8 +581,8 @@ class Plugin extends DAV\ServerPlugin { 'protected' => true, ]; } - return $acl; + return $acl; } /** @@ -613,10 +594,11 @@ class Plugin extends DAV\ServerPlugin { * null will be returned if the node doesn't support ACLs. * * @param string|DAV\INode $node + * * @return array */ - function getCurrentUserPrivilegeSet($node) { - + public function getCurrentUserPrivilegeSet($node) + { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } @@ -625,50 +607,44 @@ class Plugin extends DAV\ServerPlugin { $collected = []; - $isAuthenticated = $this->getCurrentUserPrincipal() !== null; + $isAuthenticated = null !== $this->getCurrentUserPrincipal(); foreach ($acl as $ace) { - $principal = $ace['principal']; switch ($principal) { - - case '{DAV:}owner' : + case '{DAV:}owner': $owner = $node->getOwner(); if ($owner && $this->principalMatchesPrincipal($owner)) { $collected[] = $ace; } break; - // 'all' matches for every user - case '{DAV:}all' : + case '{DAV:}all': $collected[] = $ace; break; - case '{DAV:}authenticated' : + case '{DAV:}authenticated': // Authenticated users only if ($isAuthenticated) { $collected[] = $ace; } break; - case '{DAV:}unauthenticated' : + case '{DAV:}unauthenticated': // Unauthenticated users only if (!$isAuthenticated) { $collected[] = $ace; } break; - default : + default: if ($this->principalMatchesPrincipal($ace['principal'])) { $collected[] = $ace; } break; - } - - } // Now we deduct all aggregated privileges. @@ -676,41 +652,37 @@ class Plugin extends DAV\ServerPlugin { $collected2 = []; while (count($collected)) { - $current = array_pop($collected); $collected2[] = $current['privilege']; if (!isset($flat[$current['privilege']])) { // Ignoring privileges that are not in the supported-privileges list. - $this->server->getLogger()->debug('A node has the "' . $current['privilege'] . '" in its ACL list, but this privilege was not reported in the supportedPrivilegeSet list. This will be ignored.'); + $this->server->getLogger()->debug('A node has the "'.$current['privilege'].'" in its ACL list, but this privilege was not reported in the supportedPrivilegeSet list. This will be ignored.'); continue; } foreach ($flat[$current['privilege']]['aggregates'] as $subPriv) { $collected2[] = $subPriv; $collected[] = $flat[$subPriv]; } - } return array_values(array_unique($collected2)); - } - /** * Returns a principal based on its uri. * * Returns null if the principal could not be found. * * @param string $uri - * @return null|string + * + * @return string|null */ - function getPrincipalByUri($uri) { - + public function getPrincipalByUri($uri) + { $result = null; $collections = $this->principalCollectionSet; foreach ($collections as $collection) { - try { $principalCollection = $this->server->tree->getNodeForPath($collection); } catch (NotFound $e) { @@ -728,36 +700,35 @@ class Plugin extends DAV\ServerPlugin { if ($result) { return $result; } - } - } /** - * Principal property search + * Principal property search. * * This method can search for principals matching certain values in * properties. * * This method will return a list of properties for the matched properties. * - * @param array $searchProperties The properties to search on. This is a - * key-value list. The keys are property - * names, and the values the strings to - * match them on. - * @param array $requestedProperties This is the list of properties to - * return for every match. - * @param string $collectionUri The principal collection to search on. - * If this is ommitted, the standard - * principal collection-set will be used. - * @param string $test "allof" to use AND to search the - * properties. 'anyof' for OR. - * @return array This method returns an array structure similar to - * Sabre\DAV\Server::getPropertiesForPath. Returned - * properties are index by a HTTP status code. + * @param array $searchProperties The properties to search on. This is a + * key-value list. The keys are property + * names, and the values the strings to + * match them on. + * @param array $requestedProperties this is the list of properties to + * return for every match + * @param string $collectionUri the principal collection to search on. + * If this is ommitted, the standard + * principal collection-set will be used + * @param string $test "allof" to use AND to search the + * properties. 'anyof' for OR. + * + * @return array This method returns an array structure similar to + * Sabre\DAV\Server::getPropertiesForPath. Returned + * properties are index by a HTTP status code. */ - function principalSearch(array $searchProperties, array $requestedProperties, $collectionUri = null, $test = 'allof') { - + public function principalSearch(array $searchProperties, array $requestedProperties, $collectionUri = null, $test = 'allof') + { if (!is_null($collectionUri)) { $uris = [$collectionUri]; } else { @@ -766,7 +737,6 @@ class Plugin extends DAV\ServerPlugin { $lookupResults = []; foreach ($uris as $uri) { - $principalCollection = $this->server->tree->getNodeForPath($uri); if (!$principalCollection instanceof IPrincipalCollection) { // Not a principal collection, we're simply going to ignore @@ -776,33 +746,28 @@ class Plugin extends DAV\ServerPlugin { $results = $principalCollection->searchPrincipals($searchProperties, $test); foreach ($results as $result) { - $lookupResults[] = rtrim($uri, '/') . '/' . $result; + $lookupResults[] = rtrim($uri, '/').'/'.$result; } - } $matches = []; foreach ($lookupResults as $lookupResult) { - list($matches[]) = $this->server->getPropertiesForPath($lookupResult, $requestedProperties, 0); - } return $matches; - } /** - * Sets up the plugin + * Sets up the plugin. * * This method is automatically called by the server class. * * @param DAV\Server $server - * @return void */ - function initialize(DAV\Server $server) { - + public function initialize(DAV\Server $server) + { if ($this->allowUnauthenticatedAccess) { $authPlugin = $server->getPlugin('auth'); if (!$authPlugin) { @@ -812,22 +777,22 @@ class Plugin extends DAV\ServerPlugin { } $this->server = $server; - $server->on('propFind', [$this, 'propFind'], 20); - $server->on('beforeMethod', [$this, 'beforeMethod'], 20); - $server->on('beforeBind', [$this, 'beforeBind'], 20); - $server->on('beforeUnbind', [$this, 'beforeUnbind'], 20); - $server->on('propPatch', [$this, 'propPatch']); - $server->on('beforeUnlock', [$this, 'beforeUnlock'], 20); - $server->on('report', [$this, 'report']); - $server->on('method:ACL', [$this, 'httpAcl']); - $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); - $server->on('getPrincipalByUri', function($principal, &$uri) { - + $server->on('propFind', [$this, 'propFind'], 20); + $server->on('beforeMethod:*', [$this, 'beforeMethod'], 20); + $server->on('beforeBind', [$this, 'beforeBind'], 20); + $server->on('beforeUnbind', [$this, 'beforeUnbind'], 20); + $server->on('propPatch', [$this, 'propPatch']); + $server->on('beforeUnlock', [$this, 'beforeUnlock'], 20); + $server->on('report', [$this, 'report']); + $server->on('method:ACL', [$this, 'httpAcl']); + $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); + $server->on('getPrincipalByUri', function ($principal, &$uri) { $uri = $this->getPrincipalByUri($principal); // Break event chain - if ($uri) return false; - + if ($uri) { + return false; + } }); array_push($server->protectedProperties, @@ -858,39 +823,38 @@ class Plugin extends DAV\ServerPlugin { $server->xml->elementMap['{DAV:}principal-property-search'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalPropertySearchReport'; $server->xml->elementMap['{DAV:}principal-search-property-set'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalSearchPropertySetReport'; $server->xml->elementMap['{DAV:}principal-match'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalMatchReport'; - } /* {{{ Event handlers */ /** - * Triggered before any method is handled + * Triggered before any method is handled. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function beforeMethod(RequestInterface $request, ResponseInterface $response) { - + public function beforeMethod(RequestInterface $request, ResponseInterface $response) + { $method = $request->getMethod(); $path = $request->getPath(); $exists = $this->server->tree->nodeExists($path); // If the node doesn't exists, none of these checks apply - if (!$exists) return; + if (!$exists) { + return; + } switch ($method) { - - case 'GET' : - case 'HEAD' : - case 'OPTIONS' : + case 'GET': + case 'HEAD': + case 'OPTIONS': // For these 3 we only need to know if the node is readable. $this->checkPrivileges($path, '{DAV:}read'); break; - case 'PUT' : - case 'LOCK' : + case 'PUT': + case 'LOCK': // This method requires the write-content priv if the node // already exists, and bind on the parent if the node is being // created. @@ -898,20 +862,20 @@ class Plugin extends DAV\ServerPlugin { $this->checkPrivileges($path, '{DAV:}write-content'); break; - case 'UNLOCK' : + case 'UNLOCK': // Unlock is always allowed at the moment. break; - case 'PROPPATCH' : + case 'PROPPATCH': $this->checkPrivileges($path, '{DAV:}write-properties'); break; - case 'ACL' : + case 'ACL': $this->checkPrivileges($path, '{DAV:}write-acl'); break; - case 'COPY' : - case 'MOVE' : + case 'COPY': + case 'MOVE': // Copy requires read privileges on the entire source tree. // If the target exists write-content normally needs to be // checked, however, we're deleting the node beforehand and @@ -925,9 +889,7 @@ class Plugin extends DAV\ServerPlugin { // the sourcenode can be deleted. $this->checkPrivileges($path, '{DAV:}read', self::R_RECURSIVE); break; - } - } /** @@ -937,54 +899,49 @@ class Plugin extends DAV\ServerPlugin { * new node, such as PUT, MKCOL, MKCALENDAR, LOCK, COPY and MOVE. * * @param string $uri - * @return void */ - function beforeBind($uri) { - + public function beforeBind($uri) + { list($parentUri) = Uri\split($uri); $this->checkPrivileges($parentUri, '{DAV:}bind'); - } /** - * Triggered before a node is deleted + * Triggered before a node is deleted. * * This allows us to check permissions for any operation that will delete * an existing node. * * @param string $uri - * @return void */ - function beforeUnbind($uri) { - + public function beforeUnbind($uri) + { list($parentUri) = Uri\split($uri); $this->checkPrivileges($parentUri, '{DAV:}unbind', self::R_RECURSIVEPARENTS); - } /** * Triggered before a node is unlocked. * - * @param string $uri + * @param string $uri * @param DAV\Locks\LockInfo $lock * @TODO: not yet implemented - * @return void */ - function beforeUnlock($uri, DAV\Locks\LockInfo $lock) { - - + public function beforeUnlock($uri, DAV\Locks\LockInfo $lock) + { } /** * Triggered before properties are looked up in specific nodes. * * @param DAV\PropFind $propFind - * @param DAV\INode $node + * @param DAV\INode $node * @TODO really should be broken into multiple methods, or even a class. + * * @return bool */ - function propFind(DAV\PropFind $propFind, DAV\INode $node) { - + public function propFind(DAV\PropFind $propFind, DAV\INode $node) + { $path = $propFind->getPath(); // Checking the read permission @@ -1004,95 +961,95 @@ class Plugin extends DAV\ServerPlugin { } return; - } /* Adding principal properties */ if ($node instanceof IPrincipal) { - - $propFind->handle('{DAV:}alternate-URI-set', function() use ($node) { + $propFind->handle('{DAV:}alternate-URI-set', function () use ($node) { return new Href($node->getAlternateUriSet()); }); - $propFind->handle('{DAV:}principal-URL', function() use ($node) { - return new Href($node->getPrincipalUrl() . '/'); + $propFind->handle('{DAV:}principal-URL', function () use ($node) { + return new Href($node->getPrincipalUrl().'/'); }); - $propFind->handle('{DAV:}group-member-set', function() use ($node) { + $propFind->handle('{DAV:}group-member-set', function () use ($node) { $members = $node->getGroupMemberSet(); foreach ($members as $k => $member) { - $members[$k] = rtrim($member, '/') . '/'; + $members[$k] = rtrim($member, '/').'/'; } + return new Href($members); }); - $propFind->handle('{DAV:}group-membership', function() use ($node) { + $propFind->handle('{DAV:}group-membership', function () use ($node) { $members = $node->getGroupMembership(); foreach ($members as $k => $member) { - $members[$k] = rtrim($member, '/') . '/'; + $members[$k] = rtrim($member, '/').'/'; } + return new Href($members); }); $propFind->handle('{DAV:}displayname', [$node, 'getDisplayName']); - } - $propFind->handle('{DAV:}principal-collection-set', function() { - + $propFind->handle('{DAV:}principal-collection-set', function () { $val = $this->principalCollectionSet; // Ensuring all collections end with a slash - foreach ($val as $k => $v) $val[$k] = $v . '/'; - return new Href($val); + foreach ($val as $k => $v) { + $val[$k] = $v.'/'; + } + return new Href($val); }); - $propFind->handle('{DAV:}current-user-principal', function() { + $propFind->handle('{DAV:}current-user-principal', function () { if ($url = $this->getCurrentUserPrincipal()) { - return new Xml\Property\Principal(Xml\Property\Principal::HREF, $url . '/'); + return new Xml\Property\Principal(Xml\Property\Principal::HREF, $url.'/'); } else { return new Xml\Property\Principal(Xml\Property\Principal::UNAUTHENTICATED); } }); - $propFind->handle('{DAV:}supported-privilege-set', function() use ($node) { + $propFind->handle('{DAV:}supported-privilege-set', function () use ($node) { return new Xml\Property\SupportedPrivilegeSet($this->getSupportedPrivilegeSet($node)); }); - $propFind->handle('{DAV:}current-user-privilege-set', function() use ($node, $propFind, $path) { + $propFind->handle('{DAV:}current-user-privilege-set', function () use ($node, $propFind, $path) { if (!$this->checkPrivileges($path, '{DAV:}read-current-user-privilege-set', self::R_PARENT, false)) { $propFind->set('{DAV:}current-user-privilege-set', null, 403); } else { $val = $this->getCurrentUserPrivilegeSet($node); + return new Xml\Property\CurrentUserPrivilegeSet($val); } }); - $propFind->handle('{DAV:}acl', function() use ($node, $propFind, $path) { + $propFind->handle('{DAV:}acl', function () use ($node, $propFind, $path) { /* The ACL property contains all the permissions */ if (!$this->checkPrivileges($path, '{DAV:}read-acl', self::R_PARENT, false)) { $propFind->set('{DAV:}acl', null, 403); } else { $acl = $this->getACL($node); + return new Xml\Property\Acl($this->getACL($node)); } }); - $propFind->handle('{DAV:}acl-restrictions', function() { + $propFind->handle('{DAV:}acl-restrictions', function () { return new Xml\Property\AclRestrictions(); }); /* Adding ACL properties */ if ($node instanceof IACL) { - $propFind->handle('{DAV:}owner', function() use ($node) { - return new Href($node->getOwner() . '/'); + $propFind->handle('{DAV:}owner', function () use ($node) { + return new Href($node->getOwner().'/'); }); } - } /** * This method intercepts PROPPATCH methods and make sure the * group-member-set is updated correctly. * - * @param string $path + * @param string $path * @param DAV\PropPatch $propPatch - * @return void */ - function propPatch($path, DAV\PropPatch $propPatch) { - - $propPatch->handle('{DAV:}group-member-set', function($value) use ($path) { + public function propPatch($path, DAV\PropPatch $propPatch) + { + $propPatch->handle('{DAV:}group-member-set', function ($value) use ($path) { if (is_null($value)) { $memberSet = []; } elseif ($value instanceof Href) { @@ -1116,55 +1073,58 @@ class Plugin extends DAV\ServerPlugin { return true; }); - } /** - * This method handles HTTP REPORT requests + * This method handles HTTP REPORT requests. * * @param string $reportName - * @param mixed $report - * @param mixed $path + * @param mixed $report + * @param mixed $path + * * @return bool */ - function report($reportName, $report, $path) { - + public function report($reportName, $report, $path) + { switch ($reportName) { - - case '{DAV:}principal-property-search' : + case '{DAV:}principal-property-search': $this->server->transactionType = 'report-principal-property-search'; $this->principalPropertySearchReport($path, $report); + return false; - case '{DAV:}principal-search-property-set' : + case '{DAV:}principal-search-property-set': $this->server->transactionType = 'report-principal-search-property-set'; $this->principalSearchPropertySetReport($path, $report); + return false; - case '{DAV:}expand-property' : + case '{DAV:}expand-property': $this->server->transactionType = 'report-expand-property'; $this->expandPropertyReport($path, $report); + return false; - case '{DAV:}principal-match' : + case '{DAV:}principal-match': $this->server->transactionType = 'report-principal-match'; $this->principalMatchReport($path, $report); + return false; - case '{DAV:}acl-principal-prop-set' : + case '{DAV:}acl-principal-prop-set': $this->server->transactionType = 'acl-principal-prop-set'; $this->aclPrincipalPropSetReport($path, $report); - return false; + return false; } - } /** * This method is responsible for handling the 'ACL' event. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function httpAcl(RequestInterface $request, ResponseInterface $response) { - + public function httpAcl(RequestInterface $request, ResponseInterface $response) + { $path = $request->getPath(); $body = $request->getBodyAsString(); @@ -1192,8 +1152,9 @@ class Plugin extends DAV\ServerPlugin { /* Checking if protected principals from the existing principal set are not overwritten. */ foreach ($oldAcl as $oldAce) { - - if (!isset($oldAce['protected']) || !$oldAce['protected']) continue; + if (!isset($oldAce['protected']) || !$oldAce['protected']) { + continue; + } $found = false; foreach ($newAcl as $newAce) { @@ -1201,36 +1162,35 @@ class Plugin extends DAV\ServerPlugin { $newAce['privilege'] === $oldAce['privilege'] && $newAce['principal'] === $oldAce['principal'] && $newAce['protected'] - ) - $found = true; + ) { + $found = true; + } } - if (!$found) + if (!$found) { throw new Exception\AceConflict('This resource contained a protected {DAV:}ace, but this privilege did not occur in the ACL request'); - + } } foreach ($newAcl as $newAce) { - // Do we recognize the privilege if (!isset($supportedPrivileges[$newAce['privilege']])) { - throw new Exception\NotSupportedPrivilege('The privilege you specified (' . $newAce['privilege'] . ') is not recognized by this server'); + throw new Exception\NotSupportedPrivilege('The privilege you specified ('.$newAce['privilege'].') is not recognized by this server'); } if ($supportedPrivileges[$newAce['privilege']]['abstract']) { - throw new Exception\NoAbstract('The privilege you specified (' . $newAce['privilege'] . ') is an abstract privilege'); + throw new Exception\NoAbstract('The privilege you specified ('.$newAce['privilege'].') is an abstract privilege'); } // Looking up the principal try { $principal = $this->server->tree->getNodeForPath($newAce['principal']); } catch (NotFound $e) { - throw new Exception\NotRecognizedPrincipal('The specified principal (' . $newAce['principal'] . ') does not exist'); + throw new Exception\NotRecognizedPrincipal('The specified principal ('.$newAce['principal'].') does not exist'); } if (!($principal instanceof IPrincipal)) { - throw new Exception\NotRecognizedPrincipal('The specified uri (' . $newAce['principal'] . ') is not a principal'); + throw new Exception\NotRecognizedPrincipal('The specified uri ('.$newAce['principal'].') is not a principal'); } - } $node->setACL($newAcl); @@ -1238,7 +1198,6 @@ class Plugin extends DAV\ServerPlugin { // Breaking the event chain, because we handled this method. return false; - } /* }}} */ @@ -1252,14 +1211,13 @@ class Plugin extends DAV\ServerPlugin { * or a principal URL, the principal URL and principal URLs of groups that * principal belongs to. * - * @param string $path + * @param string $path * @param Xml\Request\PrincipalMatchReport $report - * @return void */ - protected function principalMatchReport($path, Xml\Request\PrincipalMatchReport $report) { - + protected function principalMatchReport($path, Xml\Request\PrincipalMatchReport $report) + { $depth = $this->server->getHTTPDepth(0); - if ($depth !== 0) { + if (0 !== $depth) { throw new BadRequest('The principal-match report is only defined on Depth: 0'); } @@ -1267,20 +1225,15 @@ class Plugin extends DAV\ServerPlugin { $result = []; - if ($report->type === Xml\Request\PrincipalMatchReport::SELF) { - + if (Xml\Request\PrincipalMatchReport::SELF === $report->type) { // Finding all principals under the request uri that match the // current principal. foreach ($currentPrincipals as $currentPrincipal) { - - if ($currentPrincipal === $path || strpos($currentPrincipal, $path . '/') === 0) { + if ($currentPrincipal === $path || 0 === strpos($currentPrincipal, $path.'/')) { $result[] = $currentPrincipal; } - } - } else { - // We need to find all resources that have a property that matches // one of the current principals. $candidates = $this->server->getPropertiesForPath( @@ -1290,7 +1243,6 @@ class Plugin extends DAV\ServerPlugin { ); foreach ($candidates as $candidate) { - if (!isset($candidate[200][$report->principalProperty])) { continue; } @@ -1308,23 +1260,19 @@ class Plugin extends DAV\ServerPlugin { } } } - } $responses = []; foreach ($result as $item) { - $properties = []; if ($report->properties) { - $foo = $this->server->getPropertiesForPath($item, $report->properties); $foo = $foo[0]; $item = $foo['href']; unset($foo['href']); $properties = $foo; - } $responses[] = new DAV\Xml\Element\Response( @@ -1332,7 +1280,6 @@ class Plugin extends DAV\ServerPlugin { $properties, '200' ); - } $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); @@ -1344,8 +1291,6 @@ class Plugin extends DAV\ServerPlugin { $this->server->getBaseUri() ) ); - - } /** @@ -1359,12 +1304,11 @@ class Plugin extends DAV\ServerPlugin { * Other rfc's, such as ACL rely on this report, so it made sense to put * it in this plugin. * - * @param string $path + * @param string $path * @param Xml\Request\ExpandPropertyReport $report - * @return void */ - protected function expandPropertyReport($path, $report) { - + protected function expandPropertyReport($path, $report) + { $depth = $this->server->getHTTPDepth(0); $result = $this->expandProperties($path, $report->properties, $depth); @@ -1377,34 +1321,36 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setBody($xml); - } /** * This method expands all the properties and returns - * a list with property values + * a list with property values. * * @param array $path * @param array $requestedProperties the list of required properties - * @param int $depth + * @param int $depth + * * @return array */ - protected function expandProperties($path, array $requestedProperties, $depth) { - + protected function expandProperties($path, array $requestedProperties, $depth) + { $foundProperties = $this->server->getPropertiesForPath($path, array_keys($requestedProperties), $depth); $result = []; foreach ($foundProperties as $node) { - foreach ($requestedProperties as $propertyName => $childRequestedProperties) { - // We're only traversing if sub-properties were requested - if (count($childRequestedProperties) === 0) continue; + if (!is_array($childRequestedProperties) || 0 === count($childRequestedProperties)) { + continue; + } // We only have to do the expansion if the property was found // and it contains an href element. - if (!array_key_exists($propertyName, $node[200])) continue; + if (!array_key_exists($propertyName, $node[200])) { + continue; + } if (!$node[200][$propertyName] instanceof DAV\Xml\Property\Href) { continue; @@ -1416,39 +1362,35 @@ class Plugin extends DAV\ServerPlugin { foreach ($childHrefs as $href) { // Gathering the result of the children $childProps[] = [ - 'name' => '{DAV:}response', - 'value' => $this->expandProperties($href, $childRequestedProperties, 0)[0] + 'name' => '{DAV:}response', + 'value' => $this->expandProperties($href, $childRequestedProperties, 0)[0], ]; } // Replacing the property with its expanded form. $node[200][$propertyName] = $childProps; - } $result[] = new DAV\Xml\Element\Response($node['href'], $node); - } return $result; - } /** - * principalSearchPropertySetReport + * principalSearchPropertySetReport. * * This method responsible for handing the * {DAV:}principal-search-property-set report. This report returns a list * of properties the client may search on, using the * {DAV:}principal-property-search report. * - * @param string $path + * @param string $path * @param Xml\Request\PrincipalSearchPropertySetReport $report - * @return void */ - protected function principalSearchPropertySetReport($path, $report) { - + protected function principalSearchPropertySetReport($path, $report) + { $httpDepth = $this->server->getHTTPDepth(0); - if ($httpDepth !== 0) { + if (0 !== $httpDepth) { throw new DAV\Exception\BadRequest('This report is only defined when Depth: 0'); } @@ -1459,7 +1401,6 @@ class Plugin extends DAV\ServerPlugin { $writer->startElement('{DAV:}principal-search-property-set'); foreach ($this->principalSearchPropertySet as $propertyName => $description) { - $writer->startElement('{DAV:}principal-search-property'); $writer->startElement('{DAV:}prop'); @@ -1469,15 +1410,13 @@ class Plugin extends DAV\ServerPlugin { if ($description) { $writer->write([[ - 'name' => '{DAV:}description', - 'value' => $description, - 'attributes' => ['xml:lang' => 'en'] + 'name' => '{DAV:}description', + 'value' => $description, + 'attributes' => ['xml:lang' => 'en'], ]]); } $writer->endElement(); // principal-search-property - - } $writer->endElement(); // principal-search-property-set @@ -1485,27 +1424,25 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setStatus(200); $this->server->httpResponse->setBody($writer->outputMemory()); - } /** - * principalPropertySearchReport + * principalPropertySearchReport. * * This method is responsible for handing the * {DAV:}principal-property-search report. This report can be used for * clients to search for groups of principals, based on the value of one * or more properties. * - * @param string $path + * @param string $path * @param Xml\Request\PrincipalPropertySearchReport $report - * @return void */ - protected function principalPropertySearchReport($path, Xml\Request\PrincipalPropertySearchReport $report) { - + protected function principalPropertySearchReport($path, Xml\Request\PrincipalPropertySearchReport $report) + { if ($report->applyToPrincipalCollectionSet) { $path = null; } - if ($this->server->getHttpDepth('0') !== 0) { + if (0 !== $this->server->getHttpDepth('0')) { throw new BadRequest('Depth must be 0'); } $result = $this->principalSearch( @@ -1520,12 +1457,11 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setStatus(207); $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer'); - $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, $prefer['return'] === 'minimal')); - + $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, 'minimal' === $prefer['return'])); } /** - * aclPrincipalPropSet REPORT + * aclPrincipalPropSet REPORT. * * This method is responsible for handling the {DAV:}acl-principal-prop-set * REPORT, as defined in: @@ -1537,13 +1473,12 @@ class Plugin extends DAV\ServerPlugin { * is used to for example generate a UI with ACL rules, allowing you * to show names for principals for every entry. * - * @param string $path + * @param string $path * @param Xml\Request\AclPrincipalPropSetReport $report - * @return void */ - protected function aclPrincipalPropSetReport($path, Xml\Request\AclPrincipalPropSetReport $report) { - - if ($this->server->getHTTPDepth(0) !== 0) { + protected function aclPrincipalPropSetReport($path, Xml\Request\AclPrincipalPropSetReport $report) + { + if (0 !== $this->server->getHTTPDepth(0)) { throw new BadRequest('The {DAV:}acl-principal-prop-set REPORT only supports Depth 0'); } @@ -1558,14 +1493,12 @@ class Plugin extends DAV\ServerPlugin { $principals = []; foreach ($acl['{DAV:}acl']->getPrivileges() as $ace) { - - if ($ace['principal'][0] === '{') { + if ('{' === $ace['principal'][0]) { // It's not a principal, it's one of the special rules such as {DAV:}authenticated continue; } $principals[] = $ace['principal']; - } $properties = $this->server->getPropertiesForMultiplePaths( @@ -1578,10 +1511,8 @@ class Plugin extends DAV\ServerPlugin { $this->server->httpResponse->setBody( $this->server->generateMultiStatus($properties) ); - } - /* }}} */ /** @@ -1590,13 +1521,15 @@ class Plugin extends DAV\ServerPlugin { * can use to create new calendars. * * @param DAV\INode $node - * @param string $output + * @param string $output + * * @return bool */ - function htmlActionsPanel(DAV\INode $node, &$output) { - - if (!$node instanceof PrincipalCollection) + public function htmlActionsPanel(DAV\INode $node, &$output) + { + if (!$node instanceof PrincipalCollection) { return; + } $output .= '<tr><td colspan="2"><form method="post" action=""> <h3>Create new principal</h3> @@ -1610,7 +1543,6 @@ class Plugin extends DAV\ServerPlugin { </td></tr>'; return false; - } /** @@ -1624,13 +1556,12 @@ class Plugin extends DAV\ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Adds support for WebDAV ACL (rfc3744)', - 'link' => 'http://sabre.io/dav/acl/', + 'link' => 'http://sabre.io/dav/acl/', ]; - } } diff --git a/vendor/sabre/dav/lib/DAVACL/Principal.php b/vendor/sabre/dav/lib/DAVACL/Principal.php index d7db94999..e2df1c35e 100644 --- a/vendor/sabre/dav/lib/DAVACL/Principal.php +++ b/vendor/sabre/dav/lib/DAVACL/Principal.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * Principal class + * Principal class. * * This class is a representation of a simple principal * @@ -20,8 +22,8 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { - +class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL +{ use ACLTrait; /** @@ -32,93 +34,86 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { protected $principalProperties; /** - * Principal backend + * Principal backend. * * @var PrincipalBackend\BackendInterface */ protected $principalBackend; /** - * Creates the principal object + * Creates the principal object. * * @param PrincipalBackend\BackendInterface $principalBackend - * @param array $principalProperties + * @param array $principalProperties */ - function __construct(PrincipalBackend\BackendInterface $principalBackend, array $principalProperties = []) { - + public function __construct(PrincipalBackend\BackendInterface $principalBackend, array $principalProperties = []) + { if (!isset($principalProperties['uri'])) { throw new DAV\Exception('The principal properties must at least contain the \'uri\' key'); } $this->principalBackend = $principalBackend; $this->principalProperties = $principalProperties; - } /** - * Returns the full principal url + * Returns the full principal url. * * @return string */ - function getPrincipalUrl() { - + public function getPrincipalUrl() + { return $this->principalProperties['uri']; - } /** - * Returns a list of alternative urls for a principal + * Returns a list of alternative urls for a principal. * * This can for example be an email address, or ldap url. * * @return array */ - function getAlternateUriSet() { - + public function getAlternateUriSet() + { $uris = []; if (isset($this->principalProperties['{DAV:}alternate-URI-set'])) { - $uris = $this->principalProperties['{DAV:}alternate-URI-set']; - } if (isset($this->principalProperties['{http://sabredav.org/ns}email-address'])) { - $uris[] = 'mailto:' . $this->principalProperties['{http://sabredav.org/ns}email-address']; + $uris[] = 'mailto:'.$this->principalProperties['{http://sabredav.org/ns}email-address']; } return array_unique($uris); - } /** - * Returns the list of group members + * Returns the list of group members. * * If this principal is a group, this function should return * all member principal uri's for the group. * * @return array */ - function getGroupMemberSet() { - + public function getGroupMemberSet() + { return $this->principalBackend->getGroupMemberSet($this->principalProperties['uri']); - } /** - * Returns the list of groups this principal is member of + * Returns the list of groups this principal is member of. * * If this principal is a member of a (list of) groups, this function * should return a list of principal uri's for it's members. * * @return array */ - function getGroupMembership() { - + public function getGroupMembership() + { return $this->principalBackend->getGroupMemberShip($this->principalProperties['uri']); - } /** - * Sets a list of group members + * Sets a list of group members. * * If this principal is a group, this method sets all the group members. * The list of members is always overwritten, never appended to. @@ -126,12 +121,10 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { * This method should throw an exception if the members could not be set. * * @param array $groupMembers - * @return void */ - function setGroupMemberSet(array $groupMembers) { - + public function setGroupMemberSet(array $groupMembers) + { $this->principalBackend->setGroupMemberSet($this->principalProperties['uri'], $groupMembers); - } /** @@ -139,48 +132,45 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { * * @return string */ - function getName() { - + public function getName() + { $uri = $this->principalProperties['uri']; - list(, $name) = URLUtil::splitPath($uri); - return $name; + list(, $name) = Uri\split($uri); + return $name; } /** - * Returns the name of the user + * Returns the name of the user. * * @return string */ - function getDisplayName() { - + public function getDisplayName() + { if (isset($this->principalProperties['{DAV:}displayname'])) { return $this->principalProperties['{DAV:}displayname']; } else { return $this->getName(); } - } /** - * Returns a list of properties + * Returns a list of properties. * * @param array $requestedProperties + * * @return array */ - function getProperties($requestedProperties) { - + public function getProperties($requestedProperties) + { $newProperties = []; foreach ($requestedProperties as $propName) { - if (isset($this->principalProperties[$propName])) { $newProperties[$propName] = $this->principalProperties[$propName]; } - } return $newProperties; - } /** @@ -193,29 +183,24 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { * Read the PropPatch documentation for more information. * * @param DAV\PropPatch $propPatch - * @return void */ - function propPatch(DAV\PropPatch $propPatch) { - + public function propPatch(DAV\PropPatch $propPatch) + { return $this->principalBackend->updatePrincipal( $this->principalProperties['uri'], $propPatch ); - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->principalProperties['uri']; - - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php index 9bf9ba445..03a9c4bad 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; /** - * Abstract Principal Backend + * Abstract Principal Backend. * * Currently this class has no function. It's here for consistency and so we * have a non-bc-breaking way to add a default generic implementation to @@ -13,8 +15,8 @@ namespace Sabre\DAVACL\PrincipalBackend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface { - +abstract class AbstractBackend implements BackendInterface +{ /** * Finds a principal by its URI. * @@ -30,13 +32,14 @@ abstract class AbstractBackend implements BackendInterface { * * @param string $uri * @param string $principalPrefix + * * @return string */ - function findByUri($uri, $principalPrefix) { - + public function findByUri($uri, $principalPrefix) + { // Note that the default implementation here is a bit slow and could // likely be optimized. - if (substr($uri, 0, 7) !== 'mailto:') { + if ('mailto:' !== substr($uri, 0, 7)) { return; } $result = $this->searchPrincipals( @@ -47,7 +50,5 @@ abstract class AbstractBackend implements BackendInterface { if ($result) { return $result[0]; } - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php index 40b6e33ea..40ac272b5 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; /** @@ -13,8 +15,8 @@ namespace Sabre\DAVACL\PrincipalBackend; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * Returns a list of principals based on a prefix. * @@ -29,9 +31,10 @@ interface BackendInterface { * you have an email address, use this property. * * @param string $prefixPath + * * @return array */ - function getPrincipalsByPrefix($prefixPath); + public function getPrincipalsByPrefix($prefixPath); /** * Returns a specific principal, specified by it's path. @@ -39,9 +42,10 @@ interface BackendInterface { * getPrincipalsByPrefix. * * @param string $path + * * @return array */ - function getPrincipalByPath($path); + public function getPrincipalByPath($path); /** * Updates one ore more webdav properties on a principal. @@ -55,11 +59,10 @@ interface BackendInterface { * * Read the PropPatch documentation for more info and examples. * - * @param string $path + * @param string $path * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch); + public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch); /** * This method is used to search for principals matching a set of @@ -86,11 +89,12 @@ interface BackendInterface { * from working. * * @param string $prefixPath - * @param array $searchProperties + * @param array $searchProperties * @param string $test + * * @return array */ - function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof'); + public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof'); /** * Finds a principal by its URI. @@ -107,25 +111,28 @@ interface BackendInterface { * * @param string $uri * @param string $principalPrefix + * * @return string */ - function findByUri($uri, $principalPrefix); + public function findByUri($uri, $principalPrefix); /** - * Returns the list of members for a group-principal + * Returns the list of members for a group-principal. * * @param string $principal + * * @return array */ - function getGroupMemberSet($principal); + public function getGroupMemberSet($principal); /** - * Returns the list of groups a principal is a member of + * Returns the list of groups a principal is a member of. * * @param string $principal + * * @return array */ - function getGroupMembership($principal); + public function getGroupMembership($principal); /** * Updates the list of group members for a group principal. @@ -133,9 +140,7 @@ interface BackendInterface { * The principals should be passed as a list of uri's. * * @param string $principal - * @param array $members - * @return void + * @param array $members */ - function setGroupMemberSet($principal, array $members); - + public function setGroupMemberSet($principal, array $members); } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php index e354a697d..ee418e49b 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; use Sabre\DAV\MkCol; @@ -12,8 +14,8 @@ use Sabre\DAV\MkCol; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface CreatePrincipalSupport extends BackendInterface { - +interface CreatePrincipalSupport extends BackendInterface +{ /** * Creates a new principal. * @@ -22,9 +24,7 @@ interface CreatePrincipalSupport extends BackendInterface { * of the principal. * * @param string $path - * @param MkCol $mkCol - * @return void + * @param MkCol $mkCol */ - function createPrincipal($path, MkCol $mkCol); - + public function createPrincipal($path, MkCol $mkCol); } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php index eb0df888b..350ecb145 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; use Sabre\DAV; use Sabre\DAV\MkCol; -use Sabre\HTTP\URLUtil; +use Sabre\Uri; /** - * PDO principal backend + * PDO principal backend. * * * This backend assumes all principals are in a single collection. The default collection @@ -17,44 +19,43 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend implements CreatePrincipalSupport { - +class PDO extends AbstractBackend implements CreatePrincipalSupport +{ /** - * PDO table name for 'principals' + * PDO table name for 'principals'. * * @var string */ public $tableName = 'principals'; /** - * PDO table name for 'group members' + * PDO table name for 'group members'. * * @var string */ public $groupMembersTableName = 'groupmembers'; /** - * pdo + * pdo. * * @var PDO */ protected $pdo; /** - * A list of additional fields to support + * A list of additional fields to support. * * @var array */ protected $fieldMap = [ - - /** + /* * This property can be used to display the users' real name. */ '{DAV:}displayname' => [ 'dbField' => 'displayname', ], - /** + /* * This is the users' primary email-address. */ '{http://sabredav.org/ns}email-address' => [ @@ -67,10 +68,9 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -87,10 +87,11 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * you have an email address, use this property. * * @param string $prefixPath + * * @return array */ - function getPrincipalsByPrefix($prefixPath) { - + public function getPrincipalsByPrefix($prefixPath) + { $fields = [ 'uri', ]; @@ -98,15 +99,16 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { foreach ($this->fieldMap as $key => $value) { $fields[] = $value['dbField']; } - $result = $this->pdo->query('SELECT ' . implode(',', $fields) . ' FROM ' . $this->tableName); + $result = $this->pdo->query('SELECT '.implode(',', $fields).' FROM '.$this->tableName); $principals = []; while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { - // Checking if the principal is in the prefix - list($rowPrefix) = URLUtil::splitPath($row['uri']); - if ($rowPrefix !== $prefixPath) continue; + list($rowPrefix) = Uri\split($row['uri']); + if ($rowPrefix !== $prefixPath) { + continue; + } $principal = [ 'uri' => $row['uri'], @@ -117,11 +119,9 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { } } $principals[] = $principal; - } return $principals; - } /** @@ -130,10 +130,11 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * getPrincipalsByPrefix. * * @param string $path + * * @return array */ - function getPrincipalByPath($path) { - + public function getPrincipalByPath($path) + { $fields = [ 'id', 'uri', @@ -142,14 +143,16 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { foreach ($this->fieldMap as $key => $value) { $fields[] = $value['dbField']; } - $stmt = $this->pdo->prepare('SELECT ' . implode(',', $fields) . ' FROM ' . $this->tableName . ' WHERE uri = ?'); + $stmt = $this->pdo->prepare('SELECT '.implode(',', $fields).' FROM '.$this->tableName.' WHERE uri = ?'); $stmt->execute([$path]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if (!$row) return; + if (!$row) { + return; + } $principal = [ - 'id' => $row['id'], + 'id' => $row['id'], 'uri' => $row['uri'], ]; foreach ($this->fieldMap as $key => $value) { @@ -157,8 +160,8 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { $principal[$key] = $row[$value['dbField']]; } } - return $principal; + return $principal; } /** @@ -173,41 +176,36 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * * Read the PropPatch documentation for more info and examples. * - * @param string $path + * @param string $path * @param DAV\PropPatch $propPatch */ - function updatePrincipal($path, DAV\PropPatch $propPatch) { - - $propPatch->handle(array_keys($this->fieldMap), function($properties) use ($path) { - - $query = "UPDATE " . $this->tableName . " SET "; + public function updatePrincipal($path, DAV\PropPatch $propPatch) + { + $propPatch->handle(array_keys($this->fieldMap), function ($properties) use ($path) { + $query = 'UPDATE '.$this->tableName.' SET '; $first = true; $values = []; foreach ($properties as $key => $value) { - $dbField = $this->fieldMap[$key]['dbField']; if (!$first) { $query .= ', '; } $first = false; - $query .= $dbField . ' = :' . $dbField; + $query .= $dbField.' = :'.$dbField; $values[$dbField] = $value; - } - $query .= " WHERE uri = :uri"; + $query .= ' WHERE uri = :uri'; $values['uri'] = $path; $stmt = $this->pdo->prepare($query); $stmt->execute($values); return true; - }); - } /** @@ -235,48 +233,52 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * from working. * * @param string $prefixPath - * @param array $searchProperties + * @param array $searchProperties * @param string $test + * * @return array */ - function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') { - if (count($searchProperties) == 0) return []; //No criteria + public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') + { + if (0 == count($searchProperties)) { + return []; + } //No criteria - $query = 'SELECT uri FROM ' . $this->tableName . ' WHERE '; + $query = 'SELECT uri FROM '.$this->tableName.' WHERE '; $values = []; foreach ($searchProperties as $property => $value) { switch ($property) { - case '{DAV:}displayname' : - $column = "displayname"; + case '{DAV:}displayname': + $column = 'displayname'; break; - case '{http://sabredav.org/ns}email-address' : - $column = "email"; + case '{http://sabredav.org/ns}email-address': + $column = 'email'; break; - default : + default: // Unsupported property return []; } - if (count($values) > 0) $query .= (strcmp($test, "anyof") == 0 ? " OR " : " AND "); - $query .= 'lower(' . $column . ') LIKE lower(?)'; - $values[] = '%' . $value . '%'; - + if (count($values) > 0) { + $query .= (0 == strcmp($test, 'anyof') ? ' OR ' : ' AND '); + } + $query .= 'lower('.$column.') LIKE lower(?)'; + $values[] = '%'.$value.'%'; } $stmt = $this->pdo->prepare($query); $stmt->execute($values); $principals = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - // Checking if the principal is in the prefix - list($rowPrefix) = URLUtil::splitPath($row['uri']); - if ($rowPrefix !== $prefixPath) continue; + list($rowPrefix) = Uri\split($row['uri']); + if ($rowPrefix !== $prefixPath) { + continue; + } $principals[] = $row['uri']; - } return $principals; - } /** @@ -294,26 +296,32 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * * @param string $uri * @param string $principalPrefix + * * @return string */ - function findByUri($uri, $principalPrefix) { + public function findByUri($uri, $principalPrefix) + { $value = null; $scheme = null; - list($scheme, $value) = explode(":", $uri, 2); - if (empty($value)) return null; + list($scheme, $value) = explode(':', $uri, 2); + if (empty($value)) { + return null; + } $uri = null; - switch ($scheme){ - case "mailto": - $query = 'SELECT uri FROM ' . $this->tableName . ' WHERE lower(email)=lower(?)'; + switch ($scheme) { + case 'mailto': + $query = 'SELECT uri FROM '.$this->tableName.' WHERE lower(email)=lower(?)'; $stmt = $this->pdo->prepare($query); $stmt->execute([$value]); - + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { // Checking if the principal is in the prefix - list($rowPrefix) = URLUtil::splitPath($row['uri']); - if ($rowPrefix !== $principalPrefix) continue; - + list($rowPrefix) = Uri\split($row['uri']); + if ($rowPrefix !== $principalPrefix) { + continue; + } + $uri = $row['uri']; break; //Stop on first match } @@ -322,51 +330,56 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { //unsupported uri scheme return null; } + return $uri; } /** - * Returns the list of members for a group-principal + * Returns the list of members for a group-principal. * * @param string $principal + * * @return array */ - function getGroupMemberSet($principal) { - + public function getGroupMemberSet($principal) + { $principal = $this->getPrincipalByPath($principal); - if (!$principal) throw new DAV\Exception('Principal not found'); - - $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM ' . $this->groupMembersTableName . ' AS groupmembers LEFT JOIN ' . $this->tableName . ' AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.principal_id = ?'); + if (!$principal) { + throw new DAV\Exception('Principal not found'); + } + $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM '.$this->groupMembersTableName.' AS groupmembers LEFT JOIN '.$this->tableName.' AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.principal_id = ?'); $stmt->execute([$principal['id']]); $result = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row['uri']; } - return $result; + return $result; } /** - * Returns the list of groups a principal is a member of + * Returns the list of groups a principal is a member of. * * @param string $principal + * * @return array */ - function getGroupMembership($principal) { - + public function getGroupMembership($principal) + { $principal = $this->getPrincipalByPath($principal); - if (!$principal) throw new DAV\Exception('Principal not found'); - - $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM ' . $this->groupMembersTableName . ' AS groupmembers LEFT JOIN ' . $this->tableName . ' AS principals ON groupmembers.principal_id = principals.id WHERE groupmembers.member_id = ?'); + if (!$principal) { + throw new DAV\Exception('Principal not found'); + } + $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM '.$this->groupMembersTableName.' AS groupmembers LEFT JOIN '.$this->tableName.' AS principals ON groupmembers.principal_id = principals.id WHERE groupmembers.member_id = ?'); $stmt->execute([$principal['id']]); $result = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row['uri']; } - return $result; + return $result; } /** @@ -375,13 +388,12 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * The principals should be passed as a list of uri's. * * @param string $principal - * @param array $members - * @return void + * @param array $members */ - function setGroupMemberSet($principal, array $members) { - + public function setGroupMemberSet($principal, array $members) + { // Grabbing the list of principal id's. - $stmt = $this->pdo->prepare('SELECT id, uri FROM ' . $this->tableName . ' WHERE uri IN (? ' . str_repeat(', ? ', count($members)) . ');'); + $stmt = $this->pdo->prepare('SELECT id, uri FROM '.$this->tableName.' WHERE uri IN (? '.str_repeat(', ? ', count($members)).');'); $stmt->execute(array_merge([$principal], $members)); $memberIds = []; @@ -394,19 +406,17 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { $memberIds[] = $row['id']; } } - if (!$principalId) throw new DAV\Exception('Principal not found'); - + if (!$principalId) { + throw new DAV\Exception('Principal not found'); + } // Wiping out old members - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->groupMembersTableName . ' WHERE principal_id = ?;'); + $stmt = $this->pdo->prepare('DELETE FROM '.$this->groupMembersTableName.' WHERE principal_id = ?;'); $stmt->execute([$principalId]); foreach ($memberIds as $memberId) { - - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->groupMembersTableName . ' (principal_id, member_id) VALUES (?, ?);'); + $stmt = $this->pdo->prepare('INSERT INTO '.$this->groupMembersTableName.' (principal_id, member_id) VALUES (?, ?);'); $stmt->execute([$principalId, $memberId]); - } - } /** @@ -417,15 +427,12 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { * of the principal. * * @param string $path - * @param MkCol $mkCol - * @return void + * @param MkCol $mkCol */ - function createPrincipal($path, MkCol $mkCol) { - - $stmt = $this->pdo->prepare('INSERT INTO ' . $this->tableName . ' (uri) VALUES (?)'); + public function createPrincipal($path, MkCol $mkCol) + { + $stmt = $this->pdo->prepare('INSERT INTO '.$this->tableName.' (uri) VALUES (?)'); $stmt->execute([$path]); $this->updatePrincipal($path, $mkCol); - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php b/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php index ee5b88a90..4fae96e0c 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV\Exception\InvalidResourceType; @@ -7,7 +9,7 @@ use Sabre\DAV\IExtendedCollection; use Sabre\DAV\MkCol; /** - * Principals Collection + * Principals Collection. * * This collection represents a list of users. * The users are instances of Sabre\DAVACL\Principal @@ -16,8 +18,8 @@ use Sabre\DAV\MkCol; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalCollection extends AbstractPrincipalCollection implements IExtendedCollection, IACL { - +class PrincipalCollection extends AbstractPrincipalCollection implements IExtendedCollection, IACL +{ use ACLTrait; /** @@ -28,12 +30,12 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend * supplied by the authentication backend. * * @param array $principal + * * @return \Sabre\DAV\INode */ - function getChildForPrincipal(array $principal) { - + public function getChildForPrincipal(array $principal) + { return new Principal($this->principalBackend, $principal); - } /** @@ -56,21 +58,20 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend * property for you. * * @param string $name - * @param MkCol $mkCol + * @param MkCol $mkCol + * * @throws InvalidResourceType - * @return void */ - function createExtendedCollection($name, MkCol $mkCol) { - + public function createExtendedCollection($name, MkCol $mkCol) + { if (!$mkCol->hasResourceType('{DAV:}principal')) { throw new InvalidResourceType('Only resources of type {DAV:}principal may be created here'); } $this->principalBackend->createPrincipal( - $this->principalPrefix . '/' . $name, + $this->principalPrefix.'/'.$name, $mkCol ); - } /** @@ -85,7 +86,8 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend * * @return array */ - function getACL() { + public function getACL() + { return [ [ 'principal' => '{DAV:}authenticated', @@ -94,5 +96,4 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend ], ]; } - } 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 - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php index 0aa2f29a5..17b37afab 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\Xml\Deserializer; @@ -17,8 +19,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (https://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AclPrincipalPropSetReport implements XmlDeserializable { - +class AclPrincipalPropSetReport implements XmlDeserializable +{ public $properties = []; /** @@ -40,10 +42,11 @@ class AclPrincipalPropSetReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $reader->pushContext(); $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\enum'; @@ -61,7 +64,5 @@ class AclPrincipalPropSetReport implements XmlDeserializable { } return $report; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php index a9938ba5b..393308cd2 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\Xml\Reader; @@ -16,8 +18,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ExpandPropertyReport implements XmlDeserializable { - +class ExpandPropertyReport implements XmlDeserializable +{ /** * An array with requested properties. * @@ -51,17 +53,17 @@ class ExpandPropertyReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree(); $obj = new self(); $obj->properties = self::traverse($elems); return $obj; - } /** @@ -69,15 +71,15 @@ class ExpandPropertyReport implements XmlDeserializable { * {DAV:}property elements. * * @param array $elems - * @return void + * + * @return array */ - private static function traverse($elems) { - + private static function traverse($elems) + { $result = []; foreach ($elems as $elem) { - - if ($elem['name'] !== '{DAV:}property') { + if ('{DAV:}property' !== $elem['name']) { continue; } @@ -85,7 +87,7 @@ class ExpandPropertyReport implements XmlDeserializable { $elem['attributes']['namespace'] : 'DAV:'; - $propName = '{' . $namespace . '}' . $elem['attributes']['name']; + $propName = '{'.$namespace.'}'.$elem['attributes']['name']; $value = null; if (is_array($elem['value'])) { @@ -93,11 +95,8 @@ class ExpandPropertyReport implements XmlDeserializable { } $result[$propName] = $value; - } return $result; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php index 1be15ab2d..f868cc9df 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\Xml\Deserializer; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalMatchReport implements XmlDeserializable { - +class PrincipalMatchReport implements XmlDeserializable +{ /** * Report on a list of principals that match the current principal. */ @@ -31,7 +33,7 @@ class PrincipalMatchReport implements XmlDeserializable { const PRINCIPAL_PROPERTY = 2; /** - * Must be SELF or PRINCIPAL_PROPERTY + * Must be SELF or PRINCIPAL_PROPERTY. * * @var int */ @@ -71,10 +73,11 @@ class PrincipalMatchReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $reader->pushContext(); $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\enum'; @@ -101,7 +104,5 @@ class PrincipalMatchReport implements XmlDeserializable { } return $principalMatch; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php index b0cf0e408..26468fd21 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\DAV\Exception\BadRequest; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalPropertySearchReport implements XmlDeserializable { - +class PrincipalPropertySearchReport implements XmlDeserializable +{ /** * The requested properties. * @@ -28,7 +30,7 @@ class PrincipalPropertySearchReport implements XmlDeserializable { public $properties; /** - * searchProperties + * searchProperties. * * @var array */ @@ -72,31 +74,30 @@ class PrincipalPropertySearchReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $self = new self(); $foundSearchProp = false; $self->test = 'allof'; - if ($reader->getAttribute('test') === 'anyof') { + if ('anyof' === $reader->getAttribute('test')) { $self->test = 'anyof'; } $elemMap = [ '{DAV:}property-search' => 'Sabre\\Xml\\Element\\KeyValue', - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', ]; - - foreach ($reader->parseInnerTree($elemMap) as $elem) { + foreach ($reader->parseInnerTree($elemMap) as $elem) { switch ($elem['name']) { - - case '{DAV:}prop' : + case '{DAV:}prop': $self->properties = array_keys($elem['value']); break; - case '{DAV:}property-search' : + case '{DAV:}property-search': $foundSearchProp = true; // This property has two sub-elements: // {DAV:}prop - The property to be searched on. This may @@ -109,19 +110,15 @@ class PrincipalPropertySearchReport implements XmlDeserializable { $self->searchProperties[$propName] = $elem['value']['{DAV:}match']; } break; - case '{DAV:}apply-to-principal-collection-set' : + case '{DAV:}apply-to-principal-collection-set': $self->applyToPrincipalCollectionSet = true; break; - } - } if (!$foundSearchProp) { throw new BadRequest('The {DAV:}principal-property-search report must contain at least 1 {DAV:}property-search element'); } return $self; - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php index 64d1f7f86..37bc2cfbf 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Xml\Request; use Sabre\DAV\Exception\BadRequest; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlDeserializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalSearchPropertySetReport implements XmlDeserializable { - +class PrincipalSearchPropertySetReport implements XmlDeserializable +{ /** * The deserialize method is called during xml parsing. * @@ -39,10 +41,11 @@ class PrincipalSearchPropertySetReport implements XmlDeserializable { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { if (!$reader->isEmptyElement) { throw new BadRequest('The {DAV:}principal-search-property-set element must be empty'); } @@ -51,8 +54,7 @@ class PrincipalSearchPropertySetReport implements XmlDeserializable { $reader->next(); $self = new self(); - return $self; + return $self; } - } diff --git a/vendor/sabre/dav/phpstan.neon b/vendor/sabre/dav/phpstan.neon new file mode 100644 index 000000000..e50c5be6e --- /dev/null +++ b/vendor/sabre/dav/phpstan.neon @@ -0,0 +1,3 @@ +parameters: + level: 0 + bootstrap: %currentWorkingDirectory%/vendor/autoload.php diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php index 406dbe0e8..80de750dc 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\CalDAV; @@ -7,14 +9,14 @@ use Sabre\DAV; use Sabre\DAV\PropPatch; use Sabre\DAV\Xml\Element\Sharee; -abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { - +abstract class AbstractPDOTest extends \PHPUnit\Framework\TestCase +{ use DAV\DbTestHelperTrait; protected $pdo; - function setUp() { - + public function setUp() + { $this->dropTables([ 'calendarobjects', 'calendars', @@ -26,72 +28,66 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->createSchema('calendars'); $this->pdo = $this->getDb(); - } - function testConstruct() { - + public function testConstruct() + { $backend = new PDO($this->pdo); $this->assertTrue($backend instanceof PDO); - } /** * @depends testConstruct */ - function testGetCalendarsForUserNoCalendars() { - + public function testGetCalendarsForUserNoCalendars() + { $backend = new PDO($this->pdo); $calendars = $backend->getCalendarsForUser('principals/user2'); $this->assertEquals([], $calendars); - } /** * @depends testConstruct */ - function testCreateCalendarAndFetch() { - + public function testCreateCalendarAndFetch() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', [ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT']), - '{DAV:}displayname' => 'Hello!', - '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), + '{DAV:}displayname' => 'Hello!', + '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), ]); $calendars = $backend->getCalendarsForUser('principals/user2'); $elementCheck = [ - 'uri' => 'somerandomid', - '{DAV:}displayname' => 'Hello!', - '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', + 'uri' => 'somerandomid', + '{DAV:}displayname' => 'Hello!', + '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), - 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, ]; $this->assertInternalType('array', $calendars); $this->assertEquals(1, count($calendars)); foreach ($elementCheck as $name => $value) { - $this->assertArrayHasKey($name, $calendars[0]); $this->assertEquals($value, $calendars[0][$name]); - } - } /** * @depends testConstruct */ - function testUpdateCalendarAndFetch() { - + public function testUpdateCalendarAndFetch() + { $backend = new PDO($this->pdo); //Creating a new calendar $newId = $backend->createCalendar('principals/user2', 'somerandomid', []); $propPatch = new PropPatch([ - '{DAV:}displayname' => 'myCalendar', + '{DAV:}displayname' => 'myCalendar', '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), ]); @@ -107,12 +103,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { // Checking if all the information is still correct $elementCheck = [ - 'id' => $newId, - 'uri' => 'somerandomid', - '{DAV:}displayname' => 'myCalendar', - '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', - '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => '', - '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/2', + 'id' => $newId, + 'uri' => 'somerandomid', + '{DAV:}displayname' => 'myCalendar', + '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', + '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => '', + '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/2', '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), ]; @@ -120,40 +116,36 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(1, count($calendars)); foreach ($elementCheck as $name => $value) { - $this->assertArrayHasKey($name, $calendars[0]); $this->assertEquals($value, $calendars[0][$name]); - } - } /** * @depends testConstruct * @expectedException \InvalidArgumentException */ - function testUpdateCalendarBadId() { - + public function testUpdateCalendarBadId() + { $backend = new PDO($this->pdo); //Creating a new calendar $newId = $backend->createCalendar('principals/user2', 'somerandomid', []); $propPatch = new PropPatch([ - '{DAV:}displayname' => 'myCalendar', + '{DAV:}displayname' => 'myCalendar', '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), ]); // Updating the calendar $backend->updateCalendar('raaaa', $propPatch); - } /** * @depends testUpdateCalendarAndFetch */ - function testUpdateCalendarUnknownProperty() { - + public function testUpdateCalendarUnknownProperty() + { $backend = new PDO($this->pdo); //Creating a new calendar @@ -161,7 +153,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $propPatch = new PropPatch([ '{DAV:}displayname' => 'myCalendar', - '{DAV:}yourmom' => 'wittycomment', + '{DAV:}yourmom' => 'wittycomment', ]); // Updating the calendar @@ -170,63 +162,59 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { // Verifying the result of the update $this->assertEquals([ - '{DAV:}yourmom' => 403, + '{DAV:}yourmom' => 403, '{DAV:}displayname' => 424, ], $propPatch->getResult()); - } /** * @depends testCreateCalendarAndFetch */ - function testDeleteCalendar() { - + public function testDeleteCalendar() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', [ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT']), - '{DAV:}displayname' => 'Hello!', + '{DAV:}displayname' => 'Hello!', ]); $backend->deleteCalendar($returnedId); $calendars = $backend->getCalendarsForUser('principals/user2'); $this->assertEquals([], $calendars); - } /** * @depends testCreateCalendarAndFetch * @expectedException \InvalidArgumentException */ - function testDeleteCalendarBadID() { - + public function testDeleteCalendarBadID() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', [ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT']), - '{DAV:}displayname' => 'Hello!', + '{DAV:}displayname' => 'Hello!', ]); $backend->deleteCalendar('bad-id'); - } /** * @depends testCreateCalendarAndFetch * @expectedException \Sabre\DAV\Exception */ - function testCreateCalendarIncorrectComponentSet() {; - + public function testCreateCalendarIncorrectComponentSet() + { $backend = new PDO($this->pdo); //Creating a new calendar $newId = $backend->createCalendar('principals/user2', 'somerandomid', [ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => 'blabla', ]); - } - function testCreateCalendarObject() { - + public function testCreateCalendarObject() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -242,17 +230,17 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => strtotime('20120101'), - 'lastoccurence' => strtotime('20120101') + (3600 * 24), - 'componenttype' => 'VEVENT', + 'lastoccurence' => strtotime('20120101') + (3600 * 24), + 'componenttype' => 'VEVENT', ], $row); - } - function testGetMultipleObjects() { + public function testGetMultipleObjects() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -263,18 +251,18 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $check = [ [ - 'id' => 1, - 'etag' => '"' . md5($object) . '"', - 'uri' => 'id-1', - 'size' => strlen($object), + 'id' => 1, + 'etag' => '"'.md5($object).'"', + 'uri' => 'id-1', + 'size' => strlen($object), 'calendardata' => $object, 'lastmodified' => null, ], [ - 'id' => 2, - 'etag' => '"' . md5($object) . '"', - 'uri' => 'id-2', - 'size' => strlen($object), + 'id' => 2, + 'etag' => '"'.md5($object).'"', + 'uri' => 'id-2', + 'size' => strlen($object), 'calendardata' => $object, 'lastmodified' => null, ], @@ -283,62 +271,54 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $backend->getMultipleCalendarObjects($returnedId, ['id-1', 'id-2']); foreach ($check as $index => $props) { - foreach ($props as $key => $expected) { - $actual = $result[$index][$key]; switch ($key) { - case 'lastmodified' : + case 'lastmodified': $this->assertInternalType('int', $actual); break; - case 'calendardata' : + case 'calendardata': if (is_resource($actual)) { $actual = stream_get_contents($actual); } // no break intentional - default : + default: $this->assertEquals($expected, $actual); - } - } - } - } /** * @depends testGetMultipleObjects * @expectedException \InvalidArgumentException */ - function testGetMultipleObjectsBadId() { - + public function testGetMultipleObjectsBadId() + { $backend = new PDO($this->pdo); $backend->getMultipleCalendarObjects('bad-id', ['foo-bar']); - } /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest * @depends testCreateCalendarObject */ - function testCreateCalendarObjectNoComponent() { - + public function testCreateCalendarObjectNoComponent() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); $object = "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nEND:VCALENDAR\r\n"; $backend->createCalendarObject($returnedId, 'random-id', $object); - } /** * @depends testCreateCalendarObject */ - function testCreateCalendarObjectDuration() { - + public function testCreateCalendarObjectDuration() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -354,37 +334,34 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => strtotime('20120101'), - 'lastoccurence' => strtotime('20120101') + (3600 * 48), - 'componenttype' => 'VEVENT', + 'lastoccurence' => strtotime('20120101') + (3600 * 48), + 'componenttype' => 'VEVENT', ], $row); - } /** * @depends testCreateCalendarObject * @expectedException \InvalidArgumentException */ - function testCreateCalendarObjectBadId() { - + public function testCreateCalendarObjectBadId() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nDURATION:P2D\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; $backend->createCalendarObject('bad-id', 'random-id', $object); - } - /** * @depends testCreateCalendarObject */ - function testCreateCalendarObjectNoDTEND() { - + public function testCreateCalendarObjectNoDTEND() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -399,21 +376,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => strtotime('2012-01-01 10:00:00'), - 'lastoccurence' => strtotime('2012-01-01 10:00:00'), - 'componenttype' => 'VEVENT', + 'lastoccurence' => strtotime('2012-01-01 10:00:00'), + 'componenttype' => 'VEVENT', ], $row); - } /** * @depends testCreateCalendarObject */ - function testCreateCalendarObjectWithDTEND() { - + public function testCreateCalendarObjectWithDTEND() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -428,21 +404,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => strtotime('2012-01-01 10:00:00'), - 'lastoccurence' => strtotime('2012-01-01 11:00:00'), - 'componenttype' => 'VEVENT', + 'lastoccurence' => strtotime('2012-01-01 11:00:00'), + 'componenttype' => 'VEVENT', ], $row); - } /** * @depends testCreateCalendarObject */ - function testCreateCalendarObjectInfiniteRecurrence() { - + public function testCreateCalendarObjectInfiniteRecurrence() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -457,21 +432,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => strtotime('2012-01-01 10:00:00'), - 'lastoccurence' => strtotime(PDO::MAX_DATE), - 'componenttype' => 'VEVENT', + 'lastoccurence' => strtotime(PDO::MAX_DATE), + 'componenttype' => 'VEVENT', ], $row); - } /** * @depends testCreateCalendarObject */ - function testCreateCalendarObjectEndingRecurrence() { - + public function testCreateCalendarObjectEndingRecurrence() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -486,21 +460,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => strtotime('2012-01-01 10:00:00'), - 'lastoccurence' => strtotime('2012-01-01 11:00:00') + (3600 * 24 * 999), - 'componenttype' => 'VEVENT', + 'lastoccurence' => strtotime('2012-01-01 11:00:00') + (3600 * 24 * 999), + 'componenttype' => 'VEVENT', ], $row); - } /** * @depends testCreateCalendarObject */ - function testCreateCalendarObjectTask() { - + public function testCreateCalendarObjectTask() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -515,21 +488,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => null, - 'lastoccurence' => null, - 'componenttype' => 'VTODO', + 'lastoccurence' => null, + 'componenttype' => 'VTODO', ], $row); - } /** * @depends testCreateCalendarObject */ - function testGetCalendarObjects() { - + public function testGetCalendarObjects() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -543,36 +515,33 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('random-id', $data['uri']); $this->assertEquals(strlen($object), $data['size']); - } /** * @depends testGetCalendarObjects * @expectedException \InvalidArgumentException */ - function testGetCalendarObjectsBadId() { - + public function testGetCalendarObjectsBadId() + { $backend = new PDO($this->pdo); $backend->getCalendarObjects('bad-id'); - } /** * @depends testGetCalendarObjects * @expectedException \InvalidArgumentException */ - function testGetCalendarObjectBadId() { - + public function testGetCalendarObjectBadId() + { $backend = new PDO($this->pdo); $backend->getCalendarObject('bad-id', 'foo-bar'); - } /** * @depends testCreateCalendarObject */ - function testGetCalendarObjectByUID() { - + public function testGetCalendarObjectByUID() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -586,14 +555,13 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { 'somerandomid/random-id', $backend->getCalendarObjectByUID('principals/user2', 'foo') ); - } /** * @depends testCreateCalendarObject */ - function testUpdateCalendarObject() { - + public function testUpdateCalendarObject() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -610,26 +578,23 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($object2, $data['calendardata']); $this->assertEquals('random-id', $data['uri']); - - } /** * @depends testUpdateCalendarObject * @expectedException \InvalidArgumentException */ - function testUpdateCalendarObjectBadId() { - + public function testUpdateCalendarObjectBadId() + { $backend = new PDO($this->pdo); $backend->updateCalendarObject('bad-id', 'object-id', 'objectdata'); - } /** * @depends testCreateCalendarObject */ - function testDeleteCalendarObject() { - + public function testDeleteCalendarObject() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -639,222 +604,215 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $data = $backend->getCalendarObject($returnedId, 'random-id'); $this->assertNull($data); - } /** * @depends testDeleteCalendarObject * @expectedException \InvalidArgumentException */ - function testDeleteCalendarObjectBadId() { - + public function testDeleteCalendarObjectBadId() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; $backend->createCalendarObject($returnedId, 'random-id', $object); $backend->deleteCalendarObject('bad-id', 'random-id'); - } - function testCalendarQueryNoResult() { - + public function testCalendarQueryNoResult() + { $abstract = new PDO($this->pdo); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VJOURNAL', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VJOURNAL', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $this->assertEquals([ ], $abstract->calendarQuery([1, 1], $filters)); - } /** * @expectedException \InvalidArgumentException * @depends testCalendarQueryNoResult */ - function testCalendarQueryBadId() { - + public function testCalendarQueryBadId() + { $abstract = new PDO($this->pdo); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VJOURNAL', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VJOURNAL', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $abstract->calendarQuery('bad-id', $filters); - } - function testCalendarQueryTodo() { - + public function testCalendarQueryTodo() + { $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VTODO', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VTODO', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $this->assertEquals([ - "todo", + 'todo', ], $backend->calendarQuery([1, 1], $filters)); - } - function testCalendarQueryTodoNotMatch() { + public function testCalendarQueryTodoNotMatch() + { $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VTODO', + 'name' => 'VTODO', 'comp-filters' => [], 'prop-filters' => [ [ - 'name' => 'summary', - 'text-match' => null, - 'time-range' => null, - 'param-filters' => [], + 'name' => 'summary', + 'text-match' => null, + 'time-range' => null, + 'param-filters' => [], 'is-not-defined' => false, ], ], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $this->assertEquals([ ], $backend->calendarQuery([1, 1], $filters)); - } - function testCalendarQueryNoFilter() { - + public function testCalendarQueryNoFilter() + { $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VCALENDAR', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $result = $backend->calendarQuery([1, 1], $filters); $this->assertTrue(in_array('todo', $result)); $this->assertTrue(in_array('event', $result)); - } - function testCalendarQueryTimeRange() { - + public function testCalendarQueryTimeRange() + { $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event2", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event2', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('20120103'), - 'end' => new \DateTime('20120104'), + 'end' => new \DateTime('20120104'), ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $this->assertEquals([ - "event2", + 'event2', ], $backend->calendarQuery([1, 1], $filters)); - } - function testCalendarQueryTimeRangeNoEnd() { + public function testCalendarQueryTimeRangeNoEnd() + { $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event2", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event2', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('20120102'), - 'end' => null, + 'end' => null, ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $this->assertEquals([ - "event2", + 'event2', ], $backend->calendarQuery([1, 1], $filters)); - } - function testGetChanges() { - + public function testGetChanges() + { $backend = new PDO($this->pdo); $id = $backend->createCalendar( 'principals/user1', @@ -865,37 +823,37 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ 'syncToken' => 1, - 'modified' => [], - 'deleted' => [], - 'added' => [], + 'modified' => [], + 'deleted' => [], + 'added' => [], ], $result); $currentToken = $result['syncToken']; $dummyTodo = "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"; - $backend->createCalendarObject($id, "todo1.ics", $dummyTodo); - $backend->createCalendarObject($id, "todo2.ics", $dummyTodo); - $backend->createCalendarObject($id, "todo3.ics", $dummyTodo); - $backend->updateCalendarObject($id, "todo1.ics", $dummyTodo); - $backend->deleteCalendarObject($id, "todo2.ics"); + $backend->createCalendarObject($id, 'todo1.ics', $dummyTodo); + $backend->createCalendarObject($id, 'todo2.ics', $dummyTodo); + $backend->createCalendarObject($id, 'todo3.ics', $dummyTodo); + $backend->updateCalendarObject($id, 'todo1.ics', $dummyTodo); + $backend->deleteCalendarObject($id, 'todo2.ics'); $result = $backend->getChangesForCalendar($id, $currentToken, 1); $this->assertEquals([ 'syncToken' => 6, - 'modified' => ["todo1.ics"], - 'deleted' => ["todo2.ics"], - 'added' => ["todo3.ics"], + 'modified' => ['todo1.ics'], + 'deleted' => ['todo2.ics'], + 'added' => ['todo3.ics'], ], $result); $result = $backend->getChangesForCalendar($id, null, 1); $this->assertEquals([ 'syncToken' => 6, - 'modified' => [], - 'deleted' => [], - 'added' => ["todo1.ics", "todo3.ics"], + 'modified' => [], + 'deleted' => [], + 'added' => ['todo1.ics', 'todo3.ics'], ], $result); } @@ -903,8 +861,8 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { * @depends testGetChanges * @expectedException \InvalidArgumentException */ - function testGetChangesBadId() { - + public function testGetChangesBadId() + { $backend = new PDO($this->pdo); $id = $backend->createCalendar( 'principals/user1', @@ -912,16 +870,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { [] ); $backend->getChangesForCalendar('bad-id', null, 1); - } - function testCreateSubscriptions() { - + public function testCreateSubscriptions() + { $props = [ - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), - '{DAV:}displayname' => 'cal', - '{http://apple.com/ns/ical/}refreshrate' => 'P1W', - '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', + '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), + '{DAV:}displayname' => 'cal', + '{http://apple.com/ns/ical/}refreshrate' => 'P1W', + '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', '{http://calendarserver.org/ns/}subscribed-strip-todos' => true, //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true, '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true, @@ -944,29 +901,27 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { foreach ($expected as $k => $v) { $this->assertEquals($subs[0][$k], $expected[$k]); } - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testCreateSubscriptionFail() { - + public function testCreateSubscriptionFail() + { $props = [ ]; $backend = new PDO($this->pdo); $backend->createSubscription('principals/user1', 'sub1', $props); - } - function testUpdateSubscriptions() { - + public function testUpdateSubscriptions() + { $props = [ - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), - '{DAV:}displayname' => 'cal', - '{http://apple.com/ns/ical/}refreshrate' => 'P1W', - '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', + '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), + '{DAV:}displayname' => 'cal', + '{http://apple.com/ns/ical/}refreshrate' => 'P1W', + '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', '{http://calendarserver.org/ns/}subscribed-strip-todos' => true, //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true, '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true, @@ -976,7 +931,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createSubscription('principals/user1', 'sub1', $props); $newProps = [ - '{DAV:}displayname' => 'new displayname', + '{DAV:}displayname' => 'new displayname', '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false), ]; @@ -1000,16 +955,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { foreach ($expected as $k => $v) { $this->assertEquals($subs[0][$k], $expected[$k]); } - } - function testUpdateSubscriptionsFail() { - + public function testUpdateSubscriptionsFail() + { $props = [ - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), - '{DAV:}displayname' => 'cal', - '{http://apple.com/ns/ical/}refreshrate' => 'P1W', - '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', + '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), + '{DAV:}displayname' => 'cal', + '{http://apple.com/ns/ical/}refreshrate' => 'P1W', + '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', '{http://calendarserver.org/ns/}subscribed-strip-todos' => true, //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true, '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true, @@ -1019,29 +973,28 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createSubscription('principals/user1', 'sub1', $props); $propPatch = new DAV\PropPatch([ - '{DAV:}displayname' => 'new displayname', + '{DAV:}displayname' => 'new displayname', '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false), - '{DAV:}unknown' => 'foo', + '{DAV:}unknown' => 'foo', ]); $backend->updateSubscription(1, $propPatch); $propPatch->commit(); $this->assertEquals([ - '{DAV:}unknown' => 403, - '{DAV:}displayname' => 424, + '{DAV:}unknown' => 403, + '{DAV:}displayname' => 424, '{http://calendarserver.org/ns/}source' => 424, ], $propPatch->getResult()); - } - function testDeleteSubscriptions() { - + public function testDeleteSubscriptions() + { $props = [ - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), - '{DAV:}displayname' => 'cal', - '{http://apple.com/ns/ical/}refreshrate' => 'P1W', - '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', + '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), + '{DAV:}displayname' => 'cal', + '{http://apple.com/ns/ical/}refreshrate' => 'P1W', + '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', '{http://calendarserver.org/ns/}subscribed-strip-todos' => true, //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true, '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true, @@ -1051,7 +1004,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createSubscription('principals/user1', 'sub1', $props); $newProps = [ - '{DAV:}displayname' => 'new displayname', + '{DAV:}displayname' => 'new displayname', '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false), ]; @@ -1061,8 +1014,8 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(0, count($subs)); } - function testSchedulingMethods() { - + public function testSchedulingMethods() + { $backend = new PDO($this->pdo); $calData = "BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n"; @@ -1075,9 +1028,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ 'calendardata' => $calData, - 'uri' => 'schedule1.ics', - 'etag' => '"' . md5($calData) . '"', - 'size' => strlen($calData) + 'uri' => 'schedule1.ics', + 'etag' => '"'.md5($calData).'"', + 'size' => strlen($calData), ]; $result = $backend->getSchedulingObject('principals/user1', 'schedule1.ics'); @@ -1104,11 +1057,10 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $backend->getSchedulingObject('principals/user1', 'schedule1.ics'); $this->assertNull($result); - } - function testGetInvites() { - + public function testGetInvites() + { $backend = new PDO($this->pdo); // creating a new calendar @@ -1118,23 +1070,22 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $backend->getInvites($calendar['id']); $expected = [ new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - ]) + ]), ]; $this->assertEquals($expected, $result); - } /** * @depends testGetInvites * @expectedException \InvalidArgumentException */ - function testGetInvitesBadId() { - + public function testGetInvitesBadId() + { $backend = new PDO($this->pdo); // creating a new calendar @@ -1142,14 +1093,13 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar = $backend->getCalendarsForUser('principals/user1')[0]; $backend->getInvites('bad-id'); - } /** * @depends testCreateCalendarAndFetch */ - function testUpdateInvites() { - + public function testUpdateInvites() + { $backend = new PDO($this->pdo); // creating a new calendar @@ -1157,9 +1107,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar = $backend->getCalendarsForUser('principals/user1')[0]; $ownerSharee = new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, ]); @@ -1168,12 +1118,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar['id'], [ new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => ['{DAV:}displayname' => 'User 2'], - ]) + 'properties' => ['{DAV:}displayname' => 'User 2'], + ]), ] ); @@ -1181,26 +1131,26 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ $ownerSharee, new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => [ + 'properties' => [ '{DAV:}displayname' => 'User 2', ], - ]) + ]), ]; $this->assertEquals($expected, $result); // Checking calendar_instances too $expectedCalendar = [ - 'id' => [1,2], - 'principaluri' => 'principals/user2', + 'id' => [1, 2], + 'principaluri' => 'principals/user2', '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/1', - '{http://sabredav.org/ns}sync-token' => '1', - 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, - 'read-only' => true, - 'share-resource-uri' => '/ns/share/1', + '{http://sabredav.org/ns}sync-token' => '1', + 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'read-only' => true, + 'share-resource-uri' => '/ns/share/1', ]; $calendars = $backend->getCalendarsForUser('principals/user2'); @@ -1208,21 +1158,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( $v, $calendars[0][$k], - "Key " . $k . " in calendars array did not have the expected value." + 'Key '.$k.' in calendars array did not have the expected value.' ); } - // Updating an invite $backend->updateInvites( $calendar['id'], [ new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - ]) + ]), ] ); @@ -1230,14 +1179,14 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ $ownerSharee, new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => [ + 'properties' => [ '{DAV:}displayname' => 'User 2', ], - ]) + ]), ]; $this->assertEquals($expected, $result); @@ -1246,15 +1195,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar['id'], [ new Sharee([ - 'href' => 'mailto:user@example.org', + 'href' => 'mailto:user@example.org', 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS, - ]) + ]), ] ); $result = $backend->getInvites($calendar['id']); $expected = [ - $ownerSharee + $ownerSharee, ]; $this->assertEquals($expected, $result); @@ -1263,45 +1212,43 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar['id'], [ new Sharee([ - 'href' => 'principals/user2', + 'href' => 'principals/user2', 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS, - ]) + ]), ] ); $result = $backend->getInvites($calendar['id']); $expected = [ new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, ]), ]; $this->assertEquals($expected, $result); - } /** * @depends testUpdateInvites * @expectedException \InvalidArgumentException */ - function testUpdateInvitesBadId() { - + public function testUpdateInvitesBadId() + { $backend = new PDO($this->pdo); // Add a new invite $backend->updateInvites( 'bad-id', [] ); - } /** * @depends testUpdateInvites */ - function testUpdateInvitesNoPrincipal() { - + public function testUpdateInvitesNoPrincipal() + { $backend = new PDO($this->pdo); // creating a new calendar @@ -1309,9 +1256,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar = $backend->getCalendarsForUser('principals/user1')[0]; $ownerSharee = new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, ]); @@ -1320,12 +1267,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar['id'], [ new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => null, - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'href' => 'mailto:user@example.org', + 'principal' => null, + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => ['{DAV:}displayname' => 'User 2'], - ]) + 'properties' => ['{DAV:}displayname' => 'User 2'], + ]), ] ); @@ -1333,24 +1280,23 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ $ownerSharee, new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => null, - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'href' => 'mailto:user@example.org', + 'principal' => null, + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_INVALID, - 'properties' => [ + 'properties' => [ '{DAV:}displayname' => 'User 2', ], - ]) + ]), ]; $this->assertEquals($expected, $result, null, 0.0, 10, true); // Last argument is $canonicalize = true, which allows us to compare, ignoring the order, because it's different between MySQL and Sqlite. - } /** * @depends testUpdateInvites */ - function testDeleteSharedCalendar() { - + public function testDeleteSharedCalendar() + { $backend = new PDO($this->pdo); // creating a new calendar @@ -1358,9 +1304,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar = $backend->getCalendarsForUser('principals/user1')[0]; $ownerSharee = new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, ]); @@ -1369,23 +1315,23 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar['id'], [ new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => ['{DAV:}displayname' => 'User 2'], - ]) + 'properties' => ['{DAV:}displayname' => 'User 2'], + ]), ] ); $expectedCalendar = [ - 'id' => [1,2], - 'principaluri' => 'principals/user2', + 'id' => [1, 2], + 'principaluri' => 'principals/user2', '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/1', - '{http://sabredav.org/ns}sync-token' => '1', - 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, - 'read-only' => true, - 'share-resource-uri' => '/ns/share/1', + '{http://sabredav.org/ns}sync-token' => '1', + 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'read-only' => true, + 'share-resource-uri' => '/ns/share/1', ]; $calendars = $backend->getCalendarsForUser('principals/user2'); @@ -1393,7 +1339,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( $v, $calendars[0][$k], - "Key " . $k . " in calendars array did not have the expected value." + 'Key '.$k.' in calendars array did not have the expected value.' ); } @@ -1408,24 +1354,21 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $backend->getInvites($calendar['id']); $expected = [ new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, ]), ]; $this->assertEquals($expected, $result); - } /** * @expectedException \Sabre\DAV\Exception\NotImplemented */ - function testSetPublishStatus() { - + public function testSetPublishStatus() + { $backend = new PDO($this->pdo); $backend->setPublishStatus([1, 1], true); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php index 7f642efc9..166de1dab 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php @@ -1,14 +1,16 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\DAV\PropPatch; -class AbstractTest extends \PHPUnit_Framework_TestCase { - - function testUpdateCalendar() { - +class AbstractTest extends \PHPUnit\Framework\TestCase +{ + public function testUpdateCalendar() + { $abstract = new AbstractMock(); $propPatch = new PropPatch(['{DAV:}displayname' => 'anything']); @@ -16,36 +18,34 @@ class AbstractTest extends \PHPUnit_Framework_TestCase { $result = $propPatch->commit(); $this->assertFalse($result); - } - function testCalendarQuery() { - + public function testCalendarQuery() + { $abstract = new AbstractMock(); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $this->assertEquals([ 'event1.ics', ], $abstract->calendarQuery(1, $filters)); - } - function testGetCalendarObjectByUID() { - + public function testGetCalendarObjectByUID() + { $abstract = new AbstractMock(); $this->assertNull( $abstract->getCalendarObjectByUID('principal1', 'zim') @@ -60,11 +60,10 @@ class AbstractTest extends \PHPUnit_Framework_TestCase { $this->assertNull( $abstract->getCalendarObjectByUID('principal1', 'shared') ); - } - function testGetMultipleCalendarObjects() { - + public function testGetMultipleCalendarObjects() + { $abstract = new AbstractMock(); $result = $abstract->getMultipleCalendarObjects(1, [ 'event1.ics', @@ -73,106 +72,113 @@ class AbstractTest extends \PHPUnit_Framework_TestCase { $expected = [ [ - 'id' => 1, - 'calendarid' => 1, - 'uri' => 'event1.ics', + 'id' => 1, + 'calendarid' => 1, + 'uri' => 'event1.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", ], [ - 'id' => 2, - 'calendarid' => 1, - 'uri' => 'task1.ics', + 'id' => 2, + 'calendarid' => 1, + 'uri' => 'task1.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n", ], ]; $this->assertEquals($expected, $result); - - } - } -class AbstractMock extends AbstractBackend { - - function getCalendarsForUser($principalUri) { - +class AbstractMock extends AbstractBackend +{ + public function getCalendarsForUser($principalUri) + { return [ [ - 'id' => 1, + 'id' => 1, 'principaluri' => 'principal1', - 'uri' => 'cal1', + 'uri' => 'cal1', ], [ - 'id' => 2, - 'principaluri' => 'principal1', + 'id' => 2, + 'principaluri' => 'principal1', '{http://sabredav.org/ns}owner-principal' => 'principal2', - 'uri' => 'cal1', + 'uri' => 'cal1', ], ]; + } + + public function createCalendar($principalUri, $calendarUri, array $properties) + { + } + public function deleteCalendar($calendarId) + { } - function createCalendar($principalUri, $calendarUri, array $properties) { } - function deleteCalendar($calendarId) { } - function getCalendarObjects($calendarId) { + public function getCalendarObjects($calendarId) + { switch ($calendarId) { case 1: return [ [ - 'id' => 1, + 'id' => 1, 'calendarid' => 1, - 'uri' => 'event1.ics', + 'uri' => 'event1.ics', ], [ - 'id' => 2, + 'id' => 2, 'calendarid' => 1, - 'uri' => 'task1.ics', + 'uri' => 'task1.ics', ], ]; case 2: return [ [ - 'id' => 3, + 'id' => 3, 'calendarid' => 2, - 'uri' => 'shared-event.ics', - ] + 'uri' => 'shared-event.ics', + ], ]; } - } - function getCalendarObject($calendarId, $objectUri) { - + public function getCalendarObject($calendarId, $objectUri) + { switch ($objectUri) { - - case 'event1.ics' : + case 'event1.ics': return [ - 'id' => 1, - 'calendarid' => 1, - 'uri' => 'event1.ics', + 'id' => 1, + 'calendarid' => 1, + 'uri' => 'event1.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", ]; - case 'task1.ics' : + case 'task1.ics': return [ - 'id' => 2, - 'calendarid' => 1, - 'uri' => 'task1.ics', + 'id' => 2, + 'calendarid' => 1, + 'uri' => 'task1.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n", ]; - case 'shared-event.ics' : + case 'shared-event.ics': return [ - 'id' => 3, - 'calendarid' => 2, - 'uri' => 'event1.ics', + 'id' => 3, + 'calendarid' => 2, + 'uri' => 'event1.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:shared\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", ]; - } + } + public function createCalendarObject($calendarId, $objectUri, $calendarData) + { } - function createCalendarObject($calendarId, $objectUri, $calendarData) { } - function updateCalendarObject($calendarId, $objectUri, $calendarData) { } - function deleteCalendarObject($calendarId, $objectUri) { } + public function updateCalendarObject($calendarId, $objectUri, $calendarData) + { + } + + public function deleteCalendarObject($calendarId, $objectUri) + { + } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php index cc665cd8f..9f18eeb72 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php @@ -1,17 +1,19 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Backend; use Sabre\CalDAV; use Sabre\DAV; -class Mock extends AbstractBackend { - +class Mock extends AbstractBackend +{ protected $calendarData; protected $calendars; - function __construct(array $calendars = [], array $calendarData = []) { - + public function __construct(array $calendars = [], array $calendarData = []) + { foreach ($calendars as &$calendar) { if (!isset($calendar['id'])) { $calendar['id'] = DAV\UUIDUtil::getUUID(); @@ -20,7 +22,6 @@ class Mock extends AbstractBackend { $this->calendars = $calendars; $this->calendarData = $calendarData; - } /** @@ -38,10 +39,11 @@ class Mock extends AbstractBackend { * common one is '{DAV:}displayname'. * * @param string $principalUri + * * @return array */ - function getCalendarsForUser($principalUri) { - + public function getCalendarsForUser($principalUri) + { $r = []; foreach ($this->calendars as $row) { if ($row['principaluri'] == $principalUri) { @@ -50,7 +52,6 @@ class Mock extends AbstractBackend { } return $r; - } /** @@ -64,21 +65,21 @@ class Mock extends AbstractBackend { * * @param string $principalUri * @param string $calendarUri - * @param array $properties + * @param array $properties + * * @return string|int */ - function createCalendar($principalUri, $calendarUri, array $properties) { - + public function createCalendar($principalUri, $calendarUri, array $properties) + { $id = DAV\UUIDUtil::getUUID(); $this->calendars[] = array_merge([ - 'id' => $id, - 'principaluri' => $principalUri, - 'uri' => $calendarUri, - '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), + 'id' => $id, + 'principaluri' => $principalUri, + 'uri' => $calendarUri, + '{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), ], $properties); return $id; - } /** @@ -93,16 +94,13 @@ class Mock extends AbstractBackend { * * Read the PropPatch documentation for more info and examples. * - * @param mixed $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) { - - $propPatch->handleRemaining(function($props) use ($calendarId) { - + public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) + { + $propPatch->handleRemaining(function ($props) use ($calendarId) { foreach ($this->calendars as $k => $calendar) { - if ($calendar['id'] === $calendarId) { foreach ($props as $propName => $propValue) { if (is_null($propValue)) { @@ -111,30 +109,25 @@ class Mock extends AbstractBackend { $this->calendars[$k][$propName] = $propValue; } } - return true; + return true; } - } - }); - } /** - * Delete a calendar and all it's objects + * Delete a calendar and all it's objects. * * @param string $calendarId - * @return void */ - function deleteCalendar($calendarId) { - + public function deleteCalendar($calendarId) + { foreach ($this->calendars as $k => $calendar) { if ($calendar['id'] === $calendarId) { unset($this->calendars[$k]); } } - } /** @@ -157,12 +150,14 @@ class Mock extends AbstractBackend { * calendardata. * * @param string $calendarId + * * @return array */ - function getCalendarObjects($calendarId) { - - if (!isset($this->calendarData[$calendarId])) + public function getCalendarObjects($calendarId) + { + if (!isset($this->calendarData[$calendarId])) { return []; + } $objects = $this->calendarData[$calendarId]; @@ -171,8 +166,8 @@ class Mock extends AbstractBackend { $object['uri'] = $uri; $object['lastmodified'] = null; } - return $objects; + return $objects; } /** @@ -187,12 +182,13 @@ class Mock extends AbstractBackend { * * This method must return null if the object did not exist. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri + * * @return array|null */ - function getCalendarObject($calendarId, $objectUri) { - + public function getCalendarObject($calendarId, $objectUri) + { if (!isset($this->calendarData[$calendarId][$objectUri])) { return null; } @@ -200,8 +196,8 @@ class Mock extends AbstractBackend { $object['calendarid'] = $calendarId; $object['uri'] = $objectUri; $object['lastmodified'] = null; - return $object; + return $object; } /** @@ -210,17 +206,16 @@ class Mock extends AbstractBackend { * @param string $calendarId * @param string $objectUri * @param string $calendarData - * @return void */ - function createCalendarObject($calendarId, $objectUri, $calendarData) { - + public function createCalendarObject($calendarId, $objectUri, $calendarData) + { $this->calendarData[$calendarId][$objectUri] = [ 'calendardata' => $calendarData, - 'calendarid' => $calendarId, - 'uri' => $objectUri, + 'calendarid' => $calendarId, + 'uri' => $objectUri, ]; - return '"' . md5($calendarData) . '"'; + return '"'.md5($calendarData).'"'; } /** @@ -229,17 +224,16 @@ class Mock extends AbstractBackend { * @param string $calendarId * @param string $objectUri * @param string $calendarData - * @return void */ - function updateCalendarObject($calendarId, $objectUri, $calendarData) { - + public function updateCalendarObject($calendarId, $objectUri, $calendarData) + { $this->calendarData[$calendarId][$objectUri] = [ 'calendardata' => $calendarData, - 'calendarid' => $calendarId, - 'uri' => $objectUri, + 'calendarid' => $calendarId, + 'uri' => $objectUri, ]; - return '"' . md5($calendarData) . '"'; + return '"'.md5($calendarData).'"'; } /** @@ -247,12 +241,9 @@ class Mock extends AbstractBackend { * * @param string $calendarId * @param string $objectUri - * @return void */ - function deleteCalendarObject($calendarId, $objectUri) { - + public function deleteCalendarObject($calendarId, $objectUri) + { unset($this->calendarData[$calendarId][$objectUri]); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php index e068ff1e7..66388def4 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\CalDAV\Backend; +declare(strict_types=1); -class PDOMySQLTest extends AbstractPDOTest { +namespace Sabre\CalDAV\Backend; +class PDOMySQLTest extends AbstractPDOTest +{ public $driver = 'mysql'; - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php index 90ad5a171..4470e5810 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\CalDAV\Backend; +declare(strict_types=1); -class PDOSqliteTest extends AbstractPDOTest { +namespace Sabre\CalDAV\Backend; +class PDOSqliteTest extends AbstractPDOTest +{ public $driver = 'sqlite'; - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php index c92cde661..d6073514f 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; require_once 'Sabre/CalDAV/TestUtil.php'; -class CalendarObjectTest extends \PHPUnit_Framework_TestCase { - +class CalendarObjectTest extends \PHPUnit\Framework\TestCase +{ /** * @var Sabre\CalDAV\Backend_PDO */ @@ -16,25 +18,23 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { protected $calendar; protected $principalBackend; - function setup() { - + public function setup() + { $this->backend = TestUtil::getBackend(); $calendars = $this->backend->getCalendarsForUser('principals/user1'); $this->assertEquals(2, count($calendars)); $this->calendar = new Calendar($this->backend, $calendars[0]); - } - function teardown() { - + public function teardown() + { unset($this->calendar); unset($this->backend); - } - function testSetup() { - + public function testSetup() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); @@ -42,54 +42,50 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $this->assertInternalType('string', $children[0]->get()); $this->assertInternalType('string', $children[0]->getETag()); $this->assertEquals('text/calendar; charset=utf-8', $children[0]->getContentType()); - } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ - function testInvalidArg1() { - + public function testInvalidArg1() + { $obj = new CalendarObject( new Backend\Mock([], []), [], [] ); - } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ - function testInvalidArg2() { - + public function testInvalidArg2() + { $obj = new CalendarObject( new Backend\Mock([], []), [], ['calendarid' => '1'] ); - } /** * @depends testSetup */ - function testPut() { - + public function testPut() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); $newData = TestUtil::getTestCalendarData(); $children[0]->put($newData); $this->assertEquals($newData, $children[0]->get()); - } /** * @depends testSetup */ - function testPutStream() { - + public function testPutStream() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); $newData = TestUtil::getTestCalendarData(); @@ -99,15 +95,13 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { rewind($stream); $children[0]->put($stream); $this->assertEquals($newData, $children[0]->get()); - } - /** * @depends testSetup */ - function testDelete() { - + public function testDelete() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); @@ -116,14 +110,13 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $children2 = $this->calendar->getChildren(); $this->assertEquals(count($children) - 1, count($children2)); - } /** * @depends testSetup */ - function testGetLastModified() { - + public function testGetLastModified() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); @@ -131,14 +124,13 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $lastMod = $obj->getLastModified(); $this->assertTrue(is_int($lastMod) || ctype_digit($lastMod) || is_null($lastMod)); - } /** * @depends testSetup */ - function testGetSize() { - + public function testGetSize() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); @@ -146,31 +138,28 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $size = $obj->getSize(); $this->assertInternalType('int', $size); - } - function testGetOwner() { - + public function testGetOwner() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); $obj = $children[0]; $this->assertEquals('principals/user1', $obj->getOwner()); - } - function testGetGroup() { - + public function testGetGroup() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); $obj = $children[0]; $this->assertNull($obj->getGroup()); - } - function testGetACL() { - + public function testGetACL() + { $expected = [ [ 'privilege' => '{DAV:}read', @@ -204,11 +193,10 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $obj = $children[0]; $this->assertEquals($expected, $obj->getACL()); - } - function testDefaultACL() { - + public function testDefaultACL() + { $backend = new Backend\Mock([], []); $calendarObject = new CalendarObject($backend, ['principaluri' => 'principals/user1'], ['calendarid' => 1, 'uri' => 'foo']); $expected = [ @@ -229,31 +217,28 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { ], ]; $this->assertEquals($expected, $calendarObject->getACL()); - - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACL() { - + public function testSetACL() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); $obj = $children[0]; $obj->setACL([]); - } - function testGet() { - + public function testGet() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); $obj = $children[0]; - $expected = "BEGIN:VCALENDAR + $expected = 'BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Apple Inc.//iCal 4.0.1//EN CALSCALE:GREGORIAN @@ -284,100 +269,91 @@ DTEND;TZID=Asia/Seoul:20100223T070000 ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com SEQUENCE:2 END:VEVENT -END:VCALENDAR"; - - +END:VCALENDAR'; $this->assertEquals($expected, $obj->get()); - } - function testGetRefetch() { - + public function testGetRefetch() + { $backend = new Backend\Mock([], [ 1 => [ 'foo' => [ 'calendardata' => 'foo', - 'uri' => 'foo' + 'uri' => 'foo', ], - ] + ], ]); $obj = new CalendarObject($backend, ['id' => 1], ['uri' => 'foo']); $this->assertEquals('foo', $obj->get()); - } - function testGetEtag1() { - + public function testGetEtag1() + { $objectInfo = [ 'calendardata' => 'foo', - 'uri' => 'foo', - 'etag' => 'bar', - 'calendarid' => 1 + 'uri' => 'foo', + 'etag' => 'bar', + 'calendarid' => 1, ]; $backend = new Backend\Mock([], []); $obj = new CalendarObject($backend, [], $objectInfo); $this->assertEquals('bar', $obj->getETag()); - } - function testGetEtag2() { - + public function testGetEtag2() + { $objectInfo = [ 'calendardata' => 'foo', - 'uri' => 'foo', - 'calendarid' => 1 + 'uri' => 'foo', + 'calendarid' => 1, ]; $backend = new Backend\Mock([], []); $obj = new CalendarObject($backend, [], $objectInfo); - $this->assertEquals('"' . md5('foo') . '"', $obj->getETag()); - + $this->assertEquals('"'.md5('foo').'"', $obj->getETag()); } - function testGetSupportedPrivilegesSet() { - + public function testGetSupportedPrivilegesSet() + { $objectInfo = [ 'calendardata' => 'foo', - 'uri' => 'foo', - 'calendarid' => 1 + 'uri' => 'foo', + 'calendarid' => 1, ]; $backend = new Backend\Mock([], []); $obj = new CalendarObject($backend, [], $objectInfo); $this->assertNull($obj->getSupportedPrivilegeSet()); - } - function testGetSize1() { - + public function testGetSize1() + { $objectInfo = [ 'calendardata' => 'foo', - 'uri' => 'foo', - 'calendarid' => 1 + 'uri' => 'foo', + 'calendarid' => 1, ]; $backend = new Backend\Mock([], []); $obj = new CalendarObject($backend, [], $objectInfo); $this->assertEquals(3, $obj->getSize()); - } - function testGetSize2() { - + public function testGetSize2() + { $objectInfo = [ - 'uri' => 'foo', + 'uri' => 'foo', 'calendarid' => 1, - 'size' => 4, + 'size' => 4, ]; $backend = new Backend\Mock([], []); $obj = new CalendarObject($backend, [], $objectInfo); $this->assertEquals(4, $obj->getSize()); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php index ca06d8ffa..660832ba4 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php @@ -1,17 +1,19 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\VObject; -class CalendarQueryVAlarmTest extends \PHPUnit_Framework_TestCase { - +class CalendarQueryVAlarmTest extends \PHPUnit\Framework\TestCase +{ /** * This test is specifically for a time-range query on a VALARM, contained - * in a VEVENT that's recurring + * in a VEVENT that's recurring. */ - function testValarm() { - + public function testValarm() + { $vcalendar = new VObject\Component\VCalendar(); $vevent = $vcalendar->createComponent('VEVENT'); @@ -23,29 +25,28 @@ class CalendarQueryVAlarmTest extends \PHPUnit_Framework_TestCase { $valarm->TRIGGER = '-P15D'; $vevent->add($valarm); - $vcalendar->add($vevent); $filter = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => [], - 'comp-filters' => [ + 'time-range' => null, + 'prop-filters' => [], + 'comp-filters' => [ [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => [], - 'comp-filters' => [ + 'time-range' => null, + 'prop-filters' => [], + 'comp-filters' => [ [ - 'name' => 'VALARM', + 'name' => 'VALARM', 'is-not-defined' => false, - 'prop-filters' => [], - 'comp-filters' => [], - 'time-range' => [ + 'prop-filters' => [], + 'comp-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2012-05-10'), - 'end' => new \DateTime('2012-05-20'), + 'end' => new \DateTime('2012-05-20'), ], ], ], @@ -73,8 +74,8 @@ class CalendarQueryVAlarmTest extends \PHPUnit_Framework_TestCase { $this->assertFalse($validator->validate($vcalendar, $filter)); } - function testAlarmWayBefore() { - + public function testAlarmWayBefore() + { $vcalendar = new VObject\Component\VCalendar(); $vevent = $vcalendar->createComponent('VEVENT'); @@ -88,25 +89,25 @@ class CalendarQueryVAlarmTest extends \PHPUnit_Framework_TestCase { $vcalendar->add($vevent); $filter = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => [], - 'comp-filters' => [ + 'time-range' => null, + 'prop-filters' => [], + 'comp-filters' => [ [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => [], - 'comp-filters' => [ + 'time-range' => null, + 'prop-filters' => [], + 'comp-filters' => [ [ - 'name' => 'VALARM', + 'name' => 'VALARM', 'is-not-defined' => false, - 'prop-filters' => [], - 'comp-filters' => [], - 'time-range' => [ + 'prop-filters' => [], + 'comp-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2011-12-10'), - 'end' => new \DateTime('2011-12-20'), + 'end' => new \DateTime('2011-12-20'), ], ], ], @@ -116,7 +117,5 @@ class CalendarQueryVAlarmTest extends \PHPUnit_Framework_TestCase { $validator = new CalendarQueryValidator(); $this->assertTrue($validator->validate($vcalendar, $filter)); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php index f3305163b..9dc8ce188 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\VObject; -class CalendarQueryValidatorTest extends \PHPUnit_Framework_TestCase { - - function testTopLevelFail() { - +class CalendarQueryValidatorTest extends \PHPUnit\Framework\TestCase +{ + public function testTopLevelFail() + { $validator = new CalendarQueryValidator(); $vcal = <<<ICS BEGIN:VCALENDAR @@ -17,39 +19,38 @@ END:VCALENDAR ICS; $vcal = VObject\Reader::read($vcal); $this->assertFalse($validator->validate($vcal, ['name' => 'VFOO'])); - } /** * @param string $icalObject - * @param array $filters - * @param int $outcome + * @param array $filters + * @param int $outcome * @dataProvider provider */ - function testValid($icalObject, $filters, $outcome) { - + public function testValid($icalObject, $filters, $outcome) + { $validator = new CalendarQueryValidator(); // Wrapping filter in a VCALENDAR component filter, as this is always // there anyway. $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [$filters], - 'prop-filters' => [], + 'name' => 'VCALENDAR', + 'comp-filters' => [$filters], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $vObject = VObject\Reader::read($icalObject); switch ($outcome) { - case 0 : + case 0: $this->assertFalse($validator->validate($vObject, $filters)); break; - case 1 : + case 1: $this->assertTrue($validator->validate($vObject, $filters)); break; - case -1 : + case -1: try { $validator->validate($vObject, $filters); $this->fail('This test was supposed to fail'); @@ -62,13 +63,11 @@ ICS; $this->assertTrue(true); } break; - } - } - function provider() { - + public function provider() + { $blob1 = <<<yow BEGIN:VCALENDAR BEGIN:VEVENT @@ -194,7 +193,6 @@ END:VTODO END:VCALENDAR yow; - $blob16 = <<<yow BEGIN:VCALENDAR BEGIN:VTODO @@ -301,7 +299,6 @@ END:VEVENT END:VCALENDAR yow; - $blob27 = <<<yow BEGIN:VCALENDAR BEGIN:VTODO @@ -396,11 +393,11 @@ END:VCALENDAR yow; $filter1 = [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $filter2 = $filter1; $filter2['name'] = 'VTODO'; @@ -415,21 +412,21 @@ yow; $filter5 = $filter1; $filter5['comp-filters'] = [ [ - 'name' => 'VALARM', + 'name' => 'VALARM', 'is-not-defined' => false, - 'comp-filters' => [], - 'prop-filters' => [], - 'time-range' => null, + 'comp-filters' => [], + 'prop-filters' => [], + 'time-range' => null, ], ]; $filter6 = $filter1; $filter6['prop-filters'] = [ [ - 'name' => 'SUMMARY', + 'name' => 'SUMMARY', 'is-not-defined' => false, - 'param-filters' => [], - 'time-range' => null, - 'text-match' => null, + 'param-filters' => [], + 'time-range' => null, + 'text-match' => null, ], ]; $filter7 = $filter6; @@ -448,13 +445,13 @@ yow; $filter11 = $filter1; $filter11['prop-filters'] = [ [ - 'name' => 'DTSTART', + 'name' => 'DTSTART', 'is-not-defined' => false, - 'param-filters' => [ + 'param-filters' => [ [ - 'name' => 'VALUE', + 'name' => 'VALUE', 'is-not-defined' => false, - 'text-match' => null, + 'text-match' => null, ], ], 'time-range' => null, @@ -474,8 +471,8 @@ yow; // Param text filter $filter15 = $filter11; $filter15['prop-filters'][0]['param-filters'][0]['text-match'] = [ - 'collation' => 'i;ascii-casemap', - 'value' => 'dAtE', + 'collation' => 'i;ascii-casemap', + 'value' => 'dAtE', 'negate-condition' => false, ]; $filter16 = $filter15; @@ -492,13 +489,13 @@ yow; $filter19 = $filter5; $filter19['comp-filters'][0]['prop-filters'] = [ [ - 'name' => 'action', + 'name' => 'action', 'is-not-defined' => false, - 'time-range' => null, - 'param-filters' => [], - 'text-match' => [ - 'collation' => 'i;ascii-casemap', - 'value' => 'display', + 'time-range' => null, + 'param-filters' => [], + 'text-match' => [ + 'collation' => 'i;ascii-casemap', + 'value' => 'display', 'negate-condition' => false, ], ], @@ -506,13 +503,13 @@ yow; // Time range $filter20 = [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2011-01-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), ], ]; // Time range, no end date @@ -527,102 +524,102 @@ yow; $filter23 = $filter20; $filter23['time-range'] = [ 'start' => new \DateTime('2011-02-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), ]; // Time range $filter24 = [ - 'name' => 'VTODO', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VTODO', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2011-01-01 12:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), ], ]; // Time range, other dates (1 month in the future) $filter25 = $filter24; $filter25['time-range'] = [ 'start' => new \DateTime('2011-02-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), ]; $filter26 = $filter24; $filter26['time-range'] = [ 'start' => new \DateTime('2011-01-01 11:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), ]; // Time range for VJOURNAL $filter27 = [ - 'name' => 'VJOURNAL', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VJOURNAL', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2011-01-01 12:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), ], ]; $filter28 = $filter27; $filter28['time-range'] = [ 'start' => new \DateTime('2011-01-01 11:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), ]; // Time range for VFREEBUSY $filter29 = [ - 'name' => 'VFREEBUSY', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VFREEBUSY', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2011-01-01 12:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), ], ]; // Time range filter on property $filter30 = [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'comp-filters' => [], 'prop-filters' => [ [ - 'name' => 'DTSTART', + 'name' => 'DTSTART', 'is-not-defined' => false, - 'param-filters' => [], - 'time-range' => [ + 'param-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2011-01-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), ], 'text-match' => null, ], ], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; // Time range for alarm $filter31 = [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'prop-filters' => [], 'comp-filters' => [ [ - 'name' => 'VALARM', + 'name' => 'VALARM', 'is-not-defined' => false, - 'comp-filters' => [], - 'prop-filters' => [], - 'time-range' => [ + 'comp-filters' => [], + 'prop-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2011-01-01 10:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 11:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 11:15:00', new \DateTimeZone('GMT')), ], 'text-match' => null, ], ], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $filter32 = $filter31; $filter32['comp-filters'][0]['time-range'] = [ 'start' => new \DateTime('2011-01-01 11:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), ]; $filter33 = $filter31; @@ -636,55 +633,54 @@ yow; // Time range filter on non-datetime property $filter37 = [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'comp-filters' => [], 'prop-filters' => [ [ - 'name' => 'SUMMARY', + 'name' => 'SUMMARY', 'is-not-defined' => false, - 'param-filters' => [], - 'time-range' => [ + 'param-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2011-01-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), ], 'text-match' => null, ], ], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $filter38 = [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2012-07-01 00:00:00', new \DateTimeZone('UTC')), - 'end' => new \DateTime('2012-08-01 00:00:00', new \DateTimeZone('UTC')), - ] + 'end' => new \DateTime('2012-08-01 00:00:00', new \DateTimeZone('UTC')), + ], ]; $filter39 = [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'comp-filters' => [ [ - 'name' => 'VALARM', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VALARM', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2012-09-01 00:00:00', new \DateTimeZone('UTC')), - 'end' => new \DateTime('2012-10-01 00:00:00', new \DateTimeZone('UTC')), - ] + 'end' => new \DateTime('2012-10-01 00:00:00', new \DateTimeZone('UTC')), + ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; return [ - // Component check [$blob1, $filter1, 1], @@ -823,7 +819,5 @@ yow; // Event in timerange, but filtered alarm is in the far future (88). [$blob34, $filter39, 0], ]; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php index df85b6ded..7d6414a80 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV\PropPatch; require_once 'Sabre/CalDAV/TestUtil.php'; -class CalendarTest extends \PHPUnit_Framework_TestCase { - +class CalendarTest extends \PHPUnit\Framework\TestCase +{ /** * @var Sabre\CalDAV\Backend\PDO */ @@ -22,34 +24,30 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { */ protected $calendars; - function setup() { - + public function setup() + { $this->backend = TestUtil::getBackend(); $this->calendars = $this->backend->getCalendarsForUser('principals/user1'); $this->assertEquals(2, count($this->calendars)); $this->calendar = new Calendar($this->backend, $this->calendars[0]); - - } - function teardown() { - + public function teardown() + { unset($this->backend); - } - function testSimple() { - + public function testSimple() + { $this->assertEquals($this->calendars[0]['uri'], $this->calendar->getName()); - } /** * @depends testSimple */ - function testUpdateProperties() { - + public function testUpdateProperties() + { $propPatch = new PropPatch([ '{DAV:}displayname' => 'NewName', ]); @@ -61,87 +59,80 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { $calendars2 = $this->backend->getCalendarsForUser('principals/user1'); $this->assertEquals('NewName', $calendars2[0]['{DAV:}displayname']); - } /** * @depends testSimple */ - function testGetProperties() { - + public function testGetProperties() + { $question = [ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set', ]; $result = $this->calendar->getProperties($question); - foreach ($question as $q) $this->assertArrayHasKey($q, $result); + foreach ($question as $q) { + $this->assertArrayHasKey($q, $result); + } $this->assertEquals(['VEVENT', 'VTODO'], $result['{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set']->getValue()); - } /** - * @expectedException Sabre\DAV\Exception\NotFound + * @expectedException \Sabre\DAV\Exception\NotFound * @depends testSimple */ - function testGetChildNotFound() { - + public function testGetChildNotFound() + { $this->calendar->getChild('randomname'); - } /** * @depends testSimple */ - function testGetChildren() { - + public function testGetChildren() + { $children = $this->calendar->getChildren(); $this->assertEquals(1, count($children)); $this->assertTrue($children[0] instanceof CalendarObject); - } /** * @depends testGetChildren */ - function testChildExists() { - + public function testChildExists() + { $this->assertFalse($this->calendar->childExists('foo')); $children = $this->calendar->getChildren(); $this->assertTrue($this->calendar->childExists($children[0]->getName())); } - - /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ - function testCreateDirectory() { - + public function testCreateDirectory() + { $this->calendar->createDirectory('hello'); - } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ - function testSetName() { - + public function testSetName() + { $this->calendar->setName('hello'); - } - function testGetLastModified() { - + public function testGetLastModified() + { $this->assertNull($this->calendar->getLastModified()); - } - function testCreateFile() { - + public function testCreateFile() + { $file = fopen('php://memory', 'r+'); fwrite($file, TestUtil::getTestCalendarData()); rewind($file); @@ -150,11 +141,10 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { $file = $this->calendar->getChild('hello'); $this->assertTrue($file instanceof CalendarObject); - } - function testCreateFileNoSupportedComponents() { - + public function testCreateFileNoSupportedComponents() + { $file = fopen('php://memory', 'r+'); fwrite($file, TestUtil::getTestCalendarData()); rewind($file); @@ -164,31 +154,28 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { $file = $calendar->getChild('hello'); $this->assertTrue($file instanceof CalendarObject); - } - function testDelete() { - + public function testDelete() + { $this->calendar->delete(); $calendars = $this->backend->getCalendarsForUser('principals/user1'); $this->assertEquals(1, count($calendars)); } - function testGetOwner() { - + public function testGetOwner() + { $this->assertEquals('principals/user1', $this->calendar->getOwner()); - } - function testGetGroup() { - + public function testGetGroup() + { $this->assertNull($this->calendar->getGroup()); - } - function testGetACL() { - + public function testGetACL() + { $expected = [ [ 'privilege' => '{DAV:}read', @@ -206,7 +193,7 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], [ - 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', + 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true, ], @@ -222,35 +209,29 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { ], ]; $this->assertEquals($expected, $this->calendar->getACL()); - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACL() { - + public function testSetACL() + { $this->calendar->setACL([]); - } - function testGetSyncToken() { - + public function testGetSyncToken() + { $this->assertNull($this->calendar->getSyncToken()); - } - function testGetSyncTokenNoSyncSupport() { - + public function testGetSyncTokenNoSyncSupport() + { $calendar = new Calendar(new Backend\Mock([], []), []); $this->assertNull($calendar->getSyncToken()); - } - function testGetChanges() { - + public function testGetChanges() + { $this->assertNull($this->calendar->getChanges(1, 1)); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php index 9a3d47828..49252744d 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php @@ -1,29 +1,31 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\HTTP; use Sabre\VObject; /** - * This unittests is created to find out why recurring events have wrong DTSTART value + * This unittests is created to find out why recurring events have wrong DTSTART value. * * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ExpandEventsDTSTARTandDTENDTest extends \Sabre\DAVServerTest { - +class ExpandEventsDTSTARTandDTENDTest extends \Sabre\DAVServerTest +{ protected $setupCalDAV = true; protected $caldavCalendars = [ [ - 'id' => 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -52,13 +54,13 @@ END:VCALENDAR ], ]; - function testExpand() { - + public function testExpand() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody('<?xml version="1.0" encoding="utf-8" ?> @@ -91,7 +93,7 @@ END:VCALENDAR try { $vObject = VObject\Reader::read($body); } catch (VObject\ParseException $e) { - $this->fail('Could not parse object. Error:' . $e->getMessage() . ' full object: ' . $response->getBodyAsString()); + $this->fail('Could not parse object. Error:'.$e->getMessage().' full object: '.$response->getBodyAsString()); } // check if DTSTARTs and DTENDs are correct @@ -99,15 +101,14 @@ END:VCALENDAR /** @var $vevent Sabre\VObject\Component\VEvent */ foreach ($vevent->children() as $child) { /** @var $child Sabre\VObject\Property */ - if ($child->name == 'DTSTART') { + if ('DTSTART' == $child->name) { // DTSTART has to be one of three valid values - $this->assertContains($child->getValue(), ['20120207T171500Z', '20120208T171500Z', '20120209T171500Z'], 'DTSTART is not a valid value: ' . $child->getValue()); - } elseif ($child->name == 'DTEND') { + $this->assertContains($child->getValue(), ['20120207T171500Z', '20120208T171500Z', '20120209T171500Z'], 'DTSTART is not a valid value: '.$child->getValue()); + } elseif ('DTEND' == $child->name) { // DTEND has to be one of three valid values - $this->assertContains($child->getValue(), ['20120207T181500Z', '20120208T181500Z', '20120209T181500Z'], 'DTEND is not a valid value: ' . $child->getValue()); + $this->assertContains($child->getValue(), ['20120207T181500Z', '20120208T181500Z', '20120209T181500Z'], 'DTEND is not a valid value: '.$child->getValue()); } } } } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php index efc49673f..3a982fcfa 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php @@ -1,28 +1,30 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\HTTP; use Sabre\VObject; /** - * This unittests is created to find out why recurring events have wrong DTSTART value + * This unittests is created to find out why recurring events have wrong DTSTART value. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ExpandEventsDTSTARTandDTENDbyDayTest extends \Sabre\DAVServerTest { - +class ExpandEventsDTSTARTandDTENDbyDayTest extends \Sabre\DAVServerTest +{ protected $setupCalDAV = true; protected $caldavCalendars = [ [ - 'id' => 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -43,13 +45,13 @@ END:VCALENDAR ], ]; - function testExpandRecurringByDayEvent() { - + public function testExpandRecurringByDayEvent() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody('<?xml version="1.0" encoding="utf-8" ?> @@ -88,15 +90,14 @@ END:VCALENDAR /** @var $vevent Sabre\VObject\Component\VEvent */ foreach ($vevent->children() as $child) { /** @var $child Sabre\VObject\Property */ - if ($child->name == 'DTSTART') { + if ('DTSTART' == $child->name) { // DTSTART has to be one of two valid values - $this->assertContains($child->getValue(), ['20120214T171500Z', '20120216T171500Z'], 'DTSTART is not a valid value: ' . $child->getValue()); - } elseif ($child->name == 'DTEND') { + $this->assertContains($child->getValue(), ['20120214T171500Z', '20120216T171500Z'], 'DTSTART is not a valid value: '.$child->getValue()); + } elseif ('DTEND' == $child->name) { // DTEND has to be one of two valid values - $this->assertContains($child->getValue(), ['20120214T181500Z', '20120216T181500Z'], 'DTEND is not a valid value: ' . $child->getValue()); + $this->assertContains($child->getValue(), ['20120214T181500Z', '20120216T181500Z'], 'DTEND is not a valid value: '.$child->getValue()); } } } } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php index 3a22e03d4..90897f1c5 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\HTTP; @@ -15,17 +17,17 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ExpandEventsDoubleEventsTest extends \Sabre\DAVServerTest { - +class ExpandEventsDoubleEventsTest extends \Sabre\DAVServerTest +{ protected $setupCalDAV = true; protected $caldavCalendars = [ [ - 'id' => 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -54,13 +56,13 @@ END:VCALENDAR ], ]; - function testExpand() { - + public function testExpand() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody('<?xml version="1.0" encoding="utf-8" ?> @@ -93,11 +95,9 @@ END:VCALENDAR $vObject = VObject\Reader::read($body); // We only expect 3 events - $this->assertEquals(3, count($vObject->VEVENT), 'We got 6 events instead of 3. Output: ' . $body); + $this->assertEquals(3, count($vObject->VEVENT), 'We got 6 events instead of 3. Output: '.$body); // TZID should be gone $this->assertFalse(isset($vObject->VEVENT->DTSTART['TZID'])); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php index 7604c7f4c..3d4b36313 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php @@ -1,15 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; use Sabre\HTTP; -require_once 'Sabre/CalDAV/Backend/Mock.php'; -require_once 'Sabre/HTTP/ResponseMock.php'; - -class FreeBusyReportTest extends \PHPUnit_Framework_TestCase { - +class FreeBusyReportTest extends \PHPUnit\Framework\TestCase +{ /** * @var Plugin */ @@ -19,8 +18,8 @@ class FreeBusyReportTest extends \PHPUnit_Framework_TestCase { */ protected $server; - function setUp() { - + public function setUp() + { $obj1 = <<<ics BEGIN:VCALENDAR BEGIN:VEVENT @@ -54,48 +53,44 @@ ics; $calendarData = [ 1 => [ 'obj1' => [ - 'calendarid' => 1, - 'uri' => 'event1.ics', + 'calendarid' => 1, + 'uri' => 'event1.ics', 'calendardata' => $obj1, ], 'obj2' => [ - 'calendarid' => 1, - 'uri' => 'event2.ics', - 'calendardata' => $obj2 + 'calendarid' => 1, + 'uri' => 'event2.ics', + 'calendardata' => $obj2, ], 'obj3' => [ - 'calendarid' => 1, - 'uri' => 'event3.ics', - 'calendardata' => $obj3 - ] + 'calendarid' => 1, + 'uri' => 'event3.ics', + 'calendardata' => $obj3, + ], ], ]; - $caldavBackend = new Backend\Mock([], $calendarData); $calendar = new Calendar($caldavBackend, [ - 'id' => 1, - 'uri' => 'calendar', - 'principaluri' => 'principals/user1', - '{' . Plugin::NS_CALDAV . '}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR", + 'id' => 1, + 'uri' => 'calendar', + 'principaluri' => 'principals/user1', + '{'.Plugin::NS_CALDAV.'}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR", ]); $this->server = new DAV\Server([$calendar]); - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/calendar', - ]); + $request = new HTTP\Request('GET', '/calendar'); $this->server->httpRequest = $request; $this->server->httpResponse = new HTTP\ResponseMock(); $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); - } - function testFreeBusyReport() { - + public function testFreeBusyReport() + { $reportXML = <<<XML <?xml version="1.0"?> <c:free-busy-query xmlns:c="urn:ietf:params:xml:ns:caldav"> @@ -108,17 +103,16 @@ XML; $this->assertEquals(200, $this->server->httpResponse->status); $this->assertEquals('text/calendar', $this->server->httpResponse->getHeader('Content-Type')); - $this->assertTrue(strpos($this->server->httpResponse->body, 'BEGIN:VFREEBUSY') !== false); - $this->assertTrue(strpos($this->server->httpResponse->body, '20111005T120000Z/20111005T130000Z') !== false); - $this->assertTrue(strpos($this->server->httpResponse->body, '20111006T100000Z/20111006T110000Z') !== false); - + $this->assertTrue(false !== strpos($this->server->httpResponse->body, 'BEGIN:VFREEBUSY')); + $this->assertTrue(false !== strpos($this->server->httpResponse->body, '20111005T120000Z/20111005T130000Z')); + $this->assertTrue(false !== strpos($this->server->httpResponse->body, '20111006T100000Z/20111006T110000Z')); } /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ - function testFreeBusyReportNoTimeRange() { - + public function testFreeBusyReportNoTimeRange() + { $reportXML = <<<XML <?xml version="1.0"?> <c:free-busy-query xmlns:c="urn:ietf:params:xml:ns:caldav"> @@ -126,17 +120,14 @@ XML; XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); - } /** - * @expectedException Sabre\DAV\Exception\NotImplemented + * @expectedException \Sabre\DAV\Exception\NotImplemented */ - function testFreeBusyReportWrongNode() { - - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/', - ]); + public function testFreeBusyReportWrongNode() + { + $request = new HTTP\Request('REPORT', '/'); $this->server->httpRequest = $request; $reportXML = <<<XML @@ -148,15 +139,15 @@ XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); $this->plugin->report($rootElem, $report, null); - } /** - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testFreeBusyReportNoACLPlugin() { - + public function testFreeBusyReportNoACLPlugin() + { $this->server = new DAV\Server(); + $this->server->httpRequest = new HTTP\Request('REPORT', '/'); $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); @@ -169,6 +160,5 @@ XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); $this->plugin->report($rootElem, $report, null); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php index 5fd8d29a1..6cb2b609e 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php @@ -1,27 +1,29 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\HTTP; /** - * This unittest is created to check if queries for time-range include the start timestamp or not + * This unittest is created to check if queries for time-range include the start timestamp or not. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class GetEventsByTimerangeTest extends \Sabre\DAVServerTest { - +class GetEventsByTimerangeTest extends \Sabre\DAVServerTest +{ protected $setupCalDAV = true; protected $caldavCalendars = [ [ - 'id' => 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -45,14 +47,14 @@ END:VCALENDAR ], ]; - function testQueryTimerange() { - + public function testQueryTimerange() + { $request = new HTTP\Request( 'REPORT', '/calendars/user1/calendar1', [ 'Content-Type' => 'application/xml', - 'Depth' => '1', + 'Depth' => '1', ] ); @@ -75,8 +77,6 @@ END:VCALENDAR $response = $this->request($request); - $this->assertTrue(strpos($response->body, 'BEGIN:VCALENDAR') !== false); - + $this->assertTrue(false !== strpos($response->body, 'BEGIN:VCALENDAR')); } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php index 75412577e..c139e5b5c 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; @@ -7,14 +9,14 @@ use Sabre\DAVACL; use Sabre\HTTP; use Sabre\VObject; -class ICSExportPluginTest extends \Sabre\DAVServerTest { - +class ICSExportPluginTest extends \Sabre\DAVServerTest +{ protected $setupCalDAV = true; protected $icsExportPlugin; - function setUp() { - + public function setUp() + { parent::setUp(); $this->icsExportPlugin = new ICSExportPlugin(); $this->server->addPlugin( @@ -25,7 +27,7 @@ class ICSExportPluginTest extends \Sabre\DAVServerTest { 'principals/admin', 'UUID-123467', [ - '{DAV:}displayname' => 'Hello!', + '{DAV:}displayname' => 'Hello!', '{http://apple.com/ns/ical/}calendar-color' => '#AA0000FF', ] ); @@ -56,23 +58,20 @@ END:VTODO END:VCALENDAR ICS ); - - } - function testInit() { - + public function testInit() + { $this->assertEquals( $this->icsExportPlugin, $this->server->getPlugin('ics-export') ); $this->assertEquals($this->icsExportPlugin, $this->server->getPlugin('ics-export')); $this->assertEquals('ics-export', $this->icsExportPlugin->getPluginInfo()['name']); - } - function testBeforeMethod() { - + public function testBeforeMethod() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export' @@ -89,15 +88,15 @@ ICS $this->assertEquals(1, count($obj->VERSION)); $this->assertEquals(1, count($obj->CALSCALE)); $this->assertEquals(1, count($obj->PRODID)); - $this->assertTrue(strpos((string)$obj->PRODID, DAV\Version::VERSION) !== false); + $this->assertTrue(false !== strpos((string) $obj->PRODID, DAV\Version::VERSION)); $this->assertEquals(1, count($obj->VTIMEZONE)); $this->assertEquals(1, count($obj->VEVENT)); - $this->assertEquals("Hello!", $obj->{"X-WR-CALNAME"}); - $this->assertEquals("#AA0000FF", $obj->{"X-APPLE-CALENDAR-COLOR"}); - + $this->assertEquals('Hello!', $obj->{'X-WR-CALNAME'}); + $this->assertEquals('#AA0000FF', $obj->{'X-APPLE-CALENDAR-COLOR'}); } - function testBeforeMethodNoVersion() { + public function testBeforeMethodNoVersion() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export' @@ -115,25 +114,23 @@ ICS $this->assertEquals(1, count($obj->VERSION)); $this->assertEquals(1, count($obj->CALSCALE)); $this->assertEquals(1, count($obj->PRODID)); - $this->assertFalse(strpos((string)$obj->PRODID, DAV\Version::VERSION) !== false); + $this->assertFalse(false !== strpos((string) $obj->PRODID, DAV\Version::VERSION)); $this->assertEquals(1, count($obj->VTIMEZONE)); $this->assertEquals(1, count($obj->VEVENT)); - } - function testBeforeMethodNoExport() { - + public function testBeforeMethodNoExport() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467' ); $response = new HTTP\Response(); $this->assertNull($this->icsExportPlugin->httpGet($request, $response)); - } - function testACLIntegrationBlocked() { - + public function testACLIntegrationBlocked() + { $aclPlugin = new DAVACL\Plugin(); $aclPlugin->allowUnauthenticatedAccess = false; $this->server->addPlugin( @@ -146,11 +143,10 @@ ICS ); $this->request($request, 403); - } - function testACLIntegrationNotBlocked() { - + public function testACLIntegrationNotBlocked() + { $aclPlugin = new DAVACL\Plugin(); $aclPlugin->allowUnauthenticatedAccess = false; $this->server->addPlugin( @@ -176,34 +172,31 @@ ICS $this->assertEquals(1, count($obj->VERSION)); $this->assertEquals(1, count($obj->CALSCALE)); $this->assertEquals(1, count($obj->PRODID)); - $this->assertTrue(strpos((string)$obj->PRODID, DAV\Version::VERSION) !== false); + $this->assertTrue(false !== strpos((string) $obj->PRODID, DAV\Version::VERSION)); $this->assertEquals(1, count($obj->VTIMEZONE)); $this->assertEquals(1, count($obj->VEVENT)); - } - function testBadStartParam() { - + public function testBadStartParam() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&start=foo' ); $this->request($request, 400); - } - function testBadEndParam() { - + public function testBadEndParam() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&end=foo' ); $this->request($request, 400); - } - function testFilterStartEnd() { - + public function testFilterStartEnd() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&start=1&end=2' @@ -212,23 +205,21 @@ ICS $obj = VObject\Reader::read($response->getBody()); - $this->assertEquals(0, count($obj->VTIMEZONE)); - $this->assertEquals(0, count($obj->VEVENT)); - + $this->assertNull($obj->VTIMEZONE); + $this->assertNull($obj->VEVENT); } - function testExpandNoStart() { - + public function testExpandNoStart() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&expand=1&end=2' ); $this->request($request, 400); - } - function testExpand() { - + public function testExpand() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&start=1&end=2000000000&expand=1' @@ -237,13 +228,12 @@ ICS $obj = VObject\Reader::read($response->getBody()); - $this->assertEquals(0, count($obj->VTIMEZONE)); + $this->assertNull($obj->VTIMEZONE); $this->assertEquals(1, count($obj->VEVENT)); - } - function testJCal() { - + public function testJCal() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export', @@ -252,11 +242,10 @@ ICS $response = $this->request($request, 200); $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); - } - function testJCalInUrl() { - + public function testJCalInUrl() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&accept=jcal' @@ -264,11 +253,10 @@ ICS $response = $this->request($request, 200); $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); - } - function testNegotiateDefault() { - + public function testNegotiateDefault() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export', @@ -277,11 +265,10 @@ ICS $response = $this->request($request, 200); $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); - } - function testFilterComponentVEVENT() { - + public function testFilterComponentVEVENT() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&componentType=VEVENT' @@ -292,12 +279,11 @@ ICS $obj = VObject\Reader::read($response->body); $this->assertEquals(1, count($obj->VTIMEZONE)); $this->assertEquals(1, count($obj->VEVENT)); - $this->assertEquals(0, count($obj->VTODO)); - + $this->assertNull($obj->VTODO); } - function testFilterComponentVTODO() { - + public function testFilterComponentVTODO() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&componentType=VTODO' @@ -307,25 +293,23 @@ ICS $obj = VObject\Reader::read($response->body); - $this->assertEquals(0, count($obj->VTIMEZONE)); - $this->assertEquals(0, count($obj->VEVENT)); + $this->assertNull($obj->VTIMEZONE); + $this->assertNull($obj->VEVENT); $this->assertEquals(1, count($obj->VTODO)); - } - function testFilterComponentBadComponent() { - + public function testFilterComponentBadComponent() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&componentType=VVOODOO' ); $response = $this->request($request, 400); - } - function testContentDisposition() { - + public function testContentDisposition() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export' @@ -334,14 +318,13 @@ ICS $response = $this->request($request, 200); $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); $this->assertEquals( - 'attachment; filename="UUID-123467-' . date('Y-m-d') . '.ics"', + 'attachment; filename="UUID-123467-'.date('Y-m-d').'.ics"', $response->getHeader('Content-Disposition') ); - } - function testContentDispositionJson() { - + public function testContentDispositionJson() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export', @@ -351,19 +334,18 @@ ICS $response = $this->request($request, 200); $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); $this->assertEquals( - 'attachment; filename="UUID-123467-' . date('Y-m-d') . '.json"', + 'attachment; filename="UUID-123467-'.date('Y-m-d').'.json"', $response->getHeader('Content-Disposition') ); - } - function testContentDispositionBadChars() { - + public function testContentDispositionBadChars() + { $this->caldavBackend->createCalendar( 'principals/admin', 'UUID-b_ad"(ch)ars', [ - '{DAV:}displayname' => 'Test bad characters', + '{DAV:}displayname' => 'Test bad characters', '{http://apple.com/ns/ical/}calendar-color' => '#AA0000FF', ] ); @@ -377,10 +359,8 @@ ICS $response = $this->request($request, 200); $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); $this->assertEquals( - 'attachment; filename="UUID-b_adchars-' . date('Y-m-d') . '.json"', + 'attachment; filename="UUID-b_adchars-'.date('Y-m-d').'.json"', $response->getHeader('Content-Disposition') ); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php index a1a9b7c04..02d39fe84 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\VObject; -class Issue166Test extends \PHPUnit_Framework_TestCase { - - function testFlaw() { - +class Issue166Test extends \PHPUnit\Framework\TestCase +{ + public function testFlaw() + { $input = <<<HI BEGIN:VCALENDAR PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN @@ -38,26 +40,24 @@ HI; $validator = new CalendarQueryValidator(); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2011-12-01'), - 'end' => new \DateTime('2012-02-01'), + 'end' => new \DateTime('2012-02-01'), ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $input = VObject\Reader::read($input); $this->assertTrue($validator->validate($input, $filters)); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php index e2b85c2bc..83120fe6a 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php @@ -1,13 +1,16 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\VObject; -class Issue172Test extends \PHPUnit_Framework_TestCase { - +class Issue172Test extends \PHPUnit\Framework\TestCase +{ // DateTimeZone() native name: America/Los_Angeles (GMT-8 in January) - function testBuiltInTimezoneName() { + public function testBuiltInTimezoneName() + { $input = <<<HI BEGIN:VCALENDAR VERSION:2.0 @@ -19,16 +22,16 @@ END:VCALENDAR HI; $validator = new CalendarQueryValidator(); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2012-01-18 21:00:00 GMT-08:00'), - 'end' => new \DateTime('2012-01-18 21:00:00 GMT-08:00'), + 'end' => new \DateTime('2012-01-18 21:00:00 GMT-08:00'), ], ], ], @@ -39,7 +42,8 @@ HI; } // Pacific Standard Time, translates to America/Los_Angeles (GMT-8 in January) - function testOutlookTimezoneName() { + public function testOutlookTimezoneName() + { $input = <<<HI BEGIN:VCALENDAR VERSION:2.0 @@ -66,16 +70,16 @@ END:VCALENDAR HI; $validator = new CalendarQueryValidator(); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), - 'end' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), + 'end' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), ], ], ], @@ -86,7 +90,8 @@ HI; } // X-LIC-LOCATION, translates to America/Los_Angeles (GMT-8 in January) - function testLibICalLocationName() { + public function testLibICalLocationName() + { $input = <<<HI BEGIN:VCALENDAR VERSION:2.0 @@ -114,16 +119,16 @@ END:VCALENDAR HI; $validator = new CalendarQueryValidator(); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), - 'end' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), + 'end' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), ], ], ], diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php index 369e9a70c..0700024cf 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php @@ -1,28 +1,30 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\HTTP; use Sabre\VObject; /** - * This unittest is created to find out why an overwritten DAILY event has wrong DTSTART, DTEND, SUMMARY and RECURRENCEID + * This unittest is created to find out why an overwritten DAILY event has wrong DTSTART, DTEND, SUMMARY and RECURRENCEID. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Issue203Test extends \Sabre\DAVServerTest { - +class Issue203Test extends \Sabre\DAVServerTest +{ protected $setupCalDAV = true; protected $caldavCalendars = [ [ - 'id' => 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -56,13 +58,13 @@ END:VCALENDAR ], ]; - function testIssue203() { - + public function testIssue203() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody('<?xml version="1.0" encoding="utf-8" ?> @@ -96,24 +98,22 @@ END:VCALENDAR $this->assertEquals(2, count($vObject->VEVENT)); - $expectedEvents = [ [ 'DTSTART' => '20120326T135200Z', - 'DTEND' => '20120326T145200Z', + 'DTEND' => '20120326T145200Z', 'SUMMARY' => 'original summary', ], [ - 'DTSTART' => '20120328T135200Z', - 'DTEND' => '20120328T145200Z', - 'SUMMARY' => 'overwritten summary', + 'DTSTART' => '20120328T135200Z', + 'DTEND' => '20120328T145200Z', + 'SUMMARY' => 'overwritten summary', 'RECURRENCE-ID' => '20120327T135200Z', - ] + ], ]; // try to match agains $expectedEvents array foreach ($expectedEvents as $expectedEvent) { - $matching = false; foreach ($vObject->VEVENT as $vevent) { @@ -131,7 +131,7 @@ END:VCALENDAR break; } - $this->assertTrue($matching, 'Did not find the following event in the response: ' . var_export($expectedEvent, true)); + $this->assertTrue($matching, 'Did not find the following event in the response: '.var_export($expectedEvent, true)); } } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php index ce40a90b0..60c944d1d 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php @@ -1,28 +1,30 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\HTTP; use Sabre\VObject; /** - * This unittest is created to check if a VALARM TRIGGER of PT0S is supported + * This unittest is created to check if a VALARM TRIGGER of PT0S is supported. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Issue205Test extends \Sabre\DAVServerTest { - +class Issue205Test extends \Sabre\DAVServerTest +{ protected $setupCalDAV = true; protected $caldavCalendars = [ [ - 'id' => 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -49,13 +51,13 @@ END:VCALENDAR ], ]; - function testIssue205() { - + public function testIssue205() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody('<?xml version="1.0" encoding="utf-8" ?> @@ -79,8 +81,8 @@ END:VCALENDAR $response = $this->request($request); - $this->assertFalse(strpos($response->body, '<s:exception>Exception</s:exception>'), 'Exception occurred: ' . $response->body); - $this->assertFalse(strpos($response->body, 'Unknown or bad format'), 'DateTime unknown format Exception: ' . $response->body); + $this->assertFalse(strpos($response->body, '<s:exception>Exception</s:exception>'), 'Exception occurred: '.$response->body); + $this->assertFalse(strpos($response->body, 'Unknown or bad format'), 'DateTime unknown format Exception: '.$response->body); // Everts super awesome xml parser. $body = substr( @@ -93,6 +95,5 @@ END:VCALENDAR $vObject = VObject\Reader::read($body); $this->assertEquals(1, count($vObject->VEVENT)); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php index 950629fd8..10c9af50c 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php @@ -1,27 +1,29 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\HTTP; /** - * This unittest is created to check for an endless loop in Sabre\CalDAV\CalendarQueryValidator + * This unittest is created to check for an endless loop in Sabre\CalDAV\CalendarQueryValidator. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Issue211Test extends \Sabre\DAVServerTest { - +class Issue211Test extends \Sabre\DAVServerTest +{ protected $setupCalDAV = true; protected $caldavCalendars = [ [ - 'id' => 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -53,13 +55,13 @@ END:VCALENDAR ], ]; - function testIssue211() { - + public function testIssue211() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody('<?xml version="1.0" encoding="utf-8" ?> @@ -84,6 +86,5 @@ END:VCALENDAR // if this assert is reached, the endless loop is gone // There should be no matching events $this->assertFalse(strpos('BEGIN:VEVENT', $response->body)); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php index c3c0b5b48..46f5ca205 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php @@ -1,27 +1,29 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\HTTP; /** - * This unittest is created to check for an endless loop in CalendarQueryValidator + * This unittest is created to check for an endless loop in CalendarQueryValidator. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Issue220Test extends \Sabre\DAVServerTest { - +class Issue220Test extends \Sabre\DAVServerTest +{ protected $setupCalDAV = true; protected $caldavCalendars = [ [ - 'id' => 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -63,13 +65,13 @@ END:VCALENDAR ], ]; - function testIssue220() { - + public function testIssue220() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody('<?xml version="1.0" encoding="utf-8" ?> @@ -91,8 +93,8 @@ END:VCALENDAR $response = $this->request($request); - $this->assertFalse(strpos($response->body, '<s:exception>PHPUnit_Framework_Error_Warning</s:exception>'), 'Error Warning occurred: ' . $response->body); - $this->assertFalse(strpos($response->body, 'Invalid argument supplied for foreach()'), 'Invalid argument supplied for foreach(): ' . $response->body); + $this->assertFalse(strpos($response->body, '<s:exception>PHPUnit_Framework_Error_Warning</s:exception>'), 'Error Warning occurred: '.$response->body); + $this->assertFalse(strpos($response->body, 'Invalid argument supplied for foreach()'), 'Invalid argument supplied for foreach(): '.$response->body); $this->assertEquals(207, $response->status); } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php index d0783701d..a8b855ca3 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php @@ -1,27 +1,29 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\HTTP; /** - * This unittest is created to check if the time-range filter is working correctly with all-day-events + * This unittest is created to check if the time-range filter is working correctly with all-day-events. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Issue228Test extends \Sabre\DAVServerTest { - +class Issue228Test extends \Sabre\DAVServerTest +{ protected $setupCalDAV = true; protected $caldavCalendars = [ [ - 'id' => 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -43,13 +45,13 @@ END:VCALENDAR ], ]; - function testIssue228() { - + public function testIssue228() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody('<?xml version="1.0" encoding="utf-8" ?> @@ -74,6 +76,5 @@ END:VCALENDAR // We must check if absolutely nothing was returned from this query. $this->assertFalse(strpos($response->body, 'BEGIN:VCALENDAR')); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php index 6585f85c3..eceb0b87f 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php @@ -1,58 +1,56 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Notifications; use Sabre\CalDAV; -class CollectionTest extends \PHPUnit_Framework_TestCase { - +class CollectionTest extends \PHPUnit\Framework\TestCase +{ protected $caldavBackend; protected $principalUri; protected $notification; - function getInstance() { - + public function getInstance() + { $this->principalUri = 'principals/user1'; $this->notification = new CalDAV\Xml\Notification\SystemStatus(1, '"1"'); $this->caldavBackend = new CalDAV\Backend\MockSharing([], [], [ 'principals/user1' => [ - $this->notification - ] + $this->notification, + ], ]); return new Collection($this->caldavBackend, $this->principalUri); - } - function testGetChildren() { - + public function testGetChildren() + { $col = $this->getInstance(); $this->assertEquals('notifications', $col->getName()); $this->assertEquals([ - new Node($this->caldavBackend, $this->principalUri, $this->notification) + new Node($this->caldavBackend, $this->principalUri, $this->notification), ], $col->getChildren()); - } - function testGetOwner() { - + public function testGetOwner() + { $col = $this->getInstance(); $this->assertEquals('principals/user1', $col->getOwner()); - } - function testGetGroup() { - + public function testGetGroup() + { $col = $this->getInstance(); $this->assertNull($col->getGroup()); - } - function testGetACL() { - + public function testGetACL() + { $col = $this->getInstance(); $expected = [ [ @@ -63,23 +61,20 @@ class CollectionTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $col->getACL()); - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACL() { - + public function testSetACL() + { $col = $this->getInstance(); $col->setACL([]); - } - function testGetSupportedPrivilegeSet() { - + public function testGetSupportedPrivilegeSet() + { $col = $this->getInstance(); $this->assertNull($col->getSupportedPrivilegeSet()); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php index 6c6e02da8..cb19ef962 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php @@ -1,69 +1,66 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Notifications; use Sabre\CalDAV; -class NodeTest extends \PHPUnit_Framework_TestCase { - +class NodeTest extends \PHPUnit\Framework\TestCase +{ protected $systemStatus; protected $caldavBackend; - function getInstance() { - + public function getInstance() + { $principalUri = 'principals/user1'; $this->systemStatus = new CalDAV\Xml\Notification\SystemStatus(1, '"1"'); $this->caldavBackend = new CalDAV\Backend\MockSharing([], [], [ 'principals/user1' => [ - $this->systemStatus - ] + $this->systemStatus, + ], ]); $node = new Node($this->caldavBackend, 'principals/user1', $this->systemStatus); - return $node; + return $node; } - function testGetId() { - + public function testGetId() + { $node = $this->getInstance(); - $this->assertEquals($this->systemStatus->getId() . '.xml', $node->getName()); - + $this->assertEquals($this->systemStatus->getId().'.xml', $node->getName()); } - function testGetEtag() { - + public function testGetEtag() + { $node = $this->getInstance(); $this->assertEquals('"1"', $node->getETag()); - } - function testGetNotificationType() { - + public function testGetNotificationType() + { $node = $this->getInstance(); $this->assertEquals($this->systemStatus, $node->getNotificationType()); - } - function testDelete() { - + public function testDelete() + { $node = $this->getInstance(); $node->delete(); $this->assertEquals([], $this->caldavBackend->getNotificationsForPrincipal('principals/user1')); - } - function testGetGroup() { - + public function testGetGroup() + { $node = $this->getInstance(); $this->assertNull($node->getGroup()); - } - function testGetACL() { - + public function testGetACL() + { $node = $this->getInstance(); $expected = [ [ @@ -74,23 +71,20 @@ class NodeTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $node->getACL()); - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACL() { - + public function testSetACL() + { $node = $this->getInstance(); $node->setACL([]); - } - function testGetSupportedPrivilegeSet() { - + public function testGetSupportedPrivilegeSet() + { $node = $this->getInstance(); $this->assertNull($node->getSupportedPrivilegeSet()); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php index 859f6aa0c..711cc0ac7 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use DateTime; @@ -8,8 +10,8 @@ use Sabre\DAV; use Sabre\DAVACL; use Sabre\HTTP; -class PluginTest extends \PHPUnit_Framework_TestCase { - +class PluginTest extends \PHPUnit\Framework\TestCase +{ /** * @var DAV\Server */ @@ -24,37 +26,37 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ protected $caldavBackend; - function setup() { - + public function setup() + { $caldavNS = '{urn:ietf:params:xml:ns:caldav}'; $this->caldavBackend = new Backend\Mock([ [ - 'id' => 1, - 'uri' => 'UUID-123467', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'user1 calendar', - $caldavNS . 'calendar-description' => 'Calendar description', - '{http://apple.com/ns/ical/}calendar-order' => '1', - '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', - $caldavNS . 'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), + 'id' => 1, + 'uri' => 'UUID-123467', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'user1 calendar', + $caldavNS.'calendar-description' => 'Calendar description', + '{http://apple.com/ns/ical/}calendar-order' => '1', + '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', + $caldavNS.'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), ], [ - 'id' => 2, - 'uri' => 'UUID-123468', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'user1 calendar2', - $caldavNS . 'calendar-description' => 'Calendar description', - '{http://apple.com/ns/ical/}calendar-order' => '1', - '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', - $caldavNS . 'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), - ] + 'id' => 2, + 'uri' => 'UUID-123468', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'user1 calendar2', + $caldavNS.'calendar-description' => 'Calendar description', + '{http://apple.com/ns/ical/}calendar-order' => '1', + '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', + $caldavNS.'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), + ], ], [ 1 => [ 'UUID-2345' => [ 'calendardata' => TestUtil::getTestCalendarData(), - ] - ] + ], + ], ]); $principalBackend = new DAVACL\PrincipalBackend\Mock(); $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', ['principals/user1']); @@ -89,41 +91,45 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $authBackend = new DAV\Auth\Backend\Mock(); $authBackend->setPrincipal('principals/user1'); $authPlugin = new DAV\Auth\Plugin($authBackend); - $authPlugin->beforeMethod(new \Sabre\HTTP\Request(), new \Sabre\HTTP\Response()); + $authPlugin->beforeMethod(new \Sabre\HTTP\Request('GET', '/'), new \Sabre\HTTP\Response()); $this->server->addPlugin($authPlugin); // This forces a login - $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $this->response = new HTTP\ResponseMock(); $this->server->httpResponse = $this->response; - } - function testSimple() { - + public function testSimple() + { $this->assertEquals(['MKCALENDAR'], $this->plugin->getHTTPMethods('calendars/user1/randomnewcalendar')); $this->assertEquals(['calendar-access', 'calendar-proxy'], $this->plugin->getFeatures()); $this->assertEquals( 'caldav', $this->plugin->getPluginInfo()['name'] ); - } - function testUnknownMethodPassThrough() { - + public function testUnknownMethodPassThrough() + { $request = new HTTP\Request('MKBREAKFAST', '/'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(501, $this->response->status, 'Incorrect status returned. Full response body:' . $this->response->body); - + $this->assertEquals(501, $this->response->status, 'Incorrect status returned. Full response body:'.$this->response->body); } - function testReportPassThrough() { + public function testGetWithoutContentType() + { + $request = new HTTP\Request('GET', '/'); + $this->plugin->httpAfterGet($request, $this->response); + $this->assertTrue(true); + } + public function testReportPassThrough() + { $request = new HTTP\Request('REPORT', '/', ['Content-Type' => 'application/xml']); $request->setBody('<?xml version="1.0"?><s:somereport xmlns:s="http://www.rooftopsolutions.nl/NS/example" />'); @@ -131,11 +137,10 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $this->server->exec(); $this->assertEquals(415, $this->response->status); - } - function testMkCalendarBadLocation() { - + public function testMkCalendarBadLocation() + { $request = new HTTP\Request('MKCALENDAR', '/blabla'); $body = '<?xml version="1.0" encoding="utf-8" ?> @@ -181,11 +186,10 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $this->server->exec(); $this->assertEquals(403, $this->response->status); - } - function testMkCalendarNoParentNode() { - + public function testMkCalendarNoParentNode() + { $request = new HTTP\Request('MKCALENDAR', '/doesntexist/calendar'); $body = '<?xml version="1.0" encoding="utf-8" ?> @@ -231,14 +235,13 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $this->server->exec(); $this->assertEquals(409, $this->response->status); - } - function testMkCalendarExistingCalendar() { - + public function testMkCalendarExistingCalendar() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'MKCALENDAR', - 'REQUEST_URI' => '/calendars/user1/UUID-123467', + 'REQUEST_URI' => '/calendars/user1/UUID-123467', ]); $body = '<?xml version="1.0" encoding="utf-8" ?> @@ -284,11 +287,10 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $this->server->exec(); $this->assertEquals(405, $this->response->status); - } - function testMkCalendarSucceed() { - + public function testMkCalendarSucceed() + { $request = new HTTP\Request('MKCALENDAR', '/calendars/user1/NEWCALENDAR'); $timezone = 'BEGIN:VCALENDAR @@ -325,7 +327,7 @@ END:VCALENDAR'; <C:supported-calendar-component-set> <C:comp name="VEVENT"/> </C:supported-calendar-component-set> - <C:calendar-timezone><![CDATA[' . $timezone . ']]></C:calendar-timezone> + <C:calendar-timezone><![CDATA['.$timezone.']]></C:calendar-timezone> </D:prop> </D:set> </C:mkcalendar>'; @@ -334,89 +336,87 @@ END:VCALENDAR'; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(201, $this->response->status, 'Invalid response code received. Full response body: ' . $this->response->body); + $this->assertEquals(201, $this->response->status, 'Invalid response code received. Full response body: '.$this->response->body); $calendars = $this->caldavBackend->getCalendarsForUser('principals/user1'); $this->assertEquals(3, count($calendars)); $newCalendar = null; foreach ($calendars as $calendar) { - if ($calendar['uri'] === 'NEWCALENDAR') { + if ('NEWCALENDAR' === $calendar['uri']) { $newCalendar = $calendar; break; - } + } } $this->assertInternalType('array', $newCalendar); $keys = [ - 'uri' => 'NEWCALENDAR', - 'id' => null, - '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar restricted to events.', - '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => $timezone, - '{DAV:}displayname' => 'Lisa\'s Events', + 'uri' => 'NEWCALENDAR', + 'id' => null, + '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar restricted to events.', + '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => $timezone, + '{DAV:}displayname' => 'Lisa\'s Events', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => null, ]; foreach ($keys as $key => $value) { - $this->assertArrayHasKey($key, $newCalendar); - if (is_null($value)) continue; + if (is_null($value)) { + continue; + } $this->assertEquals($value, $newCalendar[$key]); - } $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; $this->assertTrue($newCalendar[$sccs] instanceof Xml\Property\SupportedCalendarComponentSet); $this->assertEquals(['VEVENT'], $newCalendar[$sccs]->getValue()); - } - function testMkCalendarEmptyBodySucceed() { - + public function testMkCalendarEmptyBodySucceed() + { $request = new HTTP\Request('MKCALENDAR', '/calendars/user1/NEWCALENDAR'); $request->setBody(''); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(201, $this->response->status, 'Invalid response code received. Full response body: ' . $this->response->body); + $this->assertEquals(201, $this->response->status, 'Invalid response code received. Full response body: '.$this->response->body); $calendars = $this->caldavBackend->getCalendarsForUser('principals/user1'); $this->assertEquals(3, count($calendars)); $newCalendar = null; foreach ($calendars as $calendar) { - if ($calendar['uri'] === 'NEWCALENDAR') { + if ('NEWCALENDAR' === $calendar['uri']) { $newCalendar = $calendar; break; - } + } } $this->assertInternalType('array', $newCalendar); $keys = [ - 'uri' => 'NEWCALENDAR', - 'id' => null, + 'uri' => 'NEWCALENDAR', + 'id' => null, '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => null, ]; foreach ($keys as $key => $value) { - $this->assertArrayHasKey($key, $newCalendar); - if (is_null($value)) continue; + if (is_null($value)) { + continue; + } $this->assertEquals($value, $newCalendar[$key]); - } $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; $this->assertTrue($newCalendar[$sccs] instanceof Xml\Property\SupportedCalendarComponentSet); $this->assertEquals(['VEVENT', 'VTODO'], $newCalendar[$sccs]->getValue()); - } - function testMkCalendarBadXml() { - + public function testMkCalendarBadXml() + { $request = new HTTP\Request('MKCALENDAR', '/blabla'); $body = 'This is not xml'; @@ -425,26 +425,24 @@ END:VCALENDAR'; $this->server->exec(); $this->assertEquals(400, $this->response->status); - } - function testPrincipalProperties() { - + public function testPrincipalProperties() + { $httpRequest = new HTTP\Request('FOO', '/blabla', ['Host' => 'sabredav.org']); $this->server->httpRequest = $httpRequest; $props = $this->server->getPropertiesForPath('/principals/user1', [ - '{' . Plugin::NS_CALDAV . '}calendar-home-set', - '{' . Plugin::NS_CALENDARSERVER . '}calendar-proxy-read-for', - '{' . Plugin::NS_CALENDARSERVER . '}calendar-proxy-write-for', - '{' . Plugin::NS_CALENDARSERVER . '}notification-URL', - '{' . Plugin::NS_CALENDARSERVER . '}email-address-set', + '{'.Plugin::NS_CALDAV.'}calendar-home-set', + '{'.Plugin::NS_CALENDARSERVER.'}calendar-proxy-read-for', + '{'.Plugin::NS_CALENDARSERVER.'}calendar-proxy-write-for', + '{'.Plugin::NS_CALENDARSERVER.'}notification-URL', + '{'.Plugin::NS_CALENDARSERVER.'}email-address-set', ]); $this->assertArrayHasKey(0, $props); $this->assertArrayHasKey(200, $props[0]); - $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}calendar-home-set', $props[0][200]); $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-home-set']; $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $prop); @@ -460,15 +458,14 @@ END:VCALENDAR'; $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $prop); $this->assertEquals(['principals/admin/'], $prop->getHrefs()); - $this->assertArrayHasKey('{' . Plugin::NS_CALENDARSERVER . '}email-address-set', $props[0][200]); - $prop = $props[0][200]['{' . Plugin::NS_CALENDARSERVER . '}email-address-set']; + $this->assertArrayHasKey('{'.Plugin::NS_CALENDARSERVER.'}email-address-set', $props[0][200]); + $prop = $props[0][200]['{'.Plugin::NS_CALENDARSERVER.'}email-address-set']; $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\EmailAddressSet', $prop); $this->assertEquals(['user1.sabredav@sabredav.org'], $prop->getValue()); - } - function testSupportedReportSetPropertyNonCalendar() { - + public function testSupportedReportSetPropertyNonCalendar() + { $props = $this->server->getPropertiesForPath('/calendars/user1', [ '{DAV:}supported-report-set', ]); @@ -487,14 +484,13 @@ END:VCALENDAR'; '{DAV:}principal-search-property-set', ]; $this->assertEquals($value, $prop->getValue()); - } /** * @depends testSupportedReportSetPropertyNonCalendar */ - function testSupportedReportSetProperty() { - + public function testSupportedReportSetProperty() + { $props = $this->server->getPropertiesForPath('/calendars/user1/UUID-123467', [ '{DAV:}supported-report-set', ]); @@ -513,14 +509,13 @@ END:VCALENDAR'; '{DAV:}expand-property', '{DAV:}principal-match', '{DAV:}principal-property-search', - '{DAV:}principal-search-property-set' + '{DAV:}principal-search-property-set', ]; $this->assertEquals($value, $prop->getValue()); - } - function testSupportedReportSetUserCalendars() { - + public function testSupportedReportSetUserCalendars() + { $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); $props = $this->server->getPropertiesForPath('/calendars/user1', [ @@ -542,22 +537,21 @@ END:VCALENDAR'; '{DAV:}principal-search-property-set', ]; $this->assertEquals($value, $prop->getValue()); - } /** * @depends testSupportedReportSetProperty */ - function testCalendarMultiGetReport() { - + public function testCalendarMultiGetReport() + { $body = - '<?xml version="1.0"?>' . - '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . - '<d:prop>' . - ' <c:calendar-data />' . - ' <d:getetag />' . - '</d:prop>' . - '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>' . + '<?xml version="1.0"?>'. + '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. + '<d:prop>'. + ' <c:calendar-data />'. + ' <d:getetag />'. + '</d:prop>'. + '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>'. '</c:calendar-multiget>'; $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); @@ -587,24 +581,23 @@ END:VCALENDAR'; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } /** * @depends testCalendarMultiGetReport */ - function testCalendarMultiGetReportExpand() { - + public function testCalendarMultiGetReportExpand() + { $body = - '<?xml version="1.0"?>' . - '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . - '<d:prop>' . - ' <c:calendar-data>' . - ' <c:expand start="20110101T000000Z" end="20111231T235959Z" />' . - ' </c:calendar-data>' . - ' <d:getetag />' . - '</d:prop>' . - '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>' . + '<?xml version="1.0"?>'. + '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. + '<d:prop>'. + ' <c:calendar-data>'. + ' <c:expand start="20110101T000000Z" end="20111231T235959Z" />'. + ' </c:calendar-data>'. + ' <d:getetag />'. + '</d:prop>'. + '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>'. '</c:calendar-multiget>'; $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); @@ -613,7 +606,7 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Invalid HTTP status received. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Invalid HTTP status received. Full response body: '.$this->response->body); $expectedIcal = TestUtil::getTestCalendarData(); $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal); @@ -640,29 +633,28 @@ XML; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } /** * @depends testSupportedReportSetProperty * @depends testCalendarMultiGetReport */ - function testCalendarQueryReport() { - + public function testCalendarQueryReport() + { $body = - '<?xml version="1.0"?>' . - '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . - '<d:prop>' . - ' <c:calendar-data>' . - ' <c:expand start="20000101T000000Z" end="20101231T235959Z" />' . - ' </c:calendar-data>' . - ' <d:getetag />' . - '</d:prop>' . - '<c:filter>' . - ' <c:comp-filter name="VCALENDAR">' . - ' <c:comp-filter name="VEVENT" />' . - ' </c:comp-filter>' . - '</c:filter>' . + '<?xml version="1.0"?>'. + '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. + '<d:prop>'. + ' <c:calendar-data>'. + ' <c:expand start="20000101T000000Z" end="20101231T235959Z" />'. + ' </c:calendar-data>'. + ' <d:getetag />'. + '</d:prop>'. + '<c:filter>'. + ' <c:comp-filter name="VCALENDAR">'. + ' <c:comp-filter name="VEVENT" />'. + ' </c:comp-filter>'. + '</c:filter>'. '</c:calendar-query>'; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', ['Depth' => '1']); @@ -671,7 +663,7 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); $expectedIcal = TestUtil::getTestCalendarData(); $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal); @@ -698,33 +690,32 @@ XML; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } /** * @depends testSupportedReportSetProperty * @depends testCalendarMultiGetReport */ - function testCalendarQueryReportWindowsPhone() { - + public function testCalendarQueryReportWindowsPhone() + { $body = - '<?xml version="1.0"?>' . - '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . - '<d:prop>' . - ' <c:calendar-data>' . - ' <c:expand start="20000101T000000Z" end="20101231T235959Z" />' . - ' </c:calendar-data>' . - ' <d:getetag />' . - '</d:prop>' . - '<c:filter>' . - ' <c:comp-filter name="VCALENDAR">' . - ' <c:comp-filter name="VEVENT" />' . - ' </c:comp-filter>' . - '</c:filter>' . + '<?xml version="1.0"?>'. + '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. + '<d:prop>'. + ' <c:calendar-data>'. + ' <c:expand start="20000101T000000Z" end="20101231T235959Z" />'. + ' </c:calendar-data>'. + ' <d:getetag />'. + '</d:prop>'. + '<c:filter>'. + ' <c:comp-filter name="VCALENDAR">'. + ' <c:comp-filter name="VEVENT" />'. + ' </c:comp-filter>'. + '</c:filter>'. '</c:calendar-query>'; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', [ - 'Depth' => '0', + 'Depth' => '0', 'User-Agent' => 'MSFT-WP/8.10.14219 (gzip)', ]); @@ -733,7 +724,7 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); $expectedIcal = TestUtil::getTestCalendarData(); $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal); @@ -760,29 +751,28 @@ XML; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } /** * @depends testSupportedReportSetProperty * @depends testCalendarMultiGetReport */ - function testCalendarQueryReportBadDepth() { - + public function testCalendarQueryReportBadDepth() + { $body = - '<?xml version="1.0"?>' . - '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . - '<d:prop>' . - ' <c:calendar-data>' . - ' <c:expand start="20000101T000000Z" end="20101231T235959Z" />' . - ' </c:calendar-data>' . - ' <d:getetag />' . - '</d:prop>' . - '<c:filter>' . - ' <c:comp-filter name="VCALENDAR">' . - ' <c:comp-filter name="VEVENT" />' . - ' </c:comp-filter>' . - '</c:filter>' . + '<?xml version="1.0"?>'. + '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. + '<d:prop>'. + ' <c:calendar-data>'. + ' <c:expand start="20000101T000000Z" end="20101231T235959Z" />'. + ' </c:calendar-data>'. + ' <d:getetag />'. + '</d:prop>'. + '<c:filter>'. + ' <c:comp-filter name="VCALENDAR">'. + ' <c:comp-filter name="VEVENT" />'. + ' </c:comp-filter>'. + '</c:filter>'. '</c:calendar-query>'; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', [ @@ -793,26 +783,25 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(400, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); - + $this->assertEquals(400, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); } /** * @depends testCalendarQueryReport */ - function testCalendarQueryReportNoCalData() { - + public function testCalendarQueryReportNoCalData() + { $body = - '<?xml version="1.0"?>' . - '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . - '<d:prop>' . - ' <d:getetag />' . - '</d:prop>' . - '<c:filter>' . - ' <c:comp-filter name="VCALENDAR">' . - ' <c:comp-filter name="VEVENT" />' . - ' </c:comp-filter>' . - '</c:filter>' . + '<?xml version="1.0"?>'. + '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. + '<d:prop>'. + ' <d:getetag />'. + '</d:prop>'. + '<c:filter>'. + ' <c:comp-filter name="VCALENDAR">'. + ' <c:comp-filter name="VEVENT" />'. + ' </c:comp-filter>'. + '</c:filter>'. '</c:calendar-query>'; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', [ @@ -823,7 +812,7 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); $expected = <<<XML <?xml version="1.0"?> @@ -841,21 +830,20 @@ XML; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } /** * @depends testCalendarQueryReport */ - function testCalendarQueryReportNoFilters() { - + public function testCalendarQueryReportNoFilters() + { $body = - '<?xml version="1.0"?>' . - '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . - '<d:prop>' . - ' <c:calendar-data />' . - ' <d:getetag />' . - '</d:prop>' . + '<?xml version="1.0"?>'. + '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. + '<d:prop>'. + ' <c:calendar-data />'. + ' <d:getetag />'. + '</d:prop>'. '</c:calendar-query>'; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467'); @@ -864,30 +852,29 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(400, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); - + $this->assertEquals(400, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); } /** * @depends testSupportedReportSetProperty * @depends testCalendarMultiGetReport */ - function testCalendarQueryReport1Object() { - + public function testCalendarQueryReport1Object() + { $body = - '<?xml version="1.0"?>' . - '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . - '<d:prop>' . - ' <c:calendar-data>' . - ' <c:expand start="20000101T000000Z" end="20101231T235959Z" />' . - ' </c:calendar-data>' . - ' <d:getetag />' . - '</d:prop>' . - '<c:filter>' . - ' <c:comp-filter name="VCALENDAR">' . - ' <c:comp-filter name="VEVENT" />' . - ' </c:comp-filter>' . - '</c:filter>' . + '<?xml version="1.0"?>'. + '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. + '<d:prop>'. + ' <c:calendar-data>'. + ' <c:expand start="20000101T000000Z" end="20101231T235959Z" />'. + ' </c:calendar-data>'. + ' <d:getetag />'. + '</d:prop>'. + '<c:filter>'. + ' <c:comp-filter name="VCALENDAR">'. + ' <c:comp-filter name="VEVENT" />'. + ' </c:comp-filter>'. + '</c:filter>'. '</c:calendar-query>'; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467/UUID-2345', ['Depth' => '0']); @@ -896,7 +883,7 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); $expectedIcal = TestUtil::getTestCalendarData(); $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal); @@ -923,26 +910,25 @@ XML; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } /** * @depends testSupportedReportSetProperty * @depends testCalendarMultiGetReport */ - function testCalendarQueryReport1ObjectNoCalData() { - + public function testCalendarQueryReport1ObjectNoCalData() + { $body = - '<?xml version="1.0"?>' . - '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . - '<d:prop>' . - ' <d:getetag />' . - '</d:prop>' . - '<c:filter>' . - ' <c:comp-filter name="VCALENDAR">' . - ' <c:comp-filter name="VEVENT" />' . - ' </c:comp-filter>' . - '</c:filter>' . + '<?xml version="1.0"?>'. + '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. + '<d:prop>'. + ' <d:getetag />'. + '</d:prop>'. + '<c:filter>'. + ' <c:comp-filter name="VCALENDAR">'. + ' <c:comp-filter name="VEVENT" />'. + ' </c:comp-filter>'. + '</c:filter>'. '</c:calendar-query>'; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467/UUID-2345', ['Depth' => '0']); @@ -951,7 +937,7 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); $expected = <<<XML <?xml version="1.0"?> @@ -969,34 +955,32 @@ XML; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } - function testHTMLActionsPanel() { - + public function testHTMLActionsPanel() + { $output = ''; $r = $this->server->emit('onHTMLActionsPanel', [$this->server->tree->getNodeForPath('calendars/user1'), &$output]); $this->assertFalse($r); - $this->assertTrue(!!strpos($output, 'Display name')); - + $this->assertTrue((bool) strpos($output, 'Display name')); } /** * @depends testCalendarMultiGetReport */ - function testCalendarMultiGetReportNoEnd() { - + public function testCalendarMultiGetReportNoEnd() + { $body = - '<?xml version="1.0"?>' . - '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . - '<d:prop>' . - ' <c:calendar-data>' . - ' <c:expand start="20110101T000000Z" />' . - ' </c:calendar-data>' . - ' <d:getetag />' . - '</d:prop>' . - '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>' . + '<?xml version="1.0"?>'. + '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. + '<d:prop>'. + ' <c:calendar-data>'. + ' <c:expand start="20110101T000000Z" />'. + ' </c:calendar-data>'. + ' <d:getetag />'. + '</d:prop>'. + '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>'. '</c:calendar-multiget>'; $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); @@ -1005,25 +989,24 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: ' . $this->response->body); - + $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: '.$this->response->body); } /** * @depends testCalendarMultiGetReport */ - function testCalendarMultiGetReportNoStart() { - + public function testCalendarMultiGetReportNoStart() + { $body = - '<?xml version="1.0"?>' . - '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . - '<d:prop>' . - ' <c:calendar-data>' . - ' <c:expand end="20110101T000000Z" />' . - ' </c:calendar-data>' . - ' <d:getetag />' . - '</d:prop>' . - '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>' . + '<?xml version="1.0"?>'. + '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. + '<d:prop>'. + ' <c:calendar-data>'. + ' <c:expand end="20110101T000000Z" />'. + ' </c:calendar-data>'. + ' <d:getetag />'. + '</d:prop>'. + '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>'. '</c:calendar-multiget>'; $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); @@ -1032,25 +1015,24 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: ' . $this->response->body); - + $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: '.$this->response->body); } /** * @depends testCalendarMultiGetReport */ - function testCalendarMultiGetReportEndBeforeStart() { - + public function testCalendarMultiGetReportEndBeforeStart() + { $body = - '<?xml version="1.0"?>' . - '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . - '<d:prop>' . - ' <c:calendar-data>' . - ' <c:expand start="20200101T000000Z" end="20110101T000000Z" />' . - ' </c:calendar-data>' . - ' <d:getetag />' . - '</d:prop>' . - '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>' . + '<?xml version="1.0"?>'. + '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. + '<d:prop>'. + ' <c:calendar-data>'. + ' <c:expand start="20200101T000000Z" end="20110101T000000Z" />'. + ' </c:calendar-data>'. + ' <d:getetag />'. + '</d:prop>'. + '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>'. '</c:calendar-multiget>'; $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); @@ -1059,28 +1041,25 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: ' . $this->response->body); - + $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: '.$this->response->body); } /** * @depends testSupportedReportSetPropertyNonCalendar */ - function testCalendarProperties() { - + public function testCalendarProperties() + { $ns = '{urn:ietf:params:xml:ns:caldav}'; $props = $this->server->getProperties('calendars/user1/UUID-123467', [ - $ns . 'max-resource-size', - $ns . 'supported-calendar-data', - $ns . 'supported-collation-set', + $ns.'max-resource-size', + $ns.'supported-calendar-data', + $ns.'supported-collation-set', ]); $this->assertEquals([ - $ns . 'max-resource-size' => 10000000, - $ns . 'supported-calendar-data' => new Xml\Property\SupportedCalendarData(), - $ns . 'supported-collation-set' => new Xml\Property\SupportedCollationSet(), + $ns.'max-resource-size' => 10000000, + $ns.'supported-calendar-data' => new Xml\Property\SupportedCalendarData(), + $ns.'supported-collation-set' => new Xml\Property\SupportedCollationSet(), ], $props); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php index 23c248825..277de0664 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php @@ -1,20 +1,20 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAVACL; -class CollectionTest extends \PHPUnit_Framework_TestCase { - - function testGetChildForPrincipal() { - +class CollectionTest extends \PHPUnit\Framework\TestCase +{ + public function testGetChildForPrincipal() + { $back = new DAVACL\PrincipalBackend\Mock(); $col = new Collection($back); $r = $col->getChildForPrincipal([ 'uri' => 'principals/admin', ]); $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\User', $r); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php index fe07f0131..8036635b2 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php @@ -1,102 +1,95 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAVACL; -class ProxyReadTest extends \PHPUnit_Framework_TestCase { - +class ProxyReadTest extends \PHPUnit\Framework\TestCase +{ protected $backend; - function getInstance() { - + public function getInstance() + { $backend = new DAVACL\PrincipalBackend\Mock(); $principal = new ProxyRead($backend, [ 'uri' => 'principal/user', ]); $this->backend = $backend; - return $principal; - } - - function testGetName() { + return $principal; + } + public function testGetName() + { $i = $this->getInstance(); $this->assertEquals('calendar-proxy-read', $i->getName()); - } - function testGetDisplayName() { + public function testGetDisplayName() + { $i = $this->getInstance(); $this->assertEquals('calendar-proxy-read', $i->getDisplayName()); - } - function testGetLastModified() { - + public function testGetLastModified() + { $i = $this->getInstance(); $this->assertNull($i->getLastModified()); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testDelete() { - + public function testDelete() + { $i = $this->getInstance(); $i->delete(); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetName() { - + public function testSetName() + { $i = $this->getInstance(); $i->setName('foo'); - } - function testGetAlternateUriSet() { - + public function testGetAlternateUriSet() + { $i = $this->getInstance(); $this->assertEquals([], $i->getAlternateUriSet()); - } - function testGetPrincipalUri() { - + public function testGetPrincipalUri() + { $i = $this->getInstance(); $this->assertEquals('principal/user/calendar-proxy-read', $i->getPrincipalUrl()); - } - function testGetGroupMemberSet() { - + public function testGetGroupMemberSet() + { $i = $this->getInstance(); $this->assertEquals([], $i->getGroupMemberSet()); - } - function testGetGroupMembership() { - + public function testGetGroupMembership() + { $i = $this->getInstance(); $this->assertEquals([], $i->getGroupMembership()); - } - function testSetGroupMemberSet() { - + public function testSetGroupMemberSet() + { $i = $this->getInstance(); $i->setGroupMemberSet(['principals/foo']); $expected = [ - $i->getPrincipalUrl() => ['principals/foo'] + $i->getPrincipalUrl() => ['principals/foo'], ]; $this->assertEquals($expected, $this->backend->groupMembers); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php index 6cdb9b30e..df1715ee5 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php @@ -1,40 +1,39 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAVACL; -class ProxyWriteTest extends ProxyReadTest { - - function getInstance() { - +class ProxyWriteTest extends ProxyReadTest +{ + public function getInstance() + { $backend = new DAVACL\PrincipalBackend\Mock(); $principal = new ProxyWrite($backend, [ 'uri' => 'principal/user', ]); $this->backend = $backend; - return $principal; + return $principal; } - function testGetName() { - + public function testGetName() + { $i = $this->getInstance(); $this->assertEquals('calendar-proxy-write', $i->getName()); - } - function testGetDisplayName() { + public function testGetDisplayName() + { $i = $this->getInstance(); $this->assertEquals('calendar-proxy-write', $i->getDisplayName()); - } - function testGetPrincipalUri() { - + public function testGetPrincipalUri() + { $i = $this->getInstance(); $this->assertEquals('principal/user/calendar-proxy-write', $i->getPrincipalUrl()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php index 420bb3b1a..2c690c65d 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Principal; use Sabre\DAVACL; -class UserTest extends \PHPUnit_Framework_TestCase { - - function getInstance() { - +class UserTest extends \PHPUnit\Framework\TestCase +{ + public function getInstance() + { $backend = new DAVACL\PrincipalBackend\Mock(); $backend->addPrincipal([ 'uri' => 'principals/user/calendar-proxy-read', @@ -18,89 +20,81 @@ class UserTest extends \PHPUnit_Framework_TestCase { $backend->addPrincipal([ 'uri' => 'principals/user/random', ]); + return new User($backend, [ 'uri' => 'principals/user', ]); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testCreateFile() { - + public function testCreateFile() + { $u = $this->getInstance(); $u->createFile('test'); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testCreateDirectory() { - + public function testCreateDirectory() + { $u = $this->getInstance(); $u->createDirectory('test'); - } - function testGetChildProxyRead() { - + public function testGetChildProxyRead() + { $u = $this->getInstance(); $child = $u->getChild('calendar-proxy-read'); $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyRead', $child); - } - function testGetChildProxyWrite() { - + public function testGetChildProxyWrite() + { $u = $this->getInstance(); $child = $u->getChild('calendar-proxy-write'); $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyWrite', $child); - } /** - * @expectedException Sabre\DAV\Exception\NotFound + * @expectedException \Sabre\DAV\Exception\NotFound */ - function testGetChildNotFound() { - + public function testGetChildNotFound() + { $u = $this->getInstance(); $child = $u->getChild('foo'); - } /** - * @expectedException Sabre\DAV\Exception\NotFound + * @expectedException \Sabre\DAV\Exception\NotFound */ - function testGetChildNotFound2() { - + public function testGetChildNotFound2() + { $u = $this->getInstance(); $child = $u->getChild('random'); - } - function testGetChildren() { - + public function testGetChildren() + { $u = $this->getInstance(); $children = $u->getChildren(); $this->assertEquals(2, count($children)); $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyRead', $children[0]); $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyWrite', $children[1]); - } - function testChildExist() { - + public function testChildExist() + { $u = $this->getInstance(); $this->assertTrue($u->childExists('calendar-proxy-read')); $this->assertTrue($u->childExists('calendar-proxy-write')); $this->assertFalse($u->childExists('foo')); - } - function testGetACL() { - + public function testGetACL() + { $expected = [ [ 'privilege' => '{DAV:}all', @@ -121,7 +115,5 @@ class UserTest extends \PHPUnit_Framework_TestCase { $u = $this->getInstance(); $this->assertEquals($expected, $u->getACL()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php index 04d4b1237..df70fe7ec 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php @@ -1,14 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV\Schedule; use Sabre\CalDAV; -use Sabre\DAV; - -class OutboxTest extends \PHPUnit_Framework_TestCase { - - function testSetup() { +class OutboxTest extends \PHPUnit\Framework\TestCase +{ + public function testSetup() + { $outbox = new Outbox('principals/user1'); $this->assertEquals('outbox', $outbox->getName()); $this->assertEquals([], $outbox->getChildren()); @@ -17,7 +18,7 @@ class OutboxTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send', + 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send', 'principal' => 'principals/user1', 'protected' => true, ], @@ -27,7 +28,7 @@ class OutboxTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send', + 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send', 'principal' => 'principals/user1/calendar-proxy-write', 'protected' => true, ], @@ -42,7 +43,5 @@ class OutboxTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], ], $outbox->getACL()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php index f71c19523..735bbef41 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php @@ -1,24 +1,26 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV\Sharing; use Sabre\DAV\Xml\Element\Sharee; -class SharedCalendarTest extends \PHPUnit_Framework_TestCase { - +class SharedCalendarTest extends \PHPUnit\Framework\TestCase +{ protected $backend; - function getInstance(array $props = null) { - + public function getInstance(array $props = null) + { if (is_null($props)) { $props = [ - 'id' => 1, + 'id' => 1, '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/original', - '{http://sabredav.org/ns}owner-principal' => 'principals/owner', - '{http://sabredav.org/ns}read-only' => false, - 'share-access' => Sharing\Plugin::ACCESS_READWRITE, - 'principaluri' => 'principals/sharee', + '{http://sabredav.org/ns}owner-principal' => 'principals/owner', + '{http://sabredav.org/ns}read-only' => false, + 'share-access' => Sharing\Plugin::ACCESS_READWRITE, + 'principaluri' => 'principals/sharee', ]; } @@ -35,11 +37,10 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase { $this->backend->updateInvites(1, [$sharee]); return new SharedCalendar($this->backend, $props); - } - function testGetInvites() { - + public function testGetInvites() + { $sharee = new Sharee(); $sharee->href = 'mailto:removeme@example.org'; $sharee->properties['{DAV:}displayname'] = 'To be removed'; @@ -50,15 +51,15 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase { [$sharee], $this->getInstance()->getInvites() ); - } - function testGetOwner() { + public function testGetOwner() + { $this->assertEquals('principals/sharee', $this->getInstance()->getOwner()); } - function testGetACL() { - + public function testGetACL() + { $expected = [ [ 'privilege' => '{DAV:}write', @@ -96,18 +97,17 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], [ - 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', + 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true, ], ]; $this->assertEquals($expected, $this->getInstance()->getACL()); - } - function testGetChildACL() { - + public function testGetChildACL() + { $expected = [ [ 'privilege' => '{DAV:}write', @@ -134,19 +134,17 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase { 'principal' => 'principals/sharee/calendar-proxy-read', 'protected' => true, ], - ]; $this->assertEquals($expected, $this->getInstance()->getChildACL()); - } - function testUpdateInvites() { - + public function testUpdateInvites() + { $instance = $this->getInstance(); $newSharees = [ new Sharee(), - new Sharee() + new Sharee(), ]; $newSharees[0]->href = 'mailto:test@example.org'; $newSharees[0]->properties['{DAV:}displayname'] = 'Foo Bar'; @@ -159,18 +157,16 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase { $instance->updateInvites($newSharees); $expected = [ - clone $newSharees[0] + clone $newSharees[0], ]; $expected[0]->inviteStatus = Sharing\Plugin::INVITE_NORESPONSE; $this->assertEquals($expected, $instance->getInvites()); - } - function testPublish() { - + public function testPublish() + { $instance = $this->getInstance(); $this->assertNull($instance->setPublishStatus(true)); $this->assertNull($instance->setPublishStatus(false)); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php index 9589176a3..57732cd06 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php @@ -1,36 +1,38 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; use Sabre\DAV\Xml\Element\Sharee; use Sabre\HTTP; -class SharingPluginTest extends \Sabre\DAVServerTest { - +class SharingPluginTest extends \Sabre\DAVServerTest +{ protected $setupCalDAV = true; protected $setupCalDAVSharing = true; protected $setupACL = true; protected $autoLogin = 'user1'; - function setUp() { - + public function setUp() + { $this->caldavCalendars = [ [ 'principaluri' => 'principals/user1', - 'id' => 1, - 'uri' => 'cal1', + 'id' => 1, + 'uri' => 'cal1', ], [ 'principaluri' => 'principals/user1', - 'id' => 2, - 'uri' => 'cal2', + 'id' => 2, + 'uri' => 'cal2', 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, ], [ 'principaluri' => 'principals/user1', - 'id' => 3, - 'uri' => 'cal3', + 'id' => 3, + 'uri' => 'cal3', ], ]; @@ -38,86 +40,79 @@ class SharingPluginTest extends \Sabre\DAVServerTest { // Making the logged in user an admin, for full access: $this->aclPlugin->adminPrincipals[] = 'principals/user2'; - } - function testSimple() { - + public function testSimple() + { $this->assertInstanceOf('Sabre\\CalDAV\\SharingPlugin', $this->server->getPlugin('caldav-sharing')); $this->assertEquals( 'caldav-sharing', $this->caldavSharingPlugin->getPluginInfo()['name'] ); - } /** * @expectedException \LogicException */ - function testSetupWithoutCoreSharingPlugin() { - + public function testSetupWithoutCoreSharingPlugin() + { $server = new DAV\Server(); $server->addPlugin( new SharingPlugin() ); - } - function testGetFeatures() { - + public function testGetFeatures() + { $this->assertEquals(['calendarserver-sharing'], $this->caldavSharingPlugin->getFeatures()); - } - function testBeforeGetShareableCalendar() { - + public function testBeforeGetShareableCalendar() + { // Forcing the server to authenticate: - $this->authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $this->authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $props = $this->server->getProperties('calendars/user1/cal1', [ - '{' . Plugin::NS_CALENDARSERVER . '}invite', - '{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes', + '{'.Plugin::NS_CALENDARSERVER.'}invite', + '{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes', ]); - $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']); - $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\AllowedSharingModes', $props['{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes']); - + $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{'.Plugin::NS_CALENDARSERVER.'}invite']); + $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\AllowedSharingModes', $props['{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes']); } - function testBeforeGetSharedCalendar() { - + public function testBeforeGetSharedCalendar() + { $props = $this->server->getProperties('calendars/user1/cal2', [ - '{' . Plugin::NS_CALENDARSERVER . '}shared-url', - '{' . Plugin::NS_CALENDARSERVER . '}invite', + '{'.Plugin::NS_CALENDARSERVER.'}shared-url', + '{'.Plugin::NS_CALENDARSERVER.'}invite', ]); - $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']); + $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{'.Plugin::NS_CALENDARSERVER.'}invite']); //$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $props['{' . Plugin::NS_CALENDARSERVER . '}shared-url']); - } - function testUpdateResourceType() { - + public function testUpdateResourceType() + { $this->caldavBackend->updateInvites(1, [ new Sharee([ 'href' => 'mailto:joe@example.org', - ]) + ]), ] ); $result = $this->server->updateProperties('calendars/user1/cal1', [ - '{DAV:}resourcetype' => new DAV\Xml\Property\ResourceType(['{DAV:}collection']) + '{DAV:}resourcetype' => new DAV\Xml\Property\ResourceType(['{DAV:}collection']), ]); $this->assertEquals([ - '{DAV:}resourcetype' => 200 + '{DAV:}resourcetype' => 200, ], $result); $this->assertEquals(0, count($this->caldavBackend->getInvites(1))); - } - function testUpdatePropertiesPassThru() { - + public function testUpdatePropertiesPassThru() + { $result = $this->server->updateProperties('calendars/user1/cal3', [ '{DAV:}foo' => 'bar', ]); @@ -125,52 +120,48 @@ class SharingPluginTest extends \Sabre\DAVServerTest { $this->assertEquals([ '{DAV:}foo' => 200, ], $result); - } - function testUnknownMethodNoPOST() { - + public function testUnknownMethodNoPOST() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PATCH', - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', ]); $response = $this->request($request); $this->assertEquals(501, $response->status, $response->body); - } - function testUnknownMethodNoXML() { - + public function testUnknownMethodNoXML() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/', - 'CONTENT_TYPE' => 'text/plain', + 'REQUEST_URI' => '/', + 'CONTENT_TYPE' => 'text/plain', ]); $response = $this->request($request); $this->assertEquals(501, $response->status, $response->body); - } - function testUnknownMethodNoNode() { - + public function testUnknownMethodNoNode() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/foo', - 'CONTENT_TYPE' => 'text/xml', + 'REQUEST_URI' => '/foo', + 'CONTENT_TYPE' => 'text/xml', ]); $response = $this->request($request); $this->assertEquals(501, $response->status, $response->body); - } - function testShareRequest() { - + public function testShareRequest() + { $request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']); $xml = <<<RRR @@ -194,13 +185,13 @@ RRR; $this->assertEquals( [ new Sharee([ - 'href' => 'mailto:joe@example.org', + 'href' => 'mailto:joe@example.org', 'properties' => [ '{DAV:}displayname' => 'Joe Shmoe', ], - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE, - 'comment' => '', + 'comment' => '', ]), ], $this->caldavBackend->getInvites(1) @@ -214,11 +205,10 @@ RRR; $this->assertTrue( $props['{DAV:}resourcetype']->is('{http://calendarserver.org/ns/}shared-owner') ); - } - function testShareRequestNoShareableCalendar() { - + public function testShareRequestNoShareableCalendar() + { $request = new HTTP\Request( 'POST', '/calendars/user1/cal2', @@ -226,7 +216,7 @@ RRR; ); $xml = '<?xml version="1.0"?> -<cs:share xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:"> +<cs:share xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:"> <cs:set> <d:href>mailto:joe@example.org</d:href> <cs:common-name>Joe Shmoe</cs:common-name> @@ -241,19 +231,18 @@ RRR; $request->setBody($xml); $response = $this->request($request, 403); - } - function testInviteReply() { - + public function testInviteReply() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1', - 'CONTENT_TYPE' => 'text/xml', + 'REQUEST_URI' => '/calendars/user1', + 'CONTENT_TYPE' => 'text/xml', ]); $xml = '<?xml version="1.0"?> -<cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:"> +<cs:invite-reply xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:"> <cs:hosturl><d:href>/principals/owner</d:href></cs:hosturl> <cs:invite-accepted /> </cs:invite-reply> @@ -262,37 +251,35 @@ RRR; $request->setBody($xml); $response = $this->request($request); $this->assertEquals(200, $response->status, $response->body); - } - function testInviteBadXML() { - + public function testInviteBadXML() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1', - 'CONTENT_TYPE' => 'text/xml', + 'REQUEST_URI' => '/calendars/user1', + 'CONTENT_TYPE' => 'text/xml', ]); $xml = '<?xml version="1.0"?> -<cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:"> +<cs:invite-reply xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:"> </cs:invite-reply> '; $request->setBody($xml); $response = $this->request($request); $this->assertEquals(400, $response->status, $response->body); - } - function testInviteWrongUrl() { - + public function testInviteWrongUrl() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1/cal1', - 'CONTENT_TYPE' => 'text/xml', + 'REQUEST_URI' => '/calendars/user1/cal1', + 'CONTENT_TYPE' => 'text/xml', ]); $xml = '<?xml version="1.0"?> -<cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:"> +<cs:invite-reply xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:"> <cs:hosturl><d:href>/principals/owner</d:href></cs:hosturl> </cs:invite-reply> '; @@ -303,27 +290,33 @@ RRR; // If the plugin did not handle this request, it must ensure that the // body is still accessible by other plugins. $this->assertEquals($xml, $request->getBody(true)); - } - function testPublish() { + public function testPostWithoutContentType() + { + $request = new HTTP\Request('POST', '/'); + $response = new HTTP\ResponseMock(); + + $this->caldavSharingPlugin->httpPost($request, $response); + $this->assertTrue(true); + } + public function testPublish() + { $request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']); $xml = '<?xml version="1.0"?> -<cs:publish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" /> +<cs:publish-calendar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" /> '; $request->setBody($xml); $response = $this->request($request); $this->assertEquals(202, $response->status, $response->body); - } - - function testUnpublish() { - + public function testUnpublish() + { $request = new HTTP\Request( 'POST', '/calendars/user1/cal1', @@ -331,18 +324,17 @@ RRR; ); $xml = '<?xml version="1.0"?> -<cs:unpublish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" /> +<cs:unpublish-calendar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" /> '; $request->setBody($xml); $response = $this->request($request); $this->assertEquals(200, $response->status, $response->body); - } - function testPublishWrongUrl() { - + public function testPublishWrongUrl() + { $request = new HTTP\Request( 'POST', '/calendars/user1', @@ -350,34 +342,31 @@ RRR; ); $xml = '<?xml version="1.0"?> -<cs:publish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" /> +<cs:publish-calendar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" /> '; $request->setBody($xml); $this->request($request, 501); - } - function testUnpublishWrongUrl() { - + public function testUnpublishWrongUrl() + { $request = new HTTP\Request( 'POST', '/calendars/user1', ['Content-Type' => 'text/xml'] ); $xml = '<?xml version="1.0"?> -<cs:unpublish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" /> +<cs:unpublish-calendar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" /> '; $request->setBody($xml); $this->request($request, 501); - } - function testUnknownXmlDoc() { - - + public function testUnknownXmlDoc() + { $request = new HTTP\Request( 'POST', '/calendars/user1/cal2', @@ -385,12 +374,11 @@ RRR; ); $xml = '<?xml version="1.0"?> -<cs:foo-bar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />'; +<cs:foo-bar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" />'; $request->setBody($xml); $response = $this->request($request); $this->assertEquals(501, $response->status, $response->body); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php b/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php index 673d39c0a..72b5080af 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php @@ -1,39 +1,41 @@ <?php -namespace Sabre\CalDAV; - -class TestUtil { +declare(strict_types=1); - static function getBackend() { +namespace Sabre\CalDAV; +class TestUtil +{ + public static function getBackend() + { $backend = new Backend\Mock(); $calendarId = $backend->createCalendar( 'principals/user1', 'UUID-123467', [ - '{DAV:}displayname' => 'user1 calendar', + '{DAV:}displayname' => 'user1 calendar', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', - '{http://apple.com/ns/ical/}calendar-order' => '1', - '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', + '{http://apple.com/ns/ical/}calendar-order' => '1', + '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', ] ); $backend->createCalendar( 'principals/user1', 'UUID-123468', [ - '{DAV:}displayname' => 'user1 calendar2', + '{DAV:}displayname' => 'user1 calendar2', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', - '{http://apple.com/ns/ical/}calendar-order' => '1', - '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', + '{http://apple.com/ns/ical/}calendar-order' => '1', + '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', ] ); $backend->createCalendarObject($calendarId, 'UUID-2345', self::getTestCalendarData()); - return $backend; + return $backend; } - static function getTestCalendarData($type = 1) { - + public static function getTestCalendarData($type = 1) + { $calendarData = 'BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Apple Inc.//iCal 4.0.1//EN @@ -62,108 +64,104 @@ SUMMARY:Something here DTSTAMP:20100228T130202Z'; switch ($type) { - case 1 : + case 1: $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDTEND;TZID=Asia/Seoul:20100223T070000\n"; break; - case 2 : + case 2: $calendarData .= "\nDTSTART:20100223T060000\nDTEND:20100223T070000\n"; break; - case 3 : + case 3: $calendarData .= "\nDTSTART;VALUE=DATE:20100223\nDTEND;VALUE=DATE:20100223\n"; break; - case 4 : + case 4: $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:PT1H\n"; break; - case 5 : + case 5: $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:-P5D\n"; break; - case 6 : + case 6: $calendarData .= "\nDTSTART;VALUE=DATE:20100223\n"; break; - case 7 : + case 7: $calendarData .= "\nDTSTART;VALUE=DATETIME:20100223T060000\n"; break; // No DTSTART, so intentionally broken - case 'X' : + case 'X': $calendarData .= "\n"; break; } - $calendarData .= 'ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com SEQUENCE:2 END:VEVENT END:VCALENDAR'; return $calendarData; - } - static function getTestTODO($type = 'due') { - + public static function getTestTODO($type = 'due') + { switch ($type) { - - case 'due' : - $extra = "DUE:20100104T000000Z"; + case 'due': + $extra = 'DUE:20100104T000000Z'; break; - case 'due2' : - $extra = "DUE:20060104T000000Z"; + case 'due2': + $extra = 'DUE:20060104T000000Z'; break; - case 'due_date' : - $extra = "DUE;VALUE=DATE:20060104"; + case 'due_date': + $extra = 'DUE;VALUE=DATE:20060104'; break; - case 'due_tz' : - $extra = "DUE;TZID=Asia/Seoul:20060104T000000Z"; + case 'due_tz': + $extra = 'DUE;TZID=Asia/Seoul:20060104T000000Z'; break; - case 'due_dtstart' : + case 'due_dtstart': $extra = "DTSTART:20050223T060000Z\nDUE:20060104T000000Z"; break; - case 'due_dtstart2' : + case 'due_dtstart2': $extra = "DTSTART:20090223T060000Z\nDUE:20100104T000000Z"; break; - case 'dtstart' : + case 'dtstart': $extra = 'DTSTART:20100223T060000Z'; break; - case 'dtstart2' : + case 'dtstart2': $extra = 'DTSTART:20060223T060000Z'; break; - case 'dtstart_date' : + case 'dtstart_date': $extra = 'DTSTART;VALUE=DATE:20100223'; break; - case 'dtstart_tz' : + case 'dtstart_tz': $extra = 'DTSTART;TZID=Asia/Seoul:20100223T060000Z'; break; - case 'dtstart_duration' : + case 'dtstart_duration': $extra = "DTSTART:20061023T060000Z\nDURATION:PT1H"; break; - case 'dtstart_duration2' : + case 'dtstart_duration2': $extra = "DTSTART:20101023T060000Z\nDURATION:PT1H"; break; - case 'completed' : + case 'completed': $extra = 'COMPLETED:20060601T000000Z'; break; - case 'completed2' : + case 'completed2': $extra = 'COMPLETED:20090601T000000Z'; break; - case 'created' : + case 'created': $extra = 'CREATED:20060601T000000Z'; break; - case 'created2' : + case 'created2': $extra = 'CREATED:20090601T000000Z'; break; - case 'completedcreated' : + case 'completedcreated': $extra = "CREATED:20060601T000000Z\nCOMPLETED:20070101T000000Z"; break; - case 'completedcreated2' : + case 'completedcreated2': $extra = "CREATED:20090601T000000Z\nCOMPLETED:20100101T000000Z"; break; - case 'notime' : + case 'notime': $extra = 'X-FILLER:oh hello'; break; - default : - throw new Exception('Unknown type: ' . $type); - + default: + throw new Exception('Unknown type: '.$type); } $todo = 'BEGIN:VCALENDAR @@ -171,7 +169,7 @@ VERSION:2.0 PRODID:-//Example Corp.//CalDAV Client//EN BEGIN:VTODO DTSTAMP:20060205T235335Z -' . $extra . ' +'.$extra.' STATUS:NEEDS-ACTION SUMMARY:Task #1 UID:DDDEEB7915FA61233B861457@example.com @@ -183,7 +181,5 @@ END:VTODO END:VCALENDAR'; return $todo; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php index 629df90c1..e6d1edace 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; @@ -8,8 +10,8 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; -class ValidateICalTest extends \PHPUnit_Framework_TestCase { - +class ValidateICalTest extends \PHPUnit\Framework\TestCase +{ /** * @var Sabre\DAV\Server */ @@ -19,21 +21,21 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase { */ protected $calBackend; - function setUp() { - + public function setUp() + { $calendars = [ [ - 'id' => 'calendar1', - 'principaluri' => 'principals/admin', - 'uri' => 'calendar1', + 'id' => 'calendar1', + 'principaluri' => 'principals/admin', + 'uri' => 'calendar1', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO', 'VJOURNAL']), ], [ - 'id' => 'calendar2', - 'principaluri' => 'principals/admin', - 'uri' => 'calendar2', + 'id' => 'calendar2', + 'principaluri' => 'principals/admin', + 'uri' => 'calendar2', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VTODO', 'VJOURNAL']), - ] + ], ]; $this->calBackend = new Backend\Mock($calendars, []); @@ -52,33 +54,30 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase { $response = new HTTP\ResponseMock(); $this->server->httpResponse = $response; - } - function request(HTTP\Request $request) { - + public function request(HTTP\Request $request) + { $this->server->httpRequest = $request; $this->server->exec(); return $this->server->httpResponse; - } - function testCreateFile() { - + public function testCreateFile() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $response = $this->request($request); $this->assertEquals(415, $response->status); - } - function testCreateFileValid() { - + public function testCreateFileValid() + { $request = new HTTP\Request( 'PUT', '/calendars/admin/calendar1/blabla.ics', @@ -101,26 +100,25 @@ ICS; $response = $this->request($request); - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5($ics) . '"'], + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5($ics).'"'], ], $response->getHeaders()); $expected = [ - 'uri' => 'blabla.ics', + 'uri' => 'blabla.ics', 'calendardata' => $ics, - 'calendarid' => 'calendar1', + 'calendarid' => 'calendar1', 'lastmodified' => null, ]; $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics')); - } - function testCreateFileNoVersion() { - + public function testCreateFileNoVersion() + { $request = new HTTP\Request( 'PUT', '/calendars/admin/calendar1/blabla.ics', @@ -142,12 +140,11 @@ ICS; $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testCreateFileNoVersionFixed() { - + public function testCreateFileNoVersionFixed() + { $request = new HTTP\Request( 'PUT', '/calendars/admin/calendar1/blabla.ics', @@ -169,10 +166,10 @@ ICS; $response = $this->request($request); - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->body); $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Length' => ['0'], 'X-Sabre-Ew-Gross' => ['iCalendar validation warning: VERSION MUST appear exactly once in a VCALENDAR component'], ], $response->getHeaders()); @@ -190,18 +187,17 @@ END:VCALENDAR\r ICS; $expected = [ - 'uri' => 'blabla.ics', + 'uri' => 'blabla.ics', 'calendardata' => $ics, - 'calendarid' => 'calendar1', + 'calendarid' => 'calendar1', 'lastmodified' => null, ]; $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics')); - } - function testCreateFileNoComponents() { - + public function testCreateFileNoComponents() + { $request = new HTTP\Request( 'PUT', '/calendars/admin/calendar1/blabla.ics', @@ -217,96 +213,89 @@ ICS; $request->setBody($ics); $response = $this->request($request); - $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testCreateFileNoUID() { - + public function testCreateFileNoUID() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testCreateFileVCard() { - + public function testCreateFileVCard() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $request->setBody("BEGIN:VCARD\r\nEND:VCARD\r\n"); $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testCreateFile2Components() { - + public function testCreateFile2Components() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nBEGIN:VJOURNAL\r\nUID:foo\r\nEND:VJOURNAL\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testCreateFile2UIDS() { - + public function testCreateFile2UIDS() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nBEGIN:VEVENT\r\nUID:bar\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testCreateFileWrongComponent() { - + public function testCreateFileWrongComponent() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VFREEBUSY\r\nUID:foo\r\nEND:VFREEBUSY\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testUpdateFile() { - + public function testUpdateFile() + { $this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo'); $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $response = $this->request($request); $this->assertEquals(415, $response->status); - } - function testUpdateFileParsableBody() { - + public function testUpdateFileParsableBody() + { $this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo'); $request = new HTTP\Request( 'PUT', @@ -330,43 +319,40 @@ ICS; $this->assertEquals(204, $response->status); $expected = [ - 'uri' => 'blabla.ics', + 'uri' => 'blabla.ics', 'calendardata' => $ics, - 'calendarid' => 'calendar1', + 'calendarid' => 'calendar1', 'lastmodified' => null, ]; $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics')); - } - function testCreateFileInvalidComponent() { - + public function testCreateFileInvalidComponent() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testUpdateFileInvalidComponent() { - + public function testUpdateFileInvalidComponent() + { $this->calBackend->createCalendarObject('calendar2', 'blabla.ics', 'foo'); $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } /** @@ -376,8 +362,8 @@ ICS; * More importantly. If any transformation happens, the etag must no longer * be returned by the server. */ - function testCreateFileModified() { - + public function testCreateFileModified() + { $request = new HTTP\Request( 'PUT', '/calendars/admin/calendar1/blabla.ics' @@ -399,8 +385,7 @@ ICS; $response = $this->request($request); - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->body); $this->assertNull($response->getHeader('ETag')); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php index 552e2ba77..c945e2c58 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; use Sabre\DAVACL; use Sabre\HTTP; -abstract class AbstractPluginTest extends \PHPUnit_Framework_TestCase { - +abstract class AbstractPluginTest extends \PHPUnit\Framework\TestCase +{ /** * @var Sabre\CardDAV\Plugin */ @@ -21,14 +23,14 @@ abstract class AbstractPluginTest extends \PHPUnit_Framework_TestCase { */ protected $backend; - function setUp() { - + public function setUp() + { $this->backend = new Backend\Mock(); $principalBackend = new DAVACL\PrincipalBackend\Mock(); $tree = [ new AddressBookRoot($principalBackend, $this->backend), - new DAVACL\PrincipalCollection($principalBackend) + new DAVACL\PrincipalCollection($principalBackend), ]; $this->plugin = new Plugin(); @@ -37,7 +39,5 @@ abstract class AbstractPluginTest extends \PHPUnit_Framework_TestCase { $this->server->sapi = new HTTP\SapiMock(); $this->server->addPlugin($this->plugin); $this->server->debugExceptions = true; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php index f8da38a16..6e7e13106 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; @@ -8,10 +10,10 @@ use Sabre\HTTP; require_once 'Sabre/CardDAV/AbstractPluginTest.php'; require_once 'Sabre/HTTP/ResponseMock.php'; -class AddressBookQueryTest extends AbstractPluginTest { - - function testQuery() { - +class AddressBookQueryTest extends AbstractPluginTest +{ + public function testQuery() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book1', @@ -37,7 +39,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -47,21 +49,19 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', ], ], '/addressbooks/user1/book1/card2' => [ 404 => [ '{DAV:}getetag' => null, ], - ] + ], ], $result); - - } - function testQueryDepth0() { - + public function testQueryDepth0() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book1/card1', @@ -87,7 +87,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -97,16 +97,14 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', ], ], ], $result); - - } - function testQueryNoMatch() { - + public function testQueryNoMatch() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book1', @@ -132,7 +130,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -140,15 +138,14 @@ class AddressBookQueryTest extends AbstractPluginTest { $result = $client->parseMultiStatus($response->body); $this->assertEquals([], $result); - } - function testQueryLimit() { - + public function testQueryLimit() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/addressbooks/user1/book1', + 'HTTP_DEPTH' => '1', ]); $request->setBody( @@ -171,7 +168,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -181,16 +178,14 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', ], ], ], $result); - - } - function testJson() { - + public function testJson() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book1/card1', @@ -214,7 +209,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -226,16 +221,15 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', - '{urn:ietf:params:xml:ns:carddav}address-data' => '["vcard",[["version",{},"text","4.0"],["prodid",{},"text","-\/\/Sabre\/\/Sabre VObject ' . $vobjVersion . '\/\/EN"],["uid",{},"text","12345"]]]', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', + '{urn:ietf:params:xml:ns:carddav}address-data' => '["vcard",[["version",{},"text","4.0"],["prodid",{},"text","-\/\/Sabre\/\/Sabre VObject '.$vobjVersion.'\/\/EN"],["uid",{},"text","12345"]]]', ], ], ], $result); - } - function testVCard4() { - + public function testVCard4() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book1/card1', @@ -259,7 +253,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -271,16 +265,15 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject $vobjVersion//EN\r\nUID:12345\r\nEND:VCARD\r\n", ], ], ], $result); - } - function testAddressBookDepth0() { - + public function testAddressBookDepth0() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book1', @@ -304,11 +297,11 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(415, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(415, $response->status, 'Incorrect status code. Full response body:'.$response->body); } - function testAddressBookProperties() { - + public function testAddressBookProperties() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book3', @@ -335,7 +328,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -345,11 +338,10 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book3/card3' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nFN:Test-Card\nEMAIL;TYPE=home:bar@example.org\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nFN:Test-Card\nEMAIL;TYPE=home:bar@example.org\nEND:VCARD").'"', '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\r\nVERSION:3.0\r\nUID:12345\r\nFN:Test-Card\r\nEND:VCARD\r\n", ], ], ], $result); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php index fc20480f2..c4aff2712 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php @@ -1,22 +1,23 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAVACL; -class AddressBookRootTest extends \PHPUnit_Framework_TestCase { - - function testGetName() { - +class AddressBookRootTest extends \PHPUnit\Framework\TestCase +{ + public function testGetName() + { $pBackend = new DAVACL\PrincipalBackend\Mock(); $cBackend = new Backend\Mock(); $root = new AddressBookRoot($pBackend, $cBackend); $this->assertEquals('addressbooks', $root->getName()); - } - function testGetChildForPrincipal() { - + public function testGetChildForPrincipal() + { $pBackend = new DAVACL\PrincipalBackend\Mock(); $cBackend = new Backend\Mock(); $root = new AddressBookRoot($pBackend, $cBackend); @@ -26,6 +27,5 @@ class AddressBookRootTest extends \PHPUnit_Framework_TestCase { $this->assertInstanceOf('Sabre\\CardDAV\\AddressBookHome', $children[0]); $this->assertEquals('user1', $children[0]->getName()); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php index 1f0064dd3..879816803 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV\PropPatch; -class AddressBookTest extends \PHPUnit_Framework_TestCase { - +class AddressBookTest extends \PHPUnit\Framework\TestCase +{ use \Sabre\DAV\DbTestHelperTrait; /** @@ -14,98 +16,88 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { protected $ab; protected $backend; - function setUp() { - + public function setUp() + { $this->backend = new Backend\Mock(); $this->ab = new AddressBook( $this->backend, [ - 'uri' => 'book1', - 'id' => 'foo', + 'uri' => 'book1', + 'id' => 'foo', '{DAV:}displayname' => 'd-name', - 'principaluri' => 'principals/user1', + 'principaluri' => 'principals/user1', ] ); - } - function testGetName() { - + public function testGetName() + { $this->assertEquals('book1', $this->ab->getName()); - } - function testGetChild() { - + public function testGetChild() + { $card = $this->ab->getChild('card1'); $this->assertInstanceOf('Sabre\\CardDAV\\Card', $card); $this->assertEquals('card1', $card->getName()); - } /** - * @expectedException Sabre\DAV\Exception\NotFound + * @expectedException \Sabre\DAV\Exception\NotFound */ - function testGetChildNotFound() { - + public function testGetChildNotFound() + { $card = $this->ab->getChild('card3'); - } - function testGetChildren() { - + public function testGetChildren() + { $cards = $this->ab->getChildren(); $this->assertEquals(2, count($cards)); $this->assertEquals('card1', $cards[0]->getName()); $this->assertEquals('card2', $cards[1]->getName()); - } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ - function testCreateDirectory() { - + public function testCreateDirectory() + { $this->ab->createDirectory('name'); - } - function testCreateFile() { - + public function testCreateFile() + { $file = fopen('php://memory', 'r+'); fwrite($file, 'foo'); rewind($file); $this->ab->createFile('card2', $file); $this->assertEquals('foo', $this->backend->cards['foo']['card2']); - } - function testDelete() { - + public function testDelete() + { $this->ab->delete(); $this->assertEquals(1, count($this->backend->addressBooks)); - } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ - function testSetName() { - + public function testSetName() + { $this->ab->setName('foo'); - } - function testGetLastModified() { - + public function testGetLastModified() + { $this->assertNull($this->ab->getLastModified()); - } - function testUpdateProperties() { - + public function testUpdateProperties() + { $propPatch = new PropPatch([ '{DAV:}displayname' => 'barrr', ]); @@ -113,20 +105,18 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { $this->assertTrue($propPatch->commit()); $this->assertEquals('barrr', $this->backend->addressBooks[0]['{DAV:}displayname']); - } - function testGetProperties() { - + public function testGetProperties() + { $props = $this->ab->getProperties(['{DAV:}displayname']); $this->assertEquals([ '{DAV:}displayname' => 'd-name', ], $props); - } - function testACLMethods() { - + public function testACLMethods() + { $this->assertEquals('principals/user1', $this->ab->getOwner()); $this->assertNull($this->ab->getGroup()); $this->assertEquals([ @@ -136,39 +126,35 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], ], $this->ab->getACL()); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACL() { - - $this->ab->setACL([]); - + public function testSetACL() + { + $this->ab->setACL([]); } - function testGetSupportedPrivilegeSet() { - + public function testGetSupportedPrivilegeSet() + { $this->assertNull( $this->ab->getSupportedPrivilegeSet() ); - } - function testGetSyncTokenNoSyncSupport() { - + public function testGetSyncTokenNoSyncSupport() + { $this->assertNull($this->ab->getSyncToken()); - } - function testGetChangesNoSyncSupport() { + public function testGetChangesNoSyncSupport() + { $this->assertNull($this->ab->getChanges(1, null)); - } - function testGetSyncToken() { - + public function testGetSyncToken() + { $this->driver = 'sqlite'; $this->dropTables(['addressbooks', 'cards', 'addressbookchanges']); $this->createSchema('addressbooks'); @@ -179,8 +165,8 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(2, $ab->getSyncToken()); } - function testGetSyncToken2() { - + public function testGetSyncToken2() + { $this->driver = 'sqlite'; $this->dropTables(['addressbooks', 'cards', 'addressbookchanges']); $this->createSchema('addressbooks'); @@ -190,5 +176,4 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { $ab = new AddressBook($backend, ['id' => 1, '{http://sabredav.org/ns}sync-token' => 2]); $this->assertEquals(2, $ab->getSyncToken()); } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php index f62bfb1ae..e5bd088fc 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV\Backend; use Sabre\CardDAV; use Sabre\DAV\PropPatch; -abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { - +abstract class AbstractPDOTest extends \PHPUnit\Framework\TestCase +{ use \Sabre\DAV\DbTestHelperTrait; /** @@ -14,8 +16,8 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { */ protected $backend; - function setUp() { - + public function setUp() + { $this->dropTables([ 'addressbooks', 'cards', @@ -26,36 +28,34 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->backend = new PDO($pdo); $pdo->exec("INSERT INTO addressbooks (principaluri, displayname, uri, description, synctoken) VALUES ('principals/user1', 'book1', 'book1', 'addressbook 1', 1)"); - $pdo->exec("INSERT INTO cards (addressbookid, carddata, uri, lastmodified, etag, size) VALUES (1, 'card1', 'card1', 0, '" . md5('card1') . "', 5)"); - + $pdo->exec("INSERT INTO cards (addressbookid, carddata, uri, lastmodified, etag, size) VALUES (1, 'card1', 'card1', 0, '".md5('card1')."', 5)"); } - function testGetAddressBooksForUser() { - + public function testGetAddressBooksForUser() + { $result = $this->backend->getAddressBooksForUser('principals/user1'); $expected = [ [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1 - ] + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book1', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 1', + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1, + ], ]; $this->assertEquals($expected, $result); - } - function testUpdateAddressBookInvalidProp() { - + public function testUpdateAddressBookInvalidProp() + { $propPatch = new PropPatch([ - '{DAV:}displayname' => 'updated', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated', - '{DAV:}foo' => 'bar', + '{DAV:}displayname' => 'updated', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'updated', + '{DAV:}foo' => 'bar', ]); $this->backend->updateAddressBook(1, $propPatch); @@ -67,22 +67,21 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1 - ] + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book1', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 1', + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1, + ], ]; $this->assertEquals($expected, $result); - } - function testUpdateAddressBookNoProps() { - + public function testUpdateAddressBookNoProps() + { $propPatch = new PropPatch([ ]); @@ -94,26 +93,24 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1 - ] + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book1', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 1', + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1, + ], ]; $this->assertEquals($expected, $result); - - } - function testUpdateAddressBookSuccess() { - + public function testUpdateAddressBookSuccess() + { $propPatch = new PropPatch([ - '{DAV:}displayname' => 'updated', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated', + '{DAV:}displayname' => 'updated', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'updated', ]); $this->backend->updateAddressBook(1, $propPatch); @@ -125,101 +122,95 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'updated', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated', - '{http://calendarserver.org/ns/}getctag' => 2, - '{http://sabredav.org/ns}sync-token' => 2 - ] + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'updated', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'updated', + '{http://calendarserver.org/ns/}getctag' => 2, + '{http://sabredav.org/ns}sync-token' => 2, + ], ]; $this->assertEquals($expected, $result); - - } - function testDeleteAddressBook() { - + public function testDeleteAddressBook() + { $this->backend->deleteAddressBook(1); $this->assertEquals([], $this->backend->getAddressBooksForUser('principals/user1')); - } /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ - function testCreateAddressBookUnsupportedProp() { - + public function testCreateAddressBookUnsupportedProp() + { $this->backend->createAddressBook('principals/user1', 'book2', [ '{DAV:}foo' => 'bar', ]); - } - function testCreateAddressBookSuccess() { - + public function testCreateAddressBookSuccess() + { $this->backend->createAddressBook('principals/user1', 'book2', [ - '{DAV:}displayname' => 'book2', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 2', + '{DAV:}displayname' => 'book2', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 2', ]); $expected = [ [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1, + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book1', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 1', + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1, ], [ - 'id' => 2, - 'uri' => 'book2', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book2', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 2', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1, - ] + 'id' => 2, + 'uri' => 'book2', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book2', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 2', + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1, + ], ]; $result = $this->backend->getAddressBooksForUser('principals/user1'); $this->assertEquals($expected, $result); - } - function testGetCards() { - + public function testGetCards() + { $result = $this->backend->getCards(1); $expected = [ [ - 'id' => 1, - 'uri' => 'card1', + 'id' => 1, + 'uri' => 'card1', 'lastmodified' => 0, - 'etag' => '"' . md5('card1') . '"', - 'size' => 5 - ] + 'etag' => '"'.md5('card1').'"', + 'size' => 5, + ], ]; $this->assertEquals($expected, $result); - } - function testGetCard() { - + public function testGetCard() + { $result = $this->backend->getCard(1, 'card1'); $expected = [ - 'id' => 1, - 'uri' => 'card1', - 'carddata' => 'card1', + 'id' => 1, + 'uri' => 'card1', + 'carddata' => 'card1', 'lastmodified' => 0, - 'etag' => '"' . md5('card1') . '"', - 'size' => 5 + 'etag' => '"'.md5('card1').'"', + 'size' => 5, ]; if (is_resource($result['carddata'])) { @@ -227,16 +218,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals($expected, $result); - } /** * @depends testGetCard */ - function testCreateCard() { - + public function testCreateCard() + { $result = $this->backend->createCard(1, 'card2', 'data2'); - $this->assertEquals('"' . md5('data2') . '"', $result); + $this->assertEquals('"'.md5('data2').'"', $result); $result = $this->backend->getCard(1, 'card2'); $this->assertEquals(2, $result['id']); $this->assertEquals('card2', $result['uri']); @@ -244,33 +234,32 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result['carddata'] = stream_get_contents($result['carddata']); } $this->assertEquals('data2', $result['carddata']); - } /** * @depends testCreateCard */ - function testGetMultiple() { - + public function testGetMultiple() + { $result = $this->backend->createCard(1, 'card2', 'data2'); $result = $this->backend->createCard(1, 'card3', 'data3'); $check = [ [ - 'id' => 1, - 'uri' => 'card1', - 'carddata' => 'card1', + 'id' => 1, + 'uri' => 'card1', + 'carddata' => 'card1', 'lastmodified' => 0, ], [ - 'id' => 2, - 'uri' => 'card2', - 'carddata' => 'data2', + 'id' => 2, + 'uri' => 'card2', + 'carddata' => 'data2', 'lastmodified' => time(), ], [ - 'id' => 3, - 'uri' => 'card3', - 'carddata' => 'data3', + 'id' => 3, + 'uri' => 'card3', + 'carddata' => 'data3', 'lastmodified' => time(), ], ]; @@ -278,40 +267,34 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $this->backend->getMultipleCards(1, ['card1', 'card2', 'card3']); foreach ($check as $index => $node) { - foreach ($node as $k => $v) { - $expected = $v; $actual = $result[$index][$k]; switch ($k) { - case 'lastmodified' : + case 'lastmodified': $this->assertInternalType('int', $actual); break; - case 'carddata' : + case 'carddata': if (is_resource($actual)) { $actual = stream_get_contents($actual); } - // No break intended. - default : + // no break intended. + default: $this->assertEquals($expected, $actual); break; } - } - } - - } /** * @depends testGetCard */ - function testUpdateCard() { - + public function testUpdateCard() + { $result = $this->backend->updateCard(1, 'card1', 'newdata'); - $this->assertEquals('"' . md5('newdata') . '"', $result); + $this->assertEquals('"'.md5('newdata').'"', $result); $result = $this->backend->getCard(1, 'card1'); $this->assertEquals(1, $result['id']); @@ -319,22 +302,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result['carddata'] = stream_get_contents($result['carddata']); } $this->assertEquals('newdata', $result['carddata']); - } /** * @depends testGetCard */ - function testDeleteCard() { - + public function testDeleteCard() + { $this->backend->deleteCard(1, 'card1'); $result = $this->backend->getCard(1, 'card1'); $this->assertFalse($result); - } - function testGetChanges() { - + public function testGetChanges() + { $backend = $this->backend; $id = $backend->createAddressBook( 'principals/user1', @@ -345,29 +326,28 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ 'syncToken' => 1, - "added" => [], - 'modified' => [], - 'deleted' => [], + 'added' => [], + 'modified' => [], + 'deleted' => [], ], $result); $currentToken = $result['syncToken']; $dummyCard = "BEGIN:VCARD\r\nEND:VCARD\r\n"; - $backend->createCard($id, "card1.ics", $dummyCard); - $backend->createCard($id, "card2.ics", $dummyCard); - $backend->createCard($id, "card3.ics", $dummyCard); - $backend->updateCard($id, "card1.ics", $dummyCard); - $backend->deleteCard($id, "card2.ics"); + $backend->createCard($id, 'card1.ics', $dummyCard); + $backend->createCard($id, 'card2.ics', $dummyCard); + $backend->createCard($id, 'card3.ics', $dummyCard); + $backend->updateCard($id, 'card1.ics', $dummyCard); + $backend->deleteCard($id, 'card2.ics'); $result = $backend->getChangesForAddressBook($id, $currentToken, 1); $this->assertEquals([ 'syncToken' => 6, - 'modified' => ["card1.ics"], - 'deleted' => ["card2.ics"], - "added" => ["card3.ics"], + 'modified' => ['card1.ics'], + 'deleted' => ['card2.ics'], + 'added' => ['card3.ics'], ], $result); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php index 8638dc74a..f7e20fbfb 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php @@ -1,29 +1,31 @@ <?php -namespace Sabre\CardDAV\Backend; +declare(strict_types=1); -class Mock extends AbstractBackend { +namespace Sabre\CardDAV\Backend; +class Mock extends AbstractBackend +{ public $addressBooks; public $cards; - function __construct($addressBooks = null, $cards = null) { - + public function __construct($addressBooks = null, $cards = null) + { $this->addressBooks = $addressBooks; $this->cards = $cards; if (is_null($this->addressBooks)) { $this->addressBooks = [ [ - 'id' => 'foo', - 'uri' => 'book1', - 'principaluri' => 'principals/user1', + 'id' => 'foo', + 'uri' => 'book1', + 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'd-name', ], [ - 'id' => 'bar', - 'uri' => 'book3', - 'principaluri' => 'principals/user1', + 'id' => 'bar', + 'uri' => 'book3', + 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'd-name', ], ]; @@ -41,20 +43,18 @@ class Mock extends AbstractBackend { ], ]; } - } - - function getAddressBooksForUser($principalUri) { - + public function getAddressBooksForUser($principalUri) + { $books = []; foreach ($this->addressBooks as $book) { if ($book['principaluri'] === $principalUri) { $books[] = $book; } } - return $books; + return $books; } /** @@ -69,45 +69,43 @@ class Mock extends AbstractBackend { * * Read the PropPatch documentation for more info and examples. * - * @param string $addressBookId + * @param string $addressBookId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) { - + public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) + { foreach ($this->addressBooks as &$book) { - if ($book['id'] !== $addressBookId) + if ($book['id'] !== $addressBookId) { continue; + } - $propPatch->handleRemaining(function($mutations) use (&$book) { + $propPatch->handleRemaining(function ($mutations) use (&$book) { foreach ($mutations as $key => $value) { $book[$key] = $value; } + return true; }); - } - } - function createAddressBook($principalUri, $url, array $properties) { - + public function createAddressBook($principalUri, $url, array $properties) + { $this->addressBooks[] = array_merge($properties, [ - 'id' => $url, - 'uri' => $url, + 'id' => $url, + 'uri' => $url, 'principaluri' => $principalUri, ]); - } - function deleteAddressBook($addressBookId) { - + public function deleteAddressBook($addressBookId) + { foreach ($this->addressBooks as $key => $value) { - if ($value['id'] === $addressBookId) + if ($value['id'] === $addressBookId) { unset($this->addressBooks[$key]); + } } unset($this->cards[$addressBookId]); - } /** @@ -127,28 +125,29 @@ class Mock extends AbstractBackend { * This may speed up certain requests, especially with large cards. * * @param mixed $addressBookId + * * @return array */ - function getCards($addressBookId) { - + public function getCards($addressBookId) + { $cards = []; foreach ($this->cards[$addressBookId] as $uri => $data) { if (is_resource($data)) { $cards[] = [ - 'uri' => $uri, + 'uri' => $uri, 'carddata' => $data, ]; } else { $cards[] = [ - 'uri' => $uri, + 'uri' => $uri, 'carddata' => $data, - 'etag' => '"' . md5($data) . '"', - 'size' => strlen($data) + 'etag' => '"'.md5($data).'"', + 'size' => strlen($data), ]; } } - return $cards; + return $cards; } /** @@ -159,24 +158,25 @@ class Mock extends AbstractBackend { * * If the card does not exist, you must return false. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri + * * @return array */ - function getCard($addressBookId, $cardUri) { - + public function getCard($addressBookId, $cardUri) + { if (!isset($this->cards[$addressBookId][$cardUri])) { return false; } $data = $this->cards[$addressBookId][$cardUri]; + return [ - 'uri' => $cardUri, + 'uri' => $cardUri, 'carddata' => $data, - 'etag' => '"' . md5($data) . '"', - 'size' => strlen($data) + 'etag' => '"'.md5($data).'"', + 'size' => strlen($data), ]; - } /** @@ -199,19 +199,20 @@ class Mock extends AbstractBackend { * * If you don't return an ETag, you can just return null. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri * @param string $cardData + * * @return string|null */ - function createCard($addressBookId, $cardUri, $cardData) { - + public function createCard($addressBookId, $cardUri, $cardData) + { if (is_resource($cardData)) { $cardData = stream_get_contents($cardData); } $this->cards[$addressBookId][$cardUri] = $cardData; - return '"' . md5($cardData) . '"'; + return '"'.md5($cardData).'"'; } /** @@ -234,25 +235,24 @@ class Mock extends AbstractBackend { * * If you don't return an ETag, you can just return null. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri * @param string $cardData + * * @return string|null */ - function updateCard($addressBookId, $cardUri, $cardData) { - + public function updateCard($addressBookId, $cardUri, $cardData) + { if (is_resource($cardData)) { $cardData = stream_get_contents($cardData); } $this->cards[$addressBookId][$cardUri] = $cardData; - return '"' . md5($cardData) . '"'; + return '"'.md5($cardData).'"'; } - function deleteCard($addressBookId, $cardUri) { - + public function deleteCard($addressBookId, $cardUri) + { unset($this->cards[$addressBookId][$cardUri]); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php index c1b0e274e..718eec6be 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\CardDAV\Backend; +declare(strict_types=1); -class PDOMySQLTest extends AbstractPDOTest { +namespace Sabre\CardDAV\Backend; +class PDOMySQLTest extends AbstractPDOTest +{ public $driver = 'mysql'; - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php index b187c4d78..b16a00ce2 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\CardDAV\Backend; +declare(strict_types=1); -class PDOSqliteTest extends AbstractPDOTest { +namespace Sabre\CardDAV\Backend; +class PDOSqliteTest extends AbstractPDOTest +{ public $driver = 'sqlite'; - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php index cb7d152c3..41853aa63 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php @@ -1,9 +1,11 @@ <?php -namespace Sabre\CardDAV; +declare(strict_types=1); -class CardTest extends \PHPUnit_Framework_TestCase { +namespace Sabre\CardDAV; +class CardTest extends \PHPUnit\Framework\TestCase +{ /** * @var Sabre\CardDAV\Card */ @@ -13,140 +15,128 @@ class CardTest extends \PHPUnit_Framework_TestCase { */ protected $backend; - function setUp() { - + public function setUp() + { $this->backend = new Backend\Mock(); $this->card = new Card( $this->backend, [ - 'uri' => 'book1', - 'id' => 'foo', + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', ], [ - 'uri' => 'card1', + 'uri' => 'card1', 'addressbookid' => 'foo', - 'carddata' => 'card', + 'carddata' => 'card', ] ); - } - function testGet() { - + public function testGet() + { $result = $this->card->get(); $this->assertEquals('card', $result); - } - function testGet2() { + public function testGet2() + { $this->card = new Card( $this->backend, [ - 'uri' => 'book1', - 'id' => 'foo', + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', ], [ - 'uri' => 'card1', + 'uri' => 'card1', 'addressbookid' => 'foo', ] ); $result = $this->card->get(); $this->assertEquals("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", $result); - } - /** * @depends testGet */ - function testPut() { - + public function testPut() + { $file = fopen('php://memory', 'r+'); fwrite($file, 'newdata'); rewind($file); $this->card->put($file); $result = $this->card->get(); $this->assertEquals('newdata', $result); - } - - function testDelete() { - + public function testDelete() + { $this->card->delete(); $this->assertEquals(1, count($this->backend->cards['foo'])); - } - function testGetContentType() { - + public function testGetContentType() + { $this->assertEquals('text/vcard; charset=utf-8', $this->card->getContentType()); - } - function testGetETag() { - - $this->assertEquals('"' . md5('card') . '"', $this->card->getETag()); - + public function testGetETag() + { + $this->assertEquals('"'.md5('card').'"', $this->card->getETag()); } - function testGetETag2() { - + public function testGetETag2() + { $card = new Card( $this->backend, [ - 'uri' => 'book1', - 'id' => 'foo', + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', ], [ - 'uri' => 'card1', + 'uri' => 'card1', 'addressbookid' => 'foo', - 'carddata' => 'card', - 'etag' => '"blabla"', + 'carddata' => 'card', + 'etag' => '"blabla"', ] ); $this->assertEquals('"blabla"', $card->getETag()); - } - function testGetLastModified() { - + public function testGetLastModified() + { $this->assertEquals(null, $this->card->getLastModified()); - } - function testGetSize() { - + public function testGetSize() + { $this->assertEquals(4, $this->card->getSize()); $this->assertEquals(4, $this->card->getSize()); - } - function testGetSize2() { - + public function testGetSize2() + { $card = new Card( $this->backend, [ - 'uri' => 'book1', - 'id' => 'foo', + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', ], [ - 'uri' => 'card1', + 'uri' => 'card1', 'addressbookid' => 'foo', - 'etag' => '"blabla"', - 'size' => 4, + 'etag' => '"blabla"', + 'size' => 4, ] ); $this->assertEquals(4, $card->getSize()); - } - function testACLMethods() { - + public function testACLMethods() + { $this->assertEquals('principals/user1', $this->card->getOwner()); $this->assertNull($this->card->getGroup()); $this->assertEquals([ @@ -156,22 +146,22 @@ class CardTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], ], $this->card->getACL()); - } - function testOverrideACL() { + public function testOverrideACL() + { $card = new Card( $this->backend, [ - 'uri' => 'book1', - 'id' => 'foo', + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', ], [ - 'uri' => 'card1', + 'uri' => 'card1', 'addressbookid' => 'foo', - 'carddata' => 'card', - 'acl' => [ + 'carddata' => 'card', + 'acl' => [ [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1', @@ -187,24 +177,20 @@ class CardTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], ], $card->getACL()); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACL() { - - $this->card->setACL([]); - + public function testSetACL() + { + $this->card->setACL([]); } - function testGetSupportedPrivilegeSet() { - + public function testGetSupportedPrivilegeSet() + { $this->assertNull( $this->card->getSupportedPrivilegeSet() ); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php index 4796a131f..760749f6c 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php @@ -1,15 +1,17 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; -class IDirectoryTest extends \PHPUnit_Framework_TestCase { - - function testResourceType() { - +class IDirectoryTest extends \PHPUnit\Framework\TestCase +{ + public function testResourceType() + { $tree = [ - new DirectoryMock('directory') + new DirectoryMock('directory'), ]; $server = new DAV\Server($tree); @@ -17,14 +19,10 @@ class IDirectoryTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($plugin); $props = $server->getProperties('directory', ['{DAV:}resourcetype']); - $this->assertTrue($props['{DAV:}resourcetype']->is('{' . Plugin::NS_CARDDAV . '}directory')); - + $this->assertTrue($props['{DAV:}resourcetype']->is('{'.Plugin::NS_CARDDAV.'}directory')); } - } -class DirectoryMock extends DAV\SimpleCollection implements IDirectory { - - - +class DirectoryMock extends DAV\SimpleCollection implements IDirectory +{ } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php index 2d57c6ae7..4e3276ed3 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; @@ -7,13 +9,13 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; -class MultiGetTest extends AbstractPluginTest { - - function testMultiGet() { - +class MultiGetTest extends AbstractPluginTest +{ + public function testMultiGet() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', + 'REQUEST_URI' => '/addressbooks/user1/book1', ]); $request->setBody( @@ -34,7 +36,7 @@ class MultiGetTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -44,19 +46,18 @@ class MultiGetTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", - ] - ] + ], + ], ], $result); - } - function testMultiGetVCard4() { - + public function testMultiGetVCard4() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', + 'REQUEST_URI' => '/addressbooks/user1/book1', ]); $request->setBody( @@ -77,23 +78,22 @@ class MultiGetTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); $result = $client->parseMultiStatus($response->body); - $prodId = "PRODID:-//Sabre//Sabre VObject " . \Sabre\VObject\Version::VERSION . "//EN"; + $prodId = 'PRODID:-//Sabre//Sabre VObject '.\Sabre\VObject\Version::VERSION.'//EN'; $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\r\nVERSION:4.0\r\n$prodId\r\nUID:12345\r\nEND:VCARD\r\n", - ] - ] + ], + ], ], $result); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php index 6962e7830..b5a68dc48 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php @@ -1,102 +1,101 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; -class PluginTest extends AbstractPluginTest { - - function testConstruct() { - - $this->assertEquals('{' . Plugin::NS_CARDDAV . '}addressbook', $this->server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook']); +class PluginTest extends AbstractPluginTest +{ + public function testConstruct() + { + $this->assertEquals('{'.Plugin::NS_CARDDAV.'}addressbook', $this->server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook']); $this->assertTrue(in_array('addressbook', $this->plugin->getFeatures())); $this->assertEquals('carddav', $this->plugin->getPluginInfo()['name']); - } - function testSupportedReportSet() { - + public function testSupportedReportSet() + { $this->assertEquals([ - '{' . Plugin::NS_CARDDAV . '}addressbook-multiget', - '{' . Plugin::NS_CARDDAV . '}addressbook-query', + '{'.Plugin::NS_CARDDAV.'}addressbook-multiget', + '{'.Plugin::NS_CARDDAV.'}addressbook-query', ], $this->plugin->getSupportedReportSet('addressbooks/user1/book1')); - } - function testSupportedReportSetEmpty() { - + public function testSupportedReportSetEmpty() + { $this->assertEquals([ ], $this->plugin->getSupportedReportSet('')); - } - function testAddressBookHomeSet() { - - $result = $this->server->getProperties('principals/user1', ['{' . Plugin::NS_CARDDAV . '}addressbook-home-set']); + public function testAddressBookHomeSet() + { + $result = $this->server->getProperties('principals/user1', ['{'.Plugin::NS_CARDDAV.'}addressbook-home-set']); $this->assertEquals(1, count($result)); - $this->assertTrue(isset($result['{' . Plugin::NS_CARDDAV . '}addressbook-home-set'])); - $this->assertEquals('addressbooks/user1/', $result['{' . Plugin::NS_CARDDAV . '}addressbook-home-set']->getHref()); - + $this->assertTrue(isset($result['{'.Plugin::NS_CARDDAV.'}addressbook-home-set'])); + $this->assertEquals('addressbooks/user1/', $result['{'.Plugin::NS_CARDDAV.'}addressbook-home-set']->getHref()); } - function testDirectoryGateway() { - - $result = $this->server->getProperties('principals/user1', ['{' . Plugin::NS_CARDDAV . '}directory-gateway']); + public function testDirectoryGateway() + { + $result = $this->server->getProperties('principals/user1', ['{'.Plugin::NS_CARDDAV.'}directory-gateway']); $this->assertEquals(1, count($result)); - $this->assertTrue(isset($result['{' . Plugin::NS_CARDDAV . '}directory-gateway'])); - $this->assertEquals(['directory'], $result['{' . Plugin::NS_CARDDAV . '}directory-gateway']->getHrefs()); - + $this->assertTrue(isset($result['{'.Plugin::NS_CARDDAV.'}directory-gateway'])); + $this->assertEquals(['directory'], $result['{'.Plugin::NS_CARDDAV.'}directory-gateway']->getHrefs()); } - function testReportPassThrough() { - + public function testReportPassThrough() + { $this->assertNull($this->plugin->report('{DAV:}foo', new \DomDocument(), '')); - } - function testHTMLActionsPanel() { - + public function testHTMLActionsPanel() + { $output = ''; $r = $this->server->emit('onHTMLActionsPanel', [$this->server->tree->getNodeForPath('addressbooks/user1'), &$output]); $this->assertFalse($r); - $this->assertTrue(!!strpos($output, 'Display name')); - + $this->assertTrue((bool) strpos($output, 'Display name')); } - function testAddressbookPluginProperties() { - - $ns = '{' . Plugin::NS_CARDDAV . '}'; + public function testAddressbookPluginProperties() + { + $ns = '{'.Plugin::NS_CARDDAV.'}'; $propFind = new DAV\PropFind('addressbooks/user1/book1', [ - $ns . 'supported-address-data', - $ns . 'supported-collation-set', + $ns.'supported-address-data', + $ns.'supported-collation-set', ]); $node = $this->server->tree->getNodeForPath('addressbooks/user1/book1'); $this->plugin->propFindEarly($propFind, $node); $this->assertInstanceOf( 'Sabre\\CardDAV\\Xml\\Property\\SupportedAddressData', - $propFind->get($ns . 'supported-address-data') + $propFind->get($ns.'supported-address-data') ); $this->assertInstanceOf( 'Sabre\\CardDAV\\Xml\\Property\\SupportedCollationSet', - $propFind->get($ns . 'supported-collation-set') + $propFind->get($ns.'supported-collation-set') ); - - } - function testGetTransform() { - - $request = new \Sabre\HTTP\Request('GET', '/addressbooks/user1/book1/card1', ['Accept: application/vcard+json']); + public function testGetTransform() + { + $request = new \Sabre\HTTP\Request('GET', '/addressbooks/user1/book1/card1', ['Accept' => 'application/vcard+json']); $response = new \Sabre\HTTP\ResponseMock(); $this->server->invokeMethod($request, $response); $this->assertEquals(200, $response->getStatus()); - } + public function testGetWithoutContentType() + { + $request = new \Sabre\HTTP\Request('GET', '/'); + $response = new \Sabre\HTTP\ResponseMock(); + $this->plugin->httpAfterGet($request, $response); + $this->assertTrue(true); + } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php index d4bc48098..8d045569c 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php @@ -1,17 +1,19 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV\PropFind; use Sabre\HTTP; -class SogoStripContentTypeTest extends \Sabre\DAVServerTest { - +class SogoStripContentTypeTest extends \Sabre\DAVServerTest +{ protected $setupCardDAV = true; protected $carddavAddressBooks = [ [ - 'id' => 1, - 'uri' => 'book1', + 'id' => 1, + 'uri' => 'book1', 'principaluri' => 'principals/user1', ], ]; @@ -21,27 +23,27 @@ class SogoStripContentTypeTest extends \Sabre\DAVServerTest { ], ]; - function testDontStrip() { - + public function testDontStrip() + { $result = $this->server->getProperties('addressbooks/user1/book1/card1.vcf', ['{DAV:}getcontenttype']); $this->assertEquals([ - '{DAV:}getcontenttype' => 'text/vcard; charset=utf-8' + '{DAV:}getcontenttype' => 'text/vcard; charset=utf-8', ], $result); - } - function testStrip() { - $this->server->httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1', + public function testStrip() + { + $this->server->httpRequest = new HTTP\Request('GET', '/', [ + 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1', ]); $result = $this->server->getProperties('addressbooks/user1/book1/card1.vcf', ['{DAV:}getcontenttype']); $this->assertEquals([ - '{DAV:}getcontenttype' => 'text/x-vcard' + '{DAV:}getcontenttype' => 'text/x-vcard', ], $result); - } - function testDontTouchOtherMimeTypes() { + public function testDontTouchOtherMimeTypes() + { $this->server->httpRequest = new HTTP\Request('GET', '/addressbooks/user1/book1/card1.vcf', [ 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1', ]); @@ -50,7 +52,16 @@ class SogoStripContentTypeTest extends \Sabre\DAVServerTest { $propFind->set('{DAV:}getcontenttype', 'text/plain'); $this->carddavPlugin->propFindLate($propFind, new \Sabre\DAV\SimpleCollection('foo')); $this->assertEquals('text/plain', $propFind->get('{DAV:}getcontenttype')); - } + public function testStripWithoutGetContentType() + { + $this->server->httpRequest = new HTTP\Request('GET', '/addressbooks/user1/book1/card1.vcf', [ + 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1', + ]); + + $propFind = new PropFind('hello', ['{DAV:}getcontenttype']); + $this->carddavPlugin->propFindLate($propFind, new \Sabre\DAV\SimpleCollection('foo')); + $this->assertEquals(null, $propFind->get('{DAV:}getcontenttype')); // Property not present + } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php b/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php index ec8a3501e..0bdf07df5 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php @@ -1,18 +1,20 @@ <?php -namespace Sabre\CardDAV; - -class TestUtil { +declare(strict_types=1); - static function getBackend() { +namespace Sabre\CardDAV; +class TestUtil +{ + public static function getBackend() + { $backend = new Backend\PDO(self::getSQLiteDB()); - return $backend; + return $backend; } - static function getSQLiteDB() { - + public static function getSQLiteDB() + { $pdo = Backend\PDOSqliteTest::getSQLite(); // Inserting events through a backend class. @@ -21,7 +23,7 @@ class TestUtil { 'principals/user1', 'UUID-123467', [ - '{DAV:}displayname' => 'user1 addressbook', + '{DAV:}displayname' => 'user1 addressbook', '{urn:ietf:params:xml:ns:carddav}addressbook-description' => 'AddressBook description', ] ); @@ -29,22 +31,23 @@ class TestUtil { 'principals/user1', 'UUID-123468', [ - '{DAV:}displayname' => 'user1 addressbook2', + '{DAV:}displayname' => 'user1 addressbook2', '{urn:ietf:params:xml:ns:carddav}addressbook-description' => 'AddressBook description', ] ); $backend->createCard($addressbookId, 'UUID-2345', self::getTestCardData()); - return $pdo; + return $pdo; } - static function deleteSQLiteDB() { + public static function deleteSQLiteDB() + { $sqliteTest = new Backend\PDOSqliteTest(); $pdo = $sqliteTest->tearDown(); } - static function getTestCardData() { - + public static function getTestCardData() + { $addressbookData = 'BEGIN:VCARD VERSION:3.0 PRODID:-//Acme Inc.//RoadRunner 1.0//EN @@ -56,7 +59,5 @@ REV:2012-06-20T07:00:39+00:00 END:VCARD'; return $addressbookData; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php index 82d82fadd..d8acc3c14 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php @@ -1,43 +1,44 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\HTTP; -class VCFExportTest extends \Sabre\DAVServerTest { - +class VCFExportTest extends \Sabre\DAVServerTest +{ protected $setupCardDAV = true; protected $autoLogin = 'user1'; protected $setupACL = true; protected $carddavAddressBooks = [ [ - 'id' => 'book1', - 'uri' => 'book1', + 'id' => 'book1', + 'uri' => 'book1', 'principaluri' => 'principals/user1', - ] + ], ]; protected $carddavCards = [ 'book1' => [ - "card1" => "BEGIN:VCARD\r\nFN:Person1\r\nEND:VCARD\r\n", - "card2" => "BEGIN:VCARD\r\nFN:Person2\r\nEND:VCARD", - "card3" => "BEGIN:VCARD\r\nFN:Person3\r\nEND:VCARD\r\n", - "card4" => "BEGIN:VCARD\nFN:Person4\nEND:VCARD\n", - ] + 'card1' => "BEGIN:VCARD\r\nFN:Person1\r\nEND:VCARD\r\n", + 'card2' => "BEGIN:VCARD\r\nFN:Person2\r\nEND:VCARD", + 'card3' => "BEGIN:VCARD\r\nFN:Person3\r\nEND:VCARD\r\n", + 'card4' => "BEGIN:VCARD\nFN:Person4\nEND:VCARD\n", + ], ]; - function setUp() { - + public function setUp() + { parent::setUp(); $plugin = new VCFExportPlugin(); $this->server->addPlugin( $plugin ); - } - function testSimple() { - + public function testSimple() + { $plugin = $this->server->getPlugin('vcf-export'); $this->assertInstanceOf('Sabre\\CardDAV\\VCFExportPlugin', $plugin); @@ -45,21 +46,20 @@ class VCFExportTest extends \Sabre\DAVServerTest { 'vcf-export', $plugin->getPluginInfo()['name'] ); - } - function testExport() { - + public function testExport() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/addressbooks/user1/book1?export', - 'QUERY_STRING' => 'export', + 'REQUEST_URI' => '/addressbooks/user1/book1?export', + 'QUERY_STRING' => 'export', 'REQUEST_METHOD' => 'GET', ]); $response = $this->request($request); $this->assertEquals(200, $response->status, $response->body); - $expected = "BEGIN:VCARD + $expected = 'BEGIN:VCARD FN:Person1 END:VCARD BEGIN:VCARD @@ -71,26 +71,24 @@ END:VCARD BEGIN:VCARD FN:Person4 END:VCARD -"; +'; // We actually expected windows line endings $expected = str_replace("\n", "\r\n", $expected); $this->assertEquals($expected, $response->body); - } - function testBrowserIntegration() { - + public function testBrowserIntegration() + { $plugin = $this->server->getPlugin('vcf-export'); $actions = ''; $addressbook = new AddressBook($this->carddavBackend, []); $this->server->emit('browserButtonActions', ['/foo', $addressbook, &$actions]); $this->assertContains('/foo?export', $actions); - } - function testContentDisposition() { - + public function testContentDisposition() + { $request = new HTTP\Request( 'GET', '/addressbooks/user1/book1?export' @@ -99,14 +97,13 @@ END:VCARD $response = $this->request($request, 200); $this->assertEquals('text/directory', $response->getHeader('Content-Type')); $this->assertEquals( - 'attachment; filename="book1-' . date('Y-m-d') . '.vcf"', + 'attachment; filename="book1-'.date('Y-m-d').'.vcf"', $response->getHeader('Content-Disposition') ); - } - function testContentDispositionBadChars() { - + public function testContentDispositionBadChars() + { $this->carddavBackend->createAddressBook( 'principals/user1', 'book-b_ad"(ch)ars', @@ -126,10 +123,8 @@ END:VCARD $response = $this->request($request, 200); $this->assertEquals('text/directory', $response->getHeader('Content-Type')); $this->assertEquals( - 'attachment; filename="book-b_adchars-' . date('Y-m-d') . '.vcf"', + 'attachment; filename="book-b_adchars-'.date('Y-m-d').'.vcf"', $response->getHeader('Content-Disposition') ); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php index 03c468f86..753efc73d 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php @@ -1,31 +1,32 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; require_once 'Sabre/CardDAV/AbstractPluginTest.php'; -class ValidateFilterTest extends AbstractPluginTest { - +class ValidateFilterTest extends AbstractPluginTest +{ /** - * @param string $input - * @param array $filters - * @param string $test - * @param bool $result + * @param string $input + * @param array $filters + * @param string $test + * @param bool $result * @param string|null $message * @dataProvider data */ - function testFilter($input, $filters, $test, $result, $message = null) { - + public function testFilter($input, $filters, $test, $result, $message = null) + { if ($result) { $this->assertTrue($this->plugin->validateFilters($input, $filters, $test), $message); } else { $this->assertFalse($this->plugin->validateFilters($input, $filters, $test), $message); } - } - function data() { - + public function data() + { $body1 = <<<HELLO BEGIN:VCARD VERSION:3.0 @@ -70,14 +71,14 @@ HELLO; // Check if TEL[TYPE] is defined $filter5 = [ - 'name' => 'tel', + 'name' => 'tel', 'is-not-defined' => false, - 'test' => 'anyof', - 'param-filters' => [ + 'test' => 'anyof', + 'param-filters' => [ [ - 'name' => 'type', + 'name' => 'type', 'is-not-defined' => false, - 'text-match' => null + 'text-match' => null, ], ], 'text-matches' => [], @@ -107,16 +108,16 @@ HELLO; // Check if URL contains 'google' $filter11 = [ - 'name' => 'url', + 'name' => 'url', 'is-not-defined' => false, - 'test' => 'anyof', - 'param-filters' => [], - 'text-matches' => [ + 'test' => 'anyof', + 'param-filters' => [], + 'text-matches' => [ [ - 'match-type' => 'contains', - 'value' => 'google', + 'match-type' => 'contains', + 'value' => 'google', 'negate-condition' => false, - 'collation' => 'i;octet', + 'collation' => 'i;octet', ], ], ]; @@ -137,22 +138,21 @@ HELLO; // Param filter with text $filter15 = $filter5; $filter15['param-filters'][0]['text-match'] = [ - 'match-type' => 'contains', - 'value' => 'WORK', - 'collation' => 'i;octet', + 'match-type' => 'contains', + 'value' => 'WORK', + 'collation' => 'i;octet', 'negate-condition' => false, ]; $filter16 = $filter15; $filter16['param-filters'][0]['text-match']['negate-condition'] = true; - // Param filter + text filter $filter17 = $filter5; $filter17['test'] = 'anyof'; $filter17['text-matches'][] = [ - 'match-type' => 'contains', - 'value' => '444', - 'collation' => 'i;octet', + 'match-type' => 'contains', + 'value' => '444', + 'collation' => 'i;octet', 'negate-condition' => false, ]; @@ -162,20 +162,19 @@ HELLO; $filter18['test'] = 'allof'; return [ - // Basic filters - [$body1, [$filter1], 'anyof',true], - [$body1, [$filter2], 'anyof',false], - [$body1, [$filter3], 'anyof',false], - [$body1, [$filter4], 'anyof',true], + [$body1, [$filter1], 'anyof', true], + [$body1, [$filter2], 'anyof', false], + [$body1, [$filter3], 'anyof', false], + [$body1, [$filter4], 'anyof', true], // Combinations - [$body1, [$filter1, $filter2], 'anyof',true], - [$body1, [$filter1, $filter2], 'allof',false], - [$body1, [$filter1, $filter4], 'anyof',true], - [$body1, [$filter1, $filter4], 'allof',true], - [$body1, [$filter2, $filter3], 'anyof',false], - [$body1, [$filter2, $filter3], 'allof',false], + [$body1, [$filter1, $filter2], 'anyof', true], + [$body1, [$filter1, $filter2], 'allof', false], + [$body1, [$filter1, $filter4], 'anyof', true], + [$body1, [$filter1, $filter4], 'allof', true], + [$body1, [$filter2, $filter3], 'anyof', false], + [$body1, [$filter2, $filter3], 'allof', false], // Basic parameters [$body1, [$filter5], 'anyof', true, 'TEL;TYPE is defined, so this should return true'], @@ -203,7 +202,5 @@ HELLO; [$body1, [$filter18], 'anyof', false], [$body1, [$filter18], 'anyof', false], ]; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php index acba2cfc8..2317b86cc 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; @@ -8,19 +10,19 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; -class ValidateVCardTest extends \PHPUnit_Framework_TestCase { - +class ValidateVCardTest extends \PHPUnit\Framework\TestCase +{ protected $server; protected $cardBackend; - function setUp() { - + public function setUp() + { $addressbooks = [ [ - 'id' => 'addressbook1', + 'id' => 'addressbook1', 'principaluri' => 'principals/admin', - 'uri' => 'addressbook1', - ] + 'uri' => 'addressbook1', + ], ]; $this->cardBackend = new Backend\Mock($addressbooks, []); @@ -39,21 +41,19 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { $response = new HTTP\ResponseMock(); $this->server->httpResponse = $response; - } - function request(HTTP\Request $request, $expectedStatus = null) { - + public function request(HTTP\Request $request, $expectedStatus = null) + { $this->server->httpRequest = $request; $this->server->exec(); if ($expectedStatus) { - $realStatus = $this->server->httpResponse->getStatus(); $msg = ''; if ($realStatus !== $expectedStatus) { - $msg = 'Response body: ' . $this->server->httpResponse->getBodyAsString(); + $msg = 'Response body: '.$this->server->httpResponse->getBodyAsString(); } $this->assertEquals( $expectedStatus, @@ -63,24 +63,22 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { } return $this->server->httpResponse; - } - function testCreateFile() { - + public function testCreateFile() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', + 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', ]); $response = $this->request($request); $this->assertEquals(415, $response->status); - } - function testCreateFileValid() { - + public function testCreateFileValid() + { $request = new HTTP\Request( 'PUT', '/addressbooks/admin/addressbook1/blabla.vcf' @@ -104,20 +102,18 @@ VCF; ); // Valid, non-auto-fixed responses should contain an ETag. $this->assertTrue( - $response->getHeader('ETag') !== null, + null !== $response->getHeader('ETag'), 'We did not receive an etag' ); - $expected = [ - 'uri' => 'blabla.vcf', + 'uri' => 'blabla.vcf', 'carddata' => $vcard, - 'size' => strlen($vcard), - 'etag' => '"' . md5($vcard) . '"', + 'size' => strlen($vcard), + 'etag' => '"'.md5($vcard).'"', ]; $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf')); - } /** @@ -126,8 +122,8 @@ VCF; * * @depends testCreateFileValid */ - function testCreateVCardAutoFix() { - + public function testCreateVCardAutoFix() + { $request = new HTTP\Request( 'PUT', '/addressbooks/admin/addressbook1/blabla.vcf' @@ -168,14 +164,13 @@ END:VCARD\r VCF; $expected = [ - 'uri' => 'blabla.vcf', + 'uri' => 'blabla.vcf', 'carddata' => $expectedVCard, - 'size' => strlen($expectedVCard), - 'etag' => '"' . md5($expectedVCard) . '"', + 'size' => strlen($expectedVCard), + 'etag' => '"'.md5($expectedVCard).'"', ]; $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf')); - } /** @@ -187,8 +182,8 @@ VCF; * * @depends testCreateFileValid */ - function testCreateVCardStrictFail() { - + public function testCreateVCardStrictFail() + { $request = new HTTP\Request( 'PUT', '/addressbooks/admin/addressbook1/blabla.vcf', @@ -209,11 +204,10 @@ VCF; $request->setBody($vcard); $this->request($request, 415); - } - function testCreateFileNoUID() { - + public function testCreateFileNoUID() + { $request = new HTTP\Request( 'PUT', '/addressbooks/admin/addressbook1/blabla.vcf' @@ -231,13 +225,13 @@ VCF; $foo = $this->cardBackend->getCard('addressbook1', 'blabla.vcf'); $this->assertTrue( - strpos($foo['carddata'], 'UID') !== false, + false !== strpos($foo['carddata'], 'UID'), print_r($foo, true) ); } - function testCreateFileJson() { - + public function testCreateFileJson() + { $request = new HTTP\Request( 'PUT', '/addressbooks/admin/addressbook1/blabla.vcf' @@ -246,29 +240,27 @@ VCF; $response = $this->request($request); - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->body); $foo = $this->cardBackend->getCard('addressbook1', 'blabla.vcf'); $this->assertEquals("BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nFN:FirstName LastName\r\nEND:VCARD\r\n", $foo['carddata']); - } - function testCreateFileVCalendar() { - + public function testCreateFileVCalendar() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', + 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', ]); $request->setBody("BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testUpdateFile() { - + public function testUpdateFile() + { $this->cardBackend->createCard('addressbook1', 'blabla.vcf', 'foo'); $request = new HTTP\Request( 'PUT', @@ -276,11 +268,10 @@ VCF; ); $response = $this->request($request, 415); - } - function testUpdateFileParsableBody() { - + public function testUpdateFileParsableBody() + { $this->cardBackend->createCard('addressbook1', 'blabla.vcf', 'foo'); $request = new HTTP\Request( 'PUT', @@ -293,13 +284,12 @@ VCF; $response = $this->request($request, 204); $expected = [ - 'uri' => 'blabla.vcf', + 'uri' => 'blabla.vcf', 'carddata' => $body, - 'size' => strlen($body), - 'etag' => '"' . md5($body) . '"', + 'size' => strlen($body), + 'etag' => '"'.md5($body).'"', ]; $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf')); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php b/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php index 6a8d389a0..5f5d666f9 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; -abstract class AbstractServer extends \PHPUnit_Framework_TestCase { - +abstract class AbstractServer extends \PHPUnit\Framework\TestCase +{ /** * @var Sabre\HTTP\ResponseMock */ @@ -17,48 +19,44 @@ abstract class AbstractServer extends \PHPUnit_Framework_TestCase { protected $server; protected $tempDir = SABRE_TEMPDIR; - function setUp() { - + public function setUp() + { $this->response = new HTTP\ResponseMock(); $this->server = new Server($this->getRootNode()); $this->server->sapi = new HTTP\SapiMock(); $this->server->httpResponse = $this->response; $this->server->debugExceptions = true; $this->deleteTree(SABRE_TEMPDIR, false); - file_put_contents(SABRE_TEMPDIR . '/test.txt', 'Test contents'); - mkdir(SABRE_TEMPDIR . '/dir'); - file_put_contents(SABRE_TEMPDIR . '/dir/child.txt', 'Child contents'); - - + file_put_contents(SABRE_TEMPDIR.'/test.txt', 'Test contents'); + mkdir(SABRE_TEMPDIR.'/dir'); + file_put_contents(SABRE_TEMPDIR.'/dir/child.txt', 'Child contents'); } - function tearDown() { - + public function tearDown() + { $this->deleteTree(SABRE_TEMPDIR, false); - } - protected function getRootNode() { - + protected function getRootNode() + { return new FS\Directory(SABRE_TEMPDIR); - } - private function deleteTree($path, $deleteRoot = true) { - + private function deleteTree($path, $deleteRoot = true) + { foreach (scandir($path) as $node) { - - if ($node == '.' || $node == '.svn' || $node == '..') continue; - $myPath = $path . '/' . $node; + if ('.' == $node || '.svn' == $node || '..' == $node) { + continue; + } + $myPath = $path.'/'.$node; if (is_file($myPath)) { unlink($myPath); } else { $this->deleteTree($myPath); } - } - if ($deleteRoot) rmdir($path); - + if ($deleteRoot) { + rmdir($path); + } } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php index 917f5ec3f..ebc1e3f7b 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php @@ -1,14 +1,16 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP; -class AbstractBasicTest extends \PHPUnit_Framework_TestCase { - - function testCheckNoHeaders() { - - $request = new HTTP\Request(); +class AbstractBasicTest extends \PHPUnit\Framework\TestCase +{ + public function testCheckNoHeaders() + { + $request = new HTTP\Request('GET', '/'); $response = new HTTP\Response(); $backend = new AbstractBasicMock(); @@ -16,14 +18,15 @@ class AbstractBasicTest extends \PHPUnit_Framework_TestCase { $this->assertFalse( $backend->check($request, $response)[0] ); - } - function testCheckUnknownUser() { - + public function testCheckUnknownUser() + { $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'wrongpassword', + 'PHP_AUTH_PW' => 'wrongpassword', ]); $response = new HTTP\Response(); @@ -32,14 +35,15 @@ class AbstractBasicTest extends \PHPUnit_Framework_TestCase { $this->assertFalse( $backend->check($request, $response)[0] ); - } - function testCheckSuccess() { - + public function testCheckSuccess() + { $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'password', + 'PHP_AUTH_PW' => 'password', ]); $response = new HTTP\Response(); @@ -48,44 +52,39 @@ class AbstractBasicTest extends \PHPUnit_Framework_TestCase { [true, 'principals/username'], $backend->check($request, $response) ); - } - function testRequireAuth() { - - $request = new HTTP\Request(); + public function testRequireAuth() + { + $request = new HTTP\Request('GET', '/'); $response = new HTTP\Response(); $backend = new AbstractBasicMock(); $backend->setRealm('writing unittests on a saturday night'); $backend->challenge($request, $response); - $this->assertContains( - 'Basic realm="writing unittests on a saturday night"', + $this->assertEquals( + 'Basic realm="writing unittests on a saturday night", charset="UTF-8"', $response->getHeader('WWW-Authenticate') ); - } - } - -class AbstractBasicMock extends AbstractBasic { - +class AbstractBasicMock extends AbstractBasic +{ /** - * Validates a username and password + * Validates a username and password. * * This method should return true or false depending on if login * succeeded. * * @param string $username * @param string $password + * * @return bool */ - function validateUserPass($username, $password) { - - return ($username == 'username' && $password == 'password'); - + public function validateUserPass($username, $password) + { + return 'username' == $username && 'password' == $password; } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php index 14c72aaa0..d9af326fe 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php @@ -1,27 +1,30 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP; -class AbstractDigestTest extends \PHPUnit_Framework_TestCase { - - function testCheckNoHeaders() { - - $request = new HTTP\Request(); +class AbstractDigestTest extends \PHPUnit\Framework\TestCase +{ + public function testCheckNoHeaders() + { + $request = new HTTP\Request('GET', '/'); $response = new HTTP\Response(); $backend = new AbstractDigestMock(); $this->assertFalse( $backend->check($request, $response)[0] ); - } - function testCheckBadGetUserInfoResponse() { - + public function testCheckBadGetUserInfoResponse() + { $header = 'username=null, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'PHP_AUTH_DIGEST' => $header, ]); $response = new HTTP\Response(); @@ -30,16 +33,17 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { $this->assertFalse( $backend->check($request, $response)[0] ); - } /** - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testCheckBadGetUserInfoResponse2() { - + public function testCheckBadGetUserInfoResponse2() + { $header = 'username=array, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'PHP_AUTH_DIGEST' => $header, ]); @@ -47,13 +51,14 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { $backend = new AbstractDigestMock(); $backend->check($request, $response); - } - function testCheckUnknownUser() { - + public function testCheckUnknownUser() + { $header = 'username=false, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'PHP_AUTH_DIGEST' => $header, ]); @@ -63,15 +68,15 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { $this->assertFalse( $backend->check($request, $response)[0] ); - } - function testCheckBadPassword() { - + public function testCheckBadPassword() + { $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'PUT', + 'REQUEST_URI' => '/', 'PHP_AUTH_DIGEST' => $header, - 'REQUEST_METHOD' => 'PUT', ]); $response = new HTTP\Response(); @@ -80,17 +85,16 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { $this->assertFalse( $backend->check($request, $response)[0] ); - } - function testCheck() { - - $digestHash = md5('HELLO:12345:1:1:auth:' . md5('GET:/')); - $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response=' . $digestHash . ', opaque=1, qop=auth, nc=1, cnonce=1'; + public function testCheck() + { + $digestHash = md5('HELLO:12345:1:1:auth:'.md5('GET:/')); + $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response='.$digestHash.', opaque=1, qop=auth, nc=1, cnonce=1'; $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'GET', + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'PHP_AUTH_DIGEST' => $header, - 'REQUEST_URI' => '/', ]); $response = new HTTP\Response(); @@ -100,12 +104,11 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { [true, 'principals/user'], $backend->check($request, $response) ); - } - function testRequireAuth() { - - $request = new HTTP\Request(); + public function testRequireAuth() + { + $request = new HTTP\Request('GET', '/'); $response = new HTTP\Response(); $backend = new AbstractDigestMock(); @@ -116,23 +119,18 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { 'Digest realm="writing unittests on a saturday night"', $response->getHeader('WWW-Authenticate') ); - } - } - -class AbstractDigestMock extends AbstractDigest { - - function getDigestHash($realm, $userName) { - +class AbstractDigestMock extends AbstractDigest +{ + public function getDigestHash($realm, $userName) + { switch ($userName) { - case 'null' : return null; - case 'false' : return false; - case 'array' : return []; - case 'user' : return 'HELLO'; + case 'null': return null; + case 'false': return false; + case 'array': return []; + case 'user': return 'HELLO'; } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php index b14e9fa2e..5e34f9c49 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php @@ -1,36 +1,35 @@ <?php -namespace Sabre\DAV\Auth\Backend; +declare(strict_types=1); -abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { +namespace Sabre\DAV\Auth\Backend; +abstract class AbstractPDOTest extends \PHPUnit\Framework\TestCase +{ use \Sabre\DAV\DbTestHelperTrait; - function setUp() { - + public function setUp() + { $this->dropTables('users'); $this->createSchema('users'); $this->getPDO()->query( "INSERT INTO users (username,digesta1) VALUES ('user','hash')" - ); - } - function testConstruct() { - + public function testConstruct() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $this->assertTrue($backend instanceof PDO); - } /** * @depends testConstruct */ - function testUserInfo() { - + public function testUserInfo() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); @@ -39,7 +38,5 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = 'hash'; $this->assertEquals($expected, $backend->getDigestHash('realm', 'user')); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php index 29cbc2162..a0086518f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php @@ -1,33 +1,35 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP; -class ApacheTest extends \PHPUnit_Framework_TestCase { - - function testConstruct() { - +class ApacheTest extends \PHPUnit\Framework\TestCase +{ + public function testConstruct() + { $backend = new Apache(); $this->assertInstanceOf('Sabre\DAV\Auth\Backend\Apache', $backend); - } - function testNoHeader() { - - $request = new HTTP\Request(); + public function testNoHeader() + { + $request = new HTTP\Request('GET', '/'); $response = new HTTP\Response(); $backend = new Apache(); $this->assertFalse( $backend->check($request, $response)[0] ); - } - function testRemoteUser() { - + public function testRemoteUser() + { $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'REMOTE_USER' => 'username', ]); $response = new HTTP\Response(); @@ -37,12 +39,13 @@ class ApacheTest extends \PHPUnit_Framework_TestCase { [true, 'principals/username'], $backend->check($request, $response) ); - } - function testRedirectRemoteUser() { - + public function testRedirectRemoteUser() + { $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'REDIRECT_REMOTE_USER' => 'username', ]); $response = new HTTP\Response(); @@ -52,12 +55,11 @@ class ApacheTest extends \PHPUnit_Framework_TestCase { [true, 'principals/username'], $backend->check($request, $response) ); - } - function testRequireAuth() { - - $request = new HTTP\Request(); + public function testRequireAuth() + { + $request = new HTTP\Request('GET', '/'); $response = new HTTP\Response(); $backend = new Apache(); @@ -66,6 +68,5 @@ class ApacheTest extends \PHPUnit_Framework_TestCase { $this->assertNull( $response->getHeader('WWW-Authenticate') ); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php index f694f4806..0297b17f9 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php @@ -1,41 +1,40 @@ <?php -namespace Sabre\DAV\Auth\Backend; - -class FileTest extends \PHPUnit_Framework_TestCase { - - function tearDown() { +declare(strict_types=1); - if (file_exists(SABRE_TEMPDIR . '/filebackend')) unlink(SABRE_TEMPDIR . '/filebackend'); +namespace Sabre\DAV\Auth\Backend; +class FileTest extends \PHPUnit\Framework\TestCase +{ + public function tearDown() + { + if (file_exists(SABRE_TEMPDIR.'/filebackend')) { + unlink(SABRE_TEMPDIR.'/filebackend'); + } } - function testConstruct() { - + public function testConstruct() + { $file = new File(); $this->assertTrue($file instanceof File); - } /** - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testLoadFileBroken() { - - file_put_contents(SABRE_TEMPDIR . '/backend', 'user:realm:hash'); - $file = new File(SABRE_TEMPDIR . '/backend'); - + public function testLoadFileBroken() + { + file_put_contents(SABRE_TEMPDIR.'/backend', 'user:realm:hash'); + $file = new File(SABRE_TEMPDIR.'/backend'); } - function testLoadFile() { - - file_put_contents(SABRE_TEMPDIR . '/backend', 'user:realm:' . md5('user:realm:password')); + public function testLoadFile() + { + file_put_contents(SABRE_TEMPDIR.'/backend', 'user:realm:'.md5('user:realm:password')); $file = new File(); - $file->loadFile(SABRE_TEMPDIR . '/backend'); + $file->loadFile(SABRE_TEMPDIR.'/backend'); $this->assertFalse($file->getDigestHash('realm', 'blabla')); $this->assertEquals(md5('user:realm:password'), $file->getDigestHash('realm', 'user')); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php index 369bc249e..730f2a975 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php @@ -1,22 +1,23 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -class Mock implements BackendInterface { - +class Mock implements BackendInterface +{ public $fail = false; public $invalidCheckResponse = false; public $principal = 'principals/admin'; - function setPrincipal($principal) { - + public function setPrincipal($principal) + { $this->principal = $principal; - } /** @@ -43,20 +44,21 @@ class Mock implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { if ($this->invalidCheckResponse) { return 'incorrect!'; } if ($this->fail) { - return [false, "fail!"]; + return [false, 'fail!']; } - return [true, $this->principal]; + return [true, $this->principal]; } /** @@ -76,12 +78,10 @@ class Mock implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php index 18f59793a..6ad7906c4 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\DAV\Auth\Backend; +declare(strict_types=1); -class PDOMySQLTest extends AbstractPDOTest { +namespace Sabre\DAV\Auth\Backend; +class PDOMySQLTest extends AbstractPDOTest +{ public $driver = 'mysql'; - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php index b1f382237..b42b40eff 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\DAV\Auth\Backend; +declare(strict_types=1); -class PDOSqliteTest extends AbstractPDOTest { +namespace Sabre\DAV\Auth\Backend; +class PDOSqliteTest extends AbstractPDOTest +{ public $driver = 'sqlite'; - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php index 743446127..03c8a4624 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php @@ -1,58 +1,57 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth; use Sabre\DAV; use Sabre\HTTP; -class PluginTest extends \PHPUnit_Framework_TestCase { - - function testInit() { - +class PluginTest extends \PHPUnit\Framework\TestCase +{ + public function testInit() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); $this->assertEquals($plugin, $fakeServer->getPlugin('auth')); $this->assertInternalType('array', $plugin->getPluginInfo()); - } /** * @depends testInit */ - function testAuthenticate() { - + public function testAuthenticate() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $fakeServer->addPlugin($plugin); $this->assertTrue( - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]) + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]) ); - } /** * @depends testInit - * @expectedException Sabre\DAV\Exception\NotAuthenticated + * @expectedException \Sabre\DAV\Exception\NotAuthenticated */ - function testAuthenticateFail() { - + public function testAuthenticateFail() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->fail = true; $plugin = new Plugin($backend); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); - + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); } /** * @depends testAuthenticateFail */ - function testAuthenticateFailDontAutoRequire() { - + public function testAuthenticateFailDontAutoRequire() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->fail = true; @@ -61,17 +60,16 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $plugin->autoRequireLogin = false; $fakeServer->addPlugin($plugin); $this->assertTrue( - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]) + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]) ); $this->assertEquals(1, count($plugin->getLoginFailedReasons())); - } /** * @depends testAuthenticate */ - function testMultipleBackend() { - + public function testMultipleBackend() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend1 = new Backend\Mock(); $backend2 = new Backend\Mock(); @@ -82,52 +80,48 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $plugin->addBackend($backend2); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); $this->assertEquals('principals/admin', $plugin->getCurrentPrincipal()); - } /** * @depends testInit - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testNoAuthBackend() { - + public function testNoAuthBackend() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); - + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); } + /** * @depends testInit - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testInvalidCheckResponse() { - + public function testInvalidCheckResponse() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->invalidCheckResponse = true; $plugin = new Plugin($backend); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); - + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); } /** * @depends testAuthenticate */ - function testGetCurrentPrincipal() { - + public function testGetCurrentPrincipal() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); $this->assertEquals('principals/admin', $plugin->getCurrentPrincipal()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php index ec104ec80..60fcc73fc 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php @@ -1,235 +1,138 @@ <?php -namespace Sabre\DAV; +declare(strict_types=1); -class BasicNodeTest extends \PHPUnit_Framework_TestCase { +namespace Sabre\DAV; +class BasicNodeTest extends \PHPUnit\Framework\TestCase +{ /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testPut() { - + public function testPut() + { $file = new FileMock(); $file->put('hi'); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testGet() { - + public function testGet() + { $file = new FileMock(); $file->get(); - } - function testGetSize() { - + public function testGetSize() + { $file = new FileMock(); $this->assertEquals(0, $file->getSize()); - } - - function testGetETag() { - + public function testGetETag() + { $file = new FileMock(); $this->assertNull($file->getETag()); - } - function testGetContentType() { - + public function testGetContentType() + { $file = new FileMock(); $this->assertNull($file->getContentType()); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testDelete() { - + public function testDelete() + { $file = new FileMock(); $file->delete(); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetName() { - + public function testSetName() + { $file = new FileMock(); $file->setName('hi'); - } - function testGetLastModified() { - + public function testGetLastModified() + { $file = new FileMock(); // checking if lastmod is within the range of a few seconds $lastMod = $file->getLastModified(); $compareTime = ($lastMod + 1) - time(); $this->assertTrue($compareTime < 3); - } - function testGetChild() { - + public function testGetChild() + { $dir = new DirectoryMock(); $file = $dir->getChild('mockfile'); $this->assertTrue($file instanceof FileMock); - } - function testChildExists() { - + public function testChildExists() + { $dir = new DirectoryMock(); $this->assertTrue($dir->childExists('mockfile')); - } - function testChildExistsFalse() { - + public function testChildExistsFalse() + { $dir = new DirectoryMock(); $this->assertFalse($dir->childExists('mockfile2')); - } /** - * @expectedException Sabre\DAV\Exception\NotFound + * @expectedException \Sabre\DAV\Exception\NotFound */ - function testGetChild404() { - + public function testGetChild404() + { $dir = new DirectoryMock(); $file = $dir->getChild('blabla'); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testCreateFile() { - + public function testCreateFile() + { $dir = new DirectoryMock(); $dir->createFile('hello', 'data'); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testCreateDirectory() { - + public function testCreateDirectory() + { $dir = new DirectoryMock(); $dir->createDirectory('hello'); - - } - - function testSimpleDirectoryConstruct() { - - $dir = new SimpleCollection('simpledir', []); - $this->assertInstanceOf('Sabre\DAV\SimpleCollection', $dir); - - } - - /** - * @depends testSimpleDirectoryConstruct - */ - function testSimpleDirectoryConstructChild() { - - $file = new FileMock(); - $dir = new SimpleCollection('simpledir', [$file]); - $file2 = $dir->getChild('mockfile'); - - $this->assertEquals($file, $file2); - - } - - /** - * @expectedException Sabre\DAV\Exception - * @depends testSimpleDirectoryConstruct - */ - function testSimpleDirectoryBadParam() { - - $dir = new SimpleCollection('simpledir', ['string shouldn\'t be here']); - - } - - /** - * @depends testSimpleDirectoryConstruct - */ - function testSimpleDirectoryAddChild() { - - $file = new FileMock(); - $dir = new SimpleCollection('simpledir'); - $dir->addChild($file); - $file2 = $dir->getChild('mockfile'); - - $this->assertEquals($file, $file2); - - } - - /** - * @depends testSimpleDirectoryConstruct - * @depends testSimpleDirectoryAddChild - */ - function testSimpleDirectoryGetChildren() { - - $file = new FileMock(); - $dir = new SimpleCollection('simpledir'); - $dir->addChild($file); - - $this->assertEquals([$file], $dir->getChildren()); - - } - - /* - * @depends testSimpleDirectoryConstruct - */ - function testSimpleDirectoryGetName() { - - $dir = new SimpleCollection('simpledir'); - $this->assertEquals('simpledir', $dir->getName()); - - } - - /** - * @depends testSimpleDirectoryConstruct - * @expectedException Sabre\DAV\Exception\NotFound - */ - function testSimpleDirectoryGetChild404() { - - $dir = new SimpleCollection('simpledir'); - $dir->getChild('blabla'); - } } -class DirectoryMock extends Collection { - - function getName() { - +class DirectoryMock extends Collection +{ + public function getName() + { return 'mockdir'; - } - function getChildren() { - + public function getChildren() + { return [new FileMock()]; - } - } -class FileMock extends File { - - function getName() { - +class FileMock extends File +{ + public function getName() + { return 'mockfile'; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php index 54a3053ec..1f48256e0 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php @@ -1,29 +1,30 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; require_once 'Sabre/DAV/AbstractServer.php'; -class GuessContentTypeTest extends DAV\AbstractServer { - - function setUp() { - +class GuessContentTypeTest extends DAV\AbstractServer +{ + public function setUp() + { parent::setUp(); \Sabre\TestUtil::clearTempDir(); - file_put_contents(SABRE_TEMPDIR . '/somefile.jpg', 'blabla'); - file_put_contents(SABRE_TEMPDIR . '/somefile.hoi', 'blabla'); - + file_put_contents(SABRE_TEMPDIR.'/somefile.jpg', 'blabla'); + file_put_contents(SABRE_TEMPDIR.'/somefile.hoi', 'blabla'); } - function tearDown() { - + public function tearDown() + { \Sabre\TestUtil::clearTempDir(); parent::tearDown(); } - function testGetProperties() { - + public function testGetProperties() + { $properties = [ '{DAV:}getcontenttype', ]; @@ -31,31 +32,29 @@ class GuessContentTypeTest extends DAV\AbstractServer { $this->assertArrayHasKey(0, $result); $this->assertArrayHasKey(404, $result[0]); $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][404]); - } /** * @depends testGetProperties */ - function testGetPropertiesPluginEnabled() { - + public function testGetPropertiesPluginEnabled() + { $this->server->addPlugin(new GuessContentType()); $properties = [ '{DAV:}getcontenttype', ]; $result = $this->server->getPropertiesForPath('/somefile.jpg', $properties); $this->assertArrayHasKey(0, $result); - $this->assertArrayHasKey(200, $result[0], 'We received: ' . print_r($result, true)); + $this->assertArrayHasKey(200, $result[0], 'We received: '.print_r($result, true)); $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][200]); $this->assertEquals('image/jpeg', $result[0][200]['{DAV:}getcontenttype']); - } /** * @depends testGetPropertiesPluginEnabled */ - function testGetPropertiesUnknown() { - + public function testGetPropertiesUnknown() + { $this->server->addPlugin(new GuessContentType()); $properties = [ '{DAV:}getcontenttype', @@ -65,6 +64,5 @@ class GuessContentTypeTest extends DAV\AbstractServer { $this->assertArrayHasKey(200, $result[0]); $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][200]); $this->assertEquals('application/octet-stream', $result[0][200]['{DAV:}getcontenttype']); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php index 33c4ede96..de7b85f32 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; @@ -7,19 +9,18 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class MapGetToPropFindTest extends DAV\AbstractServer { - - function setUp() { - +class MapGetToPropFindTest extends DAV\AbstractServer +{ + public function setUp() + { parent::setUp(); $this->server->addPlugin(new MapGetToPropFind()); - } - function testCollectionGet() { - + public function testCollectionGet() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET', ]; @@ -28,17 +29,14 @@ class MapGetToPropFindTest extends DAV\AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Incorrect status response received. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Incorrect status response received. Full response body: '.$this->response->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'DAV' => ['1, 3, extended-mkcol'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'DAV' => ['1, 3, extended-mkcol'], + 'Vary' => ['Brief,Prefer'], ], $this->response->getHeaders() ); - } - - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php index f20c50f86..fb7c63d46 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; @@ -7,129 +9,123 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class PluginTest extends DAV\AbstractServer{ - +class PluginTest extends DAV\AbstractServer +{ protected $plugin; - function setUp() { - + public function setUp() + { parent::setUp(); $this->server->addPlugin($this->plugin = new Plugin()); $this->server->tree->getNodeForPath('')->createDirectory('dir2'); - } - function testCollectionGet() { - + public function testCollectionGet() + { $request = new HTTP\Request('GET', '/dir'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString()); + $this->assertEquals(200, $this->response->getStatus(), 'Incorrect status received. Full response body: '.$this->response->getBodyAsString()); $this->assertEquals( [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['text/html; charset=utf-8'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], ], $this->response->getHeaders() ); $body = $this->response->getBodyAsString(); - $this->assertTrue(strpos($body, '<title>dir') !== false, $body); - $this->assertTrue(strpos($body, '<a href="/dir/child.txt">') !== false); - + $this->assertTrue(false !== strpos($body, '<title>dir'), $body); + $this->assertTrue(false !== strpos($body, '<a href="/dir/child.txt">')); } /** * Adding the If-None-Match should have 0 effect, but it threw an error. */ - function testCollectionGetIfNoneMatch() { - + public function testCollectionGetIfNoneMatch() + { $request = new HTTP\Request('GET', '/dir'); $request->setHeader('If-None-Match', '"foo-bar"'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString()); + $this->assertEquals(200, $this->response->getStatus(), 'Incorrect status received. Full response body: '.$this->response->getBodyAsString()); $this->assertEquals( [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['text/html; charset=utf-8'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], ], $this->response->getHeaders() ); $body = $this->response->getBodyAsString(); - $this->assertTrue(strpos($body, '<title>dir') !== false, $body); - $this->assertTrue(strpos($body, '<a href="/dir/child.txt">') !== false); - + $this->assertTrue(false !== strpos($body, '<title>dir'), $body); + $this->assertTrue(false !== strpos($body, '<a href="/dir/child.txt">')); } - function testCollectionGetRoot() { + public function testCollectionGetRoot() + { $request = new HTTP\Request('GET', '/'); $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(200, $this->response->status, "Incorrect status received. Full response body: " . $this->response->getBodyAsString()); + $this->assertEquals(200, $this->response->status, 'Incorrect status received. Full response body: '.$this->response->getBodyAsString()); $this->assertEquals( [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['text/html; charset=utf-8'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], ], $this->response->getHeaders() ); $body = $this->response->getBodyAsString(); - $this->assertTrue(strpos($body, '<title>/') !== false, $body); - $this->assertTrue(strpos($body, '<a href="/dir/">') !== false); - $this->assertTrue(strpos($body, '<span class="btn disabled">') !== false); - + $this->assertTrue(false !== strpos($body, '<title>/'), $body); + $this->assertTrue(false !== strpos($body, '<a href="/dir/">')); + $this->assertTrue(false !== strpos($body, '<span class="btn disabled">')); } - function testGETPassthru() { - + public function testGETPassthru() + { $request = new HTTP\Request('GET', '/random'); $response = new HTTP\Response(); $this->assertNull( $this->plugin->httpGet($request, $response) ); - } - function testPostOtherContentType() { - + public function testPostOtherContentType() + { $request = new HTTP\Request('POST', '/', ['Content-Type' => 'text/xml']); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(501, $this->response->status); - } - function testPostNoSabreAction() { - + public function testPostNoSabreAction() + { $request = new HTTP\Request('POST', '/', ['Content-Type' => 'application/x-www-form-urlencoded']); $request->setPostData([]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(501, $this->response->status); - } - function testPostMkCol() { - + public function testPostMkCol() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', ]; $postVars = [ 'sabreAction' => 'mkcol', - 'name' => 'new_collection', + 'name' => 'new_collection', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -140,47 +136,43 @@ class PluginTest extends DAV\AbstractServer{ $this->assertEquals(302, $this->response->status); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Location' => ['/'], + 'Location' => ['/'], ], $this->response->getHeaders()); - $this->assertTrue(is_dir(SABRE_TEMPDIR . '/new_collection')); - + $this->assertTrue(is_dir(SABRE_TEMPDIR.'/new_collection')); } - function testGetAsset() { - + public function testGetAsset() + { $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=favicon.ico'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(200, $this->response->getStatus(), 'Error: ' . $this->response->body); + $this->assertEquals(200, $this->response->getStatus(), 'Error: '.$this->response->body); $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['image/vnd.microsoft.icon'], - 'Content-Length' => ['4286'], - 'Cache-Control' => ['public, max-age=1209600'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['image/vnd.microsoft.icon'], + 'Content-Length' => ['4286'], + 'Cache-Control' => ['public, max-age=1209600'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], ], $this->response->getHeaders()); - } - function testGetAsset404() { - + public function testGetAsset404() + { $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=flavicon.ico'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(404, $this->response->getStatus(), 'Error: ' . $this->response->body); - + $this->assertEquals(404, $this->response->getStatus(), 'Error: '.$this->response->body); } - function testGetAssetEscapeBasePath() { - + public function testGetAssetEscapeBasePath() + { $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=./../assets/favicon.ico'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(404, $this->response->getStatus(), 'Error: ' . $this->response->body); - + $this->assertEquals(404, $this->response->getStatus(), 'Error: '.$this->response->body); } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php b/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php index 5a48b063c..7d787744a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php @@ -1,11 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; -class ClientMock extends Client { - +class ClientMock extends Client +{ public $request; public $response; @@ -13,22 +16,21 @@ class ClientMock extends Client { public $curlSettings; /** - * Just making this method public + * Just making this method public. * * @param string $url + * * @return string */ - function getAbsoluteUrl($url) { - + public function getAbsoluteUrl($url) + { return parent::getAbsoluteUrl($url); - } - function doRequest(RequestInterface $request) { - + public function doRequest(RequestInterface $request): ResponseInterface + { $this->request = $request; - return $this->response; + return $this->response; } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php index 687f61e2f..e9362c8e4 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php @@ -1,119 +1,111 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; -use Sabre\HTTP\Request; use Sabre\HTTP\Response; require_once 'Sabre/DAV/ClientMock.php'; -class ClientTest extends \PHPUnit_Framework_TestCase { - - function setUp() { - +class ClientTest extends \PHPUnit\Framework\TestCase +{ + public function setUp() + { if (!function_exists('curl_init')) { $this->markTestSkipped('CURL must be installed to test the client'); } - } - function testConstruct() { - + public function testConstruct() + { $client = new ClientMock([ 'baseUri' => '/', ]); $this->assertInstanceOf('Sabre\DAV\ClientMock', $client); - } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ - function testConstructNoBaseUri() { - + public function testConstructNoBaseUri() + { $client = new ClientMock([]); - } - function testAuth() { - + public function testAuth() + { $client = new ClientMock([ - 'baseUri' => '/', + 'baseUri' => '/', 'userName' => 'foo', 'password' => 'bar', ]); - $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]); + $this->assertEquals('foo:bar', $client->curlSettings[CURLOPT_USERPWD]); $this->assertEquals(CURLAUTH_BASIC | CURLAUTH_DIGEST, $client->curlSettings[CURLOPT_HTTPAUTH]); - } - function testBasicAuth() { - + public function testBasicAuth() + { $client = new ClientMock([ - 'baseUri' => '/', + 'baseUri' => '/', 'userName' => 'foo', 'password' => 'bar', - 'authType' => Client::AUTH_BASIC + 'authType' => Client::AUTH_BASIC, ]); - $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]); + $this->assertEquals('foo:bar', $client->curlSettings[CURLOPT_USERPWD]); $this->assertEquals(CURLAUTH_BASIC, $client->curlSettings[CURLOPT_HTTPAUTH]); - } - function testDigestAuth() { - + public function testDigestAuth() + { $client = new ClientMock([ - 'baseUri' => '/', + 'baseUri' => '/', 'userName' => 'foo', 'password' => 'bar', - 'authType' => Client::AUTH_DIGEST + 'authType' => Client::AUTH_DIGEST, ]); - $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]); + $this->assertEquals('foo:bar', $client->curlSettings[CURLOPT_USERPWD]); $this->assertEquals(CURLAUTH_DIGEST, $client->curlSettings[CURLOPT_HTTPAUTH]); - } - function testNTLMAuth() { - + public function testNTLMAuth() + { $client = new ClientMock([ - 'baseUri' => '/', + 'baseUri' => '/', 'userName' => 'foo', 'password' => 'bar', - 'authType' => Client::AUTH_NTLM + 'authType' => Client::AUTH_NTLM, ]); - $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]); + $this->assertEquals('foo:bar', $client->curlSettings[CURLOPT_USERPWD]); $this->assertEquals(CURLAUTH_NTLM, $client->curlSettings[CURLOPT_HTTPAUTH]); - } - function testProxy() { - + public function testProxy() + { $client = new ClientMock([ 'baseUri' => '/', - 'proxy' => 'localhost:8888', + 'proxy' => 'localhost:8888', ]); - $this->assertEquals("localhost:8888", $client->curlSettings[CURLOPT_PROXY]); - + $this->assertEquals('localhost:8888', $client->curlSettings[CURLOPT_PROXY]); } - function testEncoding() { - + public function testEncoding() + { $client = new ClientMock([ - 'baseUri' => '/', + 'baseUri' => '/', 'encoding' => Client::ENCODING_IDENTITY | Client::ENCODING_GZIP | Client::ENCODING_DEFLATE, ]); - $this->assertEquals("identity,deflate,gzip", $client->curlSettings[CURLOPT_ENCODING]); - + $this->assertEquals('identity,deflate,gzip', $client->curlSettings[CURLOPT_ENCODING]); } - function testPropFind() { - + public function testPropFind() + { $client = new ClientMock([ 'baseUri' => '/', ]); @@ -142,28 +134,26 @@ XML; $this->assertEquals('PROPFIND', $request->getMethod()); $this->assertEquals('/foo', $request->getUrl()); $this->assertEquals([ - 'Depth' => ['0'], + 'Depth' => ['0'], 'Content-Type' => ['application/xml'], ], $request->getHeaders()); - } /** * @expectedException \Sabre\HTTP\ClientHttpException */ - function testPropFindError() { - + public function testPropFindError() + { $client = new ClientMock([ 'baseUri' => '/', ]); $client->response = new Response(405, []); $client->propFind('foo', ['{DAV:}displayname', '{urn:zim}gir']); - } - function testPropFindDepth1() { - + public function testPropFindDepth1() + { $client = new ClientMock([ 'baseUri' => '/', ]); @@ -188,7 +178,7 @@ XML; $this->assertEquals([ '/foo' => [ - '{DAV:}displayname' => 'bar' + '{DAV:}displayname' => 'bar', ], ], $result); @@ -196,14 +186,13 @@ XML; $this->assertEquals('PROPFIND', $request->getMethod()); $this->assertEquals('/foo', $request->getUrl()); $this->assertEquals([ - 'Depth' => ['1'], + 'Depth' => ['1'], 'Content-Type' => ['application/xml'], ], $request->getHeaders()); - } - function testPropPatch() { - + public function testPropPatch() + { $client = new ClientMock([ 'baseUri' => '/', ]); @@ -232,30 +221,28 @@ XML; $this->assertEquals([ 'Content-Type' => ['application/xml'], ], $request->getHeaders()); - } /** * @depends testPropPatch * @expectedException \Sabre\HTTP\ClientHttpException */ - function testPropPatchHTTPError() { - + public function testPropPatchHTTPError() + { $client = new ClientMock([ 'baseUri' => '/', ]); $client->response = new Response(403, [], ''); $client->propPatch('foo', ['{DAV:}displayname' => 'hi', '{urn:zim}gir' => null]); - } /** * @depends testPropPatch - * @expectedException Sabre\HTTP\ClientException + * @expectedException \Sabre\HTTP\ClientException */ - function testPropPatchMultiStatusError() { - + public function testPropPatchMultiStatusError() + { $client = new ClientMock([ 'baseUri' => '/', ]); @@ -277,11 +264,10 @@ XML; $client->response = new Response(207, [], $responseBody); $client->propPatch('foo', ['{DAV:}displayname' => 'hi', '{urn:zim}gir' => null]); - } - function testOPTIONS() { - + public function testOPTIONS() + { $client = new ClientMock([ 'baseUri' => '/', ]); @@ -301,6 +287,5 @@ XML; $this->assertEquals('/', $request->getUrl()); $this->assertEquals([ ], $request->getHeaders()); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php index 174a561b5..5fc271587 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php @@ -1,14 +1,16 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use DOMDocument; use Sabre\DAV; -class LockedTest extends \PHPUnit_Framework_TestCase { - - function testSerialize() { - +class LockedTest extends \PHPUnit\Framework\TestCase +{ + public function testSerialize() + { $dom = new DOMDocument('1.0'); $dom->formatOutput = true; $root = $dom->createElement('d:root'); @@ -33,11 +35,10 @@ class LockedTest extends \PHPUnit_Framework_TestCase { '; $this->assertEquals($expected, $output); - } - function testSerializeAmpersand() { - + public function testSerializeAmpersand() + { $dom = new DOMDocument('1.0'); $dom->formatOutput = true; $root = $dom->createElement('d:root'); @@ -62,6 +63,5 @@ class LockedTest extends \PHPUnit_Framework_TestCase { '; $this->assertEquals($expected, $output); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php index 7142937b4..42775a313 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php @@ -1,14 +1,14 @@ <?php -namespace Sabre\DAV\Exception; - -class PaymentRequiredTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testGetHTTPCode() { +namespace Sabre\DAV\Exception; +class PaymentRequiredTest extends \PHPUnit\Framework\TestCase +{ + public function testGetHTTPCode() + { $ex = new PaymentRequired(); $this->assertEquals(402, $ex->getHTTPCode()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php index 0eb4f3dd8..7237aea0d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php @@ -1,30 +1,27 @@ <?php -namespace Sabre\DAV; - -class ExceptionTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testStatus() { +namespace Sabre\DAV; +class ExceptionTest extends \PHPUnit\Framework\TestCase +{ + public function testStatus() + { $e = new Exception(); $this->assertEquals(500, $e->getHTTPCode()); - } - function testExceptionStatuses() { - + public function testExceptionStatuses() + { $c = [ - 'Sabre\\DAV\\Exception\\NotAuthenticated' => 401, + 'Sabre\\DAV\\Exception\\NotAuthenticated' => 401, 'Sabre\\DAV\\Exception\\InsufficientStorage' => 507, ]; foreach ($c as $class => $status) { - $obj = new $class(); $this->assertEquals($status, $obj->getHTTPCode()); - } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php index f5d65a44f..4bc79b597 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php @@ -1,110 +1,101 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FSExt; require_once 'Sabre/TestUtil.php'; -class FileTest extends \PHPUnit_Framework_TestCase { - - function setUp() { - - file_put_contents(SABRE_TEMPDIR . '/file.txt', 'Contents'); - +class FileTest extends \PHPUnit\Framework\TestCase +{ + public function setUp() + { + file_put_contents(SABRE_TEMPDIR.'/file.txt', 'Contents'); } - function tearDown() { - + public function tearDown() + { \Sabre\TestUtil::clearTempDir(); - } - function testPut() { - - $filename = SABRE_TEMPDIR . '/file.txt'; + public function testPut() + { + $filename = SABRE_TEMPDIR.'/file.txt'; $file = new File($filename); $result = $file->put('New contents'); - $this->assertEquals('New contents', file_get_contents(SABRE_TEMPDIR . '/file.txt')); + $this->assertEquals('New contents', file_get_contents(SABRE_TEMPDIR.'/file.txt')); $this->assertEquals( - '"' . + '"'. sha1( - fileinode($filename) . - filesize($filename) . + fileinode($filename). + filesize($filename). filemtime($filename) - ) . '"', + ).'"', $result ); - } - function testRange() { - - $file = new File(SABRE_TEMPDIR . '/file.txt'); + public function testRange() + { + $file = new File(SABRE_TEMPDIR.'/file.txt'); $file->put('0000000'); $file->patch('111', 2, 3); - $this->assertEquals('0001110', file_get_contents(SABRE_TEMPDIR . '/file.txt')); - + $this->assertEquals('0001110', file_get_contents(SABRE_TEMPDIR.'/file.txt')); } - function testRangeStream() { - + public function testRangeStream() + { $stream = fopen('php://memory', 'r+'); - fwrite($stream, "222"); + fwrite($stream, '222'); rewind($stream); - $file = new File(SABRE_TEMPDIR . '/file.txt'); + $file = new File(SABRE_TEMPDIR.'/file.txt'); $file->put('0000000'); $file->patch($stream, 2, 3); - $this->assertEquals('0002220', file_get_contents(SABRE_TEMPDIR . '/file.txt')); - + $this->assertEquals('0002220', file_get_contents(SABRE_TEMPDIR.'/file.txt')); } - - function testGet() { - - $file = new File(SABRE_TEMPDIR . '/file.txt'); + public function testGet() + { + $file = new File(SABRE_TEMPDIR.'/file.txt'); $this->assertEquals('Contents', stream_get_contents($file->get())); - } - function testDelete() { - - $file = new File(SABRE_TEMPDIR . '/file.txt'); + public function testDelete() + { + $file = new File(SABRE_TEMPDIR.'/file.txt'); $file->delete(); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/file.txt')); - + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/file.txt')); } - function testGetETag() { - - $filename = SABRE_TEMPDIR . '/file.txt'; + public function testGetETag() + { + $filename = SABRE_TEMPDIR.'/file.txt'; $file = new File($filename); $this->assertEquals( - '"' . + '"'. sha1( - fileinode($filename) . - filesize($filename) . + fileinode($filename). + filesize($filename). filemtime($filename) - ) . '"', + ).'"', $file->getETag() ); } - function testGetContentType() { - - $file = new File(SABRE_TEMPDIR . '/file.txt'); + public function testGetContentType() + { + $file = new File(SABRE_TEMPDIR.'/file.txt'); $this->assertNull($file->getContentType()); - } - function testGetSize() { - - $file = new File(SABRE_TEMPDIR . '/file.txt'); + public function testGetSize() + { + $file = new File(SABRE_TEMPDIR.'/file.txt'); $this->assertEquals(8, $file->getSize()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php index 20fca490a..daa04c354 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FSExt; use Sabre\DAV; @@ -7,81 +9,76 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class ServerTest extends DAV\AbstractServer{ - - protected function getRootNode() { - +class ServerTest extends DAV\AbstractServer +{ + protected function getRootNode() + { return new Directory($this->tempDir); - } - function testGet() { - + public function testGet() + { $request = new HTTP\Request('GET', '/test.txt'); - $filename = $this->tempDir . '/test.txt'; + $filename = $this->tempDir.'/test.txt'; $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(200, $this->response->getStatus(), 'Invalid status code received.'); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [13], - 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($filename)))], - 'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [13], + 'Last-Modified' => [HTTP\toDate(new \DateTime('@'.filemtime($filename)))], + 'ETag' => ['"'.sha1(fileinode($filename).filesize($filename).filemtime($filename)).'"'], ], $this->response->getHeaders() ); - $this->assertEquals('Test contents', stream_get_contents($this->response->body)); - } - function testHEAD() { - + public function testHEAD() + { $request = new HTTP\Request('HEAD', '/test.txt'); - $filename = $this->tempDir . '/test.txt'; + $filename = $this->tempDir.'/test.txt'; $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [13], - 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt')))], - 'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [13], + 'Last-Modified' => [HTTP\toDate(new \DateTime('@'.filemtime($this->tempDir.'/test.txt')))], + 'ETag' => ['"'.sha1(fileinode($filename).filesize($filename).filemtime($filename)).'"'], ], $this->response->getHeaders() ); $this->assertEquals(200, $this->response->status); $this->assertEquals('', $this->response->body); - } - function testPut() { - + public function testPut() + { $request = new HTTP\Request('PUT', '/testput.txt'); - $filename = $this->tempDir . '/testput.txt'; + $filename = $this->tempDir.'/testput.txt'; $request->setBody('Testing new file'); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'], + 'Content-Length' => ['0'], + 'ETag' => ['"'.sha1(fileinode($filename).filesize($filename).filemtime($filename)).'"'], ], $this->response->getHeaders()); $this->assertEquals(201, $this->response->status); $this->assertEquals('', $this->response->body); $this->assertEquals('Testing new file', file_get_contents($filename)); - } - function testPutAlreadyExists() { - + public function testPutAlreadyExists() + { $request = new HTTP\Request('PUT', '/test.txt', ['If-None-Match' => '*']); $request->setBody('Testing new file'); $this->server->httpRequest = ($request); @@ -89,33 +86,31 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); $this->assertEquals(412, $this->response->status); - $this->assertNotEquals('Testing new file', file_get_contents($this->tempDir . '/test.txt')); - + $this->assertNotEquals('Testing new file', file_get_contents($this->tempDir.'/test.txt')); } - function testMkcol() { - + public function testMkcol() + { $request = new HTTP\Request('MKCOL', '/testcol'); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->response->getHeaders()); $this->assertEquals(201, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertTrue(is_dir($this->tempDir . '/testcol')); - + $this->assertTrue(is_dir($this->tempDir.'/testcol')); } - function testPutUpdate() { - + public function testPutUpdate() + { $request = new HTTP\Request('PUT', '/test.txt'); $request->setBody('Testing updated file'); $this->server->httpRequest = ($request); @@ -125,31 +120,29 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals(204, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertEquals('Testing updated file', file_get_contents($this->tempDir . '/test.txt')); - + $this->assertEquals('Testing updated file', file_get_contents($this->tempDir.'/test.txt')); } - function testDelete() { - + public function testDelete() + { $request = new HTTP\Request('DELETE', '/test.txt'); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->response->getHeaders()); $this->assertEquals(204, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertFalse(file_exists($this->tempDir . '/test.txt')); - + $this->assertFalse(file_exists($this->tempDir.'/test.txt')); } - function testDeleteDirectory() { - - mkdir($this->tempDir . '/testcol'); - file_put_contents($this->tempDir . '/testcol/test.txt', 'Hi! I\'m a file with a short lifespan'); + public function testDeleteDirectory() + { + mkdir($this->tempDir.'/testcol'); + file_put_contents($this->tempDir.'/testcol/test.txt', 'Hi! I\'m a file with a short lifespan'); $request = new HTTP\Request('DELETE', '/testcol'); $this->server->httpRequest = ($request); @@ -157,37 +150,35 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->response->getHeaders()); $this->assertEquals(204, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertFalse(file_exists($this->tempDir . '/testcol')); - + $this->assertFalse(file_exists($this->tempDir.'/testcol')); } - function testOptions() { - + public function testOptions() + { $request = new HTTP\Request('OPTIONS', '/'); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ - 'DAV' => ['1, 3, extended-mkcol'], - 'MS-Author-Via' => ['DAV'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], - 'Accept-Ranges' => ['bytes'], - 'Content-Length' => ['0'], + 'DAV' => ['1, 3, extended-mkcol'], + 'MS-Author-Via' => ['DAV'], + 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], + 'Accept-Ranges' => ['bytes'], + 'Content-Length' => ['0'], 'X-Sabre-Version' => [DAV\Version::VERSION], ], $this->response->getHeaders()); $this->assertEquals(200, $this->response->status); $this->assertEquals('', $this->response->body); - } - function testMove() { - - mkdir($this->tempDir . '/testcol'); + public function testMove() + { + mkdir($this->tempDir.'/testcol'); $request = new HTTP\Request('MOVE', '/test.txt', ['Destination' => '/testcol/test2.txt']); $this->server->httpRequest = ($request); @@ -197,15 +188,13 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals('', $this->response->body); $this->assertEquals([ - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], 'X-Sabre-Version' => [DAV\Version::VERSION], ], $this->response->getHeaders()); $this->assertTrue( - is_file($this->tempDir . '/testcol/test2.txt') + is_file($this->tempDir.'/testcol/test2.txt') ); - - } /** @@ -215,14 +204,14 @@ class ServerTest extends DAV\AbstractServer{ * The moveInto function *should* ignore the object and let sabredav itself * execute the slow move. */ - function testMoveOtherObject() { - - mkdir($this->tempDir . '/tree1'); - mkdir($this->tempDir . '/tree2'); + public function testMoveOtherObject() + { + mkdir($this->tempDir.'/tree1'); + mkdir($this->tempDir.'/tree2'); $tree = new DAV\Tree(new DAV\SimpleCollection('root', [ - new DAV\FS\Directory($this->tempDir . '/tree1'), - new DAV\FSExt\Directory($this->tempDir . '/tree2'), + new DAV\FS\Directory($this->tempDir.'/tree1'), + new DAV\FSExt\Directory($this->tempDir.'/tree2'), ])); $this->server->tree = $tree; @@ -234,13 +223,32 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals('', $this->response->body); $this->assertEquals([ - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], 'X-Sabre-Version' => [DAV\Version::VERSION], ], $this->response->getHeaders()); $this->assertTrue( - is_dir($this->tempDir . '/tree2/tree1') + is_dir($this->tempDir.'/tree2/tree1') ); + } + + public function testCopy() + { + mkdir($this->tempDir.'/testcol'); + + $request = new HTTP\Request('COPY', '/test.txt', ['Destination' => '/testcol/test2.txt']); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(201, $this->response->status); + $this->assertEquals('', $this->response->body); + + $this->assertEquals([ + 'Content-Length' => ['0'], + 'X-Sabre-Version' => [DAV\Version::VERSION], + ], $this->response->getHeaders()); + $this->assertTrue(is_file($this->tempDir.'/test.txt')); + $this->assertTrue(is_file($this->tempDir.'/testcol/test2.txt')); } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php index cd8bee968..d0ff77eb4 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php @@ -1,88 +1,85 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; -class HTTPPreferParsingTest extends \Sabre\DAVServerTest { - - function testParseSimple() { - - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_PREFER' => 'return-asynch', +class HTTPPreferParsingTest extends \Sabre\DAVServerTest +{ + public function assertParseResult($input, $expected) + { + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'Prefer' => $input, ]); $server = new Server(); $server->httpRequest = $httpRequest; - $this->assertEquals([ - 'respond-async' => true, - 'return' => null, - 'handling' => null, - 'wait' => null, - ], $server->getHTTPPrefer()); - + $this->assertEquals( + $expected, + $server->getHTTPPrefer() + ); } - function testParseValue() { - - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_PREFER' => 'wait=10', - ]); - - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals([ - 'respond-async' => false, - 'return' => null, - 'handling' => null, - 'wait' => '10', - ], $server->getHTTPPrefer()); - + public function testParseSimple() + { + $this->assertParseResult( + 'return-asynch', + [ + 'respond-async' => true, + 'return' => null, + 'handling' => null, + 'wait' => null, + ] + ); } - function testParseMultiple() { - - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_PREFER' => 'return-minimal, strict,lenient', - ]); - - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals([ - 'respond-async' => false, - 'return' => 'minimal', - 'handling' => 'lenient', - 'wait' => null, - ], $server->getHTTPPrefer()); - + public function testParseValue() + { + $this->assertParseResult( + 'wait=10', + [ + 'respond-async' => false, + 'return' => null, + 'handling' => null, + 'wait' => '10', + ] + ); } - function testParseWeirdValue() { - - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_PREFER' => 'BOOOH', - ]); - - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals([ - 'respond-async' => false, - 'return' => null, - 'handling' => null, - 'wait' => null, - 'boooh' => true, - ], $server->getHTTPPrefer()); - + public function testParseMultiple() + { + $this->assertParseResult( + 'return-minimal, strict,lenient', + [ + 'respond-async' => false, + 'return' => 'minimal', + 'handling' => 'lenient', + 'wait' => null, + ] + ); } - function testBrief() { + public function testParseWeirdValue() + { + $this->assertParseResult( + 'BOOOH', + [ + 'respond-async' => false, + 'return' => null, + 'handling' => null, + 'wait' => null, + 'boooh' => true, + ] + ); + } - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_BRIEF' => 't', + public function testBrief() + { + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'Brief' => 't', ]); $server = new Server(); @@ -90,24 +87,19 @@ class HTTPPreferParsingTest extends \Sabre\DAVServerTest { $this->assertEquals([ 'respond-async' => false, - 'return' => 'minimal', - 'handling' => null, - 'wait' => null, + 'return' => 'minimal', + 'handling' => null, + 'wait' => null, ], $server->getHTTPPrefer()); - } /** - * propfindMinimal - * - * @return void + * propfindMinimal. */ - function testpropfindMinimal() { - - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PROPFIND', - 'REQUEST_URI' => '/', - 'HTTP_PREFER' => 'return-minimal', + public function testpropfindMinimal() + { + $request = new HTTP\Request('PROPFIND', '/', [ + 'Prefer' => 'return-minimal', ]); $request->setBody(<<<BLA <?xml version="1.0"?> @@ -126,13 +118,12 @@ BLA $this->assertEquals(207, $response->getStatus(), $body); - $this->assertTrue(strpos($body, 'resourcetype') !== false, $body); - $this->assertTrue(strpos($body, 'something') === false, $body); - + $this->assertTrue(false !== strpos($body, 'resourcetype'), $body); + $this->assertTrue(false === strpos($body, 'something'), $body); } - function testproppatchMinimal() { - + public function testproppatchMinimal() + { $request = new HTTP\Request('PROPPATCH', '/', ['Prefer' => 'return-minimal']); $request->setBody(<<<BLA <?xml version="1.0"?> @@ -146,23 +137,20 @@ BLA BLA ); - $this->server->on('propPatch', function($path, PropPatch $propPatch) { - - $propPatch->handle('{DAV:}something', function($props) { + $this->server->on('propPatch', function ($path, PropPatch $propPatch) { + $propPatch->handle('{DAV:}something', function ($props) { return true; }); - }); $response = $this->request($request); - $this->assertEquals(0, strlen($response->body), 'Expected empty body: ' . $response->body); + $this->assertEquals('', $response->getBodyAsString(), 'Expected empty body: '.$response->body); $this->assertEquals(204, $response->status); - } - function testproppatchMinimalError() { - + public function testproppatchMinimalError() + { $request = new HTTP\Request('PROPPATCH', '/', ['Prefer' => 'return-minimal']); $request->setBody(<<<BLA <?xml version="1.0"?> @@ -181,8 +169,7 @@ BLA $body = $response->getBodyAsString(); $this->assertEquals(207, $response->status); - $this->assertTrue(strpos($body, 'something') !== false); - $this->assertTrue(strpos($body, '403 Forbidden') !== false, $body); - + $this->assertTrue(false !== strpos($body, 'something')); + $this->assertTrue(false !== strpos($body, '403 Forbidden'), $body); } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php index bd1b33150..f70febabd 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\DAVServerTest; @@ -12,30 +14,27 @@ use Sabre\HTTP; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class HttpDeleteTest extends DAVServerTest { - +class HttpDeleteTest extends DAVServerTest +{ /** * Sets up the DAV tree. - * - * @return void */ - function setUpTree() { - + public function setUpTree() + { $this->tree = new Mock\Collection('root', [ 'file1' => 'foo', - 'dir' => [ - 'subfile' => 'bar', + 'dir' => [ + 'subfile' => 'bar', 'subfile2' => 'baz', ], ]); - } /** - * A successful DELETE + * A successful DELETE. */ - function testDelete() { - + public function testDelete() + { $request = new HTTP\Request('DELETE', '/file1'); $response = $this->request($request); @@ -43,24 +42,23 @@ class HttpDeleteTest extends DAVServerTest { $this->assertEquals( 204, $response->getStatus(), - "Incorrect status code. Response body: " . $response->getBodyAsString() + 'Incorrect status code. Response body: '.$response->getBodyAsString() ); $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $response->getHeaders() ); - } /** - * Deleting a Directory + * Deleting a Directory. */ - function testDeleteDirectory() { - + public function testDeleteDirectory() + { $request = new HTTP\Request('DELETE', '/dir'); $response = $this->request($request); @@ -68,42 +66,40 @@ class HttpDeleteTest extends DAVServerTest { $this->assertEquals( 204, $response->getStatus(), - "Incorrect status code. Response body: " . $response->getBodyAsString() + 'Incorrect status code. Response body: '.$response->getBodyAsString() ); $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $response->getHeaders() ); - } /** - * DELETE on a node that does not exist + * DELETE on a node that does not exist. */ - function testDeleteNotFound() { - + public function testDeleteNotFound() + { $request = new HTTP\Request('DELETE', '/file2'); $response = $this->request($request); $this->assertEquals( 404, $response->getStatus(), - "Incorrect status code. Response body: " . $response->getBodyAsString() + 'Incorrect status code. Response body: '.$response->getBodyAsString() ); - } /** - * DELETE with preconditions + * DELETE with preconditions. */ - function testDeletePreconditions() { - + public function testDeletePreconditions() + { $request = new HTTP\Request('DELETE', '/file1', [ - 'If-Match' => '"' . md5('foo') . '"', + 'If-Match' => '"'.md5('foo').'"', ]); $response = $this->request($request); @@ -111,18 +107,17 @@ class HttpDeleteTest extends DAVServerTest { $this->assertEquals( 204, $response->getStatus(), - "Incorrect status code. Response body: " . $response->getBodyAsString() + 'Incorrect status code. Response body: '.$response->getBodyAsString() ); - } /** - * DELETE with incorrect preconditions + * DELETE with incorrect preconditions. */ - function testDeletePreconditionsFailed() { - + public function testDeletePreconditionsFailed() + { $request = new HTTP\Request('DELETE', '/file1', [ - 'If-Match' => '"' . md5('bar') . '"', + 'If-Match' => '"'.md5('bar').'"', ]); $response = $this->request($request); @@ -130,8 +125,7 @@ class HttpDeleteTest extends DAVServerTest { $this->assertEquals( 412, $response->getStatus(), - "Incorrect status code. Response body: " . $response->getBodyAsString() + 'Incorrect status code. Response body: '.$response->getBodyAsString() ); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php index 86480b1c2..d3932a4c6 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\DAVServerTest; @@ -12,31 +14,28 @@ use Sabre\HTTP; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class HttpPutTest extends DAVServerTest { - +class HttpPutTest extends DAVServerTest +{ /** * Sets up the DAV tree. - * - * @return void */ - function setUpTree() { - + public function setUpTree() + { $this->tree = new Mock\Collection('root', [ 'file1' => 'foo', ]); - } /** * A successful PUT of a new file. */ - function testPut() { - + public function testPut() + { $request = new HTTP\Request('PUT', '/file2', [], 'hello'); $response = $this->request($request); - $this->assertEquals(201, $response->getStatus(), 'Incorrect status code received. Full response body:' . $response->getBodyAsString()); + $this->assertEquals(201, $response->getStatus(), 'Incorrect status code received. Full response body:'.$response->getBodyAsString()); $this->assertEquals( 'hello', @@ -46,12 +45,11 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'] + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5('hello').'"'], ], $response->getHeaders() ); - } /** @@ -59,8 +57,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutExisting() { - + public function testPutExisting() + { $request = new HTTP\Request('PUT', '/file1', [], 'bar'); $response = $this->request($request); @@ -75,21 +73,20 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('bar') . '"'] + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5('bar').'"'], ], $response->getHeaders() ); - } /** - * PUT on existing file with If-Match: * + * PUT on existing file with If-Match: *. * * @depends testPutExisting */ - function testPutExistingIfMatchStar() { - + public function testPutExistingIfMatchStar() + { $request = new HTTP\Request( 'PUT', '/file1', @@ -109,25 +106,24 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'] + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5('hello').'"'], ], $response->getHeaders() ); - } /** - * PUT on existing file with If-Match: with a correct etag + * PUT on existing file with If-Match: with a correct etag. * * @depends testPutExisting */ - function testPutExistingIfMatchCorrect() { - + public function testPutExistingIfMatchCorrect() + { $request = new HTTP\Request( 'PUT', '/file1', - ['If-Match' => '"' . md5('foo') . '"'], + ['If-Match' => '"'.md5('foo').'"'], 'hello' ); @@ -143,12 +139,11 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'], + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5('hello').'"'], ], $response->getHeaders() ); - } /** @@ -156,8 +151,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutContentRange() { - + public function testPutContentRange() + { $request = new HTTP\Request( 'PUT', '/file2', @@ -167,7 +162,6 @@ class HttpPutTest extends DAVServerTest { $response = $this->request($request); $this->assertEquals(400, $response->getStatus()); - } /** @@ -175,8 +169,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutIfNoneMatchStar() { - + public function testPutIfNoneMatchStar() + { $request = new HTTP\Request( 'PUT', '/file2', @@ -196,12 +190,11 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'] + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5('hello').'"'], ], $response->getHeaders() ); - } /** @@ -209,8 +202,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutIfMatchStar() { - + public function testPutIfMatchStar() + { $request = new HTTP\Request( 'PUT', '/file2', @@ -221,7 +214,6 @@ class HttpPutTest extends DAVServerTest { $response = $this->request($request); $this->assertEquals(412, $response->getStatus()); - } /** @@ -229,8 +221,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutExistingIfNoneMatchStar() { - + public function testPutExistingIfNoneMatchStar() + { $request = new HTTP\Request( 'PUT', '/file1', @@ -242,7 +234,6 @@ class HttpPutTest extends DAVServerTest { $response = $this->request($request); $this->assertEquals(412, $response->getStatus()); - } /** @@ -250,8 +241,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutNoParent() { - + public function testPutNoParent() + { $request = new HTTP\Request( 'PUT', '/file1/file2', @@ -261,7 +252,6 @@ class HttpPutTest extends DAVServerTest { $response = $this->request($request); $this->assertEquals(409, $response->getStatus()); - } /** @@ -271,8 +261,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testFinderPutSuccess() { - + public function testFinderPutSuccess() + { $request = new HTTP\Request( 'PUT', '/file2', @@ -291,12 +281,11 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'], + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5('hello').'"'], ], $response->getHeaders() ); - } /** @@ -304,8 +293,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testFinderPutSuccess */ - function testFinderPutFail() { - + public function testFinderPutFail() + { $request = new HTTP\Request( 'PUT', '/file2', @@ -316,7 +305,6 @@ class HttpPutTest extends DAVServerTest { $response = $this->request($request); $this->assertEquals(403, $response->getStatus()); - } /** @@ -324,17 +312,18 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutIntercept() { - - $this->server->on('beforeBind', function($uri) { + public function testPutIntercept() + { + $this->server->on('beforeBind', function ($uri) { $this->server->httpResponse->setStatus(418); + return false; }); $request = new HTTP\Request('PUT', '/file2', [], 'hello'); $response = $this->request($request); - $this->assertEquals(418, $response->getStatus(), 'Incorrect status code received. Full response body: ' . $response->getBodyAsString()); + $this->assertEquals(418, $response->getStatus(), 'Incorrect status code received. Full response body: '.$response->getBodyAsString()); $this->assertFalse( $this->server->tree->nodeExists('file2') @@ -343,7 +332,5 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], ], $response->getHeaders()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php b/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php index ba2cf3dc1..500ad6147 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php @@ -1,34 +1,32 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; require_once 'Sabre/TestUtil.php'; -class Issue33Test extends \PHPUnit_Framework_TestCase { - - function setUp() { - +class Issue33Test extends \PHPUnit\Framework\TestCase +{ + public function setUp() + { \Sabre\TestUtil::clearTempDir(); - } - function testCopyMoveInfo() { - + public function testCopyMoveInfo() + { $bar = new SimpleCollection('bar'); $root = new SimpleCollection('webdav', [$bar]); $server = new Server($root); $server->setBaseUri('/webdav/'); - $serverVars = [ - 'REQUEST_URI' => '/webdav/bar', - 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', - 'HTTP_OVERWRITE' => 'F', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('GET', '/webdav/bar', [ + 'Destination' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', + 'Overwrite' => 'F', + ]); $server->httpRequest = $request; @@ -37,13 +35,12 @@ class Issue33Test extends \PHPUnit_Framework_TestCase { $this->assertEquals('%C3%A0fo%C3%B3', urlencode($info['destination'])); $this->assertFalse($info['destinationExists']); $this->assertFalse($info['destinationNode']); - } - function testTreeMove() { - - mkdir(SABRE_TEMPDIR . '/issue33'); - $dir = new FS\Directory(SABRE_TEMPDIR . '/issue33'); + public function testTreeMove() + { + mkdir(SABRE_TEMPDIR.'/issue33'); + $dir = new FS\Directory(SABRE_TEMPDIR.'/issue33'); $dir->createDirectory('bar'); @@ -52,40 +49,34 @@ class Issue33Test extends \PHPUnit_Framework_TestCase { $node = $tree->getNodeForPath(urldecode('%C3%A0fo%C3%B3')); $this->assertEquals(urldecode('%C3%A0fo%C3%B3'), $node->getName()); - } - function testDirName() { - + public function testDirName() + { $dirname1 = 'bar'; $dirname2 = urlencode('%C3%A0fo%C3%B3'); $this->assertTrue(dirname($dirname1) == dirname($dirname2)); - } /** * @depends testTreeMove * @depends testCopyMoveInfo */ - function testEverything() { + public function testEverything() + { + $request = new HTTP\Request('MOVE', '/webdav/bar', [ + 'Destination' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', + 'Overwrite' => 'F', + ]); - // Request object - $serverVars = [ - 'REQUEST_METHOD' => 'MOVE', - 'REQUEST_URI' => '/webdav/bar', - 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', - 'HTTP_OVERWRITE' => 'F', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(''); $response = new HTTP\ResponseMock(); // Server setup - mkdir(SABRE_TEMPDIR . '/issue33'); - $dir = new FS\Directory(SABRE_TEMPDIR . '/issue33'); + mkdir(SABRE_TEMPDIR.'/issue33'); + $dir = new FS\Directory(SABRE_TEMPDIR.'/issue33'); $dir->createDirectory('bar'); @@ -99,8 +90,6 @@ class Issue33Test extends \PHPUnit_Framework_TestCase { $server->sapi = new HTTP\SapiMock(); $server->exec(); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/issue33/' . urldecode('%C3%A0fo%C3%B3'))); - + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/issue33/'.urldecode('%C3%A0fo%C3%B3'))); } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php index bbde69097..d1cd1799c 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php @@ -1,29 +1,31 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; use Sabre\DAV; -abstract class AbstractTest extends \PHPUnit_Framework_TestCase { - +abstract class AbstractTest extends \PHPUnit\Framework\TestCase +{ /** * @abstract + * * @return AbstractBackend */ - abstract function getBackend(); - - function testSetup() { - - $backend = $this->getBackend(); - $this->assertInstanceOf('Sabre\\DAV\\Locks\\Backend\\AbstractBackend', $backend); + abstract public function getBackend(); + public function testSetup() + { + $backend = $this->getBackend(); + $this->assertInstanceOf('Sabre\\DAV\\Locks\\Backend\\AbstractBackend', $backend); } /** * @depends testSetup */ - function testGetLocks() { - + public function testGetLocks() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -40,14 +42,13 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(1, count($locks)); $this->assertEquals('Sinterklaas', $locks[0]->owner); $this->assertEquals('someuri', $locks[0]->uri); - } /** * @depends testGetLocks */ - function testGetLocksParent() { - + public function testGetLocksParent() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -64,15 +65,13 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(1, count($locks)); $this->assertEquals('Sinterklaas', $locks[0]->owner); $this->assertEquals('someuri', $locks[0]->uri); - } - /** * @depends testGetLocks */ - function testGetLocksParentDepth0() { - + public function testGetLocksParentDepth0() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -87,11 +86,10 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $locks = $backend->getLocks('someuri/child', false); $this->assertEquals(0, count($locks)); - } - function testGetLocksChildren() { - + public function testGetLocksChildren() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -111,14 +109,13 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $locks = $backend->getLocks('someuri', true); $this->assertEquals(1, count($locks)); - } /** * @depends testGetLocks */ - function testLockRefresh() { - + public function testLockRefresh() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -139,14 +136,13 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('Santa Clause', $locks[0]->owner); $this->assertEquals('someuri', $locks[0]->uri); - } /** * @depends testGetLocks */ - function testUnlock() { - + public function testUnlock() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -164,14 +160,13 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $locks = $backend->getLocks('someuri', false); $this->assertEquals(0, count($locks)); - } /** * @depends testUnlock */ - function testUnlockUnknownToken() { - + public function testUnlockUnknownToken() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -190,7 +185,5 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $locks = $backend->getLocks('someuri', false); $this->assertEquals(1, count($locks)); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php index 537996f3b..50f17a7dd 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php @@ -1,24 +1,23 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; require_once 'Sabre/TestUtil.php'; -class FileTest extends AbstractTest { - - function getBackend() { - +class FileTest extends AbstractTest +{ + public function getBackend() + { \Sabre\TestUtil::clearTempDir(); - $backend = new File(SABRE_TEMPDIR . '/lockdb'); - return $backend; + $backend = new File(SABRE_TEMPDIR.'/lockdb'); + return $backend; } - - function tearDown() { - + public function tearDown() + { \Sabre\TestUtil::clearTempDir(); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php index 0ba02fc8b..86ffc0bb3 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\DAV\Locks\Backend; +declare(strict_types=1); -class PDOMySQLTest extends PDOTest { +namespace Sabre\DAV\Locks\Backend; +class PDOMySQLTest extends PDOTest +{ public $driver = 'mysql'; - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php index a27eae93c..f5ed98f50 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php @@ -1,20 +1,20 @@ <?php -namespace Sabre\DAV\Locks\Backend; +declare(strict_types=1); -abstract class PDOTest extends AbstractTest { +namespace Sabre\DAV\Locks\Backend; +abstract class PDOTest extends AbstractTest +{ use \Sabre\DAV\DbTestHelperTrait; - function getBackend() { - + public function getBackend() + { $this->dropTables('locks'); $this->createSchema('locks'); $pdo = $this->getPDO(); return new PDO($pdo); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php index 1111db5b5..a2a31e87f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks; use Sabre\DAV; @@ -8,22 +10,21 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; require_once 'Sabre/TestUtil.php'; -class MSWordTest extends \PHPUnit_Framework_TestCase { - - function tearDown() { - +class MSWordTest extends \PHPUnit\Framework\TestCase +{ + public function tearDown() + { \Sabre\TestUtil::clearTempDir(); - } - function testLockEtc() { - - mkdir(SABRE_TEMPDIR . '/mstest'); - $tree = new DAV\FS\Directory(SABRE_TEMPDIR . '/mstest'); + public function testLockEtc() + { + mkdir(SABRE_TEMPDIR.'/mstest'); + $tree = new DAV\FS\Directory(SABRE_TEMPDIR.'/mstest'); $server = new DAV\Server($tree); $server->debugExceptions = true; - $locksBackend = new Backend\File(SABRE_TEMPDIR . '/locksdb'); + $locksBackend = new Backend\File(SABRE_TEMPDIR.'/locksdb'); $locksPlugin = new Plugin($locksBackend); $server->addPlugin($locksPlugin); @@ -34,8 +35,8 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { $server->sapi = new HTTP\SapiMock(); $server->exec(); - $this->assertEquals(201, $server->httpResponse->getStatus(), 'Full response body:' . $response1->getBodyAsString()); - $this->assertTrue(!!$server->httpResponse->getHeaders('Lock-Token')); + $this->assertEquals(201, $server->httpResponse->getStatus(), 'Full response body:'.$response1->getBodyAsString()); + $this->assertTrue((bool) $server->httpResponse->getHeaders('Lock-Token')); $lockToken = $server->httpResponse->getHeader('Lock-Token'); //sleep(10); @@ -47,7 +48,7 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(201, $server->httpResponse->status); - $this->assertTrue(!!$server->httpResponse->getHeaders('Lock-Token')); + $this->assertTrue((bool) $server->httpResponse->getHeaders('Lock-Token')); //sleep(10); @@ -57,16 +58,15 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(204, $server->httpResponse->status); - } - function getLockRequest() { - + public function getLockRequest() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'LOCK', + 'REQUEST_METHOD' => 'LOCK', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'HTTP_TIMEOUT' => 'Second-3600', - 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', + 'HTTP_TIMEOUT' => 'Second-3600', + 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', ]); $request->setBody('<D:lockinfo xmlns:D="DAV:"> @@ -82,15 +82,15 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { </D:lockinfo>'); return $request; - } - function getLockRequest2() { + public function getLockRequest2() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'LOCK', + 'REQUEST_METHOD' => 'LOCK', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'HTTP_TIMEOUT' => 'Second-3600', - 'REQUEST_URI' => '/~$Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', + 'HTTP_TIMEOUT' => 'Second-3600', + 'REQUEST_URI' => '/~$Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', ]); $request->setBody('<D:lockinfo xmlns:D="DAV:"> @@ -106,19 +106,17 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { </D:lockinfo>'); return $request; - } - function getPutRequest($lockToken) { - + public function getPutRequest($lockToken) + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', - 'HTTP_IF' => 'If: (' . $lockToken . ')', + 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', + 'HTTP_IF' => 'If: ('.$lockToken.')', ]); $request->setBody('FAKE BODY'); - return $request; + return $request; } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php index dbbf6757a..b3a0ac9af 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks; use Sabre\DAV; @@ -7,63 +9,58 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class PluginTest extends DAV\AbstractServer { - +class PluginTest extends DAV\AbstractServer +{ /** * @var Plugin */ protected $locksPlugin; - function setUp() { - + public function setUp() + { parent::setUp(); - $locksBackend = new Backend\File(SABRE_TEMPDIR . '/locksdb'); + $locksBackend = new Backend\File(SABRE_TEMPDIR.'/locksdb'); $locksPlugin = new Plugin($locksBackend); $this->server->addPlugin($locksPlugin); $this->locksPlugin = $locksPlugin; - } - function testGetInfo() { - + public function testGetInfo() + { $this->assertArrayHasKey( 'name', $this->locksPlugin->getPluginInfo() ); - } - function testGetFeatures() { - + public function testGetFeatures() + { $this->assertEquals([2], $this->locksPlugin->getFeatures()); - } - function testGetHTTPMethods() { - + public function testGetHTTPMethods() + { $this->assertEquals(['LOCK', 'UNLOCK'], $this->locksPlugin->getHTTPMethods('')); - } - function testLockNoBody() { - + public function testLockNoBody() + { $request = new HTTP\Request('LOCK', '/test.txt'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders() ); $this->assertEquals(400, $this->response->status); - } - function testLock() { - + public function testLock() + { $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -78,11 +75,11 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - $this->assertEquals(200, $this->response->status, 'Got an incorrect status back. Response body: ' . $this->response->body); + $this->assertEquals(200, $this->response->status, 'Got an incorrect status back. Response body: '.$this->response->body); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); @@ -105,22 +102,21 @@ class PluginTest extends DAV\AbstractServer { foreach ($elements as $elem) { $data = $xml->xpath($elem); - $this->assertEquals(1, count($data), 'We expected 1 match for the xpath expression "' . $elem . '". ' . count($data) . ' were found. Full response body: ' . $this->response->body); + $this->assertEquals(1, count($data), 'We expected 1 match for the xpath expression "'.$elem.'". '.count($data).' were found. Full response body: '.$this->response->body); } $depth = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:depth'); - $this->assertEquals('infinity', (string)$depth[0]); + $this->assertEquals('infinity', (string) $depth[0]); $token = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href'); - $this->assertEquals($this->response->getHeader('Lock-Token'), '<' . (string)$token[0] . '>', 'Token in response body didn\'t match token in response header.'); - + $this->assertEquals($this->response->getHeader('Lock-Token'), '<'.(string) $token[0].'>', 'Token in response body didn\'t match token in response header.'); } /** * @depends testLock */ - function testDoubleLock() { - + public function testDoubleLock() + { $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -141,15 +137,14 @@ class PluginTest extends DAV\AbstractServer { $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertEquals(423, $this->response->status, 'Full response: ' . $this->response->body); - + $this->assertEquals(423, $this->response->status, 'Full response: '.$this->response->body); } /** * @depends testLock */ - function testLockRefresh() { - + public function testLockRefresh() + { $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -168,7 +163,7 @@ class PluginTest extends DAV\AbstractServer { $this->response = new HTTP\ResponseMock(); $this->server->httpResponse = $this->response; - $request = new HTTP\Request('LOCK', '/test.txt', ['If' => '(' . $lockToken . ')']); + $request = new HTTP\Request('LOCK', '/test.txt', ['If' => '('.$lockToken.')']); $request->setBody(''); $this->server->httpRequest = $request; @@ -176,15 +171,14 @@ class PluginTest extends DAV\AbstractServer { $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertEquals(200, $this->response->status, 'We received an incorrect status code. Full response body: ' . $this->response->getBody()); - + $this->assertEquals(200, $this->response->status, 'We received an incorrect status code. Full response body: '.$this->response->getBody()); } /** * @depends testLock */ - function testLockRefreshBadToken() { - + public function testLockRefreshBadToken() + { $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -203,7 +197,7 @@ class PluginTest extends DAV\AbstractServer { $this->response = new HTTP\ResponseMock(); $this->server->httpResponse = $this->response; - $request = new HTTP\Request('LOCK', '/test.txt', ['If' => '(' . $lockToken . 'foobar) (<opaquelocktoken:anotherbadtoken>)']); + $request = new HTTP\Request('LOCK', '/test.txt', ['If' => '('.$lockToken.'foobar) (<opaquelocktoken:anotherbadtoken>)']); $request->setBody(''); $this->server->httpRequest = $request; @@ -211,15 +205,14 @@ class PluginTest extends DAV\AbstractServer { $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertEquals(423, $this->response->getStatus(), 'We received an incorrect status code. Full response body: ' . $this->response->getBody()); - + $this->assertEquals(423, $this->response->getStatus(), 'We received an incorrect status code. Full response body: '.$this->response->getBody()); } /** * @depends testLock */ - function testLockNoFile() { - + public function testLockNoFile() + { $request = new HTTP\Request('LOCK', '/notfound.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -234,57 +227,54 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(201, $this->response->status); - } /** * @depends testLock */ - function testUnlockNoToken() { - + public function testUnlockNoToken() + { $request = new HTTP\Request('UNLOCK', '/test.txt'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders() ); $this->assertEquals(400, $this->response->status); - } /** * @depends testLock */ - function testUnlockBadToken() { - + public function testUnlockBadToken() + { $request = new HTTP\Request('UNLOCK', '/test.txt', ['Lock-Token' => '<opaquelocktoken:blablabla>']); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders() ); - $this->assertEquals(409, $this->response->status, 'Got an incorrect status code. Full response body: ' . $this->response->body); - + $this->assertEquals(409, $this->response->status, 'Got an incorrect status code. Full response body: '.$this->response->body); } /** * @depends testLock */ - function testLockPutNoToken() { - + public function testLockPutNoToken() + { $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -299,7 +289,7 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); @@ -309,17 +299,16 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(423, $this->response->status); - } /** * @depends testLock */ - function testUnlock() { - + public function testUnlock() + { $request = new HTTP\Request('LOCK', '/test.txt'); $this->server->httpRequest = $request; @@ -340,22 +329,20 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpResponse = new HTTP\ResponseMock(); $this->server->invokeMethod($request, $this->server->httpResponse); - $this->assertEquals(204, $this->server->httpResponse->status, 'Got an incorrect status code. Full response body: ' . $this->response->body); + $this->assertEquals(204, $this->server->httpResponse->status, 'Got an incorrect status code. Full response body: '.$this->response->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->server->httpResponse->getHeaders() ); - - } /** * @depends testLock */ - function testUnlockWindowsBug() { - + public function testUnlockWindowsBug() + { $request = new HTTP\Request('LOCK', '/test.txt'); $this->server->httpRequest = $request; @@ -379,26 +366,21 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpResponse = new HTTP\ResponseMock(); $this->server->invokeMethod($request, $this->server->httpResponse); - $this->assertEquals(204, $this->server->httpResponse->status, 'Got an incorrect status code. Full response body: ' . $this->response->body); + $this->assertEquals(204, $this->server->httpResponse->status, 'Got an incorrect status code. Full response body: '.$this->response->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->server->httpResponse->getHeaders() ); - - } /** * @depends testLock */ - function testLockRetainOwner() { - - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'LOCK', - ]); + public function testLockRetainOwner() + { + $request = new HTTP\Request('LOCK', '/test.txt'); $this->server->httpRequest = $request; $request->setBody('<?xml version="1.0"?> @@ -414,21 +396,14 @@ class PluginTest extends DAV\AbstractServer { $locks = $this->locksPlugin->getLocks('test.txt'); $this->assertEquals(1, count($locks)); $this->assertEquals('Evert', $locks[0]->owner); - - } /** * @depends testLock */ - function testLockPutBadToken() { - - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockPutBadToken() + { + $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -442,40 +417,30 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'PUT', - 'HTTP_IF' => '(<opaquelocktoken:token1>)', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('PUT', '/test.txt', [ + 'If' => '(<opaquelocktoken:token1>)', + ]); $request->setBody('newbody'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); // $this->assertEquals('412 Precondition failed',$this->response->status); $this->assertEquals(423, $this->response->status); - } /** * @depends testLock */ - function testLockDeleteParent() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockDeleteParent() + { + $request = new HTTP\Request('LOCK', '/dir/child.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -489,34 +454,24 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir', - 'REQUEST_METHOD' => 'DELETE', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('DELETE', '/dir'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(423, $this->response->status); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } + /** * @depends testLock */ - function testLockDeleteSucceed() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockDeleteSucceed() + { + $request = new HTTP\Request('LOCK', '/dir/child.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -530,36 +485,26 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'DELETE', - 'HTTP_IF' => '(' . $this->response->getHeader('Lock-Token') . ')', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('DELETE', '/dir/child.txt', [ + 'If' => '('.$this->response->getHeader('Lock-Token').')', + ]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(204, $this->response->status); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } /** * @depends testLock */ - function testLockCopyLockSource() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockCopyLockSource() + { + $request = new HTTP\Request('LOCK', '/dir/child.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -573,35 +518,27 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'COPY', - 'HTTP_DESTINATION' => '/dir/child2.txt', - ]; + $request = new HTTP\Request('COPY', '/dir/child.txt', [ + 'Destination' => '/dir/child2.txt', + ]); - $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(201, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } + /** * @depends testLock */ - function testLockCopyLockDestination() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child2.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockCopyLockDestination() + { + $request = new HTTP\Request('LOCK', '/dir/child2.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -615,36 +552,26 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(201, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'COPY', - 'HTTP_DESTINATION' => '/dir/child2.txt', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('COPY', '/dir/child.txt', [ + 'Destination' => '/dir/child2.txt', + ]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(423, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } /** * @depends testLock */ - function testLockMoveLockSourceLocked() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockMoveLockSourceLocked() + { + $request = new HTTP\Request('LOCK', '/dir/child.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -658,36 +585,26 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'MOVE', - 'HTTP_DESTINATION' => '/dir/child2.txt', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('MOVE', '/dir/child.txt', [ + 'Destination' => '/dir/child2.txt', + ]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(423, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } /** * @depends testLock */ - function testLockMoveLockSourceSucceed() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockMoveLockSourceSucceed() + { + $request = new HTTP\Request('LOCK', '/dir/child.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -701,36 +618,26 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'MOVE', - 'HTTP_DESTINATION' => '/dir/child2.txt', - 'HTTP_IF' => '(' . $this->response->getHeader('Lock-Token') . ')', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('MOVE', '/dir/child.txt', [ + 'Destination' => '/dir/child2.txt', + 'If' => '('.$this->response->getHeader('Lock-Token').')', + ]); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(201, $this->response->status, 'A valid lock-token was provided for the source, so this MOVE operation must succeed. Full response body: ' . $this->response->body); - + $this->assertEquals(201, $this->response->status, 'A valid lock-token was provided for the source, so this MOVE operation must succeed. Full response body: '.$this->response->body); } /** * @depends testLock */ - function testLockMoveLockDestination() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child2.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockMoveLockDestination() + { + $request = new HTTP\Request('LOCK', '/dir/child2.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -744,36 +651,28 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(201, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'MOVE', - 'HTTP_DESTINATION' => '/dir/child2.txt', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('MOVE', '/dir/child.txt', [ + 'Destination' => '/dir/child2.txt', + ]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(423, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } + /** * @depends testLock */ - function testLockMoveLockParent() { - - $serverVars = [ - 'REQUEST_URI' => '/dir', - 'REQUEST_METHOD' => 'LOCK', - 'HTTP_DEPTH' => 'infinite', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockMoveLockParent() + { + $request = new HTTP\Request('LOCK', '/dir', [ + 'Depth' => 'infinite', + ]); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -787,37 +686,27 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'MOVE', - 'HTTP_DESTINATION' => '/dir/child2.txt', - 'HTTP_IF' => '</dir> (' . $this->response->getHeader('Lock-Token') . ')', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('MOVE', '/dir/child.txt', [ + 'Destination' => '/dir/child2.txt', + 'If' => '</dir> ('.$this->response->getHeader('Lock-Token').')', + ]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(201, $this->response->status, 'We locked the parent of both the source and destination, but the move didn\'t succeed.'); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } /** * @depends testLock */ - function testLockPutGoodToken() { - - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockPutGoodToken() + { + $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -831,33 +720,28 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'PUT', - 'HTTP_IF' => '(' . $this->response->getHeader('Lock-Token') . ')', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('PUT', '/test.txt', [ + 'If' => '('.$this->response->getHeader('Lock-Token').')', + ]); $request->setBody('newbody'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(204, $this->response->status); - } /** * @depends testLock */ - function testLockPutUnrelatedToken() { - + public function testLockPutUnrelatedToken() + { $request = new HTTP\Request('LOCK', '/unrelated.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -872,132 +756,109 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(201, $this->response->getStatus()); $request = new HTTP\Request( 'PUT', '/test.txt', - ['If' => '</unrelated.txt> (' . $this->response->getHeader('Lock-Token') . ')'] + ['If' => '</unrelated.txt> ('.$this->response->getHeader('Lock-Token').')'] ); $request->setBody('newbody'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(204, $this->response->status); - } - function testPutWithIncorrectETag() { - - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'PUT', - 'HTTP_IF' => '(["etag1"])', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testPutWithIncorrectETag() + { + $request = new HTTP\Request('PUT', '/test.txt', [ + 'If' => '(["etag1"])', + ]); $request->setBody('newbody'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(412, $this->response->status); - } /** * @depends testPutWithIncorrectETag */ - function testPutWithCorrectETag() { - + public function testPutWithCorrectETag() + { // We need an ETag-enabled file node. $tree = new DAV\Tree(new DAV\FSExt\Directory(SABRE_TEMPDIR)); $this->server->tree = $tree; - $filename = SABRE_TEMPDIR . '/test.txt'; + $filename = SABRE_TEMPDIR.'/test.txt'; $etag = sha1( - fileinode($filename) . - filesize($filename) . + fileinode($filename). + filesize($filename). filemtime($filename) ); - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'PUT', - 'HTTP_IF' => '(["' . $etag . '"])', - ]; - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('PUT', '/test.txt', [ + 'If' => '(["'.$etag.'"])', + ]); $request->setBody('newbody'); + $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(204, $this->response->status, 'Incorrect status received. Full response body:' . $this->response->body); - + $this->assertEquals(204, $this->response->status, 'Incorrect status received. Full response body:'.$this->response->body); } - function testDeleteWithETagOnCollection() { - - $serverVars = [ - 'REQUEST_URI' => '/dir', - 'REQUEST_METHOD' => 'DELETE', - 'HTTP_IF' => '(["etag1"])', - ]; - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testDeleteWithETagOnCollection() + { + $request = new HTTP\Request('DELETE', '/dir', [ + 'If' => '(["etag1"])', + ]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(412, $this->response->status); - } - function testGetTimeoutHeader() { - - $request = HTTP\Sapi::createFromServerArray([ - 'HTTP_TIMEOUT' => 'second-100', + public function testGetTimeoutHeader() + { + $request = new HTTP\Request('LOCK', '/foo/bar', [ + 'Timeout' => 'second-100', ]); $this->server->httpRequest = $request; $this->assertEquals(100, $this->locksPlugin->getTimeoutHeader()); - } - function testGetTimeoutHeaderTwoItems() { - - $request = HTTP\Sapi::createFromServerArray([ - 'HTTP_TIMEOUT' => 'second-5, infinite', + public function testGetTimeoutHeaderTwoItems() + { + $request = new HTTP\Request('LOCK', '/foo/bar', [ + 'Timeout' => 'second-5, infinite', ]); - $this->server->httpRequest = $request; $this->assertEquals(5, $this->locksPlugin->getTimeoutHeader()); - } - function testGetTimeoutHeaderInfinite() { - - $request = HTTP\Sapi::createFromServerArray([ - 'HTTP_TIMEOUT' => 'infinite, second-5', + public function testGetTimeoutHeaderInfinite() + { + $request = new HTTP\Request('LOCK', '/foo/bar', [ + 'Timeout' => 'infinite, second-5', ]); - $this->server->httpRequest = $request; $this->assertEquals(LockInfo::TIMEOUT_INFINITE, $this->locksPlugin->getTimeoutHeader()); - } /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ - function testGetTimeoutHeaderInvalid() { - - $request = HTTP\Sapi::createFromServerArray([ - 'HTTP_TIMEOUT' => 'yourmom', - ]); + public function testGetTimeoutHeaderInvalid() + { + $request = new HTTP\Request('GET', '/', ['Timeout' => 'yourmom']); $this->server->httpRequest = $request; $this->locksPlugin->getTimeoutHeader(); - } - - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php b/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php index fded5e474..e0bdecc09 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Mock; use Sabre\DAV; @@ -19,22 +21,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Collection extends DAV\Collection { - +class Collection extends DAV\Collection +{ protected $name; protected $children; protected $parent; /** - * Creates the object + * Creates the object. * - * @param string $name - * @param array $children + * @param string $name + * @param array $children * @param Collection $parent - * @return void */ - function __construct($name, array $children = [], Collection $parent = null) { - + public function __construct($name, array $children = [], Collection $parent = null) + { $this->name = $name; foreach ($children as $key => $value) { if (is_string($value)) { @@ -48,7 +49,6 @@ class Collection extends DAV\Collection { } } $this->parent = $parent; - } /** @@ -58,14 +58,13 @@ class Collection extends DAV\Collection { * * @return string */ - function getName() { - + public function getName() + { return $this->name; - } /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -84,41 +83,39 @@ class Collection extends DAV\Collection { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - + public function createFile($name, $data = '') + { if (is_resource($data)) { $data = stream_get_contents($data); } $this->children[] = new File($name, $data, $this); - return '"' . md5($data) . '"'; + return '"'.md5($data).'"'; } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { $this->children[] = new self($name); - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return \Sabre\DAV\INode[] */ - function getChildren() { - + public function getChildren() + { return $this->children; - } /** @@ -126,43 +123,35 @@ class Collection extends DAV\Collection { * * @param \Sabre\DAV\INode $node */ - function addNode(\Sabre\DAV\INode $node) { - + public function addNode(\Sabre\DAV\INode $node) + { $this->children[] = $node; - } /** * Removes a childnode from this node. * * @param string $name - * @return void */ - function deleteChild($name) { - + public function deleteChild($name) + { foreach ($this->children as $key => $value) { - if ($value->getName() == $name) { unset($this->children[$key]); + return; } - } - } /** * Deletes this collection and all its children,. - * - * @return void */ - function delete() { - + public function delete() + { foreach ($this->getChildren() as $child) { $this->deleteChild($child->getName()); } $this->parent->deleteChild($this->getName()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php b/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php index a624b6b6b..d48ddaa92 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Mock; use Sabre\DAV; /** - * Mock File + * Mock File. * * See the Collection in this directory for more details. * @@ -13,34 +15,32 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends DAV\File { - +class File extends DAV\File +{ protected $name; protected $contents; protected $parent; protected $lastModified; /** - * Creates the object + * Creates the object. * - * @param string $name - * @param resource $contents + * @param string $name + * @param resource $contents * @param Collection $parent - * @param int $lastModified - * @return void + * @param int $lastModified */ - function __construct($name, $contents, Collection $parent = null, $lastModified = -1) { - + public function __construct($name, $contents, Collection $parent = null, $lastModified = -1) + { $this->name = $name; $this->put($contents); $this->parent = $parent; - if ($lastModified === -1) { + if (-1 === $lastModified) { $lastModified = time(); } $this->lastModified = $lastModified; - } /** @@ -50,26 +50,23 @@ class File extends DAV\File { * * @return string */ - function getName() { - + public function getName() + { return $this->name; - } /** * Changes the name of the node. * * @param string $name - * @return void */ - function setName($name) { - + public function setName($name) + { $this->name = $name; - } /** - * Updates the data + * Updates the data. * * The data argument is a readable stream resource. * @@ -86,66 +83,59 @@ class File extends DAV\File { * return an ETag, and just return null. * * @param resource $data + * * @return string|null */ - function put($data) { - + public function put($data) + { if (is_resource($data)) { $data = stream_get_contents($data); } $this->contents = $data; - return '"' . md5($data) . '"'; + return '"'.md5($data).'"'; } /** - * Returns the data + * Returns the data. * * This method may either return a string or a readable stream resource * * @return mixed */ - function get() { - + public function get() + { return $this->contents; - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * * Return null if the ETag can not effectively be determined - * - * @return void */ - function getETag() { - - return '"' . md5($this->contents) . '"'; - + public function getETag() + { + return '"'.md5($this->contents).'"'; } /** - * Returns the size of the node, in bytes + * Returns the size of the node, in bytes. * * @return int */ - function getSize() { - + public function getSize() + { return strlen($this->contents); - } /** - * Delete the node - * - * @return void + * Delete the node. */ - function delete() { - + public function delete() + { $this->parent->deleteChild($this->name); - } /** @@ -154,10 +144,8 @@ class File extends DAV\File { * * @return int */ - function getLastModified() { - + public function getLastModified() + { return $this->lastModified; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php index 3213fcb1b..c993e609d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Mount; use Sabre\DAV; @@ -7,19 +9,18 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class PluginTest extends DAV\AbstractServer { - - function setUp() { - +class PluginTest extends DAV\AbstractServer +{ + public function setUp() + { parent::setUp(); $this->server->addPlugin(new Plugin()); - } - function testPassThrough() { - + public function testPassThrough() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET', ]; @@ -27,17 +28,16 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(501, $this->response->status, 'We expected GET to not be implemented for Directories. Response body: ' . $this->response->body); - + $this->assertEquals(501, $this->response->status, 'We expected GET to not be implemented for Directories. Response body: '.$this->response->body); } - function testMountResponse() { - + public function testMountResponse() + { $serverVars = [ - 'REQUEST_URI' => '/?mount', + 'REQUEST_URI' => '/?mount', 'REQUEST_METHOD' => 'GET', - 'QUERY_STRING' => 'mount', - 'HTTP_HOST' => 'example.org', + 'QUERY_STRING' => 'mount', + 'HTTP_HOST' => 'example.org', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -47,12 +47,10 @@ class PluginTest extends DAV\AbstractServer { $this->assertEquals(200, $this->response->status); $xml = simplexml_load_string($this->response->body); - $this->assertInstanceOf('SimpleXMLElement', $xml, 'Response was not a valid xml document. The list of errors:' . print_r(libxml_get_errors(), true) . '. xml body: ' . $this->response->body . '. What type we got: ' . gettype($xml) . ' class, if object: ' . get_class($xml)); + $this->assertInstanceOf('SimpleXMLElement', $xml, 'Response was not a valid xml document. The list of errors:'.print_r(libxml_get_errors(), true).'. xml body: '.$this->response->body.'. What type we got: '.gettype($xml).' class, if object: '.get_class($xml)); $xml->registerXPathNamespace('dm', 'http://purl.org/NET/webdav/mount'); $url = $xml->xpath('//dm:url'); - $this->assertEquals('http://example.org/', (string)$url[0]); - + $this->assertEquals('http://example.org/', (string) $url[0]); } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php index 15289ce52..6b6652967 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php @@ -1,100 +1,92 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; require_once 'Sabre/TestUtil.php'; -class ObjectTreeTest extends \PHPUnit_Framework_TestCase { - +class ObjectTreeTest extends \PHPUnit\Framework\TestCase +{ protected $tree; - function setup() { - + public function setup() + { \Sabre\TestUtil::clearTempDir(); - mkdir(SABRE_TEMPDIR . '/root'); - mkdir(SABRE_TEMPDIR . '/root/subdir'); - file_put_contents(SABRE_TEMPDIR . '/root/file.txt', 'contents'); - file_put_contents(SABRE_TEMPDIR . '/root/subdir/subfile.txt', 'subcontents'); - $rootNode = new FSExt\Directory(SABRE_TEMPDIR . '/root'); + mkdir(SABRE_TEMPDIR.'/root'); + mkdir(SABRE_TEMPDIR.'/root/subdir'); + file_put_contents(SABRE_TEMPDIR.'/root/file.txt', 'contents'); + file_put_contents(SABRE_TEMPDIR.'/root/subdir/subfile.txt', 'subcontents'); + $rootNode = new FSExt\Directory(SABRE_TEMPDIR.'/root'); $this->tree = new Tree($rootNode); - } - function teardown() { - + public function teardown() + { \Sabre\TestUtil::clearTempDir(); - } - function testGetRootNode() { - + public function testGetRootNode() + { $root = $this->tree->getNodeForPath(''); $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory', $root); - } - function testGetSubDir() { - + public function testGetSubDir() + { $root = $this->tree->getNodeForPath('subdir'); $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory', $root); - } - function testCopyFile() { - - $this->tree->copy('file.txt', 'file2.txt'); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/file2.txt')); - $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR . '/root/file2.txt')); - + public function testCopyFile() + { + $this->tree->copy('file.txt', 'file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/file2.txt')); + $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR.'/root/file2.txt')); } /** * @depends testCopyFile */ - function testCopyDirectory() { - - $this->tree->copy('subdir', 'subdir2'); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2')); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2/subfile.txt')); - $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR . '/root/subdir2/subfile.txt')); - + public function testCopyDirectory() + { + $this->tree->copy('subdir', 'subdir2'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2')); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); + $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); } /** * @depends testCopyFile */ - function testMoveFile() { - - $this->tree->move('file.txt', 'file2.txt'); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/file2.txt')); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/root/file.txt')); - $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR . '/root/file2.txt')); - + public function testMoveFile() + { + $this->tree->move('file.txt', 'file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/file2.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/file.txt')); + $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR.'/root/file2.txt')); } /** * @depends testMoveFile */ - function testMoveFileNewParent() { - - $this->tree->move('file.txt', 'subdir/file2.txt'); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir/file2.txt')); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/root/file.txt')); - $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR . '/root/subdir/file2.txt')); - + public function testMoveFileNewParent() + { + $this->tree->move('file.txt', 'subdir/file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir/file2.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/file.txt')); + $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR.'/root/subdir/file2.txt')); } /** * @depends testCopyDirectory */ - function testMoveDirectory() { - - $this->tree->move('subdir', 'subdir2'); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2')); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2/subfile.txt')); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/root/subdir')); - $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR . '/root/subdir2/subfile.txt')); - + public function testMoveDirectory() + { + $this->tree->move('subdir', 'subdir2'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2')); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/subdir')); + $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php index eff1e7d67..72fdb5ec8 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php @@ -1,20 +1,21 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PartialUpdate; use Sabre\DAV; -class FileMock implements IPatchSupport { - +class FileMock implements IPatchSupport +{ protected $data = ''; - function put($str) { - + public function put($str) + { if (is_resource($str)) { $str = stream_get_contents($str); } $this->data = $str; - } /** @@ -40,83 +41,71 @@ class FileMock implements IPatchSupport { * time. * * @param resource|string $data - * @param int $rangeType - * @param int $offset + * @param int $rangeType + * @param int $offset + * * @return string|null */ - function patch($data, $rangeType, $offset = null) { - + public function patch($data, $rangeType, $offset = null) + { if (is_resource($data)) { $data = stream_get_contents($data); } switch ($rangeType) { - - case 1 : + case 1: $this->data .= $data; break; - case 3 : + case 3: // Turn the offset into an offset-offset. $offset = strlen($this->data) - $offset; - // No break is intentional - case 2 : + // no break is intentional + case 2: $this->data = - substr($this->data, 0, $offset) . - $data . + substr($this->data, 0, $offset). + $data. substr($this->data, $offset + strlen($data)); break; - } - } - function get() { - + public function get() + { return $this->data; - } - function getContentType() { - + public function getContentType() + { return 'text/plain'; - } - function getSize() { - + public function getSize() + { return strlen($this->data); - } - function getETag() { - - return '"' . $this->data . '"'; - + public function getETag() + { + return '"'.$this->data.'"'; } - function delete() { - + public function delete() + { throw new DAV\Exception\MethodNotAllowed(); - } - function setName($name) { - + public function setName($name) + { throw new DAV\Exception\MethodNotAllowed(); - } - function getName() { - + public function getName() + { return 'partial'; - } - function getLastModified() { - + public function getLastModified() + { return null; - } - - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php index 5bd696416..63d692ec9 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php @@ -1,19 +1,20 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PartialUpdate; -use Sabre\DAV; use Sabre\HTTP; require_once 'Sabre/DAV/PartialUpdate/FileMock.php'; -class PluginTest extends \Sabre\DAVServerTest { - +class PluginTest extends \Sabre\DAVServerTest +{ protected $node; protected $plugin; - function setUp() { - + public function setUp() + { $this->node = new FileMock(); $this->tree[] = $this->node; @@ -21,38 +22,33 @@ class PluginTest extends \Sabre\DAVServerTest { $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); - - - } - function testInit() { - + public function testInit() + { $this->assertEquals('partialupdate', $this->plugin->getPluginName()); $this->assertEquals(['sabredav-partialupdate'], $this->plugin->getFeatures()); $this->assertEquals([ - 'PATCH' + 'PATCH', ], $this->plugin->getHTTPMethods('partial')); $this->assertEquals([ ], $this->plugin->getHTTPMethods('')); - } - function testPatchNoRange() { - + public function testPatchNoRange() + { $this->node->put('aaaaaaaa'); $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PATCH', - 'REQUEST_URI' => '/partial', + 'REQUEST_URI' => '/partial', ]); $response = $this->request($request); - $this->assertEquals(400, $response->status, 'Full response body:' . $response->body); - + $this->assertEquals(400, $response->status, 'Full response body:'.$response->body); } - function testPatchNotSupported() { - + public function testPatchNotSupported() + { $this->node->put('aaaaaaaa'); $request = new HTTP\Request('PATCH', '/', ['X-Update-Range' => '3-4']); $request->setBody( @@ -60,12 +56,11 @@ class PluginTest extends \Sabre\DAVServerTest { ); $response = $this->request($request); - $this->assertEquals(405, $response->status, 'Full response body:' . $response->body); - + $this->assertEquals(405, $response->status, 'Full response body:'.$response->body); } - function testPatchNoContentType() { - + public function testPatchNoContentType() + { $this->node->put('aaaaaaaa'); $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4']); $request->setBody( @@ -73,12 +68,11 @@ class PluginTest extends \Sabre\DAVServerTest { ); $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Full response body:' . $response->body); - + $this->assertEquals(415, $response->status, 'Full response body:'.$response->body); } - function testPatchBadRange() { - + public function testPatchBadRange() + { $this->node->put('aaaaaaaa'); $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']); $request->setBody( @@ -86,12 +80,11 @@ class PluginTest extends \Sabre\DAVServerTest { ); $response = $this->request($request); - $this->assertEquals(416, $response->status, 'Full response body:' . $response->body); - + $this->assertEquals(416, $response->status, 'Full response body:'.$response->body); } - function testPatchNoLength() { - + public function testPatchNoLength() + { $this->node->put('aaaaaaaa'); $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate']); $request->setBody( @@ -99,12 +92,11 @@ class PluginTest extends \Sabre\DAVServerTest { ); $response = $this->request($request); - $this->assertEquals(411, $response->status, 'Full response body:' . $response->body); - + $this->assertEquals(411, $response->status, 'Full response body:'.$response->body); } - function testPatchSuccess() { - + public function testPatchSuccess() + { $this->node->put('aaaaaaaa'); $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => 3]); $request->setBody( @@ -112,13 +104,12 @@ class PluginTest extends \Sabre\DAVServerTest { ); $response = $this->request($request); - $this->assertEquals(204, $response->status, 'Full response body:' . $response->body); + $this->assertEquals(204, $response->status, 'Full response body:'.$response->body); $this->assertEquals('aaabbbaa', $this->node->get()); - } - function testPatchNoEndRange() { - + public function testPatchNoEndRange() + { $this->node->put('aaaaa'); $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']); $request->setBody( @@ -127,9 +118,7 @@ class PluginTest extends \Sabre\DAVServerTest { $response = $this->request($request); - $this->assertEquals(204, $response->getStatus(), 'Full response body:' . $response->getBodyAsString()); + $this->assertEquals(204, $response->getStatus(), 'Full response body:'.$response->getBodyAsString()); $this->assertEquals('aaabbb', $this->node->get()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php index 2c6274173..56b2d576f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PartialUpdate; use Sabre\DAV\FSExt\File; @@ -12,14 +14,14 @@ use Sabre\HTTP; * * See: http://sabre.io/dav/http-patch/ */ -class SpecificationTest extends \PHPUnit_Framework_TestCase { - +class SpecificationTest extends \PHPUnit\Framework\TestCase +{ protected $server; - function setUp() { - + public function setUp() + { $tree = [ - new File(SABRE_TEMPDIR . '/foobar.txt') + new File(SABRE_TEMPDIR.'/foobar.txt'), ]; $server = new Server($tree); $server->debugExceptions = true; @@ -28,32 +30,30 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase { $tree[0]->put('1234567890'); $this->server = $server; - } - function tearDown() { - + public function tearDown() + { \Sabre\TestUtil::clearTempDir(); - } /** * @param string $headerValue * @param string $httpStatus * @param string $endResult - * @param int $contentLength + * @param int $contentLength * * @dataProvider data */ - function testUpdateRange($headerValue, $httpStatus, $endResult, $contentLength = 4) { - + public function testUpdateRange($headerValue, $httpStatus, $endResult, $contentLength = 4) + { $headers = [ - 'Content-Type' => 'application/x-sabredav-partialupdate', + 'Content-Type' => 'application/x-sabredav-partialupdate', 'X-Update-Range' => $headerValue, ]; if ($contentLength) { - $headers['Content-Length'] = (string)$contentLength; + $headers['Content-Length'] = (string) $contentLength; } $request = new HTTP\Request('PATCH', '/foobar.txt', $headers, '----'); @@ -64,15 +64,14 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase { $this->server->sapi = new HTTP\SapiMock(); $this->server->exec(); - $this->assertEquals($httpStatus, $this->server->httpResponse->status, 'Incorrect http status received: ' . $this->server->httpResponse->body); + $this->assertEquals($httpStatus, $this->server->httpResponse->status, 'Incorrect http status received: '.$this->server->httpResponse->body); if (!is_null($endResult)) { - $this->assertEquals($endResult, file_get_contents(SABRE_TEMPDIR . '/foobar.txt')); + $this->assertEquals($endResult, file_get_contents(SABRE_TEMPDIR.'/foobar.txt')); } - } - function data() { - + public function data() + { return [ // Problems ['foo', 400, null], @@ -86,9 +85,6 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase { ['bytes=-2', 204, '12345678----'], ['bytes=2-', 204, '12----7890'], ['append', 204, '1234567890----'], - ]; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php index 42759647a..7d55ea02e 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php @@ -1,36 +1,36 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class ServerEventsTest extends AbstractServer { - +class ServerEventsTest extends AbstractServer +{ private $tempPath; private $exception; - function testAfterBind() { - + public function testAfterBind() + { $this->server->on('afterBind', [$this, 'afterBindHandler']); $newPath = 'afterBind'; $this->tempPath = ''; $this->server->createFile($newPath, 'body'); $this->assertEquals($newPath, $this->tempPath); - } - function afterBindHandler($path) { - - $this->tempPath = $path; - + public function afterBindHandler($path) + { + $this->tempPath = $path; } - function testAfterResponse() { - + public function testAfterResponse() + { $mock = $this->getMockBuilder('stdClass') ->setMethods(['afterResponseCallback']) ->getMock(); @@ -40,74 +40,65 @@ class ServerEventsTest extends AbstractServer { $this->server->httpRequest = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/test.txt', + 'REQUEST_URI' => '/test.txt', ]); $this->server->exec(); - } - function testBeforeBindCancel() { - + public function testBeforeBindCancel() + { $this->server->on('beforeBind', [$this, 'beforeBindCancelHandler']); $this->assertFalse($this->server->createFile('bla', 'body')); // Also testing put() $req = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/barbar', + 'REQUEST_URI' => '/barbar', ]); $this->server->httpRequest = $req; $this->server->exec(); $this->assertEquals(500, $this->server->httpResponse->getStatus()); - } - function beforeBindCancelHandler($path) { - + public function beforeBindCancelHandler($path) + { return false; - } - function testException() { - + public function testException() + { $this->server->on('exception', [$this, 'exceptionHandler']); $req = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/not/exisitng', + 'REQUEST_URI' => '/not/exisitng', ]); $this->server->httpRequest = $req; $this->server->exec(); $this->assertInstanceOf('Sabre\\DAV\\Exception\\NotFound', $this->exception); - } - function exceptionHandler(Exception $exception) { - + public function exceptionHandler(Exception $exception) + { $this->exception = $exception; - } - function testMethod() { - + public function testMethod() + { $k = 1; - $this->server->on('method', function($request, $response) use (&$k) { - - $k += 1; + $this->server->on('method:*', function ($request, $response) use (&$k) { + ++$k; return false; - }); - $this->server->on('method', function($request, $response) use (&$k) { - + $this->server->on('method:*', function ($request, $response) use (&$k) { $k += 2; return false; - }); try { @@ -116,11 +107,10 @@ class ServerEventsTest extends AbstractServer { new HTTP\Response(), false ); - } catch (Exception $e) {} + } catch (Exception $e) { + } // Fun fact, PHP 7.1 changes the order when sorting-by-callback. $this->assertTrue($k >= 2 && $k <= 3); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php index 557eddbbc..8e5bc6a64 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php @@ -1,91 +1,90 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; -class ServerMKCOLTest extends AbstractServer { - - function testMkcol() { - +class ServerMKCOLTest extends AbstractServer +{ + public function testMkcol() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', + 'REQUEST_URI' => '/testcol', 'REQUEST_METHOD' => 'MKCOL', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody(""); + $request->setBody(''); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->response->getHeaders()); $this->assertEquals(201, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertTrue(is_dir($this->tempDir . '/testcol')); - + $this->assertTrue(is_dir($this->tempDir.'/testcol')); } /** * @depends testMkcol */ - function testMKCOLUnknownBody() { - + public function testMKCOLUnknownBody() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', + 'REQUEST_URI' => '/testcol', 'REQUEST_METHOD' => 'MKCOL', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody("Hello"); + $request->setBody('Hello'); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); $this->assertEquals(415, $this->response->status); - } /** * @depends testMkcol */ - function testMKCOLBrokenXML() { - + public function testMKCOLBrokenXML() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody("Hello"); + $request->setBody('Hello'); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); $this->assertEquals(400, $this->response->getStatus(), $this->response->getBodyAsString()); - } /** * @depends testMkcol */ - function testMKCOLUnknownXML() { - + public function testMKCOLUnknownXML() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', ]; @@ -96,21 +95,20 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); $this->assertEquals(400, $this->response->getStatus()); - } /** * @depends testMkcol */ - function testMKCOLNoResourceType() { - + public function testMKCOLNoResourceType() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', ]; @@ -128,21 +126,20 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); - $this->assertEquals(400, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(400, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMkcol */ - function testMKCOLIncorrectResourceType() { - + public function testMKCOLIncorrectResourceType() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', ]; @@ -160,21 +157,20 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); - $this->assertEquals(403, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(403, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMKCOLIncorrectResourceType */ - function testMKCOLSuccess() { - + public function testMKCOLSuccess() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', ]; @@ -192,21 +188,20 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->response->getHeaders()); - $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMKCOLIncorrectResourceType */ - function testMKCOLWhiteSpaceResourceType() { - + public function testMKCOLWhiteSpaceResourceType() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', ]; @@ -226,20 +221,19 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->response->getHeaders()); - $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMKCOLIncorrectResourceType */ - function testMKCOLNoParent() { - + public function testMKCOLNoParent() + { $serverVars = [ - 'REQUEST_URI' => '/testnoparent/409me', + 'REQUEST_URI' => '/testnoparent/409me', 'REQUEST_METHOD' => 'MKCOL', ]; @@ -251,20 +245,19 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); - $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMKCOLIncorrectResourceType */ - function testMKCOLParentIsNoCollection() { - + public function testMKCOLParentIsNoCollection() + { $serverVars = [ - 'REQUEST_URI' => '/test.txt/409me', + 'REQUEST_URI' => '/test.txt/409me', 'REQUEST_METHOD' => 'MKCOL', ]; @@ -276,20 +269,19 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); - $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMKCOLIncorrectResourceType */ - function testMKCOLAlreadyExists() { - + public function testMKCOLAlreadyExists() + { $serverVars = [ - 'REQUEST_URI' => '/test.txt', + 'REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'MKCOL', ]; @@ -301,20 +293,19 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], ], $this->response->getHeaders()); - $this->assertEquals(405, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(405, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMKCOLSuccess * @depends testMKCOLAlreadyExists */ - function testMKCOLAndProps() { - + public function testMKCOLAndProps() + { $request = new HTTP\Request( 'MKCOL', '/testcol', @@ -332,11 +323,11 @@ class ServerMKCOLTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); $responseBody = $this->response->getBodyAsString(); @@ -360,7 +351,5 @@ XML; $expected, $responseBody ); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php index fa67102cc..35de59e37 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; @@ -7,44 +9,40 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; require_once 'Sabre/DAV/TestPlugin.php'; -class ServerPluginTest extends AbstractServer { - +class ServerPluginTest extends AbstractServer +{ /** * @var Sabre\DAV\TestPlugin */ protected $testPlugin; - function setUp() { - + public function setUp() + { parent::setUp(); $testPlugin = new TestPlugin(); $this->server->addPlugin($testPlugin); $this->testPlugin = $testPlugin; - } - /** - */ - function testBaseClass() { - + public function testBaseClass() + { $p = new ServerPluginMock(); $this->assertEquals([], $p->getFeatures()); $this->assertEquals([], $p->getHTTPMethods('')); $this->assertEquals( [ - 'name' => 'Sabre\DAV\ServerPluginMock', + 'name' => 'Sabre\DAV\ServerPluginMock', 'description' => null, - 'link' => null + 'link' => null, ], $p->getPluginInfo() ); - } - function testOptions() { - + public function testOptions() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'OPTIONS', ]; @@ -53,56 +51,49 @@ class ServerPluginTest extends AbstractServer { $this->server->exec(); $this->assertEquals([ - 'DAV' => ['1, 3, extended-mkcol, drinking'], - 'MS-Author-Via' => ['DAV'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, BEER, WINE'], - 'Accept-Ranges' => ['bytes'], - 'Content-Length' => ['0'], + 'DAV' => ['1, 3, extended-mkcol, drinking'], + 'MS-Author-Via' => ['DAV'], + 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, BEER, WINE'], + 'Accept-Ranges' => ['bytes'], + 'Content-Length' => ['0'], 'X-Sabre-Version' => [Version::VERSION], ], $this->response->getHeaders()); $this->assertEquals(200, $this->response->status); $this->assertEquals('', $this->response->body); $this->assertEquals('OPTIONS', $this->testPlugin->beforeMethod); - - } - function testGetPlugin() { - + public function testGetPlugin() + { $this->assertEquals($this->testPlugin, $this->server->getPlugin(get_class($this->testPlugin))); - } - function testUnknownPlugin() { - + public function testUnknownPlugin() + { $this->assertNull($this->server->getPlugin('SomeRandomClassName')); - } - function testGetSupportedReportSet() { - + public function testGetSupportedReportSet() + { $this->assertEquals([], $this->testPlugin->getSupportedReportSet('/')); - } - function testGetPlugins() { - + public function testGetPlugins() + { $this->assertEquals( [ get_class($this->testPlugin) => $this->testPlugin, - 'core' => $this->server->getPlugin('core'), + 'core' => $this->server->getPlugin('core'), ], $this->server->getPlugins() ); - } - - } -class ServerPluginMock extends ServerPlugin { - - function initialize(Server $s) { } - +class ServerPluginMock extends ServerPlugin +{ + public function initialize(Server $s) + { + } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php index 203cf26d9..fa88e9095 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php @@ -1,61 +1,55 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; -class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { - +class ServerPreconditionsTest extends \PHPUnit\Framework\TestCase +{ /** - * @expectedException Sabre\DAV\Exception\PreconditionFailed + * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ - function testIfMatchNoNode() { - + public function testIfMatchNoNode() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/bar', ['If-Match' => '*']); $httpResponse = new HTTP\Response(); $server->checkPreconditions($httpRequest, $httpResponse); - } - /** - */ - function testIfMatchHasNode() { - + public function testIfMatchHasNode() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '*']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } /** - * @expectedException Sabre\DAV\Exception\PreconditionFailed + * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ - function testIfMatchWrongEtag() { - + public function testIfMatchWrongEtag() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '1234']); $httpResponse = new HTTP\Response(); $server->checkPreconditions($httpRequest, $httpResponse); - } - /** - */ - function testIfMatchCorrectEtag() { - + public function testIfMatchCorrectEtag() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '"abc123"']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } /** @@ -63,107 +57,89 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { * * @depends testIfMatchCorrectEtag */ - function testIfMatchEvolutionEtag() { - + public function testIfMatchEvolutionEtag() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '\\"abc123\\"']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - /** - */ - function testIfMatchMultiple() { - + public function testIfMatchMultiple() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '"hellothere", "abc123"']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - /** - */ - function testIfNoneMatchNoNode() { - + public function testIfNoneMatchNoNode() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/bar', ['If-None-Match' => '*']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } /** - * @expectedException Sabre\DAV\Exception\PreconditionFailed + * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ - function testIfNoneMatchHasNode() { - + public function testIfNoneMatchHasNode() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '*']); $httpResponse = new HTTP\Response(); $server->checkPreconditions($httpRequest, $httpResponse); - } - /** - */ - function testIfNoneMatchWrongEtag() { - + public function testIfNoneMatchWrongEtag() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '"1234"']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - /** - */ - function testIfNoneMatchWrongEtagMultiple() { - + public function testIfNoneMatchWrongEtagMultiple() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '"1234", "5678"']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } /** - * @expectedException Sabre\DAV\Exception\PreconditionFailed + * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ - function testIfNoneMatchCorrectEtag() { - + public function testIfNoneMatchCorrectEtag() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '"abc123"']); $httpResponse = new HTTP\Response(); $server->checkPreconditions($httpRequest, $httpResponse); - } /** - * @expectedException Sabre\DAV\Exception\PreconditionFailed + * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ - function testIfNoneMatchCorrectEtagMultiple() { - + public function testIfNoneMatchCorrectEtagMultiple() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '"1234, "abc123"']); $httpResponse = new HTTP\Response(); $server->checkPreconditions($httpRequest, $httpResponse); - } - /** - */ - function testIfNoneMatchCorrectEtagAsGet() { - + public function testIfNoneMatchCorrectEtagAsGet() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-None-Match' => '"abc123"']); @@ -172,14 +148,13 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { $this->assertFalse($server->checkPreconditions($httpRequest, $server->httpResponse)); $this->assertEquals(304, $server->httpResponse->getStatus()); $this->assertEquals(['ETag' => ['"abc123"']], $server->httpResponse->getHeaders()); - } /** * This was a test written for issue #515. */ - function testNoneMatchCorrectEtagEnsureSapiSent() { - + public function testNoneMatchCorrectEtagEnsureSapiSent() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $server->sapi = new HTTP\SapiMock(); @@ -193,22 +168,18 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { $this->assertFalse($server->checkPreconditions($httpRequest, $server->httpResponse)); $this->assertEquals(304, $server->httpResponse->getStatus()); $this->assertEquals([ - 'ETag' => ['"abc123"'], + 'ETag' => ['"abc123"'], 'X-Sabre-Version' => [Version::VERSION], ], $server->httpResponse->getHeaders()); $this->assertEquals(1, HTTP\SapiMock::$sent); - } - /** - */ - function testIfModifiedSinceUnModified() { - + public function testIfModifiedSinceUnModified() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_MODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 GMT', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Modified-Since' => 'Sun, 06 Nov 1994 08:49:37 GMT', ]); $server->httpResponse = new HTTP\ResponseMock(); $this->assertFalse($server->checkPreconditions($httpRequest, $server->httpResponse)); @@ -217,128 +188,96 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ 'Last-Modified' => ['Sat, 06 Apr 1985 23:30:00 GMT'], ], $server->httpResponse->getHeaders()); - } - - /** - */ - function testIfModifiedSinceModified() { - + public function testIfModifiedSinceModified() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_MODIFIED_SINCE' => 'Tue, 06 Nov 1984 08:49:37 GMT', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Modified-Since' => 'Tue, 06 Nov 1984 08:49:37 GMT', ]); $httpResponse = new HTTP\ResponseMock(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - /** - */ - function testIfModifiedSinceInvalidDate() { - + public function testIfModifiedSinceInvalidDate() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_MODIFIED_SINCE' => 'Your mother', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Modified-Since' => 'Your mother', ]); $httpResponse = new HTTP\ResponseMock(); // Invalid dates must be ignored, so this should return true $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - /** - */ - function testIfModifiedSinceInvalidDate2() { - + public function testIfModifiedSinceInvalidDate2() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_MODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 EST', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Unmodified-Since' => 'Sun, 06 Nov 1994 08:49:37 EST', ]); $httpResponse = new HTTP\ResponseMock(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - - /** - */ - function testIfUnmodifiedSinceUnModified() { - + public function testIfUnmodifiedSinceUnModified() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_UNMODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 GMT', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Unmodified-Since' => 'Sun, 06 Nov 1994 08:49:37 GMT', ]); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - /** - * @expectedException Sabre\DAV\Exception\PreconditionFailed + * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ - function testIfUnmodifiedSinceModified() { - + public function testIfUnmodifiedSinceModified() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_UNMODIFIED_SINCE' => 'Tue, 06 Nov 1984 08:49:37 GMT', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Unmodified-Since' => 'Tue, 06 Nov 1984 08:49:37 GMT', ]); $httpResponse = new HTTP\ResponseMock(); $server->checkPreconditions($httpRequest, $httpResponse); - } - /** - */ - function testIfUnmodifiedSinceInvalidDate() { - + public function testIfUnmodifiedSinceInvalidDate() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_UNMODIFIED_SINCE' => 'Sun, 06 Nov 1984 08:49:37 CET', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Unmodified-Since' => 'Sun, 06 Nov 1984 08:49:37 CET', ]); $httpResponse = new HTTP\ResponseMock(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - - } -class ServerPreconditionsNode extends File { - - function getETag() { - +class ServerPreconditionsNode extends File +{ + public function getETag() + { return '"abc123"'; - } - function getLastModified() { - + public function getLastModified() + { /* my birthday & time, I believe */ return strtotime('1985-04-07 01:30 +02:00'); - } - function getName() { - + public function getName() + { return 'foo'; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php index 253200be7..462fba664 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; @@ -7,95 +9,93 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; require_once 'Sabre/DAV/AbstractServer.php'; -class ServerPropsTest extends AbstractServer { - - protected function getRootNode() { - +class ServerPropsTest extends AbstractServer +{ + protected function getRootNode() + { return new FSExt\Directory(SABRE_TEMPDIR); - } - function setUp() { - - if (file_exists(SABRE_TEMPDIR . '../.sabredav')) unlink(SABRE_TEMPDIR . '../.sabredav'); + public function setUp() + { + if (file_exists(SABRE_TEMPDIR.'../.sabredav')) { + unlink(SABRE_TEMPDIR.'../.sabredav'); + } parent::setUp(); - file_put_contents(SABRE_TEMPDIR . '/test2.txt', 'Test contents2'); - mkdir(SABRE_TEMPDIR . '/col'); - file_put_contents(SABRE_TEMPDIR . 'col/test.txt', 'Test contents'); - $this->server->addPlugin(new Locks\Plugin(new Locks\Backend\File(SABRE_TEMPDIR . '/.locksdb'))); - + file_put_contents(SABRE_TEMPDIR.'/test2.txt', 'Test contents2'); + mkdir(SABRE_TEMPDIR.'/col'); + file_put_contents(SABRE_TEMPDIR.'col/test.txt', 'Test contents'); + $this->server->addPlugin(new Locks\Plugin(new Locks\Backend\File(SABRE_TEMPDIR.'/.locksdb'))); } - function tearDown() { - + public function tearDown() + { parent::tearDown(); - if (file_exists(SABRE_TEMPDIR . '../.locksdb')) unlink(SABRE_TEMPDIR . '../.locksdb'); - + if (file_exists(SABRE_TEMPDIR.'../.locksdb')) { + unlink(SABRE_TEMPDIR.'../.locksdb'); + } } - private function sendRequest($body, $path = '/', $headers = ['Depth' => '0']) { - + private function sendRequest($body, $path = '/', $headers = ['Depth' => '0']) + { $request = new HTTP\Request('PROPFIND', $path, $headers, $body); $this->server->httpRequest = $request; $this->server->exec(); - } - function testPropFindEmptyBody() { - - $this->sendRequest(""); + public function testPropFindEmptyBody() + { + $this->sendRequest(''); $this->assertEquals(207, $this->response->status); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'DAV' => ['1, 3, extended-mkcol, 2'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'DAV' => ['1, 3, extended-mkcol, 2'], + 'Vary' => ['Brief,Prefer'], ], $this->response->getHeaders() ); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); list($data) = $xml->xpath('/d:multistatus/d:response/d:href'); - $this->assertEquals('/', (string)$data, 'href element should have been /'); + $this->assertEquals('/', (string) $data, 'href element should have been /'); $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype'); $this->assertEquals(1, count($data)); - } - function testPropFindEmptyBodyFile() { - - $this->sendRequest("", '/test2.txt', []); + public function testPropFindEmptyBodyFile() + { + $this->sendRequest('', '/test2.txt', []); $this->assertEquals(207, $this->response->status); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'DAV' => ['1, 3, extended-mkcol, 2'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'DAV' => ['1, 3, extended-mkcol, 2'], + 'Vary' => ['Brief,Prefer'], ], $this->response->getHeaders() ); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); list($data) = $xml->xpath('/d:multistatus/d:response/d:href'); - $this->assertEquals('/test2.txt', (string)$data, 'href element should have been /test2.txt'); + $this->assertEquals('/test2.txt', (string) $data, 'href element should have been /test2.txt'); $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength'); $this->assertEquals(1, count($data)); - } - function testSupportedLocks() { - + public function testSupportedLocks() + { $xml = '<?xml version="1.0"?> <d:propfind xmlns:d="DAV:"> <d:prop> @@ -105,7 +105,7 @@ class ServerPropsTest extends AbstractServer { $this->sendRequest($xml); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); @@ -128,8 +128,8 @@ class ServerPropsTest extends AbstractServer { $this->assertEquals(2, count($data), 'We expected two \'d:write\' tags'); } - function testLockDiscovery() { - + public function testLockDiscovery() + { $xml = '<?xml version="1.0"?> <d:propfind xmlns:d="DAV:"> <d:prop> @@ -139,17 +139,16 @@ class ServerPropsTest extends AbstractServer { $this->sendRequest($xml); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:lockdiscovery'); $this->assertEquals(1, count($data), 'We expected a \'d:lockdiscovery\' tag'); - } - function testUnknownProperty() { - + public function testUnknownProperty() + { $xml = '<?xml version="1.0"?> <d:propfind xmlns:d="DAV:"> <d:prop> @@ -158,7 +157,7 @@ class ServerPropsTest extends AbstractServer { </d:propfind>'; $this->sendRequest($xml); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); $pathTests = [ @@ -170,17 +169,16 @@ class ServerPropsTest extends AbstractServer { '/d:multistatus/d:response/d:propstat/d:prop/d:macaroni', ]; foreach ($pathTests as $test) { - $this->assertTrue(count($xml->xpath($test)) == true, 'We expected the ' . $test . ' element to appear in the response, we got: ' . $body); + $this->assertTrue(true == count($xml->xpath($test)), 'We expected the '.$test.' element to appear in the response, we got: '.$body); } $val = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status'); $this->assertEquals(1, count($val), $body); - $this->assertEquals('HTTP/1.1 404 Not Found', (string)$val[0]); - + $this->assertEquals('HTTP/1.1 404 Not Found', (string) $val[0]); } - function testParsePropPatchRequest() { - + public function testParsePropPatchRequest() + { $body = '<?xml version="1.0"?> <d:propertyupdate xmlns:d="DAV:" xmlns:s="http://sabredav.org/NS/test"> <d:set><d:prop><s:someprop>somevalue</s:someprop></d:prop></d:set> @@ -191,11 +189,9 @@ class ServerPropsTest extends AbstractServer { $result = $this->server->xml->parse($body); $this->assertEquals([ - '{http://sabredav.org/NS/test}someprop' => 'somevalue', + '{http://sabredav.org/NS/test}someprop' => 'somevalue', '{http://sabredav.org/NS/test}someprop2' => null, '{http://sabredav.org/NS/test}someprop3' => null, ], $result->properties); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php index 81224d687..93ea083d8 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use DateTime; @@ -12,22 +14,22 @@ use Sabre\HTTP; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ServerRangeTest extends \Sabre\DAVServerTest { - +class ServerRangeTest extends \Sabre\DAVServerTest +{ protected $setupFiles = true; /** - * We need this string a lot + * We need this string a lot. */ protected $lastModified; - function setUp() { - + public function setUp() + { parent::setUp(); $this->server->createFile('files/test.txt', 'Test contents'); - $this->lastModified = HTTP\Util::toHTTPDate( - new DateTime('@' . $this->server->tree->getNodeForPath('files/test.txt')->getLastModified()) + $this->lastModified = HTTP\toDate( + new DateTime('@'.$this->server->tree->getNodeForPath('files/test.txt')->getLastModified()) ); $stream = popen('echo "Test contents"', 'r'); @@ -37,112 +39,106 @@ class ServerRangeTest extends \Sabre\DAVServerTest { ); $streamingFile->setSize(12); $this->server->tree->getNodeForPath('files')->addNode($streamingFile); - } - function testRange() { - + public function testRange() + { $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=2-5']); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [4], - 'Content-Range' => ['bytes 2-5/13'], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [4], + 'Content-Range' => ['bytes 2-5/13'], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(206, $response->getStatus()); $this->assertEquals('st c', $response->getBodyAsString()); - } /** * @depends testRange */ - function testStartRange() { - + public function testStartRange() + { $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=2-']); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [11], - 'Content-Range' => ['bytes 2-12/13'], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [11], + 'Content-Range' => ['bytes 2-12/13'], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(206, $response->getStatus()); $this->assertEquals('st contents', $response->getBodyAsString()); - } /** * @depends testRange */ - function testEndRange() { - + public function testEndRange() + { $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=-8']); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [8], - 'Content-Range' => ['bytes 5-12/13'], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [8], + 'Content-Range' => ['bytes 5-12/13'], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(206, $response->getStatus()); $this->assertEquals('contents', $response->getBodyAsString()); - } /** * @depends testRange */ - function testTooHighRange() { - + public function testTooHighRange() + { $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=100-200']); $response = $this->request($request); $this->assertEquals(416, $response->getStatus()); - } /** * @depends testRange */ - function testCrazyRange() { - + public function testCrazyRange() + { $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=8-4']); $response = $this->request($request); $this->assertEquals(416, $response->getStatus()); - } - function testNonSeekableStream() { - + public function testNonSeekableStream() + { $request = new HTTP\Request('GET', '/files/no-seeking.txt', ['Range' => 'bytes=2-5']); $response = $this->request($request); $this->assertEquals(206, $response->getStatus(), $response); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [4], - 'Content-Range' => ['bytes 2-5/12'], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [4], + 'Content-Range' => ['bytes 2-5/12'], // 'ETag' => ['"' . md5('Test contents') . '"'], 'Last-Modified' => [$this->lastModified], ], @@ -150,113 +146,107 @@ class ServerRangeTest extends \Sabre\DAVServerTest { ); $this->assertEquals('st c', $response->getBodyAsString()); - } /** * @depends testRange */ - function testIfRangeEtag() { - + public function testIfRangeEtag() + { $request = new HTTP\Request('GET', '/files/test.txt', [ - 'Range' => 'bytes=2-5', - 'If-Range' => '"' . md5('Test contents') . '"', + 'Range' => 'bytes=2-5', + 'If-Range' => '"'.md5('Test contents').'"', ]); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [4], - 'Content-Range' => ['bytes 2-5/13'], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [4], + 'Content-Range' => ['bytes 2-5/13'], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(206, $response->getStatus()); $this->assertEquals('st c', $response->getBodyAsString()); - } /** * @depends testIfRangeEtag */ - function testIfRangeEtagIncorrect() { - + public function testIfRangeEtagIncorrect() + { $request = new HTTP\Request('GET', '/files/test.txt', [ - 'Range' => 'bytes=2-5', + 'Range' => 'bytes=2-5', 'If-Range' => '"foobar"', ]); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [13], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [13], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(200, $response->getStatus()); $this->assertEquals('Test contents', $response->getBodyAsString()); - } /** * @depends testIfRangeEtag */ - function testIfRangeModificationDate() { - + public function testIfRangeModificationDate() + { $request = new HTTP\Request('GET', '/files/test.txt', [ - 'Range' => 'bytes=2-5', + 'Range' => 'bytes=2-5', 'If-Range' => 'tomorrow', ]); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [4], - 'Content-Range' => ['bytes 2-5/13'], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [4], + 'Content-Range' => ['bytes 2-5/13'], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(206, $response->getStatus()); $this->assertEquals('st c', $response->getBodyAsString()); - } /** * @depends testIfRangeModificationDate */ - function testIfRangeModificationDateModified() { - + public function testIfRangeModificationDateModified() + { $request = new HTTP\Request('GET', '/files/test.txt', [ - 'Range' => 'bytes=2-5', + 'Range' => 'bytes=2-5', 'If-Range' => '-2 years', ]); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [13], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [13], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(200, $response->getStatus()); $this->assertEquals('Test contents', $response->getBodyAsString()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php index 043179a00..53153151b 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php @@ -1,90 +1,74 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; -class ServerSimpleTest extends AbstractServer{ - - function testConstructArray() { - - $nodes = [ - new SimpleCollection('hello') - ]; - - $server = new Server($nodes); - $this->assertEquals($nodes[0], $server->tree->getNodeForPath('hello')); - - } - - /** - * @expectedException Sabre\DAV\Exception - */ - function testConstructIncorrectObj() { - +class ServerSimpleTest extends AbstractServer +{ + public function testConstructArray() + { $nodes = [ new SimpleCollection('hello'), - new \STDClass(), ]; $server = new Server($nodes); - + $this->assertEquals($nodes[0], $server->tree->getNodeForPath('hello')); } /** - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testConstructInvalidArg() { - + public function testConstructInvalidArg() + { $server = new Server(1); - } - function testOptions() { - + public function testOptions() + { $request = new HTTP\Request('OPTIONS', '/'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals([ - 'DAV' => ['1, 3, extended-mkcol'], - 'MS-Author-Via' => ['DAV'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], - 'Accept-Ranges' => ['bytes'], - 'Content-Length' => ['0'], + 'DAV' => ['1, 3, extended-mkcol'], + 'MS-Author-Via' => ['DAV'], + 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], + 'Accept-Ranges' => ['bytes'], + 'Content-Length' => ['0'], 'X-Sabre-Version' => [Version::VERSION], ], $this->response->getHeaders()); $this->assertEquals(200, $this->response->status); $this->assertEquals('', $this->response->body); - } - function testOptionsUnmapped() { - + public function testOptionsUnmapped() + { $request = new HTTP\Request('OPTIONS', '/unmapped'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals([ - 'DAV' => ['1, 3, extended-mkcol'], - 'MS-Author-Via' => ['DAV'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, MKCOL'], - 'Accept-Ranges' => ['bytes'], - 'Content-Length' => ['0'], + 'DAV' => ['1, 3, extended-mkcol'], + 'MS-Author-Via' => ['DAV'], + 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, MKCOL'], + 'Accept-Ranges' => ['bytes'], + 'Content-Length' => ['0'], 'X-Sabre-Version' => [Version::VERSION], ], $this->response->getHeaders()); $this->assertEquals(200, $this->response->status); $this->assertEquals('', $this->response->body); - } - function testNonExistantMethod() { - + public function testNonExistantMethod() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'BLABLA', ]; @@ -94,21 +78,19 @@ class ServerSimpleTest extends AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); $this->assertEquals(501, $this->response->status); - - } - function testBaseUri() { - + public function testBaseUri() + { $serverVars = [ - 'REQUEST_URI' => '/blabla/test.txt', + 'REQUEST_URI' => '/blabla/test.txt', 'REQUEST_METHOD' => 'GET', ]; - $filename = $this->tempDir . '/test.txt'; + $filename = $this->tempDir.'/test.txt'; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->setBaseUri('/blabla/'); @@ -118,26 +100,25 @@ class ServerSimpleTest extends AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [13], - 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($filename)))], - 'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [13], + 'Last-Modified' => [HTTP\toDate(new \DateTime('@'.filemtime($filename)))], + 'ETag' => ['"'.sha1(fileinode($filename).filesize($filename).filemtime($filename)).'"'], ], $this->response->getHeaders() ); $this->assertEquals(200, $this->response->status); $this->assertEquals('Test contents', stream_get_contents($this->response->body)); - } - function testBaseUriAddSlash() { - + public function testBaseUriAddSlash() + { $tests = [ - '/' => '/', - '/foo' => '/foo/', - '/foo/' => '/foo/', - '/foo/bar' => '/foo/bar/', + '/' => '/', + '/foo' => '/foo/', + '/foo/' => '/foo/', + '/foo/bar' => '/foo/bar/', '/foo/bar/' => '/foo/bar/', ]; @@ -145,92 +126,86 @@ class ServerSimpleTest extends AbstractServer{ $this->server->setBaseUri($test); $this->assertEquals($result, $this->server->getBaseUri()); - } - } - function testCalculateUri() { - + public function testCalculateUri() + { $uris = [ 'http://www.example.org/root/somepath', '/root/somepath', '/root/somepath/', + '//root/somepath/', + '///root///somepath///', ]; $this->server->setBaseUri('/root/'); foreach ($uris as $uri) { - $this->assertEquals('somepath', $this->server->calculateUri($uri)); - } $this->server->setBaseUri('/root'); foreach ($uris as $uri) { - $this->assertEquals('somepath', $this->server->calculateUri($uri)); - } $this->assertEquals('', $this->server->calculateUri('/root')); - } + $this->server->setBaseUri('/'); + + foreach ($uris as $uri) { + $this->assertEquals('root/somepath', $this->server->calculateUri($uri)); + } - function testCalculateUriSpecialChars() { + $this->assertEquals('', $this->server->calculateUri('')); + } + public function testCalculateUriSpecialChars() + { $uris = [ 'http://www.example.org/root/%C3%A0fo%C3%B3', '/root/%C3%A0fo%C3%B3', - '/root/%C3%A0fo%C3%B3/' + '/root/%C3%A0fo%C3%B3/', ]; $this->server->setBaseUri('/root/'); foreach ($uris as $uri) { - $this->assertEquals("\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri)); - } $this->server->setBaseUri('/root'); foreach ($uris as $uri) { - $this->assertEquals("\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri)); - } $this->server->setBaseUri('/'); foreach ($uris as $uri) { - $this->assertEquals("root/\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri)); - } - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testCalculateUriBreakout() { - + public function testCalculateUriBreakout() + { $uri = '/path1/'; $this->server->setBaseUri('/path2/'); $this->server->calculateUri($uri); - } - /** - */ - function testGuessBaseUri() { - + public function testGuessBaseUri() + { $serverVars = [ + 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php/root', - 'PATH_INFO' => '/root', + 'PATH_INFO' => '/root', ]; $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); @@ -238,17 +213,17 @@ class ServerSimpleTest extends AbstractServer{ $server->httpRequest = $httpRequest; $this->assertEquals('/index.php/', $server->guessBaseUri()); - } /** * @depends testGuessBaseUri */ - function testGuessBaseUriPercentEncoding() { - + public function testGuessBaseUriPercentEncoding() + { $serverVars = [ + 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php/dir/path2/path%20with%20spaces', - 'PATH_INFO' => '/dir/path2/path with spaces', + 'PATH_INFO' => '/dir/path2/path with spaces', ]; $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); @@ -256,7 +231,6 @@ class ServerSimpleTest extends AbstractServer{ $server->httpRequest = $httpRequest; $this->assertEquals('/index.php/', $server->guessBaseUri()); - } /** @@ -279,11 +253,12 @@ class ServerSimpleTest extends AbstractServer{ }*/ - function testGuessBaseUri2() { - + public function testGuessBaseUri2() + { $serverVars = [ + 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php/root/', - 'PATH_INFO' => '/root/', + 'PATH_INFO' => '/root/', ]; $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); @@ -291,12 +266,12 @@ class ServerSimpleTest extends AbstractServer{ $server->httpRequest = $httpRequest; $this->assertEquals('/index.php/', $server->guessBaseUri()); - } - function testGuessBaseUriNoPathInfo() { - + public function testGuessBaseUriNoPathInfo() + { $serverVars = [ + 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php/root', ]; @@ -305,32 +280,26 @@ class ServerSimpleTest extends AbstractServer{ $server->httpRequest = $httpRequest; $this->assertEquals('/', $server->guessBaseUri()); - } - function testGuessBaseUriNoPathInfo2() { - - $serverVars = [ - 'REQUEST_URI' => '/a/b/c/test.php', - ]; - - $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); + public function testGuessBaseUriNoPathInfo2() + { + $httpRequest = new HTTP\Request('GET', '/a/b/c/test.php'); $server = new Server(); $server->httpRequest = $httpRequest; $this->assertEquals('/', $server->guessBaseUri()); - } - /** * @depends testGuessBaseUri */ - function testGuessBaseUriQueryString() { - + public function testGuessBaseUriQueryString() + { $serverVars = [ + 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php/root?query_string=blabla', - 'PATH_INFO' => '/root', + 'PATH_INFO' => '/root', ]; $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); @@ -338,18 +307,18 @@ class ServerSimpleTest extends AbstractServer{ $server->httpRequest = $httpRequest; $this->assertEquals('/index.php/', $server->guessBaseUri()); - } /** * @depends testGuessBaseUri * @expectedException \Sabre\DAV\Exception */ - function testGuessBaseUriBadConfig() { - + public function testGuessBaseUriBadConfig() + { $serverVars = [ + 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php/root/heyyy', - 'PATH_INFO' => '/root', + 'PATH_INFO' => '/root', ]; $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); @@ -357,19 +326,18 @@ class ServerSimpleTest extends AbstractServer{ $server->httpRequest = $httpRequest; $server->guessBaseUri(); - } - function testTriggerException() { - + public function testTriggerException() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'FOO', ]; $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $httpRequest; - $this->server->on('beforeMethod', [$this, 'exceptionTrigger']); + $this->server->on('beforeMethod:*', [$this, 'exceptionTrigger']); $this->server->exec(); $this->assertEquals([ @@ -377,19 +345,17 @@ class ServerSimpleTest extends AbstractServer{ ], $this->response->getHeaders()); $this->assertEquals(500, $this->response->status); - } - function exceptionTrigger($request, $response) { - + public function exceptionTrigger($request, $response) + { throw new Exception('Hola'); - } - function testReportNotFound() { - + public function testReportNotFound() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'REPORT', ]; @@ -400,19 +366,18 @@ class ServerSimpleTest extends AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders() ); - $this->assertEquals(415, $this->response->status, 'We got an incorrect status back. Full response body follows: ' . $this->response->body); - + $this->assertEquals(415, $this->response->status, 'We got an incorrect status back. Full response body follows: '.$this->response->body); } - function testReportIntercepted() { - + public function testReportIntercepted() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'REPORT', ]; @@ -424,52 +389,49 @@ class ServerSimpleTest extends AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'testheader' => ['testvalue'], + 'testheader' => ['testvalue'], ], $this->response->getHeaders() ); - $this->assertEquals(418, $this->response->status, 'We got an incorrect status back. Full response body follows: ' . $this->response->body); - + $this->assertEquals(418, $this->response->status, 'We got an incorrect status back. Full response body follows: '.$this->response->body); } - function reportHandler($reportName, $result, $path) { - - if ($reportName == '{http://www.rooftopsolutions.nl/NS}myreport') { + public function reportHandler($reportName, $result, $path) + { + if ('{http://www.rooftopsolutions.nl/NS}myreport' == $reportName) { $this->server->httpResponse->setStatus(418); $this->server->httpResponse->setHeader('testheader', 'testvalue'); + return false; + } else { + return; } - else return; - } - function testGetPropertiesForChildren() { - + public function testGetPropertiesForChildren() + { $result = $this->server->getPropertiesForChildren('', [ '{DAV:}getcontentlength', ]); $expected = [ 'test.txt' => ['{DAV:}getcontentlength' => 13], - 'dir/' => [], + 'dir/' => [], ]; $this->assertEquals($expected, $result); - } /** * There are certain cases where no HTTP status may be set. We need to * intercept these and set it to a default error message. */ - function testNoHTTPStatusSet() { - - $this->server->on('method:GET', function() { return false; }, 1); + public function testNoHTTPStatusSet() + { + $this->server->on('method:GET', function () { return false; }, 1); $this->server->httpRequest = new HTTP\Request('GET', '/'); $this->server->exec(); $this->assertEquals(500, $this->response->getStatus()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php index 383f8e657..cb8a4ab32 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php @@ -1,102 +1,97 @@ <?php -namespace Sabre\DAV; - -class ServerUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testUpdatePropertiesFail() { +namespace Sabre\DAV; +class ServerUpdatePropertiesTest extends \PHPUnit\Framework\TestCase +{ + public function testUpdatePropertiesFail() + { $tree = [ new SimpleCollection('foo'), ]; $server = new Server($tree); $result = $server->updateProperties('foo', [ - '{DAV:}foo' => 'bar' + '{DAV:}foo' => 'bar', ]); $expected = [ '{DAV:}foo' => 403, ]; $this->assertEquals($expected, $result); - } - function testUpdatePropertiesProtected() { - + public function testUpdatePropertiesProtected() + { $tree = [ new SimpleCollection('foo'), ]; $server = new Server($tree); - $server->on('propPatch', function($path, PropPatch $propPatch) { - $propPatch->handleRemaining(function() { return true; }); + $server->on('propPatch', function ($path, PropPatch $propPatch) { + $propPatch->handleRemaining(function () { return true; }); }); $result = $server->updateProperties('foo', [ '{DAV:}getetag' => 'bla', - '{DAV:}foo' => 'bar' + '{DAV:}foo' => 'bar', ]); $expected = [ '{DAV:}getetag' => 403, - '{DAV:}foo' => 424, + '{DAV:}foo' => 424, ]; $this->assertEquals($expected, $result); - } - function testUpdatePropertiesEventFail() { - + public function testUpdatePropertiesEventFail() + { $tree = [ new SimpleCollection('foo'), ]; $server = new Server($tree); - $server->on('propPatch', function($path, PropPatch $propPatch) { + $server->on('propPatch', function ($path, PropPatch $propPatch) { $propPatch->setResultCode('{DAV:}foo', 404); - $propPatch->handleRemaining(function() { return true; }); + $propPatch->handleRemaining(function () { return true; }); }); $result = $server->updateProperties('foo', [ - '{DAV:}foo' => 'bar', + '{DAV:}foo' => 'bar', '{DAV:}foo2' => 'bla', ]); $expected = [ - '{DAV:}foo' => 404, + '{DAV:}foo' => 404, '{DAV:}foo2' => 424, ]; $this->assertEquals($expected, $result); - } - function testUpdatePropertiesEventSuccess() { - + public function testUpdatePropertiesEventSuccess() + { $tree = [ new SimpleCollection('foo'), ]; $server = new Server($tree); - $server->on('propPatch', function($path, PropPatch $propPatch) { - - $propPatch->handle(['{DAV:}foo', '{DAV:}foo2'], function() { + $server->on('propPatch', function ($path, PropPatch $propPatch) { + $propPatch->handle(['{DAV:}foo', '{DAV:}foo2'], function () { return [ - '{DAV:}foo' => 200, + '{DAV:}foo' => 200, '{DAV:}foo2' => 201, ]; }); - }); $result = $server->updateProperties('foo', [ - '{DAV:}foo' => 'bar', + '{DAV:}foo' => 'bar', '{DAV:}foo2' => 'bla', ]); $expected = [ - '{DAV:}foo' => 200, + '{DAV:}foo' => 200, '{DAV:}foo2' => 201, ]; $this->assertEquals($expected, $result); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php index 15ccfaf9e..6edca5ecc 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php @@ -1,19 +1,19 @@ <?php -namespace Sabre\DAV; - -class SimpleFileTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testAll() { +namespace Sabre\DAV; +class SimpleFileTest extends \PHPUnit\Framework\TestCase +{ + public function testAll() + { $file = new SimpleFile('filename.txt', 'contents', 'text/plain'); $this->assertEquals('filename.txt', $file->getName()); $this->assertEquals('contents', $file->get()); $this->assertEquals(8, $file->getSize()); - $this->assertEquals('"' . sha1('contents') . '"', $file->getETag()); + $this->assertEquals('"'.sha1('contents').'"', $file->getETag()); $this->assertEquals('text/plain', $file->getContentType()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php b/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php index e98fe9048..1e4b92197 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php @@ -1,27 +1,29 @@ <?php -namespace Sabre\DAV; +declare(strict_types=1); -class StringUtilTest extends \PHPUnit_Framework_TestCase { +namespace Sabre\DAV; +class StringUtilTest extends \PHPUnit\Framework\TestCase +{ /** * @param string $haystack * @param string $needle * @param string $collation * @param string $matchType * @param string $result + * * @throws Exception\BadRequest * * @dataProvider dataset */ - function testTextMatch($haystack, $needle, $collation, $matchType, $result) { - + public function testTextMatch($haystack, $needle, $collation, $matchType, $result) + { $this->assertEquals($result, StringUtil::textMatch($haystack, $needle, $collation, $matchType)); - } - function dataset() { - + public function dataset() + { return [ ['FOOBAR', 'FOO', 'i;octet', 'contains', true], ['FOOBAR', 'foo', 'i;octet', 'contains', false], @@ -68,62 +70,54 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase { ['FOOBAR', 'BAR', 'i;unicode-casemap', 'ends-with', true], ['FOOBAR', 'bar', 'i;unicode-casemap', 'ends-with', true], ]; - } /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ - function testBadCollation() { - + public function testBadCollation() + { StringUtil::textMatch('foobar', 'foo', 'blabla', 'contains'); - } - /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ - function testBadMatchType() { - + public function testBadMatchType() + { StringUtil::textMatch('foobar', 'foo', 'i;octet', 'booh'); - } - function testEnsureUTF8_ascii() { - - $inputString = "harkema"; - $outputString = "harkema"; + public function testEnsureUTF8_ascii() + { + $inputString = 'harkema'; + $outputString = 'harkema'; $this->assertEquals( $outputString, StringUtil::ensureUTF8($inputString) ); - } - function testEnsureUTF8_latin1() { - + public function testEnsureUTF8_latin1() + { $inputString = "m\xfcnster"; - $outputString = "münster"; + $outputString = 'münster'; $this->assertEquals( $outputString, StringUtil::ensureUTF8($inputString) ); - } - function testEnsureUTF8_utf8() { - + public function testEnsureUTF8_utf8() + { $inputString = "m\xc3\xbcnster"; - $outputString = "münster"; + $outputString = 'münster'; $this->assertEquals( $outputString, StringUtil::ensureUTF8($inputString) ); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php index 6acd6b077..352c8a3e7 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php @@ -1,21 +1,22 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; -class TemporaryFileFilterTest extends AbstractServer { - - function setUp() { - +class TemporaryFileFilterTest extends AbstractServer +{ + public function setUp() + { parent::setUp(); - $plugin = new TemporaryFileFilterPlugin(SABRE_TEMPDIR . '/tff'); + $plugin = new TemporaryFileFilterPlugin(SABRE_TEMPDIR.'/tff'); $this->server->addPlugin($plugin); - } - function testPutNormal() { - + public function testPutNormal() + { $request = new HTTP\Request('PUT', '/testput.txt', [], 'Testing new file'); $this->server->httpRequest = ($request); @@ -25,12 +26,11 @@ class TemporaryFileFilterTest extends AbstractServer { $this->assertEquals(201, $this->response->status); $this->assertEquals('0', $this->response->getHeader('Content-Length')); - $this->assertEquals('Testing new file', file_get_contents(SABRE_TEMPDIR . '/testput.txt')); - + $this->assertEquals('Testing new file', file_get_contents(SABRE_TEMPDIR.'/testput.txt')); } - function testPutTemp() { - + public function testPutTemp() + { // mimicking an OS/X resource fork $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file'); @@ -43,12 +43,11 @@ class TemporaryFileFilterTest extends AbstractServer { 'X-Sabre-Temp' => ['true'], ], $this->response->getHeaders()); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'), '._testput.txt should not exist in the regular file structure.'); - + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/._testput.txt'), '._testput.txt should not exist in the regular file structure.'); } - function testPutTempIfNoneMatch() { - + public function testPutTempIfNoneMatch() + { // mimicking an OS/X resource fork $request = new HTTP\Request('PUT', '/._testput.txt', ['If-None-Match' => '*'], 'Testing new file'); @@ -61,8 +60,7 @@ class TemporaryFileFilterTest extends AbstractServer { 'X-Sabre-Temp' => ['true'], ], $this->response->getHeaders()); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'), '._testput.txt should not exist in the regular file structure.'); - + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/._testput.txt'), '._testput.txt should not exist in the regular file structure.'); $this->server->exec(); @@ -71,11 +69,10 @@ class TemporaryFileFilterTest extends AbstractServer { 'X-Sabre-Temp' => ['true'], 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); - } - function testPutGet() { - + public function testPutGet() + { // mimicking an OS/X resource fork $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file'); $this->server->httpRequest = ($request); @@ -94,19 +91,29 @@ class TemporaryFileFilterTest extends AbstractServer { $this->assertEquals(200, $this->response->status); $this->assertEquals([ - 'X-Sabre-Temp' => ['true'], + 'X-Sabre-Temp' => ['true'], 'Content-Length' => [16], - 'Content-Type' => ['application/octet-stream'], + 'Content-Type' => ['application/octet-stream'], ], $this->response->getHeaders()); $this->assertEquals('Testing new file', stream_get_contents($this->response->body)); - } - function testLockNonExistant() { + public function testGetWithBrowserPlugin() + { + $this->server->addPlugin(new Browser\Plugin()); + $request = new HTTP\Request('GET', '/'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals(200, $this->response->status); + } - mkdir(SABRE_TEMPDIR . '/locksdir'); - $locksBackend = new Locks\Backend\File(SABRE_TEMPDIR . '/locks'); + public function testLockNonExistant() + { + mkdir(SABRE_TEMPDIR.'/locksdir'); + $locksBackend = new Locks\Backend\File(SABRE_TEMPDIR.'/locks'); $locksPlugin = new Locks\Plugin($locksBackend); $this->server->addPlugin($locksPlugin); @@ -126,15 +133,14 @@ class TemporaryFileFilterTest extends AbstractServer { $this->assertEquals(201, $this->response->status); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals('true', $this->response->getHeader('X-Sabre-Temp')); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testlock.txt'), '._testlock.txt should not exist in the regular file structure.'); - + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/._testlock.txt'), '._testlock.txt should not exist in the regular file structure.'); } - function testPutDelete() { - + public function testPutDelete() + { // mimicking an OS/X resource fork $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file'); @@ -151,17 +157,16 @@ class TemporaryFileFilterTest extends AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(204, $this->response->status, "Incorrect status code received. Full body:\n" . $this->response->body); + $this->assertEquals(204, $this->response->status, "Incorrect status code received. Full body:\n".$this->response->body); $this->assertEquals([ 'X-Sabre-Temp' => ['true'], ], $this->response->getHeaders()); $this->assertEquals('', $this->response->body); - } - function testPutPropfind() { - + public function testPutPropfind() + { // mimicking an OS/X resource fork $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file'); $this->server->httpRequest = $request; @@ -178,22 +183,20 @@ class TemporaryFileFilterTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Incorrect status code returned. Body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Incorrect status code returned. Body: '.$this->response->body); $this->assertEquals([ 'X-Sabre-Temp' => ['true'], 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); list($data) = $xml->xpath('/d:multistatus/d:response/d:href'); - $this->assertEquals('/._testput.txt', (string)$data, 'href element should have been /._testput.txt'); + $this->assertEquals('/._testput.txt', (string) $data, 'href element should have been /._testput.txt'); $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype'); $this->assertEquals(1, count($data)); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php b/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php index 619ac03fd..3bfe3b3b0 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php @@ -1,37 +1,35 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -class TestPlugin extends ServerPlugin { - +class TestPlugin extends ServerPlugin +{ public $beforeMethod; - function getFeatures() { - + public function getFeatures() + { return ['drinking']; - } - function getHTTPMethods($uri) { - - return ['BEER','WINE']; - + public function getHTTPMethods($uri) + { + return ['BEER', 'WINE']; } - function initialize(Server $server) { - - $server->on('beforeMethod', [$this, 'beforeMethod']); - + public function initialize(Server $server) + { + $server->on('beforeMethod:*', [$this, 'beforeMethod']); } - function beforeMethod(RequestInterface $request, ResponseInterface $response) { - + public function beforeMethod(RequestInterface $request, ResponseInterface $response) + { $this->beforeMethod = $request->getMethod(); - return true; + return true; } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php index c70d17a22..51ff5ccde 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php @@ -1,110 +1,104 @@ <?php -namespace Sabre\DAV; - -class TreeTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testNodeExists() { +namespace Sabre\DAV; +class TreeTest extends \PHPUnit\Framework\TestCase +{ + public function testNodeExists() + { $tree = new TreeMock(); $this->assertTrue($tree->nodeExists('hi')); $this->assertFalse($tree->nodeExists('hello')); - } - function testCopy() { - + public function testCopy() + { $tree = new TreeMock(); $tree->copy('hi', 'hi2'); $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); $this->assertEquals('foobar', $tree->getNodeForPath('hi/file')->get()); $this->assertEquals(['test1' => 'value'], $tree->getNodeForPath('hi/file')->getProperties([])); - } - function testCopyFile() { - + public function testCopyFile() + { $tree = new TreeMock(); $tree->copy('hi/file', 'hi/newfile'); $this->assertArrayHasKey('newfile', $tree->getNodeForPath('hi')->newFiles); } - function testCopyFile0() { - + public function testCopyFile0() + { $tree = new TreeMock(); $tree->copy('hi/file', 'hi/0'); $this->assertArrayHasKey('0', $tree->getNodeForPath('hi')->newFiles); } - function testMove() { - + public function testMove() + { $tree = new TreeMock(); $tree->move('hi', 'hi2'); $this->assertEquals('hi2', $tree->getNodeForPath('hi')->getName()); $this->assertTrue($tree->getNodeForPath('hi')->isRenamed); - } - function testDeepMove() { - + public function testDeepMove() + { $tree = new TreeMock(); $tree->move('hi/sub', 'hi2'); $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); $this->assertTrue($tree->getNodeForPath('hi/sub')->isDeleted); - } - function testDelete() { - + public function testDelete() + { $tree = new TreeMock(); $tree->delete('hi'); $this->assertTrue($tree->getNodeForPath('hi')->isDeleted); - } - function testGetChildren() { - + public function testGetChildren() + { $tree = new TreeMock(); $children = $tree->getChildren(''); - $this->assertEquals(2, count($children)); - $this->assertEquals('hi', $children[0]->getName()); - + $firstChild = $children->current(); + $this->assertEquals('hi', $firstChild->getName()); } - function testGetMultipleNodes() { - + public function testGetMultipleNodes() + { $tree = new TreeMock(); $result = $tree->getMultipleNodes(['hi/sub', 'hi/file']); $this->assertArrayHasKey('hi/sub', $result); $this->assertArrayHasKey('hi/file', $result); - $this->assertEquals('sub', $result['hi/sub']->getName()); + $this->assertEquals('sub', $result['hi/sub']->getName()); $this->assertEquals('file', $result['hi/file']->getName()); - } - function testGetMultipleNodes2() { + public function testGetMultipleNodes2() + { $tree = new TreeMock(); $result = $tree->getMultipleNodes(['multi/1', 'multi/2']); $this->assertArrayHasKey('multi/1', $result); $this->assertArrayHasKey('multi/2', $result); - } - } -class TreeMock extends Tree { - +class TreeMock extends Tree +{ private $nodes = []; - function __construct() { - + public function __construct() + { $file = new TreeFileTester('file'); $file->properties = ['test1' => 'value']; $file->data = 'foobar'; @@ -119,92 +113,86 @@ class TreeMock extends Tree { new TreeFileTester('1'), new TreeFileTester('2'), new TreeFileTester('3'), - ]) + ]), ]) ); - } - } -class TreeDirectoryTester extends SimpleCollection { - +class TreeDirectoryTester extends SimpleCollection +{ public $newDirectories = []; public $newFiles = []; public $isDeleted = false; public $isRenamed = false; - function createDirectory($name) { - + public function createDirectory($name) + { $this->newDirectories[$name] = true; - } - function createFile($name, $data = null) { - + public function createFile($name, $data = null) + { $this->newFiles[$name] = $data; - } - function getChild($name) { + public function getChild($name) + { + if (isset($this->newDirectories[$name])) { + return new self($name); + } + if (isset($this->newFiles[$name])) { + return new TreeFileTester($name, $this->newFiles[$name]); + } - if (isset($this->newDirectories[$name])) return new self($name); - if (isset($this->newFiles[$name])) return new TreeFileTester($name, $this->newFiles[$name]); return parent::getChild($name); - } - function childExists($name) { - - return !!$this->getChild($name); - + public function childExists($name) + { + return (bool) $this->getChild($name); } - function delete() { - + public function delete() + { $this->isDeleted = true; - } - function setName($name) { - + public function setName($name) + { $this->isRenamed = true; $this->name = $name; - } - } -class TreeFileTester extends File implements IProperties { - +class TreeFileTester extends File implements IProperties +{ public $name; public $data; public $properties; - function __construct($name, $data = null) { - + public function __construct($name, $data = null) + { $this->name = $name; - if (is_null($data)) $data = 'bla'; + if (is_null($data)) { + $data = 'bla'; + } $this->data = $data; - } - function getName() { - + public function getName() + { return $this->name; - } - function get() { - + public function get() + { return $this->data; - } - function getProperties($properties) { - + public function getProperties($properties) + { return $this->properties; - } /** @@ -217,19 +205,16 @@ class TreeFileTester extends File implements IProperties { * Read the PropPatch documentation for more information. * * @param PropPatch $propPatch - * @return void */ - function propPatch(PropPatch $propPatch) { - + public function propPatch(PropPatch $propPatch) + { $this->properties = $propPatch->getMutations(); $propPatch->setRemainingResultCode(200); - } - } -class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet { - +class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet +{ /** * This method receives a list of paths in it's first argument. * It must return an array with Node objects. @@ -237,10 +222,11 @@ class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet { * If any children are not found, you do not have to return them. * * @param array $paths + * * @return array */ - function getMultipleChildren(array $paths) { - + public function getMultipleChildren(array $paths) + { $result = []; foreach ($paths as $path) { try { @@ -252,7 +238,5 @@ class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet { } return $result; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php b/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php index f005ecc75..d7ef9bec9 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php @@ -1,11 +1,13 @@ <?php -namespace Sabre\DAV; - -class UUIDUtilTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testValidateUUID() { +namespace Sabre\DAV; +class UUIDUtilTest extends \PHPUnit\Framework\TestCase +{ + public function testValidateUUID() + { $this->assertTrue( UUIDUtil::validateUUID('11111111-2222-3333-4444-555555555555') ); @@ -18,8 +20,5 @@ class UUIDUtilTest extends \PHPUnit_Framework_TestCase { $this->assertFalse( UUIDUtil::validateUUID('fffffffg-2222-3333-4444-555555555555') ); - - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php index 7d7a54d06..3627991bf 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php @@ -1,38 +1,39 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; use Sabre\HTTP; -class ACLMethodTest extends \PHPUnit_Framework_TestCase { - +class ACLMethodTest extends \PHPUnit\Framework\TestCase +{ /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ - function testCallback() { - + public function testCallback() + { $acl = new Plugin(); $server = new DAV\Server(); $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpAcl($server->httpRequest, $server->httpResponse); - } /** /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ - function testNotSupportedByNode() { - + public function testNotSupportedByNode() + { $tree = [ new DAV\SimpleCollection('test'), ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request(); + $server->httpRequest = new HTTP\Request('GET', '/'); $body = '<?xml version="1.0"?> <d:acl xmlns:d="DAV:"> </d:acl>'; @@ -41,17 +42,16 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } - function testSuccessSimple() { - + public function testSuccessSimple() + { $tree = [ new MockACLNode('test', []), ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request(); + $server->httpRequest = new HTTP\Request('GET', '/'); $server->httpRequest->setUrl('/test'); $body = '<?xml version="1.0"?> @@ -62,14 +62,13 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $this->assertFalse($acl->httpACL($server->httpRequest, $server->httpResponse)); - } /** - * @expectedException Sabre\DAVACL\Exception\NotRecognizedPrincipal + * @expectedException \Sabre\DAVACL\Exception\NotRecognizedPrincipal */ - function testUnrecognizedPrincipal() { - + public function testUnrecognizedPrincipal() + { $tree = [ new MockACLNode('test', []), ]; @@ -88,14 +87,13 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } /** - * @expectedException Sabre\DAVACL\Exception\NotRecognizedPrincipal + * @expectedException \Sabre\DAVACL\Exception\NotRecognizedPrincipal */ - function testUnrecognizedPrincipal2() { - + public function testUnrecognizedPrincipal2() + { $tree = [ new MockACLNode('test', []), new DAV\SimpleCollection('principals', [ @@ -117,14 +115,13 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } /** - * @expectedException Sabre\DAVACL\Exception\NotSupportedPrivilege + * @expectedException \Sabre\DAVACL\Exception\NotSupportedPrivilege */ - function testUnknownPrivilege() { - + public function testUnknownPrivilege() + { $tree = [ new MockACLNode('test', []), ]; @@ -143,20 +140,19 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } /** - * @expectedException Sabre\DAVACL\Exception\NoAbstract + * @expectedException \Sabre\DAVACL\Exception\NoAbstract */ - function testAbstractPrivilege() { - + public function testAbstractPrivilege() + { $tree = [ new MockACLNode('test', []), ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->on('getSupportedPrivilegeSet', function($node, &$supportedPrivilegeSet) { + $server->on('getSupportedPrivilegeSet', function ($node, &$supportedPrivilegeSet) { $supportedPrivilegeSet['{DAV:}foo'] = ['abstract' => true]; }); $server->httpRequest = new HTTP\Request('ACL', '/test'); @@ -172,14 +168,13 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } /** - * @expectedException Sabre\DAVACL\Exception\AceConflict + * @expectedException \Sabre\DAVACL\Exception\AceConflict */ - function testUpdateProtectedPrivilege() { - + public function testUpdateProtectedPrivilege() + { $oldACL = [ [ 'principal' => 'principals/notfound', @@ -206,14 +201,13 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } /** - * @expectedException Sabre\DAVACL\Exception\AceConflict + * @expectedException \Sabre\DAVACL\Exception\AceConflict */ - function testUpdateProtectedPrivilege2() { - + public function testUpdateProtectedPrivilege2() + { $oldACL = [ [ 'principal' => 'principals/notfound', @@ -240,14 +234,13 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } /** - * @expectedException Sabre\DAVACL\Exception\AceConflict + * @expectedException \Sabre\DAVACL\Exception\AceConflict */ - function testUpdateProtectedPrivilege3() { - + public function testUpdateProtectedPrivilege3() + { $oldACL = [ [ 'principal' => 'principals/notfound', @@ -274,11 +267,10 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } - function testSuccessComplex() { - + public function testSuccessComplex() + { $oldACL = [ [ 'principal' => 'principals/foo', @@ -317,7 +309,6 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); - $this->assertFalse($acl->httpAcl($server->httpRequest, $server->httpResponse)); $this->assertEquals([ @@ -332,6 +323,5 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { 'protected' => false, ], ], $node->getACL()); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php index f16693625..724abc685 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php @@ -1,18 +1,20 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -class AllowAccessTest extends \PHPUnit_Framework_TestCase { - +class AllowAccessTest extends \PHPUnit\Framework\TestCase +{ /** * @var DAV\Server */ protected $server; - function setUp() { - + public function setUp() + { $nodes = [ new DAV\Mock\Collection('testdir', [ 'file1.txt' => 'contents', @@ -27,106 +29,92 @@ class AllowAccessTest extends \PHPUnit_Framework_TestCase { ); // Login $this->server->getPlugin('auth')->beforeMethod( - new \Sabre\HTTP\Request(), + new \Sabre\HTTP\Request('GET', '/'), new \Sabre\HTTP\Response() ); $aclPlugin = new Plugin(); $this->server->addPlugin($aclPlugin); - } - function testGet() { - + public function testGet() + { $this->server->httpRequest->setMethod('GET'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse])); } - function testGetDoesntExist() { - + public function testGetDoesntExist() + { $this->server->httpRequest->setMethod('GET'); $this->server->httpRequest->setUrl('/foo'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse])); } - function testHEAD() { - + public function testHEAD() + { $this->server->httpRequest->setMethod('HEAD'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:HEAD', [$this->server->httpRequest, $this->server->httpResponse])); } - function testOPTIONS() { - + public function testOPTIONS() + { $this->server->httpRequest->setMethod('OPTIONS'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:OPTIONS', [$this->server->httpRequest, $this->server->httpResponse])); } - function testPUT() { - + public function testPUT() + { $this->server->httpRequest->setMethod('PUT'); $this->server->httpRequest->setUrl('/testdir/file1.txt'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:PUT', [$this->server->httpRequest, $this->server->httpResponse])); } - function testPROPPATCH() { - + public function testPROPPATCH() + { $this->server->httpRequest->setMethod('PROPPATCH'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:PROPPATCH', [$this->server->httpRequest, $this->server->httpResponse])); } - function testCOPY() { - + public function testCOPY() + { $this->server->httpRequest->setMethod('COPY'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:COPY', [$this->server->httpRequest, $this->server->httpResponse])); } - function testMOVE() { - + public function testMOVE() + { $this->server->httpRequest->setMethod('MOVE'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:MOVE', [$this->server->httpRequest, $this->server->httpResponse])); } - function testLOCK() { - + public function testLOCK() + { $this->server->httpRequest->setMethod('LOCK'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:LOCK', [$this->server->httpRequest, $this->server->httpResponse])); } - function testBeforeBind() { - + public function testBeforeBind() + { $this->assertTrue($this->server->emit('beforeBind', ['testdir/file'])); - } - - function testBeforeUnbind() { - + public function testBeforeUnbind() + { $this->assertTrue($this->server->emit('beforeUnbind', ['testdir'])); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php index ceae9aed0..3c3aaf6c9 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php @@ -1,19 +1,21 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -class BlockAccessTest extends \PHPUnit_Framework_TestCase { - +class BlockAccessTest extends \PHPUnit\Framework\TestCase +{ /** * @var DAV\Server */ protected $server; protected $plugin; - function setUp() { - + public function setUp() + { $nodes = [ new DAV\SimpleCollection('testdir'), ]; @@ -28,151 +30,138 @@ class BlockAccessTest extends \PHPUnit_Framework_TestCase { ); // Login $this->server->getPlugin('auth')->beforeMethod( - new \Sabre\HTTP\Request(), + new \Sabre\HTTP\Request('GET', '/'), new \Sabre\HTTP\Response() ); $this->server->addPlugin($this->plugin); - } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testGet() { - + public function testGet() + { $this->server->httpRequest->setMethod('GET'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } - function testGetDoesntExist() { - + public function testGetDoesntExist() + { $this->server->httpRequest->setMethod('GET'); $this->server->httpRequest->setUrl('/foo'); - $r = $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); + $r = $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); $this->assertTrue($r); - } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testHEAD() { - + public function testHEAD() + { $this->server->httpRequest->setMethod('HEAD'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testOPTIONS() { - + public function testOPTIONS() + { $this->server->httpRequest->setMethod('OPTIONS'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testPUT() { - + public function testPUT() + { $this->server->httpRequest->setMethod('PUT'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testPROPPATCH() { - + public function testPROPPATCH() + { $this->server->httpRequest->setMethod('PROPPATCH'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testCOPY() { - + public function testCOPY() + { $this->server->httpRequest->setMethod('COPY'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testMOVE() { - + public function testMOVE() + { $this->server->httpRequest->setMethod('MOVE'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testACL() { - + public function testACL() + { $this->server->httpRequest->setMethod('ACL'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testLOCK() { - + public function testLOCK() + { $this->server->httpRequest->setMethod('LOCK'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testBeforeBind() { - + public function testBeforeBind() + { $this->server->emit('beforeBind', ['testdir/file']); - } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testBeforeUnbind() { - + public function testBeforeUnbind() + { $this->server->emit('beforeUnbind', ['testdir']); - } - function testPropFind() { - + public function testPropFind() + { $propFind = new DAV\PropFind('testdir', [ '{DAV:}displayname', '{DAV:}getcontentlength', @@ -187,19 +176,18 @@ class BlockAccessTest extends \PHPUnit_Framework_TestCase { 200 => [], 404 => [], 403 => [ - '{DAV:}displayname' => null, + '{DAV:}displayname' => null, '{DAV:}getcontentlength' => null, - '{DAV:}bar' => null, - '{DAV:}owner' => null, + '{DAV:}bar' => null, + '{DAV:}owner' => null, ], ]; $this->assertEquals($expected, $propFind->getResultForMultiStatus()); - } - function testBeforeGetPropertiesNoListing() { - + public function testBeforeGetPropertiesNoListing() + { $this->plugin->hideNodesFromListings = true; $propFind = new DAV\PropFind('testdir', [ '{DAV:}displayname', @@ -210,6 +198,5 @@ class BlockAccessTest extends \PHPUnit_Framework_TestCase { $r = $this->server->emit('propFind', [$propFind, new DAV\SimpleCollection('testdir')]); $this->assertFalse($r); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php index 1cdf2949f..60fb8f3e8 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; -class AceConflictTest extends \PHPUnit_Framework_TestCase { - - function testSerialize() { - +class AceConflictTest extends \PHPUnit\Framework\TestCase +{ + public function testSerialize() + { $ex = new AceConflict('message'); $server = new DAV\Server(); @@ -18,7 +20,7 @@ class AceConflictTest extends \PHPUnit_Framework_TestCase { $ex->serialize($server, $root); $xpaths = [ - '/d:root' => 1, + '/d:root' => 1, '/d:root/d:no-ace-conflict' => 1, ]; @@ -29,11 +31,7 @@ class AceConflictTest extends \PHPUnit_Framework_TestCase { $dxpath = new \DOMXPath($dom2); $dxpath->registerNamespace('d', 'DAV:'); foreach ($xpaths as $xpath => $count) { - - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); - + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : '.$xpath.', we could only find '.$dxpath->query($xpath)->length.' elements, while we expected '.$count); } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php index b13e7722d..f08e536b5 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; -class NeedPrivilegesExceptionTest extends \PHPUnit_Framework_TestCase { - - function testSerialize() { - +class NeedPrivilegesExceptionTest extends \PHPUnit\Framework\TestCase +{ + public function testSerialize() + { $uri = 'foo'; $privileges = [ '{DAV:}read', @@ -23,12 +25,12 @@ class NeedPrivilegesExceptionTest extends \PHPUnit_Framework_TestCase { $ex->serialize($server, $root); $xpaths = [ - '/d:root' => 1, - '/d:root/d:need-privileges' => 1, - '/d:root/d:need-privileges/d:resource' => 2, - '/d:root/d:need-privileges/d:resource/d:href' => 2, - '/d:root/d:need-privileges/d:resource/d:privilege' => 2, - '/d:root/d:need-privileges/d:resource/d:privilege/d:read' => 1, + '/d:root' => 1, + '/d:root/d:need-privileges' => 1, + '/d:root/d:need-privileges/d:resource' => 2, + '/d:root/d:need-privileges/d:resource/d:href' => 2, + '/d:root/d:need-privileges/d:resource/d:privilege' => 2, + '/d:root/d:need-privileges/d:resource/d:privilege/d:read' => 1, '/d:root/d:need-privileges/d:resource/d:privilege/d:write' => 1, ]; @@ -39,11 +41,7 @@ class NeedPrivilegesExceptionTest extends \PHPUnit_Framework_TestCase { $dxpath = new \DOMXPath($dom2); $dxpath->registerNamespace('d', 'DAV:'); foreach ($xpaths as $xpath => $count) { - - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); - + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : '.$xpath.', we could only find '.$dxpath->query($xpath)->length.' elements, while we expected '.$count); } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php index f52b17371..38e9d8b93 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; -class NoAbstractTest extends \PHPUnit_Framework_TestCase { - - function testSerialize() { - +class NoAbstractTest extends \PHPUnit\Framework\TestCase +{ + public function testSerialize() + { $ex = new NoAbstract('message'); $server = new DAV\Server(); @@ -18,7 +20,7 @@ class NoAbstractTest extends \PHPUnit_Framework_TestCase { $ex->serialize($server, $root); $xpaths = [ - '/d:root' => 1, + '/d:root' => 1, '/d:root/d:no-abstract' => 1, ]; @@ -29,11 +31,7 @@ class NoAbstractTest extends \PHPUnit_Framework_TestCase { $dxpath = new \DOMXPath($dom2); $dxpath->registerNamespace('d', 'DAV:'); foreach ($xpaths as $xpath => $count) { - - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); - + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : '.$xpath.', we could only find '.$dxpath->query($xpath)->length.' elements, while we expected '.$count); } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php index df89aaf84..62915ea1d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; -class NotRecognizedPrincipalTest extends \PHPUnit_Framework_TestCase { - - function testSerialize() { - +class NotRecognizedPrincipalTest extends \PHPUnit\Framework\TestCase +{ + public function testSerialize() + { $ex = new NotRecognizedPrincipal('message'); $server = new DAV\Server(); @@ -18,7 +20,7 @@ class NotRecognizedPrincipalTest extends \PHPUnit_Framework_TestCase { $ex->serialize($server, $root); $xpaths = [ - '/d:root' => 1, + '/d:root' => 1, '/d:root/d:recognized-principal' => 1, ]; @@ -29,11 +31,7 @@ class NotRecognizedPrincipalTest extends \PHPUnit_Framework_TestCase { $dxpath = new \DOMXPath($dom2); $dxpath->registerNamespace('d', 'DAV:'); foreach ($xpaths as $xpath => $count) { - - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); - + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : '.$xpath.', we could only find '.$dxpath->query($xpath)->length.' elements, while we expected '.$count); } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php index 50623952b..668c713d2 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; -class NotSupportedPrivilegeTest extends \PHPUnit_Framework_TestCase { - - function testSerialize() { - +class NotSupportedPrivilegeTest extends \PHPUnit\Framework\TestCase +{ + public function testSerialize() + { $ex = new NotSupportedPrivilege('message'); $server = new DAV\Server(); @@ -18,7 +20,7 @@ class NotSupportedPrivilegeTest extends \PHPUnit_Framework_TestCase { $ex->serialize($server, $root); $xpaths = [ - '/d:root' => 1, + '/d:root' => 1, '/d:root/d:not-supported-privilege' => 1, ]; @@ -29,11 +31,7 @@ class NotSupportedPrivilegeTest extends \PHPUnit_Framework_TestCase { $dxpath = new \DOMXPath($dom2); $dxpath->registerNamespace('d', 'DAV:'); foreach ($xpaths as $xpath => $count) { - - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); - + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : '.$xpath.', we could only find '.$dxpath->query($xpath)->length.' elements, while we expected '.$count); } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php index 91de64372..28e328ea6 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -7,24 +9,24 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; -class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { - - function getServer() { - +class ExpandPropertiesTest extends \PHPUnit\Framework\TestCase +{ + public function getServer() + { $tree = [ new DAV\Mock\PropertiesCollection('node1', [], [ '{http://sabredav.org/ns}simple' => 'foo', - '{http://sabredav.org/ns}href' => new DAV\Xml\Property\Href('node2'), - '{DAV:}displayname' => 'Node 1', + '{http://sabredav.org/ns}href' => new DAV\Xml\Property\Href('node2'), + '{DAV:}displayname' => 'Node 1', ]), new DAV\Mock\PropertiesCollection('node2', [], [ - '{http://sabredav.org/ns}simple' => 'simple', + '{http://sabredav.org/ns}simple' => 'simple', '{http://sabredav.org/ns}hreflist' => new DAV\Xml\Property\Href(['node1', 'node3']), - '{DAV:}displayname' => 'Node 2', + '{DAV:}displayname' => 'Node 2', ]), new DAV\Mock\PropertiesCollection('node3', [], [ '{http://sabredav.org/ns}simple' => 'simple', - '{DAV:}displayname' => 'Node 3', + '{DAV:}displayname' => 'Node 3', ]), ]; @@ -39,7 +41,7 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { [ 'principal' => '{DAV:}all', 'privilege' => '{DAV:}all', - ] + ], ]); $this->assertTrue($plugin instanceof Plugin); @@ -47,11 +49,10 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); return $fakeServer; - } - function testSimple() { - + public function testSimple() + { $xml = '<?xml version="1.0"?> <d:expand-property xmlns:d="DAV:"> <d:property name="displayname" /> @@ -62,8 +63,8 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/node1', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/node1', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -74,22 +75,21 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $server->exec(); - $this->assertEquals(207, $server->httpResponse->status, 'Incorrect status code received. Full body: ' . $server->httpResponse->body); + $this->assertEquals(207, $server->httpResponse->status, 'Incorrect status code received. Full body: '.$server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 2, - '/d:multistatus/d:response/d:propstat/d:prop' => 2, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 2, + '/d:multistatus/d:response/d:propstat/d:prop' => 2, '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:simple' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:simple' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:href' => 1, ]; @@ -97,25 +97,24 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $xml->registerXPathNamespace('d', 'DAV:'); $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response: '.$server->httpResponse->body); } - } /** * @depends testSimple */ - function testExpand() { - + public function testExpand() + { $xml = '<?xml version="1.0"?> <d:expand-property xmlns:d="DAV:"> <d:property name="href" namespace="http://sabredav.org/ns"> @@ -125,8 +124,8 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/node1', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/node1', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -137,24 +136,23 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $server->exec(); - $this->assertEquals(207, $server->httpResponse->status, 'Incorrect response status received. Full response body: ' . $server->httpResponse->body); + $this->assertEquals(207, $server->httpResponse->status, 'Incorrect response status received. Full response body: '.$server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1, ]; @@ -162,25 +160,24 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $xml->registerXPathNamespace('d', 'DAV:'); $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . ' Full response body: ' . $server->httpResponse->getBodyAsString()); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).' Full response body: '.$server->httpResponse->getBodyAsString()); } - } /** * @depends testSimple */ - function testExpandHrefList() { - + public function testExpandHrefList() + { $xml = '<?xml version="1.0"?> <d:expand-property xmlns:d="DAV:"> <d:property name="hreflist" namespace="http://sabredav.org/ns"> @@ -190,8 +187,8 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/node2', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/node2', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -205,21 +202,20 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(207, $server->httpResponse->status); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 2, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 2, '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, ]; @@ -227,25 +223,24 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $xml->registerXPathNamespace('d', 'DAV:'); $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result)); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result)); } - } /** * @depends testExpand */ - function testExpandDeep() { - + public function testExpandDeep() + { $xml = '<?xml version="1.0"?> <d:expand-property xmlns:d="DAV:"> <d:property name="hreflist" namespace="http://sabredav.org/ns"> @@ -258,8 +253,8 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/node2', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/node2', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -273,27 +268,26 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(207, $server->httpResponse->status); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 3, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 3, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 3, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 3, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1, ]; @@ -301,17 +295,16 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $xml->registerXPathNamespace('d', 'DAV:'); $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result)); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result)); } - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php b/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php index 2d9744e29..51411f304 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php @@ -1,55 +1,49 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -class MockACLNode extends DAV\Node implements IACL { - +class MockACLNode extends DAV\Node implements IACL +{ public $name; public $acl; - function __construct($name, array $acl = []) { - + public function __construct($name, array $acl = []) + { $this->name = $name; $this->acl = $acl; - } - function getName() { - + public function getName() + { return $this->name; - } - function getOwner() { - + public function getOwner() + { return null; - } - function getGroup() { - + public function getGroup() + { return null; - } - function getACL() { - + public function getACL() + { return $this->acl; - } - function setACL(array $acl) { - + public function setACL(array $acl) + { $this->acl = $acl; - } - function getSupportedPrivilegeSet() { - + public function getSupportedPrivilegeSet() + { return null; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php b/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php index 934906802..f67025c5a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php @@ -1,64 +1,58 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -class MockPrincipal extends DAV\Node implements IPrincipal { - +class MockPrincipal extends DAV\Node implements IPrincipal +{ public $name; public $principalUrl; public $groupMembership = []; public $groupMemberSet = []; - function __construct($name, $principalUrl, array $groupMembership = [], array $groupMemberSet = []) { - + public function __construct($name, $principalUrl, array $groupMembership = [], array $groupMemberSet = []) + { $this->name = $name; $this->principalUrl = $principalUrl; $this->groupMembership = $groupMembership; $this->groupMemberSet = $groupMemberSet; - } - function getName() { - + public function getName() + { return $this->name; - } - function getDisplayName() { - + public function getDisplayName() + { return $this->getName(); - } - function getAlternateUriSet() { - + public function getAlternateUriSet() + { return []; - } - function getPrincipalUrl() { - + public function getPrincipalUrl() + { return $this->principalUrl; - } - function getGroupMemberSet() { - + public function getGroupMemberSet() + { return $this->groupMemberSet; - } - function getGroupMemberShip() { - + public function getGroupMemberShip() + { return $this->groupMembership; - } - function setGroupMemberSet(array $groupMemberSet) { - + public function setGroupMemberSet(array $groupMemberSet) + { $this->groupMemberSet = $groupMemberSet; - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php index 8552448f5..9ab16df74 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -8,12 +10,12 @@ use Sabre\HTTP; require_once 'Sabre/DAVACL/MockACLNode.php'; require_once 'Sabre/HTTP/ResponseMock.php'; -class PluginAdminTest extends \PHPUnit_Framework_TestCase { - +class PluginAdminTest extends \PHPUnit\Framework\TestCase +{ public $server; - function setUp() { - + public function setUp() + { $principalBackend = new PrincipalBackend\Mock(); $tree = [ @@ -27,15 +29,15 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $this->server->addPlugin($plugin); } - function testNoAdminAccess() { - + public function testNoAdminAccess() + { $plugin = new Plugin(); $this->server->addPlugin($plugin); $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'OPTIONS', - 'HTTP_DEPTH' => 1, - 'REQUEST_URI' => '/adminonly', + 'HTTP_DEPTH' => 1, + 'REQUEST_URI' => '/adminonly', ]); $response = new HTTP\ResponseMock(); @@ -46,14 +48,13 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $this->server->exec(); $this->assertEquals(403, $response->status); - } /** * @depends testNoAdminAccess */ - function testAdminAccess() { - + public function testAdminAccess() + { $plugin = new Plugin(); $plugin->adminPrincipals = [ 'principals/admin', @@ -62,8 +63,8 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'OPTIONS', - 'HTTP_DEPTH' => 1, - 'REQUEST_URI' => '/adminonly', + 'HTTP_DEPTH' => 1, + 'REQUEST_URI' => '/adminonly', ]); $response = new HTTP\ResponseMock(); @@ -74,6 +75,5 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $this->server->exec(); $this->assertEquals(200, $response->status); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php index fb42efba7..16d3e781e 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php @@ -1,14 +1,16 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; use Sabre\HTTP; -class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { - - function testPrincipalCollectionSet() { - +class PluginPropertiesTest extends \PHPUnit\Framework\TestCase +{ + public function testPrincipalCollectionSet() + { $plugin = new Plugin(); $plugin->allowUnauthenticatedAccess = false; $plugin->setDefaultACL([ @@ -42,14 +44,11 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { 'principals2/', ]; - $this->assertEquals($expected, $result[200]['{DAV:}principal-collection-set']->getHrefs()); - - } - function testCurrentUserPrincipal() { - + public function testCurrentUserPrincipal() + { $fakeServer = new DAV\Server(); $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock()); $fakeServer->addPlugin($plugin); @@ -62,7 +61,6 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { ]); $fakeServer->addPlugin($plugin); - $requestedProperties = [ '{DAV:}current-user-principal', ]; @@ -76,7 +74,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(Xml\Property\Principal::UNAUTHENTICATED, $result[200]['{DAV:}current-user-principal']->getType()); // This will force the login - $fakeServer->emit('beforeMethod', [$fakeServer->httpRequest, $fakeServer->httpResponse]); + $fakeServer->emit('beforeMethod:PROPFIND', [$fakeServer->httpRequest, $fakeServer->httpResponse]); $result = $fakeServer->getPropertiesForPath('', $requestedProperties); $result = $result[0]; @@ -86,11 +84,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']); $this->assertEquals(Xml\Property\Principal::HREF, $result[200]['{DAV:}current-user-principal']->getType()); $this->assertEquals('principals/admin/', $result[200]['{DAV:}current-user-principal']->getHref()); - } - function testSupportedPrivilegeSet() { - + public function testSupportedPrivilegeSet() + { $plugin = new Plugin(); $plugin->allowUnauthenticatedAccess = false; $plugin->setDefaultACL([ @@ -119,28 +116,27 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->xml->write('{DAV:}root', $prop); $xpaths = [ - '/d:root' => 1, - '/d:root/d:supported-privilege' => 1, - '/d:root/d:supported-privilege/d:privilege' => 1, - '/d:root/d:supported-privilege/d:privilege/d:all' => 1, - '/d:root/d:supported-privilege/d:abstract' => 0, - '/d:root/d:supported-privilege/d:supported-privilege' => 2, - '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2, - '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 7, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 7, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1, + '/d:root' => 1, + '/d:root/d:supported-privilege' => 1, + '/d:root/d:supported-privilege/d:privilege' => 1, + '/d:root/d:supported-privilege/d:privilege/d:all' => 1, + '/d:root/d:supported-privilege/d:abstract' => 0, + '/d:root/d:supported-privilege/d:supported-privilege' => 2, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 7, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 7, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-current-user-privilege-set' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0, ]; - // reloading because php dom sucks $dom2 = new \DOMDocument('1.0', 'utf-8'); $dom2->loadXML($result); @@ -148,15 +144,12 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $dxpath = new \DOMXPath($dom2); $dxpath->registerNamespace('d', 'DAV:'); foreach ($xpaths as $xpath => $count) { - - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count . ' Full XML: ' . $result); - + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : '.$xpath.', we could only find '.$dxpath->query($xpath)->length.' elements, while we expected '.$count.' Full XML: '.$result); } - } - function testACL() { - + public function testACL() + { $plugin = new Plugin(); $plugin->allowUnauthenticatedAccess = false; $plugin->setDefaultACL([ @@ -171,12 +164,11 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}read', - ] + ], ]), new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('admin', 'principals/admin'), ]), - ]; $server = new DAV\Server($nodes); @@ -185,7 +177,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($authPlugin); // Force login - $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $requestedProperties = [ '{DAV:}acl', @@ -194,14 +186,13 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->getPropertiesForPath('foo', $requestedProperties); $result = $result[0]; - $this->assertEquals(1, count($result[200]), 'The {DAV:}acl property did not return from the list. Full list: ' . print_r($result, true)); + $this->assertEquals(1, count($result[200]), 'The {DAV:}acl property did not return from the list. Full list: '.print_r($result, true)); $this->assertArrayHasKey('{DAV:}acl', $result[200]); $this->assertInstanceOf('Sabre\\DAVACL\\Xml\Property\\Acl', $result[200]['{DAV:}acl']); - } - function testACLRestrictions() { - + public function testACLRestrictions() + { $plugin = new Plugin(); $plugin->allowUnauthenticatedAccess = false; @@ -210,12 +201,11 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}read', - ] + ], ]), new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('admin', 'principals/admin'), ]), - ]; $server = new DAV\Server($nodes); @@ -224,7 +214,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($authPlugin); // Force login - $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $requestedProperties = [ '{DAV:}acl-restrictions', @@ -233,18 +223,17 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->getPropertiesForPath('foo', $requestedProperties); $result = $result[0]; - $this->assertEquals(1, count($result[200]), 'The {DAV:}acl-restrictions property did not return from the list. Full list: ' . print_r($result, true)); + $this->assertEquals(1, count($result[200]), 'The {DAV:}acl-restrictions property did not return from the list. Full list: '.print_r($result, true)); $this->assertArrayHasKey('{DAV:}acl-restrictions', $result[200]); $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\AclRestrictions', $result[200]['{DAV:}acl-restrictions']); - } - function testAlternateUriSet() { - + public function testAlternateUriSet() + { $tree = [ new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('user', 'principals/user'), - ]) + ]), ]; $fakeServer = new DAV\Server($tree); @@ -271,11 +260,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}alternate-URI-set']); $this->assertEquals([], $result[200]['{DAV:}alternate-URI-set']->getHrefs()); - } - function testPrincipalURL() { - + public function testPrincipalURL() + { $tree = [ new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('user', 'principals/user'), @@ -307,11 +295,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}principal-URL']); $this->assertEquals('principals/user/', $result[200]['{DAV:}principal-URL']->getHref()); - } - function testGroupMemberSet() { - + public function testGroupMemberSet() + { $tree = [ new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('user', 'principals/user'), @@ -343,11 +330,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}group-member-set']); $this->assertEquals([], $result[200]['{DAV:}group-member-set']->getHrefs()); - } - function testGroupMemberShip() { - + public function testGroupMemberShip() + { $tree = [ new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('user', 'principals/user'), @@ -377,11 +363,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}group-membership']); $this->assertEquals([], $result[200]['{DAV:}group-membership']->getHrefs()); - } - function testGetDisplayName() { - + public function testGetDisplayName() + { $tree = [ new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('user', 'principals/user'), @@ -410,6 +395,5 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertTrue(isset($result[200]['{DAV:}displayname'])); $this->assertEquals('user', $result[200]['{DAV:}displayname']); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php index 0147e6a61..169629a03 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { - - function testUpdatePropertiesPassthrough() { - +class PluginUpdatePropertiesTest extends \PHPUnit\Framework\TestCase +{ + public function testUpdatePropertiesPassthrough() + { $tree = [ new DAV\SimpleCollection('foo'), ]; @@ -24,11 +26,10 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $result); - } - function testRemoveGroupMembers() { - + public function testRemoveGroupMembers() + { $tree = [ new MockPrincipal('foo', 'foo'), ]; @@ -42,16 +43,15 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { ]); $expected = [ - '{DAV:}group-member-set' => 204 + '{DAV:}group-member-set' => 204, ]; $this->assertEquals($expected, $result); $this->assertEquals([], $tree[0]->getGroupMemberSet()); - } - function testSetGroupMembers() { - + public function testSetGroupMembers() + { $tree = [ new MockPrincipal('foo', 'foo'), ]; @@ -65,19 +65,18 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { ]); $expected = [ - '{DAV:}group-member-set' => 200 + '{DAV:}group-member-set' => 200, ]; $this->assertEquals($expected, $result); $this->assertEquals(['bar', 'baz'], $tree[0]->getGroupMemberSet()); - } /** - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testSetBadValue() { - + public function testSetBadValue() + { $tree = [ new MockPrincipal('foo', 'foo'), ]; @@ -89,11 +88,10 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->updateProperties('foo', [ '{DAV:}group-member-set' => new \StdClass(), ]); - } - function testSetBadNode() { - + public function testSetBadNode() + { $tree = [ new DAV\SimpleCollection('foo'), ]; @@ -111,6 +109,5 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $result); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php index 9fef3018d..89f69b10a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php @@ -1,16 +1,17 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; use Sabre\DAV; -use Sabre\HTTP; - -abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { +abstract class AbstractPDOTest extends \PHPUnit\Framework\TestCase +{ use DAV\DbTestHelperTrait; - function setUp() { - + public function setUp() + { $this->dropTables(['principals', 'groupmembers']); $this->createSchema('principals'); @@ -19,92 +20,85 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/user','user@example.org','User')"); $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/group','group@example.org','Group')"); - $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (5,4)"); - + $pdo->query('INSERT INTO groupmembers (principal_id,member_id) VALUES (5,4)'); } - - function testConstruct() { - + public function testConstruct() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $this->assertTrue($backend instanceof PDO); - } /** * @depends testConstruct */ - function testGetPrincipalsByPrefix() { - + public function testGetPrincipalsByPrefix() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $expected = [ [ - 'uri' => 'principals/admin', + 'uri' => 'principals/admin', '{http://sabredav.org/ns}email-address' => 'admin@example.org', - '{DAV:}displayname' => 'Administrator', + '{DAV:}displayname' => 'Administrator', ], [ - 'uri' => 'principals/user', + 'uri' => 'principals/user', '{http://sabredav.org/ns}email-address' => 'user@example.org', - '{DAV:}displayname' => 'User', + '{DAV:}displayname' => 'User', ], [ - 'uri' => 'principals/group', + 'uri' => 'principals/group', '{http://sabredav.org/ns}email-address' => 'group@example.org', - '{DAV:}displayname' => 'Group', + '{DAV:}displayname' => 'Group', ], ]; $this->assertEquals($expected, $backend->getPrincipalsByPrefix('principals')); $this->assertEquals([], $backend->getPrincipalsByPrefix('foo')); - } /** * @depends testConstruct */ - function testGetPrincipalByPath() { - + public function testGetPrincipalByPath() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $expected = [ - 'id' => 4, - 'uri' => 'principals/user', + 'id' => 4, + 'uri' => 'principals/user', '{http://sabredav.org/ns}email-address' => 'user@example.org', - '{DAV:}displayname' => 'User', + '{DAV:}displayname' => 'User', ]; $this->assertEquals($expected, $backend->getPrincipalByPath('principals/user')); $this->assertEquals(null, $backend->getPrincipalByPath('foo')); - } - function testGetGroupMemberSet() { - + public function testGetGroupMemberSet() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $expected = ['principals/user']; $this->assertEquals($expected, $backend->getGroupMemberSet('principals/group')); - } - function testGetGroupMembership() { - + public function testGetGroupMembership() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $expected = ['principals/group']; $this->assertEquals($expected, $backend->getGroupMembership('principals/user')); - } - function testSetGroupMemberSet() { - + public function testSetGroupMemberSet() + { $pdo = $this->getPDO(); // Start situation @@ -118,12 +112,10 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { // Adding principals again $backend->setGroupMemberSet('principals/group', ['principals/user']); $this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group')); - - } - function testSearchPrincipals() { - + public function testSearchPrincipals() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); @@ -139,11 +131,10 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $backend->searchPrincipals('mom', ['{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE']); $this->assertEquals([], $result); - } - function testUpdatePrincipal() { - + public function testUpdatePrincipal() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); @@ -157,22 +148,21 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertTrue($result); $this->assertEquals([ - 'id' => 4, - 'uri' => 'principals/user', - '{DAV:}displayname' => 'pietje', + 'id' => 4, + 'uri' => 'principals/user', + '{DAV:}displayname' => 'pietje', '{http://sabredav.org/ns}email-address' => 'user@example.org', ], $backend->getPrincipalByPath('principals/user')); - } - function testUpdatePrincipalUnknownField() { - + public function testUpdatePrincipalUnknownField() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $propPatch = new DAV\PropPatch([ '{DAV:}displayname' => 'pietje', - '{DAV:}unknown' => 'foo', + '{DAV:}unknown' => 'foo', ]); $backend->updatePrincipal('principals/user', $propPatch); @@ -182,36 +172,31 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ '{DAV:}displayname' => 424, - '{DAV:}unknown' => 403 + '{DAV:}unknown' => 403, ], $propPatch->getResult()); $this->assertEquals([ - 'id' => '4', - 'uri' => 'principals/user', - '{DAV:}displayname' => 'User', + 'id' => '4', + 'uri' => 'principals/user', + '{DAV:}displayname' => 'User', '{http://sabredav.org/ns}email-address' => 'user@example.org', ], $backend->getPrincipalByPath('principals/user')); - } - function testFindByUriUnknownScheme() { - + public function testFindByUriUnknownScheme() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $this->assertNull($backend->findByUri('http://foo', 'principals')); - } - - function testFindByUri() { - + public function testFindByUri() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $this->assertEquals( 'principals/user', $backend->findByUri('mailto:user@example.org', 'principals') ); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php index 1464f4c26..551a77900 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php @@ -1,121 +1,117 @@ <?php -namespace Sabre\DAVACL\PrincipalBackend; +declare(strict_types=1); -class Mock extends AbstractBackend { +namespace Sabre\DAVACL\PrincipalBackend; +class Mock extends AbstractBackend +{ public $groupMembers = []; public $principals; - function __construct(array $principals = null) { - + public function __construct(array $principals = null) + { $this->principals = $principals; if (is_null($principals)) { - $this->principals = [ [ - 'uri' => 'principals/user1', - '{DAV:}displayname' => 'User 1', + 'uri' => 'principals/user1', + '{DAV:}displayname' => 'User 1', '{http://sabredav.org/ns}email-address' => 'user1.sabredav@sabredav.org', - '{http://sabredav.org/ns}vcard-url' => 'addressbooks/user1/book1/vcard1.vcf', + '{http://sabredav.org/ns}vcard-url' => 'addressbooks/user1/book1/vcard1.vcf', ], [ - 'uri' => 'principals/admin', + 'uri' => 'principals/admin', '{DAV:}displayname' => 'Admin', ], [ - 'uri' => 'principals/user2', - '{DAV:}displayname' => 'User 2', + 'uri' => 'principals/user2', + '{DAV:}displayname' => 'User 2', '{http://sabredav.org/ns}email-address' => 'user2.sabredav@sabredav.org', ], ]; - } - } - function getPrincipalsByPrefix($prefix) { - + public function getPrincipalsByPrefix($prefix) + { $prefix = trim($prefix, '/'); - if ($prefix) $prefix .= '/'; + if ($prefix) { + $prefix .= '/'; + } $return = []; foreach ($this->principals as $principal) { - - if ($prefix && strpos($principal['uri'], $prefix) !== 0) continue; + if ($prefix && 0 !== strpos($principal['uri'], $prefix)) { + continue; + } $return[] = $principal; - } return $return; - } - function addPrincipal(array $principal) { - + public function addPrincipal(array $principal) + { $this->principals[] = $principal; - } - function getPrincipalByPath($path) { - + public function getPrincipalByPath($path) + { foreach ($this->getPrincipalsByPrefix('principals') as $principal) { - if ($principal['uri'] === $path) return $principal; + if ($principal['uri'] === $path) { + return $principal; + } } - } - function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') { - + public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') + { $matches = []; foreach ($this->getPrincipalsByPrefix($prefixPath) as $principal) { - foreach ($searchProperties as $key => $value) { - if (!isset($principal[$key])) { continue 2; } - if (mb_stripos($principal[$key], $value, 0, 'UTF-8') === false) { + if (false === mb_stripos($principal[$key], $value, 0, 'UTF-8')) { continue 2; } // We have a match for this searchProperty! - if ($test === 'allof') { + if ('allof' === $test) { continue; } else { break; } - } $matches[] = $principal['uri']; - } - return $matches; + return $matches; } - function getGroupMemberSet($path) { - + public function getGroupMemberSet($path) + { return isset($this->groupMembers[$path]) ? $this->groupMembers[$path] : []; - } - function getGroupMembership($path) { - + public function getGroupMembership($path) + { $membership = []; foreach ($this->groupMembers as $group => $members) { - if (in_array($path, $members)) $membership[] = $group; + if (in_array($path, $members)) { + $membership[] = $group; + } } - return $membership; + return $membership; } - function setGroupMemberSet($path, array $members) { - + public function setGroupMemberSet($path, array $members) + { $this->groupMembers[$path] = $members; - } /** @@ -130,11 +126,11 @@ class Mock extends AbstractBackend { * * Read the PropPatch documentation for more info and examples. * - * @param string $path + * @param string $path * @param \Sabre\DAV\PropPatch $propPatch */ - function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch) { - + public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch) + { $value = null; foreach ($this->principals as $principalIndex => $value) { if ($value['uri'] === $path) { @@ -142,27 +138,22 @@ class Mock extends AbstractBackend { break; } } - if (!$principal) return; - - $propPatch->handleRemaining(function($mutations) use ($principal, $principalIndex) { + if (!$principal) { + return; + } + $propPatch->handleRemaining(function ($mutations) use ($principal, $principalIndex) { foreach ($mutations as $prop => $value) { - if (is_null($value) && isset($principal[$prop])) { unset($principal[$prop]); } else { $principal[$prop] = $value; } - } $this->principals[$principalIndex] = $principal; return true; - }); - } - - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php index 8779eb69f..54795cf4d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\DAVACL\PrincipalBackend; +declare(strict_types=1); -class PDOMySQLTest extends AbstractPDOTest { +namespace Sabre\DAVACL\PrincipalBackend; +class PDOMySQLTest extends AbstractPDOTest +{ public $driver = 'mysql'; - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php index 48454981d..549e0bd60 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\DAVACL\PrincipalBackend; +declare(strict_types=1); -class PDOSqliteTest extends AbstractPDOTest { +namespace Sabre\DAVACL\PrincipalBackend; +class PDOSqliteTest extends AbstractPDOTest +{ public $driver = 'sqlite'; - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php index bcf78821b..68aebe2ae 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php @@ -1,24 +1,25 @@ <?php -namespace Sabre\DAVACL; - -class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testBasic() { +namespace Sabre\DAVACL; +class PrincipalCollectionTest extends \PHPUnit\Framework\TestCase +{ + public function testBasic() + { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); $this->assertTrue($pc instanceof PrincipalCollection); $this->assertEquals('principals', $pc->getName()); - } /** * @depends testBasic */ - function testGetChildren() { - + public function testGetChildren() + { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); @@ -28,30 +29,27 @@ class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { foreach ($children as $child) { $this->assertTrue($child instanceof IPrincipal); } - } /** * @depends testBasic - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ - function testGetChildrenDisable() { - + public function testGetChildrenDisable() + { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); $pc->disableListing = true; $children = $pc->getChildren(); - } - function testFindByUri() { - + public function testFindByUri() + { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); $this->assertEquals('principals/user1', $pc->findByUri('mailto:user1.sabredav@sabredav.org')); $this->assertNull($pc->findByUri('mailto:fake.user.sabredav@sabredav.org')); $this->assertNull($pc->findByUri('')); } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php index 60e156d9a..3bdcfbbbd 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -7,10 +9,10 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; -class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { - - function getServer() { - +class PrincipalPropertySearchTest extends \PHPUnit\Framework\TestCase +{ + public function getServer() + { $backend = new PrincipalBackend\Mock(); $dir = new DAV\SimpleCollection('root'); @@ -30,11 +32,10 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); return $fakeServer; - } - function testDepth1() { - + public function testDepth1() + { $xml = '<?xml version="1.0"?> <d:principal-property-search xmlns:d="DAV:"> <d:property-search> @@ -51,8 +52,8 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '1', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -66,14 +67,12 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(400, $server->httpResponse->getStatus(), $server->httpResponse->getBodyAsString()); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - } - - function testUnknownSearchField() { - + public function testUnknownSearchField() + { $xml = '<?xml version="1.0"?> <d:principal-property-search xmlns:d="DAV:"> <d:property-search> @@ -90,8 +89,8 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -102,17 +101,16 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); - $this->assertEquals(207, $server->httpResponse->getStatus(), "Full body: " . $server->httpResponse->getBodyAsString()); + $this->assertEquals(207, $server->httpResponse->getStatus(), 'Full body: '.$server->httpResponse->getBodyAsString()); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], ], $server->httpResponse->getHeaders()); - } - function testCorrect() { - + public function testCorrect() + { $xml = '<?xml version="1.0"?> <d:principal-property-search xmlns:d="DAV:"> <d:apply-to-principal-collection-set /> @@ -130,8 +128,8 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -145,41 +143,39 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 2, - '/d:multistatus/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat' => 4, - '/d:multistatus/d:response/d:propstat/d:prop' => 4, - '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response' => 2, + '/d:multistatus/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat' => 4, + '/d:multistatus/d:response/d:propstat/d:prop' => 4, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2, - '/d:multistatus/d:response/d:propstat/d:status' => 4, + '/d:multistatus/d:response/d:propstat/d:status' => 4, ]; $xml = simplexml_load_string($server->httpResponse->body); $xml->registerXPathNamespace('d', 'DAV:'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response body: '.$server->httpResponse->body); } - } - function testAND() { - + public function testAND() + { $xml = '<?xml version="1.0"?> <d:principal-property-search xmlns:d="DAV:"> <d:apply-to-principal-collection-set /> @@ -203,8 +199,8 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -218,40 +214,39 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 0, - '/d:multistatus/d:response/d:href' => 0, - '/d:multistatus/d:response/d:propstat' => 0, - '/d:multistatus/d:response/d:propstat/d:prop' => 0, - '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 0, + '/d:multistatus/d:response' => 0, + '/d:multistatus/d:response/d:href' => 0, + '/d:multistatus/d:response/d:propstat' => 0, + '/d:multistatus/d:response/d:propstat/d:prop' => 0, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 0, '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 0, - '/d:multistatus/d:response/d:propstat/d:status' => 0, + '/d:multistatus/d:response/d:propstat/d:status' => 0, ]; $xml = simplexml_load_string($server->httpResponse->body); $xml->registerXPathNamespace('d', 'DAV:'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response body: '.$server->httpResponse->body); } - } - function testOR() { + public function testOR() + { $xml = '<?xml version="1.0"?> <d:principal-property-search xmlns:d="DAV:" test="anyof"> <d:apply-to-principal-collection-set /> @@ -275,8 +270,8 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -290,40 +285,39 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 2, - '/d:multistatus/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat' => 4, - '/d:multistatus/d:response/d:propstat/d:prop' => 4, - '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response' => 2, + '/d:multistatus/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat' => 4, + '/d:multistatus/d:response/d:propstat/d:prop' => 4, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2, - '/d:multistatus/d:response/d:propstat/d:status' => 4, + '/d:multistatus/d:response/d:propstat/d:status' => 4, ]; $xml = simplexml_load_string($server->httpResponse->body); $xml->registerXPathNamespace('d', 'DAV:'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response body: '.$server->httpResponse->body); } - } - function testWrongUri() { + public function testWrongUri() + { $xml = '<?xml version="1.0"?> <d:principal-property-search xmlns:d="DAV:"> <d:property-search> @@ -340,8 +334,8 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -355,11 +349,10 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', '/d:multistatus/d:response' => 0, @@ -368,30 +361,27 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $xml = simplexml_load_string($server->httpResponse->body); $xml->registerXPathNamespace('d', 'DAV:'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response body: '.$server->httpResponse->body); } - } } -class MockPlugin extends Plugin { - - function getCurrentUserPrivilegeSet($node) { - +class MockPlugin extends Plugin +{ + public function getCurrentUserPrivilegeSet($node) + { return [ '{DAV:}read', '{DAV:}write', ]; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php index fa1314d10..04f168f92 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -7,10 +9,10 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; -class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { - - function getServer() { - +class PrincipalSearchPropertySetTest extends \PHPUnit\Framework\TestCase +{ + public function getServer() + { $backend = new PrincipalBackend\Mock(); $dir = new DAV\SimpleCollection('root'); @@ -27,18 +29,17 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); return $fakeServer; - } - function testDepth1() { - + public function testDepth1() + { $xml = '<?xml version="1.0"?> <d:principal-search-property-set xmlns:d="DAV:" />'; $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '1', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -52,20 +53,19 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(400, $server->httpResponse->status); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - } - function testDepthIncorrectXML() { - + public function testDepthIncorrectXML() + { $xml = '<?xml version="1.0"?> <d:principal-search-property-set xmlns:d="DAV:"><d:ohell /></d:principal-search-property-set>'; $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -79,20 +79,19 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(400, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - } - function testCorrect() { - + public function testCorrect() + { $xml = '<?xml version="1.0"?> <d:principal-search-property-set xmlns:d="DAV:"/>'; $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -106,35 +105,32 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(200, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:principal-search-property-set', - '/d:principal-search-property-set/d:principal-search-property' => 2, - '/d:principal-search-property-set/d:principal-search-property/d:prop' => 2, - '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname' => 1, + '/d:principal-search-property-set/d:principal-search-property' => 2, + '/d:principal-search-property-set/d:principal-search-property/d:prop' => 2, + '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname' => 1, '/d:principal-search-property-set/d:principal-search-property/d:prop/s:email-address' => 1, - '/d:principal-search-property-set/d:principal-search-property/d:description' => 2, + '/d:principal-search-property-set/d:principal-search-property/d:description' => 2, ]; $xml = simplexml_load_string($server->httpResponse->body); $xml->registerXPathNamespace('d', 'DAV:'); $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response body: '.$server->httpResponse->body); } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php index 20622ad17..a4821da5a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php @@ -1,58 +1,55 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP; - -class PrincipalTest extends \PHPUnit_Framework_TestCase { - - function testConstruct() { +class PrincipalTest extends \PHPUnit\Framework\TestCase +{ + public function testConstruct() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertTrue($principal instanceof Principal); - } /** - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testConstructNoUri() { - + public function testConstructNoUri() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, []); - } - function testGetName() { - + public function testGetName() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals('admin', $principal->getName()); - } - function testGetDisplayName() { - + public function testGetDisplayName() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals('admin', $principal->getDisplayname()); $principal = new Principal($principalBackend, [ - 'uri' => 'principals/admin', - '{DAV:}displayname' => 'Mr. Admin' + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin', ]); $this->assertEquals('Mr. Admin', $principal->getDisplayname()); - } - function testGetProperties() { - + public function testGetProperties() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, [ - 'uri' => 'principals/admin', - '{DAV:}displayname' => 'Mr. Admin', + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin', '{http://www.example.org/custom}custom' => 'Custom', '{http://sabredav.org/ns}email-address' => 'admin@example.org', ]); @@ -64,15 +61,17 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { ]; $props = $principal->getProperties($keys); - foreach ($keys as $key) $this->assertArrayHasKey($key, $props); + foreach ($keys as $key) { + $this->assertArrayHasKey($key, $props); + } $this->assertEquals('Mr. Admin', $props['{DAV:}displayname']); $this->assertEquals('admin@example.org', $props['{http://sabredav.org/ns}email-address']); } - function testUpdateProperties() { - + public function testUpdateProperties() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); @@ -81,26 +80,24 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { $result = $principal->propPatch($propPatch); $result = $propPatch->commit(); $this->assertTrue($result); - } - function testGetPrincipalUrl() { - + public function testGetPrincipalUrl() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals('principals/admin', $principal->getPrincipalUrl()); - } - function testGetAlternateUriSet() { - + public function testGetAlternateUriSet() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, [ - 'uri' => 'principals/admin', - '{DAV:}displayname' => 'Mr. Admin', + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin', '{http://www.example.org/custom}custom' => 'Custom', '{http://sabredav.org/ns}email-address' => 'admin@example.org', - '{DAV:}alternate-URI-set' => [ + '{DAV:}alternate-URI-set' => [ 'mailto:admin+1@example.org', 'mailto:admin+2@example.org', 'mailto:admin@example.org', @@ -114,10 +111,10 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $principal->getAlternateUriSet()); - } - function testGetAlternateUriSetEmpty() { + public function testGetAlternateUriSetEmpty() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, [ 'uri' => 'principals/admin', @@ -126,26 +123,24 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { $expected = []; $this->assertEquals($expected, $principal->getAlternateUriSet()); - } - function testGetGroupMemberSet() { - + public function testGetGroupMemberSet() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals([], $principal->getGroupMemberSet()); - } - function testGetGroupMembership() { + public function testGetGroupMembership() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals([], $principal->getGroupMembership()); - } - function testSetGroupMemberSet() { - + public function testSetGroupMemberSet() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $principal->setGroupMemberSet(['principals/foo']); @@ -153,27 +148,24 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ 'principals/admin' => ['principals/foo'], ], $principalBackend->groupMembers); - } - function testGetOwner() { - + public function testGetOwner() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals('principals/admin', $principal->getOwner()); - } - function testGetGroup() { - + public function testGetGroup() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertNull($principal->getGroup()); - } - function testGetACl() { - + public function testGetACl() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals([ @@ -181,28 +173,24 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { 'privilege' => '{DAV:}all', 'principal' => '{DAV:}owner', 'protected' => true, - ] + ], ], $principal->getACL()); - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACl() { - + public function testSetACl() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $principal->setACL([]); - } - function testGetSupportedPrivilegeSet() { - + public function testGetSupportedPrivilegeSet() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertNull($principal->getSupportedPrivilegeSet()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php index 2de0ba6a8..a1e9ee36c 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -8,10 +10,10 @@ use Sabre\HTTP; require_once 'Sabre/DAVACL/MockPrincipal.php'; require_once 'Sabre/DAVACL/MockACLNode.php'; -class SimplePluginTest extends \PHPUnit_Framework_TestCase { - - function testValues() { - +class SimplePluginTest extends \PHPUnit\Framework\TestCase +{ + public function testValues() + { $aclPlugin = new Plugin(); $this->assertEquals('acl', $aclPlugin->getPluginName()); $this->assertEquals( @@ -24,25 +26,24 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { '{DAV:}expand-property', '{DAV:}principal-match', '{DAV:}principal-property-search', - '{DAV:}principal-search-property-set' + '{DAV:}principal-search-property-set', ], $aclPlugin->getSupportedReportSet('')); $this->assertEquals(['ACL'], $aclPlugin->getMethods('')); - $this->assertEquals( 'acl', $aclPlugin->getPluginInfo()['name'] ); } - function testGetFlatPrivilegeSet() { - + public function testGetFlatPrivilegeSet() + { $expected = [ '{DAV:}all' => [ - 'privilege' => '{DAV:}all', - 'abstract' => false, + 'privilege' => '{DAV:}all', + 'abstract' => false, 'aggregates' => [ '{DAV:}read', '{DAV:}write', @@ -50,8 +51,8 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { 'concrete' => '{DAV:}all', ], '{DAV:}read' => [ - 'privilege' => '{DAV:}read', - 'abstract' => false, + 'privilege' => '{DAV:}read', + 'abstract' => false, 'aggregates' => [ '{DAV:}read-acl', '{DAV:}read-current-user-privilege-set', @@ -59,20 +60,20 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { 'concrete' => '{DAV:}read', ], '{DAV:}read-acl' => [ - 'privilege' => '{DAV:}read-acl', - 'abstract' => false, + 'privilege' => '{DAV:}read-acl', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}read-acl', + 'concrete' => '{DAV:}read-acl', ], '{DAV:}read-current-user-privilege-set' => [ - 'privilege' => '{DAV:}read-current-user-privilege-set', - 'abstract' => false, + 'privilege' => '{DAV:}read-current-user-privilege-set', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}read-current-user-privilege-set', + 'concrete' => '{DAV:}read-current-user-privilege-set', ], '{DAV:}write' => [ - 'privilege' => '{DAV:}write', - 'abstract' => false, + 'privilege' => '{DAV:}write', + 'abstract' => false, 'aggregates' => [ '{DAV:}write-properties', '{DAV:}write-content', @@ -83,36 +84,35 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { 'concrete' => '{DAV:}write', ], '{DAV:}write-properties' => [ - 'privilege' => '{DAV:}write-properties', - 'abstract' => false, + 'privilege' => '{DAV:}write-properties', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}write-properties', + 'concrete' => '{DAV:}write-properties', ], '{DAV:}write-content' => [ - 'privilege' => '{DAV:}write-content', - 'abstract' => false, + 'privilege' => '{DAV:}write-content', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}write-content', + 'concrete' => '{DAV:}write-content', ], '{DAV:}unlock' => [ - 'privilege' => '{DAV:}unlock', - 'abstract' => false, + 'privilege' => '{DAV:}unlock', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}unlock', + 'concrete' => '{DAV:}unlock', ], '{DAV:}bind' => [ - 'privilege' => '{DAV:}bind', - 'abstract' => false, + 'privilege' => '{DAV:}bind', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}bind', + 'concrete' => '{DAV:}bind', ], '{DAV:}unbind' => [ - 'privilege' => '{DAV:}unbind', - 'abstract' => false, + 'privilege' => '{DAV:}unbind', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}unbind', + 'concrete' => '{DAV:}unbind', ], - ]; $plugin = new Plugin(); @@ -120,28 +120,24 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { $server = new DAV\Server(); $server->addPlugin($plugin); $this->assertEquals($expected, $plugin->getFlatPrivilegeSet('')); - } - function testCurrentUserPrincipalsNotLoggedIn() { - + public function testCurrentUserPrincipalsNotLoggedIn() + { $acl = new Plugin(); $acl->allowUnauthenticatedAccess = false; $server = new DAV\Server(); $server->addPlugin($acl); $this->assertEquals([], $acl->getCurrentUserPrincipals()); - } - function testCurrentUserPrincipalsSimple() { - + public function testCurrentUserPrincipalsSimple() + { $tree = [ - new DAV\SimpleCollection('principals', [ new MockPrincipal('admin', 'principals/admin'), - ]) - + ]), ]; $acl = new Plugin(); @@ -153,23 +149,20 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($auth); //forcing login - $auth->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $auth->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $this->assertEquals(['principals/admin'], $acl->getCurrentUserPrincipals()); - } - function testCurrentUserPrincipalsGroups() { - + public function testCurrentUserPrincipalsGroups() + { $tree = [ - new DAV\SimpleCollection('principals', [ new MockPrincipal('admin', 'principals/admin', ['principals/administrators', 'principals/everyone']), new MockPrincipal('administrators', 'principals/administrators', ['principals/groups'], ['principals/admin']), new MockPrincipal('everyone', 'principals/everyone', [], ['principals/admin']), new MockPrincipal('groups', 'principals/groups', [], ['principals/administrators']), - ]) - + ]), ]; $acl = new Plugin(); @@ -181,7 +174,7 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($auth); //forcing login - $auth->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $auth->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $expected = [ 'principals/admin', @@ -194,11 +187,10 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { // The second one should trigger the cache and be identical $this->assertEquals($expected, $acl->getCurrentUserPrincipals()); - } - function testGetACL() { - + public function testGetACL() + { $acl = [ [ 'principal' => 'principals/admin', @@ -210,7 +202,6 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { ], ]; - $tree = [ new MockACLNode('foo', $acl), ]; @@ -221,11 +212,10 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($aclPlugin); $this->assertEquals($acl, $aclPlugin->getACL('foo')); - } - function testGetCurrentUserPrivilegeSet() { - + public function testGetCurrentUserPrivilegeSet() + { $acl = [ [ 'principal' => 'principals/admin', @@ -241,14 +231,12 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { ], ]; - $tree = [ new MockACLNode('foo', $acl), new DAV\SimpleCollection('principals', [ new MockPrincipal('admin', 'principals/admin'), ]), - ]; $server = new DAV\Server($tree); @@ -260,7 +248,7 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($auth); //forcing login - $auth->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $auth->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $expected = [ '{DAV:}write', @@ -274,11 +262,10 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $aclPlugin->getCurrentUserPrivilegeSet('foo')); - } - function testCheckPrivileges() { - + public function testCheckPrivileges() + { $acl = [ [ 'principal' => 'principals/admin', @@ -294,14 +281,12 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { ], ]; - $tree = [ new MockACLNode('foo', $acl), new DAV\SimpleCollection('principals', [ new MockPrincipal('admin', 'principals/admin'), ]), - ]; $server = new DAV\Server($tree); @@ -316,6 +301,5 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { //$auth->beforeMethod('GET','/'); $this->assertFalse($aclPlugin->checkPrivileges('foo', ['{DAV:}read'], Plugin::R_PARENT, false)); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVServerTest.php b/vendor/sabre/dav/tests/Sabre/DAVServerTest.php index 35f240d23..982090d23 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVServerTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVServerTest.php @@ -1,10 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre; use Sabre\HTTP\Request; use Sabre\HTTP\Response; -use Sabre\HTTP\Sapi; /** * This class may be used as a basis for other webdav-related unittests. @@ -16,8 +17,8 @@ use Sabre\HTTP\Sapi; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { - +abstract class DAVServerTest extends \PHPUnit\Framework\TestCase +{ protected $setupCalDAV = false; protected $setupCardDAV = false; protected $setupACL = false; @@ -33,7 +34,7 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { /** * An array with calendars. Every calendar should have * - principaluri - * - uri + * - uri. */ protected $caldavCalendars = []; protected $caldavCalendarObjects = []; @@ -54,27 +55,27 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { protected $propertyStorageBackend; /** - * @var Sabre\CalDAV\Plugin + * @var \Sabre\CalDAV\Plugin */ protected $caldavPlugin; /** - * @var Sabre\CardDAV\Plugin + * @var \Sabre\CardDAV\Plugin */ protected $carddavPlugin; /** - * @var Sabre\DAVACL\Plugin + * @var \Sabre\DAVACL\Plugin */ protected $aclPlugin; /** - * @var Sabre\CalDAV\SharingPlugin + * @var \Sabre\CalDAV\SharingPlugin */ protected $caldavSharingPlugin; /** - * CalDAV scheduling plugin + * CalDAV scheduling plugin. * * @var CalDAV\Schedule\Plugin */ @@ -108,14 +109,13 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { */ protected $autoLogin = null; - function setUp() { - + public function setUp() + { $this->initializeEverything(); - } - function initializeEverything() { - + public function initializeEverything() + { $this->setUpBackends(); $this->setUpTree(); @@ -173,7 +173,6 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { $this->aclPlugin->adminPrincipals = ['principals/admin']; $this->server->addPlugin($this->aclPlugin); } - } /** @@ -187,11 +186,12 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { * the test. * * @param array|\Sabre\HTTP\Request $request - * @param int $expectedStatus + * @param int $expectedStatus + * * @return \Sabre\HTTP\Response */ - function request($request, $expectedStatus = null) { - + public function request($request, $expectedStatus = null) + { if (is_array($request)) { $request = HTTP\Request::createFromServerArray($request); } @@ -203,10 +203,10 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { if ($expectedStatus) { $responseBody = $expectedStatus !== $response->getStatus() ? $response->getBodyAsString() : ''; - $this->assertEquals($expectedStatus, $response->getStatus(), 'Incorrect HTTP status received for request. Response body: ' . $responseBody); + $this->assertEquals($expectedStatus, $response->getStatus(), 'Incorrect HTTP status received for request. Response body: '.$responseBody); } - return $this->server->httpResponse; + return $this->server->httpResponse; } /** @@ -215,9 +215,10 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { * * @param string $userName */ - function autoLogin($userName) { + public function autoLogin($userName) + { $authBackend = new DAV\Auth\Backend\Mock(); - $authBackend->setPrincipal('principals/' . $userName); + $authBackend->setPrincipal('principals/'.$userName); $this->authPlugin = new DAV\Auth\Plugin($authBackend); // If the auth plugin already exists, we're removing its hooks: @@ -227,14 +228,14 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { $this->server->addPlugin($this->authPlugin); // This will trigger the actual login procedure - $this->authPlugin->beforeMethod(new Request(), new Response()); + $this->authPlugin->beforeMethod(new Request('GET', '/'), new Response()); } /** * Override this to provide your own Tree for your test-case. */ - function setUpTree() { - + public function setUpTree() + { if ($this->setupCalDAV) { $this->tree[] = new CalDAV\CalendarRoot( $this->principalBackend, @@ -258,15 +259,12 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { ); } if ($this->setupFiles) { - $this->tree[] = new DAV\Mock\Collection('files'); - } - } - function setUpBackends() { - + public function setUpBackends() + { if ($this->setupCalDAVSharing && is_null($this->caldavBackend)) { $this->caldavBackend = new CalDAV\Backend\MockSharing($this->caldavCalendars, $this->caldavCalendarObjects); } @@ -289,18 +287,14 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { if ($this->setupLocks) { $this->locksBackend = new DAV\Locks\Backend\Mock(); } - if ($this->setupPropertyStorage) { + if ($this->setupPropertyStorage) { $this->propertyStorageBackend = new DAV\PropertyStorage\Backend\Mock(); } - } - - function assertHttpStatus($expectedStatus, HTTP\Request $req) { - + public function assertHttpStatus($expectedStatus, HTTP\Request $req) + { $resp = $this->request($req); - $this->assertEquals((int)$expectedStatus, (int)$resp->status, 'Incorrect HTTP status received: ' . $resp->body); - + $this->assertEquals((int) $expectedStatus, (int) $resp->status, 'Incorrect HTTP status received: '.$resp->body); } - } diff --git a/vendor/sabre/dav/tests/Sabre/HTTP/ResponseMock.php b/vendor/sabre/dav/tests/Sabre/HTTP/ResponseMock.php index eb486bf5b..c5357928a 100644 --- a/vendor/sabre/dav/tests/Sabre/HTTP/ResponseMock.php +++ b/vendor/sabre/dav/tests/Sabre/HTTP/ResponseMock.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\HTTP; /** - * HTTP Response Mock object + * HTTP Response Mock object. * * This class exists to make the transition to sabre/http easier. * @@ -11,12 +13,11 @@ namespace Sabre\HTTP; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ResponseMock extends Response { - +class ResponseMock extends Response +{ /** * Making these public. */ public $body; public $status; - } diff --git a/vendor/sabre/dav/tests/Sabre/TestUtil.php b/vendor/sabre/dav/tests/Sabre/TestUtil.php index 9df94915f..4e7ca2fc4 100644 --- a/vendor/sabre/dav/tests/Sabre/TestUtil.php +++ b/vendor/sabre/dav/tests/Sabre/TestUtil.php @@ -1,71 +1,66 @@ <?php -namespace Sabre; +declare(strict_types=1); -class TestUtil { +namespace Sabre; +class TestUtil +{ /** * This function deletes all the contents of the temporary directory. - * - * @return void */ - static function clearTempDir() { - + public static function clearTempDir() + { self::deleteTree(SABRE_TEMPDIR, false); - } - - private static function deleteTree($path, $deleteRoot = true) { - + private static function deleteTree($path, $deleteRoot = true) + { foreach (scandir($path) as $node) { - - if ($node == '.' || $node == '..') continue; - $myPath = $path . '/' . $node; + if ('.' == $node || '..' == $node) { + continue; + } + $myPath = $path.'/'.$node; if (is_file($myPath)) { unlink($myPath); } else { self::deleteTree($myPath); } - } if ($deleteRoot) { rmdir($path); } - } - static function getMySQLDB() { - + public static function getMySQLDB() + { try { $pdo = new \PDO(SABRE_MYSQLDSN, SABRE_MYSQLUSER, SABRE_MYSQLPASS); $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + return $pdo; } catch (\PDOException $e) { return null; } - } - static function getSQLiteDB() { - - $pdo = new \PDO('sqlite:' . SABRE_TEMPDIR . '/pdobackend'); + public static function getSQLiteDB() + { + $pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend'); $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - return $pdo; + return $pdo; } - static function getPgSqlDB() { - + public static function getPgSqlDB() + { //try { - $pdo = new \PDO(SABRE_PGSQLDSN); - $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - return $pdo; + $pdo = new \PDO(SABRE_PGSQLDSN); + $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + + return $pdo; //} catch (\PDOException $e) { // return null; //} - } - - } diff --git a/vendor/sabre/dav/tests/bootstrap.php b/vendor/sabre/dav/tests/bootstrap.php index 26eb32aa2..03e6006b9 100644 --- a/vendor/sabre/dav/tests/bootstrap.php +++ b/vendor/sabre/dav/tests/bootstrap.php @@ -1,38 +1,59 @@ <?php -set_include_path(__DIR__ . '/../lib/' . PATH_SEPARATOR . __DIR__ . PATH_SEPARATOR . get_include_path()); +declare(strict_types=1); -$autoLoader = include __DIR__ . '/../vendor/autoload.php'; +set_include_path(__DIR__.'/../lib/'.PATH_SEPARATOR.__DIR__.PATH_SEPARATOR.get_include_path()); + +$autoLoader = include __DIR__.'/../vendor/autoload.php'; // SabreDAV tests auto loading $autoLoader->add('Sabre\\', __DIR__); // VObject tests auto loading -$autoLoader->addPsr4('Sabre\\VObject\\', __DIR__ . '/../vendor/sabre/vobject/tests/VObject'); -$autoLoader->addPsr4('Sabre\\Xml\\', __DIR__ . '/../vendor/sabre/xml/tests/Sabre/Xml'); +$autoLoader->addPsr4('Sabre\\VObject\\', __DIR__.'/../vendor/sabre/vobject/tests/VObject'); +$autoLoader->addPsr4('Sabre\\Xml\\', __DIR__.'/../vendor/sabre/xml/tests/Sabre/Xml'); date_default_timezone_set('UTC'); +// List of variables that can be set by the environment +$environmentVars = [ + 'SABRE_MYSQLUSER', + 'SABRE_MYSQLPASS', + 'SABRE_MYSQLDSN', + 'SABRE_PGSQLDSN', +]; +foreach ($environmentVars as $var) { + if ($value = getenv($var)) { + define($var, $value); + } +} + $config = [ - 'SABRE_TEMPDIR' => dirname(__FILE__) . '/temp/', + 'SABRE_TEMPDIR' => dirname(__FILE__).'/temp/', 'SABRE_HASSQLITE' => in_array('sqlite', PDO::getAvailableDrivers()), - 'SABRE_HASMYSQL' => in_array('mysql', PDO::getAvailableDrivers()), - 'SABRE_HASPGSQL' => in_array('pgsql', PDO::getAvailableDrivers()), - 'SABRE_MYSQLDSN' => 'mysql:host=127.0.0.1;dbname=sabredav_test', + 'SABRE_HASMYSQL' => in_array('mysql', PDO::getAvailableDrivers()), + 'SABRE_HASPGSQL' => in_array('pgsql', PDO::getAvailableDrivers()), + 'SABRE_MYSQLDSN' => 'mysql:host=127.0.0.1;dbname=sabredav_test', 'SABRE_MYSQLUSER' => 'sabredav', 'SABRE_MYSQLPASS' => '', - 'SABRE_PGSQLDSN' => 'pgsql:host=localhost;dbname=sabredav_test;user=sabredav;password=sabredav', + 'SABRE_PGSQLDSN' => 'pgsql:host=localhost;dbname=sabredav_test;user=sabredav;password=sabredav', ]; -if (file_exists(__DIR__ . '/config.user.php')) { - include __DIR__ . '/config.user.php'; +if (file_exists(__DIR__.'/config.user.php')) { + include __DIR__.'/config.user.php'; foreach ($userConfig as $key => $value) { $config[$key] = $value; } } foreach ($config as $key => $value) { - if (!defined($key)) define($key, $value); + if (!defined($key)) { + define($key, $value); + } } -if (!file_exists(SABRE_TEMPDIR)) mkdir(SABRE_TEMPDIR); -if (file_exists('.sabredav')) unlink('.sabredav'); +if (!file_exists(SABRE_TEMPDIR)) { + mkdir(SABRE_TEMPDIR); +} +if (file_exists('.sabredav')) { + unlink('.sabredav'); +} |