From eaa7150311cbabeb0e2f6f78a352279a0c426c0b Mon Sep 17 00:00:00 2001 From: George Steel Date: Fri, 14 Oct 2022 11:42:18 +0100 Subject: [PATCH 1/6] Add support for PHP 8.2, remove support for PHP 7.4 Signed-off-by: George Steel --- composer.json | 16 +-- composer.lock | 345 +++++++++++++++++++------------------------------- 2 files changed, 135 insertions(+), 226 deletions(-) diff --git a/composer.json b/composer.json index 5fa4fabd..d3c7ed1a 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "dealerdirect/phpcodesniffer-composer-installer": true }, "platform": { - "php": "7.4.99" + "php": "8.0.99" } }, "extra": { @@ -31,20 +31,20 @@ } }, "require": { - "php": "^7.4 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "laminas/laminas-stdlib": "^3.3", "webmozart/assert": "^1.10" }, "require-dev": { "laminas/laminas-coding-standard": "~2.4.0", - "laminas/laminas-eventmanager": "^3.5.0", - "laminas/laminas-modulemanager": "^2.11.0", + "laminas/laminas-eventmanager": "^3.6", + "laminas/laminas-modulemanager": "^2.12", "laminas/laminas-serializer": "^2.13.0", - "laminas/laminas-servicemanager": "^3.14.0", - "phpbench/phpbench": "^1.2.5", - "phpunit/phpunit": "~9.5.21", + "laminas/laminas-servicemanager": "^3.19", + "phpbench/phpbench": "^1.2.6", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.24.0" + "vimeo/psalm": "^4.29" }, "suggest": { "laminas/laminas-eventmanager": "^3.2, to support aggregate hydrator usage", diff --git a/composer.lock b/composer.lock index b560f590..593df3ed 100644 --- a/composer.lock +++ b/composer.lock @@ -4,35 +4,34 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3afc506718e0708403c332ada7b02654", + "content-hash": "df7c98123692f1fbd7719e92bcf6438d", "packages": [ { "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": { @@ -64,7 +63,7 @@ "type": "community_bridge" } ], - "time": "2022-08-24T13:56:50+00:00" + "time": "2022-10-10T19:10:24+00:00" }, { "name": "webmozart/assert", @@ -1190,32 +1189,33 @@ }, { "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", @@ -1253,7 +1253,7 @@ "type": "community_bridge" } ], - "time": "2022-04-06T21:05:17+00:00" + "time": "2022-10-11T12:46:13+00:00" }, { "name": "laminas/laminas-json", @@ -1460,21 +1460,21 @@ }, { "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": { @@ -1490,17 +1490,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" @@ -1547,7 +1546,7 @@ "type": "community_bridge" } ], - "time": "2022-09-22T11:33:46+00:00" + "time": "2022-10-10T20:59:22+00:00" }, { "name": "myclabs/deep-copy", @@ -2755,20 +2754,20 @@ }, { "name": "psr/cache", - "version": "1.0.1", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/cache.git", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { @@ -2788,7 +2787,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for caching libraries", @@ -2798,9 +2797,9 @@ "psr-6" ], "support": { - "source": "https://github.com/php-fig/cache/tree/master" + "source": "https://github.com/php-fig/cache/tree/3.0.0" }, - "time": "2016-08-06T20:24:11+00:00" + "time": "2021-02-03T23:26:27+00:00" }, { "name": "psr/container", @@ -2852,30 +2851,30 @@ }, { "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/", @@ -2896,9 +2895,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": "sebastian/cli-parser", @@ -4047,46 +4046,42 @@ }, { "name": "symfony/console", - "version": "v5.4.14", + "version": "v6.0.14", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "984ea2c0f45f42dfed01d2f3987b187467c4b16d" + "reference": "1f89cab8d52c84424f798495b3f10342a7b1a070" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/984ea2c0f45f42dfed01d2f3987b187467c4b16d", - "reference": "984ea2c0f45f42dfed01d2f3987b187467c4b16d", + "url": "https://api.github.com/repos/symfony/console/zipball/1f89cab8d52c84424f798495b3f10342a7b1a070", + "reference": "1f89cab8d52c84424f798495b3f10342a7b1a070", "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", @@ -4126,7 +4121,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.14" + "source": "https://github.com/symfony/console/tree/v6.0.14" }, "funding": [ { @@ -4142,29 +4137,29 @@ "type": "tidelift" } ], - "time": "2022-10-07T08:01:20+00:00" + "time": "2022-10-07T08:02:12+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", @@ -4193,7 +4188,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": [ { @@ -4209,27 +4204,26 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2022-01-02T09:55:41+00:00" }, { "name": "symfony/filesystem", - "version": "v5.4.13", + "version": "v6.0.13", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "ac09569844a9109a5966b9438fc29113ce77cf51" + "reference": "3adca49133bd055ebe6011ed1e012be3c908af79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/ac09569844a9109a5966b9438fc29113ce77cf51", - "reference": "ac09569844a9109a5966b9438fc29113ce77cf51", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/3adca49133bd055ebe6011ed1e012be3c908af79", + "reference": "3adca49133bd055ebe6011ed1e012be3c908af79", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.0.2", "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8", - "symfony/polyfill-php80": "^1.16" + "symfony/polyfill-mbstring": "~1.8" }, "type": "library", "autoload": { @@ -4257,7 +4251,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.4.13" + "source": "https://github.com/symfony/filesystem/tree/v6.0.13" }, "funding": [ { @@ -4273,26 +4267,24 @@ "type": "tidelift" } ], - "time": "2022-09-21T19:53:16+00:00" + "time": "2022-09-21T20:25:27+00:00" }, { "name": "symfony/finder", - "version": "v5.4.11", + "version": "v6.0.11", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "7872a66f57caffa2916a584db1aa7f12adc76f8c" + "reference": "09cb683ba5720385ea6966e5e06be2a34f2568b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/7872a66f57caffa2916a584db1aa7f12adc76f8c", - "reference": "7872a66f57caffa2916a584db1aa7f12adc76f8c", + "url": "https://api.github.com/repos/symfony/finder/zipball/09cb683ba5720385ea6966e5e06be2a34f2568b1", + "reference": "09cb683ba5720385ea6966e5e06be2a34f2568b1", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.0.2" }, "type": "library", "autoload": { @@ -4320,7 +4312,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.11" + "source": "https://github.com/symfony/finder/tree/v6.0.11" }, "funding": [ { @@ -4336,27 +4328,25 @@ "type": "tidelift" } ], - "time": "2022-07-29T07:37:50+00:00" + "time": "2022-07-29T07:39:48+00:00" }, { "name": "symfony/options-resolver", - "version": "v5.4.11", + "version": "v6.0.3", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "54f14e36aa73cb8f7261d7686691fd4d75ea2690" + "reference": "51f7006670febe4cbcbae177cbffe93ff833250d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/54f14e36aa73cb8f7261d7686691fd4d75ea2690", - "reference": "54f14e36aa73cb8f7261d7686691fd4d75ea2690", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/51f7006670febe4cbcbae177cbffe93ff833250d", + "reference": "51f7006670febe4cbcbae177cbffe93ff833250d", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php73": "~1.0", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.0.2", + "symfony/deprecation-contracts": "^2.1|^3" }, "type": "library", "autoload": { @@ -4389,7 +4379,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v5.4.11" + "source": "https://github.com/symfony/options-resolver/tree/v6.0.3" }, "funding": [ { @@ -4405,7 +4395,7 @@ "type": "tidelift" } ], - "time": "2022-07-20T13:00:38+00:00" + "time": "2022-01-02T09:55:41+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4737,85 +4727,6 @@ ], "time": "2022-05-24T11:49:31+00:00" }, - { - "name": "symfony/polyfill-php73", - "version": "v1.26.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85", - "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.26-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.26.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-05-24T11:49:31+00:00" - }, { "name": "symfony/polyfill-php80", "version": "v1.26.0", @@ -4901,21 +4812,20 @@ }, { "name": "symfony/process", - "version": "v5.4.11", + "version": "v6.0.11", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "6e75fe6874cbc7e4773d049616ab450eff537bf1" + "reference": "44270a08ccb664143dede554ff1c00aaa2247a43" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/6e75fe6874cbc7e4773d049616ab450eff537bf1", - "reference": "6e75fe6874cbc7e4773d049616ab450eff537bf1", + "url": "https://api.github.com/repos/symfony/process/zipball/44270a08ccb664143dede554ff1c00aaa2247a43", + "reference": "44270a08ccb664143dede554ff1c00aaa2247a43", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.0.2" }, "type": "library", "autoload": { @@ -4943,7 +4853,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.11" + "source": "https://github.com/symfony/process/tree/v6.0.11" }, "funding": [ { @@ -4959,7 +4869,7 @@ "type": "tidelift" } ], - "time": "2022-06-27T16:58:25+00:00" + "time": "2022-06-27T17:10:44+00:00" }, { "name": "symfony/service-contracts", @@ -5046,34 +4956,33 @@ }, { "name": "symfony/string", - "version": "v5.4.14", + "version": "v6.0.14", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "089e7237497fae7a9c404d0c3aeb8db3254733e4" + "reference": "3db7da820a6e4a584b714b3933c34c6a7db4d86c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/089e7237497fae7a9c404d0c3aeb8db3254733e4", - "reference": "089e7237497fae7a9c404d0c3aeb8db3254733e4", + "url": "https://api.github.com/repos/symfony/string/zipball/3db7da820a6e4a584b714b3933c34c6a7db4d86c", + "reference": "3db7da820a6e4a584b714b3933c34c6a7db4d86c", "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": { @@ -5112,7 +5021,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.14" + "source": "https://github.com/symfony/string/tree/v6.0.14" }, "funding": [ { @@ -5128,7 +5037,7 @@ "type": "tidelift" } ], - "time": "2022-10-05T15:16:54+00:00" + "time": "2022-10-10T09:34:08+00:00" }, { "name": "theseer/tokenizer", @@ -5460,11 +5369,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" } From 919c27deddcc02a1552d64c016c7985c79608ebb Mon Sep 17 00:00:00 2001 From: George Steel Date: Fri, 14 Oct 2022 11:53:22 +0100 Subject: [PATCH 2/6] Solve dynamic property deprecations Signed-off-by: George Steel --- test/ClassMethodsHydratorTest.php | 1 - test/Filter/FilterCompositeTest.php | 7 ++++--- test/StandaloneHydratorPluginManagerFactoryTest.php | 5 +++++ test/StandaloneHydratorPluginManagerTest.php | 2 ++ test/TestAsset/HydratorClosureStrategyEntity.php | 3 +++ test/TestAsset/ObjectProperty.php | 3 +++ 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/test/ClassMethodsHydratorTest.php b/test/ClassMethodsHydratorTest.php index aa8373af..abb88e58 100644 --- a/test/ClassMethodsHydratorTest.php +++ b/test/ClassMethodsHydratorTest.php @@ -78,7 +78,6 @@ public function testCanHydratedPromiscuousInstances(): void public function testSetOptionsThrowsException(): void { $this->expectException(TypeError::class); - $this->expectExceptionMessage('iterable'); $this->hydrator->setOptions('invalid options'); } diff --git a/test/Filter/FilterCompositeTest.php b/test/Filter/FilterCompositeTest.php index 6b5ca51f..33dc6a12 100644 --- a/test/Filter/FilterCompositeTest.php +++ b/test/Filter/FilterCompositeTest.php @@ -119,15 +119,16 @@ private function buildFilters(array $values): array foreach ($values as $value) { $filters[] = new class ($value) implements FilterInterface { - /** @param mixed $value */ - public function __construct($value) + public mixed $value; + + public function __construct(mixed $value) { $this->value = $value; } public function filter(string $property, ?object $instance = null): bool { - return $this->value; + return (bool) $this->value; } }; } diff --git a/test/StandaloneHydratorPluginManagerFactoryTest.php b/test/StandaloneHydratorPluginManagerFactoryTest.php index bcdb4fab..2deb58a9 100644 --- a/test/StandaloneHydratorPluginManagerFactoryTest.php +++ b/test/StandaloneHydratorPluginManagerFactoryTest.php @@ -15,6 +15,7 @@ use Laminas\Hydrator\ReflectionHydrator; use Laminas\Hydrator\StandaloneHydratorPluginManager; use Laminas\Hydrator\StandaloneHydratorPluginManagerFactory; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; @@ -24,6 +25,10 @@ class StandaloneHydratorPluginManagerFactoryTest extends TestCase { private const MESSAGE_DEFAULT_SERVICES = 'Missing the service %s'; + private StandaloneHydratorPluginManagerFactory $factory; + /** @var ContainerInterface&MockObject */ + private ContainerInterface|MockObject $container; + protected function setUp(): void { $this->factory = new StandaloneHydratorPluginManagerFactory(); diff --git a/test/StandaloneHydratorPluginManagerTest.php b/test/StandaloneHydratorPluginManagerTest.php index 8844f9b1..ba707a55 100644 --- a/test/StandaloneHydratorPluginManagerTest.php +++ b/test/StandaloneHydratorPluginManagerTest.php @@ -15,6 +15,8 @@ class StandaloneHydratorPluginManagerTest extends TestCase { + private StandaloneHydratorPluginManager $manager; + protected function setUp(): void { $this->manager = new StandaloneHydratorPluginManager(); diff --git a/test/TestAsset/HydratorClosureStrategyEntity.php b/test/TestAsset/HydratorClosureStrategyEntity.php index fef4ac48..71e62285 100644 --- a/test/TestAsset/HydratorClosureStrategyEntity.php +++ b/test/TestAsset/HydratorClosureStrategyEntity.php @@ -4,6 +4,9 @@ namespace LaminasTest\Hydrator\TestAsset; +use AllowDynamicProperties; + +#[AllowDynamicProperties] class HydratorClosureStrategyEntity { /** @var mixed */ diff --git a/test/TestAsset/ObjectProperty.php b/test/TestAsset/ObjectProperty.php index cb606e1b..601d419f 100644 --- a/test/TestAsset/ObjectProperty.php +++ b/test/TestAsset/ObjectProperty.php @@ -4,6 +4,9 @@ namespace LaminasTest\Hydrator\TestAsset; +use AllowDynamicProperties; + +#[AllowDynamicProperties] class ObjectProperty { /** @var string */ From 667fce6cdc07b9317e3d5c0e4e8e35afb1b2abdf Mon Sep 17 00:00:00 2001 From: George Steel Date: Fri, 14 Oct 2022 11:54:30 +0100 Subject: [PATCH 3/6] Use modern class reference syntax instead of `get_class()` Signed-off-by: George Steel --- src/ClassMethodsHydrator.php | 7 +++---- src/DelegatingHydrator.php | 4 +--- src/HydratorPluginManager.php | 3 +-- src/ObjectPropertyHydrator.php | 3 +-- src/ReflectionHydrator.php | 4 +--- src/Strategy/BooleanStrategy.php | 9 ++++----- src/Strategy/CollectionStrategy.php | 7 +++---- src/Strategy/DateTimeFormatterStrategy.php | 3 +-- src/Strategy/ExplodeStrategy.php | 5 ++--- src/Strategy/HydratorStrategy.php | 5 ++--- src/Strategy/SerializableStrategy.php | 3 +-- test/Strategy/CollectionStrategyTest.php | 7 +++---- test/Strategy/HydratorStrategyTest.php | 7 +++---- 13 files changed, 26 insertions(+), 41 deletions(-) diff --git a/src/ClassMethodsHydrator.php b/src/ClassMethodsHydrator.php index b697e7cd..1c287dcd 100644 --- a/src/ClassMethodsHydrator.php +++ b/src/ClassMethodsHydrator.php @@ -9,7 +9,6 @@ use Traversable; use Webmozart\Assert\Assert; -use function get_class; use function get_class_methods; use function is_callable; use function lcfirst; @@ -129,7 +128,7 @@ public function getMethodExistsCheck(): bool */ public function extract(object $object): array { - $objectClass = get_class($object); + $objectClass = $object::class; $isAnonymous = false !== strpos($objectClass, '@anonymous'); if ($isAnonymous) { @@ -182,7 +181,7 @@ public function extract(object $object): array throw new Exception\BadMethodCallException(sprintf( 'Cannot extract data for attribute "%s" on class of type "%s"; method "%s" does not exist', $realAttributeName, - get_class($object), + $object::class, $methodName )); } @@ -223,7 +222,7 @@ private function identifyAttributeName(object $object, string $method): string */ public function hydrate(array $data, object $object) { - $objectClass = get_class($object); + $objectClass = $object::class; foreach ($data as $property => $value) { $propertyFqn = $objectClass . '::$' . $property; diff --git a/src/DelegatingHydrator.php b/src/DelegatingHydrator.php index f3674e87..62874b11 100644 --- a/src/DelegatingHydrator.php +++ b/src/DelegatingHydrator.php @@ -6,8 +6,6 @@ use Psr\Container\ContainerInterface; -use function get_class; - class DelegatingHydrator implements HydratorInterface { /** @var ContainerInterface */ @@ -39,6 +37,6 @@ public function extract(object $object): array */ protected function getHydrator(object $object): HydratorInterface { - return $this->hydrators->get(get_class($object)); + return $this->hydrators->get($object::class); } } diff --git a/src/HydratorPluginManager.php b/src/HydratorPluginManager.php index 6092139f..6c276307 100644 --- a/src/HydratorPluginManager.php +++ b/src/HydratorPluginManager.php @@ -9,7 +9,6 @@ use Laminas\ServiceManager\Exception\InvalidServiceException; use Laminas\ServiceManager\Factory\InvokableFactory; -use function get_class; use function gettype; use function is_object; use function sprintf; @@ -125,7 +124,7 @@ public function validate($instance) throw new InvalidServiceException(sprintf( 'Plugin of type %s is invalid; must implement %s', - is_object($instance) ? get_class($instance) : gettype($instance), + is_object($instance) ? $instance::class : gettype($instance), HydratorInterface::class )); } diff --git a/src/ObjectPropertyHydrator.php b/src/ObjectPropertyHydrator.php index 3c305d2f..7dba9328 100644 --- a/src/ObjectPropertyHydrator.php +++ b/src/ObjectPropertyHydrator.php @@ -9,7 +9,6 @@ use function array_fill_keys; use function array_map; -use function get_class; use function get_object_vars; class ObjectPropertyHydrator extends AbstractHydrator @@ -57,7 +56,7 @@ public function extract(object $object): array */ public function hydrate(array $data, object $object) { - $properties = &self::$skippedPropertiesCache[get_class($object)] ?? null; + $properties = &self::$skippedPropertiesCache[$object::class] ?? null; if (null === $properties) { $reflection = new ReflectionClass($object); diff --git a/src/ReflectionHydrator.php b/src/ReflectionHydrator.php index 03192fee..84d7adfc 100644 --- a/src/ReflectionHydrator.php +++ b/src/ReflectionHydrator.php @@ -7,8 +7,6 @@ use ReflectionClass; use ReflectionProperty; -use function get_class; - class ReflectionHydrator extends AbstractHydrator { /** @@ -64,7 +62,7 @@ public function hydrate(array $data, object $object) */ protected static function getReflProperties(object $input): array { - $class = get_class($input); + $class = $input::class; if (isset(static::$reflProperties[$class])) { return static::$reflProperties[$class]; diff --git a/src/Strategy/BooleanStrategy.php b/src/Strategy/BooleanStrategy.php index 6868c463..8f1aa69f 100644 --- a/src/Strategy/BooleanStrategy.php +++ b/src/Strategy/BooleanStrategy.php @@ -6,7 +6,6 @@ use Laminas\Hydrator\Exception\InvalidArgumentException; -use function get_class; use function gettype; use function is_bool; use function is_int; @@ -35,14 +34,14 @@ public function __construct($trueValue, $falseValue) if (! is_int($trueValue) && ! is_string($trueValue)) { throw new InvalidArgumentException(sprintf( 'Unable to instantiate BooleanStrategy. Expected int or string as $trueValue. %s was given', - is_object($trueValue) ? get_class($trueValue) : gettype($trueValue) + is_object($trueValue) ? $trueValue::class : gettype($trueValue) )); } if (! is_int($falseValue) && ! is_string($falseValue)) { throw new InvalidArgumentException(sprintf( 'Unable to instantiate BooleanStrategy. Expected int or string as $falseValue. %s was given', - is_object($falseValue) ? get_class($falseValue) : gettype($falseValue) + is_object($falseValue) ? $falseValue::class : gettype($falseValue) )); } @@ -62,7 +61,7 @@ public function extract($value, ?object $object = null) if (! is_bool($value)) { throw new InvalidArgumentException(sprintf( 'Unable to extract. Expected bool. %s was given.', - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) )); } @@ -85,7 +84,7 @@ public function hydrate($value, ?array $data = null) if (! is_string($value) && ! is_int($value)) { throw new InvalidArgumentException(sprintf( 'Unable to hydrate. Expected bool, string or int. %s was given.', - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) )); } diff --git a/src/Strategy/CollectionStrategy.php b/src/Strategy/CollectionStrategy.php index 0fe3fc33..4078e081 100644 --- a/src/Strategy/CollectionStrategy.php +++ b/src/Strategy/CollectionStrategy.php @@ -10,7 +10,6 @@ use function array_map; use function class_exists; -use function get_class; use function gettype; use function is_array; use function is_object; @@ -50,7 +49,7 @@ public function extract($value, ?object $object = null) if (! is_array($value)) { throw new Exception\InvalidArgumentException(sprintf( 'Value needs to be an array, got "%s" instead.', - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) )); } @@ -59,7 +58,7 @@ public function extract($value, ?object $object = null) throw new Exception\InvalidArgumentException(sprintf( 'Value needs to be an instance of "%s", got "%s" instead.', $this->objectClassName, - is_object($object) ? get_class($object) : gettype($object) + is_object($object) ? $object::class : gettype($object) )); } @@ -79,7 +78,7 @@ public function hydrate($value, ?array $data = null) if (! is_array($value)) { throw new Exception\InvalidArgumentException(sprintf( 'Value needs to be an array, got "%s" instead.', - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) )); } diff --git a/src/Strategy/DateTimeFormatterStrategy.php b/src/Strategy/DateTimeFormatterStrategy.php index 1a896c39..f554003b 100644 --- a/src/Strategy/DateTimeFormatterStrategy.php +++ b/src/Strategy/DateTimeFormatterStrategy.php @@ -8,7 +8,6 @@ use DateTimeInterface; use DateTimeZone; -use function get_class; use function gettype; use function is_object; use function is_string; @@ -101,7 +100,7 @@ public function hydrate($value, ?array $data = null) if (! is_string($value)) { throw new Exception\InvalidArgumentException(sprintf( 'Unable to hydrate. Expected null, string, or DateTimeInterface; %s was given.', - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) )); } diff --git a/src/Strategy/ExplodeStrategy.php b/src/Strategy/ExplodeStrategy.php index ac0d40b4..fe308482 100644 --- a/src/Strategy/ExplodeStrategy.php +++ b/src/Strategy/ExplodeStrategy.php @@ -5,7 +5,6 @@ namespace Laminas\Hydrator\Strategy; use function explode; -use function get_class; use function gettype; use function implode; use function is_array; @@ -63,7 +62,7 @@ public function hydrate($value, ?array $data = null) throw new Exception\InvalidArgumentException(sprintf( '%s expects argument 1 to be string, %s provided instead', __METHOD__, - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) )); } @@ -89,7 +88,7 @@ public function extract($value, ?object $object = null) throw new Exception\InvalidArgumentException(sprintf( '%s expects argument 1 to be array, %s provided instead', __METHOD__, - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) )); } diff --git a/src/Strategy/HydratorStrategy.php b/src/Strategy/HydratorStrategy.php index 44eabf26..d1789f9b 100644 --- a/src/Strategy/HydratorStrategy.php +++ b/src/Strategy/HydratorStrategy.php @@ -9,7 +9,6 @@ use ReflectionException; use function class_exists; -use function get_class; use function gettype; use function is_array; use function is_object; @@ -54,7 +53,7 @@ public function extract($value, ?object $object = null) sprintf( 'Value needs to be an instance of "%s", got "%s" instead.', $this->objectClassName, - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) ) ); } @@ -83,7 +82,7 @@ public function hydrate($value, ?array $data = null) throw new Exception\InvalidArgumentException( sprintf( 'Value needs to be an array, got "%s" instead.', - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) ) ); } diff --git a/src/Strategy/SerializableStrategy.php b/src/Strategy/SerializableStrategy.php index 2523d9af..56acdcd6 100644 --- a/src/Strategy/SerializableStrategy.php +++ b/src/Strategy/SerializableStrategy.php @@ -8,7 +8,6 @@ use Laminas\Serializer\Adapter\AdapterInterface as SerializerAdapter; use Laminas\Serializer\Serializer as SerializerFactory; -use function get_class; use function gettype; use function is_array; use function is_object; @@ -72,7 +71,7 @@ public function setSerializer($serializer): void '%s expects either a string serializer name or Laminas\Serializer\Adapter\AdapterInterface instance; ' . 'received "%s"', __METHOD__, - is_object($serializer) ? get_class($serializer) : gettype($serializer) + is_object($serializer) ? $serializer::class : gettype($serializer) )); } $this->serializer = $serializer; diff --git a/test/Strategy/CollectionStrategyTest.php b/test/Strategy/CollectionStrategyTest.php index ba01e7cc..374acacf 100644 --- a/test/Strategy/CollectionStrategyTest.php +++ b/test/Strategy/CollectionStrategyTest.php @@ -20,7 +20,6 @@ use function array_map; use function count; use function fopen; -use function get_class; use function gettype; use function is_object; use function mt_getrandmax; @@ -95,7 +94,7 @@ public function testExtractRejectsInvalidValue($value): void $this->expectException(Exception\InvalidArgumentException::class); $this->expectExceptionMessage(sprintf( 'Value needs to be an array, got "%s" instead.', - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) )); /** @psalm-suppress MixedArgument */ @@ -140,7 +139,7 @@ public function testExtractRejectsInvalidObject($object): void $this->expectExceptionMessage(sprintf( 'Value needs to be an instance of "%s", got "%s" instead.', TestAsset\User::class, - is_object($object) ? get_class($object) : gettype($object) + is_object($object) ? $object::class : gettype($object) )); $strategy->extract($value); @@ -214,7 +213,7 @@ public function testHydrateRejectsInvalidValue($value): void $this->expectException(Exception\InvalidArgumentException::class); $this->expectExceptionMessage(sprintf( 'Value needs to be an array, got "%s" instead.', - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) )); /** @psalm-suppress MixedArgument */ diff --git a/test/Strategy/HydratorStrategyTest.php b/test/Strategy/HydratorStrategyTest.php index 9564ced5..243e2818 100644 --- a/test/Strategy/HydratorStrategyTest.php +++ b/test/Strategy/HydratorStrategyTest.php @@ -17,7 +17,6 @@ use function count; use function fopen; -use function get_class; use function gettype; use function is_object; use function mt_getrandmax; @@ -78,7 +77,7 @@ public function testExtractRejectsInvalidValue($value): void sprintf( 'Value needs to be an instance of "%s", got "%s" instead.', TestAsset\User::class, - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) ) ); @@ -119,7 +118,7 @@ public function testExtractRejectsInvalidObject($object): void sprintf( 'Value needs to be an instance of "%s", got "%s" instead.', TestAsset\User::class, - is_object($object) ? get_class($object) : gettype($object) + is_object($object) ? $object::class : gettype($object) ) ); @@ -185,7 +184,7 @@ public function testHydrateRejectsInvalidValue($value): void $this->expectExceptionMessage( sprintf( 'Value needs to be an array, got "%s" instead.', - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) ) ); From 2a24fd4cd404467ed912c1fe82f14e6dd393640b Mon Sep 17 00:00:00 2001 From: George Steel Date: Fri, 14 Oct 2022 11:56:44 +0100 Subject: [PATCH 4/6] Correctly register psalm phpunit plugin Signed-off-by: George Steel --- psalm-baseline.xml | 344 +-------------------------------------------- psalm.xml | 22 +-- 2 files changed, 7 insertions(+), 359 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 694f1d1b..cd08f23a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + null === $this->eventManager @@ -74,9 +74,7 @@ HydratorInterface - - $this->hydrators->get(get_class($object)) - + @@ -312,64 +310,22 @@ $value - - - $hydrator - AggregateHydratorFunctionalTest - AggregateHydratorFunctionalTest - - - - - $eventManager - $hydrator - AggregateHydratorTest - AggregateHydratorTest - - - - - ExtractEventTest - ExtractEventTest - - - - - HydrateEventTest - HydrateEventTest - - onExtract onHydrate - - $hydrator - $listener - HydratorListenerTest - HydratorListenerTest - 'thisIsNotAnObject' 'thisIsNotAnObject' - - $hydrator - ArraySerializableHydratorTest - ArraySerializableHydratorTest - new ArraySerializable() - - ArraySerializableTest - ArraySerializableTest - @@ -378,41 +334,11 @@ 'non-object' 'non-object' - - $hydrator - ClassMethodsHydratorTest - ClassMethodsHydratorTest - new ClassMethods() - - ClassMethodsTest - ClassMethodsTest - - - - - DelegatingHydratorFactoryTest - DelegatingHydratorFactoryTest - - - $factory - $factory - $factory - $factory - - - - - $hydrator - $hydrators - $object - DelegatingHydratorTest - DelegatingHydratorTest - @@ -434,41 +360,7 @@ $value $value - - bool - - - $this->value - - - FilterCompositeTest - FilterCompositeTest - - - $this->value - - - $this->value - - - - - MethodMatchFilterTest - MethodMatchFilterTest - - - - - NumberOfParameterFilterTest - NumberOfParameterFilterTest - - - - - $filter - OptionalParametersFilterTest - OptionalParametersFilterTest - + @@ -479,10 +371,6 @@ setHydrator setHydrator - - HydratorAwareTraitTest - HydratorAwareTraitTest - @@ -497,11 +385,6 @@ $value $value - - $hydrator - HydratorClosureStrategyTest - HydratorClosureStrategyTest - addStrategy addStrategy @@ -530,23 +413,6 @@ $property $property - - $hydrator - HydratorObjectPropertyTest - HydratorObjectPropertyTest - - - - - HydratorPluginManagerCompatibilityTest - HydratorPluginManagerCompatibilityTest - - - - - HydratorPluginManagerFactoryTest - HydratorPluginManagerFactoryTest - @@ -556,11 +422,6 @@ $attributes['entities'][] - - $hydrator - HydratorStrategyTest - HydratorStrategyTest - addStrategy addStrategy @@ -591,50 +452,12 @@ $property $property - - $classMethodsCamelCase - $classMethodsCamelCaseMissing - $classMethodsInvalidParameter - $classMethodsTitleCase - $classMethodsUnderscore - $reflection - HydratorTest - HydratorTest - - - - - HydratingArrayIteratorTest - HydratingArrayIteratorTest - - - - - HydratingIteratorIteratorTest - HydratingIteratorIteratorTest - - - - - CompositeNamingStrategyTest - CompositeNamingStrategyTest - - - - - IdentityNamingStrategyTest - IdentityNamingStrategyTest - ['foo' => $invalidValue] ['foo' => $invalidValue] - - MapNamingStrategyTest - MapNamingStrategyTest - @@ -647,10 +470,6 @@ filter filter - - CamelCaseToUnderscoreFilterTest - CamelCaseToUnderscoreFilterTest - @@ -663,56 +482,28 @@ filter filter - - UnderscoreToCamelCaseFilterTest - UnderscoreToCamelCaseFilterTest - - - - - UnderscoreNamingStrategyTest - UnderscoreNamingStrategyTest - 'thisIsNotAnObject' 'thisIsNotAnObject' - - $hydrator - ObjectPropertyHydratorTest - ObjectPropertyHydratorTest - new ObjectProperty() - - ObjectPropertyTest - ObjectPropertyTest - $argument $argument - - $hydrator - ReflectionHydratorTest - ReflectionHydratorTest - new Reflection() - - ReflectionTest - ReflectionTest - @@ -725,27 +516,6 @@ Reflection::class Reflection::class - - $manager - - - $manager - - - ($this->factory)($this->container) - - - StandaloneHydratorPluginManagerFactoryTest - StandaloneHydratorPluginManagerFactoryTest - - - $this->container - $this->factory - - - $this->container - $this->factory - @@ -757,10 +527,8 @@ Hydrator\ObjectProperty::class Hydrator\Reflection::class - + $factories - $this->manager - $this->manager $factories[$class] @@ -771,27 +539,6 @@ $factories $instance - - get - get - has - has - - - StandaloneHydratorPluginManagerTest - StandaloneHydratorPluginManagerTest - - - $this->manager - - - $this->manager - $this->manager - $this->manager - $this->manager - $this->manager - $this->manager - @@ -799,10 +546,6 @@ 5 true - - BooleanStrategyTest - BooleanStrategyTest - @@ -821,10 +564,6 @@ hydrate - - CollectionStrategyTest - CollectionStrategyTest - @@ -843,20 +582,11 @@ getTimezone getTimezone - - DateTimeFormatterStrategyTest - DateTimeFormatterStrategyTest - format - - $strategy - DateTimeImmutableFormatterStrategyTest - DateTimeImmutableFormatterStrategyTest - @@ -867,10 +597,6 @@ $value - - ExplodeStrategyTest - ExplodeStrategyTest - @@ -908,73 +634,11 @@ expects expects - - HydratorStrategyTest - HydratorStrategyTest - - - - - NullableStrategyTest - NullableStrategyTest - $serialized $serialized - - SerializableStrategyTest - SerializableStrategyTest - - - - - $value - $value - $value - $value - $value - $value - $value - $value - $value - $value - $value - $value - - - function ($value) { - function ($value) { - function ($value) { - function ($value) { - function ($value) { - function ($value) { - function ($value) { - function ($value) { - function ($value) { - function ($value) { - function ($value) { - function ($value) { - - - $value - $value - $value - $value - $value - $value - $value - $value - $value - $value - $value - $value - - - StrategyChainTest - StrategyChainTest - diff --git a/psalm.xml b/psalm.xml index 180a3a30..82d21ebb 100644 --- a/psalm.xml +++ b/psalm.xml @@ -16,23 +16,7 @@ - - - - - - - - - - - - - - - - - - - + + + From 2485c9465ae759e729db49becdb9a60dd5325793 Mon Sep 17 00:00:00 2001 From: George Steel Date: Fri, 14 Oct 2022 12:27:34 +0100 Subject: [PATCH 5/6] Fix psalm issues with tests Signed-off-by: George Steel --- psalm-baseline.xml | 52 ++---------------- .../AggregateHydratorFunctionalTest.php | 43 ++++++++------- test/Filter/FilterCompositeTest.php | 9 ++-- test/NamingStrategy/MapNamingStrategyTest.php | 32 +++++------ test/StandaloneHydratorPluginManagerTest.php | 22 ++++---- test/Strategy/CollectionStrategyTest.php | 35 ++++++------ .../DateTimeFormatterStrategyTest.php | 53 ++++++++++--------- ...DateTimeImmutableFormatterStrategyTest.php | 29 +++++----- test/Strategy/ExplodeStrategyTest.php | 32 ++++++----- test/Strategy/HydratorStrategyTest.php | 32 ++++++----- 10 files changed, 150 insertions(+), 189 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index cd08f23a..77daa621 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -360,7 +360,6 @@ $value $value - @@ -453,12 +452,6 @@ $property - - - ['foo' => $invalidValue] - ['foo' => $invalidValue] - - new CamelCaseToUnderscoreFilter() @@ -518,9 +511,6 @@ - - $expectedType - Hydrator\ArraySerializable::class Hydrator\ClassMethods::class @@ -548,25 +538,21 @@ - - $expectedExceptionType - $data function ($data) { - + $data - $objectClassName hydrate - + $date $date $date @@ -574,7 +560,7 @@ $extracted $hydrated - + format format getName @@ -588,20 +574,7 @@ format - - - '' - [] - [] - - - $value - - - - $expectedExceptionType - $data @@ -614,26 +587,9 @@ $objectClassName $value - + hydrate - method - method - willReturnCallback - willReturnCallback - - $hydrator - $hydrator - $this->createHydratorMock() - $this->createHydratorMock() - $this->createHydratorMock() - $this->createHydratorMock() - $this->createHydratorMock() - - - expects - expects - diff --git a/test/Aggregate/AggregateHydratorFunctionalTest.php b/test/Aggregate/AggregateHydratorFunctionalTest.php index c5898f54..9fbc3b21 100644 --- a/test/Aggregate/AggregateHydratorFunctionalTest.php +++ b/test/Aggregate/AggregateHydratorFunctionalTest.php @@ -20,8 +20,7 @@ */ class AggregateHydratorFunctionalTest extends TestCase { - /** @var AggregateHydrator */ - protected $hydrator; + protected AggregateHydrator $hydrator; /** * {@inheritDoc} @@ -38,10 +37,10 @@ public function testEmptyAggregate(): void { $object = new ArrayObject(['zaphod' => 'beeblebrox']); - $this->assertSame([], $this->hydrator->extract($object)); - $this->assertSame($object, $this->hydrator->hydrate(['arthur' => 'dent'], $object)); + self::assertSame([], $this->hydrator->extract($object)); + self::assertSame($object, $this->hydrator->hydrate(['arthur' => 'dent'], $object)); - $this->assertSame(['zaphod' => 'beeblebrox'], $object->getArrayCopy()); + self::assertSame(['zaphod' => 'beeblebrox'], $object->getArrayCopy()); } /** @@ -55,7 +54,7 @@ public function testSingleHydratorExtraction(HydratorInterface $comparisonHydrat $this->hydrator->add($comparisonHydrator); - $this->assertSame($comparisonHydrator->extract($blueprint), $this->hydrator->extract($object)); + self::assertSame($comparisonHydrator->extract($blueprint), $this->hydrator->extract($object)); } /** @@ -75,10 +74,10 @@ public function testSingleHydratorHydration( $hydratedBlueprint = $comparisonHydrator->hydrate($data, $blueprint); $hydrated = $this->hydrator->hydrate($data, $object); - $this->assertEquals($hydratedBlueprint, $hydrated); + self::assertEquals($hydratedBlueprint, $hydrated); if ($hydratedBlueprint === $blueprint) { - $this->assertSame($hydrated, $object); + self::assertSame($hydrated, $object); } } @@ -94,10 +93,10 @@ public function testExtractWithMultipleHydrators(): void $extracted = $this->hydrator->extract($object); - $this->assertArrayHasKey('maintainer', $extracted); - $this->assertArrayHasKey('president', $extracted); - $this->assertSame('Marvin', $extracted['maintainer']); - $this->assertSame('Zaphod', $extracted['president']); + self::assertArrayHasKey('maintainer', $extracted); + self::assertArrayHasKey('president', $extracted); + self::assertSame('Marvin', $extracted['maintainer']); + self::assertSame('Zaphod', $extracted['president']); } /** @@ -110,16 +109,16 @@ public function testHydrateWithMultipleHydrators(): void $object = new AggregateObject(); - $this->assertSame( + self::assertSame( $object, $this->hydrator->hydrate(['maintainer' => 'Trillian', 'president' => '???'], $object) ); - $this->assertArrayHasKey('maintainer', $object->arrayData); - $this->assertArrayHasKey('president', $object->arrayData); - $this->assertSame('Trillian', $object->arrayData['maintainer']); - $this->assertSame('???', $object->arrayData['president']); - $this->assertSame('Trillian', $object->maintainer); + self::assertArrayHasKey('maintainer', $object->arrayData); + self::assertArrayHasKey('president', $object->arrayData); + self::assertSame('Trillian', $object->arrayData['maintainer']); + self::assertSame('???', $object->arrayData['president']); + self::assertSame('Trillian', $object->maintainer); } /** @@ -137,7 +136,7 @@ public function testStoppedPropagationInExtraction(): void $this->hydrator->add(new ArraySerializableHydrator()); $this->hydrator->getEventManager()->attach(ExtractEvent::EVENT_EXTRACT, $callback, 1000); - $this->assertSame(['Ravenous Bugblatter Beast of Traal'], $this->hydrator->extract($object)); + self::assertSame(['Ravenous Bugblatter Beast of Traal'], $this->hydrator->extract($object)); } /** @@ -156,15 +155,15 @@ public function testStoppedPropagationInHydration(): void $this->hydrator->add(new ArraySerializableHydrator()); $this->hydrator->getEventManager()->attach(HydrateEvent::EVENT_HYDRATE, $callback, 1000); - $this->assertSame($swappedObject, $this->hydrator->hydrate(['president' => 'Zaphod'], $object)); + self::assertSame($swappedObject, $this->hydrator->hydrate(['president' => 'Zaphod'], $object)); } /** * Data provider method * - * @return array + * @return list */ - public function getHydratorSet() + public function getHydratorSet(): array { return [ [new ArraySerializableHydrator(), new ArrayObject(['zaphod' => 'beeblebrox']), ['arthur' => 'dent']], diff --git a/test/Filter/FilterCompositeTest.php b/test/Filter/FilterCompositeTest.php index 33dc6a12..b80bab4c 100644 --- a/test/Filter/FilterCompositeTest.php +++ b/test/Filter/FilterCompositeTest.php @@ -36,6 +36,7 @@ public function testFilters(array $orFilters, array $andFilters): void } } + /** @return list */ public function validFiltersProvider(): array { return [ @@ -56,12 +57,10 @@ public function validFiltersProvider(): array ]; } + /** @return list */ public function invalidFiltersProvider(): array { - $callback = /** - * @return true - */ - static fn(): bool => true; + $callback = static fn(): bool => true; return [ [ @@ -155,7 +154,7 @@ private function generateFilters( } /** - * @psalm-return Generator + * @psalm-return Generator */ public function providerCompositionFiltering(): Generator { diff --git a/test/NamingStrategy/MapNamingStrategyTest.php b/test/NamingStrategy/MapNamingStrategyTest.php index f288aa4d..2c57409c 100644 --- a/test/NamingStrategy/MapNamingStrategyTest.php +++ b/test/NamingStrategy/MapNamingStrategyTest.php @@ -4,6 +4,7 @@ namespace LaminasTest\Hydrator\NamingStrategy; +use Generator; use Laminas\Hydrator\Exception; use Laminas\Hydrator\NamingStrategy\MapNamingStrategy; use PHPUnit\Framework\TestCase; @@ -15,7 +16,8 @@ */ class MapNamingStrategyTest extends TestCase { - public function invalidMapValues(): iterable + /** @return Generator> */ + public function invalidMapValues(): Generator { yield 'null' => [null]; yield 'true' => [true]; @@ -26,8 +28,8 @@ public function invalidMapValues(): iterable yield 'object' => [(object) ['foo' => 'bar']]; } - /** @psalm-return iterable}> */ - public function invalidKeyArrays(): iterable + /** @psalm-return Generator}> */ + public function invalidKeyArrays(): Generator { yield 'int' => [ 'invalidKeyArray' => [1 => 'foo'], @@ -39,14 +41,14 @@ public function invalidKeyArrays(): iterable /** * @dataProvider invalidMapValues - * @param mixed $invalidValue */ public function testExtractionMapConstructorRaisesExceptionWhenFlippingHydrationMapForInvalidValues( - $invalidValue + mixed $invalidValue ): void { $this->expectException(Exception\InvalidArgumentException::class); $this->expectExceptionMessage('can not be flipped'); + /** @psalm-suppress MixedArgumentTypeCoercion */ MapNamingStrategy::createFromExtractionMap(['foo' => $invalidValue]); } @@ -65,14 +67,14 @@ public function testExtractionMapConstructorRaisesExceptionWhenFlippingHydration /** * @dataProvider invalidMapValues - * @param mixed $invalidValue */ public function testHydrationMapConstructorRaisesExceptionWhenFlippingExtractionMapForInvalidValues( - $invalidValue + mixed $invalidValue ): void { $this->expectException(Exception\InvalidArgumentException::class); $this->expectExceptionMessage('can not be flipped'); + /** @psalm-suppress MixedArgumentTypeCoercion */ MapNamingStrategy::createFromHydrationMap(['foo' => $invalidValue]); } @@ -92,43 +94,43 @@ public function testHydrationMapConstructorRaisesExceptionWhenFlippingExtraction public function testExtractReturnsVerbatimWhenEmptyExtractionMapProvided(): void { $strategy = MapNamingStrategy::createFromExtractionMap([]); - $this->assertEquals('some_stuff', $strategy->extract('some_stuff')); + self::assertEquals('some_stuff', $strategy->extract('some_stuff')); } public function testHydrateReturnsVerbatimWhenEmptyHydrationMapProvided(): void { $strategy = MapNamingStrategy::createFromHydrationMap([]); - $this->assertEquals('some_stuff', $strategy->hydrate('some_stuff')); + self::assertEquals('some_stuff', $strategy->hydrate('some_stuff')); } public function testExtractUsesProvidedExtractionMap(): void { $strategy = MapNamingStrategy::createFromExtractionMap(['stuff3' => 'stuff4']); - $this->assertEquals('stuff4', $strategy->extract('stuff3')); + self::assertEquals('stuff4', $strategy->extract('stuff3')); } public function testExtractUsesFlippedHydrationMapWhenOnlyHydrationMapProvided(): void { $strategy = MapNamingStrategy::createFromHydrationMap(['stuff3' => 'stuff4']); - $this->assertEquals('stuff3', $strategy->extract('stuff4')); + self::assertEquals('stuff3', $strategy->extract('stuff4')); } public function testHydrateUsesProvidedHydrationMap(): void { $strategy = MapNamingStrategy::createFromHydrationMap(['stuff3' => 'stuff4']); - $this->assertEquals('stuff4', $strategy->hydrate('stuff3')); + self::assertEquals('stuff4', $strategy->hydrate('stuff3')); } public function testHydrateUsesFlippedExtractionMapOnlyExtractionMapProvided(): void { $strategy = MapNamingStrategy::createFromExtractionMap(['foo' => 'bar']); - $this->assertEquals('foo', $strategy->hydrate('bar')); + self::assertEquals('foo', $strategy->hydrate('bar')); } public function testHydrateAndExtractUseAsymmetricMapProvided(): void { $strategy = MapNamingStrategy::createFromAsymmetricMap(['foo' => 'bar'], ['bat' => 'baz']); - $this->assertEquals('bar', $strategy->extract('foo')); - $this->assertEquals('baz', $strategy->hydrate('bat')); + self::assertEquals('bar', $strategy->extract('foo')); + self::assertEquals('baz', $strategy->hydrate('bat')); } } diff --git a/test/StandaloneHydratorPluginManagerTest.php b/test/StandaloneHydratorPluginManagerTest.php index ba707a55..038a3df1 100644 --- a/test/StandaloneHydratorPluginManagerTest.php +++ b/test/StandaloneHydratorPluginManagerTest.php @@ -5,6 +5,7 @@ namespace LaminasTest\Hydrator; use Closure; +use Generator; use Laminas\Hydrator; use Laminas\Hydrator\StandaloneHydratorPluginManager; use PHPUnit\Framework\TestCase; @@ -33,9 +34,9 @@ public function reflectProperty(object $class, string $property) } /** - * @psalm-return iterable + * @psalm-return Generator */ - public function hydratorsWithoutConstructors(): iterable + public function hydratorsWithoutConstructors(): Generator { yield 'ArraySerializable' => [Hydrator\ArraySerializableHydrator::class]; yield 'ArraySerializableHydrator' => [Hydrator\ArraySerializableHydrator::class]; @@ -58,14 +59,14 @@ public function testInstantiationInitializesFactoriesForHydratorsWithoutConstruc { $factories = $this->reflectProperty($this->manager, 'factories'); - $this->assertArrayHasKey($class, $factories); - $this->assertInstanceOf(Closure::class, $factories[$class]); + self::assertArrayHasKey($class, $factories); + self::assertInstanceOf(Closure::class, $factories[$class]); } public function testDelegatingHydratorFactoryIsInitialized(): void { $factories = $this->reflectProperty($this->manager, 'factories'); - $this->assertInstanceOf( + self::assertInstanceOf( Hydrator\DelegatingHydratorFactory::class, $factories[Hydrator\DelegatingHydrator::class] ); @@ -73,10 +74,11 @@ public function testDelegatingHydratorFactoryIsInitialized(): void public function testHasReturnsFalseForUnknownNames(): void { - $this->assertFalse($this->manager->has('unknown-service-name')); + self::assertFalse($this->manager->has('unknown-service-name')); } - public function knownServices(): iterable + /** @return Generator */ + public function knownServices(): Generator { foreach ($this->hydratorsWithoutConstructors() as $key => $data) { $class = array_pop($data); @@ -96,7 +98,7 @@ public function knownServices(): iterable */ public function testHasReturnsTrueForKnownServices(string $service): void { - $this->assertTrue($this->manager->has($service)); + self::assertTrue($this->manager->has($service)); } public function testGetRaisesExceptionForUnknownService(): void @@ -107,10 +109,12 @@ public function testGetRaisesExceptionForUnknownService(): void /** * @dataProvider knownServices + * @param string|class-string $service + * @param class-string $expectedType */ public function testGetReturnsExpectedTypesForKnownServices(string $service, string $expectedType): void { $instance = $this->manager->get($service); - $this->assertInstanceOf($expectedType, $instance); + self::assertInstanceOf($expectedType, $instance); } } diff --git a/test/Strategy/CollectionStrategyTest.php b/test/Strategy/CollectionStrategyTest.php index 374acacf..69a9f0d6 100644 --- a/test/Strategy/CollectionStrategyTest.php +++ b/test/Strategy/CollectionStrategyTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase; use ReflectionClass; use stdClass; +use Throwable; use TypeError; use function array_map; @@ -38,7 +39,7 @@ public function testImplementsStrategyInterface(): void { $reflection = new ReflectionClass(CollectionStrategy::class); - $this->assertTrue($reflection->implementsInterface(StrategyInterface::class), sprintf( + self::assertTrue($reflection->implementsInterface(StrategyInterface::class), sprintf( 'Failed to assert that "%s" implements "%s"', CollectionStrategy::class, StrategyInterface::class @@ -47,22 +48,24 @@ public function testImplementsStrategyInterface(): void /** * @dataProvider providerInvalidObjectClassName - * @param mixed $objectClassName + * @param class-string $expectedExceptionType */ public function testConstructorRejectsInvalidObjectClassName( - $objectClassName, + mixed $objectClassName, string $expectedExceptionType, string $expectedExceptionMessage ): void { $this->expectException($expectedExceptionType); $this->expectExceptionMessage($expectedExceptionMessage); + /** @psalm-suppress MixedArgument */ new CollectionStrategy( $this->createHydratorMock(), $objectClassName ); } + /** @return array, 2: string}> */ public function providerInvalidObjectClassName(): array { // @codingStandardsIgnoreStart @@ -82,9 +85,8 @@ public function providerInvalidObjectClassName(): array /** * @dataProvider providerInvalidValueForExtraction - * @param mixed $value */ - public function testExtractRejectsInvalidValue($value): void + public function testExtractRejectsInvalidValue(mixed $value): void { $strategy = new CollectionStrategy( $this->createHydratorMock(), @@ -102,9 +104,9 @@ public function testExtractRejectsInvalidValue($value): void } /** - * @return Generator + * @return Generator> */ - public function providerInvalidValueForExtraction() + public function providerInvalidValueForExtraction(): Generator { $values = [ 'boolean-false' => false, @@ -146,9 +148,9 @@ public function testExtractRejectsInvalidObject($object): void } /** - * @return Generator + * @return Generator> */ - public function providerInvalidObjectForExtraction() + public function providerInvalidObjectForExtraction(): Generator { $values = [ 'boolean-false' => false, @@ -185,7 +187,7 @@ public function testExtractUsesHydratorToExtractValues(): void $hydrator = $this->createHydratorMock(); $hydrator - ->expects($this->exactly(count($value))) + ->expects(self::exactly(count($value))) ->method('extract') ->willReturnCallback($extraction); @@ -196,14 +198,13 @@ public function testExtractUsesHydratorToExtractValues(): void $expected = array_map($extraction, $value); - $this->assertSame($expected, $strategy->extract($value)); + self::assertSame($expected, $strategy->extract($value)); } /** * @dataProvider providerInvalidValueForHydration - * @param mixed $value */ - public function testHydrateRejectsInvalidValue($value): void + public function testHydrateRejectsInvalidValue(mixed $value): void { $strategy = new CollectionStrategy( $this->createHydratorMock(), @@ -221,9 +222,9 @@ public function testHydrateRejectsInvalidValue($value): void } /** - * @return Generator + * @return Generator> */ - public function providerInvalidValueForHydration() + public function providerInvalidValueForHydration(): Generator { $values = [ 'boolean-false' => false, @@ -264,7 +265,7 @@ public function testHydrateUsesHydratorToHydrateValues(): void $hydrator = $this->createHydratorMock(); $hydrator - ->expects($this->exactly(count($value))) + ->expects(self::exactly(count($value))) ->method('hydrate') ->willReturnCallback($hydration); @@ -275,7 +276,7 @@ public function testHydrateUsesHydratorToHydrateValues(): void $expected = array_map($hydration, $value); - $this->assertEquals($expected, $strategy->hydrate($value)); + self::assertEquals($expected, $strategy->hydrate($value)); } /** diff --git a/test/Strategy/DateTimeFormatterStrategyTest.php b/test/Strategy/DateTimeFormatterStrategyTest.php index ee0bc447..979f0d02 100644 --- a/test/Strategy/DateTimeFormatterStrategyTest.php +++ b/test/Strategy/DateTimeFormatterStrategyTest.php @@ -6,6 +6,7 @@ use DateTime; use DateTimeImmutable; +use DateTimeInterface; use DateTimeZone; use Laminas\Hydrator\Strategy\DateTimeFormatterStrategy; use Laminas\Hydrator\Strategy\Exception\InvalidArgumentException; @@ -22,25 +23,25 @@ class DateTimeFormatterStrategyTest extends TestCase public function testHydrate(): void { $strategy = new DateTimeFormatterStrategy('Y-m-d'); - $this->assertEquals('2014-04-26', $strategy->hydrate('2014-04-26')->format('Y-m-d')); + self::assertEquals('2014-04-26', $strategy->hydrate('2014-04-26')->format('Y-m-d')); $strategy = new DateTimeFormatterStrategy('Y-m-d', new DateTimeZone('Asia/Kathmandu')); $date = $strategy->hydrate('2014-04-26'); - $this->assertEquals('Asia/Kathmandu', $date->getTimezone()->getName()); + self::assertEquals('Asia/Kathmandu', $date->getTimezone()->getName()); } public function testExtract(): void { $strategy = new DateTimeFormatterStrategy('d/m/Y'); - $this->assertEquals('26/04/2014', $strategy->extract(new DateTime('2014-04-26'))); + self::assertEquals('26/04/2014', $strategy->extract(new DateTime('2014-04-26'))); } public function testGetNullWithInvalidDateOnHydration(): void { $strategy = new DateTimeFormatterStrategy('Y-m-d'); - $this->assertEquals(null, $strategy->hydrate(null)); - $this->assertEquals(null, $strategy->hydrate('')); + self::assertEquals(null, $strategy->hydrate(null)); + self::assertEquals(null, $strategy->hydrate('')); } public function testCanExtractIfNotDateTime(): void @@ -48,13 +49,13 @@ public function testCanExtractIfNotDateTime(): void $strategy = new DateTimeFormatterStrategy(); $date = $strategy->extract(new stdClass()); - $this->assertInstanceOf(stdClass::class, $date); + self::assertInstanceOf(stdClass::class, $date); } public function testCanHydrateWithInvalidDateTime(): void { $strategy = new DateTimeFormatterStrategy('d/m/Y'); - $this->assertSame('foo bar baz', $strategy->hydrate('foo bar baz')); + self::assertSame('foo bar baz', $strategy->hydrate('foo bar baz')); } public function testCanExtractAnyDateTimeInterface(): void @@ -65,7 +66,7 @@ public function testCanExtractAnyDateTimeInterface(): void $format = 'Y-m-d'; $dateMock - ->expects($this->once()) + ->expects(self::once()) ->method('format') ->with($format); @@ -74,7 +75,7 @@ public function testCanExtractAnyDateTimeInterface(): void ->getMock(); $dateImmutableMock - ->expects($this->once()) + ->expects(self::once()) ->method('format') ->with($format); @@ -94,22 +95,20 @@ public function testAcceptsCreateFromFormatSpecialCharacters($format, $expectedV $strategy = new DateTimeFormatterStrategy($format); $hydrated = $strategy->hydrate($expectedValue); - $this->assertInstanceOf(DateTime::class, $hydrated); - $this->assertEquals($expectedValue, $hydrated->format('Y-m-d')); + self::assertInstanceOf(DateTime::class, $hydrated); + self::assertEquals($expectedValue, $hydrated->format('Y-m-d')); } /** * @dataProvider formatsWithSpecialCharactersProvider - * @param string $format - * @param string $expectedValue */ - public function testCanExtractWithCreateFromFormatSpecialCharacters($format, $expectedValue): void + public function testCanExtractWithCreateFromFormatSpecialCharacters(string $format, string $expectedValue): void { $date = DateTime::createFromFormat($format, $expectedValue); $strategy = new DateTimeFormatterStrategy($format); $extracted = $strategy->extract($date); - $this->assertEquals($expectedValue, $extracted); + self::assertEquals($expectedValue, $extracted); } public function testCanExtractWithCreateFromFormatEscapedSpecialCharacters(): void @@ -117,7 +116,7 @@ public function testCanExtractWithCreateFromFormatEscapedSpecialCharacters(): vo $date = DateTime::createFromFormat('Y-m-d', '2018-02-05'); $strategy = new DateTimeFormatterStrategy('Y-m-d\\+'); $extracted = $strategy->extract($date); - $this->assertEquals('2018-02-05+', $extracted); + self::assertEquals('2018-02-05+', $extracted); } /** @@ -138,15 +137,18 @@ public function testCanHydrateWithDateTimeFallback(): void $strategy = new DateTimeFormatterStrategy('Y-m-d', null, true); $date = $strategy->hydrate('2018-09-06T12:10:30'); - $this->assertSame('2018-09-06', $date->format('Y-m-d')); + self::assertInstanceOf(DateTimeInterface::class, $date); + self::assertSame('2018-09-06', $date->format('Y-m-d')); $strategy = new DateTimeFormatterStrategy('Y-m-d', new DateTimeZone('Europe/Prague'), true); $date = $strategy->hydrate('2018-09-06T12:10:30'); - $this->assertSame('Europe/Prague', $date->getTimezone()->getName()); + self::assertInstanceOf(DateTimeInterface::class, $date); + self::assertSame('Europe/Prague', $date->getTimezone()->getName()); } - public function invalidValuesForHydration(): iterable + /** @return array> */ + public function invalidValuesForHydration(): array { return [ 'zero' => [0], @@ -160,9 +162,8 @@ public function invalidValuesForHydration(): iterable /** * @dataProvider invalidValuesForHydration - * @param mixed $value */ - public function testHydrateRaisesExceptionIfValueIsInvalid($value): void + public function testHydrateRaisesExceptionIfValueIsInvalid(mixed $value): void { $strategy = new DateTimeFormatterStrategy('Y-m-d'); @@ -171,7 +172,8 @@ public function testHydrateRaisesExceptionIfValueIsInvalid($value): void $strategy->hydrate($value); } - public function validUnhydratableValues(): iterable + /** @return array> */ + public function validUnHydratableValues(): array { return [ 'empty string' => [''], @@ -181,13 +183,12 @@ public function validUnhydratableValues(): iterable } /** - * @dataProvider validUnhydratableValues - * @param mixed $value + * @dataProvider validUnHydratableValues */ - public function testReturnsValueVerbatimUnderSpecificConditions($value): void + public function testReturnsValueVerbatimUnderSpecificConditions(mixed $value): void { $strategy = new DateTimeFormatterStrategy('Y-m-d'); $hydrated = $strategy->hydrate($value); - $this->assertSame($value, $hydrated); + self::assertSame($value, $hydrated); } } diff --git a/test/Strategy/DateTimeImmutableFormatterStrategyTest.php b/test/Strategy/DateTimeImmutableFormatterStrategyTest.php index 4e6ec193..33609051 100644 --- a/test/Strategy/DateTimeImmutableFormatterStrategyTest.php +++ b/test/Strategy/DateTimeImmutableFormatterStrategyTest.php @@ -5,7 +5,6 @@ namespace LaminasTest\Hydrator\Strategy; use DateTimeImmutable; -use Generator; use Laminas\Hydrator\Strategy\DateTimeFormatterStrategy; use Laminas\Hydrator\Strategy\DateTimeImmutableFormatterStrategy; use PHPUnit\Framework\TestCase; @@ -23,7 +22,7 @@ protected function setUp(): void public function testExtraction(): void { - $this->assertEquals( + self::assertEquals( '2020-05-25', $this->strategy->extract(new DateTimeImmutable('2020-05-25')) ); @@ -32,12 +31,12 @@ public function testExtraction(): void public function testHydrationWithDateTimeImmutableObjectShouldReturnSame(): void { $dateTime = new DateTimeImmutable('2020-05-25'); - $this->assertEquals($dateTime, $this->strategy->hydrate($dateTime)); + self::assertEquals($dateTime, $this->strategy->hydrate($dateTime)); } public function testHydrationShouldReturnImmutableDateTimeObject(): void { - $this->assertInstanceOf( + self::assertInstanceOf( DateTimeImmutable::class, $this->strategy->hydrate('2020-05-25') ); @@ -45,31 +44,27 @@ public function testHydrationShouldReturnImmutableDateTimeObject(): void public function testHydrationShouldReturnDateTimeObjectWithSameValue(): void { - $this->assertSame( + self::assertSame( '2020-05-25', $this->strategy->hydrate('2020-05-25')->format('Y-m-d') ); } /** - * @param mixed $value * @dataProvider dataProviderForInvalidDateValues */ - public function testHydrationShouldReturnInvalidDateValuesAsIs($value): void + public function testHydrationShouldReturnInvalidDateValuesAsIs(string|null $value): void { - $this->assertSame($value, $this->strategy->hydrate($value)); + self::assertSame($value, $this->strategy->hydrate($value)); } - public function dataProviderForInvalidDateValues(): Generator + /** @return array */ + public function dataProviderForInvalidDateValues(): array { - $values = [ - 'null' => null, - 'empty-string' => '', - 'foo' => 'foo', + return [ + 'null' => [null], + 'empty-string' => [''], + 'foo' => ['foo'], ]; - - foreach ($values as $key => $value) { - yield $key => [$value]; - } } } diff --git a/test/Strategy/ExplodeStrategyTest.php b/test/Strategy/ExplodeStrategyTest.php index ea30547a..17957b56 100644 --- a/test/Strategy/ExplodeStrategyTest.php +++ b/test/Strategy/ExplodeStrategyTest.php @@ -20,18 +20,16 @@ class ExplodeStrategyTest extends TestCase { /** * @dataProvider getValidHydratedValues - * @param string $expected - * @param string $delimiter * @param string[] $extractValue */ - public function testExtract($expected, $delimiter, $extractValue): void + public function testExtract(mixed $expected, string $delimiter, array $extractValue): void { $strategy = new ExplodeStrategy($delimiter); if (is_numeric($expected)) { - $this->assertEquals($expected, $strategy->extract($extractValue)); + self::assertEquals($expected, $strategy->extract($extractValue)); } else { - $this->assertSame($expected, $strategy->extract($extractValue)); + self::assertSame($expected, $strategy->extract($extractValue)); } } @@ -41,6 +39,7 @@ public function testGetExceptionWithInvalidArgumentOnExtraction(): void $this->expectException(InvalidArgumentException::class); + /** @psalm-suppress InvalidArgument */ $strategy->extract(''); } @@ -48,7 +47,7 @@ public function testGetEmptyArrayWhenHydratingNullValue(): void { $strategy = new ExplodeStrategy(); - $this->assertSame([], $strategy->hydrate(null)); + self::assertSame([], $strategy->hydrate(null)); } public function testGetExceptionWithEmptyDelimiter(): void @@ -61,10 +60,10 @@ public function testGetExceptionWithEmptyDelimiter(): void public function testHydrateWithExplodeLimit(): void { $strategy = new ExplodeStrategy('-', 2); - $this->assertSame(['foo', 'bar-baz-bat'], $strategy->hydrate('foo-bar-baz-bat')); + self::assertSame(['foo', 'bar-baz-bat'], $strategy->hydrate('foo-bar-baz-bat')); $strategy = new ExplodeStrategy('-', 3); - $this->assertSame(['foo', 'bar', 'baz-bat'], $strategy->hydrate('foo-bar-baz-bat')); + self::assertSame(['foo', 'bar', 'baz-bat'], $strategy->hydrate('foo-bar-baz-bat')); } public function testHydrateWithInvalidScalarType(): void @@ -77,6 +76,7 @@ public function testHydrateWithInvalidScalarType(): void . ' array provided instead' ); + /** @psalm-suppress InvalidArgument */ $strategy->hydrate([]); } @@ -90,6 +90,7 @@ public function testHydrateWithInvalidObjectType(): void . ' stdClass provided instead' ); + /** @psalm-suppress InvalidArgument */ $strategy->hydrate(new stdClass()); } @@ -103,28 +104,25 @@ public function testExtractWithInvalidObjectType(): void . ' stdClass provided instead' ); + /** @psalm-suppress InvalidArgument */ $strategy->extract(new stdClass()); } /** * @dataProvider getValidHydratedValues - * @param mixed $value - * @param string $delimiter - * @param string[] $expected */ - public function testHydration($value, $delimiter, array $expected): void + public function testHydration(mixed $value, string $delimiter, array $expected): void { $strategy = new ExplodeStrategy($delimiter); - $this->assertSame($expected, $strategy->hydrate($value)); + /** @psalm-suppress MixedArgument */ + self::assertSame($expected, $strategy->hydrate($value)); } /** - * Data provider - * - * @return mixed[][] + * @return array}> */ - public function getValidHydratedValues() + public function getValidHydratedValues(): array { // @codingStandardsIgnoreStart return [ diff --git a/test/Strategy/HydratorStrategyTest.php b/test/Strategy/HydratorStrategyTest.php index 243e2818..e912280b 100644 --- a/test/Strategy/HydratorStrategyTest.php +++ b/test/Strategy/HydratorStrategyTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use stdClass; +use Throwable; use TypeError; use function count; @@ -28,10 +29,10 @@ class HydratorStrategyTest extends TestCase { /** * @dataProvider providerInvalidObjectClassName - * @param mixed $objectClassName + * @param class-string $expectedExceptionType */ public function testConstructorRejectsInvalidObjectClassName( - $objectClassName, + mixed $objectClassName, string $expectedExceptionType, string $expectedExceptionMessage ): void { @@ -44,6 +45,7 @@ public function testConstructorRejectsInvalidObjectClassName( ); } + /** @return array, string}> */ public function providerInvalidObjectClassName(): array { // @codingStandardsIgnoreStart @@ -84,7 +86,8 @@ public function testExtractRejectsInvalidValue($value): void $strategy->extract($value); } - public function providerInvalidValueForExtraction(): ?Generator + /** @return Generator */ + public function providerInvalidValueForExtraction(): Generator { $values = [ 'boolean-false' => false, @@ -125,7 +128,8 @@ public function testExtractRejectsInvalidObject($object): void $strategy->extract($object); } - public function providerInvalidObjectForExtraction(): ?Generator + /** @return Generator */ + public function providerInvalidObjectForExtraction(): Generator { $values = [ 'boolean-false' => false, @@ -157,7 +161,7 @@ public function testExtractUsesHydratorToExtractValues(): void $hydrator = $this->createHydratorMock(); - $hydrator->expects($this->once()) + $hydrator->expects(self::once()) ->method('extract') ->willReturnCallback($extraction); @@ -166,7 +170,7 @@ public function testExtractUsesHydratorToExtractValues(): void TestAsset\User::class ); - $this->assertSame($extraction($value), $strategy->extract($value)); + self::assertSame($extraction($value), $strategy->extract($value)); } /** @@ -191,7 +195,8 @@ public function testHydrateRejectsInvalidValue($value): void $strategy->hydrate($value); } - public function providerInvalidValueForHydration(): ?Generator + /** @return Generator */ + public function providerInvalidValueForHydration(): Generator { $values = [ 'boolean-false' => false, @@ -219,10 +224,11 @@ public function testHydrateShouldReturnEmptyOrSameObjects($value): void TestAsset\User::class ); - $this->assertSame($value, $strategy->hydrate($value)); + self::assertSame($value, $strategy->hydrate($value)); } - public function providerEmptyOrSameObjects(): ?Generator + /** @return Generator */ + public function providerEmptyOrSameObjects(): Generator { $values = [ 'null' => null, @@ -254,7 +260,7 @@ public function testHydrateUsesHydratorToHydrateValues(): void $hydrator = $this->createHydratorMock(); - $hydrator->expects($this->exactly(count($value))) + $hydrator->expects(self::exactly(count($value))) ->method('hydrate') ->willReturnCallback($hydration); @@ -263,13 +269,13 @@ public function testHydrateUsesHydratorToHydrateValues(): void TestAsset\User::class ); - $this->assertEquals($hydration($value), $strategy->hydrate($value)); + self::assertEquals($hydration($value), $strategy->hydrate($value)); } /** - * @return MockObject|HydratorInterface + * @return MockObject&HydratorInterface */ - private function createHydratorMock() + private function createHydratorMock(): HydratorInterface { return $this->createMock(HydratorInterface::class); } From 32de091ec8cdd9cccfdd491b8b91db522aca34cf Mon Sep 17 00:00:00 2001 From: George Steel Date: Fri, 14 Oct 2022 12:32:07 +0100 Subject: [PATCH 6/6] Stop ignoring platform reqs on 8.1, but ignore them on 8.2 Signed-off-by: George Steel --- .laminas-ci.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.laminas-ci.json b/.laminas-ci.json index bce3fa21..7dad22d9 100644 --- a/.laminas-ci.json +++ b/.laminas-ci.json @@ -1,5 +1,6 @@ { "ignore_php_platform_requirements": { - "8.1": true + "8.1": false, + "8.2": true } }