diff --git a/composer.json b/composer.json index 8b134b3a..1be3425c 100644 --- a/composer.json +++ b/composer.json @@ -18,21 +18,21 @@ "phpcbf": "phpcbf -p" }, "require": { - "php": ">=7.3.0", + "php": ">=7.4.0", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-PDO": "*", "ext-SimpleXML": "*", "ext-xml": "*", - "doctrine/dbal": "^3.1", + "doctrine/dbal": "^3.2", "erusev/parsedown": "^1.7", - "gettext/gettext": "^5.5", + "gettext/gettext": "^5.6", "gettext/translator": "^1.0", - "guzzlehttp/guzzle": "^7.3", - "illuminate/container": "^8.41", - "illuminate/database": "^8.41", - "illuminate/support": "^8.41", + "guzzlehttp/guzzle": "^7.4", + "illuminate/container": "^8.76", + "illuminate/database": "^8.76", + "illuminate/support": "^8.76", "league/oauth2-client": "^2.6", "nikic/fast-route": "^1.3", "nyholm/psr7": "^1.4", @@ -41,19 +41,19 @@ "psr/log": "^1.1", "respect/validation": "^1.1", "swiftmailer/swiftmailer": "^6.2", - "symfony/http-foundation": "^5.2", - "symfony/mime": "^5.2", + "symfony/http-foundation": "^6.0", + "symfony/mime": "^6.0", "symfony/psr-http-message-bridge": "^2.1", "twig/twig": "^3.3", - "vlucas/phpdotenv": "^5.3" + "vlucas/phpdotenv": "^5.4" }, "require-dev": { - "dms/phpunit-arraysubset-asserts": "^0.3.0", - "fakerphp/faker": "^1.14.1", - "filp/whoops": "^2.12", + "dms/phpunit-arraysubset-asserts": "^0.3.1", + "fakerphp/faker": "^1.17", + "filp/whoops": "^2.14", "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "^3.6", - "symfony/var-dumper": "^5.2" + "symfony/var-dumper": "^6.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 18bd5348..86effbc2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ed2a8819c2b212ab9d781824a12d7120", + "content-hash": "6382e7e9ba81aa4f0146649008ae6f2d", "packages": [ { "name": "composer/package-versions-deprecated", @@ -2938,29 +2938,28 @@ }, { "name": "symfony/http-foundation", - "version": "v5.4.1", + "version": "v6.0.1", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "5dad3780023a707f4c24beac7d57aead85c1ce3c" + "reference": "4c55dff16ba400dc81c56b6234e5942f9b9c7bcc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/5dad3780023a707f4c24beac7d57aead85c1ce3c", - "reference": "5dad3780023a707f4c24beac7d57aead85c1ce3c", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/4c55dff16ba400dc81c56b6234e5942f9b9c7bcc", + "reference": "4c55dff16ba400dc81c56b6234e5942f9b9c7bcc", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.0.2", "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-mbstring": "~1.1", - "symfony/polyfill-php80": "^1.16" + "symfony/polyfill-mbstring": "~1.1" }, "require-dev": { "predis/predis": "~1.0", - "symfony/cache": "^4.4|^5.0|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/mime": "^4.4|^5.0|^6.0" + "symfony/cache": "^5.4|^6.0", + "symfony/expression-language": "^5.4|^6.0", + "symfony/mime": "^5.4|^6.0" }, "suggest": { "symfony/mime": "To use the file extension guesser" @@ -2991,7 +2990,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v5.4.1" + "source": "https://github.com/symfony/http-foundation/tree/v6.0.1" }, "funding": [ { @@ -3007,42 +3006,40 @@ "type": "tidelift" } ], - "time": "2021-12-09T12:46:57+00:00" + "time": "2021-12-09T12:47:37+00:00" }, { "name": "symfony/mime", - "version": "v5.4.0", + "version": "v6.0.1", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "d4365000217b67c01acff407573906ff91bcfb34" + "reference": "3506356e2368c5623f52cf5ff643e0dee8d5eef7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/d4365000217b67c01acff407573906ff91bcfb34", - "reference": "d4365000217b67c01acff407573906ff91bcfb34", + "url": "https://api.github.com/repos/symfony/mime/zipball/3506356e2368c5623f52cf5ff643e0dee8d5eef7", + "reference": "3506356e2368c5623f52cf5ff643e0dee8d5eef7", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", + "php": ">=8.0.2", "symfony/polyfill-intl-idn": "^1.10", - "symfony/polyfill-mbstring": "^1.0", - "symfony/polyfill-php80": "^1.16" + "symfony/polyfill-mbstring": "^1.0" }, "conflict": { "egulias/email-validator": "~3.0.0", "phpdocumentor/reflection-docblock": "<3.2.2", "phpdocumentor/type-resolver": "<1.4.0", - "symfony/mailer": "<4.4" + "symfony/mailer": "<5.4" }, "require-dev": { "egulias/email-validator": "^2.1.10|^3.1", "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/property-access": "^4.4|^5.1|^6.0", - "symfony/property-info": "^4.4|^5.1|^6.0", - "symfony/serializer": "^5.2|^6.0" + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/property-access": "^5.4|^6.0", + "symfony/property-info": "^5.4|^6.0", + "symfony/serializer": "^5.4|^6.0" }, "type": "library", "autoload": { @@ -3074,7 +3071,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v5.4.0" + "source": "https://github.com/symfony/mime/tree/v6.0.1" }, "funding": [ { @@ -3090,7 +3087,7 @@ "type": "tidelift" } ], - "time": "2021-11-23T10:19:22+00:00" + "time": "2021-12-08T15:13:44+00:00" }, { "name": "symfony/polyfill-ctype", @@ -5500,16 +5497,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.10", + "version": "9.5.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c814a05837f2edb0d1471d6e3f4ab3501ca3899a" + "reference": "2406855036db1102126125537adb1406f7242fdd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c814a05837f2edb0d1471d6e3f4ab3501ca3899a", - "reference": "c814a05837f2edb0d1471d6e3f4ab3501ca3899a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2406855036db1102126125537adb1406f7242fdd", + "reference": "2406855036db1102126125537adb1406f7242fdd", "shasum": "" }, "require": { @@ -5587,11 +5584,11 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.10" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.11" }, "funding": [ { - "url": "https://phpunit.de/donate.html", + "url": "https://phpunit.de/sponsors.html", "type": "custom" }, { @@ -5599,7 +5596,7 @@ "type": "github" } ], - "time": "2021-09-25T07:38:51+00:00" + "time": "2021-12-25T07:07:57+00:00" }, { "name": "sebastian/cli-parser", @@ -6623,32 +6620,31 @@ }, { "name": "symfony/var-dumper", - "version": "v5.4.1", + "version": "v6.0.1", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "2366ac8d8abe0c077844613c1a4f0c0a9f522dcc" + "reference": "9ca4948ec35bb15175e5475ba83dfdb13042a86c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/2366ac8d8abe0c077844613c1a4f0c0a9f522dcc", - "reference": "2366ac8d8abe0c077844613c1a4f0c0a9f522dcc", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/9ca4948ec35bb15175e5475ba83dfdb13042a86c", + "reference": "9ca4948ec35bb15175e5475ba83dfdb13042a86c", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.0.2", + "symfony/polyfill-mbstring": "~1.0" }, "conflict": { "phpunit/phpunit": "<5.4.3", - "symfony/console": "<4.4" + "symfony/console": "<5.4" }, "require-dev": { "ext-iconv": "*", - "symfony/console": "^4.4|^5.0|^6.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/uid": "^5.1|^6.0", + "symfony/console": "^5.4|^6.0", + "symfony/process": "^5.4|^6.0", + "symfony/uid": "^5.4|^6.0", "twig/twig": "^2.13|^3.0.4" }, "suggest": { @@ -6692,7 +6688,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v5.4.1" + "source": "https://github.com/symfony/var-dumper/tree/v6.0.1" }, "funding": [ { @@ -6708,7 +6704,7 @@ "type": "tidelift" } ], - "time": "2021-12-01T15:04:08+00:00" + "time": "2021-12-08T15:13:44+00:00" }, { "name": "theseer/tokenizer", @@ -6825,7 +6821,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.3.0", + "php": ">=7.4.0", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", diff --git a/src/Http/Request.php b/src/Http/Request.php index 0621d488..49a61b61 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -3,7 +3,6 @@ namespace Engelsystem\Http; use Nyholm\Psr7\UploadedFile; -use Nyholm\Psr7\Uri; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UriInterface; @@ -194,22 +193,6 @@ class Request extends SymfonyRequest implements ServerRequestInterface return $new; } - /** - * Retrieves the URI instance. - * - * This method MUST return a UriInterface instance. - * - * @link http://tools.ietf.org/html/rfc3986#section-4.3 - * @return string|UriInterface Returns a UriInterface instance - * representing the URI of the request. - */ - public function getUri() - { - $uri = parent::getUri(); - - return new Uri($uri); - } - /** * Retrieve server parameters. * diff --git a/src/Http/RequestServiceProvider.php b/src/Http/RequestServiceProvider.php index 37f8c604..382c6cae 100644 --- a/src/Http/RequestServiceProvider.php +++ b/src/Http/RequestServiceProvider.php @@ -38,7 +38,7 @@ class RequestServiceProvider extends ServiceProvider protected function setTrustedProxies( $request, $proxies, - $trustedHeadersSet = Request::HEADER_FORWARDED | Request::HEADER_X_FORWARDED_ALL + $trustedHeadersSet = Request::HEADER_FORWARDED | Request::HEADER_X_FORWARDED_TRAEFIK ) { $request->setTrustedProxies($proxies, $trustedHeadersSet); } diff --git a/src/Middleware/RouteDispatcher.php b/src/Middleware/RouteDispatcher.php index c20eba4b..19c6a343 100644 --- a/src/Middleware/RouteDispatcher.php +++ b/src/Middleware/RouteDispatcher.php @@ -4,6 +4,7 @@ namespace Engelsystem\Middleware; use Engelsystem\Http\Request; use FastRoute\Dispatcher as FastRouteDispatcher; +use Nyholm\Psr7\Uri; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; @@ -45,7 +46,7 @@ class RouteDispatcher implements MiddlewareInterface */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { - $path = $request->getUri()->getPath(); + $path = (new Uri($request->getUri()))->getPath(); if ($request instanceof Request) { $path = $request->getPathInfo(); } diff --git a/tests/Unit/Http/RequestTest.php b/tests/Unit/Http/RequestTest.php index 1635f73d..547a73d2 100644 --- a/tests/Unit/Http/RequestTest.php +++ b/tests/Unit/Http/RequestTest.php @@ -200,22 +200,10 @@ class RequestTest extends TestCase $new = $request->withUri($uri); $this->assertNotEquals($request, $new); - $this->assertEquals('http://foo.bar/bla?foo=bar', (string)$new->getUri()); + $this->assertEquals('http://foo.bar/bla?foo=bar', $new->getUri()); $new = $request->withUri($uri, true); - $this->assertEquals('http://lor.em/bla?foo=bar', (string)$new->getUri()); - } - - /** - * @covers \Engelsystem\Http\Request::getUri - */ - public function testGetUri() - { - $request = Request::create('http://lor.em/test?bla=foo'); - - $uri = $request->getUri(); - $this->assertInstanceOf(UriInterface::class, $uri); - $this->assertEquals('http://lor.em/test?bla=foo', (string)$uri); + $this->assertEquals('http://lor.em/bla?foo=bar', $new->getUri()); } /** diff --git a/tests/Unit/Middleware/RouteDispatcherTest.php b/tests/Unit/Middleware/RouteDispatcherTest.php index d35c0f6b..44b2e7b3 100644 --- a/tests/Unit/Middleware/RouteDispatcherTest.php +++ b/tests/Unit/Middleware/RouteDispatcherTest.php @@ -140,13 +140,10 @@ class RouteDispatcherTest extends TestCase ->willReturn('HEAD'); $request->expects($this->atLeastOnce()) ->method('getUri') - ->willReturn($uriInterface); + ->willReturn('http://foo.bar/lorem/foo%21bar'); $request->expects($this->atLeastOnce()) ->method('getPathInfo') ->willReturn('/foo%21bar'); - $uriInterface->expects($this->atLeastOnce()) - ->method('getPath') - ->willReturn('/lorem/foo%21bar'); return [$dispatcher, $response, $request, $handler]; }