From d835cf5889bcc54a98db3df64562841fc04a3873 Mon Sep 17 00:00:00 2001 From: Mike Soule Date: Sun, 8 Nov 2026 00:36:15 -0500 Subject: [PATCH] prepare tests and tooling for PHP 8.5 Remove implicit nullable parameter deprecations from test helpers and cover last insert IDs with omitted and null names. Upgrade PHPStan to 1.x and extend both CI matrices to PHP 8.5 while retaining PHP 8.0 support. --- .github/workflows/ci.yml | 2 ++ CHANGELOG.md | 7 +++++++ composer.json | 2 +- tests/FakeConnection.php | 2 +- tests/InsertTest.php | 14 ++++++++++++++ tests/QueryTestCase.php | 2 +- 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f70ed70..1640c12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,7 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' steps: - uses: actions/checkout@v4 @@ -78,6 +79,7 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' steps: - uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2557553..00e344c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## Unreleased + +- Explicitly nullable params in test helpers. +- Test last insert IDs with omitted and null names. +- Upgrade PHPStan to 1.0. +- Add PHP 8.5 to Github workflow. + ## 2.0.0 Initial release. diff --git a/composer.json b/composer.json index 4623bb8..0186a8f 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "require-dev": { "pds/skeleton": "^1.0", "phpunit/phpunit": "~9.0", - "phpstan/phpstan": "^0.12.82" + "phpstan/phpstan": "^1.0" }, "autoload": { "psr-4": { diff --git a/tests/FakeConnection.php b/tests/FakeConnection.php index 6214fae..f4c4cfd 100644 --- a/tests/FakeConnection.php +++ b/tests/FakeConnection.php @@ -41,7 +41,7 @@ public function perform(string $statement, array $values = []) : PDOStatement return new PDOStatement(); } - public function lastInsertId(string $name = null) : string + public function lastInsertId(?string $name = null) : string { return "{$name}-1"; } diff --git a/tests/InsertTest.php b/tests/InsertTest.php index 0c54c60..972da27 100644 --- a/tests/InsertTest.php +++ b/tests/InsertTest.php @@ -16,4 +16,18 @@ public function testGetLastInsertId() $actual = $query->getLastInsertId('foo'); $this->assertSame('foo-1', $actual); } + + public function testGetLastInsertId_withoutName() + { + $query = $this->newQuery(); + $actual = $query->getLastInsertId(); + $this->assertSame('-1', $actual); + } + + public function testGetLastInsertId_withNullName() + { + $query = $this->newQuery(); + $actual = $query->getLastInsertId(null); + $this->assertSame('-1', $actual); + } } diff --git a/tests/QueryTestCase.php b/tests/QueryTestCase.php index c8bb14d..d065e7e 100644 --- a/tests/QueryTestCase.php +++ b/tests/QueryTestCase.php @@ -19,7 +19,7 @@ protected function getQueryClass() return substr(get_class($this), 0, -4); } - protected function newQuery(string $arg = null) + protected function newQuery(?string $arg = null) { if ($arg === null) { $arg = new FakeConnection('fake');