From 4a96b17bc3c62d7dcfe3efaf2209d8b91aaa0027 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 24 Nov 2025 10:29:37 +0300 Subject: [PATCH 1/4] PHP 8.5 support --- .github/workflows/build.yml | 2 +- .github/workflows/composer-require-checker.yml | 2 +- .github/workflows/mutation.yml | 5 +++-- .github/workflows/rector.yml | 2 +- CHANGELOG.md | 1 + README.md | 2 +- composer.json | 10 ++++------ tools/.gitignore | 2 ++ tools/infection/composer.json | 10 ++++++++++ tools/psalm/composer.json | 5 +++++ 10 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 tools/.gitignore create mode 100644 tools/infection/composer.json create mode 100644 tools/psalm/composer.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3584e6c..1b1e2d8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,4 +31,4 @@ jobs: os: >- ['ubuntu-latest', 'windows-latest'] php: >- - ['8.1', '8.2', '8.3', '8.4'] + ['8.1', '8.2', '8.3', '8.4', '8.5'] diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index a93390b..d2ef508 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -31,4 +31,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.1', '8.2', '8.3', '8.4'] + ['8.1', '8.2', '8.3', '8.4', '8.5'] diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index a6873e2..cc40daa 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -22,11 +22,12 @@ name: mutation test jobs: mutation: - uses: yiisoft/actions/.github/workflows/roave-infection.yml@master + uses: yiisoft/actions/.github/workflows/infection.yml@master with: os: >- ['ubuntu-latest'] php: >- - ['8.3'] + ['8.5'] + infection-args: "--ignore-msi-with-no-mutations" secrets: STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 5d6931d..20f7d89 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -21,4 +21,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.4'] + ['8.5'] diff --git a/CHANGELOG.md b/CHANGELOG.md index b616dc9..fd3c740 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.1.1 under development - New #64: Add `PasswordHasher::needsRehash()` method (@Gerych1984) +- Enh #69: Add PHP 8.5 support (@vjik) ## 1.1.0 February 26, 2025 diff --git a/README.md b/README.md index 2d712a9..eb32a42 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Security package provides a set of classes to handle common security-related tas ## Requirements -- PHP 8.1 or higher. +- PHP 8.1 - 8.5. - `hash` PHP extension. - `openssl` PHP extension. diff --git a/composer.json b/composer.json index 28eeea5..c4a7c10 100644 --- a/composer.json +++ b/composer.json @@ -34,18 +34,17 @@ } ], "require": { - "php": "8.1 - 8.4", + "php": "8.1 - 8.5", "ext-hash": "*", "ext-openssl": "*", "yiisoft/strings": "^2.0" }, "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", "maglnet/composer-require-checker": "^4.7.1", "phpunit/phpunit": "^10.5.45", "rector/rector": "^2.0.9", - "roave/infection-static-analysis-plugin": "^1.35", - "spatie/phpunit-watcher": "^1.24", - "vimeo/psalm": "^5.26.1 || ^6.8.8" + "spatie/phpunit-watcher": "^1.24" }, "autoload": { "psr-4": { @@ -63,9 +62,8 @@ }, "config": { "sort-packages": true, - "bump-after-update": "dev", "allow-plugins": { - "infection/extension-installer": true, + "bamarni/composer-bin-plugin": true, "composer/package-versions-deprecated": true } } diff --git a/tools/.gitignore b/tools/.gitignore new file mode 100644 index 0000000..cf452dc --- /dev/null +++ b/tools/.gitignore @@ -0,0 +1,2 @@ +/*/vendor +/*/composer.lock diff --git a/tools/infection/composer.json b/tools/infection/composer.json new file mode 100644 index 0000000..18be2ea --- /dev/null +++ b/tools/infection/composer.json @@ -0,0 +1,10 @@ +{ + "require-dev": { + "infection/infection": "^0.26 || ^0.31.9" + }, + "config": { + "allow-plugins": { + "infection/extension-installer": true + } + } +} diff --git a/tools/psalm/composer.json b/tools/psalm/composer.json new file mode 100644 index 0000000..44e11e3 --- /dev/null +++ b/tools/psalm/composer.json @@ -0,0 +1,5 @@ +{ + "require-dev": { + "vimeo/psalm": "^5.26.1 || ^6.8.8" + } +} From 6f5f693c5e692b09ebd4fb405db1bd1abf4c166e Mon Sep 17 00:00:00 2001 From: vjik <525501+vjik@users.noreply.github.com> Date: Mon, 24 Nov 2025 07:30:22 +0000 Subject: [PATCH 2/4] Apply Rector changes (CI) --- tests/TestCase.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 872d16c..f94d330 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -21,10 +21,8 @@ protected function invokeMethod($object, $method, array $args = [], bool $revoke { $reflection = new \ReflectionObject($object); $method = $reflection->getMethod($method); - $method->setAccessible(true); $result = $method->invokeArgs($object, $args); if ($revoke) { - $method->setAccessible(false); } return $result; @@ -47,10 +45,8 @@ protected function setInaccessibleProperty($object, $propertyName, $value, bool $class = $class->getParentClass(); } $property = $class->getProperty($propertyName); - $property->setAccessible(true); $property->setValue($object, $value); if ($revoke) { - $property->setAccessible(false); } } @@ -73,11 +69,9 @@ protected function getInaccessibleProperty($object, string $propertyName, bool $ } $property = $class->getProperty($propertyName); - $property->setAccessible(true); $result = $property->getValue($object); if ($revoke) { - $property->setAccessible(false); } return $result; From f54d8dc4c0ee7f21060c9b7a57da60d32a1e13af Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 24 Nov 2025 10:31:23 +0300 Subject: [PATCH 3/4] fix --- composer.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/composer.json b/composer.json index c4a7c10..dcd8410 100644 --- a/composer.json +++ b/composer.json @@ -56,6 +56,13 @@ "Yiisoft\\Security\\Tests\\": "tests" } }, + "extra": { + "bamarni-bin": { + "bin-links": true, + "target-directory": "tools", + "forward-command": true + } + }, "scripts": { "test": "phpunit --testdox --no-interaction", "test-watch": "phpunit-watcher watch" From 8d1f8014006c636e6a278d9af50a4c216b602aa2 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 24 Nov 2025 10:36:59 +0300 Subject: [PATCH 4/4] Cleanup test --- tests/TestCase.php | 89 +++------------------------------------------- 1 file changed, 5 insertions(+), 84 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index f94d330..0aef408 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -4,102 +4,23 @@ namespace Yiisoft\Security\Tests; +use ReflectionClass; + abstract class TestCase extends \PHPUnit\Framework\TestCase { - /** - * Invokes a inaccessible method. - * - * @param $object - * @param $method - * @param bool $revoke whether to make method inaccessible after execution - * - * @throws \ReflectionException - * - * @return mixed - */ - protected function invokeMethod($object, $method, array $args = [], bool $revoke = true) - { - $reflection = new \ReflectionObject($object); - $method = $reflection->getMethod($method); - $result = $method->invokeArgs($object, $args); - if ($revoke) { - } - - return $result; - } - - /** - * Sets an inaccessible object property to a designated value. - * - * @param $object - * @param $propertyName - * @param $value - * @param bool $revoke whether to make property inaccessible after setting - * - * @throws \ReflectionException - */ - protected function setInaccessibleProperty($object, $propertyName, $value, bool $revoke = true): void - { - $class = new \ReflectionClass($object); - while (!$class->hasProperty($propertyName)) { - $class = $class->getParentClass(); - } - $property = $class->getProperty($propertyName); - $property->setValue($object, $value); - if ($revoke) { - } - } - /** * Gets an inaccessible object property. * - * @param $object * @param bool $revoke whether to make property inaccessible after getting - * - * @throws \ReflectionException - * - * @return mixed */ - protected function getInaccessibleProperty($object, string $propertyName, bool $revoke = true) + protected function getInaccessibleProperty(object $object, string $propertyName): mixed { - $class = new \ReflectionClass($object); + $class = new ReflectionClass($object); while (!$class->hasProperty($propertyName)) { $class = $class->getParentClass(); } - $property = $class->getProperty($propertyName); - - $result = $property->getValue($object); - if ($revoke) { - } - - return $result; - } - - public function assertSameExceptObject($expected, $actual): void - { - // assert for all types - $this->assertEquals($expected, $actual); - - // no more asserts for objects - if (is_object($expected)) { - return; - } - - // asserts same for all types except objects and arrays that can contain objects - if (!is_array($expected)) { - $this->assertSame($expected, $actual); - return; - } - - // assert same for each element of the array except objects - foreach ($expected as $key => $value) { - if (!is_object($value)) { - $this->assertSame($expected[$key], $actual[$key]); - } else { - $this->assertEquals($expected[$key], $actual[$key]); - } - } + return $class->getProperty($propertyName)->getValue($object); } }