From 3bba005009c812ad55eb5dbcc2b9c527c2fc3b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Demonchaux?= Date: Sun, 16 Oct 2022 18:02:06 +0200 Subject: [PATCH 1/3] Drop support php 7, add php 8.2 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Demonchaux --- .laminas-ci.json | 5 +- .../install-mongodb-extension-via-pecl.sh | 14 + .laminas-ci/pre-install.sh | 19 + composer.json | 23 +- composer.lock | 556 +++++++----------- psalm-baseline.xml | 33 +- src/Config/SessionConfig.php | 5 +- src/Service/SessionManagerFactory.php | 7 +- src/Storage/Factory.php | 6 +- test/SaveHandler/CacheTest.php | 105 ++-- test/Validator/ValidatorChainTest.php | 3 +- 11 files changed, 321 insertions(+), 455 deletions(-) create mode 100755 .laminas-ci/install-mongodb-extension-via-pecl.sh create mode 100755 .laminas-ci/pre-install.sh diff --git a/.laminas-ci.json b/.laminas-ci.json index 99d05c00..96c36dfb 100644 --- a/.laminas-ci.json +++ b/.laminas-ci.json @@ -3,5 +3,8 @@ "mongodb", "mysql", "pgsql" - ] + ], + "ignore_php_platform_requirements": { + "8.2": true + } } diff --git a/.laminas-ci/install-mongodb-extension-via-pecl.sh b/.laminas-ci/install-mongodb-extension-via-pecl.sh new file mode 100755 index 00000000..cf9e2efe --- /dev/null +++ b/.laminas-ci/install-mongodb-extension-via-pecl.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +PHP_VERSION="$1" + +if ! [[ "${PHP_VERSION}" =~ 8\.2 ]]; then + echo "mongodb is only installed from pecl for PHP 8.2, ${PHP_VERSION} detected." + exit 0; +fi + +set +e + +pecl install mongodb +echo "extension=mongodb.so" > /etc/php/${PHP_VERSION}/mods-available/mongodb.ini +phpenmod -v ${PHP} -s cli mongodb diff --git a/.laminas-ci/pre-install.sh b/.laminas-ci/pre-install.sh new file mode 100755 index 00000000..41cd6234 --- /dev/null +++ b/.laminas-ci/pre-install.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +WORKING_DIRECTORY=$2 +JOB=$3 +PHP_VERSION=$(echo "${JOB}" | jq -r '.php') + + +if [ ! -z "$GITHUB_BASE_REF" ] && [[ "$GITHUB_BASE_REF" =~ ^[0-9]+\.[0-9] ]]; then + readarray -td. TARGET_BRANCH_VERSION_PARTS <<<"${GITHUB_BASE_REF}."; + unset 'TARGET_BRANCH_VERSION_PARTS[-1]'; + declare -a TARGET_BRANCH_VERSION_PARTS + MAJOR_OF_TARGET_BRANCH=${TARGET_BRANCH_VERSION_PARTS[0]} + MINOR_OF_TARGET_BRANCH=${TARGET_BRANCH_VERSION_PARTS[1]} + + export COMPOSER_ROOT_VERISON="${MAJOR_OF_TARGET_BRANCH}.${MINOR_OF_TARGET_BRANCH}.99" + echo "Exported COMPOSER_ROOT_VERISON as ${COMPOSER_ROOT_VERISON}" +fi + +${WORKING_DIRECTORY}/.laminas-ci/install-mongodb-extension-via-pecl.sh "${PHP_VERSION}" || exit 1 diff --git a/composer.json b/composer.json index cdc04d0e..569bf12c 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "config": { "sort-packages": true, "platform": { - "php": "7.4.99" + "php": "8.0.99" }, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true, @@ -32,24 +32,23 @@ } }, "require": { - "php": "^7.4 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "laminas/laminas-eventmanager": "^3.5", "laminas/laminas-servicemanager": "^3.15.1", "laminas/laminas-stdlib": "^3.10.1" }, "require-dev": { - "laminas/laminas-cache": "^3.1.3", - "laminas/laminas-cache-storage-adapter-memory": "^2.0.0", + "laminas/laminas-cache": "^3.8", + "laminas/laminas-cache-storage-adapter-memory": "^2.2", "laminas/laminas-coding-standard": "~2.4.0", - "laminas/laminas-db": "^2.13.4", - "laminas/laminas-http": "^2.15", - "laminas/laminas-validator": "^2.15", - "mongodb/mongodb": "~1.13.1", - "php-mock/php-mock-phpunit": "^1.1.2 || ^2.0", - "phpspec/prophecy-phpunit": "^2.0.1", + "laminas/laminas-db": "^2.15", + "laminas/laminas-http": "^2.17.1", + "laminas/laminas-validator": "^2.28", + "mongodb/mongodb": "~1.13.0", + "php-mock/php-mock-phpunit": "^1.1.2 || ^2.6.1", "phpunit/phpunit": "^9.5.26", - "psalm/plugin-phpunit": "^0.18.0", - "vimeo/psalm": "^4.29.0" + "psalm/plugin-phpunit": "^0.17.0", + "vimeo/psalm": "^4.30" }, "suggest": { "laminas/laminas-cache": "Laminas\\Cache component", diff --git a/composer.lock b/composer.lock index 66719657..491fe2fe 100644 --- a/composer.lock +++ b/composer.lock @@ -4,36 +4,37 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7c16715f260a049f88f645da07282ffc", + "content-hash": "b58e2bb2183f4dd2f055ac7dc5b84031", "packages": [ { "name": "laminas/laminas-eventmanager", - "version": "3.5.0", + "version": "3.6.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-eventmanager.git", - "reference": "41f7209428f37cab9573365e361f4078209aaafa" + "reference": "3f1afbad86cd34a431fdc069f265cfe6f8fc8308" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-eventmanager/zipball/41f7209428f37cab9573365e361f4078209aaafa", - "reference": "41f7209428f37cab9573365e361f4078209aaafa", + "url": "https://api.github.com/repos/laminas/laminas-eventmanager/zipball/3f1afbad86cd34a431fdc069f265cfe6f8fc8308", + "reference": "3f1afbad86cd34a431fdc069f265cfe6f8fc8308", "shasum": "" }, "require": { - "php": "^7.4 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "container-interop/container-interop": "<1.2", "zendframework/zend-eventmanager": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~2.2.1", - "laminas/laminas-stdlib": "^3.6", - "phpbench/phpbench": "^1.1", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5.5", - "psr/container": "^1.1.2 || ^2.0.2" + "laminas/laminas-coding-standard": "~2.4.0", + "laminas/laminas-stdlib": "^3.15", + "phpbench/phpbench": "^1.2.6", + "phpunit/phpunit": "^9.5.25", + "psalm/plugin-phpunit": "^0.17.0", + "psr/container": "^1.1.2 || ^2.0.2", + "vimeo/psalm": "^4.28" }, "suggest": { "laminas/laminas-stdlib": "^2.7.3 || ^3.0, to use the FilterChain feature", @@ -71,25 +72,25 @@ "type": "community_bridge" } ], - "time": "2022-04-06T21:05:17+00:00" + "time": "2022-10-11T12:46:13+00:00" }, { "name": "laminas/laminas-servicemanager", - "version": "3.17.0", + "version": "3.19.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-servicemanager.git", - "reference": "360be5f16955dd1edbcce1cfaa98ed82a17f02ec" + "reference": "ed160729bb8721127efdaac799f9a298963345b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/360be5f16955dd1edbcce1cfaa98ed82a17f02ec", - "reference": "360be5f16955dd1edbcce1cfaa98ed82a17f02ec", + "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/ed160729bb8721127efdaac799f9a298963345b1", + "reference": "ed160729bb8721127efdaac799f9a298963345b1", "shasum": "" }, "require": { "laminas/laminas-stdlib": "^3.2.1", - "php": "~7.4.0 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "psr/container": "^1.0" }, "conflict": { @@ -105,17 +106,16 @@ "container-interop/container-interop": "^1.2.0" }, "require-dev": { - "composer/package-versions-deprecated": "^1.0", + "composer/package-versions-deprecated": "^1.11.99.5", "laminas/laminas-coding-standard": "~2.4.0", "laminas/laminas-container-config-test": "^0.7", - "laminas/laminas-dependency-plugin": "^2.1.2", - "mikey179/vfsstream": "^1.6.10@alpha", - "ocramius/proxy-manager": "^2.11", - "phpbench/phpbench": "^1.1", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5.5", + "laminas/laminas-dependency-plugin": "^2.2", + "mikey179/vfsstream": "^1.6.11@alpha", + "ocramius/proxy-manager": "^2.14.1", + "phpbench/phpbench": "^1.2.6", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.8" + "vimeo/psalm": "^4.28" }, "suggest": { "ocramius/proxy-manager": "ProxyManager ^2.1.1 to handle lazy initialization of services" @@ -162,35 +162,34 @@ "type": "community_bridge" } ], - "time": "2022-09-22T11:33:46+00:00" + "time": "2022-10-10T20:59:22+00:00" }, { "name": "laminas/laminas-stdlib", - "version": "3.13.0", + "version": "3.15.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-stdlib.git", - "reference": "66a6d03c381f6c9f1dd988bf8244f9afb9380d76" + "reference": "63b66bd4b696f024f42616b9d95cdb10e5109c27" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/66a6d03c381f6c9f1dd988bf8244f9afb9380d76", - "reference": "66a6d03c381f6c9f1dd988bf8244f9afb9380d76", + "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/63b66bd4b696f024f42616b9d95cdb10e5109c27", + "reference": "63b66bd4b696f024f42616b9d95cdb10e5109c27", "shasum": "" }, "require": { - "php": "^7.4 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "zendframework/zend-stdlib": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~2.3.0", + "laminas/laminas-coding-standard": "^2.4.0", "phpbench/phpbench": "^1.2.6", - "phpstan/phpdoc-parser": "^0.5.4", - "phpunit/phpunit": "^9.5.23", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.26" + "vimeo/psalm": "^4.28" }, "type": "library", "autoload": { @@ -222,7 +221,7 @@ "type": "community_bridge" } ], - "time": "2022-08-24T13:56:50+00:00" + "time": "2022-10-10T19:10:24+00:00" }, { "name": "psr/container", @@ -1075,16 +1074,16 @@ }, { "name": "laminas/laminas-cache", - "version": "3.6.0", + "version": "3.8.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-cache.git", - "reference": "4929dea8c0d5468701fa5073cd6ef7efe5ff0043" + "reference": "b756eb5905f499695c09ab4f3a3e2bafeece8d88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-cache/zipball/4929dea8c0d5468701fa5073cd6ef7efe5ff0043", - "reference": "4929dea8c0d5468701fa5073cd6ef7efe5ff0043", + "url": "https://api.github.com/repos/laminas/laminas-cache/zipball/b756eb5905f499695c09ab4f3a3e2bafeece8d88", + "reference": "b756eb5905f499695c09ab4f3a3e2bafeece8d88", "shasum": "" }, "require": { @@ -1092,7 +1091,7 @@ "laminas/laminas-eventmanager": "^3.4", "laminas/laminas-servicemanager": "^3.11.1", "laminas/laminas-stdlib": "^3.6", - "php": "~7.4.0 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "psr/cache": "^1.0", "psr/simple-cache": "^1.0", "stella-maris/clock": "^0.1.5", @@ -1118,7 +1117,7 @@ "laminas/laminas-serializer": "^2.6.1", "phpbench/phpbench": "^1.0", "phpunit/phpunit": "^9.5.23", - "psalm/plugin-phpunit": "^0.17.0", + "psalm/plugin-phpunit": "^0.18.0", "vimeo/psalm": "^4.24" }, "suggest": { @@ -1171,25 +1170,25 @@ "type": "community_bridge" } ], - "time": "2022-09-19T21:06:59+00:00" + "time": "2022-11-08T15:24:00+00:00" }, { "name": "laminas/laminas-cache-storage-adapter-memory", - "version": "2.1.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-cache-storage-adapter-memory.git", - "reference": "92890fa5a8977418604b7a7b024503faad2c6e55" + "reference": "e002c7d3fa0d4723589b550d7ab4586befa72366" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-cache-storage-adapter-memory/zipball/92890fa5a8977418604b7a7b024503faad2c6e55", - "reference": "92890fa5a8977418604b7a7b024503faad2c6e55", + "url": "https://api.github.com/repos/laminas/laminas-cache-storage-adapter-memory/zipball/e002c7d3fa0d4723589b550d7ab4586befa72366", + "reference": "e002c7d3fa0d4723589b550d7ab4586befa72366", "shasum": "" }, "require": { "laminas/laminas-cache": "^3.0", - "php": "~7.4.0 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "laminas/laminas-servicemanager": "<3.11" @@ -1238,7 +1237,7 @@ "type": "community_bridge" } ], - "time": "2022-09-20T10:00:52+00:00" + "time": "2022-10-22T14:38:52+00:00" }, { "name": "laminas/laminas-coding-standard", @@ -1431,16 +1430,16 @@ }, { "name": "laminas/laminas-http", - "version": "2.16.1", + "version": "2.17.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-http.git", - "reference": "838825d42b03aedcb1d8b5a61ebfe28967bbfbfb" + "reference": "324e5895235fe40bfd5a4e2a0337bd7bf9a97a50" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-http/zipball/838825d42b03aedcb1d8b5a61ebfe28967bbfbfb", - "reference": "838825d42b03aedcb1d8b5a61ebfe28967bbfbfb", + "url": "https://api.github.com/repos/laminas/laminas-http/zipball/324e5895235fe40bfd5a4e2a0337bd7bf9a97a50", + "reference": "324e5895235fe40bfd5a4e2a0337bd7bf9a97a50", "shasum": "" }, "require": { @@ -1448,15 +1447,15 @@ "laminas/laminas-stdlib": "^3.6", "laminas/laminas-uri": "^2.9.1", "laminas/laminas-validator": "^2.15", - "php": "^7.3 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "zendframework/zend-http": "*" }, "require-dev": { "ext-curl": "*", - "laminas/laminas-coding-standard": "~2.2.1", - "phpunit/phpunit": "^9.5.5" + "laminas/laminas-coding-standard": "~2.4.0", + "phpunit/phpunit": "^9.5.25" }, "suggest": { "paragonie/certainty": "For automated management of cacert.pem" @@ -1492,31 +1491,31 @@ "type": "community_bridge" } ], - "time": "2022-11-11T09:12:35+00:00" + "time": "2022-11-11T09:16:23+00:00" }, { "name": "laminas/laminas-loader", - "version": "2.8.0", + "version": "2.9.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-loader.git", - "reference": "d0589ec9dd48365fd95ad10d1c906efd7711c16b" + "reference": "51ed9c3fa42d1098a9997571730c0cbf42d078d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-loader/zipball/d0589ec9dd48365fd95ad10d1c906efd7711c16b", - "reference": "d0589ec9dd48365fd95ad10d1c906efd7711c16b", + "url": "https://api.github.com/repos/laminas/laminas-loader/zipball/51ed9c3fa42d1098a9997571730c0cbf42d078d3", + "reference": "51ed9c3fa42d1098a9997571730c0cbf42d078d3", "shasum": "" }, "require": { - "php": "^7.3 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "zendframework/zend-loader": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~2.2.1", - "phpunit/phpunit": "^9.3" + "laminas/laminas-coding-standard": "~2.4.0", + "phpunit/phpunit": "~9.5.25" }, "type": "library", "autoload": { @@ -1548,33 +1547,33 @@ "type": "community_bridge" } ], - "time": "2021-09-02T18:30:53+00:00" + "time": "2022-10-16T12:50:49+00:00" }, { "name": "laminas/laminas-uri", - "version": "2.9.1", + "version": "2.10.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-uri.git", - "reference": "7e837dc15c8fd3949df7d1213246fd7c8640032b" + "reference": "663b050294945c7345cc3a61f3ca661d5f9e1f80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-uri/zipball/7e837dc15c8fd3949df7d1213246fd7c8640032b", - "reference": "7e837dc15c8fd3949df7d1213246fd7c8640032b", + "url": "https://api.github.com/repos/laminas/laminas-uri/zipball/663b050294945c7345cc3a61f3ca661d5f9e1f80", + "reference": "663b050294945c7345cc3a61f3ca661d5f9e1f80", "shasum": "" }, "require": { "laminas/laminas-escaper": "^2.9", "laminas/laminas-validator": "^2.15", - "php": "^7.3 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "zendframework/zend-uri": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~2.2.1", - "phpunit/phpunit": "^9.5.5" + "laminas/laminas-coding-standard": "~2.4.0", + "phpunit/phpunit": "^9.5.25" }, "type": "library", "autoload": { @@ -1606,26 +1605,27 @@ "type": "community_bridge" } ], - "time": "2021-09-09T18:37:15+00:00" + "time": "2022-10-16T15:02:45+00:00" }, { "name": "laminas/laminas-validator", - "version": "2.25.0", + "version": "2.28.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-validator.git", - "reference": "42de39b78e73b321db7d948cf8530a2764f8b9aa" + "reference": "695bfa40b0a83dc1c5c58bdf74a03fdbeb516c39" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/42de39b78e73b321db7d948cf8530a2764f8b9aa", - "reference": "42de39b78e73b321db7d948cf8530a2764f8b9aa", + "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/695bfa40b0a83dc1c5c58bdf74a03fdbeb516c39", + "reference": "695bfa40b0a83dc1c5c58bdf74a03fdbeb516c39", "shasum": "" }, "require": { "laminas/laminas-servicemanager": "^3.12.0", "laminas/laminas-stdlib": "^3.13", - "php": "^7.4 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", + "psr/http-message": "^1.0.1" }, "conflict": { "zendframework/zend-validator": "*" @@ -1633,18 +1633,16 @@ "require-dev": { "laminas/laminas-coding-standard": "^2.4.0", "laminas/laminas-db": "^2.15.0", - "laminas/laminas-filter": "^2.18.0", - "laminas/laminas-http": "^2.16.0", - "laminas/laminas-i18n": "^2.17.0", + "laminas/laminas-filter": "^2.23.0", + "laminas/laminas-http": "^2.17.0", + "laminas/laminas-i18n": "^2.19", "laminas/laminas-session": "^2.13.0", - "laminas/laminas-uri": "^2.9.1", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5.24", - "psalm/plugin-phpunit": "^0.17.0", - "psr/http-client": "^1.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^1.0", - "vimeo/psalm": "^4.27.0" + "laminas/laminas-uri": "^2.10.0", + "phpunit/phpunit": "^9.5.25", + "psalm/plugin-phpunit": "^0.18.0", + "psr/http-client": "^1.0.1", + "psr/http-factory": "^1.0.1", + "vimeo/psalm": "^4.28" }, "suggest": { "laminas/laminas-db": "Laminas\\Db component, required by the (No)RecordExists validator", @@ -1692,7 +1690,7 @@ "type": "community_bridge" } ], - "time": "2022-09-20T11:33:19+00:00" + "time": "2022-11-14T08:50:44+00:00" }, { "name": "mongodb/mongodb", @@ -2457,125 +2455,6 @@ }, "time": "2022-10-14T12:47:21+00:00" }, - { - "name": "phpspec/prophecy", - "version": "v1.15.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.2", - "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0", - "sebastian/recursion-context": "^3.0 || ^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^6.0 || ^7.0", - "phpunit/phpunit": "^8.0 || ^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" - }, - "time": "2021-12-08T12:19:24+00:00" - }, - { - "name": "phpspec/prophecy-phpunit", - "version": "v2.0.1", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy-phpunit.git", - "reference": "2d7a9df55f257d2cba9b1d0c0963a54960657177" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy-phpunit/zipball/2d7a9df55f257d2cba9b1d0c0963a54960657177", - "reference": "2d7a9df55f257d2cba9b1d0c0963a54960657177", - "shasum": "" - }, - "require": { - "php": "^7.3 || ^8", - "phpspec/prophecy": "^1.3", - "phpunit/phpunit": "^9.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\PhpUnit\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christophe Coevoet", - "email": "stof@notk.org" - } - ], - "description": "Integrating the Prophecy mocking library in PHPUnit test cases", - "homepage": "http://phpspec.net", - "keywords": [ - "phpunit", - "prophecy" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy-phpunit/issues", - "source": "https://github.com/phpspec/prophecy-phpunit/tree/v2.0.1" - }, - "time": "2020-07-09T08:33:42+00:00" - }, { "name": "phpstan/phpdoc-parser", "version": "1.5.1", @@ -3042,16 +2921,16 @@ }, { "name": "psalm/plugin-phpunit", - "version": "0.18.3", + "version": "0.17.0", "source": { "type": "git", "url": "https://github.com/psalm/psalm-plugin-phpunit.git", - "reference": "057c1cdf7546c1e427f6fd83b635d0cc18c252bf" + "reference": "45951541beef07e93e3ad197daf01da88e85c31d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/psalm/psalm-plugin-phpunit/zipball/057c1cdf7546c1e427f6fd83b635d0cc18c252bf", - "reference": "057c1cdf7546c1e427f6fd83b635d0cc18c252bf", + "url": "https://api.github.com/repos/psalm/psalm-plugin-phpunit/zipball/45951541beef07e93e3ad197daf01da88e85c31d", + "reference": "45951541beef07e93e3ad197daf01da88e85c31d", "shasum": "" }, "require": { @@ -3059,7 +2938,7 @@ "composer/semver": "^1.4 || ^2.0 || ^3.0", "ext-simplexml": "*", "php": "^7.1 || ^8.0", - "vimeo/psalm": "dev-master || dev-4.x || ^4.5 || ^5@beta" + "vimeo/psalm": "dev-master || dev-4.x || ^4.5" }, "conflict": { "phpunit/phpunit": "<7.5" @@ -3096,9 +2975,9 @@ "description": "Psalm plugin for PHPUnit", "support": { "issues": "https://github.com/psalm/psalm-plugin-phpunit/issues", - "source": "https://github.com/psalm/psalm-plugin-phpunit/tree/0.18.3" + "source": "https://github.com/psalm/psalm-plugin-phpunit/tree/0.17.0" }, - "time": "2022-11-03T18:17:28+00:00" + "time": "2022-06-14T17:05:57+00:00" }, { "name": "psr/cache", @@ -3149,32 +3028,85 @@ }, "time": "2016-08-06T20:24:11+00:00" }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/master" + }, + "time": "2016-08-06T14:39:51+00:00" + }, { "name": "psr/log", - "version": "1.1.4", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "3.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -3195,9 +3127,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/3.0.0" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2021-07-14T16:46:02+00:00" }, { "name": "psr/simple-cache", @@ -4380,46 +4312,42 @@ }, { "name": "symfony/console", - "version": "v5.4.15", + "version": "v6.0.15", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "ea59bb0edfaf9f28d18d8791410ee0355f317669" + "reference": "b0b910724a0a0326b4481e4f8a30abb2dd442efb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/ea59bb0edfaf9f28d18d8791410ee0355f317669", - "reference": "ea59bb0edfaf9f28d18d8791410ee0355f317669", + "url": "https://api.github.com/repos/symfony/console/zipball/b0b910724a0a0326b4481e4f8a30abb2dd442efb", + "reference": "b0b910724a0a0326b4481e4f8a30abb2dd442efb", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", + "php": ">=8.0.2", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.9", - "symfony/polyfill-php80": "^1.16", "symfony/service-contracts": "^1.1|^2|^3", - "symfony/string": "^5.1|^6.0" + "symfony/string": "^5.4|^6.0" }, "conflict": { - "psr/log": ">=3", - "symfony/dependency-injection": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/event-dispatcher": "<4.4", - "symfony/lock": "<4.4", - "symfony/process": "<4.4" + "symfony/dependency-injection": "<5.4", + "symfony/dotenv": "<5.4", + "symfony/event-dispatcher": "<5.4", + "symfony/lock": "<5.4", + "symfony/process": "<5.4" }, "provide": { - "psr/log-implementation": "1.0|2.0" + "psr/log-implementation": "1.0|2.0|3.0" }, "require-dev": { - "psr/log": "^1|^2", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/lock": "^4.4|^5.0|^6.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/var-dumper": "^4.4|^5.0|^6.0" + "psr/log": "^1|^2|^3", + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/event-dispatcher": "^5.4|^6.0", + "symfony/lock": "^5.4|^6.0", + "symfony/process": "^5.4|^6.0", + "symfony/var-dumper": "^5.4|^6.0" }, "suggest": { "psr/log": "For using the console logger", @@ -4459,7 +4387,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.15" + "source": "https://github.com/symfony/console/tree/v6.0.15" }, "funding": [ { @@ -4475,29 +4403,29 @@ "type": "tidelift" } ], - "time": "2022-10-26T21:41:52+00:00" + "time": "2022-10-26T21:42:20+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.2", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" + "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", + "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" + "dev-main": "3.0-dev" }, "thanks": { "name": "symfony/contracts", @@ -4526,7 +4454,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.2" }, "funding": [ { @@ -4542,7 +4470,7 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2022-01-02T09:55:41+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4874,85 +4802,6 @@ ], "time": "2022-11-03T14:55:06+00:00" }, - { - "name": "symfony/polyfill-php73", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9", - "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, { "name": "symfony/polyfill-php80", "version": "v1.27.0", @@ -5121,34 +4970,33 @@ }, { "name": "symfony/string", - "version": "v5.4.15", + "version": "v6.0.15", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed" + "reference": "51ac0fa0ccf132a00519b87c97e8f775fa14e771" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", - "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", + "url": "https://api.github.com/repos/symfony/string/zipball/51ac0fa0ccf132a00519b87c97e8f775fa14e771", + "reference": "51ac0fa0ccf132a00519b87c97e8f775fa14e771", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.0.2", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "~1.15" + "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/translation-contracts": ">=3.0" + "symfony/translation-contracts": "<2.0" }, "require-dev": { - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/http-client": "^4.4|^5.0|^6.0", - "symfony/translation-contracts": "^1.1|^2", - "symfony/var-exporter": "^4.4|^5.0|^6.0" + "symfony/error-handler": "^5.4|^6.0", + "symfony/http-client": "^5.4|^6.0", + "symfony/translation-contracts": "^2.0|^3.0", + "symfony/var-exporter": "^5.4|^6.0" }, "type": "library", "autoload": { @@ -5187,7 +5035,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.15" + "source": "https://github.com/symfony/string/tree/v6.0.15" }, "funding": [ { @@ -5203,7 +5051,7 @@ "type": "tidelift" } ], - "time": "2022-10-05T15:16:54+00:00" + "time": "2022-10-10T09:34:08+00:00" }, { "name": "theseer/tokenizer", @@ -5534,11 +5382,11 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.4 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "platform-dev": [], "platform-overrides": { - "php": "7.4.99" + "php": "8.0.99" }, "plugin-api-version": "2.3.0" } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index b36b80a5..7d3ad9f6 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + null === $key @@ -1121,27 +1121,9 @@ - - $args - $args - $args - $args - - - $args[1] - $args[1] - $args[1] - $data - - shouldBeCalledTimes - will - willReturn - willReturn - willReturn - assertTrue is_string($data) @@ -1149,14 +1131,11 @@ CacheAdapter - - getItem - getItem - getItem - getItem - - - $args + + $firstArgs + $firstArgs + $firstArgs + $firstArgs diff --git a/src/Config/SessionConfig.php b/src/Config/SessionConfig.php index 6bd79437..9b4f2899 100644 --- a/src/Config/SessionConfig.php +++ b/src/Config/SessionConfig.php @@ -10,7 +10,6 @@ use function array_shift; use function class_exists; use function explode; -use function get_class; use function hash_algos; use function implode; use function in_array; @@ -524,14 +523,14 @@ private function performSaveHandlerUpdate($phpSaveHandler) if (! $phpSaveHandler instanceof SessionHandlerInterface) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid save handler specified ("%s"); must implement %s', - get_class($phpSaveHandler), + $phpSaveHandler::class, SessionHandlerInterface::class )); } session_set_save_handler($phpSaveHandler); - return get_class($phpSaveHandler); + return $phpSaveHandler::class; } /** diff --git a/src/Service/SessionManagerFactory.php b/src/Service/SessionManagerFactory.php index cfc2542b..bf7f537e 100644 --- a/src/Service/SessionManagerFactory.php +++ b/src/Service/SessionManagerFactory.php @@ -17,7 +17,6 @@ use function array_merge; use function class_exists; -use function get_class; use function gettype; use function is_array; use function is_object; @@ -81,7 +80,7 @@ public function __invoke(ContainerInterface $container, $requestedName, ?array $ 'SessionManager requires that the %s service implement %s; received "%s"', ConfigInterface::class, ConfigInterface::class, - is_object($config) ? get_class($config) : gettype($config) + is_object($config) ? $config::class : gettype($config) )); } } @@ -93,7 +92,7 @@ public function __invoke(ContainerInterface $container, $requestedName, ?array $ 'SessionManager requires that the %s service implement %s; received "%s"', StorageInterface::class, StorageInterface::class, - is_object($storage) ? get_class($storage) : gettype($storage) + is_object($storage) ? $storage::class : gettype($storage) )); } } @@ -105,7 +104,7 @@ public function __invoke(ContainerInterface $container, $requestedName, ?array $ 'SessionManager requires that the %s service implement %s; received "%s"', SaveHandlerInterface::class, SaveHandlerInterface::class, - is_object($saveHandler) ? get_class($saveHandler) : gettype($saveHandler) + is_object($saveHandler) ? $saveHandler::class : gettype($saveHandler) )); } } diff --git a/src/Storage/Factory.php b/src/Storage/Factory.php index fc0459ff..48e58b0a 100644 --- a/src/Storage/Factory.php +++ b/src/Storage/Factory.php @@ -38,7 +38,7 @@ public static function factory($type, $options = []) throw new Exception\InvalidArgumentException(sprintf( '%s expects the $type argument to be a string class name; received "%s"', __METHOD__, - is_object($type) ? get_class($type) : gettype($type) + is_object($type) ? $type::class : gettype($type) )); } if (! class_exists($type)) { @@ -60,7 +60,7 @@ public static function factory($type, $options = []) throw new Exception\InvalidArgumentException(sprintf( '%s expects the $options argument to be an array or Traversable; received "%s"', __METHOD__, - is_object($options) ? get_class($options) : gettype($options) + is_object($options) ? $options::class : gettype($options) )); } @@ -145,7 +145,7 @@ protected static function createSessionArrayStorage($type, array $options) throw new Exception\InvalidArgumentException(sprintf( '%s expects the "input" option to be null, an array, or to implement ArrayAccess; received "%s"', $type, - is_object($input) ? get_class($input) : gettype($input) + is_object($input) ? $input::class : gettype($input) )); } } diff --git a/test/SaveHandler/CacheTest.php b/test/SaveHandler/CacheTest.php index e45a346d..fbc65096 100644 --- a/test/SaveHandler/CacheTest.php +++ b/test/SaveHandler/CacheTest.php @@ -7,8 +7,6 @@ use Laminas\Cache\Storage\StorageInterface; use Laminas\Session\SaveHandler\Cache; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; -use Prophecy\PhpUnit\ProphecyTrait; use function is_string; use function serialize; @@ -23,8 +21,6 @@ */ class CacheTest extends TestCase { - use ProphecyTrait; - /** @var CacheAdapter */ protected $cache; @@ -46,15 +42,19 @@ protected function setUp(): void public function testReadWrite(): void { - $cacheStorage = $this->prophesize(StorageInterface::class); - $cacheStorage->setItem('242', Argument::type('string')) - ->will( - function ($args) { - $this->getItem('242')->willReturn($args[1]); - return true; - } - ); - $this->usedSaveHandlers[] = $saveHandler = new Cache($cacheStorage->reveal()); + $cacheStorage = $this->createMock(StorageInterface::class); + $cacheStorage->expects(self::any()) + ->method('setItem') + ->with('242', self::anything()) + ->willReturnCallback(function (string $firstArgs, string $secondArgs) use ($cacheStorage) { + $cacheStorage->expects(self::any()) + ->method('getItem') + ->with('242') + ->willReturn($secondArgs); + return true; + }); + + $this->usedSaveHandlers[] = $saveHandler = new Cache($cacheStorage); $id = '242'; @@ -70,15 +70,18 @@ function ($args) { public function testReadWriteComplex(): void { - $cacheStorage = $this->prophesize(StorageInterface::class); - $cacheStorage->setItem('242', Argument::type('string')) - ->will( - function ($args) { - $this->getItem('242')->willReturn($args[1]); - return true; - } - ); - $this->usedSaveHandlers[] = $saveHandler = new Cache($cacheStorage->reveal()); + $cacheStorage = $this->createMock(StorageInterface::class); + $cacheStorage->expects(self::any()) + ->method('setItem') + ->with('242', self::anything()) + ->willReturnCallback(function (string $firstArgs, string $secondArgs) use ($cacheStorage) { + $cacheStorage->expects(self::any()) + ->method('getItem') + ->with('242') + ->willReturn($secondArgs); + return true; + }); + $this->usedSaveHandlers[] = $saveHandler = new Cache($cacheStorage); $saveHandler->open('savepath', 'sessionname'); $id = '242'; @@ -90,16 +93,19 @@ function ($args) { public function testReadWriteTwice(): void { - $cacheStorage = $this->prophesize(StorageInterface::class); - $cacheStorage->setItem('242', Argument::type('string')) - ->will( - function ($args) { - $this->getItem('242')->willReturn($args[1])->shouldBeCalledTimes(2); - return true; - } - ) - ->shouldBeCalledTimes(2); - $this->usedSaveHandlers[] = $saveHandler = new Cache($cacheStorage->reveal()); + $cacheStorage = $this->createMock(StorageInterface::class); + $cacheStorage->expects(self::exactly(2)) + ->method('setItem') + ->with('242', self::anything()) + ->willReturnCallback(function (string $firstArgs, string $secondArgs) use ($cacheStorage) { + $cacheStorage->expects(self::any()) + ->method('getItem') + ->with('242') + ->willReturn($secondArgs); + return true; + }); + + $this->usedSaveHandlers[] = $saveHandler = new Cache($cacheStorage); $id = '242'; @@ -114,9 +120,9 @@ function ($args) { public function testReadShouldAlwaysReturnString(): void { - $cacheStorage = $this->prophesize(StorageInterface::class); - $cacheStorage->getItem('242')->willReturn(null); - $this->usedSaveHandlers[] = $saveHandler = new Cache($cacheStorage->reveal()); + $cacheStorage = $this->createMock(StorageInterface::class); + $cacheStorage->expects(self::any())->method('getItem')->willReturn(null); + $this->usedSaveHandlers[] = $saveHandler = new Cache($cacheStorage); $id = '242'; @@ -127,8 +133,8 @@ public function testReadShouldAlwaysReturnString(): void public function testDestroyReturnsTrueEvenWhenSessionDoesNotExist(): void { - $cacheStorage = $this->prophesize(StorageInterface::class); - $this->usedSaveHandlers[] = $saveHandler = new Cache($cacheStorage->reveal()); + $cacheStorage = $this->createMock(StorageInterface::class); + $this->usedSaveHandlers[] = $saveHandler = new Cache($cacheStorage); $id = '242'; @@ -139,18 +145,19 @@ public function testDestroyReturnsTrueEvenWhenSessionDoesNotExist(): void public function testDestroyReturnsTrueWhenSessionIsDeleted(): void { - $cacheStorage = $this->prophesize(StorageInterface::class); - $cacheStorage->setItem('242', Argument::type('string')) - ->will( - function ($args) { - $this->getItem('242', Argument::any()) - ->will( - fn($args) => $args[1] - ); - return true; - } - ); - $this->usedSaveHandlers[] = $saveHandler = new Cache($cacheStorage->reveal()); + $cacheStorage = $this->createMock(StorageInterface::class); + $cacheStorage->expects(self::any()) + ->method('setItem') + ->with('242', self::anything()) + ->willReturnCallback(function (string $firstArgs, string $secondArgs) use ($cacheStorage) { + $cacheStorage->expects(self::any()) + ->method('getItem') + ->with('242') + ->willReturn($secondArgs); + return true; + }); + + $this->usedSaveHandlers[] = $saveHandler = new Cache($cacheStorage); $id = '242'; diff --git a/test/Validator/ValidatorChainTest.php b/test/Validator/ValidatorChainTest.php index 76508bee..d6f86fb8 100644 --- a/test/Validator/ValidatorChainTest.php +++ b/test/Validator/ValidatorChainTest.php @@ -11,7 +11,6 @@ use PHPUnit\Framework\TestCase; use function assert; -use function get_class; use function property_exists; class ValidatorChainTest extends TestCase @@ -45,7 +44,7 @@ public function testExistingValidatorsAreAttached(): void { $validator = $this->createValidatorSpy(); $storage = new ArrayStorage(); - $storage->setMetadata('_VALID', [get_class($validator) => $validator->getData()]); + $storage->setMetadata('_VALID', [$validator::class => $validator->getData()]); $this->validatorChain = new ValidatorChain($storage); From 58484a3afb54dbee8901780ea59b9b3a5e64e3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Demonchaux?= Date: Tue, 15 Nov 2022 09:56:10 +0100 Subject: [PATCH 2/3] code review --- composer.json | 1 - composer.lock | 201 +-------------------------------- test/SaveHandler/CacheTest.php | 8 +- 3 files changed, 5 insertions(+), 205 deletions(-) diff --git a/composer.json b/composer.json index 569bf12c..b7f99734 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,6 @@ "laminas/laminas-http": "^2.17.1", "laminas/laminas-validator": "^2.28", "mongodb/mongodb": "~1.13.0", - "php-mock/php-mock-phpunit": "^1.1.2 || ^2.6.1", "phpunit/phpunit": "^9.5.26", "psalm/plugin-phpunit": "^0.17.0", "vimeo/psalm": "^4.30" diff --git a/composer.lock b/composer.lock index 491fe2fe..70e043cc 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": "b58e2bb2183f4dd2f055ac7dc5b84031", + "content-hash": "4a8df1997fbcca256766004e22da83e2", "packages": [ { "name": "laminas/laminas-eventmanager", @@ -2091,205 +2091,6 @@ }, "time": "2022-02-21T01:04:05+00:00" }, - { - "name": "php-mock/php-mock", - "version": "2.3.1", - "source": { - "type": "git", - "url": "https://github.com/php-mock/php-mock.git", - "reference": "9a55bd8ba40e6da2e97a866121d2c69dedd4952b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-mock/php-mock/zipball/9a55bd8ba40e6da2e97a866121d2c69dedd4952b", - "reference": "9a55bd8ba40e6da2e97a866121d2c69dedd4952b", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0 || ^8.0", - "phpunit/php-text-template": "^1 || ^2" - }, - "replace": { - "malkusch/php-mock": "*" - }, - "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.0 || ^9.0", - "squizlabs/php_codesniffer": "^3.5" - }, - "suggest": { - "php-mock/php-mock-phpunit": "Allows integration into PHPUnit testcase with the trait PHPMock." - }, - "type": "library", - "autoload": { - "files": [ - "autoload.php" - ], - "psr-4": { - "phpmock\\": [ - "classes/", - "tests/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "WTFPL" - ], - "authors": [ - { - "name": "Markus Malkusch", - "email": "markus@malkusch.de", - "homepage": "http://markus.malkusch.de", - "role": "Developer" - } - ], - "description": "PHP-Mock can mock built-in PHP functions (e.g. time()). PHP-Mock relies on PHP's namespace fallback policy. No further extension is needed.", - "homepage": "https://github.com/php-mock/php-mock", - "keywords": [ - "BDD", - "TDD", - "function", - "mock", - "stub", - "test", - "test double" - ], - "support": { - "issues": "https://github.com/php-mock/php-mock/issues", - "source": "https://github.com/php-mock/php-mock/tree/2.3.1" - }, - "funding": [ - { - "url": "https://github.com/michalbundyra", - "type": "github" - } - ], - "time": "2022-02-07T18:57:52+00:00" - }, - { - "name": "php-mock/php-mock-integration", - "version": "2.1.0", - "source": { - "type": "git", - "url": "https://github.com/php-mock/php-mock-integration.git", - "reference": "003d585841e435958a02e9b986953907b8b7609b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-mock/php-mock-integration/zipball/003d585841e435958a02e9b986953907b8b7609b", - "reference": "003d585841e435958a02e9b986953907b8b7609b", - "shasum": "" - }, - "require": { - "php": ">=5.6", - "php-mock/php-mock": "^2.2", - "phpunit/php-text-template": "^1 || ^2" - }, - "require-dev": { - "phpunit/phpunit": "^5.7.27 || ^6 || ^7 || ^8 || ^9" - }, - "type": "library", - "autoload": { - "psr-4": { - "phpmock\\integration\\": "classes/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "WTFPL" - ], - "authors": [ - { - "name": "Markus Malkusch", - "email": "markus@malkusch.de", - "homepage": "http://markus.malkusch.de", - "role": "Developer" - } - ], - "description": "Integration package for PHP-Mock", - "homepage": "https://github.com/php-mock/php-mock-integration", - "keywords": [ - "BDD", - "TDD", - "function", - "mock", - "stub", - "test", - "test double" - ], - "support": { - "issues": "https://github.com/php-mock/php-mock-integration/issues", - "source": "https://github.com/php-mock/php-mock-integration/tree/2.1.0" - }, - "time": "2020-02-08T14:40:25+00:00" - }, - { - "name": "php-mock/php-mock-phpunit", - "version": "2.6.1", - "source": { - "type": "git", - "url": "https://github.com/php-mock/php-mock-phpunit.git", - "reference": "b9ba2db21e7e1c7deba98bc86dcfc6425fb4647d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-mock/php-mock-phpunit/zipball/b9ba2db21e7e1c7deba98bc86dcfc6425fb4647d", - "reference": "b9ba2db21e7e1c7deba98bc86dcfc6425fb4647d", - "shasum": "" - }, - "require": { - "php": ">=7", - "php-mock/php-mock-integration": "^2.1", - "phpunit/phpunit": "^6 || ^7 || ^8 || ^9" - }, - "require-dev": { - "phpspec/prophecy": "^1.10.3" - }, - "type": "library", - "autoload": { - "files": [ - "autoload.php" - ], - "psr-4": { - "phpmock\\phpunit\\": "classes/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "WTFPL" - ], - "authors": [ - { - "name": "Markus Malkusch", - "email": "markus@malkusch.de", - "homepage": "http://markus.malkusch.de", - "role": "Developer" - } - ], - "description": "Mock built-in PHP functions (e.g. time()) with PHPUnit. This package relies on PHP's namespace fallback policy. No further extension is needed.", - "homepage": "https://github.com/php-mock/php-mock-phpunit", - "keywords": [ - "BDD", - "TDD", - "function", - "mock", - "phpunit", - "stub", - "test", - "test double" - ], - "support": { - "issues": "https://github.com/php-mock/php-mock-phpunit/issues", - "source": "https://github.com/php-mock/php-mock-phpunit/tree/2.6.1" - }, - "funding": [ - { - "url": "https://github.com/michalbundyra", - "type": "github" - } - ], - "time": "2022-09-07T20:40:07+00:00" - }, { "name": "phpdocumentor/reflection-common", "version": "2.2.0", diff --git a/test/SaveHandler/CacheTest.php b/test/SaveHandler/CacheTest.php index fbc65096..1b1cb8bd 100644 --- a/test/SaveHandler/CacheTest.php +++ b/test/SaveHandler/CacheTest.php @@ -46,7 +46,7 @@ public function testReadWrite(): void $cacheStorage->expects(self::any()) ->method('setItem') ->with('242', self::anything()) - ->willReturnCallback(function (string $firstArgs, string $secondArgs) use ($cacheStorage) { + ->willReturnCallback(function (string $firstArgs, string $secondArgs) use ($cacheStorage): bool { $cacheStorage->expects(self::any()) ->method('getItem') ->with('242') @@ -74,7 +74,7 @@ public function testReadWriteComplex(): void $cacheStorage->expects(self::any()) ->method('setItem') ->with('242', self::anything()) - ->willReturnCallback(function (string $firstArgs, string $secondArgs) use ($cacheStorage) { + ->willReturnCallback(function (string $firstArgs, string $secondArgs) use ($cacheStorage): bool { $cacheStorage->expects(self::any()) ->method('getItem') ->with('242') @@ -97,7 +97,7 @@ public function testReadWriteTwice(): void $cacheStorage->expects(self::exactly(2)) ->method('setItem') ->with('242', self::anything()) - ->willReturnCallback(function (string $firstArgs, string $secondArgs) use ($cacheStorage) { + ->willReturnCallback(function (string $firstArgs, string $secondArgs) use ($cacheStorage): bool { $cacheStorage->expects(self::any()) ->method('getItem') ->with('242') @@ -149,7 +149,7 @@ public function testDestroyReturnsTrueWhenSessionIsDeleted(): void $cacheStorage->expects(self::any()) ->method('setItem') ->with('242', self::anything()) - ->willReturnCallback(function (string $firstArgs, string $secondArgs) use ($cacheStorage) { + ->willReturnCallback(function (string $firstArgs, string $secondArgs) use ($cacheStorage): bool { $cacheStorage->expects(self::any()) ->method('getItem') ->with('242') From a21c83d23268f4a401cd5cfbaecd15eec4e74b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Demonchaux?= Date: Tue, 15 Nov 2022 09:57:50 +0100 Subject: [PATCH 3/3] code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Demonchaux --- test/Config/SessionConfigTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/Config/SessionConfigTest.php b/test/Config/SessionConfigTest.php index 11da03c0..5331a3c9 100644 --- a/test/Config/SessionConfigTest.php +++ b/test/Config/SessionConfigTest.php @@ -6,7 +6,6 @@ use Laminas\Session\Exception; use Laminas\Session\Exception\InvalidArgumentException; use LaminasTest\Session\TestAsset\TestSaveHandler; -use phpmock\phpunit\PHPMock; use PHPUnit\Framework\TestCase; use ReflectionProperty; use SessionHandlerInterface; @@ -25,8 +24,6 @@ */ class SessionConfigTest extends TestCase { - use PHPMock; - /** @var SessionConfig */ protected $config;