From 9b0916fc02aa1e9d908127c2cc9c6277bb534091 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 18 Apr 2024 22:21:24 +0200 Subject: [PATCH 01/10] Test base server --- composer.json | 7 +- composer.lock | 567 +++++++++++++++++++++++++++-------------- src/Http/Exception.php | 4 +- src/Http/Hook.php | 249 +----------------- src/Http/Http.php | 270 +------------------- src/Http/Validator.php | 55 +--- 6 files changed, 400 insertions(+), 752 deletions(-) diff --git a/composer.json b/composer.json index e8a29456..9244c0a6 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "upf" ], "license": "MIT", + "minimum-stability": "dev", "autoload": { "psr-4": { "Utopia\\": "src/" @@ -29,7 +30,7 @@ "require": { "php": ">=8.0", "ext-swoole": "*", - "utopia-php/di": "dev-main" + "utopia-php/servers": "dev-dev" }, "require-dev": { "ext-xdebug": "*", @@ -40,6 +41,10 @@ "phpbench/phpbench": "^1.2" }, "repositories": [ + { + "type": "vcs", + "url": "https://github.com/utopia-php/servers" + }, { "type": "vcs", "url": "https://github.com/utopia-php/di" diff --git a/composer.lock b/composer.lock index fe3851f1..46f4edf6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,69 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9fb7534dc954b1f29c6d74dbfcf1a296", + "content-hash": "f961290f450cd8657302383ece07a86b", "packages": [ + { + "name": "utopia-php/cli", + "version": "0.17.0", + "source": { + "type": "git", + "url": "https://github.com/utopia-php/cli.git", + "reference": "0829fd5215afe88f53f3091cedc808da801fd1bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utopia-php/cli/zipball/0829fd5215afe88f53f3091cedc808da801fd1bb", + "reference": "0829fd5215afe88f53f3091cedc808da801fd1bb", + "shasum": "" + }, + "require": { + "php": ">=7.4", + "utopia-php/framework": "0.34.*" + }, + "require-dev": { + "laravel/pint": "1.2.*", + "phpunit/phpunit": "^9.3", + "squizlabs/php_codesniffer": "^3.6", + "vimeo/psalm": "4.0.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Utopia\\CLI\\": "src/CLI" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A simple CLI library to manage command line applications", + "keywords": [ + "cli", + "command line", + "framework", + "php", + "upf", + "utopia" + ], + "support": { + "issues": "https://github.com/utopia-php/cli/issues", + "source": "https://github.com/utopia-php/cli/tree/0.17.0" + }, + "time": "2024-01-24T11:37:29+00:00" + }, { "name": "utopia-php/di", "version": "dev-main", "source": { "type": "git", "url": "https://github.com/utopia-php/di.git", - "reference": "0bb7af5693bc131f4d2ce34d3f732d41e6637679" + "reference": "fb3c45b268018b87dcbbf87ad943ced9eea3bbe2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/di/zipball/0bb7af5693bc131f4d2ce34d3f732d41e6637679", - "reference": "0bb7af5693bc131f4d2ce34d3f732d41e6637679", + "url": "https://api.github.com/repos/utopia-php/di/zipball/fb3c45b268018b87dcbbf87ad943ced9eea3bbe2", + "reference": "fb3c45b268018b87dcbbf87ad943ced9eea3bbe2", "shasum": "" }, "require": { @@ -66,22 +115,142 @@ "source": "https://github.com/utopia-php/di/tree/main", "issues": "https://github.com/utopia-php/di/issues" }, - "time": "2024-04-08T22:41:41+00:00" + "time": "2024-04-18T20:06:02+00:00" + }, + { + "name": "utopia-php/framework", + "version": "0.34.2", + "source": { + "type": "git", + "url": "https://github.com/utopia-php/http.git", + "reference": "fd126c02b78cc80678c9638f7b335dfb4a841b78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utopia-php/http/zipball/fd126c02b78cc80678c9638f7b335dfb4a841b78", + "reference": "fd126c02b78cc80678c9638f7b335dfb4a841b78", + "shasum": "" + }, + "require": { + "ext-swoole": "*", + "php": ">=8.0" + }, + "require-dev": { + "laravel/pint": "^1.2", + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5.25", + "swoole/ide-helper": "4.8.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Utopia\\Http\\": "src/Http" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A simple, light and advanced PHP HTTP framework", + "keywords": [ + "framework", + "http", + "php", + "upf" + ], + "support": { + "issues": "https://github.com/utopia-php/http/issues", + "source": "https://github.com/utopia-php/http/tree/0.34.2" + }, + "time": "2024-02-20T11:36:56+00:00" + }, + { + "name": "utopia-php/servers", + "version": "dev-dev", + "source": { + "type": "git", + "url": "https://github.com/utopia-php/servers.git", + "reference": "afde8000e4d87ab1bb3cceba1c17e2506292123a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utopia-php/servers/zipball/afde8000e4d87ab1bb3cceba1c17e2506292123a", + "reference": "afde8000e4d87ab1bb3cceba1c17e2506292123a", + "shasum": "" + }, + "require": { + "php": ">=8.0", + "utopia-php/cli": "0.17.*", + "utopia-php/di": "dev-main" + }, + "require-dev": { + "laravel/pint": "^0.2.3", + "phpstan/phpstan": "^1.8", + "phpunit/phpunit": "^9.5.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Utopia\\Queue\\": "src/Servers" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\E2E\\": "tests/Servers/Unit" + } + }, + "scripts": { + "test": [ + "phpunit" + ], + "analyse": [ + "vendor/bin/phpstan analyse" + ], + "format": [ + "vendor/bin/pint" + ], + "lint": [ + "vendor/bin/pint --test" + ] + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Team Appwrite", + "email": "team@appwrite.io" + } + ], + "description": "A base library for building Utopia style servers.", + "keywords": [ + "framework", + "php", + "servers", + "upf", + "utopia" + ], + "support": { + "source": "https://github.com/utopia-php/servers/tree/dev", + "issues": "https://github.com/utopia-php/servers/issues" + }, + "time": "2024-04-18T20:05:13+00:00" } ], "packages-dev": [ { "name": "doctrine/annotations", - "version": "2.0.1", + "version": "2.0.x-dev", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f" + "reference": "94f40ad7ecbc6931958faa8a57c48dce5da2b468" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f", - "reference": "e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/94f40ad7ecbc6931958faa8a57c48dce5da2b468", + "reference": "94f40ad7ecbc6931958faa8a57c48dce5da2b468", "shasum": "" }, "require": { @@ -101,6 +270,7 @@ "suggest": { "php": "PHP 8.0 or higher comes with attributes, a native replacement for annotations" }, + "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -142,37 +312,38 @@ ], "support": { "issues": "https://github.com/doctrine/annotations/issues", - "source": "https://github.com/doctrine/annotations/tree/2.0.1" + "source": "https://github.com/doctrine/annotations/tree/2.0.x" }, - "time": "2023-02-02T22:02:53+00:00" + "time": "2023-08-23T17:36:07+00:00" }, { "name": "doctrine/instantiator", - "version": "2.0.0", + "version": "2.0.x-dev", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" + "reference": "6c0ee619435c5d4f3bc515ab1514cf4cf1006c6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", - "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/6c0ee619435c5d4f3bc515ab1514cf4cf1006c6e", + "reference": "6c0ee619435c5d4f3bc515ab1514cf4cf1006c6e", "shasum": "" }, "require": { "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^11", + "doctrine/coding-standard": "^12", "ext-pdo": "*", "ext-phar": "*", "phpbench/phpbench": "^1.2", "phpstan/phpstan": "^1.9.4", "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.5.27", + "phpunit/phpunit": "^10.5", "vimeo/psalm": "^5.4" }, + "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -198,7 +369,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/2.0.0" + "source": "https://github.com/doctrine/instantiator/tree/2.0.x" }, "funding": [ { @@ -214,20 +385,20 @@ "type": "tidelift" } ], - "time": "2022-12-30T00:23:10+00:00" + "time": "2023-12-09T14:19:21+00:00" }, { "name": "doctrine/lexer", - "version": "3.0.1", + "version": "3.1.x-dev", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "31ad66abc0fc9e1a1f2d9bc6a42668d2fbbcd6dd" + "reference": "cd03cc3c085aa94b046bd2d342b08d6b0e5d834f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/31ad66abc0fc9e1a1f2d9bc6a42668d2fbbcd6dd", - "reference": "31ad66abc0fc9e1a1f2d9bc6a42668d2fbbcd6dd", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/cd03cc3c085aa94b046bd2d342b08d6b0e5d834f", + "reference": "cd03cc3c085aa94b046bd2d342b08d6b0e5d834f", "shasum": "" }, "require": { @@ -275,7 +446,7 @@ ], "support": { "issues": "https://github.com/doctrine/lexer/issues", - "source": "https://github.com/doctrine/lexer/tree/3.0.1" + "source": "https://github.com/doctrine/lexer/tree/3.1.x" }, "funding": [ { @@ -291,7 +462,7 @@ "type": "tidelift" } ], - "time": "2024-02-05T11:56:58+00:00" + "time": "2024-02-05T12:02:27+00:00" }, { "name": "laravel/pint", @@ -361,16 +532,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.1", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + "reference": "2f5294676c802a62b0549f6bc8983f14294ce369" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/2f5294676c802a62b0549f6bc8983f14294ce369", + "reference": "2f5294676c802a62b0549f6bc8983f14294ce369", "shasum": "" }, "require": { @@ -378,13 +549,15 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, + "default-branch": true, "type": "library", "autoload": { "files": [ @@ -408,7 +581,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.x" }, "funding": [ { @@ -416,20 +589,20 @@ "type": "tidelift" } ], - "time": "2023-03-08T13:26:56+00:00" + "time": "2024-02-10T11:10:03+00:00" }, { "name": "nikic/php-parser", - "version": "v5.0.2", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13" + "reference": "46be4560c4cd4bab2b74882c0da39a4548a5cfbe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/139676794dc1e9231bf7bcd123cfc0c99182cb13", - "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/46be4560c4cd4bab2b74882c0da39a4548a5cfbe", + "reference": "46be4560c4cd4bab2b74882c0da39a4548a5cfbe", "shasum": "" }, "require": { @@ -440,8 +613,9 @@ }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.0" }, + "default-branch": true, "bin": [ "bin/php-parse" ], @@ -472,13 +646,13 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.2" + "source": "https://github.com/nikic/PHP-Parser/tree/master" }, - "time": "2024-03-05T20:51:40+00:00" + "time": "2024-03-17T10:24:36+00:00" }, { "name": "phar-io/manifest", - "version": "2.0.4", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", @@ -498,6 +672,7 @@ "phar-io/version": "^3.0.1", "php": "^7.2 || ^8.0" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -596,7 +771,7 @@ }, { "name": "phpbench/container", - "version": "2.2.2", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/phpbench/container.git", @@ -617,6 +792,7 @@ "phpstan/phpstan": "^0.12.52", "phpunit/phpunit": "^8" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -698,16 +874,16 @@ }, { "name": "phpbench/phpbench", - "version": "1.2.15", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/phpbench/phpbench.git", - "reference": "f7000319695cfad04a57fc64bf7ef7abdf4c437c" + "reference": "c4af952ad3e19cc1a754b98f1ea47a10371e1749" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpbench/phpbench/zipball/f7000319695cfad04a57fc64bf7ef7abdf4c437c", - "reference": "f7000319695cfad04a57fc64bf7ef7abdf4c437c", + "url": "https://api.github.com/repos/phpbench/phpbench/zipball/c4af952ad3e19cc1a754b98f1ea47a10371e1749", + "reference": "c4af952ad3e19cc1a754b98f1ea47a10371e1749", "shasum": "" }, "require": { @@ -719,33 +895,39 @@ "ext-spl": "*", "ext-tokenizer": "*", "php": "^8.1", - "phpbench/container": "^2.1", + "phpbench/container": "^2.2", "phpbench/dom": "~0.3.3", "psr/log": "^1.1 || ^2.0 || ^3.0", "seld/jsonlint": "^1.1", - "symfony/console": "^4.2 || ^5.0 || ^6.0 || ^7.0", - "symfony/filesystem": "^4.2 || ^5.0 || ^6.0 || ^7.0", - "symfony/finder": "^4.2 || ^5.0 || ^6.0 || ^7.0", - "symfony/options-resolver": "^4.2 || ^5.0 || ^6.0 || ^7.0", - "symfony/process": "^4.2 || ^5.0 || ^6.0 || ^7.0", + "symfony/console": "^6.1 || ^7.0", + "symfony/filesystem": "^6.1 || ^7.0", + "symfony/finder": "^6.1 || ^7.0", + "symfony/options-resolver": "^6.1 || ^7.0", + "symfony/process": "^6.1 || ^7.0", "webmozart/glob": "^4.6" }, + "replace": { + "symfony/polyfill-php80": "*", + "symfony/polyfill-php81": "*" + }, "require-dev": { "dantleech/invoke": "^2.0", + "ergebnis/composer-normalize": "^2.39", "friendsofphp/php-cs-fixer": "^3.0", "jangregor/phpstan-prophecy": "^1.0", "phpspec/prophecy": "dev-master", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.0", "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^10.0", - "rector/rector": "^0.18.10", - "symfony/error-handler": "^5.2 || ^6.0 || ^7.0", - "symfony/var-dumper": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^10.4", + "rector/rector": "^0.18.11 || ^1.0.0", + "symfony/error-handler": "^6.1 || ^7.0", + "symfony/var-dumper": "^6.1 || ^7.0" }, "suggest": { "ext-xdebug": "For Xdebug profiling extension." }, + "default-branch": true, "bin": [ "bin/phpbench" ], @@ -784,7 +966,7 @@ ], "support": { "issues": "https://github.com/phpbench/phpbench/issues", - "source": "https://github.com/phpbench/phpbench/tree/1.2.15" + "source": "https://github.com/phpbench/phpbench/tree/master" }, "funding": [ { @@ -792,20 +974,20 @@ "type": "github" } ], - "time": "2023-11-29T12:21:11+00:00" + "time": "2024-04-10T12:50:15+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.66", + "version": "1.11.x-dev", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "94779c987e4ebd620025d9e5fdd23323903950bd" + "reference": "1ab6c28b7f4c273d1ffd6a4a5d8ef7e989ea04c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/94779c987e4ebd620025d9e5fdd23323903950bd", - "reference": "94779c987e4ebd620025d9e5fdd23323903950bd", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1ab6c28b7f4c273d1ffd6a4a5d8ef7e989ea04c5", + "reference": "1ab6c28b7f4c273d1ffd6a4a5d8ef7e989ea04c5", "shasum": "" }, "require": { @@ -814,6 +996,7 @@ "conflict": { "phpstan/phpstan-shim": "*" }, + "default-branch": true, "bin": [ "phpstan", "phpstan.phar" @@ -848,26 +1031,22 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2024-03-28T16:17:31+00:00" + "time": "2024-04-18T15:41:16+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.31", + "version": "9.2.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" + "reference": "3352293d9e91513d5508c415835014881b420218" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/3352293d9e91513d5508c415835014881b420218", + "reference": "3352293d9e91513d5508c415835014881b420218", "shasum": "" }, "require": { @@ -924,7 +1103,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2" }, "funding": [ { @@ -932,20 +1111,20 @@ "type": "github" } ], - "time": "2024-03-02T06:37:42+00:00" + "time": "2024-03-22T05:16:32+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "3.0.6", + "version": "3.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + "reference": "38b24367e1b340aa78b96d7cab042942d917bb84" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/38b24367e1b340aa78b96d7cab042942d917bb84", + "reference": "38b24367e1b340aa78b96d7cab042942d917bb84", "shasum": "" }, "require": { @@ -984,7 +1163,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0" }, "funding": [ { @@ -992,7 +1171,7 @@ "type": "github" } ], - "time": "2021-12-02T12:48:52+00:00" + "time": "2022-02-11T16:23:04+00:00" }, { "name": "phpunit/php-invoker", @@ -1177,16 +1356,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.19", + "version": "9.6.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8" + "reference": "2f5cc6727bef6304e013d24e16e2203ca1f5ea94" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8", - "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2f5cc6727bef6304e013d24e16e2203ca1f5ea94", + "reference": "2f5cc6727bef6304e013d24e16e2203ca1f5ea94", "shasum": "" }, "require": { @@ -1260,7 +1439,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.19" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6" }, "funding": [ { @@ -1276,29 +1455,33 @@ "type": "tidelift" } ], - "time": "2024-04-05T04:35:58+00:00" + "time": "2024-04-18T12:34:34+00:00" }, { "name": "psr/cache", - "version": "3.0.0", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/php-fig/cache.git", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" + "reference": "0a7c67d0d1c8167b342eb74339d6f961663826ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "url": "https://api.github.com/repos/php-fig/cache/zipball/0a7c67d0d1c8167b342eb74339d6f961663826ce", + "reference": "0a7c67d0d1c8167b342eb74339d6f961663826ce", "shasum": "" }, "require": { "php": ">=8.0.0" }, + "suggest": { + "fig/cache-util": "Provides some useful PSR-6 utilities" + }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -1323,27 +1506,28 @@ "psr-6" ], "support": { - "source": "https://github.com/php-fig/cache/tree/3.0.0" + "source": "https://github.com/php-fig/cache/tree/master" }, - "time": "2021-02-03T23:26:27+00:00" + "time": "2021-02-24T03:25:37+00:00" }, { "name": "psr/container", - "version": "2.0.2", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + "reference": "707984727bd5b2b670e59559d3ed2500240cf875" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", - "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "url": "https://api.github.com/repos/php-fig/container/zipball/707984727bd5b2b670e59559d3ed2500240cf875", + "reference": "707984727bd5b2b670e59559d3ed2500240cf875", "shasum": "" }, "require": { "php": ">=7.4.0" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -1376,13 +1560,13 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/2.0.2" + "source": "https://github.com/php-fig/container" }, - "time": "2021-11-05T16:47:00+00:00" + "time": "2023-09-22T11:11:30+00:00" }, { "name": "psr/log", - "version": "3.0.0", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", @@ -1397,6 +1581,7 @@ "require": { "php": ">=8.0.0" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -1432,7 +1617,7 @@ }, { "name": "sebastian/cli-parser", - "version": "1.0.2", + "version": "1.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", @@ -1599,16 +1784,16 @@ }, { "name": "sebastian/comparator", - "version": "4.0.8", + "version": "4.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "fa0f136dd2334583309d32b62544682ee972b51a" + "reference": "b247957a1c8dc81a671770f74b479c0a78a818f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", - "reference": "fa0f136dd2334583309d32b62544682ee972b51a", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/b247957a1c8dc81a671770f74b479c0a78a818f1", + "reference": "b247957a1c8dc81a671770f74b479c0a78a818f1", "shasum": "" }, "require": { @@ -1661,7 +1846,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0" }, "funding": [ { @@ -1669,11 +1854,11 @@ "type": "github" } ], - "time": "2022-09-14T12:41:17+00:00" + "time": "2022-09-14T12:46:14+00:00" }, { "name": "sebastian/complexity", - "version": "2.0.3", + "version": "2.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", @@ -1730,7 +1915,7 @@ }, { "name": "sebastian/diff", - "version": "4.0.6", + "version": "4.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", @@ -1796,7 +1981,7 @@ }, { "name": "sebastian/environment", - "version": "5.1.5", + "version": "5.1.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", @@ -1847,7 +2032,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1" }, "funding": [ { @@ -1859,7 +2044,7 @@ }, { "name": "sebastian/exporter", - "version": "4.0.6", + "version": "4.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", @@ -1936,7 +2121,7 @@ }, { "name": "sebastian/global-state", - "version": "5.0.7", + "version": "5.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", @@ -2000,7 +2185,7 @@ }, { "name": "sebastian/lines-of-code", - "version": "1.0.4", + "version": "1.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", @@ -2169,7 +2354,7 @@ }, { "name": "sebastian/recursion-context", - "version": "4.0.5", + "version": "4.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", @@ -2232,16 +2417,16 @@ }, { "name": "sebastian/resource-operations", - "version": "3.0.4", + "version": "dev-main", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" + "reference": "ff553e7482dcee39fa4acc2b175d6ddeb0f7bc25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", - "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ff553e7482dcee39fa4acc2b175d6ddeb0f7bc25", + "reference": "ff553e7482dcee39fa4acc2b175d6ddeb0f7bc25", "shasum": "" }, "require": { @@ -2250,6 +2435,7 @@ "require-dev": { "phpunit/phpunit": "^9.0" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -2274,7 +2460,7 @@ "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/main" }, "funding": [ { @@ -2282,11 +2468,11 @@ "type": "github" } ], - "time": "2024-03-14T16:00:52+00:00" + "time": "2024-03-14T18:47:08+00:00" }, { "name": "sebastian/type", - "version": "3.2.1", + "version": "3.2.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", @@ -2330,7 +2516,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" + "source": "https://github.com/sebastianbergmann/type/tree/3.2" }, "funding": [ { @@ -2342,7 +2528,7 @@ }, { "name": "sebastian/version", - "version": "3.0.2", + "version": "3.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", @@ -2501,16 +2687,16 @@ }, { "name": "symfony/console", - "version": "v7.0.6", + "version": "7.1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "fde915cd8e7eb99b3d531d3d5c09531429c3f9e5" + "reference": "1b84910b638ce3265e132d7b42405b2db64f6f69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/fde915cd8e7eb99b3d531d3d5c09531429c3f9e5", - "reference": "fde915cd8e7eb99b3d531d3d5c09531429c3f9e5", + "url": "https://api.github.com/repos/symfony/console/zipball/1b84910b638ce3265e132d7b42405b2db64f6f69", + "reference": "1b84910b638ce3265e132d7b42405b2db64f6f69", "shasum": "" }, "require": { @@ -2574,7 +2760,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.0.6" + "source": "https://github.com/symfony/console/tree/7.1" }, "funding": [ { @@ -2590,29 +2776,30 @@ "type": "tidelift" } ], - "time": "2024-04-01T11:04:53+00:00" + "time": "2024-04-06T17:55:56+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.4.0", + "version": "dev-main", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" + "reference": "2c438b99bb2753c1628c1e6f523991edea5b03a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/2c438b99bb2753c1628c1e6f523991edea5b03a4", + "reference": "2c438b99bb2753c1628c1e6f523991edea5b03a4", "shasum": "" }, "require": { "php": ">=8.1" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -2641,7 +2828,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/main" }, "funding": [ { @@ -2657,26 +2844,27 @@ "type": "tidelift" } ], - "time": "2023-05-23T14:45:45+00:00" + "time": "2024-01-02T14:07:37+00:00" }, { "name": "symfony/filesystem", - "version": "v7.0.6", + "version": "7.1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "408105dff4c104454100730bdfd1a9cdd993f04d" + "reference": "47d346741881ecf75f6b6474b52f0781e6c42af7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/408105dff4c104454100730bdfd1a9cdd993f04d", - "reference": "408105dff4c104454100730bdfd1a9cdd993f04d", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/47d346741881ecf75f6b6474b52f0781e6c42af7", + "reference": "47d346741881ecf75f6b6474b52f0781e6c42af7", "shasum": "" }, "require": { "php": ">=8.2", "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8" + "symfony/polyfill-mbstring": "~1.8", + "symfony/process": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -2704,7 +2892,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.0.6" + "source": "https://github.com/symfony/filesystem/tree/7.1" }, "funding": [ { @@ -2720,20 +2908,20 @@ "type": "tidelift" } ], - "time": "2024-03-21T19:37:36+00:00" + "time": "2024-04-16T16:29:43+00:00" }, { "name": "symfony/finder", - "version": "v7.0.0", + "version": "7.1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "6e5688d69f7cfc4ed4a511e96007e06c2d34ce56" + "reference": "9bfc6ffa24b1b66f7c3c9f71b2870e1413c1ce03" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/6e5688d69f7cfc4ed4a511e96007e06c2d34ce56", - "reference": "6e5688d69f7cfc4ed4a511e96007e06c2d34ce56", + "url": "https://api.github.com/repos/symfony/finder/zipball/9bfc6ffa24b1b66f7c3c9f71b2870e1413c1ce03", + "reference": "9bfc6ffa24b1b66f7c3c9f71b2870e1413c1ce03", "shasum": "" }, "require": { @@ -2768,7 +2956,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.0.0" + "source": "https://github.com/symfony/finder/tree/7.1" }, "funding": [ { @@ -2784,20 +2972,20 @@ "type": "tidelift" } ], - "time": "2023-10-31T17:59:56+00:00" + "time": "2024-03-20T15:26:56+00:00" }, { "name": "symfony/options-resolver", - "version": "v7.0.0", + "version": "7.1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "700ff4096e346f54cb628ea650767c8130f1001f" + "reference": "9564f64c16f99e29f252eafc642965e8fcb755ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/700ff4096e346f54cb628ea650767c8130f1001f", - "reference": "700ff4096e346f54cb628ea650767c8130f1001f", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/9564f64c16f99e29f252eafc642965e8fcb755ce", + "reference": "9564f64c16f99e29f252eafc642965e8fcb755ce", "shasum": "" }, "require": { @@ -2835,7 +3023,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v7.0.0" + "source": "https://github.com/symfony/options-resolver/tree/7.1" }, "funding": [ { @@ -2851,11 +3039,11 @@ "type": "tidelift" } ], - "time": "2023-08-08T10:20:21+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.29.0", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -2876,6 +3064,7 @@ "suggest": { "ext-ctype": "For best performance" }, + "default-branch": true, "type": "library", "extra": { "thanks": { @@ -2934,7 +3123,7 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.29.0", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", @@ -2952,6 +3141,7 @@ "suggest": { "ext-intl": "For best performance" }, + "default-branch": true, "type": "library", "extra": { "thanks": { @@ -3012,7 +3202,7 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.29.0", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -3030,6 +3220,7 @@ "suggest": { "ext-intl": "For best performance" }, + "default-branch": true, "type": "library", "extra": { "thanks": { @@ -3093,16 +3284,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.29.0", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" + "reference": "3cf95983a25d6439cac5f5164f0bfeeb1eb5d264" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3cf95983a25d6439cac5f5164f0bfeeb1eb5d264", + "reference": "3cf95983a25d6439cac5f5164f0bfeeb1eb5d264", "shasum": "" }, "require": { @@ -3114,6 +3305,7 @@ "suggest": { "ext-mbstring": "For best performance" }, + "default-branch": true, "type": "library", "extra": { "thanks": { @@ -3153,7 +3345,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/1.x" }, "funding": [ { @@ -3169,20 +3361,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-04-12T09:26:28+00:00" }, { "name": "symfony/process", - "version": "v7.0.4", + "version": "7.1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "0e7727191c3b71ebec6d529fa0e50a01ca5679e9" + "reference": "8e99b1b15d2975b242fc089382c8f8055a85d996" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/0e7727191c3b71ebec6d529fa0e50a01ca5679e9", - "reference": "0e7727191c3b71ebec6d529fa0e50a01ca5679e9", + "url": "https://api.github.com/repos/symfony/process/zipball/8e99b1b15d2975b242fc089382c8f8055a85d996", + "reference": "8e99b1b15d2975b242fc089382c8f8055a85d996", "shasum": "" }, "require": { @@ -3214,7 +3406,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.0.4" + "source": "https://github.com/symfony/process/tree/7.1" }, "funding": [ { @@ -3230,33 +3422,35 @@ "type": "tidelift" } ], - "time": "2024-02-22T20:27:20+00:00" + "time": "2024-04-05T09:28:19+00:00" }, { "name": "symfony/service-contracts", - "version": "v3.4.2", + "version": "dev-main", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "11bbf19a0fb7b36345861e85c5768844c552906e" + "reference": "a17e69656265139c2ab4a62529f495a2a41fd6ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/11bbf19a0fb7b36345861e85c5768844c552906e", - "reference": "11bbf19a0fb7b36345861e85c5768844c552906e", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a17e69656265139c2ab4a62529f495a2a41fd6ce", + "reference": "a17e69656265139c2ab4a62529f495a2a41fd6ce", "shasum": "" }, "require": { "php": ">=8.1", - "psr/container": "^1.1|^2.0" + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" }, "conflict": { "ext-psr": "<1.1|>=2" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -3296,7 +3490,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.4.2" + "source": "https://github.com/symfony/service-contracts/tree/main" }, "funding": [ { @@ -3312,20 +3506,20 @@ "type": "tidelift" } ], - "time": "2023-12-19T21:51:00+00:00" + "time": "2024-04-05T09:39:30+00:00" }, { "name": "symfony/string", - "version": "v7.0.4", + "version": "7.1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "f5832521b998b0bec40bee688ad5de98d4cf111b" + "reference": "236b450c00ab6560e6cda684853d2db3c6b41731" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/f5832521b998b0bec40bee688ad5de98d4cf111b", - "reference": "f5832521b998b0bec40bee688ad5de98d4cf111b", + "url": "https://api.github.com/repos/symfony/string/zipball/236b450c00ab6560e6cda684853d2db3c6b41731", + "reference": "236b450c00ab6560e6cda684853d2db3c6b41731", "shasum": "" }, "require": { @@ -3339,6 +3533,7 @@ "symfony/translation-contracts": "<2.5" }, "require-dev": { + "symfony/emoji": "^7.1", "symfony/error-handler": "^6.4|^7.0", "symfony/http-client": "^6.4|^7.0", "symfony/intl": "^6.4|^7.0", @@ -3382,7 +3577,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.0.4" + "source": "https://github.com/symfony/string/tree/7.1" }, "funding": [ { @@ -3398,7 +3593,7 @@ "type": "tidelift" } ], - "time": "2024-02-01T13:17:36+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "theseer/tokenizer", @@ -3452,7 +3647,7 @@ }, { "name": "webmozart/glob", - "version": "4.7.0", + "version": "4.8.x-dev", "source": { "type": "git", "url": "https://github.com/webmozarts/glob.git", @@ -3501,9 +3696,9 @@ } ], "aliases": [], - "minimum-stability": "stable", + "minimum-stability": "dev", "stability-flags": { - "utopia-php/di": 20 + "utopia-php/servers": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/src/Http/Exception.php b/src/Http/Exception.php index 46e55958..4de36cc3 100644 --- a/src/Http/Exception.php +++ b/src/Http/Exception.php @@ -2,6 +2,8 @@ namespace Utopia\Http; -class Exception extends \Exception +use Utopia\Servers\Exception as ServersException; + +class Exception extends ServersException { } diff --git a/src/Http/Hook.php b/src/Http/Hook.php index 6519744e..e83a4f88 100644 --- a/src/Http/Hook.php +++ b/src/Http/Hook.php @@ -2,253 +2,8 @@ namespace Utopia\Http; -use Utopia\DI\Injection; +use Utopia\Servers\Hook as ServersHook; -class Hook extends Injection +class Hook extends ServersHook { - /** - * Description - * - * @var string - */ - protected string $desc = ''; - - /** - * Parameters - * - * List of route params names and validators - * - * @var array - */ - protected array $params = []; - - /** - * Group - * - * @var array - */ - protected array $groups = []; - - /** - * Labels - * - * List of route label names - * - * @var array - */ - protected array $labels = []; - - /** - * Injections - * - * List of route required injections for action callback - * - * @var array - */ - protected array $injections = []; - - /** - * Add Description - * - * @param string $desc - * @return static - */ - public function desc(string $desc): static - { - $this->desc = $desc; - - return $this; - } - - /** - * Get Description - * - * @return string - */ - public function getDesc(): string - { - return $this->desc; - } - - /** - * Add Group - * - * @param array $groups - * @return static - */ - public function groups(array $groups): static - { - $this->groups = $groups; - - return $this; - } - - /** - * Get Groups - * - * @return array - */ - public function getGroups(): array - { - return $this->groups; - } - - /** - * Add Label - * - * @param string $key - * @param mixed $value - * @return $this - */ - public function label(string $key, mixed $value): static - { - $this->labels[$key] = $value; - - return $this; - } - - /** - * Get Label - * - * Return given label value or default value if label doesn't exists - * - * @param string $key - * @param mixed $default - * @return mixed - */ - public function getLabel(string $key, mixed $default): mixed - { - return (isset($this->labels[$key])) ? $this->labels[$key] : $default; - } - - /** - * Add Action - * - * @param callable $action - * @return static - */ - public function action(callable $action): static - { - $this->setCallback($action); - - return $this; - } - - /** - * Get Action - * - * @return callable - */ - public function getAction() - { - return $this->getCallback(); - } - - /** - * Depenedency - * - * @param string $name - * @return self - * - * @throws Exception - */ - public function inject(string $name): self - { - parent::inject($name); - - return $this; - } - - /** - * Add Param - * - * @param string $key - * @param mixed $default - * @param Validator|callable $validator - * @param string $description - * @param bool $optional - * @param array $injections - * @param bool $skipValidation - * @return static - */ - public function param(string $key, mixed $default, Validator|callable $validator, string $description = '', bool $optional = false, array $injections = [], bool $skipValidation = false): static - { - $this->params[$key] = [ - 'default' => $default, - 'validator' => $validator, - 'description' => $description, - 'optional' => $optional, - 'injections' => $injections, - 'skipValidation' => $skipValidation, - 'value' => null, - 'order' => count($this->params) + count($this->injections), - ]; - - $this->inject($key); - - return $this; - } - - /** - * Get Params - * - * @return array - */ - public function getParams(): array - { - return $this->params; - } - - /** - * Get Param Values - * - * @return array - */ - public function getParamsValues(): array - { - $values = []; - - foreach ($this->params as $key => $param) { - $values[$key] = $param['value']; - } - - return $values; - } - - /** - * Set Param Value - * - * @param string $key - * @param mixed $value - * @return static - * - * @throws Exception - */ - public function setParamValue(string $key, mixed $value): static - { - if (!isset($this->params[$key])) { - throw new Exception('Unknown key'); - } - - $this->params[$key]['value'] = $value; - - return $this; - } - - /** - * Get Param Value - * - * @param string $key - * @return mixed - * - * @throws Exception - */ - public function getParamValue(string $key): mixed - { - if (!isset($this->params[$key])) { - throw new Exception('Unknown key'); - } - - return $this->params[$key]['value']; - } } diff --git a/src/Http/Http.php b/src/Http/Http.php index 73fe8d85..00569b20 100755 --- a/src/Http/Http.php +++ b/src/Http/Http.php @@ -4,8 +4,9 @@ use Utopia\DI\Container; use Utopia\DI\Dependency; +use Utopia\Servers\Base; -class Http +class Http extends Base { /** * Request method constants @@ -18,52 +19,11 @@ class Http public const REQUEST_METHOD_OPTIONS = 'OPTIONS'; public const REQUEST_METHOD_HEAD = 'HEAD'; - /** - * Mode Type - */ - public const MODE_TYPE_DEVELOPMENT = 'development'; - public const MODE_TYPE_STAGE = 'stage'; - public const MODE_TYPE_PRODUCTION = 'production'; - /** * @var Files */ protected Files $files; - /** - * Current running mode - * - * @var string - */ - protected static string $mode = ''; - - /** - * Errors - * - * Errors callbacks - * - * @var Hook[] - */ - protected static array $errors = []; - - /** - * Init - * - * A callback function that is initialized on application start - * - * @var Hook[] - */ - protected static array $init = []; - - /** - * Shutdown - * - * A callback function that is initialized on application end - * - * @var Hook[] - */ - protected static array $shutdown = []; - /** * Options * @@ -73,22 +33,6 @@ class Http */ protected static array $options = []; - /** - * Server Start hooks - * - * @var Hook[] - */ - protected static array $startHooks = []; - - /** - * Route - * - * Memory cached result for chosen route - * - * @var Route|null - */ - protected ?Route $route = null; - /** * Wildcard route * If set, this get's executed if no other route is matched @@ -102,11 +46,6 @@ class Http */ protected Adapter $server; - /** - * @var Container - */ - protected Container $container; - protected string|null $requestClass = null; protected string|null $responseClass = null; @@ -221,40 +160,6 @@ public static function wildcard(): Route return $route; } - /** - * Init - * - * Set a callback function that will be initialized on application start - * - * @return Hook - */ - public static function init(): Hook - { - $hook = new Hook(); - $hook->groups(['*']); - - self::$init[] = $hook; - - return $hook; - } - - /** - * Shutdown - * - * Set a callback function that will be initialized on application end - * - * @return Hook - */ - public static function shutdown(): Hook - { - $hook = new Hook(); - $hook->groups(['*']); - - self::$shutdown[] = $hook; - - return $hook; - } - /** * Options * @@ -272,23 +177,6 @@ public static function options(): Hook return $hook; } - /** - * Error - * - * An error callback for failed or no matched requests - * - * @return Hook - */ - public static function error(): Hook - { - $hook = new Hook(); - $hook->groups(['*']); - - self::$errors[] = $hook; - - return $hook; - } - /** * Get Mode * @@ -314,24 +202,6 @@ public static function setMode(string $value): void self::$mode = $value; } - /** - * Get Container - * - * @return Container - */ - public function getContainer(): Container - { - return $this->container; - } - - /** - * Set Container - */ - public function setContainer(Container $container): void - { - $this->container = $container; - } - /** * Get allow override * @@ -355,36 +225,6 @@ public static function setAllowOverride(bool $value): void Router::setAllowOverride($value); } - /** - * Is http in production mode? - * - * @return bool - */ - public static function isProduction(): bool - { - return self::MODE_TYPE_PRODUCTION === self::$mode; - } - - /** - * Is http in development mode? - * - * @return bool - */ - public static function isDevelopment(): bool - { - return self::MODE_TYPE_DEVELOPMENT === self::$mode; - } - - /** - * Is http in stage mode? - * - * @return bool - */ - public static function isStage(): bool - { - return self::MODE_TYPE_STAGE === self::$mode; - } - /** * Add Route * @@ -454,13 +294,6 @@ protected function getFileMimeType(string $uri): mixed return $this->files->getFileMimeType($uri); } - public static function onStart(): Hook - { - $hook = new Hook(); - self::$startHooks[] = $hook; - return $hook; - } - public function start() { $this->server->onRequest(function ($request, $response) { @@ -505,7 +338,7 @@ public function start() ; try { - foreach (self::$startHooks as $hook) { + foreach (self::$start as $hook) { $this->prepare($container, $hook, [], [])->inject($hook, true); } } catch(\Exception $e) { @@ -632,53 +465,6 @@ protected function lifecycle(Route $route, Request $request, Container $context) return $this; } - /** - * Prepare hook for injection, add dependencies, run validation. - * - * @param Hook $hook - * @param array $values - * @param array $requestParams - * @return Container - * - * @throws Exception - */ - protected function prepare(Container $context, Hook $hook, array $values = [], array $requestParams = []): Container - { - foreach ($hook->getParams() as $key => $param) { // Get value from route or request object - $existsInRequest = \array_key_exists($key, $requestParams); - $existsInValues = \array_key_exists($key, $values); - $paramExists = $existsInRequest || $existsInValues; - $arg = $existsInRequest ? $requestParams[$key] : $param['default']; - - $value = $existsInValues ? $values[$key] : $arg; - - /** - * Validation - */ - if (!$param['skipValidation']) { - if (!$paramExists && !$param['optional']) { - throw new Exception('Param "' . $key . '" is not optional.', 400); - } - - if ($paramExists) { - $this->validate($key, $param, $value, $context); - } - } - - $hook->setParamValue($key, $value); - - $dependencyForValue = new Dependency(); - $dependencyForValue - ->setName($key) - ->setCallback(fn () => $value) - ; - - $context->set($dependencyForValue); - } - - return $context; - } - /** * Run * @@ -813,50 +599,6 @@ public function run(Container $context): static return $this; } - /** - * Validate Param - * - * Creates an validator instance and validate given value with given rules. - * - * @param string $key - * @param array $param - * @param mixed $value - * @return void - * - * @throws Exception - */ - protected function validate(string $key, array $param, mixed $value, Container $context): void - { - if ($param['optional'] && \is_null($value)) { - return; - } - - $validator = $param['validator']; // checking whether the class exists - - if (\is_callable($validator)) { - - $dependency = new Dependency(); - $dependency - ->setName('_validator:'.$key) - ->setCallback($param['validator']) - ; - - foreach ($param['injections'] as $injection) { - $dependency->inject($injection); - } - - $validator = $context->inject($dependency); - } - - if (!$validator instanceof Validator) { // is the validator object an instance of the Validator class - throw new Exception('Validator object is not an instance of the Validator class', 500); - } - - if (!$validator->isValid($value)) { - throw new Exception('Invalid `' . $key . '` param: ' . $validator->getDescription(), 400); - } - } - /** * Reset all the static variables * @@ -865,11 +607,7 @@ protected function validate(string $key, array $param, mixed $value, Container $ public static function reset(): void { Router::reset(); - self::$mode = ''; - self::$errors = []; - self::$init = []; - self::$shutdown = []; self::$options = []; - self::$startHooks = []; + parent::reset(); } } diff --git a/src/Http/Validator.php b/src/Http/Validator.php index 6a8304ea..0026fc6e 100755 --- a/src/Http/Validator.php +++ b/src/Http/Validator.php @@ -2,56 +2,9 @@ namespace Utopia\Http; -abstract class Validator -{ - public const TYPE_BOOLEAN = 'boolean'; - - public const TYPE_INTEGER = 'integer'; - - public const TYPE_FLOAT = 'double'; /* gettype() returns 'double' for historical reasons */ - - public const TYPE_STRING = 'string'; - - public const TYPE_ARRAY = 'array'; - - public const TYPE_OBJECT = 'object'; +use Utopia\Servers\Validator as ServersValidator; - public const TYPE_MIXED = 'mixed'; - - /** - * Get Description - * - * Returns validator description - * - * @return string - */ - abstract public function getDescription(): string; - - /** - * Is array - * - * Returns true if an array or false if not. - * - * @return bool - */ - abstract public function isArray(): bool; - - /** - * Is valid - * - * Returns true if valid or false if not. - * - * @param mixed $value - * @return bool - */ - abstract public function isValid($value): bool; - - /** - * Get Type - * - * Returns validator type. - * - * @return string - */ - abstract public function getType(): string; +abstract class Validator extends ServersValidator +{ + } From 488706fcb11c7725aecf5764df9198d1389e455b Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 18 Apr 2024 22:27:32 +0200 Subject: [PATCH 02/10] Update TESTING argument in Dockerfile.swoole --- Dockerfile.swoole | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.swoole b/Dockerfile.swoole index f2267a55..a930c97a 100644 --- a/Dockerfile.swoole +++ b/Dockerfile.swoole @@ -1,6 +1,6 @@ FROM composer:2.0 AS step0 -ARG TESTING=false +ARG TESTING=true ARG DEBUG=false ENV TESTING=$TESTING @@ -16,7 +16,7 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \ FROM appwrite/base:0.9.0 as final -ARG TESTING=false +ARG TESTING=true ARG DEBUG=false ENV TESTING=$TESTING From 06a134c5eaf6730e557515e6e8a3e11d8fee0378 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 18 Apr 2024 22:41:01 +0200 Subject: [PATCH 03/10] Updated deps --- composer.lock | 106 ++------------------------------------------------ 1 file changed, 4 insertions(+), 102 deletions(-) diff --git a/composer.lock b/composer.lock index 46f4edf6..2318987c 100644 --- a/composer.lock +++ b/composer.lock @@ -6,55 +6,6 @@ ], "content-hash": "f961290f450cd8657302383ece07a86b", "packages": [ - { - "name": "utopia-php/cli", - "version": "0.17.0", - "source": { - "type": "git", - "url": "https://github.com/utopia-php/cli.git", - "reference": "0829fd5215afe88f53f3091cedc808da801fd1bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cli/zipball/0829fd5215afe88f53f3091cedc808da801fd1bb", - "reference": "0829fd5215afe88f53f3091cedc808da801fd1bb", - "shasum": "" - }, - "require": { - "php": ">=7.4", - "utopia-php/framework": "0.34.*" - }, - "require-dev": { - "laravel/pint": "1.2.*", - "phpunit/phpunit": "^9.3", - "squizlabs/php_codesniffer": "^3.6", - "vimeo/psalm": "4.0.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "Utopia\\CLI\\": "src/CLI" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A simple CLI library to manage command line applications", - "keywords": [ - "cli", - "command line", - "framework", - "php", - "upf", - "utopia" - ], - "support": { - "issues": "https://github.com/utopia-php/cli/issues", - "source": "https://github.com/utopia-php/cli/tree/0.17.0" - }, - "time": "2024-01-24T11:37:29+00:00" - }, { "name": "utopia-php/di", "version": "dev-main", @@ -117,71 +68,22 @@ }, "time": "2024-04-18T20:06:02+00:00" }, - { - "name": "utopia-php/framework", - "version": "0.34.2", - "source": { - "type": "git", - "url": "https://github.com/utopia-php/http.git", - "reference": "fd126c02b78cc80678c9638f7b335dfb4a841b78" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/fd126c02b78cc80678c9638f7b335dfb4a841b78", - "reference": "fd126c02b78cc80678c9638f7b335dfb4a841b78", - "shasum": "" - }, - "require": { - "ext-swoole": "*", - "php": ">=8.0" - }, - "require-dev": { - "laravel/pint": "^1.2", - "phpbench/phpbench": "^1.2", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9.5.25", - "swoole/ide-helper": "4.8.3" - }, - "type": "library", - "autoload": { - "psr-4": { - "Utopia\\Http\\": "src/Http" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A simple, light and advanced PHP HTTP framework", - "keywords": [ - "framework", - "http", - "php", - "upf" - ], - "support": { - "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.34.2" - }, - "time": "2024-02-20T11:36:56+00:00" - }, { "name": "utopia-php/servers", "version": "dev-dev", "source": { "type": "git", "url": "https://github.com/utopia-php/servers.git", - "reference": "afde8000e4d87ab1bb3cceba1c17e2506292123a" + "reference": "253ae7c51be0f0ade4e8ffb3e8c142cc27819374" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/servers/zipball/afde8000e4d87ab1bb3cceba1c17e2506292123a", - "reference": "afde8000e4d87ab1bb3cceba1c17e2506292123a", + "url": "https://api.github.com/repos/utopia-php/servers/zipball/253ae7c51be0f0ade4e8ffb3e8c142cc27819374", + "reference": "253ae7c51be0f0ade4e8ffb3e8c142cc27819374", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/cli": "0.17.*", "utopia-php/di": "dev-main" }, "require-dev": { @@ -235,7 +137,7 @@ "source": "https://github.com/utopia-php/servers/tree/dev", "issues": "https://github.com/utopia-php/servers/issues" }, - "time": "2024-04-18T20:05:13+00:00" + "time": "2024-04-18T20:40:06+00:00" } ], "packages-dev": [ From 1c1b5a337d2529dde40079c57e8849e7d473dfd0 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 18 Apr 2024 22:43:19 +0200 Subject: [PATCH 04/10] Fixed format --- src/Http/Adapter/Swoole/Server.php | 2 -- src/Http/Validator.php | 1 - tests/e2e/BaseTest.php | 2 +- tests/e2e/init.php | 2 +- tests/e2e/server-swoole.php | 5 ++--- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Http/Adapter/Swoole/Server.php b/src/Http/Adapter/Swoole/Server.php index 4cdc93b2..0724430f 100755 --- a/src/Http/Adapter/Swoole/Server.php +++ b/src/Http/Adapter/Swoole/Server.php @@ -6,8 +6,6 @@ use Swoole\Http\Server as SwooleServer; use Swoole\Runtime; -use function Swoole\Coroutine\run; - class Server extends Adapter { protected SwooleServer $server; diff --git a/src/Http/Validator.php b/src/Http/Validator.php index 0026fc6e..551d1cea 100755 --- a/src/Http/Validator.php +++ b/src/Http/Validator.php @@ -6,5 +6,4 @@ abstract class Validator extends ServersValidator { - } diff --git a/tests/e2e/BaseTest.php b/tests/e2e/BaseTest.php index e04c4016..f7be2237 100644 --- a/tests/e2e/BaseTest.php +++ b/tests/e2e/BaseTest.php @@ -73,7 +73,7 @@ public function testParamInjection() $this->assertEquals(200, $response['headers']['status-code']); $this->assertStringStartsWith('Hello World!test4573', $response['body']); } - + public function testNotFound() { $response = $this->client->call(Client::METHOD_GET, '/non-existing-page'); diff --git a/tests/e2e/init.php b/tests/e2e/init.php index f5e736dd..540891e6 100644 --- a/tests/e2e/init.php +++ b/tests/e2e/init.php @@ -119,7 +119,7 @@ Http::get('/param-injection') ->inject('response') - ->param('param', 'default', fn($num) => new Text($num), 'test param', false, ['num']) + ->param('param', 'default', fn ($num) => new Text($num), 'test param', false, ['num']) ->action(function (Response $response, string $param) { $response->send('Hello World!' . $param); }); diff --git a/tests/e2e/server-swoole.php b/tests/e2e/server-swoole.php index 2f3d1eda..367d4ee7 100755 --- a/tests/e2e/server-swoole.php +++ b/tests/e2e/server-swoole.php @@ -14,15 +14,14 @@ require_once __DIR__.'/init.php'; -$pool = new PDOPool((new PDOConfig) +$pool = new PDOPool((new PDOConfig()) ->withHost('mariadb') ->withPort(3306) // ->withUnixSocket('/tmp/mysql.sock') ->withDbName('test') ->withCharset('utf8mb4') ->withUsername('user') - ->withPassword('password') -, 9000); + ->withPassword('password'), 9000); $dependency = new Dependency(); From e84ceaeda253c5b942972450dec73b91405c1cf7 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 18 Apr 2024 23:04:25 +0200 Subject: [PATCH 05/10] Fixed inheritance --- composer.lock | 10 +++++----- src/Http/Validator.php | 13 +++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 2318987c..ef084367 100644 --- a/composer.lock +++ b/composer.lock @@ -74,12 +74,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/servers.git", - "reference": "253ae7c51be0f0ade4e8ffb3e8c142cc27819374" + "reference": "43881ed83f97cb31af7f940db74c520c70b914ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/servers/zipball/253ae7c51be0f0ade4e8ffb3e8c142cc27819374", - "reference": "253ae7c51be0f0ade4e8ffb3e8c142cc27819374", + "url": "https://api.github.com/repos/utopia-php/servers/zipball/43881ed83f97cb31af7f940db74c520c70b914ab", + "reference": "43881ed83f97cb31af7f940db74c520c70b914ab", "shasum": "" }, "require": { @@ -94,7 +94,7 @@ "type": "library", "autoload": { "psr-4": { - "Utopia\\Queue\\": "src/Servers" + "Utopia\\Servers\\": "src/Servers" } }, "autoload-dev": { @@ -137,7 +137,7 @@ "source": "https://github.com/utopia-php/servers/tree/dev", "issues": "https://github.com/utopia-php/servers/issues" }, - "time": "2024-04-18T20:40:06+00:00" + "time": "2024-04-18T20:51:43+00:00" } ], "packages-dev": [ diff --git a/src/Http/Validator.php b/src/Http/Validator.php index 551d1cea..f75b1550 100755 --- a/src/Http/Validator.php +++ b/src/Http/Validator.php @@ -6,4 +6,17 @@ abstract class Validator extends ServersValidator { + public const TYPE_BOOLEAN = 'boolean'; + + public const TYPE_INTEGER = 'integer'; + + public const TYPE_FLOAT = 'double'; /* gettype() returns 'double' for historical reasons */ + + public const TYPE_STRING = 'string'; + + public const TYPE_ARRAY = 'array'; + + public const TYPE_OBJECT = 'object'; + + public const TYPE_MIXED = 'mixed'; } From 4c4e85eac5164eabc97bc57708310b3e6419b9d6 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 22 Apr 2024 15:38:46 +0200 Subject: [PATCH 06/10] Added methods for get and set query strings --- src/Http/Adapter/FPM/Request.php | 27 ++++++++++++++++ src/Http/Adapter/Swoole/Request.php | 27 ++++++++++++++++ src/Http/Request.php | 49 +++++++++++++++++++---------- tests/RequestTest.php | 20 ++++++++++-- 4 files changed, 105 insertions(+), 18 deletions(-) diff --git a/src/Http/Adapter/FPM/Request.php b/src/Http/Adapter/FPM/Request.php index ecabb457..5de5d6d7 100644 --- a/src/Http/Adapter/FPM/Request.php +++ b/src/Http/Adapter/FPM/Request.php @@ -164,6 +164,33 @@ public function setURI(string $uri): static return $this; } + + /** + * Get Query String + * + * Return HTTP request query string + * + * @return string + */ + public function getQueryString(): string + { + return $this->getServer('QUERY_STRING') ?? ''; + } + + /** + * Set Query String + * + * Set HTTP request query string + * + * @param string $uri + * @return static + */ + public function setQueryString(string $value): static + { + $this->setServer('QUERY_STRING', $value); + + return $this; + } /** * Get files diff --git a/src/Http/Adapter/Swoole/Request.php b/src/Http/Adapter/Swoole/Request.php index 9e0ffa11..96ab81a5 100644 --- a/src/Http/Adapter/Swoole/Request.php +++ b/src/Http/Adapter/Swoole/Request.php @@ -179,6 +179,33 @@ public function setURI(string $uri): static return $this; } + /** + * Get Query String + * + * Return HTTP request query string + * + * @return string + */ + public function getQueryString(): string + { + return $this->getServer('query_string') ?? ''; + } + + /** + * Set Query String + * + * Set HTTP request query string + * + * @param string $uri + * @return static + */ + public function setQueryString(string $value): static + { + $this->setServer('query_string', $value); + + return $this; + } + /** * Get Referer * diff --git a/src/Http/Request.php b/src/Http/Request.php index 65f67b28..8eefde7a 100755 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -90,6 +90,19 @@ public function getQuery(string $key, mixed $default = null): mixed return $this->queryString[$key] ?? $default; } + /** + * Set query string parameters + * + * @param array $params + * @return static + */ + public function setQuery(array $params): static + { + $this->queryString = $params; + + return $this; + } + /** * Get payload * @@ -203,10 +216,7 @@ abstract public function setMethod(string $method): static; * * @return string */ - public function getURI(): string - { - return $this->getServer('REQUEST_URI') ?? ''; - } + abstract public function getURI(): string; /** * Get Path @@ -218,6 +228,25 @@ public function getURI(): string */ abstract public function setURI(string $uri): static; + /** + * Get query string + * + * Method for querying HTTP GET request query string + * + * @return string + */ + abstract public function getQueryString(): string; + + /** + * Set query string + * + * Method for setting HTTP GET request query string + * + * @param string $value + * @return string + */ + abstract public function setQueryString(string $value): static; + /** * Get files * @@ -454,18 +483,6 @@ public function getRangeUnit(): ?string return null; } - /** - * Set query string parameters - * - * @param array $params - * @return static - */ - public function setQueryString(array $params): static - { - $this->queryString = $params; - - return $this; - } /** * Set payload parameters diff --git a/tests/RequestTest.php b/tests/RequestTest.php index 55d49ee9..6138ae78 100755 --- a/tests/RequestTest.php +++ b/tests/RequestTest.php @@ -65,9 +65,9 @@ public function testCanGetQueryParameter() $this->assertEquals($this->request->getQuery('unknown', 'test'), 'test'); } - public function testCanSetQueryString() + public function testCanSetQuery() { - $this->request->setQueryString(['key' => 'value']); + $this->request->setQuery(['key' => 'value']); $this->assertEquals($this->request->getQuery('key'), 'value'); $this->assertEquals($this->request->getQuery('unknown', 'test'), 'test'); @@ -156,6 +156,22 @@ public function testCanSetUri() $this->assertEquals('/page.html', $this->request->getURI()); } + public function testCanGetQueryString() + { + $this->assertEquals('', $this->request->getQueryString()); + + $_SERVER['QUERY_STRING'] = 'text=hello&value=key'; + + $this->assertEquals('text=hello&value=key', $this->request->getQueryString()); + } + + public function testCanSetQueryString() + { + $this->request->setURI('text=hello&value=key'); + + $this->assertEquals('text=hello&value=key', $this->request->getURI()); + } + public function testCanGetPort() { $_SERVER['HTTP_HOST'] = 'localhost:8080'; From 395f876b4f87d428ebdf85a7308376eba4c8019f Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 22 Apr 2024 15:51:18 +0200 Subject: [PATCH 07/10] Updated composer --- composer.lock | 70 +++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/composer.lock b/composer.lock index ef084367..6ced2394 100644 --- a/composer.lock +++ b/composer.lock @@ -74,12 +74,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/servers.git", - "reference": "43881ed83f97cb31af7f940db74c520c70b914ab" + "reference": "20bb7ab93c21d0ae37bc309d41b70ddf2a78a6fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/servers/zipball/43881ed83f97cb31af7f940db74c520c70b914ab", - "reference": "43881ed83f97cb31af7f940db74c520c70b914ab", + "url": "https://api.github.com/repos/utopia-php/servers/zipball/20bb7ab93c21d0ae37bc309d41b70ddf2a78a6fd", + "reference": "20bb7ab93c21d0ae37bc309d41b70ddf2a78a6fd", "shasum": "" }, "require": { @@ -137,7 +137,7 @@ "source": "https://github.com/utopia-php/servers/tree/dev", "issues": "https://github.com/utopia-php/servers/issues" }, - "time": "2024-04-18T20:51:43+00:00" + "time": "2024-04-21T18:53:43+00:00" } ], "packages-dev": [ @@ -499,12 +499,12 @@ "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "46be4560c4cd4bab2b74882c0da39a4548a5cfbe" + "reference": "c5ee33df86c06b3278c670f64273b1ba768a0744" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/46be4560c4cd4bab2b74882c0da39a4548a5cfbe", - "reference": "46be4560c4cd4bab2b74882c0da39a4548a5cfbe", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c5ee33df86c06b3278c670f64273b1ba768a0744", + "reference": "c5ee33df86c06b3278c670f64273b1ba768a0744", "shasum": "" }, "require": { @@ -550,7 +550,7 @@ "issues": "https://github.com/nikic/PHP-Parser/issues", "source": "https://github.com/nikic/PHP-Parser/tree/master" }, - "time": "2024-03-17T10:24:36+00:00" + "time": "2024-04-19T12:04:10+00:00" }, { "name": "phar-io/manifest", @@ -884,12 +884,12 @@ "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "1ab6c28b7f4c273d1ffd6a4a5d8ef7e989ea04c5" + "reference": "3b03bac1068a585926a14e97692baef8642c2a1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1ab6c28b7f4c273d1ffd6a4a5d8ef7e989ea04c5", - "reference": "1ab6c28b7f4c273d1ffd6a4a5d8ef7e989ea04c5", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3b03bac1068a585926a14e97692baef8642c2a1b", + "reference": "3b03bac1068a585926a14e97692baef8642c2a1b", "shasum": "" }, "require": { @@ -935,7 +935,7 @@ "type": "github" } ], - "time": "2024-04-18T15:41:16+00:00" + "time": "2024-04-22T13:39:03+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1262,12 +1262,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "2f5cc6727bef6304e013d24e16e2203ca1f5ea94" + "reference": "33a0610878994fc134c74c25d5276d606d49079b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2f5cc6727bef6304e013d24e16e2203ca1f5ea94", - "reference": "2f5cc6727bef6304e013d24e16e2203ca1f5ea94", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/33a0610878994fc134c74c25d5276d606d49079b", + "reference": "33a0610878994fc134c74c25d5276d606d49079b", "shasum": "" }, "require": { @@ -1357,7 +1357,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T12:34:34+00:00" + "time": "2024-04-20T06:05:08+00:00" }, { "name": "psr/cache", @@ -2949,12 +2949,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" + "reference": "c9e59dec962d38cf2e0e4c61c4a1a1312f4dd7fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c9e59dec962d38cf2e0e4c61c4a1a1312f4dd7fe", + "reference": "c9e59dec962d38cf2e0e4c61c4a1a1312f4dd7fe", "shasum": "" }, "require": { @@ -3005,7 +3005,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/1.x" }, "funding": [ { @@ -3021,7 +3021,7 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-04-19T06:31:17+00:00" }, { "name": "symfony/polyfill-intl-grapheme", @@ -3029,12 +3029,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f" + "reference": "0a1df740cbb01859ce1bac85b0ad58ffe02f69b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f", - "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/0a1df740cbb01859ce1bac85b0ad58ffe02f69b6", + "reference": "0a1df740cbb01859ce1bac85b0ad58ffe02f69b6", "shasum": "" }, "require": { @@ -3084,7 +3084,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/1.x" }, "funding": [ { @@ -3100,7 +3100,7 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-04-19T06:31:17+00:00" }, { "name": "symfony/polyfill-intl-normalizer", @@ -3108,12 +3108,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" + "reference": "2a090dc3db090fcb35cc7329d18a07f281f15d79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", - "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/2a090dc3db090fcb35cc7329d18a07f281f15d79", + "reference": "2a090dc3db090fcb35cc7329d18a07f281f15d79", "shasum": "" }, "require": { @@ -3166,7 +3166,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/1.x" }, "funding": [ { @@ -3182,7 +3182,7 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-04-19T06:31:17+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -3190,12 +3190,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "3cf95983a25d6439cac5f5164f0bfeeb1eb5d264" + "reference": "e642fbe7a7b73cdb05460555289a9057bfd6ead6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3cf95983a25d6439cac5f5164f0bfeeb1eb5d264", - "reference": "3cf95983a25d6439cac5f5164f0bfeeb1eb5d264", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e642fbe7a7b73cdb05460555289a9057bfd6ead6", + "reference": "e642fbe7a7b73cdb05460555289a9057bfd6ead6", "shasum": "" }, "require": { @@ -3263,7 +3263,7 @@ "type": "tidelift" } ], - "time": "2024-04-12T09:26:28+00:00" + "time": "2024-04-19T06:31:17+00:00" }, { "name": "symfony/process", From b45169405bd28db2acdcecf0010a09e217897649 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 22 Apr 2024 16:00:27 +0200 Subject: [PATCH 08/10] Fixed format --- src/Http/Adapter/FPM/Request.php | 2 +- src/Http/Request.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Http/Adapter/FPM/Request.php b/src/Http/Adapter/FPM/Request.php index 5de5d6d7..1cad6db1 100644 --- a/src/Http/Adapter/FPM/Request.php +++ b/src/Http/Adapter/FPM/Request.php @@ -164,7 +164,7 @@ public function setURI(string $uri): static return $this; } - + /** * Get Query String * diff --git a/src/Http/Request.php b/src/Http/Request.php index 8eefde7a..66d09a78 100755 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -236,12 +236,12 @@ abstract public function setURI(string $uri): static; * @return string */ abstract public function getQueryString(): string; - + /** * Set query string * * Method for setting HTTP GET request query string - * + * * @param string $value * @return string */ From b7494aa6454fbe290fb2ab9f50fd5b187138788d Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 22 Apr 2024 16:06:34 +0200 Subject: [PATCH 09/10] Fixed codeQL --- src/Http/Adapter/FPM/Request.php | 2 +- src/Http/Adapter/Swoole/Request.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Http/Adapter/FPM/Request.php b/src/Http/Adapter/FPM/Request.php index 1cad6db1..bdc8ebf5 100644 --- a/src/Http/Adapter/FPM/Request.php +++ b/src/Http/Adapter/FPM/Request.php @@ -182,7 +182,7 @@ public function getQueryString(): string * * Set HTTP request query string * - * @param string $uri + * @param string $value * @return static */ public function setQueryString(string $value): static diff --git a/src/Http/Adapter/Swoole/Request.php b/src/Http/Adapter/Swoole/Request.php index 96ab81a5..d93310d2 100644 --- a/src/Http/Adapter/Swoole/Request.php +++ b/src/Http/Adapter/Swoole/Request.php @@ -196,7 +196,7 @@ public function getQueryString(): string * * Set HTTP request query string * - * @param string $uri + * @param string $value * @return static */ public function setQueryString(string $value): static From f16451f6e5d2f0fe737ec46d3fb939934a2b25e0 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 22 Apr 2024 16:31:22 +0200 Subject: [PATCH 10/10] Fixed response type --- src/Http/Request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/Request.php b/src/Http/Request.php index 66d09a78..e8894e04 100755 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -243,7 +243,7 @@ abstract public function getQueryString(): string; * Method for setting HTTP GET request query string * * @param string $value - * @return string + * @return static */ abstract public function setQueryString(string $value): static;