From 1e1e1a431f931bf6d29c00a0a488fd58d4ec3698 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 31 Oct 2020 10:42:41 +0200 Subject: [PATCH 1/3] Minor cleanups --- app/controllers/api/account.php | 6 +- app/controllers/api/database.php | 9 +- app/controllers/api/functions.php | 18 +- app/controllers/api/projects.php | 36 ++- app/controllers/api/storage.php | 6 +- app/controllers/api/teams.php | 19 +- app/controllers/api/users.php | 6 +- composer.lock | 377 ++++++++++++++---------------- src/Appwrite/Utopia/Response.php | 26 +++ 9 files changed, 262 insertions(+), 241 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index e7f12088df..857d31ef88 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -116,8 +116,10 @@ App::post('/v1/account') ->setAttribute('roles', Authorization::getRoles()) ; - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($user, Response::MODEL_USER); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($user, Response::MODEL_USER) + ; }, ['request', 'response', 'project', 'projectDB', 'audits']); App::post('/v1/account/sessions') diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 7f32abb778..f86200ab83 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -79,8 +79,10 @@ App::post('/v1/database/collections') ->setParam('data', $data->getArrayCopy()) ; - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($data, Response::MODEL_COLLECTION); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($data, Response::MODEL_COLLECTION) + ; }, ['response', 'projectDB', 'audits']); App::get('/v1/database/collections') @@ -357,9 +359,8 @@ App::post('/v1/database/collections/:collectionId/documents') $response ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($data, Response::MODEL_ANY) ; - - $response->dynamic($data, Response::MODEL_ANY); }, ['response', 'projectDB', 'audits']); App::get('/v1/database/collections/:collectionId/documents') diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index a46e8f32a6..071cebfce8 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -60,8 +60,10 @@ App::post('/v1/functions') throw new Exception('Failed saving function to DB', 500); } - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($function, Response::MODEL_FUNCTION); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($function, Response::MODEL_FUNCTION) + ; }, ['response', 'projectDB']); App::get('/v1/functions') @@ -427,8 +429,10 @@ App::post('/v1/functions/:functionId/tags') ->setParam('storage', $tag->getAttribute('size', 0)) ; - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($tag, Response::MODEL_TAG); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($tag, Response::MODEL_TAG) + ; }, ['request', 'response', 'projectDB', 'usage']); App::get('/v1/functions/:functionId/tags') @@ -611,8 +615,10 @@ App::post('/v1/functions/:functionId/executions') 'trigger' => 'http', ]); - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($execution, Response::MODEL_EXECUTION); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($execution, Response::MODEL_EXECUTION) + ; }, ['response', 'project', 'projectDB']); App::get('/v1/functions/:functionId/executions') diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index c8b6aa19ae..fbcc563874 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -80,8 +80,10 @@ App::post('/v1/projects') $consoleDB->createNamespace($project->getId()); - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($project, Response::MODEL_PROJECT); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($project, Response::MODEL_PROJECT) + ; }, ['response', 'consoleDB', 'projectDB']); App::get('/v1/projects') @@ -485,8 +487,10 @@ App::post('/v1/projects/:projectId/webhooks') throw new Exception('Failed saving project to DB', 500); } - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($webhook, Response::MODEL_WEBHOOK); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($webhook, Response::MODEL_WEBHOOK) + ; }, ['response', 'consoleDB']); App::get('/v1/projects/:projectId/webhooks') @@ -664,8 +668,10 @@ App::post('/v1/projects/:projectId/keys') throw new Exception('Failed saving project to DB', 500); } - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($key, Response::MODEL_KEY); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($key, Response::MODEL_KEY) + ; }, ['response', 'consoleDB']); App::get('/v1/projects/:projectId/keys') @@ -857,8 +863,10 @@ App::post('/v1/projects/:projectId/tasks') ResqueScheduler::enqueueAt($next, 'v1-tasks', 'TasksV1', $task->getArrayCopy()); } - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($task, Response::MODEL_TASK); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($task, Response::MODEL_TASK) + ; }, ['response', 'consoleDB']); App::get('/v1/projects/:projectId/tasks') @@ -1059,8 +1067,10 @@ App::post('/v1/projects/:projectId/platforms') throw new Exception('Failed saving project to DB', 500); } - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($platform, Response::MODEL_PLATFORM); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($platform, Response::MODEL_PLATFORM) + ; }, ['response', 'consoleDB']); App::get('/v1/projects/:projectId/platforms') @@ -1249,8 +1259,10 @@ App::post('/v1/projects/:projectId/domains') throw new Exception('Failed saving project to DB', 500); } - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($domain, Response::MODEL_DOMAIN); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($domain, Response::MODEL_DOMAIN) + ; }, ['response', 'consoleDB']); App::get('/v1/projects/:projectId/domains') diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index f9fe7c6618..bd20fb569a 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -149,8 +149,10 @@ App::post('/v1/storage/files') ->setParam('storage', $sizeActual) ; - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($file, Response::MODEL_FILE); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($file, Response::MODEL_FILE) + ; }, ['request', 'response', 'user', 'projectDB', 'audits', 'usage']); App::get('/v1/storage/files') diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index fe17a42e8a..050eda1f50 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -81,8 +81,10 @@ App::post('/v1/teams') } } - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($team, Response::MODEL_TEAM); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($team, Response::MODEL_TEAM) + ; }, ['response', 'user', 'projectDB', 'mode']); App::get('/v1/teams') @@ -393,12 +395,13 @@ App::post('/v1/teams/:teamId/memberships') ->setParam('resource', 'teams/'.$teamId) ; - $response->setStatusCode(Response::STATUS_CODE_CREATED); - - $response->dynamic(new Document(\array_merge($membership->getArrayCopy(), [ - 'email' => $email, - 'name' => $name, - ])), Response::MODEL_MEMBERSHIP); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic(new Document(\array_merge($membership->getArrayCopy(), [ + 'email' => $email, + 'name' => $name, + ])), Response::MODEL_MEMBERSHIP) + ; }, ['response', 'project', 'user', 'projectDB', 'locale', 'audits', 'mails', 'mode']); App::get('/v1/teams/:teamId/memberships') diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index cf84053044..f519b79c8f 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -66,8 +66,10 @@ App::post('/v1/users') throw new Exception('Account already exists', 409); } - $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($user, Response::MODEL_USER); + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($user, Response::MODEL_USER) + ; }, ['response', 'projectDB']); App::get('/v1/users') diff --git a/composer.lock b/composer.lock index bb21ed0419..ab6b993a6c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7ad12180c132b3225874c7f18594409a", + "content-hash": "5f0e8470b46e87d70f3858b3f4ad9b30", "packages": [ { "name": "appwrite/php-clamav", @@ -51,77 +51,28 @@ ], "time": "2020-02-29T11:35:01+00:00" }, - { - "name": "bacon/bacon-qr-code", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/Bacon/BaconQrCode.git", - "reference": "add6d9ff97336b62f95a3b94f75cea4e085465b2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/add6d9ff97336b62f95a3b94f75cea4e085465b2", - "reference": "add6d9ff97336b62f95a3b94f75cea4e085465b2", - "shasum": "" - }, - "require": { - "dasprid/enum": "^1.0", - "ext-iconv": "*", - "php": "^7.1" - }, - "require-dev": { - "phly/keep-a-changelog": "^1.4", - "phpunit/phpunit": "^7 | ^8 | ^9", - "squizlabs/php_codesniffer": "^3.4" - }, - "suggest": { - "ext-imagick": "to generate QR code images" - }, - "type": "library", - "autoload": { - "psr-4": { - "BaconQrCode\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Ben Scholzen 'DASPRiD'", - "email": "mail@dasprids.de", - "homepage": "https://dasprids.de/", - "role": "Developer" - } - ], - "description": "BaconQrCode is a QR code generator for PHP.", - "homepage": "https://github.com/Bacon/BaconQrCode", - "time": "2020-07-30T16:40:58+00:00" - }, { "name": "chillerlan/php-qrcode", - "version": "4.1.0", + "version": "4.2.0", "source": { "type": "git", "url": "https://github.com/chillerlan/php-qrcode.git", - "reference": "2cecb32cf618319dd01d9bc1fa64dc6bb683df85" + "reference": "1972af7af51b203bc239d8fb94243f6ed2a1067a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/2cecb32cf618319dd01d9bc1fa64dc6bb683df85", - "reference": "2cecb32cf618319dd01d9bc1fa64dc6bb683df85", + "url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/1972af7af51b203bc239d8fb94243f6ed2a1067a", + "reference": "1972af7af51b203bc239d8fb94243f6ed2a1067a", "shasum": "" }, "require": { - "chillerlan/php-settings-container": "^2.0", + "chillerlan/php-settings-container": "^2.1", "ext-mbstring": "*", - "php": "^7.4" + "php": "^7.4 || ^8.0" }, "require-dev": { - "phan/phan": "^2.7", - "phpunit/phpunit": "^9.1", + "phan/phan": "^3.2.2", + "phpunit/phpunit": "^9.4", "setasign/fpdf": "^1.8.2" }, "suggest": { @@ -168,29 +119,29 @@ "type": "ko_fi" } ], - "time": "2020-06-04T17:07:12+00:00" + "time": "2020-10-07T14:41:07+00:00" }, { "name": "chillerlan/php-settings-container", - "version": "2.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/chillerlan/php-settings-container.git", - "reference": "75888345532373074fba482a6642c0f8cda996f0" + "reference": "90ab24a3dc09569bfa0f3dbc3d44bab3aaa2a6c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/75888345532373074fba482a6642c0f8cda996f0", - "reference": "75888345532373074fba482a6642c0f8cda996f0", + "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/90ab24a3dc09569bfa0f3dbc3d44bab3aaa2a6c5", + "reference": "90ab24a3dc09569bfa0f3dbc3d44bab3aaa2a6c5", "shasum": "" }, "require": { "ext-json": "*", - "php": "^7.4" + "php": "^7.4 || ^8.0" }, "require-dev": { - "phan/phan": "^2.6", - "phpunit/phpunit": "^9.1" + "phan/phan": "^3.2.2", + "phpunit/phpunit": "9.4" }, "type": "library", "autoload": { @@ -217,7 +168,13 @@ "container", "helper" ], - "time": "2020-04-16T16:56:44+00:00" + "funding": [ + { + "url": "https://ko-fi.com/codemasher", + "type": "ko_fi" + } + ], + "time": "2020-10-07T13:18:35+00:00" }, { "name": "colinmollenhour/credis", @@ -259,49 +216,6 @@ "homepage": "https://github.com/colinmollenhour/credis", "time": "2020-10-13T23:55:13+00:00" }, - { - "name": "dasprid/enum", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/DASPRiD/Enum.git", - "reference": "5abf82f213618696dda8e3bf6f64dd042d8542b2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/DASPRiD/Enum/zipball/5abf82f213618696dda8e3bf6f64dd042d8542b2", - "reference": "5abf82f213618696dda8e3bf6f64dd042d8542b2", - "shasum": "" - }, - "require-dev": { - "phpunit/phpunit": "^7 | ^8 | ^9", - "squizlabs/php_codesniffer": "^3.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "DASPRiD\\Enum\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Ben Scholzen 'DASPRiD'", - "email": "mail@dasprids.de", - "homepage": "https://dasprids.de/", - "role": "Developer" - } - ], - "description": "PHP 7.1 enum implementation", - "keywords": [ - "enum", - "map" - ], - "time": "2020-10-02T16:03:48+00:00" - }, { "name": "domnikl/statsd", "version": "3.0.2", @@ -858,6 +772,7 @@ "parser", "useragent" ], + "abandoned": "matomo/device-detector", "time": "2020-08-17T07:37:33+00:00" }, { @@ -1604,6 +1519,58 @@ "utopia" ], "time": "2020-10-24T08:51:37+00:00" + }, + { + "name": "utopia-php/swoole", + "version": "0.2.0", + "source": { + "type": "git", + "url": "https://github.com/utopia-php/swoole.git", + "reference": "bc9dd3e113e9b8cbbf54468524637f39b2deb861" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utopia-php/swoole/zipball/bc9dd3e113e9b8cbbf54468524637f39b2deb861", + "reference": "bc9dd3e113e9b8cbbf54468524637f39b2deb861", + "shasum": "" + }, + "require": { + "ext-swoole": "*", + "php": ">=7.3", + "utopia-php/framework": "0.*.*" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "swoole/ide-helper": "4.5.5", + "vimeo/psalm": "4.0.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Utopia\\Swoole\\": "src/Swoole" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eldad Fux", + "email": "team@appwrite.io" + } + ], + "description": "An extension for Utopia Framework to work with PHP Swoole as a PHP FPM alternative", + "keywords": [ + "framework", + "http", + "php", + "server", + "swoole", + "upf", + "utopia" + ], + "time": "2020-10-29T12:42:38+00:00" } ], "packages-dev": [ @@ -2828,19 +2795,19 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ed363c3ce393560a1c300dce0298bbf0f0528b13" + "reference": "7c0684ac5818c3a5a79d9dd9d85aac2aebdadb05" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ed363c3ce393560a1c300dce0298bbf0f0528b13", - "reference": "ed363c3ce393560a1c300dce0298bbf0f0528b13", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7c0684ac5818c3a5a79d9dd9d85aac2aebdadb05", + "reference": "7c0684ac5818c3a5a79d9dd9d85aac2aebdadb05", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.8", + "nikic/php-parser": "^4.10.2", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -2893,7 +2860,7 @@ "type": "github" } ], - "time": "2020-10-26T15:46:21+00:00" + "time": "2020-10-30T14:10:23+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2901,12 +2868,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "86daa943fbb765aa0129d16f84c5bf7aaec44582" + "reference": "437553634c79817d89b412cf2e6711ef1ccf6418" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/86daa943fbb765aa0129d16f84c5bf7aaec44582", - "reference": "86daa943fbb765aa0129d16f84c5bf7aaec44582", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/437553634c79817d89b412cf2e6711ef1ccf6418", + "reference": "437553634c79817d89b412cf2e6711ef1ccf6418", "shasum": "" }, "require": { @@ -2949,7 +2916,7 @@ "type": "github" } ], - "time": "2020-10-26T04:57:30+00:00" + "time": "2020-10-30T14:12:04+00:00" }, { "name": "phpunit/php-invoker", @@ -2957,12 +2924,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "dd5300fef2ede06687642585706f912c073a0cc5" + "reference": "27560ee0808c5ba9144ad228887e788c608c8f58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/dd5300fef2ede06687642585706f912c073a0cc5", - "reference": "dd5300fef2ede06687642585706f912c073a0cc5", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/27560ee0808c5ba9144ad228887e788c608c8f58", + "reference": "27560ee0808c5ba9144ad228887e788c608c8f58", "shasum": "" }, "require": { @@ -3008,7 +2975,7 @@ "type": "github" } ], - "time": "2020-10-26T04:57:38+00:00" + "time": "2020-10-30T14:12:14+00:00" }, { "name": "phpunit/php-text-template", @@ -3016,12 +2983,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "60c51e16ad53fc17844f6fd6e608e80d9743f320" + "reference": "2d6aa395e3f5a69ba3a5449d090cf7b845552081" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/60c51e16ad53fc17844f6fd6e608e80d9743f320", - "reference": "60c51e16ad53fc17844f6fd6e608e80d9743f320", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/2d6aa395e3f5a69ba3a5449d090cf7b845552081", + "reference": "2d6aa395e3f5a69ba3a5449d090cf7b845552081", "shasum": "" }, "require": { @@ -3063,7 +3030,7 @@ "type": "github" } ], - "time": "2020-10-26T05:38:01+00:00" + "time": "2020-10-30T14:12:53+00:00" }, { "name": "phpunit/php-timer", @@ -3071,12 +3038,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + "reference": "735b06b2ce91f813d4574d0671a4e8165c8ece9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/735b06b2ce91f813d4574d0671a4e8165c8ece9c", + "reference": "735b06b2ce91f813d4574d0671a4e8165c8ece9c", "shasum": "" }, "require": { @@ -3118,7 +3085,7 @@ "type": "github" } ], - "time": "2020-10-26T13:16:10+00:00" + "time": "2020-10-30T14:12:23+00:00" }, { "name": "phpunit/phpunit", @@ -3126,12 +3093,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "d3b55c36f95329c062e69f6c10441106cf712f7f" + "reference": "abbb373dfdc7be1c77a1a700da67f28a7013d2e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d3b55c36f95329c062e69f6c10441106cf712f7f", - "reference": "d3b55c36f95329c062e69f6c10441106cf712f7f", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/abbb373dfdc7be1c77a1a700da67f28a7013d2e7", + "reference": "abbb373dfdc7be1c77a1a700da67f28a7013d2e7", "shasum": "" }, "require": { @@ -3147,7 +3114,7 @@ "phar-io/version": "^3.0.2", "php": ">=7.3", "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2", + "phpunit/php-code-coverage": "^9.2.3", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -3217,7 +3184,7 @@ "type": "github" } ], - "time": "2020-10-26T06:27:31+00:00" + "time": "2020-10-30T14:20:26+00:00" }, { "name": "psr/container", @@ -3274,12 +3241,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "bb3529e836d10bd4d2713ae050a2c5251eb9ff3e" + "reference": "a8a95d7ddcf625e12c9eca502af7a2f72d6e3e7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/bb3529e836d10bd4d2713ae050a2c5251eb9ff3e", - "reference": "bb3529e836d10bd4d2713ae050a2c5251eb9ff3e", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/a8a95d7ddcf625e12c9eca502af7a2f72d6e3e7a", + "reference": "a8a95d7ddcf625e12c9eca502af7a2f72d6e3e7a", "shasum": "" }, "require": { @@ -3318,7 +3285,7 @@ "type": "github" } ], - "time": "2020-10-26T04:58:42+00:00" + "time": "2020-10-30T14:13:23+00:00" }, { "name": "sebastian/code-unit", @@ -3326,12 +3293,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + "reference": "97d3d265ae9e0692bc19553d0a28d2e99c6a13dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/97d3d265ae9e0692bc19553d0a28d2e99c6a13dc", + "reference": "97d3d265ae9e0692bc19553d0a28d2e99c6a13dc", "shasum": "" }, "require": { @@ -3370,7 +3337,7 @@ "type": "github" } ], - "time": "2020-10-26T13:08:54+00:00" + "time": "2020-10-30T14:10:33+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -3378,12 +3345,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "aed227b805d6b8d279d05cee266b46f5512b8ea4" + "reference": "b7b8338be2131558c2eaeb0ec0b62ee3885181a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/aed227b805d6b8d279d05cee266b46f5512b8ea4", - "reference": "aed227b805d6b8d279d05cee266b46f5512b8ea4", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/b7b8338be2131558c2eaeb0ec0b62ee3885181a8", + "reference": "b7b8338be2131558c2eaeb0ec0b62ee3885181a8", "shasum": "" }, "require": { @@ -3421,7 +3388,7 @@ "type": "github" } ], - "time": "2020-10-26T04:56:19+00:00" + "time": "2020-10-30T14:10:42+00:00" }, { "name": "sebastian/comparator", @@ -3429,12 +3396,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + "reference": "237324bd32872e15f51bc2eadac2a9e43e28409d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/237324bd32872e15f51bc2eadac2a9e43e28409d", + "reference": "237324bd32872e15f51bc2eadac2a9e43e28409d", "shasum": "" }, "require": { @@ -3491,7 +3458,7 @@ "type": "github" } ], - "time": "2020-10-26T15:49:45+00:00" + "time": "2020-10-30T14:10:53+00:00" }, { "name": "sebastian/complexity", @@ -3499,12 +3466,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + "reference": "3bd69c610bb8e2958f3289d1a9583514471b62e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/3bd69c610bb8e2958f3289d1a9583514471b62e6", + "reference": "3bd69c610bb8e2958f3289d1a9583514471b62e6", "shasum": "" }, "require": { @@ -3544,7 +3511,7 @@ "type": "github" } ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2020-10-30T14:13:03+00:00" }, { "name": "sebastian/diff", @@ -3552,12 +3519,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + "reference": "7b02596262b190492663ff4df9227100f70c7823" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7b02596262b190492663ff4df9227100f70c7823", + "reference": "7b02596262b190492663ff4df9227100f70c7823", "shasum": "" }, "require": { @@ -3606,7 +3573,7 @@ "type": "github" } ], - "time": "2020-10-26T13:10:38+00:00" + "time": "2020-10-30T14:11:04+00:00" }, { "name": "sebastian/environment", @@ -3614,12 +3581,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "621594614bd6158ea0c1d6af09c6e5af01d8b1e8" + "reference": "7a613938b2aa9c873233f810e6300bf06c42ca17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/621594614bd6158ea0c1d6af09c6e5af01d8b1e8", - "reference": "621594614bd6158ea0c1d6af09c6e5af01d8b1e8", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/7a613938b2aa9c873233f810e6300bf06c42ca17", + "reference": "7a613938b2aa9c873233f810e6300bf06c42ca17", "shasum": "" }, "require": { @@ -3665,7 +3632,7 @@ "type": "github" } ], - "time": "2020-10-26T04:56:46+00:00" + "time": "2020-10-30T14:11:15+00:00" }, { "name": "sebastian/exporter", @@ -3673,12 +3640,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "1c85999374d0f9e8c7c11ff1e93d0c75343eba8e" + "reference": "33fcbffef7131af7ee4ad12f52bf6a3d02124557" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/1c85999374d0f9e8c7c11ff1e93d0c75343eba8e", - "reference": "1c85999374d0f9e8c7c11ff1e93d0c75343eba8e", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/33fcbffef7131af7ee4ad12f52bf6a3d02124557", + "reference": "33fcbffef7131af7ee4ad12f52bf6a3d02124557", "shasum": "" }, "require": { @@ -3738,7 +3705,7 @@ "type": "github" } ], - "time": "2020-10-26T04:56:54+00:00" + "time": "2020-10-30T14:11:24+00:00" }, { "name": "sebastian/global-state", @@ -3746,12 +3713,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "a90ccbddffa067b51f574dea6eb25d5680839455" + "reference": "e9696869db3ba851de7221f4d6997b4262b623d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/a90ccbddffa067b51f574dea6eb25d5680839455", - "reference": "a90ccbddffa067b51f574dea6eb25d5680839455", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e9696869db3ba851de7221f4d6997b4262b623d9", + "reference": "e9696869db3ba851de7221f4d6997b4262b623d9", "shasum": "" }, "require": { @@ -3798,7 +3765,7 @@ "type": "github" } ], - "time": "2020-10-26T15:55:19+00:00" + "time": "2020-10-30T14:11:34+00:00" }, { "name": "sebastian/lines-of-code", @@ -3806,12 +3773,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "acf76492a65401babcf5283296fa510782783a7a" + "reference": "edc91041d25e5f667f5adf1deb0f96a11153575e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/acf76492a65401babcf5283296fa510782783a7a", - "reference": "acf76492a65401babcf5283296fa510782783a7a", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/edc91041d25e5f667f5adf1deb0f96a11153575e", + "reference": "edc91041d25e5f667f5adf1deb0f96a11153575e", "shasum": "" }, "require": { @@ -3851,7 +3818,7 @@ "type": "github" } ], - "time": "2020-10-26T17:03:56+00:00" + "time": "2020-10-30T14:13:13+00:00" }, { "name": "sebastian/object-enumerator", @@ -3859,12 +3826,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + "reference": "d913c474aa28f6646d5a899d18b546a9d8a94134" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/d913c474aa28f6646d5a899d18b546a9d8a94134", + "reference": "d913c474aa28f6646d5a899d18b546a9d8a94134", "shasum": "" }, "require": { @@ -3904,7 +3871,7 @@ "type": "github" } ], - "time": "2020-10-26T13:12:34+00:00" + "time": "2020-10-30T14:11:44+00:00" }, { "name": "sebastian/object-reflector", @@ -3912,12 +3879,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + "reference": "4acdc9cb8f4eae4da631c414ece1fff21d3578b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/4acdc9cb8f4eae4da631c414ece1fff21d3578b0", + "reference": "4acdc9cb8f4eae4da631c414ece1fff21d3578b0", "shasum": "" }, "require": { @@ -3955,7 +3922,7 @@ "type": "github" } ], - "time": "2020-10-26T13:14:26+00:00" + "time": "2020-10-30T14:11:55+00:00" }, { "name": "sebastian/recursion-context", @@ -3963,12 +3930,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "be9bb5ea038598dd67ac9d40c5c37205d73deff9" + "reference": "d09a5073917f11f0b1e2dce2443d91acb50d0671" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/be9bb5ea038598dd67ac9d40c5c37205d73deff9", - "reference": "be9bb5ea038598dd67ac9d40c5c37205d73deff9", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/d09a5073917f11f0b1e2dce2443d91acb50d0671", + "reference": "d09a5073917f11f0b1e2dce2443d91acb50d0671", "shasum": "" }, "require": { @@ -4014,7 +3981,7 @@ "type": "github" } ], - "time": "2020-10-26T13:20:23+00:00" + "time": "2020-10-30T14:12:33+00:00" }, { "name": "sebastian/resource-operations", @@ -4073,12 +4040,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "81cd61ab7bbf2de744aba0ea61fae32f721df3d2" + "reference": "d6eb978632b7b77cad85a9a655e5c3dbb9c7100c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/81cd61ab7bbf2de744aba0ea61fae32f721df3d2", - "reference": "81cd61ab7bbf2de744aba0ea61fae32f721df3d2", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/d6eb978632b7b77cad85a9a655e5c3dbb9c7100c", + "reference": "d6eb978632b7b77cad85a9a655e5c3dbb9c7100c", "shasum": "" }, "require": { @@ -4117,7 +4084,7 @@ "type": "github" } ], - "time": "2020-10-26T13:18:59+00:00" + "time": "2020-10-30T14:12:43+00:00" }, { "name": "sebastian/version", @@ -4170,16 +4137,16 @@ }, { "name": "swoole/ide-helper", - "version": "4.5.4", + "version": "4.5.5", "source": { "type": "git", "url": "https://github.com/swoole/ide-helper.git", - "reference": "3382a1844afb206cac064252f6b8b50115bf72bb" + "reference": "aefd9d15e00cf14b89a5ed87cfa3bd79c9889028" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swoole/ide-helper/zipball/3382a1844afb206cac064252f6b8b50115bf72bb", - "reference": "3382a1844afb206cac064252f6b8b50115bf72bb", + "url": "https://api.github.com/repos/swoole/ide-helper/zipball/aefd9d15e00cf14b89a5ed87cfa3bd79c9889028", + "reference": "aefd9d15e00cf14b89a5ed87cfa3bd79c9889028", "shasum": "" }, "require-dev": { @@ -4200,7 +4167,7 @@ } ], "description": "IDE help files for Swoole.", - "time": "2020-09-16T00:12:52+00:00" + "time": "2020-10-14T18:05:12+00:00" }, { "name": "symfony/console", @@ -4208,12 +4175,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "4f00061f0fe49fb7c836fc31d66f365d8bff32fa" + "reference": "f372360d0dfa520b23b91fc70e2bba6a232ac62d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/4f00061f0fe49fb7c836fc31d66f365d8bff32fa", - "reference": "4f00061f0fe49fb7c836fc31d66f365d8bff32fa", + "url": "https://api.github.com/repos/symfony/console/zipball/f372360d0dfa520b23b91fc70e2bba6a232ac62d", + "reference": "f372360d0dfa520b23b91fc70e2bba6a232ac62d", "shasum": "" }, "require": { @@ -4294,7 +4261,7 @@ "type": "tidelift" } ], - "time": "2020-10-24T12:08:07+00:00" + "time": "2020-10-29T07:35:47+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4973,12 +4940,12 @@ "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "78173b3c850e344cb8515fc2a05138d39a6c39e0" + "reference": "b163c7f71698165ccf13738ac77273b40d5776f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/78173b3c850e344cb8515fc2a05138d39a6c39e0", - "reference": "78173b3c850e344cb8515fc2a05138d39a6c39e0", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/b163c7f71698165ccf13738ac77273b40d5776f8", + "reference": "b163c7f71698165ccf13738ac77273b40d5776f8", "shasum": "" }, "require": { @@ -5040,7 +5007,7 @@ "type": "tidelift" } ], - "time": "2020-10-21T12:45:52+00:00" + "time": "2020-10-27T19:26:34+00:00" }, { "name": "vimeo/psalm", diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 22f2925e5e..cbfd53f3e4 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -215,14 +215,40 @@ class Response extends SwooleResponse /** * Validate response objects and outputs * the response according to given format type + * + * @param Document $document + * @param string $model + * + * return void */ public function dynamic(Document $document, string $model) { return $this->json($this->output($document, $model)); } + /** + * (Mocking method for avoiding IDE errors, remove when possible) + * + * Set status code + * + * Set HTTP response status code between available options. if status code is unknown an exception will be thrown + * + * @param int $code + * @return self + * @throws Exception + */ + public function setStatusCode(int $code = 200): self + { + return $this->setStatusCode($code); + } + /** * Generate valid response object from document data + * + * @param Document $document + * @param string $model + * + * return array */ public function output(Document $document, string $model): array { From db7d7dd89ed7d82d45f0f3a14990de02291abfd1 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 31 Oct 2020 11:24:17 +0200 Subject: [PATCH 2/3] Updated mock method --- src/Appwrite/Utopia/Response.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index cbfd53f3e4..60ce5fdcff 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -239,7 +239,8 @@ class Response extends SwooleResponse */ public function setStatusCode(int $code = 200): self { - return $this->setStatusCode($code); + $this->setStatusCode($code); + return $this; } /** From ecc32c725d1f28b82aebed4fbaecbc77ef04e018 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 31 Oct 2020 13:06:09 +0200 Subject: [PATCH 3/3] Added docblock to fix IDE errors --- src/Appwrite/Utopia/Response.php | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 60ce5fdcff..a1b3434461 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -35,6 +35,9 @@ use Appwrite\Utopia\Response\Model\Tag; use Appwrite\Utopia\Response\Model\Task; use Appwrite\Utopia\Response\Model\Webhook; +/** + * @method public function setStatusCode(int $code = 200): Response + */ class Response extends SwooleResponse { // General @@ -221,26 +224,9 @@ class Response extends SwooleResponse * * return void */ - public function dynamic(Document $document, string $model) + public function dynamic(Document $document, string $model): void { - return $this->json($this->output($document, $model)); - } - - /** - * (Mocking method for avoiding IDE errors, remove when possible) - * - * Set status code - * - * Set HTTP response status code between available options. if status code is unknown an exception will be thrown - * - * @param int $code - * @return self - * @throws Exception - */ - public function setStatusCode(int $code = 200): self - { - $this->setStatusCode($code); - return $this; + $this->json($this->output($document, $model)); } /**