From 72bfe3c9d04619a13943981a4b04e3b4a3427d0d Mon Sep 17 00:00:00 2001
From: Eldad Fux
Date: Mon, 31 Jan 2022 23:56:39 +0200
Subject: [PATCH 01/10] Updated namespaces, added server class
---
composer.json | 3 +-
composer.lock | 438 ++++++++++++++-----------
src/Adapter.php | 39 +++
src/Adapter/Swoole/Files.php | 176 ++++++++++
src/Adapter/Swoole/Request.php | 339 +++++++++++++++++++
src/Adapter/Swoole/Response.php | 148 +++++++++
src/Adapter/Swoole/Server.php | 72 ++++
src/App.php | 5 +-
src/Exception.php | 2 +-
src/Request.php | 2 +-
src/Response.php | 2 +-
src/Route.php | 2 +-
src/Server.php | 46 +++
src/Validator.php | 2 +-
src/Validator/ArrayList.php | 2 +-
src/Validator/Assoc.php | 2 +-
src/Validator/Boolean.php | 2 +-
src/Validator/FloatValidator.php | 2 +-
src/Validator/HexColor.php | 2 +-
src/Validator/Integer.php | 2 +-
src/Validator/JSON.php | 2 +-
src/Validator/Numeric.php | 2 +-
src/Validator/Range.php | 2 +-
src/Validator/Text.php | 2 +-
src/Validator/WhiteList.php | 2 +-
src/Validator/Wildcard.php | 2 +-
src/View.php | 2 +-
tests/AppTest.php | 2 +-
tests/RequestTest.php | 2 +-
tests/ResponseTest.php | 2 +-
tests/RouteTest.php | 2 +-
tests/Validator/ArrayListTest.php | 2 +-
tests/Validator/AssocTest.php | 2 +-
tests/Validator/BooleanTest.php | 2 +-
tests/Validator/FloatValidatorTest.php | 2 +-
tests/Validator/HexColorTest.php | 2 +-
tests/Validator/IntegerTest.php | 2 +-
tests/Validator/JSONTest.php | 2 +-
tests/Validator/NumericTest.php | 2 +-
tests/Validator/RangeTest.php | 2 +-
tests/Validator/TextTest.php | 2 +-
tests/Validator/WhiteListTest.php | 2 +-
tests/Validator/WildcardTest.php | 2 +-
tests/ViewTest.php | 2 +-
44 files changed, 1109 insertions(+), 227 deletions(-)
create mode 100644 src/Adapter.php
create mode 100644 src/Adapter/Swoole/Files.php
create mode 100644 src/Adapter/Swoole/Request.php
create mode 100644 src/Adapter/Swoole/Response.php
create mode 100644 src/Adapter/Swoole/Server.php
create mode 100644 src/Server.php
diff --git a/composer.json b/composer.json
index b4bdd8ad..1f7c812d 100755
--- a/composer.json
+++ b/composer.json
@@ -12,12 +12,13 @@
}
],
"autoload": {
- "psr-4": {"Utopia\\": "src/"}
+ "psr-4": {"Utopia\\HTTP\\": "src/"}
},
"require": {
"php": ">=7.3.0"
},
"require-dev": {
+ "swoole/ide-helper": "4.8.5",
"phpunit/phpunit": "^9.4",
"vimeo/psalm": "4.0.1"
}
diff --git a/composer.lock b/composer.lock
index afeebedb..a3943f4a 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,32 +4,32 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "1c9c7f35fec0d2bd5ae80707ccc74939",
+ "content-hash": "63a5aab14d1587d0a66334fb2046d7c1",
"packages": [],
"packages-dev": [
{
"name": "amphp/amp",
- "version": "v2.5.2",
+ "version": "v2.6.1",
"source": {
"type": "git",
"url": "https://github.com/amphp/amp.git",
- "reference": "efca2b32a7580087adb8aabbff6be1dc1bb924a9"
+ "reference": "c5fc66a78ee38d7ac9195a37bacaf940eb3f65ae"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/amphp/amp/zipball/efca2b32a7580087adb8aabbff6be1dc1bb924a9",
- "reference": "efca2b32a7580087adb8aabbff6be1dc1bb924a9",
+ "url": "https://api.github.com/repos/amphp/amp/zipball/c5fc66a78ee38d7ac9195a37bacaf940eb3f65ae",
+ "reference": "c5fc66a78ee38d7ac9195a37bacaf940eb3f65ae",
"shasum": ""
},
"require": {
- "php": ">=7"
+ "php": ">=7.1"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1",
"ext-json": "*",
"jetbrains/phpstorm-stubs": "^2019.3",
- "phpunit/phpunit": "^6.0.9 | ^7",
+ "phpunit/phpunit": "^7 | ^8 | ^9",
"psalm/phar": "^3.11@dev",
"react/promise": "^2"
},
@@ -86,7 +86,7 @@
"support": {
"irc": "irc://irc.freenode.org/amphp",
"issues": "https://github.com/amphp/amp/issues",
- "source": "https://github.com/amphp/amp/tree/v2.5.2"
+ "source": "https://github.com/amphp/amp/tree/v2.6.1"
},
"funding": [
{
@@ -94,7 +94,7 @@
"type": "github"
}
],
- "time": "2021-01-10T17:06:37+00:00"
+ "time": "2021-09-23T18:43:08+00:00"
},
{
"name": "amphp/byte-stream",
@@ -175,16 +175,16 @@
},
{
"name": "composer/package-versions-deprecated",
- "version": "1.11.99.2",
+ "version": "1.11.99.5",
"source": {
"type": "git",
"url": "https://github.com/composer/package-versions-deprecated.git",
- "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c"
+ "reference": "b4f54f74ef3453349c24a845d22392cd31e65f1d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/c6522afe5540d5fc46675043d3ed5a45a740b27c",
- "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c",
+ "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/b4f54f74ef3453349c24a845d22392cd31e65f1d",
+ "reference": "b4f54f74ef3453349c24a845d22392cd31e65f1d",
"shasum": ""
},
"require": {
@@ -228,7 +228,7 @@
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"support": {
"issues": "https://github.com/composer/package-versions-deprecated/issues",
- "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.2"
+ "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.5"
},
"funding": [
{
@@ -244,20 +244,20 @@
"type": "tidelift"
}
],
- "time": "2021-05-24T07:46:03+00:00"
+ "time": "2022-01-17T14:14:24+00:00"
},
{
"name": "composer/semver",
- "version": "3.2.5",
+ "version": "3.2.7",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
- "reference": "31f3ea725711245195f62e54ffa402d8ef2fdba9"
+ "reference": "deac27056b57e46faf136fae7b449eeaa71661ee"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/semver/zipball/31f3ea725711245195f62e54ffa402d8ef2fdba9",
- "reference": "31f3ea725711245195f62e54ffa402d8ef2fdba9",
+ "url": "https://api.github.com/repos/composer/semver/zipball/deac27056b57e46faf136fae7b449eeaa71661ee",
+ "reference": "deac27056b57e46faf136fae7b449eeaa71661ee",
"shasum": ""
},
"require": {
@@ -309,7 +309,7 @@
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/semver/issues",
- "source": "https://github.com/composer/semver/tree/3.2.5"
+ "source": "https://github.com/composer/semver/tree/3.2.7"
},
"funding": [
{
@@ -325,7 +325,7 @@
"type": "tidelift"
}
],
- "time": "2021-05-24T12:41:47+00:00"
+ "time": "2022-01-04T09:57:54+00:00"
},
{
"name": "composer/xdebug-handler",
@@ -709,16 +709,16 @@
},
{
"name": "nikic/php-parser",
- "version": "v4.10.5",
+ "version": "v4.13.2",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f"
+ "reference": "210577fe3cf7badcc5814d99455df46564f3c077"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4432ba399e47c66624bc73c8c0f811e5c109576f",
- "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077",
+ "reference": "210577fe3cf7badcc5814d99455df46564f3c077",
"shasum": ""
},
"require": {
@@ -759,9 +759,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
- "source": "https://github.com/nikic/PHP-Parser/tree/v4.10.5"
+ "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2"
},
- "time": "2021-05-03T19:11:20+00:00"
+ "time": "2021-11-30T19:35:32+00:00"
},
{
"name": "openlss/lib-array2xml",
@@ -818,16 +818,16 @@
},
{
"name": "phar-io/manifest",
- "version": "2.0.1",
+ "version": "2.0.3",
"source": {
"type": "git",
"url": "https://github.com/phar-io/manifest.git",
- "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133"
+ "reference": "97803eca37d319dfa7826cc2437fc020857acb53"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phar-io/manifest/zipball/85265efd3af7ba3ca4b2a2c34dbfc5788dd29133",
- "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133",
+ "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53",
+ "reference": "97803eca37d319dfa7826cc2437fc020857acb53",
"shasum": ""
},
"require": {
@@ -872,9 +872,9 @@
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"support": {
"issues": "https://github.com/phar-io/manifest/issues",
- "source": "https://github.com/phar-io/manifest/tree/master"
+ "source": "https://github.com/phar-io/manifest/tree/2.0.3"
},
- "time": "2020-06-27T14:33:11+00:00"
+ "time": "2021-07-20T11:28:43+00:00"
},
{
"name": "phar-io/version",
@@ -982,16 +982,16 @@
},
{
"name": "phpdocumentor/reflection-docblock",
- "version": "5.2.2",
+ "version": "5.3.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
- "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556"
+ "reference": "622548b623e81ca6d78b721c5e029f4ce664f170"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556",
- "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556",
+ "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170",
+ "reference": "622548b623e81ca6d78b721c5e029f4ce664f170",
"shasum": ""
},
"require": {
@@ -1002,7 +1002,8 @@
"webmozart/assert": "^1.9.1"
},
"require-dev": {
- "mockery/mockery": "~1.3.2"
+ "mockery/mockery": "~1.3.2",
+ "psalm/phar": "^4.8"
},
"type": "library",
"extra": {
@@ -1032,22 +1033,22 @@
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"support": {
"issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
- "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master"
+ "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0"
},
- "time": "2020-09-03T19:13:55+00:00"
+ "time": "2021-10-19T17:43:47+00:00"
},
{
"name": "phpdocumentor/type-resolver",
- "version": "1.4.0",
+ "version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
- "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0"
+ "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
- "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
+ "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706",
+ "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706",
"shasum": ""
},
"require": {
@@ -1055,7 +1056,8 @@
"phpdocumentor/reflection-common": "^2.0"
},
"require-dev": {
- "ext-tokenizer": "*"
+ "ext-tokenizer": "*",
+ "psalm/phar": "^4.8"
},
"type": "library",
"extra": {
@@ -1081,39 +1083,39 @@
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
- "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0"
+ "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0"
},
- "time": "2020-09-17T18:55:26+00:00"
+ "time": "2022-01-04T19:58:01+00:00"
},
{
"name": "phpspec/prophecy",
- "version": "1.13.0",
+ "version": "v1.15.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
- "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea"
+ "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea",
- "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea",
+ "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13",
+ "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.2",
- "php": "^7.2 || ~8.0, <8.1",
+ "php": "^7.2 || ~8.0, <8.2",
"phpdocumentor/reflection-docblock": "^5.2",
"sebastian/comparator": "^3.0 || ^4.0",
"sebastian/recursion-context": "^3.0 || ^4.0"
},
"require-dev": {
- "phpspec/phpspec": "^6.0",
+ "phpspec/phpspec": "^6.0 || ^7.0",
"phpunit/phpunit": "^8.0 || ^9.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.11.x-dev"
+ "dev-master": "1.x-dev"
}
},
"autoload": {
@@ -1148,29 +1150,29 @@
],
"support": {
"issues": "https://github.com/phpspec/prophecy/issues",
- "source": "https://github.com/phpspec/prophecy/tree/1.13.0"
+ "source": "https://github.com/phpspec/prophecy/tree/v1.15.0"
},
- "time": "2021-03-17T13:42:18+00:00"
+ "time": "2021-12-08T12:19:24+00:00"
},
{
"name": "phpunit/php-code-coverage",
- "version": "9.2.6",
+ "version": "9.2.10",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "f6293e1b30a2354e8428e004689671b83871edde"
+ "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde",
- "reference": "f6293e1b30a2354e8428e004689671b83871edde",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687",
+ "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"ext-xmlwriter": "*",
- "nikic/php-parser": "^4.10.2",
+ "nikic/php-parser": "^4.13.0",
"php": ">=7.3",
"phpunit/php-file-iterator": "^3.0.3",
"phpunit/php-text-template": "^2.0.2",
@@ -1219,7 +1221,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
- "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.6"
+ "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10"
},
"funding": [
{
@@ -1227,20 +1229,20 @@
"type": "github"
}
],
- "time": "2021-03-28T07:26:59+00:00"
+ "time": "2021-12-05T09:12:13+00:00"
},
{
"name": "phpunit/php-file-iterator",
- "version": "3.0.5",
+ "version": "3.0.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
- "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8"
+ "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8",
- "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
+ "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
"shasum": ""
},
"require": {
@@ -1279,7 +1281,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
- "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5"
+ "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6"
},
"funding": [
{
@@ -1287,7 +1289,7 @@
"type": "github"
}
],
- "time": "2020-09-28T05:57:25+00:00"
+ "time": "2021-12-02T12:48:52+00:00"
},
{
"name": "phpunit/php-invoker",
@@ -1472,16 +1474,16 @@
},
{
"name": "phpunit/phpunit",
- "version": "9.5.6",
+ "version": "9.5.13",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb"
+ "reference": "597cb647654ede35e43b137926dfdfef0fb11743"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb",
- "reference": "fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/597cb647654ede35e43b137926dfdfef0fb11743",
+ "reference": "597cb647654ede35e43b137926dfdfef0fb11743",
"shasum": ""
},
"require": {
@@ -1493,11 +1495,11 @@
"ext-xml": "*",
"ext-xmlwriter": "*",
"myclabs/deep-copy": "^1.10.1",
- "phar-io/manifest": "^2.0.1",
+ "phar-io/manifest": "^2.0.3",
"phar-io/version": "^3.0.2",
"php": ">=7.3",
"phpspec/prophecy": "^1.12.1",
- "phpunit/php-code-coverage": "^9.2.3",
+ "phpunit/php-code-coverage": "^9.2.7",
"phpunit/php-file-iterator": "^3.0.5",
"phpunit/php-invoker": "^3.1.1",
"phpunit/php-text-template": "^2.0.3",
@@ -1559,11 +1561,11 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
- "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.6"
+ "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.13"
},
"funding": [
{
- "url": "https://phpunit.de/donate.html",
+ "url": "https://phpunit.de/sponsors.html",
"type": "custom"
},
{
@@ -1571,26 +1573,31 @@
"type": "github"
}
],
- "time": "2021-06-23T05:14:38+00:00"
+ "time": "2022-01-24T07:33:35+00:00"
},
{
"name": "psr/container",
- "version": "1.1.1",
+ "version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
- "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
+ "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
- "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
+ "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
+ "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
"shasum": ""
},
"require": {
- "php": ">=7.2.0"
+ "php": ">=7.4.0"
},
"type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ },
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
@@ -1617,9 +1624,9 @@
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
- "source": "https://github.com/php-fig/container/tree/1.1.1"
+ "source": "https://github.com/php-fig/container/tree/2.0.2"
},
- "time": "2021-03-05T17:36:06+00:00"
+ "time": "2021-11-05T16:47:00+00:00"
},
{
"name": "psr/log",
@@ -2100,16 +2107,16 @@
},
{
"name": "sebastian/exporter",
- "version": "4.0.3",
+ "version": "4.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
- "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65"
+ "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65",
- "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65",
+ "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9",
+ "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9",
"shasum": ""
},
"require": {
@@ -2158,14 +2165,14 @@
}
],
"description": "Provides the functionality to export PHP variables for visualization",
- "homepage": "http://www.github.com/sebastianbergmann/exporter",
+ "homepage": "https://www.github.com/sebastianbergmann/exporter",
"keywords": [
"export",
"exporter"
],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
- "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3"
+ "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4"
},
"funding": [
{
@@ -2173,7 +2180,7 @@
"type": "github"
}
],
- "time": "2020-09-28T05:24:23+00:00"
+ "time": "2021-11-11T14:18:36+00:00"
},
{
"name": "sebastian/global-state",
@@ -2635,30 +2642,73 @@
],
"time": "2020-09-28T06:39:44+00:00"
},
+ {
+ "name": "swoole/ide-helper",
+ "version": "4.8.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/swoole/ide-helper.git",
+ "reference": "d03c707d4dc803228e93b4884c72949c4d28e8b8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/swoole/ide-helper/zipball/d03c707d4dc803228e93b4884c72949c4d28e8b8",
+ "reference": "d03c707d4dc803228e93b4884c72949c4d28e8b8",
+ "shasum": ""
+ },
+ "type": "library",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "Team Swoole",
+ "email": "team@swoole.com"
+ }
+ ],
+ "description": "IDE help files for Swoole.",
+ "support": {
+ "issues": "https://github.com/swoole/ide-helper/issues",
+ "source": "https://github.com/swoole/ide-helper/tree/4.8.5"
+ },
+ "funding": [
+ {
+ "url": "https://gitee.com/swoole/swoole?donate=true",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/swoole",
+ "type": "github"
+ }
+ ],
+ "time": "2021-12-24T22:44:20+00:00"
+ },
{
"name": "symfony/console",
- "version": "v5.3.2",
+ "version": "v5.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1"
+ "reference": "a2a86ec353d825c75856c6fd14fac416a7bdb6b8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/649730483885ff2ca99ca0560ef0e5f6b03f2ac1",
- "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1",
+ "url": "https://api.github.com/repos/symfony/console/zipball/a2a86ec353d825c75856c6fd14fac416a7bdb6b8",
+ "reference": "a2a86ec353d825c75856c6fd14fac416a7bdb6b8",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1",
+ "symfony/deprecation-contracts": "^2.1|^3",
"symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php73": "^1.8",
- "symfony/polyfill-php80": "^1.15",
- "symfony/service-contracts": "^1.1|^2",
- "symfony/string": "^5.1"
+ "symfony/polyfill-php73": "^1.9",
+ "symfony/polyfill-php80": "^1.16",
+ "symfony/service-contracts": "^1.1|^2|^3",
+ "symfony/string": "^5.1|^6.0"
},
"conflict": {
+ "psr/log": ">=3",
"symfony/dependency-injection": "<4.4",
"symfony/dotenv": "<5.1",
"symfony/event-dispatcher": "<4.4",
@@ -2666,16 +2716,16 @@
"symfony/process": "<4.4"
},
"provide": {
- "psr/log-implementation": "1.0"
+ "psr/log-implementation": "1.0|2.0"
},
"require-dev": {
- "psr/log": "~1.0",
- "symfony/config": "^4.4|^5.0",
- "symfony/dependency-injection": "^4.4|^5.0",
- "symfony/event-dispatcher": "^4.4|^5.0",
- "symfony/lock": "^4.4|^5.0",
- "symfony/process": "^4.4|^5.0",
- "symfony/var-dumper": "^4.4|^5.0"
+ "psr/log": "^1|^2",
+ "symfony/config": "^4.4|^5.0|^6.0",
+ "symfony/dependency-injection": "^4.4|^5.0|^6.0",
+ "symfony/event-dispatcher": "^4.4|^5.0|^6.0",
+ "symfony/lock": "^4.4|^5.0|^6.0",
+ "symfony/process": "^4.4|^5.0|^6.0",
+ "symfony/var-dumper": "^4.4|^5.0|^6.0"
},
"suggest": {
"psr/log": "For using the console logger",
@@ -2715,7 +2765,7 @@
"terminal"
],
"support": {
- "source": "https://github.com/symfony/console/tree/v5.3.2"
+ "source": "https://github.com/symfony/console/tree/v5.4.3"
},
"funding": [
{
@@ -2731,29 +2781,29 @@
"type": "tidelift"
}
],
- "time": "2021-06-12T09:42:48+00:00"
+ "time": "2022-01-26T16:28:35+00:00"
},
{
"name": "symfony/deprecation-contracts",
- "version": "v2.4.0",
+ "version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
- "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627"
+ "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627",
- "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627",
+ "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/c726b64c1ccfe2896cb7df2e1331c357ad1c8ced",
+ "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced",
"shasum": ""
},
"require": {
- "php": ">=7.1"
+ "php": ">=8.0.2"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.4-dev"
+ "dev-main": "3.0-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -2782,7 +2832,7 @@
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0"
+ "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.0"
},
"funding": [
{
@@ -2798,25 +2848,28 @@
"type": "tidelift"
}
],
- "time": "2021-03-23T23:28:01+00:00"
+ "time": "2021-11-01T23:48:49+00:00"
},
{
"name": "symfony/polyfill-ctype",
- "version": "v1.23.0",
+ "version": "v1.24.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
- "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce"
+ "reference": "30885182c981ab175d4d034db0f6f469898070ab"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce",
- "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce",
+ "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab",
+ "reference": "30885182c981ab175d4d034db0f6f469898070ab",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
+ "provide": {
+ "ext-ctype": "*"
+ },
"suggest": {
"ext-ctype": "For best performance"
},
@@ -2861,7 +2914,7 @@
"portable"
],
"support": {
- "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0"
+ "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0"
},
"funding": [
{
@@ -2877,20 +2930,20 @@
"type": "tidelift"
}
],
- "time": "2021-02-19T12:13:01+00:00"
+ "time": "2021-10-20T20:35:02+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
- "version": "v1.23.0",
+ "version": "v1.24.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
- "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab"
+ "reference": "81b86b50cf841a64252b439e738e97f4a34e2783"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/24b72c6baa32c746a4d0840147c9715e42bb68ab",
- "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/81b86b50cf841a64252b439e738e97f4a34e2783",
+ "reference": "81b86b50cf841a64252b439e738e97f4a34e2783",
"shasum": ""
},
"require": {
@@ -2942,7 +2995,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.0"
+ "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.24.0"
},
"funding": [
{
@@ -2958,11 +3011,11 @@
"type": "tidelift"
}
],
- "time": "2021-05-27T09:17:38+00:00"
+ "time": "2021-11-23T21:10:46+00:00"
},
{
"name": "symfony/polyfill-intl-normalizer",
- "version": "v1.23.0",
+ "version": "v1.24.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
@@ -3026,7 +3079,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0"
+ "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.24.0"
},
"funding": [
{
@@ -3046,21 +3099,24 @@
},
{
"name": "symfony/polyfill-mbstring",
- "version": "v1.23.0",
+ "version": "v1.24.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
- "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1"
+ "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2df51500adbaebdc4c38dea4c89a2e131c45c8a1",
- "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825",
+ "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
+ "provide": {
+ "ext-mbstring": "*"
+ },
"suggest": {
"ext-mbstring": "For best performance"
},
@@ -3106,7 +3162,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.0"
+ "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0"
},
"funding": [
{
@@ -3122,20 +3178,20 @@
"type": "tidelift"
}
],
- "time": "2021-05-27T09:27:20+00:00"
+ "time": "2021-11-30T18:21:41+00:00"
},
{
"name": "symfony/polyfill-php73",
- "version": "v1.23.0",
+ "version": "v1.24.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php73.git",
- "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010"
+ "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010",
- "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010",
+ "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5",
+ "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5",
"shasum": ""
},
"require": {
@@ -3185,7 +3241,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0"
+ "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0"
},
"funding": [
{
@@ -3201,20 +3257,20 @@
"type": "tidelift"
}
],
- "time": "2021-02-19T12:13:01+00:00"
+ "time": "2021-06-05T21:20:04+00:00"
},
{
"name": "symfony/polyfill-php80",
- "version": "v1.23.0",
+ "version": "v1.24.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
- "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0"
+ "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/eca0bf41ed421bed1b57c4958bab16aa86b757d0",
- "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0",
+ "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9",
+ "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9",
"shasum": ""
},
"require": {
@@ -3268,7 +3324,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.0"
+ "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0"
},
"funding": [
{
@@ -3284,25 +3340,28 @@
"type": "tidelift"
}
],
- "time": "2021-02-19T12:13:01+00:00"
+ "time": "2021-09-13T13:58:33+00:00"
},
{
"name": "symfony/service-contracts",
- "version": "v2.4.0",
+ "version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
- "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb"
+ "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb",
- "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb",
+ "url": "https://api.github.com/repos/symfony/service-contracts/zipball/36715ebf9fb9db73db0cb24263c79077c6fe8603",
+ "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
- "psr/container": "^1.1"
+ "php": ">=8.0.2",
+ "psr/container": "^2.0"
+ },
+ "conflict": {
+ "ext-psr": "<1.1|>=2"
},
"suggest": {
"symfony/service-implementation": ""
@@ -3310,7 +3369,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.4-dev"
+ "dev-main": "3.0-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -3347,7 +3406,7 @@
"standards"
],
"support": {
- "source": "https://github.com/symfony/service-contracts/tree/v2.4.0"
+ "source": "https://github.com/symfony/service-contracts/tree/v3.0.0"
},
"funding": [
{
@@ -3363,35 +3422,37 @@
"type": "tidelift"
}
],
- "time": "2021-04-01T10:43:52+00:00"
+ "time": "2021-11-04T17:53:12+00:00"
},
{
"name": "symfony/string",
- "version": "v5.3.3",
+ "version": "v6.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
- "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1"
+ "reference": "522144f0c4c004c80d56fa47e40e17028e2eefc2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/string/zipball/bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1",
- "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1",
+ "url": "https://api.github.com/repos/symfony/string/zipball/522144f0c4c004c80d56fa47e40e17028e2eefc2",
+ "reference": "522144f0c4c004c80d56fa47e40e17028e2eefc2",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
+ "php": ">=8.0.2",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-grapheme": "~1.0",
"symfony/polyfill-intl-normalizer": "~1.0",
- "symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php80": "~1.15"
+ "symfony/polyfill-mbstring": "~1.0"
+ },
+ "conflict": {
+ "symfony/translation-contracts": "<2.0"
},
"require-dev": {
- "symfony/error-handler": "^4.4|^5.0",
- "symfony/http-client": "^4.4|^5.0",
- "symfony/translation-contracts": "^1.1|^2",
- "symfony/var-exporter": "^4.4|^5.0"
+ "symfony/error-handler": "^5.4|^6.0",
+ "symfony/http-client": "^5.4|^6.0",
+ "symfony/translation-contracts": "^2.0|^3.0",
+ "symfony/var-exporter": "^5.4|^6.0"
},
"type": "library",
"autoload": {
@@ -3430,7 +3491,7 @@
"utf8"
],
"support": {
- "source": "https://github.com/symfony/string/tree/v5.3.3"
+ "source": "https://github.com/symfony/string/tree/v6.0.3"
},
"funding": [
{
@@ -3446,20 +3507,20 @@
"type": "tidelift"
}
],
- "time": "2021-06-27T11:44:38+00:00"
+ "time": "2022-01-02T09:55:41+00:00"
},
{
"name": "theseer/tokenizer",
- "version": "1.2.0",
+ "version": "1.2.1",
"source": {
"type": "git",
"url": "https://github.com/theseer/tokenizer.git",
- "reference": "75a63c33a8577608444246075ea0af0d052e452a"
+ "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a",
- "reference": "75a63c33a8577608444246075ea0af0d052e452a",
+ "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e",
+ "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e",
"shasum": ""
},
"require": {
@@ -3488,7 +3549,7 @@
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"support": {
"issues": "https://github.com/theseer/tokenizer/issues",
- "source": "https://github.com/theseer/tokenizer/tree/master"
+ "source": "https://github.com/theseer/tokenizer/tree/1.2.1"
},
"funding": [
{
@@ -3496,7 +3557,7 @@
"type": "github"
}
],
- "time": "2020-07-12T23:59:07+00:00"
+ "time": "2021-07-28T10:34:58+00:00"
},
{
"name": "vimeo/psalm",
@@ -3658,16 +3719,16 @@
},
{
"name": "webmozart/glob",
- "version": "4.3.0",
+ "version": "4.4.0",
"source": {
"type": "git",
"url": "https://github.com/webmozarts/glob.git",
- "reference": "06358fafde0f32edb4513f4fd88fe113a40c90ee"
+ "reference": "539b5dbc10021d3f9242e7a9e9b6b37843179e83"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/webmozarts/glob/zipball/06358fafde0f32edb4513f4fd88fe113a40c90ee",
- "reference": "06358fafde0f32edb4513f4fd88fe113a40c90ee",
+ "url": "https://api.github.com/repos/webmozarts/glob/zipball/539b5dbc10021d3f9242e7a9e9b6b37843179e83",
+ "reference": "539b5dbc10021d3f9242e7a9e9b6b37843179e83",
"shasum": ""
},
"require": {
@@ -3675,8 +3736,8 @@
"webmozart/path-util": "^2.2"
},
"require-dev": {
- "phpunit/phpunit": "^8.0",
- "symfony/filesystem": "^5.1"
+ "phpunit/phpunit": "^9.5",
+ "symfony/filesystem": "^5.3"
},
"type": "library",
"extra": {
@@ -3702,9 +3763,9 @@
"description": "A PHP implementation of Ant's glob.",
"support": {
"issues": "https://github.com/webmozarts/glob/issues",
- "source": "https://github.com/webmozarts/glob/tree/4.3.0"
+ "source": "https://github.com/webmozarts/glob/tree/4.4.0"
},
- "time": "2021-01-21T06:17:15+00:00"
+ "time": "2021-10-07T16:13:08+00:00"
},
{
"name": "webmozart/path-util",
@@ -3754,6 +3815,7 @@
"issues": "https://github.com/webmozart/path-util/issues",
"source": "https://github.com/webmozart/path-util/tree/2.3.0"
},
+ "abandoned": "symfony/filesystem",
"time": "2015-12-17T08:42:14+00:00"
}
],
@@ -3766,5 +3828,5 @@
"php": ">=7.3.0"
},
"platform-dev": [],
- "plugin-api-version": "2.1.0"
+ "plugin-api-version": "2.0.0"
}
diff --git a/src/Adapter.php b/src/Adapter.php
new file mode 100644
index 00000000..d829ba35
--- /dev/null
+++ b/src/Adapter.php
@@ -0,0 +1,39 @@
+
+ */
+abstract class Adapter
+{
+ protected string $host;
+ protected int $port;
+
+ function __construct(string $host = '0.0.0.0', int $port = 80) {
+ $this->host = $host;
+ $this->port = $port;
+ }
+
+ /**
+ * Starts the Server.
+ * @return void
+ */
+ public abstract function start(): void;
+
+ /**
+ * Shuts down the Server.
+ * @return void
+ */
+ public abstract function end(): void;
+}
\ No newline at end of file
diff --git a/src/Adapter/Swoole/Files.php b/src/Adapter/Swoole/Files.php
new file mode 100644
index 00000000..f59e5535
--- /dev/null
+++ b/src/Adapter/Swoole/Files.php
@@ -0,0 +1,176 @@
+ 'text/css',
+ 'js' => 'text/javascript',
+ 'svg' => 'image/svg+xml',
+ ];
+
+ /**
+ * Add MimeType
+ *
+ * @var string $mimeType
+ *
+ * @return void
+ */
+ public static function addMimeType(string $mimeType): void
+ {
+ self::$mimeTypes[$mimeType] = true;
+ }
+
+ /**
+ * Remove MimeType
+ *
+ * @var string $mimeType
+ *
+ * @return void
+ */
+ public static function removeMimeType(string $mimeType): void
+ {
+ if(isset(self::$mimeTypes[$mimeType])) {
+ unset(self::$mimeTypes[$mimeType]);
+ }
+ }
+
+ /**
+ * Get MimeType List
+ *
+ * @return array
+ */
+ public static function getMimeTypes(): array
+ {
+ return self::$mimeTypes;
+ }
+
+ /**
+ * Get Files Loaded Count
+ *
+ * @return int
+ */
+ public static function getCount(): int
+ {
+ return self::$count;
+ }
+
+ /**
+ * Load
+ *
+ * @var string $path
+ *
+ * @return void
+ */
+ public static function load(string $directory, string $root = null): void
+ {
+ if(!is_readable($directory)) {
+ throw new Exception('Failed to load directory: '.$directory);
+ }
+
+ $directory = realpath($directory);
+
+ $root = ($root) ? $root : $directory;
+
+ $handle = opendir($directory);
+
+ while ($path = readdir($handle)) {
+ $extension = pathinfo($path, PATHINFO_EXTENSION);
+
+ if (in_array($path, ['.', '..'])) {
+ continue;
+ }
+
+ if (in_array($extension, ['php', 'phtml'])) {
+ continue;
+ }
+
+ if(substr($path, 0, 1) === '.') {
+ continue;
+ }
+
+ if (is_dir($directory.'/'.$path)) {
+ self::load($directory.'/'.$path, $root);
+ continue;
+ }
+
+ self::$count++;
+
+ self::$loaded[substr($directory.'/'.$path , strlen($root))] = [
+ 'contents' => file_get_contents($directory.'/'.$path),
+ 'mimeType' => (array_key_exists($extension, self::$extensions))
+ ? self::$extensions[$extension]
+ : mime_content_type($directory.'/'.$path)
+ ];
+ }
+
+ closedir($handle);
+
+ if($directory === $root) {
+ echo '[Static Files] Loadded '.self::$count.' files'.PHP_EOL;
+ }
+ }
+
+ /**
+ * Is File Loaded
+ *
+ * @var string $uri
+ */
+ public static function isFileLoaded(string $uri): bool
+ {
+ if(!array_key_exists($uri, self::$loaded)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Get File Contants
+ *
+ * @var string $uri
+ */
+ public static function getFileContents(string $uri): string
+ {
+ if(!array_key_exists($uri, self::$loaded)) {
+ throw new Exception('File not found or not loaded: '.$uri);
+ }
+
+ return self::$loaded[$uri]['contents'];
+ }
+
+ /**
+ * Get File MimeType
+ *
+ * @var string $uri
+ */
+ public static function getFileMimeType(string $uri): string
+ {
+ if(!array_key_exists($uri, self::$loaded)) {
+ throw new Exception('File not found or not loaded: '.$uri);
+ }
+
+ return self::$loaded[$uri]['mimeType'];
+ }
+}
diff --git a/src/Adapter/Swoole/Request.php b/src/Adapter/Swoole/Request.php
new file mode 100644
index 00000000..7716842d
--- /dev/null
+++ b/src/Adapter/Swoole/Request.php
@@ -0,0 +1,339 @@
+swoole = $request;
+ }
+
+ /**
+ * Get Param
+ *
+ * Get param by current method name
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getParam(string $key, $default = null)
+ {
+ switch($this->getMethod()) {
+ case self::METHOD_GET:
+ return $this->getQuery($key, $default);
+ break;
+ case self::METHOD_POST:
+ case self::METHOD_PUT:
+ case self::METHOD_PATCH:
+ case self::METHOD_DELETE:
+ return $this->getPayload($key, $default);
+ break;
+ default:
+ return $this->getQuery($key, $default);
+ }
+ }
+
+ /**
+ * Get Params
+ *
+ * Get all params of current method
+ *
+ * @return array
+ */
+ public function getParams(): array
+ {
+ switch($this->getMethod()) {
+ case self::METHOD_GET:
+ return (!empty($this->swoole->get)) ? $this->swoole->get : [];
+ break;
+ case self::METHOD_POST:
+ case self::METHOD_PUT:
+ case self::METHOD_PATCH:
+ case self::METHOD_DELETE:
+ return $this->generateInput();
+ break;
+ default:
+ return (!empty($this->swoole->get)) ? $this->swoole->get : [];
+ }
+
+ return [];
+ }
+
+ /**
+ * Get Query
+ *
+ * Method for querying HTTP GET request parameters. If $key is not found $default value will be returned.
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getQuery(string $key, $default = null)
+ {
+ return (isset($this->swoole->get[$key])) ? $this->swoole->get[$key] : $default;
+ }
+
+ /**
+ * Get payload
+ *
+ * Method for querying HTTP request payload parameters. If $key is not found $default value will be returned.
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getPayload(string $key, $default = null)
+ {
+ $payload = $this->generateInput();
+
+ return (isset($payload[$key])) ? $payload[$key] : $default;
+ }
+
+ /**
+ * Get server
+ *
+ * Method for querying server parameters. If $key is not found $default value will be returned.
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getServer(string $key, $default = null)
+ {
+ return (isset($this->swoole->server) && isset($this->swoole->server[$key])) ? $this->swoole->server[$key] : $default;
+ }
+
+ /**
+ * Get IP
+ *
+ * Returns users IP address.
+ * Support HTTP_X_FORWARDED_FOR header usually return
+ * from different proxy servers or PHP default REMOTE_ADDR
+ */
+ public function getIP(): string
+ {
+ $ips = explode(',',$this->getHeader('x-forwarded-for', $this->getServer('remote_addr', '0.0.0.0')));
+ return trim($ips[0] ?? '');
+ }
+
+ /**
+ * Get Protocol
+ *
+ * Returns request protocol.
+ * Support HTTP_X_FORWARDED_PROTO header usually return
+ * from different proxy servers or PHP default REQUEST_SCHEME
+ *
+ * @return string
+ */
+ public function getProtocol(): string
+ {
+ $protocol = $this->getHeader('x-forwarded-proto', $this->getServer('server_protocol', 'https'));
+
+ if($protocol === 'HTTP/1.1') {
+ return 'http';
+ }
+
+ return $protocol;
+ }
+
+ /**
+ * Get Port
+ *
+ * Returns request port.
+ *
+ * @return string
+ */
+ public function getPort(): string
+ {
+ return $this->getHeader('x-forwarded-port', (string)\parse_url($this->getProtocol().'://'.$this->getHeader('x-forwarded-host', $this->getHeader('host')), PHP_URL_PORT));
+ }
+
+ /**
+ * Get Hostname
+ *
+ * Returns request hostname.
+ *
+ * @return string
+ */
+ public function getHostname(): string
+ {
+ return \parse_url($this->getProtocol().'://'.$this->getHeader('x-forwarded-host', $this->getHeader('host')), PHP_URL_HOST);
+ }
+
+ /**
+ * Get Method
+ *
+ * Return HTTP request method
+ *
+ * @return string
+ */
+ public function getMethod(): string
+ {
+ return $this->getServer('request_method', 'UNKNOWN');
+ }
+
+ /**
+ * Get URI
+ *
+ * Return HTTP request URI
+ *
+ * @return string
+ */
+ public function getURI(): string
+ {
+ return $this->getServer('request_uri', '');
+ }
+
+ /**
+ * Get Referer
+ *
+ * Return HTTP referer header
+ *
+ * @return string
+ */
+ public function getReferer(string $default = ''): string
+ {
+ return $this->getHeader('referer', '');
+ }
+
+ /**
+ * Get Origin
+ *
+ * Return HTTP origin header
+ *
+ * @return string
+ */
+ public function getOrigin(string $default = ''): string
+ {
+ return $this->getHeader('origin', $default);
+ }
+
+ /**
+ * Get User Agent
+ *
+ * Return HTTP user agent header
+ *
+ * @return string
+ */
+ public function getUserAgent(string $default = ''): string
+ {
+ return $this->getHeader('user-agent', $default);
+ }
+
+ /**
+ * Get Accept
+ *
+ * Return HTTP accept header
+ *
+ * @return string
+ */
+ public function getAccept(string $default = ''): string
+ {
+ return $this->getHeader('accept', $default);
+ }
+
+ /**
+ * Get files
+ *
+ * Method for querying upload files data. If $key is not found empty array will be returned.
+ *
+ * @param string $key
+ * @return array
+ */
+ public function getFiles($key): array
+ {
+ $key = strtolower($key);
+ return (isset($this->swoole->files[$key])) ? $this->swoole->files[$key] : [];
+ }
+
+ /**
+ * Get cookie
+ *
+ * Method for querying HTTP cookie parameters. If $key is not found $default value will be returned.
+ *
+ * @param string $key
+ * @param string $default
+ * @return string
+ */
+ public function getCookie(string $key, string $default = ''): string
+ {
+ $key = strtolower($key);
+ return (isset($this->swoole->cookie[$key])) ? $this->swoole->cookie[$key] : $default;
+ }
+
+ /**
+ * Get header
+ *
+ * Method for querying HTTP header parameters. If $key is not found $default value will be returned.
+ *
+ * @param string $key
+ * @param string $default
+ * @return string
+ */
+ public function getHeader(string $key, string $default = ''): string
+ {
+ return (isset($this->swoole->header[$key])) ? $this->swoole->header[$key] : $default;
+ }
+
+ /**
+ * Generate input
+ *
+ * Generate PHP input stream and parse it as an array in order to handle different content type of requests
+ *
+ * @return array
+ */
+ protected function generateInput(): array
+ {
+ if (null === $this->payload) {
+ $contentType = $this->getHeader('content-type');
+
+ // Get content-type without the charset
+ $length = strpos($contentType, ';');
+ $length = (empty($length)) ? strlen($contentType) : $length;
+ $contentType = substr($contentType, 0, $length);
+
+ switch ($contentType) {
+ case 'application/json':
+ $this->payload = json_decode($this->swoole->rawContent(), true);
+ break;
+
+ default:
+ $this->payload = $this->swoole->post;
+ break;
+ }
+
+ if(empty($this->payload)) { // Make sure we return same data type even if json payload is empty or failed
+ $this->payload = [];
+ }
+ }
+
+ return $this->payload;
+ }
+
+ /**
+ * Generate headers
+ *
+ * Parse request headers as an array for easy querying using the getHeader method
+ *
+ * @return array
+ */
+ protected function generateHeaders(): array
+ {
+ return $this->swoole->header;
+ }
+}
\ No newline at end of file
diff --git a/src/Adapter/Swoole/Response.php b/src/Adapter/Swoole/Response.php
new file mode 100644
index 00000000..07ee47f7
--- /dev/null
+++ b/src/Adapter/Swoole/Response.php
@@ -0,0 +1,148 @@
+ true,
+ 'text/css' => true,
+ 'text/javascript' => true,
+ 'application/javascript' => true,
+ 'text/html' => true,
+ 'text/html; charset=UTF-8' => true,
+ 'application/json' => true,
+ 'application/json; charset=UTF-8' => true,
+ 'image/svg+xml' => true,
+ 'application/xml+rss' => true,
+ ];
+
+ /**
+ * Response constructor.
+ */
+ public function __construct(SwooleResponse $response)
+ {
+ $this->swoole = $response;
+ parent::__construct(\microtime(true));
+ }
+
+ /**
+ * Output response
+ *
+ * Generate HTTP response output including the response header (+cookies) and body and prints them.
+ *
+ * @param string $body
+ * @param int $exit exit code or don't exit if code is null
+ *
+ * @return void
+ */
+ public function send(string $body = '', int $exit = null): void
+ {
+ if($this->sent) {
+ return;
+ }
+
+ $this->sent = true;
+
+ $this->addHeader('X-Debug-Speed', (string)(microtime(true) - $this->startTime));
+
+ $this
+ ->appendCookies()
+ ->appendHeaders()
+ ;
+
+ if(!$this->disablePayload) {
+
+ $chunk = 2000000; // Max chunk of 2 mb
+ $length = strlen($body);
+
+ $this->size = $this->size + strlen(implode("\n", $this->headers)) + $length;
+
+ if(array_key_exists(
+ $this->contentType,
+ $this->compressed
+ ) && ($length <= $chunk)) { // Dont compress with GZIP / Brotli if header is not listed and size is bigger than 2mb
+ $this->swoole->end($body);
+ }
+ else {
+ for ($i=0; $i < ceil($length / $chunk); $i++) {
+ $this->swoole->write(substr($body, ($i * $chunk), min((($i * $chunk) + $chunk), $length)));
+ }
+
+ $this->swoole->end();
+ }
+
+ $this->disablePayload();
+ }
+ else {
+ $this->swoole->end();
+ }
+ }
+
+ /**
+ * Append headers
+ *
+ * Iterating over response headers to generate them using native PHP header function.
+ * This method is also responsible for generating the response and content type headers.
+ *
+ * @return self
+ */
+ protected function appendHeaders(): self
+ {
+ // Send status code header
+ $this->swoole->status((string)$this->statusCode);
+
+ // Send content type header
+ $this
+ ->addHeader('Content-Type', $this->contentType)
+ ;
+
+ // Set application headers
+ foreach ($this->headers as $key => $value) {
+ $this->swoole->header($key, $value);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Append cookies
+ *
+ * Iterating over response cookies to generate them using native PHP cookie function.
+ *
+ * @return self
+ */
+ protected function appendCookies(): self
+ {
+ foreach ($this->cookies as $cookie) {
+ $this->swoole->cookie(
+ $cookie['name'],
+ $cookie['value'],
+ $cookie['expire'],
+ $cookie['path'],
+ $cookie['domain'],
+ $cookie['secure'],
+ $cookie['httponly'],
+ $cookie['samesite'],
+ );
+ }
+
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Adapter/Swoole/Server.php b/src/Adapter/Swoole/Server.php
new file mode 100644
index 00000000..cdf5d185
--- /dev/null
+++ b/src/Adapter/Swoole/Server.php
@@ -0,0 +1,72 @@
+
+ */
+class Server
+{
+ protected SwooleServer $server;
+ protected string $host;
+ protected int $port;
+
+ function __construct(string $host = '0.0.0.0', int $port = 80) {
+ $this->host = $host;
+ $this->port = $port;
+ $this->server = new SwooleServer($host, $port);
+ }
+
+ /**
+ * Starts the Server.
+ * @return void
+ */
+ public function start(): void
+ {
+
+ $this->server->on('start', function (Server $http) {
+ // $app = new App('UTC');
+ });
+
+ $this->server->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) {
+ $request = new Request($swooleRequest);
+ $response = new Response($swooleResponse);
+
+ if(Files::isFileLoaded($request->getURI())) {
+ $time = (60 * 60 * 24 * 365 * 2); // 45 days cache
+
+ return $response
+ ->setContentType(Files::getFileMimeType($request->getURI()))
+ ->addHeader('Cache-Control', 'public, max-age='.$time)
+ ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time).' GMT') // 45 days cache
+ ->send(Files::getFileContents($request->getURI()))
+ ;
+ }
+
+ $app = new App('UTC');
+
+ $app
+ ->run($request, $response);
+ });
+ }
+
+ /**
+ * Shuts down the Server.
+ * @return void
+ */
+ public function end(): void
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/App.php b/src/App.php
index bf8b4358..375c568c 100755
--- a/src/App.php
+++ b/src/App.php
@@ -9,7 +9,7 @@
* @author Appwrite Team
*/
-namespace Utopia;
+namespace Utopia\HTTP;
class App
{
@@ -770,5 +770,4 @@ public static function reset(): void
];
self::$sorted = false;
}
-
-}
+}
\ No newline at end of file
diff --git a/src/Exception.php b/src/Exception.php
index 88118f0f..f051369c 100644
--- a/src/Exception.php
+++ b/src/Exception.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia;
+namespace Utopia\HTTP;
class Exception extends \Exception
{
diff --git a/src/Request.php b/src/Request.php
index 3628aa8b..7c6a0aad 100755
--- a/src/Request.php
+++ b/src/Request.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia;
+namespace Utopia\HTTP;
class Request
{
diff --git a/src/Response.php b/src/Response.php
index d328534c..ebcaa1d3 100755
--- a/src/Response.php
+++ b/src/Response.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia;
+namespace Utopia\HTTP;
class Response
{
diff --git a/src/Route.php b/src/Route.php
index 95b5f9d5..e2c84286 100755
--- a/src/Route.php
+++ b/src/Route.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia;
+namespace Utopia\HTTP;
use Exception;
diff --git a/src/Server.php b/src/Server.php
new file mode 100644
index 00000000..3a21ba08
--- /dev/null
+++ b/src/Server.php
@@ -0,0 +1,46 @@
+
+ */
+class Server
+{
+ protected Adapter $adapter;
+
+ /**
+ * Creates an instance of a HTTP server.
+ * @param Adapter $adapter
+ */
+ public function __construct(Adapter $adapter)
+ {
+ $this->adapter = $adapter;
+ }
+
+ /**
+ * Start the HTTP server
+ *
+ * @return void
+ */
+ public function start(): void
+ {
+ }
+
+ /**
+ * Shuts down the WebSocket server.
+ * @return void
+ */
+ public function end(): void
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Validator.php b/src/Validator.php
index 6addfabe..aa330721 100755
--- a/src/Validator.php
+++ b/src/Validator.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia;
+namespace Utopia\HTTP;
abstract class Validator
{
diff --git a/src/Validator/ArrayList.php b/src/Validator/ArrayList.php
index 2ec0af41..68b23e90 100644
--- a/src/Validator/ArrayList.php
+++ b/src/Validator/ArrayList.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use Utopia\Validator;
diff --git a/src/Validator/Assoc.php b/src/Validator/Assoc.php
index de87e0c0..af0e5011 100644
--- a/src/Validator/Assoc.php
+++ b/src/Validator/Assoc.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use Utopia\Validator;
diff --git a/src/Validator/Boolean.php b/src/Validator/Boolean.php
index b2222106..b1cd629d 100644
--- a/src/Validator/Boolean.php
+++ b/src/Validator/Boolean.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use Utopia\Validator;
diff --git a/src/Validator/FloatValidator.php b/src/Validator/FloatValidator.php
index 8244a86b..c46d4909 100755
--- a/src/Validator/FloatValidator.php
+++ b/src/Validator/FloatValidator.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use Utopia\Validator;
diff --git a/src/Validator/HexColor.php b/src/Validator/HexColor.php
index 77c63990..528355fa 100644
--- a/src/Validator/HexColor.php
+++ b/src/Validator/HexColor.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use Utopia\Validator;
diff --git a/src/Validator/Integer.php b/src/Validator/Integer.php
index 01f4ad43..451681a7 100755
--- a/src/Validator/Integer.php
+++ b/src/Validator/Integer.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use Utopia\Validator;
diff --git a/src/Validator/JSON.php b/src/Validator/JSON.php
index 05fdd279..c3bcc6ae 100644
--- a/src/Validator/JSON.php
+++ b/src/Validator/JSON.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use Utopia\Validator;
diff --git a/src/Validator/Numeric.php b/src/Validator/Numeric.php
index 53e7887a..f0e87a25 100755
--- a/src/Validator/Numeric.php
+++ b/src/Validator/Numeric.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use Utopia\Validator;
diff --git a/src/Validator/Range.php b/src/Validator/Range.php
index 201648f5..4b480018 100755
--- a/src/Validator/Range.php
+++ b/src/Validator/Range.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
/**
* Range
diff --git a/src/Validator/Text.php b/src/Validator/Text.php
index 71b3d4ac..b4cab56c 100644
--- a/src/Validator/Text.php
+++ b/src/Validator/Text.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use Utopia\Validator;
diff --git a/src/Validator/WhiteList.php b/src/Validator/WhiteList.php
index 66cf22b0..bba1d32d 100755
--- a/src/Validator/WhiteList.php
+++ b/src/Validator/WhiteList.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use Utopia\Validator;
diff --git a/src/Validator/Wildcard.php b/src/Validator/Wildcard.php
index 42c2239d..0b6c866d 100644
--- a/src/Validator/Wildcard.php
+++ b/src/Validator/Wildcard.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use Utopia\Validator;
diff --git a/src/View.php b/src/View.php
index 02f31721..69a7acbf 100755
--- a/src/View.php
+++ b/src/View.php
@@ -10,7 +10,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia;
+namespace Utopia\HTTP;
use Exception;
diff --git a/tests/AppTest.php b/tests/AppTest.php
index 5691ddc6..d29a118f 100755
--- a/tests/AppTest.php
+++ b/tests/AppTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia;
+namespace Utopia\HTTP;
use PHPUnit\Framework\TestCase;
use Utopia\Validator\Text;
diff --git a/tests/RequestTest.php b/tests/RequestTest.php
index e5cc1174..7ff9af2d 100755
--- a/tests/RequestTest.php
+++ b/tests/RequestTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Tests;
+namespace Utopia\HTTP\Tests;
use PHPUnit\Framework\TestCase;
use Utopia\Request;
diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php
index 31a679c2..a4a4fd79 100755
--- a/tests/ResponseTest.php
+++ b/tests/ResponseTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia;
+namespace Utopia\HTTP;
use PHPUnit\Framework\TestCase;
diff --git a/tests/RouteTest.php b/tests/RouteTest.php
index 5593e3a7..5efca89a 100755
--- a/tests/RouteTest.php
+++ b/tests/RouteTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia;
+namespace Utopia\HTTP;
use PHPUnit\Framework\TestCase;
use Utopia\Validator\Text;
diff --git a/tests/Validator/ArrayListTest.php b/tests/Validator/ArrayListTest.php
index f3b56411..0a2aeee8 100755
--- a/tests/Validator/ArrayListTest.php
+++ b/tests/Validator/ArrayListTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Validator/AssocTest.php b/tests/Validator/AssocTest.php
index 0c17c5ce..b43167d8 100755
--- a/tests/Validator/AssocTest.php
+++ b/tests/Validator/AssocTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Validator/BooleanTest.php b/tests/Validator/BooleanTest.php
index ed2a1027..d063c674 100755
--- a/tests/Validator/BooleanTest.php
+++ b/tests/Validator/BooleanTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Validator/FloatValidatorTest.php b/tests/Validator/FloatValidatorTest.php
index 817b1ab9..a5d42736 100755
--- a/tests/Validator/FloatValidatorTest.php
+++ b/tests/Validator/FloatValidatorTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Validator/HexColorTest.php b/tests/Validator/HexColorTest.php
index 3a65e59a..676cf750 100755
--- a/tests/Validator/HexColorTest.php
+++ b/tests/Validator/HexColorTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Validator/IntegerTest.php b/tests/Validator/IntegerTest.php
index efe68f3e..8c3d98de 100755
--- a/tests/Validator/IntegerTest.php
+++ b/tests/Validator/IntegerTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Validator/JSONTest.php b/tests/Validator/JSONTest.php
index 695bdf79..a0458ffa 100755
--- a/tests/Validator/JSONTest.php
+++ b/tests/Validator/JSONTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Validator/NumericTest.php b/tests/Validator/NumericTest.php
index 948b0aff..dd4fbb72 100755
--- a/tests/Validator/NumericTest.php
+++ b/tests/Validator/NumericTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Validator/RangeTest.php b/tests/Validator/RangeTest.php
index 05593288..b750dfcf 100755
--- a/tests/Validator/RangeTest.php
+++ b/tests/Validator/RangeTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Validator/TextTest.php b/tests/Validator/TextTest.php
index f99dbaa8..207688eb 100755
--- a/tests/Validator/TextTest.php
+++ b/tests/Validator/TextTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Validator/WhiteListTest.php b/tests/Validator/WhiteListTest.php
index fcf2e97d..d6abbeee 100755
--- a/tests/Validator/WhiteListTest.php
+++ b/tests/Validator/WhiteListTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Validator/WildcardTest.php b/tests/Validator/WildcardTest.php
index fb6c66f1..4ce4a3d7 100644
--- a/tests/Validator/WildcardTest.php
+++ b/tests/Validator/WildcardTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia\Validator;
+namespace Utopia\HTTP\Validator;
use PHPUnit\Framework\TestCase;
diff --git a/tests/ViewTest.php b/tests/ViewTest.php
index 15203889..a25589da 100755
--- a/tests/ViewTest.php
+++ b/tests/ViewTest.php
@@ -11,7 +11,7 @@
* @license The MIT License (MIT)
*/
-namespace Utopia;
+namespace Utopia\HTTP;
use PHPUnit\Framework\TestCase;
From 222bd8c717d15f8ada4dc3ffdb9c2eebf927bd6a Mon Sep 17 00:00:00 2001
From: Eldad Fux
Date: Tue, 1 Feb 2022 00:52:43 +0200
Subject: [PATCH 02/10] Added request and response adapters
---
src/Adapter/FPM/Request.php | 361 +++++++++++++++++++++++++++++++++
src/Adapter/FPM/Response.php | 111 ++++++++++
src/Adapter/Swoole/Request.php | 13 ++
src/Adapter/Swoole/Server.php | 1 +
src/Request.php | 209 +++----------------
src/Response.php | 70 +------
6 files changed, 522 insertions(+), 243 deletions(-)
create mode 100755 src/Adapter/FPM/Request.php
create mode 100755 src/Adapter/FPM/Response.php
diff --git a/src/Adapter/FPM/Request.php b/src/Adapter/FPM/Request.php
new file mode 100755
index 00000000..1405380a
--- /dev/null
+++ b/src/Adapter/FPM/Request.php
@@ -0,0 +1,361 @@
+
+ * @license The MIT License (MIT)
+ */
+
+namespace Utopia\HTTP\Adapter\FPM;
+
+use Utopia\HTTP\Request as HTTPRequest;
+
+class Request extends HTTPRequest
+{
+ /**
+ * Get Param
+ *
+ * Get param by current method name
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getParam(string $key, $default = null)
+ {
+ switch ($this->getServer('REQUEST_METHOD', '')) {
+ case self::METHOD_GET:
+ return $this->getQuery($key, $default);
+ break;
+ case self::METHOD_POST:
+ case self::METHOD_PUT:
+ case self::METHOD_PATCH:
+ case self::METHOD_DELETE:
+ return $this->getPayload($key, $default);
+ break;
+ default:
+ return $this->getQuery($key, $default);
+ }
+ }
+
+ /**
+ * Get Params
+ *
+ * Get all params of current method
+ *
+ * @return array
+ */
+ public function getParams(): array
+ {
+ switch ($this->getServer('REQUEST_METHOD', '')) {
+ case self::METHOD_GET:
+ return $_GET;
+ break;
+ case self::METHOD_POST:
+ case self::METHOD_PUT:
+ case self::METHOD_PATCH:
+ case self::METHOD_DELETE:
+ return $this->generateInput();
+ break;
+ default:
+ return $_GET;
+ }
+ }
+
+ /**
+ * Get Query
+ *
+ * Method for querying HTTP GET request parameters. If $key is not found $default value will be returned.
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getQuery(string $key, $default = null)
+ {
+ return (isset($_GET[$key])) ? $_GET[$key] : $default;
+ }
+
+ /**
+ * Get payload
+ *
+ * Method for querying HTTP request payload parameters. If $key is not found $default value will be returned.
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getPayload(string $key, $default = null)
+ {
+ $payload = $this->generateInput();
+
+ return (isset($payload[$key])) ? $payload[$key] : $default;
+ }
+
+ /**
+ * Get server
+ *
+ * Method for querying server parameters. If $key is not found $default value will be returned.
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getServer(string $key, $default = null)
+ {
+ return (isset($_SERVER[$key])) ? $_SERVER[$key] : $default;
+ }
+
+ /**
+ * Get IP
+ *
+ * Returns users IP address.
+ * Support HTTP_X_FORWARDED_FOR header usually return
+ * from different proxy servers or PHP default REMOTE_ADDR
+ *
+ * @return string
+ */
+ public function getIP(): string
+ {
+ $ips = explode(',',$this->getHeader('HTTP_X_FORWARDED_FOR', $this->getServer('REMOTE_ADDR', '0.0.0.0')));
+ return trim($ips[0] ?? '');
+ }
+
+ /**
+ * Get Protocol
+ *
+ * Returns request protocol.
+ * Support HTTP_X_FORWARDED_PROTO header usually return
+ * from different proxy servers or PHP default REQUEST_SCHEME
+ *
+ * @return string
+ */
+ public function getProtocol(): string
+ {
+ return $this->getServer('HTTP_X_FORWARDED_PROTO', $this->getServer('REQUEST_SCHEME', 'https'));
+ }
+
+ /**
+ * Get Port
+ *
+ * Returns request port.
+ *
+ * @return string
+ */
+ public function getPort(): string
+ {
+ return (string) \parse_url($this->getProtocol().'://'.$this->getServer('HTTP_HOST', ''), PHP_URL_PORT);
+ }
+
+ /**
+ * Get Hostname
+ *
+ * Returns request hostname.
+ *
+ * @return string
+ */
+ public function getHostname(): string
+ {
+ return (string) \parse_url($this->getProtocol().'://'.$this->getServer('HTTP_HOST', ''), PHP_URL_HOST);
+ }
+
+ /**
+ * Get Method
+ *
+ * Return HTTP request method
+ *
+ * @return string
+ */
+ public function getMethod(): string
+ {
+ return $this->getServer('REQUEST_METHOD', 'UNKNOWN');
+ }
+
+ /**
+ * Get URI
+ *
+ * Return HTTP request URI
+ *
+ * @return string
+ */
+ public function getURI(): string
+ {
+ return $this->getServer('REQUEST_URI', '');
+ }
+
+ /**
+ * Get files
+ *
+ * Method for querying upload files data. If $key is not found empty array will be returned.
+ *
+ * @param string $key
+ * @return array
+ */
+ public function getFiles(string $key): array
+ {
+ return (isset($_FILES[$key])) ? $_FILES[$key] : [];
+ }
+
+ /**
+ * Get Referer
+ *
+ * Return HTTP referer header
+ *
+ * @return string
+ */
+ public function getReferer(string $default = ''): string
+ {
+ return $this->getServer('HTTP_REFERER', $default);
+ }
+
+ /**
+ * Get Origin
+ *
+ * Return HTTP origin header
+ *
+ * @return string
+ */
+ public function getOrigin(string $default = ''): string
+ {
+ return $this->getServer('HTTP_ORIGIN', $default);
+ }
+
+ /**
+ * Get User Agent
+ *
+ * Return HTTP user agent header
+ *
+ * @return string
+ */
+ public function getUserAgent(string $default = ''): string
+ {
+ return $this->getServer('HTTP_USER_AGENT', $default);
+ }
+
+ /**
+ * Get Accept
+ *
+ * Return HTTP accept header
+ *
+ * @return string
+ */
+ public function getAccept(string $default = ''): string
+ {
+ return $this->getServer('HTTP_ACCEPT', $default);
+ }
+
+ /**
+ * Get cookie
+ *
+ * Method for querying HTTP cookie parameters. If $key is not found $default value will be returned.
+ *
+ * @param string $key
+ * @param string $default
+ * @return string
+ */
+ public function getCookie(string $key, string $default = ''): string
+ {
+ return (isset($_COOKIE[$key])) ? $_COOKIE[$key] : $default;
+ }
+
+ /**
+ * Get header
+ *
+ * Method for querying HTTP header parameters. If $key is not found $default value will be returned.
+ *
+ * @param string $key
+ * @param string $default
+ * @return string
+ */
+ public function getHeader(string $key, string $default = ''): string
+ {
+ $headers = $this->generateHeaders();
+
+ return (isset($headers[$key])) ? $headers[$key] : $default;
+ }
+
+ /**
+ * Get Request Size
+ *
+ * Returns request size in bytes
+ *
+ * @return int
+ */
+ public function getSize(): int
+ {
+ return \mb_strlen(\implode("\n", $this->generateHeaders()), '8bit') + \mb_strlen(\file_get_contents('php://input'), '8bit');
+ }
+
+ /**
+ * Generate input
+ *
+ * Generate PHP input stream and parse it as an array in order to handle different content type of requests
+ *
+ * @return array
+ */
+ protected function generateInput(): array
+ {
+ if (null === $this->payload) {
+ $contentType = $this->getHeader('content-type');
+
+ // Get content-type without the charset
+ $length = \strpos($contentType, ';');
+ $length = (empty($length)) ? \strlen($contentType) : $length;
+ $contentType = \substr($contentType, 0, $length);
+
+ switch ($contentType) {
+ case 'application/json':
+ $this->payload = \json_decode(\file_get_contents('php://input'), true);
+ break;
+
+ default:
+ $this->payload = $_POST;
+ break;
+ }
+
+ if (empty($this->payload)) { // Make sure we return same data type even if json payload is empty or failed
+ $this->payload = [];
+ }
+ }
+
+ return $this->payload;
+ }
+
+ /**
+ * Generate headers
+ *
+ * Parse request headers as an array for easy querying using the getHeader method
+ *
+ * @return array
+ */
+ protected function generateHeaders(): array
+ {
+ if (null === $this->headers) {
+ /**
+ * Fallback for older PHP versions
+ * that do not support generateHeaders
+ */
+ if (!\function_exists('getallheaders')) {
+ $headers = [];
+
+ foreach ($_SERVER as $name => $value) {
+ if (\substr($name, 0, 5) == 'HTTP_') {
+ $headers[\str_replace(' ', '-', \strtolower(\str_replace('_', ' ', \substr($name, 5))))] = $value;
+ }
+ }
+
+ $this->headers = $headers;
+
+ return $this->headers;
+ }
+
+ $this->headers = array_change_key_case(getallheaders());
+ }
+
+ return $this->headers;
+ }
+}
diff --git a/src/Adapter/FPM/Response.php b/src/Adapter/FPM/Response.php
new file mode 100755
index 00000000..6f170a61
--- /dev/null
+++ b/src/Adapter/FPM/Response.php
@@ -0,0 +1,111 @@
+
+ * @license The MIT License (MIT)
+ */
+
+namespace Utopia\HTTP\Adapter\FPM;
+
+use Utopia\HTTP\Response as HTTPResponse;
+
+class Response extends HTTPResponse
+{
+ /**
+ * Output response
+ *
+ * Generate HTTP response output including the response header (+cookies) and body and prints them.
+ *
+ * @param string $body
+ * @param int $exit exit code or don't exit if code is null
+ *
+ * @return void
+ */
+ public function send(string $body = '', int $exit = null): void
+ {
+ if($this->sent) {
+ return;
+ }
+
+ $this->sent = true;
+
+ $this->addHeader('X-Debug-Speed', (string)(\microtime(true) - $this->startTime));
+
+ $this
+ ->appendCookies()
+ ->appendHeaders()
+ ;
+
+ if (!$this->disablePayload) {
+ $this->size = $this->size + \mb_strlen(\implode("\n", \headers_list())) + \mb_strlen($body, '8bit');
+
+ echo $body;
+
+ $this->disablePayload();
+ }
+
+ if (!\is_null($exit)) {
+ exit($exit); // Exit with code
+ }
+ }
+
+ /**
+ * Append headers
+ *
+ * Iterating over response headers to generate them using native PHP header function.
+ * This method is also responsible for generating the response and content type headers.
+ *
+ * @return self
+ */
+ protected function appendHeaders(): self
+ {
+ // Send status code header
+ \http_response_code($this->statusCode);
+
+ // Send content type header
+ if (!empty($this->contentType)) {
+ $this
+ ->addHeader('Content-Type', $this->contentType)
+ ;
+ }
+
+ // Set application headers
+ foreach ($this->headers as $key => $value) {
+ \header($key . ': ' . $value);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Append cookies
+ *
+ * Iterating over response cookies to generate them using native PHP cookie function.
+ *
+ * @return self
+ */
+ protected function appendCookies(): self
+ {
+ foreach ($this->cookies as $cookie) {
+ if (\version_compare(PHP_VERSION, '7.3.0', '<')) {
+ \setcookie($cookie['name'], $cookie['value'], $cookie['expire'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
+ } else {
+ \setcookie($cookie['name'], $cookie['value'], [
+ 'expires' => $cookie['expire'],
+ 'path' => $cookie['path'],
+ 'domain' => $cookie['domain'],
+ 'secure' => $cookie['secure'],
+ 'httponly' => $cookie['httponly'],
+ 'samesite' => $cookie['samesite'],
+ ]);
+ }
+ }
+
+ return $this;
+ }
+}
diff --git a/src/Adapter/Swoole/Request.php b/src/Adapter/Swoole/Request.php
index 7716842d..a60c922e 100644
--- a/src/Adapter/Swoole/Request.php
+++ b/src/Adapter/Swoole/Request.php
@@ -2,6 +2,7 @@
namespace Utopia\HTTP\Adapter\Swoole;
+use Exception;
use Utopia\HTTP\Request as UtopiaRequest;
use Swoole\Http\Request as SwooleRequest;
@@ -336,4 +337,16 @@ protected function generateHeaders(): array
{
return $this->swoole->header;
}
+
+ /**
+ * Get Request Size
+ *
+ * Returns request size in bytes
+ *
+ * @return int
+ */
+ public function getSize(): int
+ {
+ throw new Exception('not implemented');
+ }
}
\ No newline at end of file
diff --git a/src/Adapter/Swoole/Server.php b/src/Adapter/Swoole/Server.php
index cdf5d185..a0d1a606 100644
--- a/src/Adapter/Swoole/Server.php
+++ b/src/Adapter/Swoole/Server.php
@@ -34,6 +34,7 @@ function __construct(string $host = '0.0.0.0', int $port = 80) {
*/
public function start(): void
{
+ Files::load(__DIR__ . '/../public');
$this->server->on('start', function (Server $http) {
// $app = new App('UTC');
diff --git a/src/Request.php b/src/Request.php
index 7c6a0aad..bfea9b6b 100755
--- a/src/Request.php
+++ b/src/Request.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP;
-class Request
+abstract class Request
{
/**
* HTTP methods
@@ -50,22 +50,7 @@ class Request
* @param mixed $default
* @return mixed
*/
- public function getParam(string $key, $default = null)
- {
- switch ($this->getServer('REQUEST_METHOD', '')) {
- case self::METHOD_GET:
- return $this->getQuery($key, $default);
- break;
- case self::METHOD_POST:
- case self::METHOD_PUT:
- case self::METHOD_PATCH:
- case self::METHOD_DELETE:
- return $this->getPayload($key, $default);
- break;
- default:
- return $this->getQuery($key, $default);
- }
- }
+ abstract public function getParam(string $key, $default = null);
/**
* Get Params
@@ -74,22 +59,7 @@ public function getParam(string $key, $default = null)
*
* @return array
*/
- public function getParams(): array
- {
- switch ($this->getServer('REQUEST_METHOD', '')) {
- case self::METHOD_GET:
- return $_GET;
- break;
- case self::METHOD_POST:
- case self::METHOD_PUT:
- case self::METHOD_PATCH:
- case self::METHOD_DELETE:
- return $this->generateInput();
- break;
- default:
- return $_GET;
- }
- }
+ abstract public function getParams(): array;
/**
* Get Query
@@ -100,11 +70,8 @@ public function getParams(): array
* @param mixed $default
* @return mixed
*/
- public function getQuery(string $key, $default = null)
- {
- return (isset($_GET[$key])) ? $_GET[$key] : $default;
- }
-
+ abstract public function getQuery(string $key, $default = null);
+
/**
* Get payload
*
@@ -114,13 +81,8 @@ public function getQuery(string $key, $default = null)
* @param mixed $default
* @return mixed
*/
- public function getPayload(string $key, $default = null)
- {
- $payload = $this->generateInput();
-
- return (isset($payload[$key])) ? $payload[$key] : $default;
- }
-
+ abstract public function getPayload(string $key, $default = null);
+
/**
* Get server
*
@@ -130,10 +92,7 @@ public function getPayload(string $key, $default = null)
* @param mixed $default
* @return mixed
*/
- public function getServer(string $key, $default = null)
- {
- return (isset($_SERVER[$key])) ? $_SERVER[$key] : $default;
- }
+ abstract public function getServer(string $key, $default = null);
/**
* Get IP
@@ -144,11 +103,7 @@ public function getServer(string $key, $default = null)
*
* @return string
*/
- public function getIP(): string
- {
- $ips = explode(',',$this->getHeader('HTTP_X_FORWARDED_FOR', $this->getServer('REMOTE_ADDR', '0.0.0.0')));
- return trim($ips[0] ?? '');
- }
+ abstract public function getIP(): string;
/**
* Get Protocol
@@ -159,10 +114,7 @@ public function getIP(): string
*
* @return string
*/
- public function getProtocol(): string
- {
- return $this->getServer('HTTP_X_FORWARDED_PROTO', $this->getServer('REQUEST_SCHEME', 'https'));
- }
+ abstract public function getProtocol(): string;
/**
* Get Port
@@ -171,10 +123,7 @@ public function getProtocol(): string
*
* @return string
*/
- public function getPort(): string
- {
- return (string) \parse_url($this->getProtocol().'://'.$this->getServer('HTTP_HOST', ''), PHP_URL_PORT);
- }
+ abstract public function getPort(): string;
/**
* Get Hostname
@@ -183,10 +132,7 @@ public function getPort(): string
*
* @return string
*/
- public function getHostname(): string
- {
- return (string) \parse_url($this->getProtocol().'://'.$this->getServer('HTTP_HOST', ''), PHP_URL_HOST);
- }
+ abstract public function getHostname(): string;
/**
* Get Method
@@ -195,10 +141,7 @@ public function getHostname(): string
*
* @return string
*/
- public function getMethod(): string
- {
- return $this->getServer('REQUEST_METHOD', 'UNKNOWN');
- }
+ abstract public function getMethod(): string;
/**
* Get URI
@@ -207,10 +150,7 @@ public function getMethod(): string
*
* @return string
*/
- public function getURI(): string
- {
- return $this->getServer('REQUEST_URI', '');
- }
+ abstract public function getURI(): string;
/**
* Get files
@@ -220,10 +160,7 @@ public function getURI(): string
* @param string $key
* @return array
*/
- public function getFiles(string $key): array
- {
- return (isset($_FILES[$key])) ? $_FILES[$key] : [];
- }
+ abstract public function getFiles(string $key): array;
/**
* Get Referer
@@ -232,10 +169,7 @@ public function getFiles(string $key): array
*
* @return string
*/
- public function getReferer(string $default = ''): string
- {
- return $this->getServer('HTTP_REFERER', $default);
- }
+ abstract public function getReferer(string $default = ''): string;
/**
* Get Origin
@@ -244,10 +178,7 @@ public function getReferer(string $default = ''): string
*
* @return string
*/
- public function getOrigin(string $default = ''): string
- {
- return $this->getServer('HTTP_ORIGIN', $default);
- }
+ abstract public function getOrigin(string $default = ''): string;
/**
* Get User Agent
@@ -256,10 +187,7 @@ public function getOrigin(string $default = ''): string
*
* @return string
*/
- public function getUserAgent(string $default = ''): string
- {
- return $this->getServer('HTTP_USER_AGENT', $default);
- }
+ abstract public function getUserAgent(string $default = ''): string;
/**
* Get Accept
@@ -268,10 +196,7 @@ public function getUserAgent(string $default = ''): string
*
* @return string
*/
- public function getAccept(string $default = ''): string
- {
- return $this->getServer('HTTP_ACCEPT', $default);
- }
+ abstract public function getAccept(string $default = ''): string;
/**
* Get cookie
@@ -282,10 +207,7 @@ public function getAccept(string $default = ''): string
* @param string $default
* @return string
*/
- public function getCookie(string $key, string $default = ''): string
- {
- return (isset($_COOKIE[$key])) ? $_COOKIE[$key] : $default;
- }
+ abstract public function getCookie(string $key, string $default = ''): string;
/**
* Get header
@@ -296,12 +218,7 @@ public function getCookie(string $key, string $default = ''): string
* @param string $default
* @return string
*/
- public function getHeader(string $key, string $default = ''): string
- {
- $headers = $this->generateHeaders();
-
- return (isset($headers[$key])) ? $headers[$key] : $default;
- }
+ abstract public function getHeader(string $key, string $default = ''): string;
/**
* Get Request Size
@@ -310,10 +227,16 @@ public function getHeader(string $key, string $default = ''): string
*
* @return int
*/
- public function getSize(): int
- {
- return \mb_strlen(\implode("\n", $this->generateHeaders()), '8bit') + \mb_strlen(\file_get_contents('php://input'), '8bit');
- }
+ abstract public function getSize(): int;
+
+ /**
+ * Generate headers
+ *
+ * Parse request headers as an array for easy querying using the getHeader method
+ *
+ * @return array
+ */
+ abstract protected function generateHeaders(): array;
/**
* Get Content Range Start
@@ -383,75 +306,6 @@ public function getContentRangeUnit()
}
}
- /**
- * Generate input
- *
- * Generate PHP input stream and parse it as an array in order to handle different content type of requests
- *
- * @return array
- */
- protected function generateInput(): array
- {
- if (null === $this->payload) {
- $contentType = $this->getHeader('content-type');
-
- // Get content-type without the charset
- $length = \strpos($contentType, ';');
- $length = (empty($length)) ? \strlen($contentType) : $length;
- $contentType = \substr($contentType, 0, $length);
-
- switch ($contentType) {
- case 'application/json':
- $this->payload = \json_decode(\file_get_contents('php://input'), true);
- break;
-
- default:
- $this->payload = $_POST;
- break;
- }
-
- if (empty($this->payload)) { // Make sure we return same data type even if json payload is empty or failed
- $this->payload = [];
- }
- }
-
- return $this->payload;
- }
-
- /**
- * Generate headers
- *
- * Parse request headers as an array for easy querying using the getHeader method
- *
- * @return array
- */
- protected function generateHeaders(): array
- {
- if (null === $this->headers) {
- /**
- * Fallback for older PHP versions
- * that do not support generateHeaders
- */
- if (!\function_exists('getallheaders')) {
- $headers = [];
-
- foreach ($_SERVER as $name => $value) {
- if (\substr($name, 0, 5) == 'HTTP_') {
- $headers[\str_replace(' ', '-', \strtolower(\str_replace('_', ' ', \substr($name, 5))))] = $value;
- }
- }
-
- $this->headers = $headers;
-
- return $this->headers;
- }
-
- $this->headers = array_change_key_case(getallheaders());
- }
-
- return $this->headers;
- }
-
/**
* Content Range Parser
*
@@ -500,6 +354,7 @@ protected function parseContentRange() {
}
return $data;
}
+
return null;
}
diff --git a/src/Response.php b/src/Response.php
index ebcaa1d3..431fcdc6 100755
--- a/src/Response.php
+++ b/src/Response.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP;
-class Response
+abstract class Response
{
/**
* HTTP content types
@@ -378,33 +378,7 @@ public function getCookies(): array
*
* @return void
*/
- public function send(string $body = '', int $exit = null): void
- {
- if($this->sent) {
- return;
- }
-
- $this->sent = true;
-
- $this->addHeader('X-Debug-Speed', (string)(\microtime(true) - $this->startTime));
-
- $this
- ->appendCookies()
- ->appendHeaders()
- ;
-
- if (!$this->disablePayload) {
- $this->size = $this->size + \mb_strlen(\implode("\n", \headers_list())) + \mb_strlen($body, '8bit');
-
- echo $body;
-
- $this->disablePayload();
- }
-
- if (!\is_null($exit)) {
- exit($exit); // Exit with code
- }
- }
+ abstract public function send(string $body = '', int $exit = null): void;
/**
* Append headers
@@ -414,25 +388,7 @@ public function send(string $body = '', int $exit = null): void
*
* @return self
*/
- protected function appendHeaders(): self
- {
- // Send status code header
- \http_response_code($this->statusCode);
-
- // Send content type header
- if (!empty($this->contentType)) {
- $this
- ->addHeader('Content-Type', $this->contentType)
- ;
- }
-
- // Set application headers
- foreach ($this->headers as $key => $value) {
- \header($key . ': ' . $value);
- }
-
- return $this;
- }
+ abstract protected function appendHeaders(): self;
/**
* Append cookies
@@ -441,25 +397,7 @@ protected function appendHeaders(): self
*
* @return self
*/
- protected function appendCookies(): self
- {
- foreach ($this->cookies as $cookie) {
- if (\version_compare(PHP_VERSION, '7.3.0', '<')) {
- \setcookie($cookie['name'], $cookie['value'], $cookie['expire'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
- } else {
- \setcookie($cookie['name'], $cookie['value'], [
- 'expires' => $cookie['expire'],
- 'path' => $cookie['path'],
- 'domain' => $cookie['domain'],
- 'secure' => $cookie['secure'],
- 'httponly' => $cookie['httponly'],
- 'samesite' => $cookie['samesite'],
- ]);
- }
- }
-
- return $this;
- }
+ abstract protected function appendCookies(): self;
/**
* Redirect
From 992e213d9f2a910b1bd2d8fe511f9f371f4ee1ec Mon Sep 17 00:00:00 2001
From: Eldad Fux
Date: Tue, 1 Feb 2022 01:11:28 +0200
Subject: [PATCH 03/10] Updated with main
---
src/Adapter/FPM/Request.php | 16 ++--
src/Adapter/FPM/Response.php | 165 ++++++++++++++++++++++++++++-----
src/Adapter/Swoole/Request.php | 8 +-
3 files changed, 152 insertions(+), 37 deletions(-)
diff --git a/src/Adapter/FPM/Request.php b/src/Adapter/FPM/Request.php
index 1405380a..32b6a312 100755
--- a/src/Adapter/FPM/Request.php
+++ b/src/Adapter/FPM/Request.php
@@ -25,7 +25,7 @@ class Request extends HTTPRequest
* @param mixed $default
* @return mixed
*/
- public function getParam(string $key, $default = null)
+ public function getParam(string $key, mixed $default = null): mixed
{
switch ($this->getServer('REQUEST_METHOD', '')) {
case self::METHOD_GET:
@@ -75,7 +75,7 @@ public function getParams(): array
* @param mixed $default
* @return mixed
*/
- public function getQuery(string $key, $default = null)
+ public function getQuery(string $key, mixed $default = null): mixed
{
return (isset($_GET[$key])) ? $_GET[$key] : $default;
}
@@ -89,7 +89,7 @@ public function getQuery(string $key, $default = null)
* @param mixed $default
* @return mixed
*/
- public function getPayload(string $key, $default = null)
+ public function getPayload(string $key, mixed $default = null): mixed
{
$payload = $this->generateInput();
@@ -105,7 +105,7 @@ public function getPayload(string $key, $default = null)
* @param mixed $default
* @return mixed
*/
- public function getServer(string $key, $default = null)
+ public function getServer(string $key, mixed $default = null): mixed
{
return (isset($_SERVER[$key])) ? $_SERVER[$key] : $default;
}
@@ -209,7 +209,7 @@ public function getFiles(string $key): array
*/
public function getReferer(string $default = ''): string
{
- return $this->getServer('HTTP_REFERER', $default);
+ return (string) $this->getServer('HTTP_REFERER', $default);
}
/**
@@ -221,7 +221,7 @@ public function getReferer(string $default = ''): string
*/
public function getOrigin(string $default = ''): string
{
- return $this->getServer('HTTP_ORIGIN', $default);
+ return (string) $this->getServer('HTTP_ORIGIN', $default);
}
/**
@@ -233,7 +233,7 @@ public function getOrigin(string $default = ''): string
*/
public function getUserAgent(string $default = ''): string
{
- return $this->getServer('HTTP_USER_AGENT', $default);
+ return (string) $this->getServer('HTTP_USER_AGENT', $default);
}
/**
@@ -245,7 +245,7 @@ public function getUserAgent(string $default = ''): string
*/
public function getAccept(string $default = ''): string
{
- return $this->getServer('HTTP_ACCEPT', $default);
+ return (string) $this->getServer('HTTP_ACCEPT', $default);
}
/**
diff --git a/src/Adapter/FPM/Response.php b/src/Adapter/FPM/Response.php
index 6f170a61..6ede3ea7 100755
--- a/src/Adapter/FPM/Response.php
+++ b/src/Adapter/FPM/Response.php
@@ -26,14 +26,14 @@ class Response extends HTTPResponse
*
* @return void
*/
- public function send(string $body = '', int $exit = null): void
+ public function send(string $body = ''): void
{
if($this->sent) {
return;
}
$this->sent = true;
-
+
$this->addHeader('X-Debug-Speed', (string)(\microtime(true) - $this->startTime));
$this
@@ -42,15 +42,25 @@ public function send(string $body = '', int $exit = null): void
;
if (!$this->disablePayload) {
- $this->size = $this->size + \mb_strlen(\implode("\n", \headers_list())) + \mb_strlen($body, '8bit');
+ $length = strlen($body);
- echo $body;
+ $this->size = $this->size + strlen(implode("\n", $this->headers)) + $length;
- $this->disablePayload();
- }
+ if(array_key_exists(
+ $this->contentType,
+ $this->compressed
+ ) && ($length <= self::CHUNK_SIZE)) { // Dont compress with GZIP / Brotli if header is not listed and size is bigger than 2mb
+ $this->end($body);
+ }
+ else {
+ for ($i=0; $i < ceil($length / self::CHUNK_SIZE); $i++) {
+ $this->write(substr($body, ($i * self::CHUNK_SIZE), min(self::CHUNK_SIZE, $length - ($i * self::CHUNK_SIZE))));
+ }
+
+ $this->end();
+ }
- if (!\is_null($exit)) {
- exit($exit); // Exit with code
+ $this->disablePayload();
}
}
@@ -65,18 +75,16 @@ public function send(string $body = '', int $exit = null): void
protected function appendHeaders(): self
{
// Send status code header
- \http_response_code($this->statusCode);
+ $this->sendStatus($this->statusCode);
// Send content type header
if (!empty($this->contentType)) {
- $this
- ->addHeader('Content-Type', $this->contentType)
- ;
+ $this->addHeader('Content-Type', $this->contentType);
}
// Set application headers
foreach ($this->headers as $key => $value) {
- \header($key . ': ' . $value);
+ $this->sendHeader($key, $value);
}
return $this;
@@ -92,20 +100,127 @@ protected function appendHeaders(): self
protected function appendCookies(): self
{
foreach ($this->cookies as $cookie) {
- if (\version_compare(PHP_VERSION, '7.3.0', '<')) {
- \setcookie($cookie['name'], $cookie['value'], $cookie['expire'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
- } else {
- \setcookie($cookie['name'], $cookie['value'], [
- 'expires' => $cookie['expire'],
- 'path' => $cookie['path'],
- 'domain' => $cookie['domain'],
- 'secure' => $cookie['secure'],
- 'httponly' => $cookie['httponly'],
- 'samesite' => $cookie['samesite'],
- ]);
- }
+ $this->sendCookie($cookie['name'], $cookie['value'], [
+ 'expires' => $cookie['expire'],
+ 'path' => $cookie['path'],
+ 'domain' => $cookie['domain'],
+ 'secure' => $cookie['secure'],
+ 'httponly' => $cookie['httponly'],
+ 'samesite' => $cookie['samesite'],
+ ]);
}
return $this;
}
+
+ /**
+ * Send Status Code
+ *
+ * @param int $statusCode
+ *
+ * @return void
+ */
+ protected function sendStatus(int $statusCode): void
+ {
+ http_response_code($statusCode);
+ }
+
+ /**
+ * Send Header
+ *
+ * Output Header
+ *
+ * @param string $key
+ * @param string $value
+ *
+ * @return void
+ */
+ protected function sendHeader(string $key, string $value): void
+ {
+ \header($key . ': ' . $value);
+ }
+
+ /**
+ * Send Cookie
+ *
+ * Output Cookie
+ *
+ * @param string $name
+ * @param string $value
+ * @param array $options
+ *
+ * @return void
+ */
+ protected function sendCookie(string $name, string $value, array $options): void
+ {
+ \setcookie($name, $value, $options);
+ }
+
+ /**
+ * Write
+ *
+ * Send output
+ *
+ * @param string $content
+ *
+ * @return void
+ */
+ protected function write(string $content): void
+ {
+ echo $content;
+ }
+
+ /**
+ * End
+ *
+ * Send optional content and end
+ *
+ * @param string $content
+ *
+ * @return void
+ */
+ protected function end(string $content = null): void
+ {
+ if(!is_null($content)) {
+ echo $content;
+ }
+ }
+
+ /**
+ * Output response
+ *
+ * Generate HTTP response output including the response header (+cookies) and body and prints them.
+ *
+ * @param string $body
+ * @param bool $last
+ *
+ * @return void
+ */
+ public function chunk(string $body = '', bool $end = false): void
+ {
+ if ($this->sent) {
+ return;
+ }
+
+ if ($end) {
+ $this->sent = true;
+ }
+
+ $this->addHeader('X-Debug-Speed', (string) (microtime(true) - $this->startTime));
+
+ $this
+ ->appendCookies()
+ ->appendHeaders()
+ ;
+
+ if (!$this->disablePayload) {
+ $this->write($body);
+ if ($end) {
+ $this->disablePayload();
+ $this->end();
+ }
+ } else {
+ $this->end();
+ }
+ }
}
diff --git a/src/Adapter/Swoole/Request.php b/src/Adapter/Swoole/Request.php
index a60c922e..b0c72309 100644
--- a/src/Adapter/Swoole/Request.php
+++ b/src/Adapter/Swoole/Request.php
@@ -32,7 +32,7 @@ public function __construct(SwooleRequest $request)
* @param mixed $default
* @return mixed
*/
- public function getParam(string $key, $default = null)
+ public function getParam(string $key, $default = null): mixed
{
switch($this->getMethod()) {
case self::METHOD_GET:
@@ -84,7 +84,7 @@ public function getParams(): array
* @param mixed $default
* @return mixed
*/
- public function getQuery(string $key, $default = null)
+ public function getQuery(string $key, $default = null): mixed
{
return (isset($this->swoole->get[$key])) ? $this->swoole->get[$key] : $default;
}
@@ -98,7 +98,7 @@ public function getQuery(string $key, $default = null)
* @param mixed $default
* @return mixed
*/
- public function getPayload(string $key, $default = null)
+ public function getPayload(string $key, $default = null): mixed
{
$payload = $this->generateInput();
@@ -114,7 +114,7 @@ public function getPayload(string $key, $default = null)
* @param mixed $default
* @return mixed
*/
- public function getServer(string $key, $default = null)
+ public function getServer(string $key, $default = null): mixed
{
return (isset($this->swoole->server) && isset($this->swoole->server[$key])) ? $this->swoole->server[$key] : $default;
}
From d88b94ce6b242dcac418d1b454f2fd40469a1268 Mon Sep 17 00:00:00 2001
From: Eldad Fux
Date: Tue, 1 Feb 2022 01:18:56 +0200
Subject: [PATCH 04/10] Sync with latest
---
src/Adapter/FPM/Response.php | 135 --------------------------
src/Adapter/Swoole/Response.php | 138 +++++++++++----------------
src/Response.php | 163 +++++++++++++++++++++++++++++++-
3 files changed, 213 insertions(+), 223 deletions(-)
diff --git a/src/Adapter/FPM/Response.php b/src/Adapter/FPM/Response.php
index 6ede3ea7..6aade9fa 100755
--- a/src/Adapter/FPM/Response.php
+++ b/src/Adapter/FPM/Response.php
@@ -16,103 +16,6 @@
class Response extends HTTPResponse
{
- /**
- * Output response
- *
- * Generate HTTP response output including the response header (+cookies) and body and prints them.
- *
- * @param string $body
- * @param int $exit exit code or don't exit if code is null
- *
- * @return void
- */
- public function send(string $body = ''): void
- {
- if($this->sent) {
- return;
- }
-
- $this->sent = true;
-
- $this->addHeader('X-Debug-Speed', (string)(\microtime(true) - $this->startTime));
-
- $this
- ->appendCookies()
- ->appendHeaders()
- ;
-
- if (!$this->disablePayload) {
- $length = strlen($body);
-
- $this->size = $this->size + strlen(implode("\n", $this->headers)) + $length;
-
- if(array_key_exists(
- $this->contentType,
- $this->compressed
- ) && ($length <= self::CHUNK_SIZE)) { // Dont compress with GZIP / Brotli if header is not listed and size is bigger than 2mb
- $this->end($body);
- }
- else {
- for ($i=0; $i < ceil($length / self::CHUNK_SIZE); $i++) {
- $this->write(substr($body, ($i * self::CHUNK_SIZE), min(self::CHUNK_SIZE, $length - ($i * self::CHUNK_SIZE))));
- }
-
- $this->end();
- }
-
- $this->disablePayload();
- }
- }
-
- /**
- * Append headers
- *
- * Iterating over response headers to generate them using native PHP header function.
- * This method is also responsible for generating the response and content type headers.
- *
- * @return self
- */
- protected function appendHeaders(): self
- {
- // Send status code header
- $this->sendStatus($this->statusCode);
-
- // Send content type header
- if (!empty($this->contentType)) {
- $this->addHeader('Content-Type', $this->contentType);
- }
-
- // Set application headers
- foreach ($this->headers as $key => $value) {
- $this->sendHeader($key, $value);
- }
-
- return $this;
- }
-
- /**
- * Append cookies
- *
- * Iterating over response cookies to generate them using native PHP cookie function.
- *
- * @return self
- */
- protected function appendCookies(): self
- {
- foreach ($this->cookies as $cookie) {
- $this->sendCookie($cookie['name'], $cookie['value'], [
- 'expires' => $cookie['expire'],
- 'path' => $cookie['path'],
- 'domain' => $cookie['domain'],
- 'secure' => $cookie['secure'],
- 'httponly' => $cookie['httponly'],
- 'samesite' => $cookie['samesite'],
- ]);
- }
-
- return $this;
- }
-
/**
* Send Status Code
*
@@ -185,42 +88,4 @@ protected function end(string $content = null): void
echo $content;
}
}
-
- /**
- * Output response
- *
- * Generate HTTP response output including the response header (+cookies) and body and prints them.
- *
- * @param string $body
- * @param bool $last
- *
- * @return void
- */
- public function chunk(string $body = '', bool $end = false): void
- {
- if ($this->sent) {
- return;
- }
-
- if ($end) {
- $this->sent = true;
- }
-
- $this->addHeader('X-Debug-Speed', (string) (microtime(true) - $this->startTime));
-
- $this
- ->appendCookies()
- ->appendHeaders()
- ;
-
- if (!$this->disablePayload) {
- $this->write($body);
- if ($end) {
- $this->disablePayload();
- $this->end();
- }
- } else {
- $this->end();
- }
- }
}
diff --git a/src/Adapter/Swoole/Response.php b/src/Adapter/Swoole/Response.php
index 07ee47f7..f7b96d5c 100644
--- a/src/Adapter/Swoole/Response.php
+++ b/src/Adapter/Swoole/Response.php
@@ -43,106 +43,76 @@ public function __construct(SwooleResponse $response)
}
/**
- * Output response
- *
- * Generate HTTP response output including the response header (+cookies) and body and prints them.
- *
- * @param string $body
- * @param int $exit exit code or don't exit if code is null
- *
+ * Write
+ *
+ * @param string $content
+ *
* @return void
*/
- public function send(string $body = '', int $exit = null): void
+ protected function write(string $content): void
{
- if($this->sent) {
- return;
- }
-
- $this->sent = true;
-
- $this->addHeader('X-Debug-Speed', (string)(microtime(true) - $this->startTime));
-
- $this
- ->appendCookies()
- ->appendHeaders()
- ;
-
- if(!$this->disablePayload) {
-
- $chunk = 2000000; // Max chunk of 2 mb
- $length = strlen($body);
-
- $this->size = $this->size + strlen(implode("\n", $this->headers)) + $length;
-
- if(array_key_exists(
- $this->contentType,
- $this->compressed
- ) && ($length <= $chunk)) { // Dont compress with GZIP / Brotli if header is not listed and size is bigger than 2mb
- $this->swoole->end($body);
- }
- else {
- for ($i=0; $i < ceil($length / $chunk); $i++) {
- $this->swoole->write(substr($body, ($i * $chunk), min((($i * $chunk) + $chunk), $length)));
- }
-
- $this->swoole->end();
- }
-
- $this->disablePayload();
- }
- else {
- $this->swoole->end();
- }
+ $this->swoole->write($content);
}
/**
- * Append headers
- *
- * Iterating over response headers to generate them using native PHP header function.
- * This method is also responsible for generating the response and content type headers.
- *
- * @return self
+ * End
+ *
+ * @param string $content
+ *
+ * @return void
*/
- protected function appendHeaders(): self
+ protected function end(string $content=null): void
{
- // Send status code header
- $this->swoole->status((string)$this->statusCode);
-
- // Send content type header
- $this
- ->addHeader('Content-Type', $this->contentType)
- ;
+ $this->swoole->end($content);
+ }
- // Set application headers
- foreach ($this->headers as $key => $value) {
- $this->swoole->header($key, $value);
- }
+ /**
+ * Send Status Code
+ *
+ * @param int $statusCode
+ *
+ * @return void
+ */
+ protected function sendStatus(int $statusCode): void
+ {
+ $this->swoole->status($statusCode);
+ }
- return $this;
+ /**
+ * Send Header
+ *
+ * @param string $key
+ * @param string $value
+ *
+ * @return void
+ */
+ protected function sendHeader(string $key, string $value): void
+ {
+ $this->swoole->header($key, $value);
}
/**
- * Append cookies
+ * Send Cookie
*
- * Iterating over response cookies to generate them using native PHP cookie function.
+ * Send a cookie
+ *
+ * @param string $name
+ * @param string $value
+ * @param array $options
*
- * @return self
+ * @return void
*/
- protected function appendCookies(): self
+ protected function sendCookie(string $name, string $value, array $options): void
{
- foreach ($this->cookies as $cookie) {
- $this->swoole->cookie(
- $cookie['name'],
- $cookie['value'],
- $cookie['expire'],
- $cookie['path'],
- $cookie['domain'],
- $cookie['secure'],
- $cookie['httponly'],
- $cookie['samesite'],
- );
- }
-
- return $this;
+ $this->swoole->cookie(
+ $name,
+ $value,
+ $options['expire'] ?? 0,
+ $options['path'] ?? "",
+ $options['domain'] ?? "",
+ $options['secure'] ?? false,
+ $options['httponly'] ?? false,
+ $options['samesite'] ?? false,
+ );
}
}
\ No newline at end of file
diff --git a/src/Response.php b/src/Response.php
index 58ac4a7b..febc8c7e 100755
--- a/src/Response.php
+++ b/src/Response.php
@@ -396,11 +396,48 @@ public function getCookies(): array
* Generate HTTP response output including the response header (+cookies) and body and prints them.
*
* @param string $body
+ * @param int $exit exit code or don't exit if code is null
*
* @return void
*/
- abstract public function send(string $body = ''): void;
-
+ public function send(string $body = ''): void
+ {
+ if($this->sent) {
+ return;
+ }
+
+ $this->sent = true;
+
+ $this->addHeader('X-Debug-Speed', (string)(\microtime(true) - $this->startTime));
+
+ $this
+ ->appendCookies()
+ ->appendHeaders()
+ ;
+
+ if (!$this->disablePayload) {
+ $length = strlen($body);
+
+ $this->size = $this->size + strlen(implode("\n", $this->headers)) + $length;
+
+ if(array_key_exists(
+ $this->contentType,
+ $this->compressed
+ ) && ($length <= self::CHUNK_SIZE)) { // Dont compress with GZIP / Brotli if header is not listed and size is bigger than 2mb
+ $this->end($body);
+ }
+ else {
+ for ($i=0; $i < ceil($length / self::CHUNK_SIZE); $i++) {
+ $this->write(substr($body, ($i * self::CHUNK_SIZE), min(self::CHUNK_SIZE, $length - ($i * self::CHUNK_SIZE))));
+ }
+
+ $this->end();
+ }
+
+ $this->disablePayload();
+ }
+ }
+
/**
* Append headers
*
@@ -409,7 +446,23 @@ abstract public function send(string $body = ''): void;
*
* @return self
*/
- abstract protected function appendHeaders(): self;
+ protected function appendHeaders(): self
+ {
+ // Send status code header
+ $this->sendStatus($this->statusCode);
+
+ // Send content type header
+ if (!empty($this->contentType)) {
+ $this->addHeader('Content-Type', $this->contentType);
+ }
+
+ // Set application headers
+ foreach ($this->headers as $key => $value) {
+ $this->sendHeader($key, $value);
+ }
+
+ return $this;
+ }
/**
* Append cookies
@@ -418,7 +471,109 @@ abstract protected function appendHeaders(): self;
*
* @return self
*/
- abstract protected function appendCookies(): self;
+ protected function appendCookies(): self
+ {
+ foreach ($this->cookies as $cookie) {
+ $this->sendCookie($cookie['name'], $cookie['value'], [
+ 'expires' => $cookie['expire'],
+ 'path' => $cookie['path'],
+ 'domain' => $cookie['domain'],
+ 'secure' => $cookie['secure'],
+ 'httponly' => $cookie['httponly'],
+ 'samesite' => $cookie['samesite'],
+ ]);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Write
+ *
+ * @param string $content
+ *
+ * @return void
+ */
+ abstract protected function write(string $content): void;
+
+ /**
+ * End
+ *
+ * @param string $content
+ *
+ * @return void
+ */
+ abstract protected function end(string $content=null): void;
+
+ /**
+ * Send Status Code
+ *
+ * @param int $statusCode
+ *
+ * @return void
+ */
+ abstract protected function sendStatus(int $statusCode): void;
+
+ /**
+ * Send Header
+ *
+ * @param string $key
+ * @param string $value
+ *
+ * @return void
+ */
+ abstract protected function sendHeader(string $key, string $value): void;
+
+ /**
+ * Send Cookie
+ *
+ * Send a cookie
+ *
+ * @param string $name
+ * @param string $value
+ * @param array $options
+ *
+ * @return void
+ */
+ abstract protected function sendCookie(string $name, string $value, array $options): void;
+
+ /**
+ * Output response
+ *
+ * Generate HTTP response output including the response header (+cookies) and body and prints them.
+ *
+ * @param string $body
+ * @param bool $last
+ *
+ * @return void
+ */
+ public function chunk(string $body = '', bool $end = false): void
+ {
+ if ($this->sent) {
+ return;
+ }
+
+ if ($end) {
+ $this->sent = true;
+ }
+
+ $this->addHeader('X-Debug-Speed', (string) (microtime(true) - $this->startTime));
+
+ $this
+ ->appendCookies()
+ ->appendHeaders()
+ ;
+
+ if (!$this->disablePayload) {
+ $this->write($body);
+ if ($end) {
+ $this->disablePayload();
+ $this->end();
+ }
+ } else {
+ $this->end();
+ }
+ }
/**
* Redirect
From 974f25879451cd7616c8bfc399784654b779d1f1 Mon Sep 17 00:00:00 2001
From: Eldad Fux
Date: Tue, 1 Feb 2022 01:24:34 +0200
Subject: [PATCH 05/10] Updated namespaces
---
README.md | 6 +++---
docs/Getting-Starting-Guide.md | 14 +++++++-------
src/Adapter/FPM/Request.php | 2 +-
src/Adapter/FPM/Response.php | 2 +-
src/Adapter/Swoole/Request.php | 2 +-
src/Adapter/Swoole/Response.php | 2 +-
src/Adapter/Swoole/Server.php | 2 +-
src/Server.php | 2 +-
src/Validator/ArrayList.php | 2 +-
src/Validator/Assoc.php | 2 +-
src/Validator/Boolean.php | 2 +-
src/Validator/FloatValidator.php | 2 +-
src/Validator/HexColor.php | 2 +-
src/Validator/Integer.php | 2 +-
src/Validator/JSON.php | 2 +-
src/Validator/Numeric.php | 2 +-
src/Validator/Text.php | 2 +-
src/Validator/WhiteList.php | 2 +-
src/Validator/Wildcard.php | 2 +-
tests/AppTest.php | 4 ++--
tests/RequestTest.php | 2 +-
tests/RouteTest.php | 2 +-
tests/UtopiaRequestTest.php | 2 +-
tests/e2e/server.php | 6 +++---
24 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/README.md b/README.md
index 8aac0ffb..8c9f798e 100644
--- a/README.md
+++ b/README.md
@@ -21,9 +21,9 @@ Init your first application:
```php
require_once __DIR__ . '/../../vendor/autoload.php';
-use Utopia\App;
-use Utopia\Request;
-use Utopia\Response;
+use Utopia\HTTP\App;
+use Utopia\HTTP\Request;
+use Utopia\HTTP\Response;
App::get('/hello-world') // Define Route
->inject('request')
diff --git a/docs/Getting-Starting-Guide.md b/docs/Getting-Starting-Guide.md
index 4a350d15..66bfe830 100644
--- a/docs/Getting-Starting-Guide.md
+++ b/docs/Getting-Starting-Guide.md
@@ -9,9 +9,9 @@ If you’re new to Utopia, let’s get started by looking at an example of a bas
## Basic GET Route
```php
-use Utopia\App;
-use Utopia\Swoole\Request;
-use Utopia\Swoole\Response;
+use Utopia\HTTP\App;
+use Utopia\HTTP\Swoole\Request;
+use Utopia\HTTP\Swoole\Response;
use Swoole\Http\Server;
use Swoole\Http\Request as SwooleRequest;
use Swoole\Http\Response as SwooleResponse;
@@ -138,13 +138,13 @@ You can find the details of other status codes by visiting our [GitHub repositor
Let's make the above example slightly advanced by adding more properties.
```php
-use Utopia\App;
-use Utopia\Swoole\Request;
-use Utopia\Swoole\Response;
+use Utopia\HTTP\App;
+use Utopia\HTTP\Swoole\Request;
+use Utopia\HTTP\Swoole\Response;
use Swoole\Http\Server;
use Swoole\Http\Request as SwooleRequest;
use Swoole\Http\Response as SwooleResponse;
-use Utopia\Validator\Wildcard;
+use Utopia\HTTP\Validator\Wildcard;
$http = new Server("0.0.0.0", 8080);
diff --git a/src/Adapter/FPM/Request.php b/src/Adapter/FPM/Request.php
index 32b6a312..1ccbc0a3 100755
--- a/src/Adapter/FPM/Request.php
+++ b/src/Adapter/FPM/Request.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Adapter\FPM;
-use Utopia\HTTP\Request as HTTPRequest;
+use Utopia\HTTP\HTTP\Request as HTTPRequest;
class Request extends HTTPRequest
{
diff --git a/src/Adapter/FPM/Response.php b/src/Adapter/FPM/Response.php
index 6aade9fa..1997f6f6 100755
--- a/src/Adapter/FPM/Response.php
+++ b/src/Adapter/FPM/Response.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Adapter\FPM;
-use Utopia\HTTP\Response as HTTPResponse;
+use Utopia\HTTP\HTTP\Response as HTTPResponse;
class Response extends HTTPResponse
{
diff --git a/src/Adapter/Swoole/Request.php b/src/Adapter/Swoole/Request.php
index b0c72309..e30c9724 100644
--- a/src/Adapter/Swoole/Request.php
+++ b/src/Adapter/Swoole/Request.php
@@ -3,7 +3,7 @@
namespace Utopia\HTTP\Adapter\Swoole;
use Exception;
-use Utopia\HTTP\Request as UtopiaRequest;
+use Utopia\HTTP\HTTP\Request as UtopiaRequest;
use Swoole\Http\Request as SwooleRequest;
class Request extends UtopiaRequest
diff --git a/src/Adapter/Swoole/Response.php b/src/Adapter/Swoole/Response.php
index f7b96d5c..7475f147 100644
--- a/src/Adapter/Swoole/Response.php
+++ b/src/Adapter/Swoole/Response.php
@@ -2,7 +2,7 @@
namespace Utopia\HTTP\Adapter\Swoole;
-use Utopia\HTTP\Response as UtopiaResponse;
+use Utopia\HTTP\HTTP\Response as UtopiaResponse;
use Swoole\Http\Response as SwooleResponse;
class Response extends UtopiaResponse
diff --git a/src/Adapter/Swoole/Server.php b/src/Adapter/Swoole/Server.php
index a0d1a606..8b6d2c0e 100644
--- a/src/Adapter/Swoole/Server.php
+++ b/src/Adapter/Swoole/Server.php
@@ -5,7 +5,7 @@
use Swoole\Http\Server as SwooleServer;
use Swoole\Http\Request as SwooleRequest;
use Swoole\Http\Response as SwooleResponse;
-use Utopia\HTTP\App;
+use Utopia\HTTP\HTTP\App;
/**
* Utopia PHP Framework
diff --git a/src/Server.php b/src/Server.php
index 3a21ba08..a057e3e3 100644
--- a/src/Server.php
+++ b/src/Server.php
@@ -2,7 +2,7 @@
namespace Utopia\HTTP;
use Throwable;
-use Utopia\Adapter;
+use Utopia\HTTP\Adapter;
/**
* Utopia PHP Framework
diff --git a/src/Validator/ArrayList.php b/src/Validator/ArrayList.php
index cb5b54f9..62578c22 100644
--- a/src/Validator/ArrayList.php
+++ b/src/Validator/ArrayList.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Validator;
-use Utopia\Validator;
+use Utopia\HTTP\Validator;
/**
* ArrayList
diff --git a/src/Validator/Assoc.php b/src/Validator/Assoc.php
index b11494b7..702b9863 100644
--- a/src/Validator/Assoc.php
+++ b/src/Validator/Assoc.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Validator;
-use Utopia\Validator;
+use Utopia\HTTP\Validator;
/**
* ArrayList
diff --git a/src/Validator/Boolean.php b/src/Validator/Boolean.php
index cf4c07ca..c3b46650 100644
--- a/src/Validator/Boolean.php
+++ b/src/Validator/Boolean.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Validator;
-use Utopia\Validator;
+use Utopia\HTTP\Validator;
/**
* Bool
diff --git a/src/Validator/FloatValidator.php b/src/Validator/FloatValidator.php
index 60a7dd8f..56d03117 100755
--- a/src/Validator/FloatValidator.php
+++ b/src/Validator/FloatValidator.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Validator;
-use Utopia\Validator;
+use Utopia\HTTP\Validator;
/**
* Float
diff --git a/src/Validator/HexColor.php b/src/Validator/HexColor.php
index 2b52ae43..abf6cc50 100644
--- a/src/Validator/HexColor.php
+++ b/src/Validator/HexColor.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Validator;
-use Utopia\Validator;
+use Utopia\HTTP\Validator;
class HexColor extends Validator
{
diff --git a/src/Validator/Integer.php b/src/Validator/Integer.php
index 1afb9eed..eaa8e4cc 100755
--- a/src/Validator/Integer.php
+++ b/src/Validator/Integer.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Validator;
-use Utopia\Validator;
+use Utopia\HTTP\Validator;
/**
* Integer
*
diff --git a/src/Validator/JSON.php b/src/Validator/JSON.php
index b653e984..786f2abb 100644
--- a/src/Validator/JSON.php
+++ b/src/Validator/JSON.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Validator;
-use Utopia\Validator;
+use Utopia\HTTP\Validator;
class JSON extends Validator
{
diff --git a/src/Validator/Numeric.php b/src/Validator/Numeric.php
index 7674f8b7..94b9b8b1 100755
--- a/src/Validator/Numeric.php
+++ b/src/Validator/Numeric.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Validator;
-use Utopia\Validator;
+use Utopia\HTTP\Validator;
/**
* Numeric
diff --git a/src/Validator/Text.php b/src/Validator/Text.php
index 47a6adea..d389e4aa 100644
--- a/src/Validator/Text.php
+++ b/src/Validator/Text.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Validator;
-use Utopia\Validator;
+use Utopia\HTTP\Validator;
/**
* Text
diff --git a/src/Validator/WhiteList.php b/src/Validator/WhiteList.php
index ae9ea320..97e0dda4 100755
--- a/src/Validator/WhiteList.php
+++ b/src/Validator/WhiteList.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Validator;
-use Utopia\Validator;
+use Utopia\HTTP\Validator;
/**
* WhiteList
diff --git a/src/Validator/Wildcard.php b/src/Validator/Wildcard.php
index 14f211e9..6ef31907 100644
--- a/src/Validator/Wildcard.php
+++ b/src/Validator/Wildcard.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Validator;
-use Utopia\Validator;
+use Utopia\HTTP\Validator;
/**
* Wildcard
diff --git a/tests/AppTest.php b/tests/AppTest.php
index 390a4296..e57b999e 100755
--- a/tests/AppTest.php
+++ b/tests/AppTest.php
@@ -14,8 +14,8 @@
namespace Utopia\HTTP;
use PHPUnit\Framework\TestCase;
-use Utopia\Tests\UtopiaRequestTest;
-use Utopia\Validator\Text;
+use Utopia\HTTP\Tests\UtopiaRequestTest;
+use Utopia\HTTP\Validator\Text;
App::setResource('rand', function () {return rand();});
App::setResource('first', function ($second) {return 'first-'.$second;}, ['second']);
diff --git a/tests/RequestTest.php b/tests/RequestTest.php
index 6f6f116f..729e3ceb 100755
--- a/tests/RequestTest.php
+++ b/tests/RequestTest.php
@@ -14,7 +14,7 @@
namespace Utopia\HTTP\Tests;
use PHPUnit\Framework\TestCase;
-use Utopia\Request;
+use Utopia\HTTP\Request;
class RequestTest extends TestCase
{
diff --git a/tests/RouteTest.php b/tests/RouteTest.php
index ad92a1de..bf62ae2b 100755
--- a/tests/RouteTest.php
+++ b/tests/RouteTest.php
@@ -14,7 +14,7 @@
namespace Utopia\HTTP;
use PHPUnit\Framework\TestCase;
-use Utopia\Validator\Text;
+use Utopia\HTTP\Validator\Text;
class RouteTest extends TestCase
{
diff --git a/tests/UtopiaRequestTest.php b/tests/UtopiaRequestTest.php
index 33363ede..8605f306 100644
--- a/tests/UtopiaRequestTest.php
+++ b/tests/UtopiaRequestTest.php
@@ -2,7 +2,7 @@
namespace Utopia\Tests;
-use Utopia\Request as UtopiaRequest;
+use Utopia\HTTP\Request as UtopiaRequest;
class UtopiaRequestTest extends UtopiaRequest
{
diff --git a/tests/e2e/server.php b/tests/e2e/server.php
index e9d900b8..55ab588c 100644
--- a/tests/e2e/server.php
+++ b/tests/e2e/server.php
@@ -2,9 +2,9 @@
require_once __DIR__ . '/../../vendor/autoload.php';
-use Utopia\App;
-use Utopia\Request;
-use Utopia\Response;
+use Utopia\HTTP\App;
+use Utopia\HTTP\Request;
+use Utopia\HTTP\Response;
ini_set('memory_limit', '512M');
ini_set('display_errors', 1);
From efb540b470e280863defd967e38d9ae5ec6ce8bb Mon Sep 17 00:00:00 2001
From: Eldad Fux
Date: Tue, 1 Feb 2022 07:52:22 +0200
Subject: [PATCH 06/10] Fixed namspaces
---
src/Adapter/FPM/Request.php | 2 +-
src/Adapter/FPM/Response.php | 2 +-
src/Adapter/Swoole/Request.php | 2 +-
src/Adapter/Swoole/Response.php | 2 +-
src/Adapter/Swoole/Server.php | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/Adapter/FPM/Request.php b/src/Adapter/FPM/Request.php
index 1ccbc0a3..32b6a312 100755
--- a/src/Adapter/FPM/Request.php
+++ b/src/Adapter/FPM/Request.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Adapter\FPM;
-use Utopia\HTTP\HTTP\Request as HTTPRequest;
+use Utopia\HTTP\Request as HTTPRequest;
class Request extends HTTPRequest
{
diff --git a/src/Adapter/FPM/Response.php b/src/Adapter/FPM/Response.php
index 1997f6f6..6aade9fa 100755
--- a/src/Adapter/FPM/Response.php
+++ b/src/Adapter/FPM/Response.php
@@ -12,7 +12,7 @@
namespace Utopia\HTTP\Adapter\FPM;
-use Utopia\HTTP\HTTP\Response as HTTPResponse;
+use Utopia\HTTP\Response as HTTPResponse;
class Response extends HTTPResponse
{
diff --git a/src/Adapter/Swoole/Request.php b/src/Adapter/Swoole/Request.php
index e30c9724..b0c72309 100644
--- a/src/Adapter/Swoole/Request.php
+++ b/src/Adapter/Swoole/Request.php
@@ -3,7 +3,7 @@
namespace Utopia\HTTP\Adapter\Swoole;
use Exception;
-use Utopia\HTTP\HTTP\Request as UtopiaRequest;
+use Utopia\HTTP\Request as UtopiaRequest;
use Swoole\Http\Request as SwooleRequest;
class Request extends UtopiaRequest
diff --git a/src/Adapter/Swoole/Response.php b/src/Adapter/Swoole/Response.php
index 7475f147..f7b96d5c 100644
--- a/src/Adapter/Swoole/Response.php
+++ b/src/Adapter/Swoole/Response.php
@@ -2,7 +2,7 @@
namespace Utopia\HTTP\Adapter\Swoole;
-use Utopia\HTTP\HTTP\Response as UtopiaResponse;
+use Utopia\HTTP\Response as UtopiaResponse;
use Swoole\Http\Response as SwooleResponse;
class Response extends UtopiaResponse
diff --git a/src/Adapter/Swoole/Server.php b/src/Adapter/Swoole/Server.php
index 8b6d2c0e..a0d1a606 100644
--- a/src/Adapter/Swoole/Server.php
+++ b/src/Adapter/Swoole/Server.php
@@ -5,7 +5,7 @@
use Swoole\Http\Server as SwooleServer;
use Swoole\Http\Request as SwooleRequest;
use Swoole\Http\Response as SwooleResponse;
-use Utopia\HTTP\HTTP\App;
+use Utopia\HTTP\App;
/**
* Utopia PHP Framework
From 1e5149a38dd468fa8d92b455d7544b9e0c451b49 Mon Sep 17 00:00:00 2001
From: Eldad Fux
Date: Tue, 1 Feb 2022 07:56:24 +0200
Subject: [PATCH 07/10] Utopia Framework -> Utopia HTTP
---
README.md | 8 ++++----
composer.json | 6 +++---
docs/Getting-Starting-Guide.md | 4 ++--
src/Adapter.php | 6 +++---
src/Adapter/FPM/Request.php | 6 +++---
src/Adapter/FPM/Response.php | 6 +++---
src/Adapter/Swoole/Server.php | 6 +++---
src/App.php | 6 +++---
src/Exception.php | 6 +++---
src/Request.php | 6 +++---
src/Response.php | 6 +++---
src/Route.php | 6 +++---
src/Server.php | 6 +++---
src/Validator.php | 6 +++---
src/Validator/ArrayList.php | 6 +++---
src/Validator/Assoc.php | 6 +++---
src/Validator/Boolean.php | 6 +++---
src/Validator/FloatValidator.php | 6 +++---
src/Validator/HexColor.php | 6 +++---
src/Validator/Integer.php | 6 +++---
src/Validator/JSON.php | 6 +++---
src/Validator/Numeric.php | 6 +++---
src/Validator/Range.php | 6 +++---
src/Validator/Text.php | 6 +++---
src/Validator/WhiteList.php | 6 +++---
src/Validator/Wildcard.php | 6 +++---
src/View.php | 6 +++---
tests/AppTest.php | 6 +++---
tests/RequestTest.php | 6 +++---
tests/ResponseTest.php | 6 +++---
tests/RouteTest.php | 6 +++---
tests/Validator/ArrayListTest.php | 6 +++---
tests/Validator/AssocTest.php | 6 +++---
tests/Validator/BooleanTest.php | 6 +++---
tests/Validator/FloatValidatorTest.php | 6 +++---
tests/Validator/HexColorTest.php | 6 +++---
tests/Validator/IntegerTest.php | 6 +++---
tests/Validator/JSONTest.php | 6 +++---
tests/Validator/NumericTest.php | 6 +++---
tests/Validator/RangeTest.php | 6 +++---
tests/Validator/TextTest.php | 6 +++---
tests/Validator/WhiteListTest.php | 6 +++---
tests/Validator/WildcardTest.php | 6 +++---
tests/ViewTest.php | 6 +++---
44 files changed, 132 insertions(+), 132 deletions(-)
diff --git a/README.md b/README.md
index 8c9f798e..c097ba6e 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[![Build Status](https://travis-ci.org/utopia-php/framework.svg?branch=master)](https://travis-ci.org/utopia-php/framework)
-![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/framework.svg)
+[![Build Status](https://travis-ci.org/utopia-php/http.svg?branch=master)](https://travis-ci.org/utopia-php/http)
+![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/http.svg)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://discord.gg/GSeTUeA)
Utopia Framework is a PHP MVC based framework with minimal must-have features for professional, simple, advanced and secure web development. This library is maintained by the [Appwrite team](https://appwrite.io).
@@ -14,7 +14,7 @@ Utopia Framework is dependency free. Any extra features such as authentication,
Install using composer:
```bash
-composer require utopia-php/framework
+composer require utopia-php/http
```
Init your first application:
@@ -88,7 +88,7 @@ All code contributions - including those of people having commit access - must g
Fork the project, create a feature branch, and send us a pull request.
-You can refer to the [Contributing Guide](https://github.com/utopia-php/framework/blob/master/CONTRIBUTING.md) for more info.
+You can refer to the [Contributing Guide](https://github.com/utopia-php/http/blob/master/CONTRIBUTING.md) for more info.
For security issues, please email security@appwrite.io instead of posting a public issue in GitHub.
diff --git a/composer.json b/composer.json
index 5fb0008a..002cf7da 100755
--- a/composer.json
+++ b/composer.json
@@ -1,8 +1,8 @@
{
- "name": "utopia-php/framework",
- "description": "A simple, light and advanced PHP framework",
+ "name": "utopia-php/http",
+ "description": "A simple, light and advanced PHP framework for building HTTP servers",
"type": "library",
- "keywords": ["php","framework", "upf"],
+ "keywords": ["php","framework", "upf", "http"],
"license": "MIT",
"minimum-stability": "stable",
"authors": [
diff --git a/docs/Getting-Starting-Guide.md b/docs/Getting-Starting-Guide.md
index 66bfe830..b87be2aa 100644
--- a/docs/Getting-Starting-Guide.md
+++ b/docs/Getting-Starting-Guide.md
@@ -130,7 +130,7 @@ $response
->send('')
```
-You can find the details of other status codes by visiting our [GitHub repository](https://github.com/utopia-php/framework/blob/master/src/Response.php).
+You can find the details of other status codes by visiting our [GitHub repository](https://github.com/utopia-php/http/blob/master/src/Response.php).
# Advanced Utopia
@@ -280,7 +280,7 @@ App::shutdown(function($request) {
An example of the shutdown method is shown above. The shutdown method uses the Utopia CLI lib to log api to the console; this is done for routes in the `api` group in the current example.
# Running Locally
-If you have PHP and Composer installed on your device, you can run Utopia apps locally by downloading the Utopia-PHP/framework dependency using `composer require utopia-php/framework` command.
+If you have PHP and Composer installed on your device, you can run Utopia apps locally by downloading the utopia-php/http dependency using `composer require utopia-php/http` command.
> Utopia Framework requires PHP 7.3 or later. We recommend using the latest PHP version whenever possible.
diff --git a/src/Adapter.php b/src/Adapter.php
index d829ba35..8878346e 100644
--- a/src/Adapter.php
+++ b/src/Adapter.php
@@ -7,12 +7,12 @@
use Swoole\Http\Response as SwooleResponse;
/**
- * Utopia PHP Framework
+ * Utopia HTTP
*
- * @package Framework
+ * @package HTTP
* @subpackage Core
*
- * @link https://github.com/utopia-php/framework
+ * @link https://github.com/utopia-php/http
* @author Appwrite Team
*/
abstract class Adapter
diff --git a/src/Adapter/FPM/Request.php b/src/Adapter/FPM/Request.php
index 32b6a312..e883338e 100755
--- a/src/Adapter/FPM/Request.php
+++ b/src/Adapter/FPM/Request.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Adapter/FPM/Response.php b/src/Adapter/FPM/Response.php
index 6aade9fa..6ac6caef 100755
--- a/src/Adapter/FPM/Response.php
+++ b/src/Adapter/FPM/Response.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Adapter/Swoole/Server.php b/src/Adapter/Swoole/Server.php
index a0d1a606..213dab8f 100644
--- a/src/Adapter/Swoole/Server.php
+++ b/src/Adapter/Swoole/Server.php
@@ -8,12 +8,12 @@
use Utopia\HTTP\App;
/**
- * Utopia PHP Framework
+ * Utopia HTTP
*
- * @package Framework
+ * @package HTTP
* @subpackage Core
*
- * @link https://github.com/utopia-php/framework
+ * @link https://github.com/utopia-php/http
* @author Appwrite Team
*/
class Server
diff --git a/src/App.php b/src/App.php
index 5a69c5d2..59e74929 100755
--- a/src/App.php
+++ b/src/App.php
@@ -1,11 +1,11 @@
*/
diff --git a/src/Exception.php b/src/Exception.php
index f051369c..87692e79 100644
--- a/src/Exception.php
+++ b/src/Exception.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Request.php b/src/Request.php
index e9cdc6d3..7aef5685 100755
--- a/src/Request.php
+++ b/src/Request.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Response.php b/src/Response.php
index febc8c7e..7150cc58 100755
--- a/src/Response.php
+++ b/src/Response.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Route.php b/src/Route.php
index 654bee02..febf35e6 100755
--- a/src/Route.php
+++ b/src/Route.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Server.php b/src/Server.php
index a057e3e3..ef73c27e 100644
--- a/src/Server.php
+++ b/src/Server.php
@@ -5,12 +5,12 @@
use Utopia\HTTP\Adapter;
/**
- * Utopia PHP Framework
+ * Utopia HTTP
*
- * @package Framework
+ * @package HTTP
* @subpackage Core
*
- * @link https://github.com/utopia-php/framework
+ * @link https://github.com/utopia-php/http
* @author Appwrite Team
*/
class Server
diff --git a/src/Validator.php b/src/Validator.php
index 72211087..47408879 100755
--- a/src/Validator.php
+++ b/src/Validator.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Validator/ArrayList.php b/src/Validator/ArrayList.php
index 62578c22..2e9a69e5 100644
--- a/src/Validator/ArrayList.php
+++ b/src/Validator/ArrayList.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Validator/Assoc.php b/src/Validator/Assoc.php
index 702b9863..ce8de00f 100644
--- a/src/Validator/Assoc.php
+++ b/src/Validator/Assoc.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Validator/Boolean.php b/src/Validator/Boolean.php
index c3b46650..c348bf36 100644
--- a/src/Validator/Boolean.php
+++ b/src/Validator/Boolean.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Validator/FloatValidator.php b/src/Validator/FloatValidator.php
index 56d03117..45d6b0b4 100755
--- a/src/Validator/FloatValidator.php
+++ b/src/Validator/FloatValidator.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Validator/HexColor.php b/src/Validator/HexColor.php
index abf6cc50..5ad4d1fb 100644
--- a/src/Validator/HexColor.php
+++ b/src/Validator/HexColor.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Validator/Integer.php b/src/Validator/Integer.php
index eaa8e4cc..91f82124 100755
--- a/src/Validator/Integer.php
+++ b/src/Validator/Integer.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Validator/JSON.php b/src/Validator/JSON.php
index 786f2abb..eef7385d 100644
--- a/src/Validator/JSON.php
+++ b/src/Validator/JSON.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Validator/Numeric.php b/src/Validator/Numeric.php
index 94b9b8b1..eedbc79a 100755
--- a/src/Validator/Numeric.php
+++ b/src/Validator/Numeric.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Validator/Range.php b/src/Validator/Range.php
index 0a6f9df9..d603e729 100755
--- a/src/Validator/Range.php
+++ b/src/Validator/Range.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Validator/Text.php b/src/Validator/Text.php
index d389e4aa..a485a3cd 100644
--- a/src/Validator/Text.php
+++ b/src/Validator/Text.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Validator/WhiteList.php b/src/Validator/WhiteList.php
index 97e0dda4..f9aaad1a 100755
--- a/src/Validator/WhiteList.php
+++ b/src/Validator/WhiteList.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/Validator/Wildcard.php b/src/Validator/Wildcard.php
index 6ef31907..e4e63666 100644
--- a/src/Validator/Wildcard.php
+++ b/src/Validator/Wildcard.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/src/View.php b/src/View.php
index 93318529..abdda585 100755
--- a/src/View.php
+++ b/src/View.php
@@ -1,11 +1,11 @@
* @license The MIT License (MIT)
*/
diff --git a/tests/AppTest.php b/tests/AppTest.php
index e57b999e..c8155dce 100755
--- a/tests/AppTest.php
+++ b/tests/AppTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/RequestTest.php b/tests/RequestTest.php
index 729e3ceb..1e6b3ecc 100755
--- a/tests/RequestTest.php
+++ b/tests/RequestTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php
index 94d51465..a8f95698 100755
--- a/tests/ResponseTest.php
+++ b/tests/ResponseTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/RouteTest.php b/tests/RouteTest.php
index bf62ae2b..3851196a 100755
--- a/tests/RouteTest.php
+++ b/tests/RouteTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/Validator/ArrayListTest.php b/tests/Validator/ArrayListTest.php
index fde89b89..0d506b0e 100755
--- a/tests/Validator/ArrayListTest.php
+++ b/tests/Validator/ArrayListTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/Validator/AssocTest.php b/tests/Validator/AssocTest.php
index 20b9c57f..ac4918f4 100755
--- a/tests/Validator/AssocTest.php
+++ b/tests/Validator/AssocTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/Validator/BooleanTest.php b/tests/Validator/BooleanTest.php
index d063c674..64787842 100755
--- a/tests/Validator/BooleanTest.php
+++ b/tests/Validator/BooleanTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/Validator/FloatValidatorTest.php b/tests/Validator/FloatValidatorTest.php
index ede305e6..a19daad0 100755
--- a/tests/Validator/FloatValidatorTest.php
+++ b/tests/Validator/FloatValidatorTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/Validator/HexColorTest.php b/tests/Validator/HexColorTest.php
index 676cf750..6bb7f5ab 100755
--- a/tests/Validator/HexColorTest.php
+++ b/tests/Validator/HexColorTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/Validator/IntegerTest.php b/tests/Validator/IntegerTest.php
index 1bf10969..a9bcb85e 100755
--- a/tests/Validator/IntegerTest.php
+++ b/tests/Validator/IntegerTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/Validator/JSONTest.php b/tests/Validator/JSONTest.php
index a0458ffa..a7dfb403 100755
--- a/tests/Validator/JSONTest.php
+++ b/tests/Validator/JSONTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/Validator/NumericTest.php b/tests/Validator/NumericTest.php
index dd4fbb72..ee0b9d6e 100755
--- a/tests/Validator/NumericTest.php
+++ b/tests/Validator/NumericTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/Validator/RangeTest.php b/tests/Validator/RangeTest.php
index a0a2de02..97ca2a25 100755
--- a/tests/Validator/RangeTest.php
+++ b/tests/Validator/RangeTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/Validator/TextTest.php b/tests/Validator/TextTest.php
index 207688eb..323c2976 100755
--- a/tests/Validator/TextTest.php
+++ b/tests/Validator/TextTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/Validator/WhiteListTest.php b/tests/Validator/WhiteListTest.php
index 677e9a05..2cc31d40 100755
--- a/tests/Validator/WhiteListTest.php
+++ b/tests/Validator/WhiteListTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/Validator/WildcardTest.php b/tests/Validator/WildcardTest.php
index 4ce4a3d7..823af3c4 100644
--- a/tests/Validator/WildcardTest.php
+++ b/tests/Validator/WildcardTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
diff --git a/tests/ViewTest.php b/tests/ViewTest.php
index a25589da..6be60e77 100755
--- a/tests/ViewTest.php
+++ b/tests/ViewTest.php
@@ -1,11 +1,11 @@
* @version 1.0 RC4
* @license The MIT License (MIT)
From 961d8307fcc2592a61fd8c9642d2340a97c3b501 Mon Sep 17 00:00:00 2001
From: Eldad Fux
Date: Tue, 1 Feb 2022 08:42:18 +0200
Subject: [PATCH 08/10] Fixed tests
---
src/Adapter.php | 4 ----
src/Adapter/Swoole/Response.php | 2 ++
src/Validator/ArrayList.php | 2 +-
src/Validator/Assoc.php | 2 +-
src/Validator/Boolean.php | 2 +-
src/Validator/FloatValidator.php | 2 +-
src/Validator/Integer.php | 2 +-
src/Validator/Numeric.php | 2 +-
src/Validator/Range.php | 2 +-
src/Validator/Text.php | 2 +-
src/Validator/WhiteList.php | 2 +-
src/Validator/Wildcard.php | 2 +-
tests/AppTest.php | 4 +++-
tests/RequestTest.php | 2 +-
tests/ResponseTest.php | 5 +++--
tests/UtopiaRequestTest.php | 4 ++--
tests/Validator/ArrayListTest.php | 4 ++--
tests/Validator/AssocTest.php | 2 +-
tests/Validator/BooleanTest.php | 2 +-
tests/Validator/FloatValidatorTest.php | 4 ++--
tests/Validator/HexColorTest.php | 2 +-
tests/Validator/IntegerTest.php | 8 ++++----
tests/Validator/JSONTest.php | 2 +-
tests/Validator/NumericTest.php | 2 +-
tests/Validator/RangeTest.php | 16 ++++++++--------
tests/Validator/TextTest.php | 2 +-
tests/Validator/WhiteListTest.php | 2 +-
tests/Validator/WildcardTest.php | 2 +-
tests/ViewTest.php | 4 ++--
tests/e2e/server.php | 4 ++--
30 files changed, 49 insertions(+), 48 deletions(-)
diff --git a/src/Adapter.php b/src/Adapter.php
index 8878346e..0081f19c 100644
--- a/src/Adapter.php
+++ b/src/Adapter.php
@@ -2,10 +2,6 @@
namespace Utopia\HTTP;
-use Swoole\Http\Server;
-use Swoole\Http\Request as SwooleRequest;
-use Swoole\Http\Response as SwooleResponse;
-
/**
* Utopia HTTP
*
diff --git a/src/Adapter/Swoole/Response.php b/src/Adapter/Swoole/Response.php
index f7b96d5c..a6676d1d 100644
--- a/src/Adapter/Swoole/Response.php
+++ b/src/Adapter/Swoole/Response.php
@@ -35,6 +35,8 @@ class Response extends UtopiaResponse
/**
* Response constructor.
+ *
+ * @param SwooleResponse $response
*/
public function __construct(SwooleResponse $response)
{
diff --git a/src/Validator/ArrayList.php b/src/Validator/ArrayList.php
index 2e9a69e5..7a1ac795 100644
--- a/src/Validator/ArrayList.php
+++ b/src/Validator/ArrayList.php
@@ -19,7 +19,7 @@
*
* Validate that an variable is a valid array value and each element passes given validation
*
- * @package Utopia\Validator
+ * @package Utopia\HTTP\Validator
*/
class ArrayList extends Validator
{
diff --git a/src/Validator/Assoc.php b/src/Validator/Assoc.php
index ce8de00f..a2b814cb 100644
--- a/src/Validator/Assoc.php
+++ b/src/Validator/Assoc.php
@@ -19,7 +19,7 @@
*
* Validate that an variable is a valid array value and each element passes given validation
*
- * @package Utopia\Validator
+ * @package Utopia\HTTP\Validator
*/
class Assoc extends Validator
{
diff --git a/src/Validator/Boolean.php b/src/Validator/Boolean.php
index c348bf36..97d0a68c 100644
--- a/src/Validator/Boolean.php
+++ b/src/Validator/Boolean.php
@@ -19,7 +19,7 @@
*
* Validate that an variable is a boolean value
*
- * @package Utopia\Validator
+ * @package Utopia\HTTP\Validator
*/
class Boolean extends Validator
{
diff --git a/src/Validator/FloatValidator.php b/src/Validator/FloatValidator.php
index 45d6b0b4..ba64207b 100755
--- a/src/Validator/FloatValidator.php
+++ b/src/Validator/FloatValidator.php
@@ -19,7 +19,7 @@
*
* Validate that an variable is a float
*
- * @package Utopia\Validator
+ * @package Utopia\HTTP\Validator
*/
class FloatValidator extends Validator
{
diff --git a/src/Validator/Integer.php b/src/Validator/Integer.php
index 91f82124..f727dedb 100755
--- a/src/Validator/Integer.php
+++ b/src/Validator/Integer.php
@@ -18,7 +18,7 @@
*
* Validate that an variable is an integer
*
- * @package Utopia\Validator
+ * @package Utopia\HTTP\Validator
*/
class Integer extends Validator
{
diff --git a/src/Validator/Numeric.php b/src/Validator/Numeric.php
index eedbc79a..9e6efe4c 100755
--- a/src/Validator/Numeric.php
+++ b/src/Validator/Numeric.php
@@ -19,7 +19,7 @@
*
* Validate that an variable is numeric
*
- * @package Utopia\Validator
+ * @package Utopia\HTTP\Validator
*/
class Numeric extends Validator
{
diff --git a/src/Validator/Range.php b/src/Validator/Range.php
index d603e729..11c34baa 100755
--- a/src/Validator/Range.php
+++ b/src/Validator/Range.php
@@ -17,7 +17,7 @@
*
* Validates that an number is in range.
*
- * @package Utopia\Validator
+ * @package Utopia\HTTP\Validator
*/
class Range extends Numeric
{
diff --git a/src/Validator/Text.php b/src/Validator/Text.php
index a485a3cd..dc0d763a 100644
--- a/src/Validator/Text.php
+++ b/src/Validator/Text.php
@@ -19,7 +19,7 @@
*
* Validate that an variable is a valid text value
*
- * @package Utopia\Validator
+ * @package Utopia\HTTP\Validator
*/
class Text extends Validator
{
diff --git a/src/Validator/WhiteList.php b/src/Validator/WhiteList.php
index f9aaad1a..328d6598 100755
--- a/src/Validator/WhiteList.php
+++ b/src/Validator/WhiteList.php
@@ -19,7 +19,7 @@
*
* Checks if a variable is inside predefined white list.
*
- * @package Utopia\Validator
+ * @package Utopia\HTTP\Validator
*/
class WhiteList extends Validator
{
diff --git a/src/Validator/Wildcard.php b/src/Validator/Wildcard.php
index e4e63666..34608ceb 100644
--- a/src/Validator/Wildcard.php
+++ b/src/Validator/Wildcard.php
@@ -19,7 +19,7 @@
*
* Does not perform any validation. Always returns valid
*
- * @package Utopia\Validator
+ * @package Utopia\HTTP\Validator
*/
class Wildcard extends Validator
{
diff --git a/tests/AppTest.php b/tests/AppTest.php
index c8155dce..af51f5f2 100755
--- a/tests/AppTest.php
+++ b/tests/AppTest.php
@@ -14,8 +14,10 @@
namespace Utopia\HTTP;
use PHPUnit\Framework\TestCase;
-use Utopia\HTTP\Tests\UtopiaRequestTest;
+use Utopia\HTTP\Adapter\FPM\Request;
+use Utopia\HTTP\Adapter\FPM\Response;
use Utopia\HTTP\Validator\Text;
+use Utopia\Tests\UtopiaRequestTest;
App::setResource('rand', function () {return rand();});
App::setResource('first', function ($second) {return 'first-'.$second;}, ['second']);
diff --git a/tests/RequestTest.php b/tests/RequestTest.php
index 1e6b3ecc..45d75d9a 100755
--- a/tests/RequestTest.php
+++ b/tests/RequestTest.php
@@ -14,7 +14,7 @@
namespace Utopia\HTTP\Tests;
use PHPUnit\Framework\TestCase;
-use Utopia\HTTP\Request;
+use Utopia\HTTP\Adapter\FPM\Request;
class RequestTest extends TestCase
{
diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php
index a8f95698..b38bec69 100755
--- a/tests/ResponseTest.php
+++ b/tests/ResponseTest.php
@@ -14,6 +14,7 @@
namespace Utopia\HTTP;
use PHPUnit\Framework\TestCase;
+use Utopia\HTTP\Adapter\FPM\Response;
class ResponseTest extends TestCase
{
@@ -37,7 +38,7 @@ public function testSetContentType()
$contentType = $this->response->setContentType(Response::CONTENT_TYPE_HTML, Response::CHARSET_UTF8);
// Assertions
- $this->assertInstanceOf('Utopia\Response', $contentType);
+ $this->assertInstanceOf('Utopia\HTTP\Response', $contentType);
}
public function testSetStatus()
@@ -45,7 +46,7 @@ public function testSetStatus()
$status = $this->response->setStatusCode(Response::STATUS_CODE_OK);
// Assertions
- $this->assertInstanceOf('Utopia\Response', $status);
+ $this->assertInstanceOf('Utopia\HTTP\Response', $status);
try{
$this->response->setStatusCode(0); // Unknown status code
diff --git a/tests/UtopiaRequestTest.php b/tests/UtopiaRequestTest.php
index 8605f306..4611aa5f 100644
--- a/tests/UtopiaRequestTest.php
+++ b/tests/UtopiaRequestTest.php
@@ -2,9 +2,9 @@
namespace Utopia\Tests;
-use Utopia\HTTP\Request as UtopiaRequest;
+use Utopia\HTTP\Adapter\FPM\Request;
-class UtopiaRequestTest extends UtopiaRequest
+class UtopiaRequestTest extends Request
{
/**
* @var array
diff --git a/tests/Validator/ArrayListTest.php b/tests/Validator/ArrayListTest.php
index 0d506b0e..87f258c4 100755
--- a/tests/Validator/ArrayListTest.php
+++ b/tests/Validator/ArrayListTest.php
@@ -57,8 +57,8 @@ public function testIsValid()
$this->assertEquals(false, $this->arrayList2->isValid('string'));
$this->assertEquals(true, $this->arrayList2->isValid([1, 2, 3]));
$this->assertEquals(false, $this->arrayList2->isValid(1, '2', 3));
- $this->assertEquals($this->arrayList1->getType(), \Utopia\Validator::TYPE_STRING);
- $this->assertEquals($this->arrayList2->getType(), \Utopia\Validator::TYPE_MIXED);
+ $this->assertEquals($this->arrayList1->getType(), \Utopia\HTTP\Validator::TYPE_STRING);
+ $this->assertEquals($this->arrayList2->getType(), \Utopia\HTTP\Validator::TYPE_MIXED);
$this->assertEquals($this->arrayList1->isArray(), true);
$this->assertEquals(true, $this->arrayList3->isValid([1]));
diff --git a/tests/Validator/AssocTest.php b/tests/Validator/AssocTest.php
index ac4918f4..0330ce11 100755
--- a/tests/Validator/AssocTest.php
+++ b/tests/Validator/AssocTest.php
@@ -44,7 +44,7 @@ public function testIsValid()
$this->assertEquals(true, $this->assoc->isValid([]));
$this->assertEquals(true, $this->assoc->isValid(['value' => str_repeat("-", 62000)]));
$this->assertEquals(false, $this->assoc->isValid(['value' => str_repeat("-", 66000)]));
- $this->assertEquals($this->assoc->getType(), \Utopia\Validator::TYPE_ARRAY);
+ $this->assertEquals($this->assoc->getType(), \Utopia\HTTP\Validator::TYPE_ARRAY);
$this->assertEquals($this->assoc->isArray(), true);
}
}
diff --git a/tests/Validator/BooleanTest.php b/tests/Validator/BooleanTest.php
index 64787842..47850ebc 100755
--- a/tests/Validator/BooleanTest.php
+++ b/tests/Validator/BooleanTest.php
@@ -60,7 +60,7 @@ public function testIsValid()
$this->assertEquals(false, $this->boolean->isValid(['string', 'string']));
$this->assertEquals(false, $this->boolean->isValid('string'));
$this->assertEquals(false, $this->boolean->isValid(1.2));
- $this->assertEquals($this->boolean->getType(), \Utopia\Validator::TYPE_BOOLEAN);
+ $this->assertEquals($this->boolean->getType(), \Utopia\HTTP\Validator::TYPE_BOOLEAN);
$this->assertEquals($this->boolean->isArray(), false);
}
}
diff --git a/tests/Validator/FloatValidatorTest.php b/tests/Validator/FloatValidatorTest.php
index a19daad0..7f4ae0dd 100755
--- a/tests/Validator/FloatValidatorTest.php
+++ b/tests/Validator/FloatValidatorTest.php
@@ -50,7 +50,7 @@ public function testIsValid()
$this->assertEquals($this->validator->isValid(true), false);
$this->assertEquals($this->validator->isValid('23.5'), false);
$this->assertEquals($this->validator->isValid('23'), false);
- $this->assertEquals($this->validator->getType(), \Utopia\Validator::TYPE_FLOAT);
+ $this->assertEquals($this->validator->getType(), \Utopia\HTTP\Validator::TYPE_FLOAT);
$this->assertEquals($this->validator->isArray(), false);
// Assertions Loose
@@ -62,7 +62,7 @@ public function testIsValid()
$this->assertEquals($this->looseValidator->isValid(true), false);
$this->assertEquals($this->looseValidator->isValid('23.5'), true);
$this->assertEquals($this->looseValidator->isValid('23'), true);
- $this->assertEquals($this->looseValidator->getType(), \Utopia\Validator::TYPE_FLOAT);
+ $this->assertEquals($this->looseValidator->getType(), \Utopia\HTTP\Validator::TYPE_FLOAT);
$this->assertEquals($this->looseValidator->isArray(), false);
}
}
diff --git a/tests/Validator/HexColorTest.php b/tests/Validator/HexColorTest.php
index 6bb7f5ab..310bbbdd 100755
--- a/tests/Validator/HexColorTest.php
+++ b/tests/Validator/HexColorTest.php
@@ -44,7 +44,7 @@ public function testIsValid()
$this->assertEquals($this->hexColor->isValid('ffffff'), true);
$this->assertEquals($this->hexColor->isValid('fff'), true);
$this->assertEquals($this->hexColor->isValid('000000'), true);
- $this->assertEquals($this->hexColor->getType(), \Utopia\Validator::TYPE_STRING);
+ $this->assertEquals($this->hexColor->getType(), \Utopia\HTTP\Validator::TYPE_STRING);
$this->assertEquals($this->hexColor->isArray(), false);
}
}
diff --git a/tests/Validator/IntegerTest.php b/tests/Validator/IntegerTest.php
index a9bcb85e..9ebbb8eb 100755
--- a/tests/Validator/IntegerTest.php
+++ b/tests/Validator/IntegerTest.php
@@ -18,12 +18,12 @@
class IntegerTest extends TestCase
{
/**
- * @var \Utopia\Validator\Integer
+ * @var \Utopia\HTTP\Validator\Integer
*/
protected $validator = null;
/**
- * @var \Utopia\Validator\Integer
+ * @var \Utopia\HTTP\Validator\Integer
*/
protected $looseValidator = null;
@@ -49,7 +49,7 @@ public function testIsValid()
$this->assertEquals($this->validator->isValid(null), false);
$this->assertEquals($this->validator->isValid(true), false);
$this->assertEquals($this->validator->isValid(false), false);
- $this->assertEquals($this->validator->getType(), \Utopia\Validator::TYPE_INTEGER);
+ $this->assertEquals($this->validator->getType(), \Utopia\HTTP\Validator::TYPE_INTEGER);
$this->assertEquals($this->validator->isArray(), false);
// Assertions loose
@@ -60,7 +60,7 @@ public function testIsValid()
$this->assertEquals($this->looseValidator->isValid(null), false);
$this->assertEquals($this->looseValidator->isValid(true), false);
$this->assertEquals($this->looseValidator->isValid(false), false);
- $this->assertEquals($this->looseValidator->getType(), \Utopia\Validator::TYPE_INTEGER);
+ $this->assertEquals($this->looseValidator->getType(), \Utopia\HTTP\Validator::TYPE_INTEGER);
$this->assertEquals($this->looseValidator->isArray(), false);
}
}
diff --git a/tests/Validator/JSONTest.php b/tests/Validator/JSONTest.php
index a7dfb403..a97fe9e9 100755
--- a/tests/Validator/JSONTest.php
+++ b/tests/Validator/JSONTest.php
@@ -47,7 +47,7 @@ public function testIsValid()
$this->assertEquals(true, $this->json->isValid(['test']));
$this->assertEquals(true, $this->json->isValid(['test' => 'demo']));
$this->assertEquals(true, $this->json->isValid('{"test": "demo"}'));
- $this->assertEquals($this->json->getType(), \Utopia\Validator::TYPE_OBJECT);
+ $this->assertEquals($this->json->getType(), \Utopia\HTTP\Validator::TYPE_OBJECT);
$this->assertEquals($this->json->isArray(), false);
}
}
diff --git a/tests/Validator/NumericTest.php b/tests/Validator/NumericTest.php
index ee0b9d6e..eea8738c 100755
--- a/tests/Validator/NumericTest.php
+++ b/tests/Validator/NumericTest.php
@@ -43,7 +43,7 @@ public function testIsValid()
$this->assertEquals($this->numeric->isValid(9.1), true);
$this->assertEquals($this->numeric->isValid('not numeric'), false);
$this->assertEquals($this->numeric->isValid([]), false);
- $this->assertEquals($this->numeric->getType(), \Utopia\Validator::TYPE_MIXED);
+ $this->assertEquals($this->numeric->getType(), \Utopia\HTTP\Validator::TYPE_MIXED);
$this->assertEquals($this->numeric->isArray(), false);
}
}
diff --git a/tests/Validator/RangeTest.php b/tests/Validator/RangeTest.php
index 97ca2a25..cfad1f4b 100755
--- a/tests/Validator/RangeTest.php
+++ b/tests/Validator/RangeTest.php
@@ -25,8 +25,8 @@ class RangeTest extends TestCase
public function setUp():void
{
- $this->rangeFloat = new Range(0, 1, \Utopia\Validator::TYPE_FLOAT);
- $this->rangeInt = new Range(0, 5, \Utopia\Validator::TYPE_INTEGER);
+ $this->rangeFloat = new Range(0, 1, \Utopia\HTTP\Validator::TYPE_FLOAT);
+ $this->rangeInt = new Range(0, 5, \Utopia\HTTP\Validator::TYPE_INTEGER);
}
public function tearDown():void
@@ -47,9 +47,9 @@ public function testIsValid()
$this->assertEquals($this->rangeInt->isValid(-1), false);
$this->assertEquals($this->rangeInt->getMin(), 0);
$this->assertEquals($this->rangeInt->getMax(), 5);
- $this->assertEquals($this->rangeInt->getFormat(), \Utopia\Validator::TYPE_INTEGER);
+ $this->assertEquals($this->rangeInt->getFormat(), \Utopia\HTTP\Validator::TYPE_INTEGER);
$this->assertEquals($this->rangeInt->isArray(), false);
- $this->assertEquals($this->rangeInt->getType(), \Utopia\Validator::TYPE_INTEGER);
+ $this->assertEquals($this->rangeInt->getType(), \Utopia\HTTP\Validator::TYPE_INTEGER);
// Assertions for float
$this->assertEquals($this->rangeFloat->isValid(0.0), true);
@@ -62,15 +62,15 @@ public function testIsValid()
$this->assertEquals($this->rangeFloat->isValid(-1), false);
$this->assertEquals($this->rangeFloat->getMin(), 0);
$this->assertEquals($this->rangeFloat->getMax(), 1);
- $this->assertEquals($this->rangeFloat->getFormat(), \Utopia\Validator::TYPE_FLOAT);
+ $this->assertEquals($this->rangeFloat->getFormat(), \Utopia\HTTP\Validator::TYPE_FLOAT);
$this->assertEquals($this->rangeFloat->isArray(), false);
- $this->assertEquals($this->rangeFloat->getType(), \Utopia\Validator::TYPE_FLOAT);
+ $this->assertEquals($this->rangeFloat->getType(), \Utopia\HTTP\Validator::TYPE_FLOAT);
}
public function testInfinity()
{
- $integer = new Range(5, INF, \Utopia\Validator::TYPE_INTEGER);
- $float = new Range(-INF, 45.6, \Utopia\Validator::TYPE_FLOAT);
+ $integer = new Range(5, INF, \Utopia\HTTP\Validator::TYPE_INTEGER);
+ $float = new Range(-INF, 45.6, \Utopia\HTTP\Validator::TYPE_FLOAT);
$this->assertEquals(true, $integer->isValid(25));
$this->assertEquals(false, $integer->isValid(3));
diff --git a/tests/Validator/TextTest.php b/tests/Validator/TextTest.php
index 323c2976..fbef1acf 100755
--- a/tests/Validator/TextTest.php
+++ b/tests/Validator/TextTest.php
@@ -43,6 +43,6 @@ public function testIsValid()
$this->assertEquals(false, $this->text->isValid(["seven", 8, 9.0]));
$this->assertEquals(false, $this->text->isValid(false));
$this->assertEquals(false, $this->text->isArray());
- $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->text->getType());
+ $this->assertEquals(\Utopia\HTTP\Validator::TYPE_STRING, $this->text->getType());
}
}
diff --git a/tests/Validator/WhiteListTest.php b/tests/Validator/WhiteListTest.php
index 2cc31d40..dd3a48ef 100755
--- a/tests/Validator/WhiteListTest.php
+++ b/tests/Validator/WhiteListTest.php
@@ -29,7 +29,7 @@ public function testIsValid()
$this->assertEquals($whiteList->isValid(3), true);
$this->assertEquals($whiteList->isValid(5), false);
$this->assertEquals($whiteList->getList(), ['string1', 'string2', 3, 4]);
- $this->assertEquals($whiteList->getType(), \Utopia\Validator::TYPE_STRING); //string by default
+ $this->assertEquals($whiteList->getType(), \Utopia\HTTP\Validator::TYPE_STRING); //string by default
$this->assertEquals($whiteList->isArray(), false);
$whiteList = new WhiteList(['string1', 'string2', 3, 4], false);
diff --git a/tests/Validator/WildcardTest.php b/tests/Validator/WildcardTest.php
index 823af3c4..804a0f02 100644
--- a/tests/Validator/WildcardTest.php
+++ b/tests/Validator/WildcardTest.php
@@ -39,7 +39,7 @@ public function testIsValid()
$this->assertEquals(true, $this->wildcard->isValid(1));
$this->assertEquals(true, $this->wildcard->isValid(true));
$this->assertEquals(true, $this->wildcard->isValid(false));
- $this->assertEquals($this->wildcard->getType(), \Utopia\Validator::TYPE_STRING);
+ $this->assertEquals($this->wildcard->getType(), \Utopia\HTTP\Validator::TYPE_STRING);
$this->assertEquals($this->wildcard->isArray(), false);
}
}
diff --git a/tests/ViewTest.php b/tests/ViewTest.php
index 6be60e77..c9b66aad 100755
--- a/tests/ViewTest.php
+++ b/tests/ViewTest.php
@@ -37,7 +37,7 @@ public function testSetParam()
$value = $this->view->setParam('key', 'value');
// Assertions
- $this->assertInstanceOf('Utopia\View', $value);
+ $this->assertInstanceOf('Utopia\HTTP\View', $value);
}
public function testGetParam()
@@ -54,7 +54,7 @@ public function testSetPath()
$value = $this->view->setPath('mocks/View/fake.phtml');
// Assertions
- $this->assertInstanceOf('Utopia\View', $value);
+ $this->assertInstanceOf('Utopia\HTTP\View', $value);
}
public function testSetRendered()
diff --git a/tests/e2e/server.php b/tests/e2e/server.php
index 55ab588c..e591f501 100644
--- a/tests/e2e/server.php
+++ b/tests/e2e/server.php
@@ -2,9 +2,9 @@
require_once __DIR__ . '/../../vendor/autoload.php';
+use Utopia\HTTP\Adapter\FPM\Request;
+use Utopia\HTTP\Adapter\FPM\Response;
use Utopia\HTTP\App;
-use Utopia\HTTP\Request;
-use Utopia\HTTP\Response;
ini_set('memory_limit', '512M');
ini_set('display_errors', 1);
From 93269658c2ccca2f48b79b1cf7edbf97d328096f Mon Sep 17 00:00:00 2001
From: Eldad Fux
Date: Sat, 12 Mar 2022 15:47:05 +0200
Subject: [PATCH 09/10] Updated doc blocks checks
---
docker-compose.yml | 1 +
src/Adapter/Swoole/Files.php | 12 ++++++------
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/docker-compose.yml b/docker-compose.yml
index 55ad1dfc..f05d4d6b 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -6,4 +6,5 @@ services:
ports:
- "9020:80"
volumes:
+ - .:/usr/share/nginx/html
- ./tests:/usr/share/nginx/html/tests
\ No newline at end of file
diff --git a/src/Adapter/Swoole/Files.php b/src/Adapter/Swoole/Files.php
index f59e5535..7b042e49 100644
--- a/src/Adapter/Swoole/Files.php
+++ b/src/Adapter/Swoole/Files.php
@@ -33,7 +33,7 @@ class Files
/**
* Add MimeType
*
- * @var string $mimeType
+ * @param string $mimeType
*
* @return void
*/
@@ -45,7 +45,7 @@ public static function addMimeType(string $mimeType): void
/**
* Remove MimeType
*
- * @var string $mimeType
+ * @param string $mimeType
*
* @return void
*/
@@ -79,7 +79,7 @@ public static function getCount(): int
/**
* Load
*
- * @var string $path
+ * @param string $path
*
* @return void
*/
@@ -135,7 +135,7 @@ public static function load(string $directory, string $root = null): void
/**
* Is File Loaded
*
- * @var string $uri
+ * @param string $uri
*/
public static function isFileLoaded(string $uri): bool
{
@@ -149,7 +149,7 @@ public static function isFileLoaded(string $uri): bool
/**
* Get File Contants
*
- * @var string $uri
+ * @param string $uri
*/
public static function getFileContents(string $uri): string
{
@@ -163,7 +163,7 @@ public static function getFileContents(string $uri): string
/**
* Get File MimeType
*
- * @var string $uri
+ * @param string $uri
*/
public static function getFileMimeType(string $uri): string
{
From 1958e1de6f61c3ce67db06305c3275cdb282cabe Mon Sep 17 00:00:00 2001
From: Eldad Fux
Date: Sat, 12 Mar 2022 15:54:56 +0200
Subject: [PATCH 10/10] Updated dependencies
---
composer.lock | 634 +++++++++++----------------------
src/Adapter/Swoole/Request.php | 2 +-
2 files changed, 214 insertions(+), 422 deletions(-)
diff --git a/composer.lock b/composer.lock
index 7c33130d..5a4bdfde 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,21 +4,21 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "63a5aab14d1587d0a66334fb2046d7c1",
+ "content-hash": "32adca63b220fdaa63164dcd749d66af",
"packages": [],
"packages-dev": [
{
"name": "amphp/amp",
- "version": "v2.6.1",
+ "version": "v2.6.2",
"source": {
"type": "git",
"url": "https://github.com/amphp/amp.git",
- "reference": "c5fc66a78ee38d7ac9195a37bacaf940eb3f65ae"
+ "reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/amphp/amp/zipball/c5fc66a78ee38d7ac9195a37bacaf940eb3f65ae",
- "reference": "c5fc66a78ee38d7ac9195a37bacaf940eb3f65ae",
+ "url": "https://api.github.com/repos/amphp/amp/zipball/9d5100cebffa729aaffecd3ad25dc5aeea4f13bb",
+ "reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb",
"shasum": ""
},
"require": {
@@ -40,13 +40,13 @@
}
},
"autoload": {
- "psr-4": {
- "Amp\\": "lib"
- },
"files": [
"lib/functions.php",
"lib/Internal/functions.php"
- ]
+ ],
+ "psr-4": {
+ "Amp\\": "lib"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -71,7 +71,7 @@
}
],
"description": "A non-blocking concurrency framework for PHP applications.",
- "homepage": "http://amphp.org/amp",
+ "homepage": "https://amphp.org/amp",
"keywords": [
"async",
"asynchronous",
@@ -86,7 +86,7 @@
"support": {
"irc": "irc://irc.freenode.org/amphp",
"issues": "https://github.com/amphp/amp/issues",
- "source": "https://github.com/amphp/amp/tree/v2.6.1"
+ "source": "https://github.com/amphp/amp/tree/v2.6.2"
},
"funding": [
{
@@ -94,7 +94,7 @@
"type": "github"
}
],
- "time": "2021-09-23T18:43:08+00:00"
+ "time": "2022-02-20T17:52:18+00:00"
},
{
"name": "amphp/byte-stream",
@@ -129,12 +129,12 @@
}
},
"autoload": {
- "psr-4": {
- "Amp\\ByteStream\\": "lib"
- },
"files": [
"lib/functions.php"
- ]
+ ],
+ "psr-4": {
+ "Amp\\ByteStream\\": "lib"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -246,25 +246,96 @@
],
"time": "2022-01-17T14:14:24+00:00"
},
+ {
+ "name": "composer/pcre",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/composer/pcre.git",
+ "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/composer/pcre/zipball/67a32d7d6f9f560b726ab25a061b38ff3a80c560",
+ "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^5.3.2 || ^7.0 || ^8.0"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^1.3",
+ "phpstan/phpstan-strict-rules": "^1.1",
+ "symfony/phpunit-bridge": "^4.2 || ^5"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Composer\\Pcre\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jordi Boggiano",
+ "email": "j.boggiano@seld.be",
+ "homepage": "http://seld.be"
+ }
+ ],
+ "description": "PCRE wrapping library that offers type-safe preg_* replacements.",
+ "keywords": [
+ "PCRE",
+ "preg",
+ "regex",
+ "regular expression"
+ ],
+ "support": {
+ "issues": "https://github.com/composer/pcre/issues",
+ "source": "https://github.com/composer/pcre/tree/1.0.1"
+ },
+ "funding": [
+ {
+ "url": "https://packagist.com",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/composer",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/composer/composer",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-01-21T20:24:37+00:00"
+ },
{
"name": "composer/semver",
- "version": "3.2.7",
+ "version": "3.2.9",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
- "reference": "deac27056b57e46faf136fae7b449eeaa71661ee"
+ "reference": "a951f614bd64dcd26137bc9b7b2637ddcfc57649"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/semver/zipball/deac27056b57e46faf136fae7b449eeaa71661ee",
- "reference": "deac27056b57e46faf136fae7b449eeaa71661ee",
+ "url": "https://api.github.com/repos/composer/semver/zipball/a951f614bd64dcd26137bc9b7b2637ddcfc57649",
+ "reference": "a951f614bd64dcd26137bc9b7b2637ddcfc57649",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
- "phpstan/phpstan": "^0.12.54",
+ "phpstan/phpstan": "^1.4",
"symfony/phpunit-bridge": "^4.2 || ^5"
},
"type": "library",
@@ -309,7 +380,7 @@
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/semver/issues",
- "source": "https://github.com/composer/semver/tree/3.2.7"
+ "source": "https://github.com/composer/semver/tree/3.2.9"
},
"funding": [
{
@@ -325,29 +396,31 @@
"type": "tidelift"
}
],
- "time": "2022-01-04T09:57:54+00:00"
+ "time": "2022-02-04T13:58:43+00:00"
},
{
"name": "composer/xdebug-handler",
- "version": "2.0.2",
+ "version": "2.0.5",
"source": {
"type": "git",
"url": "https://github.com/composer/xdebug-handler.git",
- "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339"
+ "reference": "9e36aeed4616366d2b690bdce11f71e9178c579a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/84674dd3a7575ba617f5a76d7e9e29a7d3891339",
- "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339",
+ "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/9e36aeed4616366d2b690bdce11f71e9178c579a",
+ "reference": "9e36aeed4616366d2b690bdce11f71e9178c579a",
"shasum": ""
},
"require": {
+ "composer/pcre": "^1",
"php": "^5.3.2 || ^7.0 || ^8.0",
"psr/log": "^1 || ^2 || ^3"
},
"require-dev": {
- "phpstan/phpstan": "^0.12.55",
- "symfony/phpunit-bridge": "^4.2 || ^5"
+ "phpstan/phpstan": "^1.0",
+ "phpstan/phpstan-strict-rules": "^1.1",
+ "symfony/phpunit-bridge": "^4.2 || ^5.0 || ^6.0"
},
"type": "library",
"autoload": {
@@ -373,7 +446,7 @@
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/xdebug-handler/issues",
- "source": "https://github.com/composer/xdebug-handler/tree/2.0.2"
+ "source": "https://github.com/composer/xdebug-handler/tree/2.0.5"
},
"funding": [
{
@@ -389,7 +462,7 @@
"type": "tidelift"
}
],
- "time": "2021-07-31T17:03:58+00:00"
+ "time": "2022-02-24T20:20:32+00:00"
},
{
"name": "dnoegel/php-xdg-base-dir",
@@ -430,29 +503,30 @@
},
{
"name": "doctrine/instantiator",
- "version": "1.4.0",
+ "version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
- "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b"
+ "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b",
- "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b",
+ "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc",
+ "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
- "doctrine/coding-standard": "^8.0",
+ "doctrine/coding-standard": "^9",
"ext-pdo": "*",
"ext-phar": "*",
- "phpbench/phpbench": "^0.13 || 1.0.0-alpha2",
- "phpstan/phpstan": "^0.12",
- "phpstan/phpstan-phpunit": "^0.12",
- "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
+ "phpbench/phpbench": "^0.16 || ^1",
+ "phpstan/phpstan": "^1.4",
+ "phpstan/phpstan-phpunit": "^1",
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
+ "vimeo/psalm": "^4.22"
},
"type": "library",
"autoload": {
@@ -479,7 +553,7 @@
],
"support": {
"issues": "https://github.com/doctrine/instantiator/issues",
- "source": "https://github.com/doctrine/instantiator/tree/1.4.0"
+ "source": "https://github.com/doctrine/instantiator/tree/1.4.1"
},
"funding": [
{
@@ -495,7 +569,7 @@
"type": "tidelift"
}
],
- "time": "2020-11-10T18:47:58+00:00"
+ "time": "2022-03-03T08:28:38+00:00"
},
{
"name": "felixfbecker/advanced-json-rpc",
@@ -600,37 +674,38 @@
},
{
"name": "myclabs/deep-copy",
- "version": "1.10.2",
+ "version": "1.11.0",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
- "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220"
+ "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220",
- "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220",
+ "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614",
+ "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
- "replace": {
- "myclabs/deep-copy": "self.version"
+ "conflict": {
+ "doctrine/collections": "<1.6.8",
+ "doctrine/common": "<2.13.3 || >=3,<3.2.2"
},
"require-dev": {
- "doctrine/collections": "^1.0",
- "doctrine/common": "^2.6",
- "phpunit/phpunit": "^7.1"
+ "doctrine/collections": "^1.6.8",
+ "doctrine/common": "^2.13.3 || ^3.2.2",
+ "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
},
"type": "library",
"autoload": {
- "psr-4": {
- "DeepCopy\\": "src/DeepCopy/"
- },
"files": [
"src/DeepCopy/deep_copy.php"
- ]
+ ],
+ "psr-4": {
+ "DeepCopy\\": "src/DeepCopy/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -646,7 +721,7 @@
],
"support": {
"issues": "https://github.com/myclabs/DeepCopy/issues",
- "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2"
+ "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0"
},
"funding": [
{
@@ -654,7 +729,7 @@
"type": "tidelift"
}
],
- "time": "2020-11-13T09:40:50+00:00"
+ "time": "2022-03-03T13:19:32+00:00"
},
{
"name": "netresearch/jsonmapper",
@@ -878,16 +953,16 @@
},
{
"name": "phar-io/version",
- "version": "3.1.0",
+ "version": "3.2.1",
"source": {
"type": "git",
"url": "https://github.com/phar-io/version.git",
- "reference": "bae7c545bef187884426f042434e561ab1ddb182"
+ "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182",
- "reference": "bae7c545bef187884426f042434e561ab1ddb182",
+ "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
+ "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
"shasum": ""
},
"require": {
@@ -923,9 +998,9 @@
"description": "Library for handling version information and constraints",
"support": {
"issues": "https://github.com/phar-io/version/issues",
- "source": "https://github.com/phar-io/version/tree/3.1.0"
+ "source": "https://github.com/phar-io/version/tree/3.2.1"
},
- "time": "2021-02-23T14:00:09+00:00"
+ "time": "2022-02-21T01:04:05+00:00"
},
{
"name": "phpdocumentor/reflection-common",
@@ -1156,16 +1231,16 @@
},
{
"name": "phpunit/php-code-coverage",
- "version": "9.2.10",
+ "version": "9.2.15",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687"
+ "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687",
- "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f",
+ "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f",
"shasum": ""
},
"require": {
@@ -1221,7 +1296,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
- "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10"
+ "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15"
},
"funding": [
{
@@ -1229,7 +1304,7 @@
"type": "github"
}
],
- "time": "2021-12-05T09:12:13+00:00"
+ "time": "2022-03-07T09:28:20+00:00"
},
{
"name": "phpunit/php-file-iterator",
@@ -1474,16 +1549,16 @@
},
{
"name": "phpunit/phpunit",
- "version": "9.5.13",
+ "version": "9.5.18",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "597cb647654ede35e43b137926dfdfef0fb11743"
+ "reference": "1b5856028273bfd855e60a887278857d872ec67a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/597cb647654ede35e43b137926dfdfef0fb11743",
- "reference": "597cb647654ede35e43b137926dfdfef0fb11743",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1b5856028273bfd855e60a887278857d872ec67a",
+ "reference": "1b5856028273bfd855e60a887278857d872ec67a",
"shasum": ""
},
"require": {
@@ -1499,7 +1574,7 @@
"phar-io/version": "^3.0.2",
"php": ">=7.3",
"phpspec/prophecy": "^1.12.1",
- "phpunit/php-code-coverage": "^9.2.7",
+ "phpunit/php-code-coverage": "^9.2.13",
"phpunit/php-file-iterator": "^3.0.5",
"phpunit/php-invoker": "^3.1.1",
"phpunit/php-text-template": "^2.0.3",
@@ -1534,11 +1609,11 @@
}
},
"autoload": {
- "classmap": [
- "src/"
- ],
"files": [
"src/Framework/Assert/Functions.php"
+ ],
+ "classmap": [
+ "src/"
]
},
"notification-url": "https://packagist.org/downloads/",
@@ -1561,7 +1636,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
- "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.13"
+ "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.18"
},
"funding": [
{
@@ -1573,7 +1648,7 @@
"type": "github"
}
],
- "time": "2022-01-24T07:33:35+00:00"
+ "time": "2022-03-08T06:52:28+00:00"
},
{
"name": "psr/container",
@@ -2184,16 +2259,16 @@
},
{
"name": "sebastian/global-state",
- "version": "5.0.3",
+ "version": "5.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
- "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49"
+ "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49",
- "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49",
+ "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2",
+ "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2",
"shasum": ""
},
"require": {
@@ -2236,7 +2311,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues",
- "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3"
+ "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5"
},
"funding": [
{
@@ -2244,7 +2319,7 @@
"type": "github"
}
],
- "time": "2021-06-11T13:31:12+00:00"
+ "time": "2022-02-14T08:28:10+00:00"
},
{
"name": "sebastian/lines-of-code",
@@ -2686,46 +2761,42 @@
},
{
"name": "symfony/console",
- "version": "v5.4.3",
+ "version": "v6.0.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "a2a86ec353d825c75856c6fd14fac416a7bdb6b8"
+ "reference": "3bebf4108b9e07492a2a4057d207aa5a77d146b1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/a2a86ec353d825c75856c6fd14fac416a7bdb6b8",
- "reference": "a2a86ec353d825c75856c6fd14fac416a7bdb6b8",
+ "url": "https://api.github.com/repos/symfony/console/zipball/3bebf4108b9e07492a2a4057d207aa5a77d146b1",
+ "reference": "3bebf4108b9e07492a2a4057d207aa5a77d146b1",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1|^3",
+ "php": ">=8.0.2",
"symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php73": "^1.9",
- "symfony/polyfill-php80": "^1.16",
"symfony/service-contracts": "^1.1|^2|^3",
- "symfony/string": "^5.1|^6.0"
+ "symfony/string": "^5.4|^6.0"
},
"conflict": {
- "psr/log": ">=3",
- "symfony/dependency-injection": "<4.4",
- "symfony/dotenv": "<5.1",
- "symfony/event-dispatcher": "<4.4",
- "symfony/lock": "<4.4",
- "symfony/process": "<4.4"
+ "symfony/dependency-injection": "<5.4",
+ "symfony/dotenv": "<5.4",
+ "symfony/event-dispatcher": "<5.4",
+ "symfony/lock": "<5.4",
+ "symfony/process": "<5.4"
},
"provide": {
- "psr/log-implementation": "1.0|2.0"
+ "psr/log-implementation": "1.0|2.0|3.0"
},
"require-dev": {
- "psr/log": "^1|^2",
- "symfony/config": "^4.4|^5.0|^6.0",
- "symfony/dependency-injection": "^4.4|^5.0|^6.0",
- "symfony/event-dispatcher": "^4.4|^5.0|^6.0",
- "symfony/lock": "^4.4|^5.0|^6.0",
- "symfony/process": "^4.4|^5.0|^6.0",
- "symfony/var-dumper": "^4.4|^5.0|^6.0"
+ "psr/log": "^1|^2|^3",
+ "symfony/config": "^5.4|^6.0",
+ "symfony/dependency-injection": "^5.4|^6.0",
+ "symfony/event-dispatcher": "^5.4|^6.0",
+ "symfony/lock": "^5.4|^6.0",
+ "symfony/process": "^5.4|^6.0",
+ "symfony/var-dumper": "^5.4|^6.0"
},
"suggest": {
"psr/log": "For using the console logger",
@@ -2765,7 +2836,7 @@
"terminal"
],
"support": {
- "source": "https://github.com/symfony/console/tree/v5.4.3"
+ "source": "https://github.com/symfony/console/tree/v6.0.5"
},
"funding": [
{
@@ -2781,78 +2852,11 @@
"type": "tidelift"
}
],
- "time": "2022-01-26T16:28:35+00:00"
- },
- {
- "name": "symfony/deprecation-contracts",
- "version": "v3.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/deprecation-contracts.git",
- "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/c726b64c1ccfe2896cb7df2e1331c357ad1c8ced",
- "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced",
- "shasum": ""
- },
- "require": {
- "php": ">=8.0.2"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "3.0-dev"
- },
- "thanks": {
- "name": "symfony/contracts",
- "url": "https://github.com/symfony/contracts"
- }
- },
- "autoload": {
- "files": [
- "function.php"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "A generic function and convention to trigger deprecation notices",
- "homepage": "https://symfony.com",
- "support": {
- "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2021-11-01T23:48:49+00:00"
+ "time": "2022-02-25T10:48:52+00:00"
},
{
"name": "symfony/polyfill-ctype",
- "version": "v1.24.0",
+ "version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
@@ -2884,12 +2888,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Ctype\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Ctype\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -2914,7 +2918,7 @@
"portable"
],
"support": {
- "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0"
+ "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0"
},
"funding": [
{
@@ -2934,7 +2938,7 @@
},
{
"name": "symfony/polyfill-intl-grapheme",
- "version": "v1.24.0",
+ "version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
@@ -2963,12 +2967,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Intl\\Grapheme\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Intl\\Grapheme\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -2995,7 +2999,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.24.0"
+ "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.25.0"
},
"funding": [
{
@@ -3015,7 +3019,7 @@
},
{
"name": "symfony/polyfill-intl-normalizer",
- "version": "v1.24.0",
+ "version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
@@ -3044,12 +3048,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
- },
"files": [
"bootstrap.php"
],
+ "psr-4": {
+ "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
+ },
"classmap": [
"Resources/stubs"
]
@@ -3079,7 +3083,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.24.0"
+ "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.25.0"
},
"funding": [
{
@@ -3099,7 +3103,7 @@
},
{
"name": "symfony/polyfill-mbstring",
- "version": "v1.24.0",
+ "version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
@@ -3131,12 +3135,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Mbstring\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3162,7 +3166,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0"
+ "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0"
},
"funding": [
{
@@ -3180,168 +3184,6 @@
],
"time": "2021-11-30T18:21:41+00:00"
},
- {
- "name": "symfony/polyfill-php73",
- "version": "v1.24.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-php73.git",
- "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5",
- "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "1.23-dev"
- },
- "thanks": {
- "name": "symfony/polyfill",
- "url": "https://github.com/symfony/polyfill"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Php73\\": ""
- },
- "files": [
- "bootstrap.php"
- ],
- "classmap": [
- "Resources/stubs"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2021-06-05T21:20:04+00:00"
- },
- {
- "name": "symfony/polyfill-php80",
- "version": "v1.24.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-php80.git",
- "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9",
- "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "1.23-dev"
- },
- "thanks": {
- "name": "symfony/polyfill",
- "url": "https://github.com/symfony/polyfill"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Php80\\": ""
- },
- "files": [
- "bootstrap.php"
- ],
- "classmap": [
- "Resources/stubs"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Ion Bazan",
- "email": "ion.bazan@gmail.com"
- },
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2021-09-13T13:58:33+00:00"
- },
{
"name": "symfony/service-contracts",
"version": "v3.0.0",
@@ -3456,12 +3298,12 @@
},
"type": "library",
"autoload": {
- "psr-4": {
- "Symfony\\Component\\String\\": ""
- },
"files": [
"Resources/functions.php"
],
+ "psr-4": {
+ "Symfony\\Component\\String\\": ""
+ },
"exclude-from-classmap": [
"/Tests/"
]
@@ -3636,13 +3478,13 @@
}
},
"autoload": {
- "psr-4": {
- "Psalm\\": "src/Psalm/"
- },
"files": [
"src/functions.php",
"src/spl_object_id.php"
- ]
+ ],
+ "psr-4": {
+ "Psalm\\": "src/Psalm/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3719,59 +3561,9 @@
],
"support": {
"issues": "https://github.com/webmozarts/assert/issues",
- "source": "https://github.com/webmozarts/assert/tree/1.9.1"
- },
- "time": "2020-07-08T17:02:28+00:00"
- },
- {
- "name": "webmozart/glob",
- "version": "4.4.0",
- "source": {
- "type": "git",
- "url": "https://github.com/webmozarts/glob.git",
- "reference": "539b5dbc10021d3f9242e7a9e9b6b37843179e83"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/webmozarts/glob/zipball/539b5dbc10021d3f9242e7a9e9b6b37843179e83",
- "reference": "539b5dbc10021d3f9242e7a9e9b6b37843179e83",
- "shasum": ""
- },
- "require": {
- "php": "^7.3 || ^8.0.0",
- "webmozart/path-util": "^2.2"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.5",
- "symfony/filesystem": "^5.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.1-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Webmozart\\Glob\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@gmail.com"
- }
- ],
- "description": "A PHP implementation of Ant's glob.",
- "support": {
- "issues": "https://github.com/webmozarts/glob/issues",
- "source": "https://github.com/webmozarts/glob/tree/4.4.0"
+ "source": "https://github.com/webmozarts/assert/tree/1.10.0"
},
- "time": "2021-10-07T16:13:08+00:00"
+ "time": "2021-03-09T10:59:23+00:00"
},
{
"name": "webmozart/path-util",
diff --git a/src/Adapter/Swoole/Request.php b/src/Adapter/Swoole/Request.php
index b0c72309..4017d157 100644
--- a/src/Adapter/Swoole/Request.php
+++ b/src/Adapter/Swoole/Request.php
@@ -13,7 +13,7 @@ class Request extends UtopiaRequest
*
* @var SwooleRequest
*/
- protected $swoole;
+ protected $swoole = null;
/**
* Request constructor.