From c452f6e5b97d047f64dd1c463cba193711887538 Mon Sep 17 00:00:00 2001 From: George Steel Date: Mon, 10 Oct 2022 22:14:19 +0100 Subject: [PATCH 1/5] Add support for PHP 8.2, Remove support for PHP 7.4 - Remove `prophecy` - Update psalm baseline Signed-off-by: George Steel --- composer.json | 13 +- composer.lock | 486 +++++++++++-------------------------- psalm-baseline.xml | 63 ++--- test/LaminasRouterTest.php | 473 ++++++++++++++++++------------------ 4 files changed, 400 insertions(+), 635 deletions(-) diff --git a/composer.json b/composer.json index 72d7c9e..6e30cf0 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "dealerdirect/phpcodesniffer-composer-installer": true }, "platform": { - "php": "7.4.99" + "php": "8.0.99" } }, "extra": { @@ -34,7 +34,7 @@ } }, "require": { - "php": "^7.4 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "fig/http-message-util": "^1.1.5", "laminas/laminas-psr7bridge": "^0.2.2 || ^1.0.0", "laminas/laminas-router": "^3.3.0", @@ -43,12 +43,11 @@ }, "require-dev": { "laminas/laminas-coding-standard": "~2.4.0", - "laminas/laminas-i18n": "~2.17", - "laminas/laminas-stratigility": "^3.8", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5.24", + "laminas/laminas-i18n": "^2.19", + "laminas/laminas-stratigility": "^3.9", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.27" + "vimeo/psalm": "^4.28" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 549d899..c7e69ff 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": "d14d9a8526a52bf302a4480d4738b27c", + "content-hash": "94b7329b188cde61f19e3c229d01b324", "packages": [ { "name": "fig/http-message-util", @@ -64,20 +64,20 @@ }, { "name": "laminas/laminas-diactoros", - "version": "2.17.0", + "version": "2.18.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-diactoros.git", - "reference": "5b32597aa46b83c8b85bb1cf9a6ed4fe7dd980c5" + "reference": "c33a4e76178a3cbdc801cc364379a8c9f1bd78ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/5b32597aa46b83c8b85bb1cf9a6ed4fe7dd980c5", - "reference": "5b32597aa46b83c8b85bb1cf9a6ed4fe7dd980c5", + "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/c33a4e76178a3cbdc801cc364379a8c9f1bd78ec", + "reference": "c33a4e76178a3cbdc801cc364379a8c9f1bd78ec", "shasum": "" }, "require": { - "php": "^7.4 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.0" }, @@ -96,9 +96,9 @@ "http-interop/http-factory-tests": "^0.9.0", "laminas/laminas-coding-standard": "^2.4.0", "php-http/psr7-integration-tests": "^1.1.1", - "phpunit/phpunit": "^9.5.23", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.24.0" + "vimeo/psalm": "^4.28" }, "type": "library", "extra": { @@ -157,36 +157,36 @@ "type": "community_bridge" } ], - "time": "2022-08-30T17:01:46+00:00" + "time": "2022-10-10T18:21:32+00:00" }, { "name": "laminas/laminas-escaper", - "version": "2.10.0", + "version": "2.12.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-escaper.git", - "reference": "58af67282db37d24e584a837a94ee55b9c7552be" + "reference": "ee7a4c37bf3d0e8c03635d5bddb5bb3184ead490" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/58af67282db37d24e584a837a94ee55b9c7552be", - "reference": "58af67282db37d24e584a837a94ee55b9c7552be", + "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/ee7a4c37bf3d0e8c03635d5bddb5bb3184ead490", + "reference": "ee7a4c37bf3d0e8c03635d5bddb5bb3184ead490", "shasum": "" }, "require": { "ext-ctype": "*", "ext-mbstring": "*", - "php": "^7.4 || ~8.0.0 || ~8.1.0" + "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "zendframework/zend-escaper": "*" }, "require-dev": { "infection/infection": "^0.26.6", - "laminas/laminas-coding-standard": "~2.3.0", + "laminas/laminas-coding-standard": "~2.4.0", "maglnet/composer-require-checker": "^3.8.0", "phpunit/phpunit": "^9.5.18", - "psalm/plugin-phpunit": "^0.16.1", + "psalm/plugin-phpunit": "^0.17.0", "vimeo/psalm": "^4.22.0" }, "type": "library", @@ -219,7 +219,7 @@ "type": "community_bridge" } ], - "time": "2022-03-08T20:15:36+00:00" + "time": "2022-10-10T10:11:09+00:00" }, { "name": "laminas/laminas-http", @@ -408,33 +408,33 @@ }, { "name": "laminas/laminas-router", - "version": "3.9.0", + "version": "3.10.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-router.git", - "reference": "ebd084f7fda7520394b9ddc1e9ec2cbdf2094daa" + "reference": "84aa1047389270cc2b05e2fe85667efb592fbf5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-router/zipball/ebd084f7fda7520394b9ddc1e9ec2cbdf2094daa", - "reference": "ebd084f7fda7520394b9ddc1e9ec2cbdf2094daa", + "url": "https://api.github.com/repos/laminas/laminas-router/zipball/84aa1047389270cc2b05e2fe85667efb592fbf5e", + "reference": "84aa1047389270cc2b05e2fe85667efb592fbf5e", "shasum": "" }, "require": { "laminas/laminas-http": "^2.15", "laminas/laminas-servicemanager": "^3.14.0", "laminas/laminas-stdlib": "^3.10.1", - "php": "^7.4 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "zendframework/zend-router": "*" }, "require-dev": { "laminas/laminas-coding-standard": "~2.4.0", - "laminas/laminas-i18n": "^2.15.0", - "phpunit/phpunit": "^9.5.5", + "laminas/laminas-i18n": "^2.17", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.24.0" + "vimeo/psalm": "^4.28" }, "suggest": { "laminas/laminas-i18n": "^2.15.0 if defining translatable HTTP path segments" @@ -475,25 +475,25 @@ "type": "community_bridge" } ], - "time": "2022-08-30T22:41:24+00:00" + "time": "2022-10-10T15:38:09+00:00" }, { "name": "laminas/laminas-servicemanager", - "version": "3.17.0", + "version": "3.18.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-servicemanager.git", - "reference": "360be5f16955dd1edbcce1cfaa98ed82a17f02ec" + "reference": "5d786a07bb4bad2a7a7c5f8255197766e6d526e2" }, "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/5d786a07bb4bad2a7a7c5f8255197766e6d526e2", + "reference": "5d786a07bb4bad2a7a7c5f8255197766e6d526e2", "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": { @@ -509,17 +509,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" @@ -566,35 +565,34 @@ "type": "community_bridge" } ], - "time": "2022-09-22T11:33:46+00:00" + "time": "2022-10-10T14:30:35+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": { @@ -626,7 +624,7 @@ "type": "community_bridge" } ], - "time": "2022-08-24T13:56:50+00:00" + "time": "2022-10-10T19:10:24+00:00" }, { "name": "laminas/laminas-uri", @@ -774,21 +772,21 @@ }, { "name": "mezzio/mezzio-router", - "version": "3.8.0", + "version": "3.9.0", "source": { "type": "git", "url": "https://github.com/mezzio/mezzio-router.git", - "reference": "27075d3e9b407791abf7ba5e62954a59be4b18df" + "reference": "5b03ab8ef9ae8323a9093d5b9d79a69a3733968f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mezzio/mezzio-router/zipball/27075d3e9b407791abf7ba5e62954a59be4b18df", - "reference": "27075d3e9b407791abf7ba5e62954a59be4b18df", + "url": "https://api.github.com/repos/mezzio/mezzio-router/zipball/5b03ab8ef9ae8323a9093d5b9d79a69a3733968f", + "reference": "5b03ab8ef9ae8323a9093d5b9d79a69a3733968f", "shasum": "" }, "require": { "fig/http-message-util": "^1.1.2", - "php": "^7.4 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "psr/container": "^1.0 || ^2.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.0.1", @@ -800,14 +798,12 @@ "zendframework/zend-expressive-router": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~2.3.0", - "laminas/laminas-diactoros": "^2.6", - "laminas/laminas-stratigility": "^3.4", - "phpspec/prophecy": "^1.9", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5.11", - "psalm/plugin-phpunit": "^0.15.0", - "vimeo/psalm": "^4.17" + "laminas/laminas-coding-standard": "~2.4.0", + "laminas/laminas-diactoros": "^2.18", + "laminas/laminas-stratigility": "^3.8", + "phpunit/phpunit": "^9.5.25", + "psalm/plugin-phpunit": "^0.17.0", + "vimeo/psalm": "^4.28" }, "suggest": { "mezzio/mezzio-aurarouter": "^3.0 to use the Aura.Router routing adapter", @@ -853,7 +849,7 @@ "type": "community_bridge" } ], - "time": "2022-01-06T16:27:49+00:00" + "time": "2022-10-10T19:40:00+00:00" }, { "name": "psr/container", @@ -1983,23 +1979,23 @@ }, { "name": "laminas/laminas-i18n", - "version": "2.17.0", + "version": "2.19.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-i18n.git", - "reference": "7e8e63353b38792f2f360dc57cfa7187be20f182" + "reference": "ebabca3a6398fc872127bc69a51bda5afc720d67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-i18n/zipball/7e8e63353b38792f2f360dc57cfa7187be20f182", - "reference": "7e8e63353b38792f2f360dc57cfa7187be20f182", + "url": "https://api.github.com/repos/laminas/laminas-i18n/zipball/ebabca3a6398fc872127bc69a51bda5afc720d67", + "reference": "ebabca3a6398fc872127bc69a51bda5afc720d67", "shasum": "" }, "require": { "ext-intl": "*", "laminas/laminas-servicemanager": "^3.14.0", "laminas/laminas-stdlib": "^2.7 || ^3.0", - "php": "^7.4 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "laminas/laminas-view": "<2.20.0", @@ -2007,19 +2003,18 @@ "zendframework/zend-i18n": "*" }, "require-dev": { - "laminas/laminas-cache": "^3.1.2", - "laminas/laminas-cache-storage-adapter-memory": "^2.0.0", - "laminas/laminas-cache-storage-deprecated-factory": "^1.0.0", - "laminas/laminas-coding-standard": "~2.3.0", - "laminas/laminas-config": "^3.4.0", + "laminas/laminas-cache": "^3.6", + "laminas/laminas-cache-storage-adapter-memory": "^2.1", + "laminas/laminas-cache-storage-deprecated-factory": "^1.0.1", + "laminas/laminas-coding-standard": "~2.4.0", + "laminas/laminas-config": "^3.7", "laminas/laminas-eventmanager": "^3.5.0", - "laminas/laminas-filter": "^2.16.0", - "laminas/laminas-validator": "^2.17.0", - "laminas/laminas-view": "^2.21.0", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5.21", + "laminas/laminas-filter": "^2.21", + "laminas/laminas-validator": "^2.25", + "laminas/laminas-view": "^2.23", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.24.0" + "vimeo/psalm": "^4.28" }, "suggest": { "laminas/laminas-cache": "You should install this package to cache the translations", @@ -2066,26 +2061,26 @@ "type": "community_bridge" } ], - "time": "2022-07-27T11:23:29+00:00" + "time": "2022-10-10T15:48:56+00:00" }, { "name": "laminas/laminas-stratigility", - "version": "3.8.0", + "version": "3.9.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-stratigility.git", - "reference": "aa47a70ed02cff6109bf09aa7c3e85c574033d81" + "reference": "b847ad3a0a9f1c09de9bcc918454cc8d36efb6aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-stratigility/zipball/aa47a70ed02cff6109bf09aa7c3e85c574033d81", - "reference": "aa47a70ed02cff6109bf09aa7c3e85c574033d81", + "url": "https://api.github.com/repos/laminas/laminas-stratigility/zipball/b847ad3a0a9f1c09de9bcc918454cc8d36efb6aa", + "reference": "b847ad3a0a9f1c09de9bcc918454cc8d36efb6aa", "shasum": "" }, "require": { "fig/http-message-util": "^1.1", "laminas/laminas-escaper": "^2.10.0", - "php": "^7.4 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "psr/http-message": "^1.0", "psr/http-server-middleware": "^1.0" }, @@ -2094,11 +2089,11 @@ "zendframework/zend-stratigility": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~2.3.0", - "laminas/laminas-diactoros": "^2.13.0", - "phpunit/phpunit": "^9.5.21", + "laminas/laminas-coding-standard": "~2.4.0", + "laminas/laminas-diactoros": "^2.18", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.24.0" + "vimeo/psalm": "^4.28" }, "suggest": { "psr/http-message-implementation": "Please install a psr/http-message-implementation to consume Stratigility; e.g., laminas/laminas-diactoros" @@ -2146,7 +2141,7 @@ "type": "community_bridge" } ], - "time": "2022-07-23T13:56:06+00:00" + "time": "2022-10-10T19:34:46+00:00" }, { "name": "myclabs/deep-copy", @@ -2638,125 +2633,6 @@ }, "time": "2022-03-15T21:29:03+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", @@ -3283,30 +3159,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/", @@ -3327,9 +3203,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", @@ -4414,46 +4290,42 @@ }, { "name": "symfony/console", - "version": "v5.4.13", + "version": "v6.0.13", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3f97f6c7b7e26848a90c0c0cfb91eeb2bb8618be" + "reference": "8f14753b865651c2aad107ef97475740a9b0730f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3f97f6c7b7e26848a90c0c0cfb91eeb2bb8618be", - "reference": "3f97f6c7b7e26848a90c0c0cfb91eeb2bb8618be", + "url": "https://api.github.com/repos/symfony/console/zipball/8f14753b865651c2aad107ef97475740a9b0730f", + "reference": "8f14753b865651c2aad107ef97475740a9b0730f", "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", @@ -4493,7 +4365,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.13" + "source": "https://github.com/symfony/console/tree/v6.0.13" }, "funding": [ { @@ -4509,29 +4381,29 @@ "type": "tidelift" } ], - "time": "2022-08-26T13:50:20+00:00" + "time": "2022-09-03T14:23:25+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", @@ -4560,7 +4432,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": [ { @@ -4576,7 +4448,7 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2022-01-02T09:55:41+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4908,85 +4780,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", @@ -5155,34 +4948,33 @@ }, { "name": "symfony/string", - "version": "v5.4.13", + "version": "v6.0.13", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "2900c668a32138a34118740de3e4d5a701801f53" + "reference": "65e99fb179e7241606377e4042cd2161f3dd1c05" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/2900c668a32138a34118740de3e4d5a701801f53", - "reference": "2900c668a32138a34118740de3e4d5a701801f53", + "url": "https://api.github.com/repos/symfony/string/zipball/65e99fb179e7241606377e4042cd2161f3dd1c05", + "reference": "65e99fb179e7241606377e4042cd2161f3dd1c05", "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": { @@ -5221,7 +5013,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.13" + "source": "https://github.com/symfony/string/tree/v6.0.13" }, "funding": [ { @@ -5237,7 +5029,7 @@ "type": "tidelift" } ], - "time": "2022-09-01T01:52:16+00:00" + "time": "2022-09-02T08:05:03+00:00" }, { "name": "theseer/tokenizer", @@ -5510,11 +5302,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 690d634..c7cec12 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + $this->allowedMethodsByPath[$params[self::METHOD_NOT_ALLOWED_ROUTE]] @@ -31,65 +31,34 @@ - - Argument::type(LaminasRequest::class) - Argument::type(LaminasRequest::class) - Argument::type(LaminasRequest::class) - Argument::type(LaminasRequest::class) - - + $routesToInject - $this->laminasRouter->reveal() $routesToInject - - willReturn - willReturn - + + array + + + $this->routesToInject + getMiddleware getMiddleware getMiddleware - - - willReturn - willReturn - - + + Closure::bind($fn, $router, LaminasRouter::class)() + Closure::bind(fn() => $this->laminasRouter, $router, LaminasRouter::class)() + + getMiddleware getMiddleware getMiddleware - willReturn - willReturn - willReturn - willReturn - willReturn - - reveal - shouldBeCalled - shouldBeCalled - shouldBeCalled - shouldBeCalled - shouldBeCalled - willReturn - willReturn - willReturn - willReturn - willReturn - - - RouteResult::fromRouteFailure() - - - RouteResult::fromRouteMatch('/foo', 'bar') - - - MiddlewareInterface - ServerRequestInterface - + + $this->routesToInject + diff --git a/test/LaminasRouterTest.php b/test/LaminasRouterTest.php index 09dfcb9..618a8a6 100644 --- a/test/LaminasRouterTest.php +++ b/test/LaminasRouterTest.php @@ -7,6 +7,7 @@ use Closure; use Fig\Http\Message\RequestMethodInterface as RequestMethod; use Laminas\Diactoros\ServerRequest; +use Laminas\Diactoros\ServerRequestFactory; use Laminas\Diactoros\Uri; use Laminas\Http\Request as LaminasRequest; use Laminas\I18n\Translator\TranslatorInterface; @@ -17,64 +18,43 @@ use Mezzio\Router\LaminasRouter; use Mezzio\Router\Route; use Mezzio\Router\RouteResult; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; -use Prophecy\PhpUnit\ProphecyTrait; -use Prophecy\Prophecy\ObjectProphecy; use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Message\UriInterface; use Psr\Http\Server\MiddlewareInterface; class LaminasRouterTest extends TestCase { - use ProphecyTrait; - - /** @var TreeRouteStack|ObjectProphecy */ - private $laminasRouter; - /** @var Route[] */ - private ?array $routesToInject = null; + /** @var TreeRouteStack&MockObject */ + private TreeRouteStack $laminasRouter; protected function setUp(): void { - $this->laminasRouter = $this->prophesize(TreeRouteStack::class); + $this->laminasRouter = $this->createMock(TreeRouteStack::class); } private function getRouter(): LaminasRouter { - return new LaminasRouter($this->laminasRouter->reveal()); + return new LaminasRouter($this->laminasRouter); } private function getMiddleware(): MiddlewareInterface { - return $this->prophesize(MiddlewareInterface::class)->reveal(); + return $this->createMock(MiddlewareInterface::class); } public function testWillLazyInstantiateALaminasTreeRouteStackIfNoneIsProvidedToConstructor(): void { $router = new LaminasRouter(); $laminasRouter = Closure::bind(fn() => $this->laminasRouter, $router, LaminasRouter::class)(); - $this->assertInstanceOf(TreeRouteStack::class, $laminasRouter); + self::assertInstanceOf(TreeRouteStack::class, $laminasRouter); } - /** - * @return ObjectProphecy - **/ - public function createRequestProphecy(string $requestMethod = RequestMethod::METHOD_GET): ObjectProphecy + private function createRequest(string $requestMethod = RequestMethod::METHOD_GET): ServerRequestInterface { - $request = $this->prophesize(ServerRequestInterface::class); - - $uri = $this->prophesize(UriInterface::class); - $uri->getPath()->willReturn('/foo'); - $uri->__toString()->willReturn('http://www.example.com/foo'); + $uri = new Uri('https://www.example.com/foo'); - $request->getMethod()->willReturn($requestMethod); - $request->getUri()->will([$uri, 'reveal']); - $request->getHeaders()->willReturn([]); - $request->getCookieParams()->willReturn([]); - $request->getQueryParams()->willReturn([]); - $request->getServerParams()->willReturn([]); - - return $request; + return (new ServerRequestFactory())->createServerRequest($requestMethod, $uri); } public function testAddingRouteAggregatesInRouter(): void @@ -83,8 +63,10 @@ public function testAddingRouteAggregatesInRouter(): void $router = $this->getRouter(); $router->addRoute($route); - $routesToInject = Closure::bind(fn() => $this->routesToInject, $router, LaminasRouter::class)(); - $this->assertContains($route, $routesToInject); + /** @psalm-var Closure(): list $fn */ + $fn = fn(): array => $this->routesToInject; + $routesToInject = Closure::bind($fn, $router, LaminasRouter::class)(); + self::assertContains($route, $routesToInject); } /** @@ -95,42 +77,45 @@ public function testMatchingInjectsRoutesInRouter(): void $middleware = $this->getMiddleware(); $route = new Route('/foo', $middleware, [RequestMethod::METHOD_GET]); - $this->laminasRouter->addRoute('/foo^GET', [ - 'type' => 'segment', - 'options' => [ - 'route' => '/foo', - ], - 'may_terminate' => false, - 'child_routes' => [ - RequestMethod::METHOD_GET => [ - 'type' => 'method', - 'options' => [ - 'verb' => RequestMethod::METHOD_GET, - 'defaults' => [ - 'middleware' => $middleware, + $this->laminasRouter->expects(self::once()) + ->method('addRoute') + ->with('/foo^GET', [ + 'type' => 'segment', + 'options' => [ + 'route' => '/foo', + ], + 'may_terminate' => false, + 'child_routes' => [ + RequestMethod::METHOD_GET => [ + 'type' => 'method', + 'options' => [ + 'verb' => RequestMethod::METHOD_GET, + 'defaults' => [ + 'middleware' => $middleware, + ], ], ], - ], - LaminasRouter::METHOD_NOT_ALLOWED_ROUTE => [ - 'type' => 'regex', - 'priority' => -1, - 'options' => [ - 'regex' => '', - 'defaults' => [ - LaminasRouter::METHOD_NOT_ALLOWED_ROUTE => '/foo', + LaminasRouter::METHOD_NOT_ALLOWED_ROUTE => [ + 'type' => 'regex', + 'priority' => -1, + 'options' => [ + 'regex' => '', + 'defaults' => [ + LaminasRouter::METHOD_NOT_ALLOWED_ROUTE => '/foo', + ], + 'spec' => '', ], - 'spec' => '', ], ], - ], - ])->shouldBeCalled(); + ]); $router = $this->getRouter(); $router->addRoute($route); - - /** @var ServerRequestInterface $request */ - $request = $this->createRequestProphecy()->reveal(); - $this->laminasRouter->match(Argument::type(LaminasRequest::class))->willReturn(null); + $request = $this->createRequest(); + $this->laminasRouter->expects(self::once()) + ->method('match') + ->with(self::isInstanceOf(LaminasRequest::class)) + ->willReturn(null); $router->match($request); } @@ -143,48 +128,57 @@ public function testGeneratingUriInjectsRoutesInRouter(): void $middleware = $this->getMiddleware(); $route = new Route('/foo', $middleware, [RequestMethod::METHOD_GET]); - $this->laminasRouter->addRoute('/foo^GET', [ - 'type' => 'segment', - 'options' => [ - 'route' => '/foo', - ], - 'may_terminate' => false, - 'child_routes' => [ - RequestMethod::METHOD_GET => [ - 'type' => 'method', - 'options' => [ - 'verb' => RequestMethod::METHOD_GET, - 'defaults' => [ - 'middleware' => $middleware, + $this->laminasRouter->expects(self::once()) + ->method('addRoute') + ->with('/foo^GET', [ + 'type' => 'segment', + 'options' => [ + 'route' => '/foo', + ], + 'may_terminate' => false, + 'child_routes' => [ + RequestMethod::METHOD_GET => [ + 'type' => 'method', + 'options' => [ + 'verb' => RequestMethod::METHOD_GET, + 'defaults' => [ + 'middleware' => $middleware, + ], ], ], - ], - LaminasRouter::METHOD_NOT_ALLOWED_ROUTE => [ - 'type' => 'regex', - 'priority' => -1, - 'options' => [ - 'regex' => '', - 'defaults' => [ - LaminasRouter::METHOD_NOT_ALLOWED_ROUTE => '/foo', + LaminasRouter::METHOD_NOT_ALLOWED_ROUTE => [ + 'type' => 'regex', + 'priority' => -1, + 'options' => [ + 'regex' => '', + 'defaults' => [ + LaminasRouter::METHOD_NOT_ALLOWED_ROUTE => '/foo', + ], + 'spec' => '', ], - 'spec' => '', ], ], - ], - ])->shouldBeCalled(); - $this->laminasRouter->hasRoute('foo')->willReturn(true); - $this->laminasRouter->assemble( - [], - [ - 'name' => 'foo', - 'only_return_path' => true, - ] - )->willReturn('/foo'); + ]); + + $this->laminasRouter->expects(self::once()) + ->method('hasRoute') + ->with('foo') + ->willReturn(true); + $this->laminasRouter->expects(self::once()) + ->method('assemble') + ->with( + [], + [ + 'name' => 'foo', + 'only_return_path' => true, + ] + ) + ->willReturn('/foo'); $router = $this->getRouter(); $router->addRoute($route); - $this->assertEquals('/foo', $router->generateUri('foo')); + self::assertEquals('/foo', $router->generateUri('foo')); } public function testCanSpecifyRouteOptions(): void @@ -200,72 +194,64 @@ public function testCanSpecifyRouteOptions(): void ], ]); - $this->laminasRouter->addRoute('/foo/:id^GET', [ - 'type' => 'segment', - 'options' => [ - 'route' => '/foo/:id', - 'constraints' => [ - 'id' => '\d+', - ], - 'defaults' => [ - 'bar' => 'baz', + $this->laminasRouter->expects(self::once()) + ->method('addRoute') + ->with('/foo/:id^GET', [ + 'type' => 'segment', + 'options' => [ + 'route' => '/foo/:id', + 'constraints' => [ + 'id' => '\d+', + ], + 'defaults' => [ + 'bar' => 'baz', + ], ], - ], - 'may_terminate' => false, - 'child_routes' => [ - RequestMethod::METHOD_GET => [ - 'type' => 'method', - 'options' => [ - 'verb' => RequestMethod::METHOD_GET, - 'defaults' => [ - 'middleware' => $middleware, + 'may_terminate' => false, + 'child_routes' => [ + RequestMethod::METHOD_GET => [ + 'type' => 'method', + 'options' => [ + 'verb' => RequestMethod::METHOD_GET, + 'defaults' => [ + 'middleware' => $middleware, + ], ], ], - ], - LaminasRouter::METHOD_NOT_ALLOWED_ROUTE => [ - 'type' => 'regex', - 'priority' => -1, - 'options' => [ - 'regex' => '', - 'defaults' => [ - LaminasRouter::METHOD_NOT_ALLOWED_ROUTE => '/foo/:id', + LaminasRouter::METHOD_NOT_ALLOWED_ROUTE => [ + 'type' => 'regex', + 'priority' => -1, + 'options' => [ + 'regex' => '', + 'defaults' => [ + LaminasRouter::METHOD_NOT_ALLOWED_ROUTE => '/foo/:id', + ], + 'spec' => '', ], - 'spec' => '', ], ], - ], - ])->shouldBeCalled(); - - $this->laminasRouter->hasRoute('foo')->willReturn(true); - $this->laminasRouter->assemble( - [], - [ - 'name' => 'foo', - 'only_return_path' => true, - ] - )->willReturn('/foo'); + ]); + + $this->laminasRouter->expects(self::once()) + ->method('hasRoute') + ->with('foo') + ->willReturn(true); + $this->laminasRouter->expects(self::once()) + ->method('assemble') + ->with( + [], + [ + 'name' => 'foo', + 'only_return_path' => true, + ] + ) + ->willReturn('/foo'); $router = $this->getRouter(); $router->addRoute($route); $router->generateUri('foo'); } - public function routeResults(): array - { - /** @var MiddlewareInterface $middleware */ - $middleware = $this->prophesize(MiddlewareInterface::class)->reveal(); - return [ - 'success' => [ - new Route('/foo', $middleware), - RouteResult::fromRouteMatch('/foo', 'bar'), - ], - 'failure' => [ - new Route('/foo', $middleware), - RouteResult::fromRouteFailure(), - ], - ]; - } - public function testMatch(): void { $middleware = $this->getMiddleware(); @@ -281,35 +267,30 @@ public function testMatch(): void ); $result = $laminasRouter->match($request); - $this->assertInstanceOf(RouteResult::class, $result); - $this->assertEquals('/foo^GET', $result->getMatchedRouteName()); - $this->assertEquals($middleware, $result->getMatchedRoute()->getMiddleware()); + self::assertInstanceOf(RouteResult::class, $result); + self::assertEquals('/foo^GET', $result->getMatchedRouteName()); + self::assertEquals($middleware, $result->getMatchedRoute()->getMiddleware()); } public function testReturnsRouteFailureForRouteInjectedManuallyIntoBaseRouterButNotRouterBridge(): void { - $uri = $this->prophesize(UriInterface::class); - $uri->getPath()->willReturn('/foo'); - - $request = new ServerRequest( - ['REQUEST_METHOD' => RequestMethod::METHOD_GET], - [], - '/foo', - RequestMethod::METHOD_GET - ); + $request = $this->createRequest(); $laminasRequest = Psr7ServerRequest::toLaminas($request); $routeMatch = new \Laminas\Router\Http\RouteMatch([], 4); $routeMatch->setMatchedRouteName('/foo'); - $this->laminasRouter->match($laminasRequest)->willReturn($routeMatch); + $this->laminasRouter->expects(self::once()) + ->method('match') + ->with($laminasRequest) + ->willReturn($routeMatch); $router = $this->getRouter(); $result = $router->match($request); - $this->assertInstanceOf(RouteResult::class, $result); - $this->assertTrue($result->isFailure()); - $this->assertFalse($result->isMethodFailure()); + self::assertInstanceOf(RouteResult::class, $result); + self::assertTrue($result->isFailure()); + self::assertFalse($result->isMethodFailure()); } public function testMatchedRouteNameWhenGetMethodAllowed(): void @@ -326,10 +307,10 @@ public function testMatchedRouteNameWhenGetMethodAllowed(): void RequestMethod::METHOD_GET ); $result = $laminasRouter->match($request); - $this->assertInstanceOf(RouteResult::class, $result); - $this->assertTrue($result->isSuccess()); - $this->assertSame('/foo', $result->getMatchedRouteName()); - $this->assertSame($middleware, $result->getMatchedRoute()->getMiddleware()); + self::assertInstanceOf(RouteResult::class, $result); + self::assertTrue($result->isSuccess()); + self::assertSame('/foo', $result->getMatchedRouteName()); + self::assertSame($middleware, $result->getMatchedRoute()->getMiddleware()); } /** @@ -337,29 +318,39 @@ public function testMatchedRouteNameWhenGetMethodAllowed(): void */ public function testSuccessfulMatchIsPossible(): void { - $routeMatch = $this->prophesize(RouteMatch::class); - $routeMatch->getMatchedRouteName()->willReturn('/foo'); - $routeMatch->getParams()->willReturn([ - 'middleware' => 'bar', - ]); - - $this->laminasRouter - ->match(Argument::type(LaminasRequest::class)) - ->willReturn($routeMatch->reveal()); - $this->laminasRouter - ->addRoute('/foo', Argument::type('array')) - ->shouldBeCalled(); - - $request = $this->createRequestProphecy(); + $routeMatch = $this->createMock(RouteMatch::class); + $routeMatch->expects(self::once()) + ->method('getMatchedRouteName') + ->willReturn('/foo'); + $routeMatch->expects(self::once()) + ->method('getParams') + ->willReturn([ + 'middleware' => 'bar', + ]); + + $this->laminasRouter->expects(self::once()) + ->method('match') + ->with(self::isInstanceOf(LaminasRequest::class)) + ->willReturn($routeMatch); + + $this->laminasRouter->expects(self::once()) + ->method('addRoute') + ->with('/foo', self::callback(function ($arg): bool { + self::assertIsArray($arg); + + return true; + })); + + $request = $this->createRequest(); $middleware = $this->getMiddleware(); $router = $this->getRouter(); $router->addRoute(new Route('/foo', $middleware, [RequestMethod::METHOD_GET], '/foo')); - $result = $router->match($request->reveal()); - $this->assertInstanceOf(RouteResult::class, $result); - $this->assertTrue($result->isSuccess()); - $this->assertSame('/foo', $result->getMatchedRouteName()); - $this->assertSame($middleware, $result->getMatchedRoute()->getMiddleware()); + $result = $router->match($request); + self::assertInstanceOf(RouteResult::class, $result); + self::assertTrue($result->isSuccess()); + self::assertSame('/foo', $result->getMatchedRouteName()); + self::assertSame($middleware, $result->getMatchedRoute()->getMiddleware()); } /** @@ -367,17 +358,18 @@ public function testSuccessfulMatchIsPossible(): void */ public function testNonSuccessfulMatchNotDueToHttpMethodsIsPossible(): void { - $this->laminasRouter - ->match(Argument::type(LaminasRequest::class)) + $this->laminasRouter->expects(self::once()) + ->method('match') + ->with(self::isInstanceOf(LaminasRequest::class)) ->willReturn(null); - $request = $this->createRequestProphecy(); + $request = $this->createRequest(); $router = $this->getRouter(); - $result = $router->match($request->reveal()); - $this->assertInstanceOf(RouteResult::class, $result); - $this->assertTrue($result->isFailure()); - $this->assertFalse($result->isMethodFailure()); + $result = $router->match($request); + self::assertInstanceOf(RouteResult::class, $result); + self::assertTrue($result->isFailure()); + self::assertFalse($result->isMethodFailure()); } /** @@ -399,10 +391,10 @@ public function testMatchFailureDueToHttpMethodReturnsRouteResultWithAllowedMeth ); $result = $router->match($request); - $this->assertInstanceOf(RouteResult::class, $result); - $this->assertTrue($result->isFailure()); - $this->assertTrue($result->isMethodFailure()); - $this->assertEquals([RequestMethod::METHOD_POST, RequestMethod::METHOD_DELETE], $result->getAllowedMethods()); + self::assertInstanceOf(RouteResult::class, $result); + self::assertTrue($result->isFailure()); + self::assertTrue($result->isMethodFailure()); + self::assertEquals([RequestMethod::METHOD_POST, RequestMethod::METHOD_DELETE], $result->getAllowedMethods()); } /** @@ -424,10 +416,10 @@ public function testMatchFailureDueToMethodNotAllowedWithParamsInTheRoute(): voi ); $result = $router->match($request); - $this->assertInstanceOf(RouteResult::class, $result); - $this->assertTrue($result->isFailure()); - $this->assertTrue($result->isMethodFailure()); - $this->assertEquals([RequestMethod::METHOD_POST, RequestMethod::METHOD_DELETE], $result->getAllowedMethods()); + self::assertInstanceOf(RouteResult::class, $result); + self::assertTrue($result->isFailure()); + self::assertTrue($result->isMethodFailure()); + self::assertEquals([RequestMethod::METHOD_POST, RequestMethod::METHOD_DELETE], $result->getAllowedMethods()); } /** @@ -446,10 +438,10 @@ public function testCanGenerateUriFromRoutes(): void $router->addRoute($route3); $router->addRoute($route4); - $this->assertEquals('/foo', $router->generateUri('foo-create')); - $this->assertEquals('/foo', $router->generateUri('foo-list')); - $this->assertEquals('/foo/bar', $router->generateUri('foo', ['id' => 'bar'])); - $this->assertEquals('/bar/BAZ', $router->generateUri('bar', ['baz' => 'BAZ'])); + self::assertEquals('/foo', $router->generateUri('foo-create')); + self::assertEquals('/foo', $router->generateUri('foo-list')); + self::assertEquals('/foo/bar', $router->generateUri('foo', ['id' => 'bar'])); + self::assertEquals('/bar/BAZ', $router->generateUri('bar', ['baz' => 'BAZ'])); } /** @@ -468,37 +460,47 @@ public function testPassingTrailingSlashToRouteNotExpectingItResultsIn404Failure RequestMethod::METHOD_GET ); $result = $router->match($request); - $this->assertTrue($result->isFailure()); - $this->assertFalse($result->isMethodFailure()); + self::assertTrue($result->isFailure()); + self::assertFalse($result->isMethodFailure()); } public function testSuccessfulMatchingComposesRouteInRouteResult(): void { $route = new Route('/foo', $this->getMiddleware(), [RequestMethod::METHOD_GET]); - $routeMatch = $this->prophesize(RouteMatch::class); - $routeMatch->getMatchedRouteName()->willReturn($route->getName()); - $routeMatch->getParams()->willReturn([ - 'middleware' => $route->getMiddleware(), - ]); + $routeMatch = $this->createMock(RouteMatch::class); + $routeMatch->expects(self::once()) + ->method('getMatchedRouteName') + ->willReturn($route->getName()); + + $routeMatch->expects(self::once()) + ->method('getParams') + ->willReturn([ + 'middleware' => $route->getMiddleware(), + ]); + + $this->laminasRouter->expects(self::once()) + ->method('match') + ->with(self::isInstanceOf(LaminasRequest::class)) + ->willReturn($routeMatch); + $this->laminasRouter->expects(self::once()) + ->method('addRoute') + ->with('/foo^GET', self::callback(static function (mixed $arg): bool { + self::assertIsArray($arg); - $this->laminasRouter - ->match(Argument::type(LaminasRequest::class)) - ->willReturn($routeMatch->reveal()); - $this->laminasRouter - ->addRoute('/foo^GET', Argument::type('array')) - ->shouldBeCalled(); + return true; + })); - $request = $this->createRequestProphecy(); + $request = $this->createRequest(); $router = $this->getRouter(); $router->addRoute($route); - $result = $router->match($request->reveal()); + $result = $router->match($request); - $this->assertInstanceOf(RouteResult::class, $result); - $this->assertTrue($result->isSuccess()); - $this->assertSame($route, $result->getMatchedRoute()); + self::assertInstanceOf(RouteResult::class, $result); + self::assertTrue($result->isSuccess()); + self::assertSame($route, $result->getMatchedRoute()); } /** @@ -522,12 +524,12 @@ public function testRoutesCanMatchImplicitHeadAndOptionsRequests(string $method) $router = new LaminasRouter(); $router->addRoute($route); - $request = $this->createRequestProphecy($method); - $result = $router->match($request->reveal()); + $request = $this->createRequest($method); + $result = $router->match($request); - $this->assertInstanceOf(RouteResult::class, $result); - $this->assertFalse($result->isSuccess()); - $this->assertSame([RequestMethod::METHOD_PUT], $result->getAllowedMethods()); + self::assertInstanceOf(RouteResult::class, $result); + self::assertFalse($result->isSuccess()); + self::assertSame([RequestMethod::METHOD_PUT], $result->getAllowedMethods()); } public function testUriGenerationMayUseOptions(): void @@ -537,16 +539,19 @@ public function testUriGenerationMayUseOptions(): void $router = new LaminasRouter(); $router->addRoute($route); - $translator = $this->prophesize(TranslatorInterface::class); - $translator->translate('lang', 'uri', 'de')->willReturn('found'); + $translator = $this->createMock(TranslatorInterface::class); + $translator->expects(self::once()) + ->method('translate') + ->with('lang', 'uri', 'de') + ->willReturn('found'); $uri = $router->generateUri('test', [], [ - 'translator' => $translator->reveal(), + 'translator' => $translator, 'locale' => 'de', 'text_domain' => 'uri', ]); - $this->assertEquals('/de/found', $uri); + self::assertEquals('/de/found', $uri); } public function testGenerateUriRaisesExceptionForNotFoundRoute(): void @@ -572,6 +577,6 @@ public function testMatchReturnsRouteFailureOnFailureToConvertPsr7Request(): voi $result = $router->match($serverRequest); - $this->assertTrue($result->isFailure()); + self::assertTrue($result->isFailure()); } } From 78a421d564fed82780b21495e91de5a95ae174d9 Mon Sep 17 00:00:00 2001 From: George Steel Date: Mon, 10 Oct 2022 22:21:59 +0100 Subject: [PATCH 2/5] Bump minimum version of mezzio-router to exclude prophecy Signed-off-by: George Steel --- composer.json | 2 +- composer.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 6e30cf0..2136867 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "fig/http-message-util": "^1.1.5", "laminas/laminas-psr7bridge": "^0.2.2 || ^1.0.0", "laminas/laminas-router": "^3.3.0", - "mezzio/mezzio-router": "^3.2", + "mezzio/mezzio-router": "^3.9", "psr/http-message": "^1.0.1" }, "require-dev": { diff --git a/composer.lock b/composer.lock index c7e69ff..48e4b9a 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": "94b7329b188cde61f19e3c229d01b324", + "content-hash": "a94b08a2a27e6e129138178266a6236d", "packages": [ { "name": "fig/http-message-util", @@ -479,16 +479,16 @@ }, { "name": "laminas/laminas-servicemanager", - "version": "3.18.0", + "version": "3.19.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-servicemanager.git", - "reference": "5d786a07bb4bad2a7a7c5f8255197766e6d526e2" + "reference": "ed160729bb8721127efdaac799f9a298963345b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/5d786a07bb4bad2a7a7c5f8255197766e6d526e2", - "reference": "5d786a07bb4bad2a7a7c5f8255197766e6d526e2", + "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/ed160729bb8721127efdaac799f9a298963345b1", + "reference": "ed160729bb8721127efdaac799f9a298963345b1", "shasum": "" }, "require": { @@ -565,7 +565,7 @@ "type": "community_bridge" } ], - "time": "2022-10-10T14:30:35+00:00" + "time": "2022-10-10T20:59:22+00:00" }, { "name": "laminas/laminas-stdlib", From 61beab1b6134287c871b6d17e8a6684f2b4bcd39 Mon Sep 17 00:00:00 2001 From: George Steel Date: Mon, 10 Oct 2022 22:25:01 +0100 Subject: [PATCH 3/5] Ignore platform reqs on 8.2 for `laminas-http` 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 89d56ca..9b09973 100644 --- a/.laminas-ci.json +++ b/.laminas-ci.json @@ -1,6 +1,7 @@ { "ignore_php_platform_requirements": { "8.0": false, - "8.1": false + "8.1": false, + "8.2": true } } From e89679320ce230b3b2d2e027177f781d3d4e0fc7 Mon Sep 17 00:00:00 2001 From: George Steel Date: Mon, 10 Oct 2022 22:31:53 +0100 Subject: [PATCH 4/5] Bump minimum version of `laminas-router`. `laminas/laminas-psr7bridge` at `^0.x` is no longer installable Signed-off-by: George Steel --- composer.json | 4 ++-- composer.lock | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 2136867..446dcdc 100644 --- a/composer.json +++ b/composer.json @@ -36,8 +36,8 @@ "require": { "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "fig/http-message-util": "^1.1.5", - "laminas/laminas-psr7bridge": "^0.2.2 || ^1.0.0", - "laminas/laminas-router": "^3.3.0", + "laminas/laminas-psr7bridge": "^1.0.0", + "laminas/laminas-router": "^3.10.0", "mezzio/mezzio-router": "^3.9", "psr/http-message": "^1.0.1" }, diff --git a/composer.lock b/composer.lock index 48e4b9a..ece24a4 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": "a94b08a2a27e6e129138178266a6236d", + "content-hash": "db24dc4714d7ca9823d49d6ab1200699", "packages": [ { "name": "fig/http-message-util", @@ -64,16 +64,16 @@ }, { "name": "laminas/laminas-diactoros", - "version": "2.18.0", + "version": "2.19.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-diactoros.git", - "reference": "c33a4e76178a3cbdc801cc364379a8c9f1bd78ec" + "reference": "b3c7e9262b4fbec801d8df2370cdebb4f5d3a0ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/c33a4e76178a3cbdc801cc364379a8c9f1bd78ec", - "reference": "c33a4e76178a3cbdc801cc364379a8c9f1bd78ec", + "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/b3c7e9262b4fbec801d8df2370cdebb4f5d3a0ae", + "reference": "b3c7e9262b4fbec801d8df2370cdebb4f5d3a0ae", "shasum": "" }, "require": { @@ -157,7 +157,7 @@ "type": "community_bridge" } ], - "time": "2022-10-10T18:21:32+00:00" + "time": "2022-10-10T21:28:03+00:00" }, { "name": "laminas/laminas-escaper", From 26c4625c930fb31abe8494c70997408b7126290c Mon Sep 17 00:00:00 2001 From: George Steel Date: Mon, 10 Oct 2022 22:36:32 +0100 Subject: [PATCH 5/5] Require `laminas-diactoros` as a dev dependency Prevents older versions being installed in dev where ServerRequestFactory is abstract Signed-off-by: George Steel --- composer.json | 1 + composer.lock | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 446dcdc..3635fc9 100644 --- a/composer.json +++ b/composer.json @@ -43,6 +43,7 @@ }, "require-dev": { "laminas/laminas-coding-standard": "~2.4.0", + "laminas/laminas-diactoros": "^2.19", "laminas/laminas-i18n": "^2.19", "laminas/laminas-stratigility": "^3.9", "phpunit/phpunit": "^9.5.25", diff --git a/composer.lock b/composer.lock index ece24a4..92e35bf 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": "db24dc4714d7ca9823d49d6ab1200699", + "content-hash": "83e3da84ea88790f5c6113dfde4d68de", "packages": [ { "name": "fig/http-message-util",