diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index fc5f29a..4dca2b0 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -18,6 +18,7 @@ jobs: strategy: matrix: php-version: + - "8.6" - "8.5" - "8.4" - "8.3" @@ -34,7 +35,7 @@ jobs: # for github/codeql-action/upload-sarif to upload SARIF results security-events: write container: - image: byjg/php:8.4-cli + image: byjg/php:8.5-cli options: --user root --privileged steps: @@ -44,10 +45,15 @@ jobs: - name: Composer run: composer install + - name: Composer (psalm) + + run: composer --working-dir=tools/psalm update --no-interaction + + - name: Psalm # Note: Ignoring error code 2, which just signals that some # flaws were found, not that Psalm itself failed to run. - run: ./vendor/bin/psalm + run: ./tools/psalm/vendor/bin/psalm --show-info=true --report=psalm-results.sarif || [ $? = 2 ] diff --git a/CHANGELOG-7.0.md b/CHANGELOG-7.0.md new file mode 100644 index 0000000..b917c5b --- /dev/null +++ b/CHANGELOG-7.0.md @@ -0,0 +1,116 @@ +# Changelog - Version 7.0 + +## Overview + +Version 7.0 upgrades the underlying persistence stack to `byjg/micro-orm` 7.0 and +`byjg/anydataset-db` 7.0. The AuthUser public API is **unchanged**: `UsersService`, +`UsersRepository`, `UserPropertiesRepository`, models, enums and mapper interfaces keep the exact +same signatures as 6.x. + +Since 6.0 the library was already wired exclusively through `DatabaseExecutor` — the API that +became mandatory in anydataset-db 7.0 — so no library code had to change beyond the dependency +constraints. + +## Breaking Changes + +### Dependencies + +| Package | 6.x | 7.0 | +|---|---|---| +| `byjg/micro-orm` | `^6.0` | `^7.0` | +| `byjg/anydataset-db` (transitive) | `^6.0` | `^7.0` | + +### Removed driver query methods (via anydataset-db 7.0) + +The query methods deprecated on the drivers since anydataset-db 6.0 no longer exist +(`$dbDriver->execute()`, `getIterator()`, `getScalar()`, `executeAndGetId()`, `getAllFields()`). +If your application still calls them on the driver instance it passes to AuthUser, migrate to: + +```php +execute($sql, $params); +``` + +The recommended wiring is unchanged and keeps working as-is: + +```php +=8.3 <8.7"`. + The previous `<8.6` upper bound excluded PHP 8.6, since `<8.6` is exclusive. + +### ByJG dependencies + +- `byjg/cache-engine` is now `^7.0`. +- `byjg/jwt-wrapper` is now `^7.0`. +- `byjg/micro-orm` is now `^7.0`. + +While 7.0 is unreleased these resolve to `7.0.x-dev` from each component's +`7.0` branch, via `minimum-stability: dev` with `prefer-stable: true`. + +## Toolchain + +- PHPUnit updated to `^12.5`. +- Psalm moved out of `require-dev` into its own manifest, `tools/psalm/composer.json`. + + Psalm enumerates the PHP versions it supports and no published release lists + 8.6. As a dev dependency it made `composer install` fail on the 8.6 build job + before any test ran. It now installs separately, only for the Psalm job. + + `composer psalm` still works — it bootstraps the tool and runs it. + +- PHPUnit 13 is deliberately **not** used. It requires PHP `>=8.4.1`, breaking the + 8.3 floor, and needs `sebastian/diff ^9.0`, which stable Psalm 6.16.1 rejects — + a combination that silently resolves Psalm to an unreleased `6.x-dev` branch. + +## Continuous Integration + +- The build matrix now includes PHP 8.6. +- The Psalm job runs on PHP 8.5 and installs Psalm from `tools/psalm`. + +## Housekeeping + +- `phpunit.xml.dist` renamed to `phpunit.xml`. diff --git a/README.md b/README.md index db477b9..98e2abb 100644 --- a/README.md +++ b/README.md @@ -128,14 +128,5 @@ Because this project uses PHP Session you need to run the unit test the followin This project is licensed under the MIT License - see the [LICENSE](https://github.com/byjg/php-authuser/blob/master/LICENSE) file for details. -## Dependencies - -```mermaid -flowchart TD - byjg/authuser --> byjg/micro-orm - byjg/authuser --> byjg/cache-engine - byjg/authuser --> byjg/jwt-wrapper -``` - ---- [Open source ByJG](http://opensource.byjg.com) diff --git a/composer.json b/composer.json index 9fd678e..7f0c26c 100644 --- a/composer.json +++ b/composer.json @@ -14,18 +14,20 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": ">=8.3 <8.6", - "byjg/micro-orm": "^6.0", - "byjg/cache-engine": "^6.0", - "byjg/jwt-wrapper": "^6.0" + "php": ">=8.3 <8.7", + "byjg/micro-orm": "^7.0", + "byjg/cache-engine": "^7.0", + "byjg/jwt-wrapper": "^7.0" }, "require-dev": { - "phpunit/phpunit": "^10.5|^11.5", - "vimeo/psalm": "^5.9|^6.13" + "phpunit/phpunit": "^12.5" }, "scripts": { "test": "vendor/bin/phpunit", - "psalm": "vendor/bin/psalm --threads=1" + "psalm": [ + "@composer --working-dir=tools/psalm update --no-interaction", + "tools/psalm/vendor/bin/psalm --threads=1" + ] }, "license": "MIT" } diff --git a/phpunit.xml.dist b/phpunit.xml similarity index 100% rename from phpunit.xml.dist rename to phpunit.xml diff --git a/psalm.xml b/psalm.xml index 037de8b..c1976fd 100644 --- a/psalm.xml +++ b/psalm.xml @@ -7,7 +7,7 @@ cacheDirectory="/tmp/psalm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" - xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" + xsi:schemaLocation="https://getpsalm.org/schema/config tools/psalm/vendor/vimeo/psalm/config.xsd" > diff --git a/tests/PasswordMd5MapperTest.php b/tests/PasswordMd5MapperTest.php index 6257082..ab20070 100644 --- a/tests/PasswordMd5MapperTest.php +++ b/tests/PasswordMd5MapperTest.php @@ -25,7 +25,8 @@ class PasswordMd5MapperTest extends TestCase public function setUp(): void { $this->db = Factory::getDbInstance(self::CONNECTION_STRING); - $this->db->execute('create table users ( + $executor = DatabaseExecutor::using($this->db); + $executor->execute('create table users ( userid integer primary key autoincrement, name varchar(45), email varchar(200), @@ -37,7 +38,7 @@ public function setUp(): void role varchar(20));' ); - $this->db->execute('create table users_property ( + $executor->execute('create table users_property ( id integer primary key autoincrement, userid integer, name varchar(45), @@ -45,7 +46,6 @@ public function setUp(): void ); // Create repositories and service with custom MD5 password mapper via UserModelMd5 - $executor = DatabaseExecutor::using($this->db); $usersRepository = new UsersRepository($executor, UserModelMd5::class); $propertiesRepository = new UserPropertiesRepository($executor, UserPropertiesModel::class); $this->service = new UsersService( diff --git a/tests/UsersDBDataset2ByUserNameTestUsersBase.php b/tests/UsersDBDataset2ByUserNameTestUsersBase.php index 25c9687..5622d87 100644 --- a/tests/UsersDBDataset2ByUserNameTestUsersBase.php +++ b/tests/UsersDBDataset2ByUserNameTestUsersBase.php @@ -22,8 +22,9 @@ public function __setUp($loginField) $this->prefix = ""; $this->loginField = $loginField; - $this->db = Factory::getDbRelationalInstance(self::CONNECTION_STRING); - $this->db->execute('create table mytable ( + $this->db = Factory::getDbInstance(self::CONNECTION_STRING); + $executor = DatabaseExecutor::using($this->db); + $executor->execute('create table mytable ( myuserid integer primary key autoincrement, myname varchar(45), myemail varchar(200), @@ -35,14 +36,13 @@ public function __setUp($loginField) myrole varchar(20));' ); - $this->db->execute('create table theirproperty ( + $executor->execute('create table theirproperty ( theirid integer primary key autoincrement, theiruserid integer, theirname varchar(45), theirvalue varchar(45));' ); - $executor = DatabaseExecutor::using($this->db); $usersRepository = new UsersRepository($executor, CustomUserModel::class); $propertiesRepository = new UserPropertiesRepository($executor, CustomUserPropertiesModel::class); $this->object = new UsersService( diff --git a/tests/UsersDBDatasetByUsernameTestUsersBase.php b/tests/UsersDBDatasetByUsernameTestUsersBase.php index 4a5b266..3c9f2e1 100644 --- a/tests/UsersDBDatasetByUsernameTestUsersBase.php +++ b/tests/UsersDBDatasetByUsernameTestUsersBase.php @@ -26,7 +26,8 @@ public function __setUp($loginField) $this->loginField = $loginField; $this->db = Factory::getDbInstance(self::CONNECTION_STRING); - $this->db->execute('create table users ( + $executor = DatabaseExecutor::using($this->db); + $executor->execute('create table users ( userid integer primary key autoincrement, name varchar(45), email varchar(200), @@ -38,14 +39,13 @@ public function __setUp($loginField) role varchar(20));' ); - $this->db->execute('create table users_property ( + $executor->execute('create table users_property ( id integer primary key autoincrement, userid integer, name varchar(45), value varchar(45));' ); - $executor = DatabaseExecutor::using($this->db); $usersRepository = new UsersRepository($executor, UserModel::class); $propertiesRepository = new UserPropertiesRepository($executor, UserPropertiesModel::class); $this->object = new UsersService( diff --git a/tests/UsersDBDatasetDefinitionTest.php b/tests/UsersDBDatasetDefinitionTest.php index e3479d5..de544ca 100644 --- a/tests/UsersDBDatasetDefinitionTest.php +++ b/tests/UsersDBDatasetDefinitionTest.php @@ -38,7 +38,8 @@ public function __setUp($loginField) $this->loginField = $loginField; $this->db = Factory::getDbInstance(self::CONNECTION_STRING); - $this->db->execute('create table mytable ( + $executor = DatabaseExecutor::using($this->db); + $executor->execute('create table mytable ( myuserid integer primary key autoincrement, myname varchar(45), myemail varchar(200), @@ -51,14 +52,13 @@ public function __setUp($loginField) myrole varchar(20));' ); - $this->db->execute('create table theirproperty ( + $executor->execute('create table theirproperty ( theirid integer primary key autoincrement, theiruserid integer, theirname varchar(45), theirvalue varchar(45));' ); - $executor = DatabaseExecutor::using($this->db); $usersRepository = new UsersRepository($executor, MyUserModel::class); $propertiesRepository = new UserPropertiesRepository($executor, MyUserPropertiesModel::class); $this->object = new UsersService( diff --git a/tools/psalm/composer.json b/tools/psalm/composer.json new file mode 100644 index 0000000..197dd5f --- /dev/null +++ b/tools/psalm/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "vimeo/psalm": "^6.16" + } +}