From 2e8c7ccc63f0448d7ce82ea5ef682453ed853b58 Mon Sep 17 00:00:00 2001 From: Tom Mitchelmore Date: Mon, 8 Sep 2025 08:18:47 +0100 Subject: [PATCH 1/8] Upgrade dependencies --- composer.json | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 26af239..4736a03 100644 --- a/composer.json +++ b/composer.json @@ -4,13 +4,11 @@ "psr/http-message": "^1.0" }, "require-dev": { - "laminas/laminas-diactoros": "^2.4", - "phpunit/phpunit": "^6.0", - "mockery/mockery": "^1.0.0", - "brain/monkey": "^2.0.2", - "satooshi/php-coveralls": "^1.0", - "squizlabs/php_codesniffer": "^3.5", - "codedungeon/phpunit-result-printer": "^0.4.4" + "laminas/laminas-diactoros": "^3.6", + "phpunit/phpunit": "^12", + "mockery/mockery": "^1.6", + "brain/monkey": "^2.6.2", + "squizlabs/php_codesniffer": "^3.7.2" }, "autoload": { "psr-4": { From f74cc961e25d2163cbda87e48cf9b2d4b31dab29 Mon Sep 17 00:00:00 2001 From: Tom Mitchelmore Date: Mon, 8 Sep 2025 08:19:40 +0100 Subject: [PATCH 2/8] Migrate test suite --- .gitignore | 2 ++ phpunit.xml | 24 +++++--------- tests/TestDiactorosServerRequest.php | 2 +- tests/Unit/Psr7ServerRequestExtensionTest.php | 33 ++++++++++--------- 4 files changed, 28 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 7579f74..9248812 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ vendor composer.lock +.phpunit.cache +.phpunit.result.cache diff --git a/phpunit.xml b/phpunit.xml index 2ebc93b..6483b85 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,23 +1,15 @@ - + + tests - - - src/ - - + + + + src + + diff --git a/tests/TestDiactorosServerRequest.php b/tests/TestDiactorosServerRequest.php index 9370288..2e76e99 100644 --- a/tests/TestDiactorosServerRequest.php +++ b/tests/TestDiactorosServerRequest.php @@ -4,7 +4,7 @@ use Rareloop\Psr7ServerRequestExtension\InteractsWithInput; use Rareloop\Psr7ServerRequestExtension\InteractsWithUri; -use Zend\Diactoros\ServerRequest; +use Laminas\Diactoros\ServerRequest; class TestDiactorosServerRequest extends ServerRequest { diff --git a/tests/Unit/Psr7ServerRequestExtensionTest.php b/tests/Unit/Psr7ServerRequestExtensionTest.php index d8d7d6c..4bce977 100644 --- a/tests/Unit/Psr7ServerRequestExtensionTest.php +++ b/tests/Unit/Psr7ServerRequestExtensionTest.php @@ -2,12 +2,13 @@ namespace Rareloop\Psr7ServerRequestExtension\Test; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Rareloop\Psr7ServerRequestExtension\Test\TestDiactorosServerRequest as ServerRequest; class Psr7ServerRequestExtensionTest extends TestCase { - /** @test */ + #[Test] public function can_get_path() { $request = new ServerRequest([], [], '/test/123', 'GET'); @@ -15,7 +16,7 @@ public function can_get_path() $this->assertSame('/test/123', $request->path()); } - /** @test */ + #[Test] public function can_get_url_without_query_string() { $request = new ServerRequest([], [], 'https://test.com/test/123?foo=bar', 'GET'); @@ -23,7 +24,7 @@ public function can_get_url_without_query_string() $this->assertSame('https://test.com/test/123', $request->url()); } - /** @test */ + #[Test] public function can_get_url_with_query_string() { $request = new ServerRequest([], [], 'https://test.com/test/123?foo=bar', 'GET'); @@ -31,7 +32,7 @@ public function can_get_url_with_query_string() $this->assertSame('https://test.com/test/123?foo=bar', $request->fullUrl()); } - /** @test */ + #[Test] public function no_trailing_question_mark_is_added_when_no_query_params_are_present() { $request = new ServerRequest([], [], 'https://test.com/test/123', 'GET'); @@ -39,7 +40,7 @@ public function no_trailing_question_mark_is_added_when_no_query_params_are_pres $this->assertSame('https://test.com/test/123', $request->fullUrl()); } - /** @test */ + #[Test] public function can_check_method() { $request = new ServerRequest([], [], '/test/123', 'GET'); @@ -50,7 +51,7 @@ public function can_check_method() $this->assertFalse($request->isMethod('POST')); } - /** @test */ + #[Test] public function can_get_all_input() { $request = new ServerRequest([], [], '/test/123', 'GET', 'php://input', [], [], ['foo' => 'bar'], ['baz' => 'qux']); @@ -61,7 +62,7 @@ public function can_get_all_input() $this->assertSame('qux', $input['baz']); } - /** @test */ + #[Test] public function can_get_specific_input_with_key() { $request = new ServerRequest([], [], '/test/123', 'GET', 'php://input', [], [], ['foo' => 'bar'], ['baz' => 'qux']); @@ -70,7 +71,7 @@ public function can_get_specific_input_with_key() $this->assertSame('qux', $request->input('baz')); } - /** @test */ + #[Test] public function can_get_default_when_key_is_not_found_in_input() { $request = new ServerRequest([], [], '/test/123', 'GET'); @@ -78,7 +79,7 @@ public function can_get_default_when_key_is_not_found_in_input() $this->assertSame('bar', $request->input('foo', 'bar')); } - /** @test */ + #[Test] public function can_check_if_input_has_a_specific_key() { $request = new ServerRequest([], [], '/test/123', 'GET', 'php://input', [], [], ['foo' => 'bar']); @@ -87,7 +88,7 @@ public function can_check_if_input_has_a_specific_key() $this->assertFalse($request->has('baz')); } - /** @test */ + #[Test] public function can_check_if_input_has_collection_of_keys() { $request = new ServerRequest([], [], '/test/123', 'GET', 'php://input', [], [], ['foo' => 'bar'], ['baz' => 'qux']); @@ -95,7 +96,7 @@ public function can_check_if_input_has_collection_of_keys() $this->assertTrue($request->has(['foo', 'baz'])); } - /** @test */ + #[Test] public function can_get_all_query() { $request = new ServerRequest([], [], '/test/123', 'GET', 'php://input', [], [], ['foo' => 'bar'], ['baz' => 'qux']); @@ -106,7 +107,7 @@ public function can_get_all_query() $this->assertFalse(isset($input['baz'])); } - /** @test */ + #[Test] public function can_get_specific_query_with_key() { $request = new ServerRequest([], [], '/test/123', 'GET', 'php://input', [], [], ['foo' => 'bar'], ['baz' => 'qux']); @@ -114,7 +115,7 @@ public function can_get_specific_query_with_key() $this->assertSame('bar', $request->query('foo')); } - /** @test */ + #[Test] public function can_get_default_when_key_is_not_found_in_query() { $request = new ServerRequest([], [], '/test/123', 'GET'); @@ -122,7 +123,7 @@ public function can_get_default_when_key_is_not_found_in_query() $this->assertSame('bar', $request->query('foo', 'bar')); } - /** @test */ + #[Test] public function can_get_all_post() { $request = new ServerRequest([], [], '/test/123', 'GET', 'php://input', [], [], ['foo' => 'bar'], ['baz' => 'qux']); @@ -133,7 +134,7 @@ public function can_get_all_post() $this->assertFalse(isset($input['foo'])); } - /** @test */ + #[Test] public function can_get_specific_post_with_key() { $request = new ServerRequest([], [], '/test/123', 'GET', 'php://input', [], [], ['foo' => 'bar'], ['baz' => 'qux']); @@ -141,7 +142,7 @@ public function can_get_specific_post_with_key() $this->assertSame('qux', $request->post('baz')); } - /** @test */ + #[Test] public function can_get_default_when_key_is_not_found_in_post() { $request = new ServerRequest([], [], '/test/123', 'GET'); From b896df3d41549a2ec4bb71d0eaa10f5acdc2500e Mon Sep 17 00:00:00 2001 From: Tom Mitchelmore Date: Mon, 8 Sep 2025 08:30:19 +0100 Subject: [PATCH 3/8] Update PSR http message --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4736a03..2fece32 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "rareloop/psr7-server-request-extension", "require": { - "psr/http-message": "^1.0" + "psr/http-message": "^2" }, "require-dev": { "laminas/laminas-diactoros": "^3.6", From f37e081f3380d47c98c25a6ebd70e0b445fa2a59 Mon Sep 17 00:00:00 2001 From: Tom Mitchelmore Date: Mon, 8 Sep 2025 10:04:47 +0100 Subject: [PATCH 4/8] Migrate phpunit --- phpunit.xml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 6483b85..66eb280 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,15 +1,13 @@ - - - - - tests - - - - - - src - - + + + + tests + + + + + src/ + + From 6cad1a014f76e8d9b0b320a6b859f6656002ae27 Mon Sep 17 00:00:00 2001 From: Tom Mitchelmore Date: Mon, 8 Sep 2025 10:05:58 +0100 Subject: [PATCH 5/8] Update to php 8.4 --- composer.json | 6 ++++-- rector.php | 15 +++++++++++++++ src/InteractsWithUri.php | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 rector.php diff --git a/composer.json b/composer.json index 2fece32..24f8a47 100644 --- a/composer.json +++ b/composer.json @@ -1,14 +1,16 @@ { "name": "rareloop/psr7-server-request-extension", "require": { - "psr/http-message": "^2" + "psr/http-message": "^2", + "php": "^8.4" }, "require-dev": { "laminas/laminas-diactoros": "^3.6", "phpunit/phpunit": "^12", "mockery/mockery": "^1.6", "brain/monkey": "^2.6.2", - "squizlabs/php_codesniffer": "^3.7.2" + "squizlabs/php_codesniffer": "^3.7.2", + "rector/rector": "^2.1" }, "autoload": { "psr-4": { diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..e0304fa --- /dev/null +++ b/rector.php @@ -0,0 +1,15 @@ +withPaths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->withPhpSets(php84: true) + ->withTypeCoverageLevel(0) + ->withDeadCodeLevel(0) + ->withCodeQualityLevel(0); diff --git a/src/InteractsWithUri.php b/src/InteractsWithUri.php index 4ab9dab..a1e1d91 100644 --- a/src/InteractsWithUri.php +++ b/src/InteractsWithUri.php @@ -33,6 +33,6 @@ public function fullUrl(): string public function isMethod($method): bool { - return strtolower($method) === strtolower($this->getMethod()); + return strtolower((string) $method) === strtolower($this->getMethod()); } } From bc8ce22206e083a0d31b515c21217e0d948393a8 Mon Sep 17 00:00:00 2001 From: Tom Mitchelmore Date: Tue, 7 Oct 2025 10:08:16 +0100 Subject: [PATCH 6/8] Re-support 8.1-8.4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 24f8a47..1a9cba0 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "rareloop/psr7-server-request-extension", "require": { "psr/http-message": "^2", - "php": "^8.4" + "php": ">=8.1" }, "require-dev": { "laminas/laminas-diactoros": "^3.6", From 9baf05db28ef0455bee1a56fabab5dfe4f1d774c Mon Sep 17 00:00:00 2001 From: Adam Tomat Date: Mon, 13 Oct 2025 16:46:35 +0100 Subject: [PATCH 7/8] Remove rector and downgrade PHPUnit --- composer.json | 5 ++--- rector.php | 15 --------------- src/InteractsWithUri.php | 2 +- 3 files changed, 3 insertions(+), 19 deletions(-) delete mode 100644 rector.php diff --git a/composer.json b/composer.json index 1a9cba0..be608fd 100644 --- a/composer.json +++ b/composer.json @@ -6,11 +6,10 @@ }, "require-dev": { "laminas/laminas-diactoros": "^3.6", - "phpunit/phpunit": "^12", + "phpunit/phpunit": "^10.5", "mockery/mockery": "^1.6", "brain/monkey": "^2.6.2", - "squizlabs/php_codesniffer": "^3.7.2", - "rector/rector": "^2.1" + "squizlabs/php_codesniffer": "^3.7.2" }, "autoload": { "psr-4": { diff --git a/rector.php b/rector.php deleted file mode 100644 index e0304fa..0000000 --- a/rector.php +++ /dev/null @@ -1,15 +0,0 @@ -withPaths([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->withPhpSets(php84: true) - ->withTypeCoverageLevel(0) - ->withDeadCodeLevel(0) - ->withCodeQualityLevel(0); diff --git a/src/InteractsWithUri.php b/src/InteractsWithUri.php index a1e1d91..4ab9dab 100644 --- a/src/InteractsWithUri.php +++ b/src/InteractsWithUri.php @@ -33,6 +33,6 @@ public function fullUrl(): string public function isMethod($method): bool { - return strtolower((string) $method) === strtolower($this->getMethod()); + return strtolower($method) === strtolower($this->getMethod()); } } From 913bbed40801be9f93a1e12587eadd51f2d0ca88 Mon Sep 17 00:00:00 2001 From: Adam Tomat Date: Mon, 13 Oct 2025 16:46:42 +0100 Subject: [PATCH 8/8] Add github actions --- .github/workflows/ci.yml | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7208d53 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,46 @@ +name: CI + +on: [push, pull_request] + +jobs: + build-test: + runs-on: ubuntu-latest + strategy: + matrix: + php_version: [8.1, 8.2, 8.3, 8.4] + composer_flags: ['', '--prefer-lowest'] + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php_version }} + extensions: xdebug + + - name: Install dependencies + uses: php-actions/composer@v5 + with: + php_version: ${{ matrix.php_version }} + args: ${{ matrix.composer_flags }} + command: update + + - name: Run tests + run: ./vendor/bin/phpunit --coverage-clover ./tests/logs/clover.xml + env: + XDEBUG_MODE: coverage + + - name: Run Codesniffer + run: vendor/bin/phpcs --standard=PSR2 ./src + + # - name: Submit coverage to Coveralls + # # We use php-coveralls library for this, as the official Coveralls GitHub Action lacks support for clover reports: + # # https://github.com/coverallsapp/github-action/issues/15 + # env: + # COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # COVERALLS_PARALLEL: true + # COVERALLS_FLAG_NAME: ${{ github.job }}-PHP-${{ matrix.php_version }} ${{ matrix.composer_flags }} + # run: | + # composer global require php-coveralls/php-coveralls + # ~/.composer/vendor/bin/php-coveralls -v