From 1b4a5cecad6c0aadfeac2b990d4dd4202c90e951 Mon Sep 17 00:00:00 2001 From: Craig Wann Date: Wed, 15 May 2024 12:36:32 -0500 Subject: [PATCH] Adding php 7.4 support. --- composer.json | 6 +- composer.lock | 288 +++++++++--------- phpunit.xml | 28 +- src/Factories/ConditionFactory.php | 2 +- src/Factories/Conditions/HasCapFactory.php | 2 +- src/Factories/DispatcherFactory.php | 2 +- src/Factories/Factory.php | 2 +- .../Middleware/UserHasCapFactory.php | 2 +- src/Factories/RedirectResponseFactory.php | 2 +- src/Factories/ResponseFactory.php | 2 +- src/FastRoute/Routes.php | 3 +- src/Middleware/DispatchController.php | 16 +- src/Middleware/UserHasCap.php | 2 +- tests/DispatchMiddlewareTest.php | 104 +++---- 14 files changed, 236 insertions(+), 225 deletions(-) diff --git a/composer.json b/composer.json index 10fc53a..77666b1 100644 --- a/composer.json +++ b/composer.json @@ -39,6 +39,10 @@ "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true - } + }, + "platform": { + "php": "7.4" + }, + "platform-check": false } } diff --git a/composer.lock b/composer.lock index 2239893..280cf4f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,30 +4,30 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2e4aa8836c2c7d6f6ebb3f77c4807c7c", + "content-hash": "7e3ff7788f2f5a622323e54a36d6ecaf", "packages": [ { "name": "carbonphp/carbon-doctrine-types", - "version": "3.2.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/CarbonPHP/carbon-doctrine-types.git", - "reference": "18ba5ddfec8976260ead6e866180bd5d2f71aa1d" + "reference": "99f76ffa36cce3b70a4a6abce41dba15ca2e84cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/CarbonPHP/carbon-doctrine-types/zipball/18ba5ddfec8976260ead6e866180bd5d2f71aa1d", - "reference": "18ba5ddfec8976260ead6e866180bd5d2f71aa1d", + "url": "https://api.github.com/repos/CarbonPHP/carbon-doctrine-types/zipball/99f76ffa36cce3b70a4a6abce41dba15ca2e84cb", + "reference": "99f76ffa36cce3b70a4a6abce41dba15ca2e84cb", "shasum": "" }, "require": { - "php": "^8.1" + "php": "^7.4 || ^8.0" }, "conflict": { - "doctrine/dbal": "<4.0.0 || >=5.0.0" + "doctrine/dbal": "<3.7.0 || >=4.0.0" }, "require-dev": { - "doctrine/dbal": "^4.0.0", + "doctrine/dbal": "^3.7.0", "nesbot/carbon": "^2.71.0 || ^3.0.0", "phpunit/phpunit": "^10.3" }, @@ -57,7 +57,7 @@ ], "support": { "issues": "https://github.com/CarbonPHP/carbon-doctrine-types/issues", - "source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/3.2.0" + "source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/2.1.0" }, "funding": [ { @@ -73,7 +73,7 @@ "type": "tidelift" } ], - "time": "2024-02-09T16:56:22+00:00" + "time": "2023-12-11T17:09:12+00:00" }, { "name": "doctrine/inflector", @@ -914,30 +914,30 @@ }, { "name": "psr/log", - "version": "2.0.0", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376" + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/ef29f6d262798707a9edd554e2b82517ef3a9376", - "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", "shasum": "" }, "require": { - "php": ">=8.0.0" + "php": ">=5.3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "src" + "Psr\\Log\\": "Psr/Log/" } }, "notification-url": "https://packagist.org/downloads/", @@ -958,9 +958,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/2.0.0" + "source": "https://github.com/php-fig/log/tree/1.1.4" }, - "time": "2021-07-14T16:41:46+00:00" + "time": "2021-05-03T11:20:27+00:00" }, { "name": "psr/simple-cache", @@ -1015,25 +1015,25 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.5.0", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + "reference": "80d075412b557d41002320b96a096ca65aa2c98d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", + "reference": "80d075412b557d41002320b96a096ca65aa2c98d", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.5-dev" + "dev-main": "2.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -1062,7 +1062,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" }, "funding": [ { @@ -1078,34 +1078,31 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2023-01-24T14:02:46+00:00" }, { "name": "symfony/error-handler", - "version": "v6.3.12", + "version": "v5.4.39", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "93a8400a7eaaaf385b2d6f71e30e064baa639629" + "reference": "9e02a6e831d6c2dbc5f96c8ff5314d453ecd53cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/93a8400a7eaaaf385b2d6f71e30e064baa639629", - "reference": "93a8400a7eaaaf385b2d6f71e30e064baa639629", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/9e02a6e831d6c2dbc5f96c8ff5314d453ecd53cd", + "reference": "9e02a6e831d6c2dbc5f96c8ff5314d453ecd53cd", "shasum": "" }, "require": { - "php": ">=8.1", + "php": ">=7.2.5", "psr/log": "^1|^2|^3", - "symfony/var-dumper": "^5.4|^6.0" - }, - "conflict": { - "symfony/deprecation-contracts": "<2.5" + "symfony/var-dumper": "^4.4|^5.0|^6.0" }, "require-dev": { - "symfony/deprecation-contracts": "^2.5|^3", - "symfony/http-kernel": "^5.4|^6.0", - "symfony/serializer": "^5.4|^6.0" + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/http-kernel": "^4.4|^5.0|^6.0", + "symfony/serializer": "^4.4|^5.0|^6.0" }, "bin": [ "Resources/bin/patch-type-declarations" @@ -1136,7 +1133,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v6.3.12" + "source": "https://github.com/symfony/error-handler/tree/v5.4.39" }, "funding": [ { @@ -1152,43 +1149,48 @@ "type": "tidelift" } ], - "time": "2024-01-23T14:35:58+00:00" + "time": "2024-04-18T08:26:06+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v6.4.7", + "version": "v5.4.39", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "d84384f3f67de3cb650db64d685d70395dacfc3f" + "reference": "d40fae9fd85c762b6ba378152fdd1157a85d7e4f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d84384f3f67de3cb650db64d685d70395dacfc3f", - "reference": "d84384f3f67de3cb650db64d685d70395dacfc3f", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d40fae9fd85c762b6ba378152fdd1157a85d7e4f", + "reference": "d40fae9fd85c762b6ba378152fdd1157a85d7e4f", "shasum": "" }, "require": { - "php": ">=8.1", - "symfony/event-dispatcher-contracts": "^2.5|^3" + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/event-dispatcher-contracts": "^2|^3", + "symfony/polyfill-php80": "^1.16" }, "conflict": { - "symfony/dependency-injection": "<5.4", - "symfony/service-contracts": "<2.5" + "symfony/dependency-injection": "<4.4" }, "provide": { "psr/event-dispatcher-implementation": "1.0", - "symfony/event-dispatcher-implementation": "2.0|3.0" + "symfony/event-dispatcher-implementation": "2.0" }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^5.4|^6.0|^7.0", - "symfony/dependency-injection": "^5.4|^6.0|^7.0", - "symfony/error-handler": "^5.4|^6.0|^7.0", - "symfony/expression-language": "^5.4|^6.0|^7.0", - "symfony/http-foundation": "^5.4|^6.0|^7.0", - "symfony/service-contracts": "^2.5|^3", - "symfony/stopwatch": "^5.4|^6.0|^7.0" + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/http-foundation": "^4.4|^5.0|^6.0", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/stopwatch": "^4.4|^5.0|^6.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" }, "type": "library", "autoload": { @@ -1216,7 +1218,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.7" + "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.39" }, "funding": [ { @@ -1232,30 +1234,33 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-04-18T08:26:06+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v3.5.0", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "8f93aec25d41b72493c6ddff14e916177c9efc50" + "reference": "540f4c73e87fd0c71ca44a6aa305d024ac68cb73" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/8f93aec25d41b72493c6ddff14e916177c9efc50", - "reference": "8f93aec25d41b72493c6ddff14e916177c9efc50", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/540f4c73e87fd0c71ca44a6aa305d024ac68cb73", + "reference": "540f4c73e87fd0c71ca44a6aa305d024ac68cb73", "shasum": "" }, "require": { - "php": ">=8.1", + "php": ">=7.2.5", "psr/event-dispatcher": "^1" }, + "suggest": { + "symfony/event-dispatcher-implementation": "" + }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.5-dev" + "dev-main": "2.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -1292,7 +1297,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.3" }, "funding": [ { @@ -1308,7 +1313,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-01-23T13:51:25+00:00" }, { "name": "symfony/finder", @@ -2202,51 +2207,53 @@ }, { "name": "symfony/translation", - "version": "v6.4.7", + "version": "v5.4.39", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "7495687c58bfd88b7883823747b0656d90679123" + "reference": "0fabede35e3985c4f96089edeeefe8313e15ca3a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/7495687c58bfd88b7883823747b0656d90679123", - "reference": "7495687c58bfd88b7883823747b0656d90679123", + "url": "https://api.github.com/repos/symfony/translation/zipball/0fabede35e3985c4f96089edeeefe8313e15ca3a", + "reference": "0fabede35e3985c4f96089edeeefe8313e15ca3a", "shasum": "" }, "require": { - "php": ">=8.1", - "symfony/deprecation-contracts": "^2.5|^3", + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.0", - "symfony/translation-contracts": "^2.5|^3.0" + "symfony/polyfill-php80": "^1.16", + "symfony/translation-contracts": "^2.3" }, "conflict": { - "symfony/config": "<5.4", - "symfony/console": "<5.4", - "symfony/dependency-injection": "<5.4", - "symfony/http-client-contracts": "<2.5", - "symfony/http-kernel": "<5.4", - "symfony/service-contracts": "<2.5", - "symfony/twig-bundle": "<5.4", - "symfony/yaml": "<5.4" + "symfony/config": "<4.4", + "symfony/console": "<5.3", + "symfony/dependency-injection": "<5.0", + "symfony/http-kernel": "<5.0", + "symfony/twig-bundle": "<5.0", + "symfony/yaml": "<4.4" }, "provide": { - "symfony/translation-implementation": "2.3|3.0" + "symfony/translation-implementation": "2.3" }, "require-dev": { - "nikic/php-parser": "^4.18|^5.0", "psr/log": "^1|^2|^3", - "symfony/config": "^5.4|^6.0|^7.0", - "symfony/console": "^5.4|^6.0|^7.0", - "symfony/dependency-injection": "^5.4|^6.0|^7.0", - "symfony/finder": "^5.4|^6.0|^7.0", - "symfony/http-client-contracts": "^2.5|^3.0", - "symfony/http-kernel": "^5.4|^6.0|^7.0", - "symfony/intl": "^5.4|^6.0|^7.0", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/console": "^5.4|^6.0", + "symfony/dependency-injection": "^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/http-client-contracts": "^1.1|^2.0|^3.0", + "symfony/http-kernel": "^5.0|^6.0", + "symfony/intl": "^4.4|^5.0|^6.0", "symfony/polyfill-intl-icu": "^1.21", - "symfony/routing": "^5.4|^6.0|^7.0", - "symfony/service-contracts": "^2.5|^3", - "symfony/yaml": "^5.4|^6.0|^7.0" + "symfony/service-contracts": "^1.1.2|^2|^3", + "symfony/yaml": "^4.4|^5.0|^6.0" + }, + "suggest": { + "psr/log-implementation": "To use logging capability in translator", + "symfony/config": "", + "symfony/yaml": "" }, "type": "library", "autoload": { @@ -2277,7 +2284,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v6.4.7" + "source": "https://github.com/symfony/translation/tree/v5.4.39" }, "funding": [ { @@ -2293,29 +2300,32 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-04-18T08:26:06+00:00" }, { "name": "symfony/translation-contracts", - "version": "v3.5.0", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "b9d2189887bb6b2e0367a9fc7136c5239ab9b05a" + "reference": "b0073a77ac0b7ea55131020e87b1e3af540f4664" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/b9d2189887bb6b2e0367a9fc7136c5239ab9b05a", - "reference": "b9d2189887bb6b2e0367a9fc7136c5239ab9b05a", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/b0073a77ac0b7ea55131020e87b1e3af540f4664", + "reference": "b0073a77ac0b7ea55131020e87b1e3af540f4664", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.2.5" + }, + "suggest": { + "symfony/translation-implementation": "" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.5-dev" + "dev-main": "2.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -2325,10 +2335,7 @@ "autoload": { "psr-4": { "Symfony\\Contracts\\Translation\\": "" - }, - "exclude-from-classmap": [ - "/Test/" - ] + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2355,7 +2362,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/translation-contracts/tree/v2.5.3" }, "funding": [ { @@ -2371,39 +2378,43 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-01-23T13:51:25+00:00" }, { "name": "symfony/var-dumper", - "version": "v6.4.7", + "version": "v5.4.39", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "7a9cd977cd1c5fed3694bee52990866432af07d7" + "reference": "1987f86ad7f339fe3d3e8e6cf3b7ce4d4b8e547e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/7a9cd977cd1c5fed3694bee52990866432af07d7", - "reference": "7a9cd977cd1c5fed3694bee52990866432af07d7", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/1987f86ad7f339fe3d3e8e6cf3b7ce4d4b8e547e", + "reference": "1987f86ad7f339fe3d3e8e6cf3b7ce4d4b8e547e", "shasum": "" }, "require": { - "php": ">=8.1", - "symfony/deprecation-contracts": "^2.5|^3", - "symfony/polyfill-mbstring": "~1.0" + "php": ">=7.2.5", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.16" }, "conflict": { - "symfony/console": "<5.4" + "symfony/console": "<4.4" }, "require-dev": { "ext-iconv": "*", - "symfony/console": "^5.4|^6.0|^7.0", - "symfony/error-handler": "^6.3|^7.0", - "symfony/http-kernel": "^5.4|^6.0|^7.0", - "symfony/process": "^5.4|^6.0|^7.0", - "symfony/uid": "^5.4|^6.0|^7.0", + "symfony/console": "^4.4|^5.0|^6.0", + "symfony/http-kernel": "^4.4|^5.0|^6.0", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/uid": "^5.1|^6.0", "twig/twig": "^2.13|^3.0.4" }, + "suggest": { + "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).", + "ext-intl": "To show region name in time zone dump", + "symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script" + }, "bin": [ "Resources/bin/var-dump-server" ], @@ -2440,7 +2451,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.4.7" + "source": "https://github.com/symfony/var-dumper/tree/v5.4.39" }, "funding": [ { @@ -2456,7 +2467,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-04-18T08:26:06+00:00" }, { "name": "voku/portable-ascii", @@ -2614,30 +2625,30 @@ }, { "name": "doctrine/instantiator", - "version": "2.0.0", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", - "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", "shasum": "" }, "require": { - "php": "^8.1" + "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^11", + "doctrine/coding-standard": "^9 || ^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^1.2", - "phpstan/phpstan": "^1.9.4", - "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.5.27", - "vimeo/psalm": "^5.4" + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.30 || ^5.4" }, "type": "library", "autoload": { @@ -2664,7 +2675,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/2.0.0" + "source": "https://github.com/doctrine/instantiator/tree/1.5.0" }, "funding": [ { @@ -2680,7 +2691,7 @@ "type": "tidelift" } ], - "time": "2022-12-30T00:23:10+00:00" + "time": "2022-12-30T00:15:36+00:00" }, { "name": "mreduar/laravel-phpcs", @@ -4615,5 +4626,8 @@ "ext-json": "*" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "platform-overrides": { + "php": "7.4" + }, + "plugin-api-version": "2.6.0" } diff --git a/phpunit.xml b/phpunit.xml index 80c695a..96ceb7c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,17 +1,13 @@ - - - - tests - - - - - ./src - - - \ No newline at end of file + + + + ./src + + + + + tests + + + diff --git a/src/Factories/ConditionFactory.php b/src/Factories/ConditionFactory.php index b5c76c4..e8e8251 100644 --- a/src/Factories/ConditionFactory.php +++ b/src/Factories/ConditionFactory.php @@ -50,7 +50,7 @@ public function __construct(Container $container) * @return Condition The newly created condition object or collection of condition objects. * @throws BindingResolutionException */ - public function make(mixed $value = null, iterable $options = []): Condition + public function make($value = null, iterable $options = []): Condition { if (! $value) { return new CallbackCondition(function () { diff --git a/src/Factories/Conditions/HasCapFactory.php b/src/Factories/Conditions/HasCapFactory.php index baa68a0..7b0f8d3 100644 --- a/src/Factories/Conditions/HasCapFactory.php +++ b/src/Factories/Conditions/HasCapFactory.php @@ -37,7 +37,7 @@ public function __construct(Container $container) * * @return Condition */ - public function make(mixed $value = null, iterable $options = []): Condition + public function make($value = null, iterable $options = []): Condition { if ($value instanceof Condition) { return $value; diff --git a/src/Factories/DispatcherFactory.php b/src/Factories/DispatcherFactory.php index f3abfce..832cce2 100644 --- a/src/Factories/DispatcherFactory.php +++ b/src/Factories/DispatcherFactory.php @@ -26,7 +26,7 @@ class DispatcherFactory implements Factory * * @return BaseDispatcher An instance of the base dispatcher. */ - public function make(mixed $value = null, $options = []): BaseDispatcher + public function make($value = null, $options = []): BaseDispatcher { return simpleDispatcher($value, array_merge($options, [ 'routeCollector' => Routes::class, diff --git a/src/Factories/Factory.php b/src/Factories/Factory.php index 3367ce2..41a0b3b 100644 --- a/src/Factories/Factory.php +++ b/src/Factories/Factory.php @@ -4,5 +4,5 @@ interface Factory { - public function make(mixed $value = null, iterable $options = []); + public function make($value = null, iterable $options = []); } diff --git a/src/Factories/Middleware/UserHasCapFactory.php b/src/Factories/Middleware/UserHasCapFactory.php index d19973c..da871ba 100644 --- a/src/Factories/Middleware/UserHasCapFactory.php +++ b/src/Factories/Middleware/UserHasCapFactory.php @@ -37,7 +37,7 @@ public function __construct(Container $container) * * @return Middleware */ - public function make(mixed $value = null, iterable $options = []) + public function make($value = null, iterable $options = []) { if ($value instanceof Middleware) { return $value; diff --git a/src/Factories/RedirectResponseFactory.php b/src/Factories/RedirectResponseFactory.php index da4e341..a6efb35 100644 --- a/src/Factories/RedirectResponseFactory.php +++ b/src/Factories/RedirectResponseFactory.php @@ -16,7 +16,7 @@ public function __construct(Container $container) $this->container = $container; } - public function make(mixed $value = null, iterable $options = []): RedirectResponse + public function make($value = null, iterable $options = []): RedirectResponse { $status = $options['status'] ?? 302; $headers = $options['headers'] ?? []; diff --git a/src/Factories/ResponseFactory.php b/src/Factories/ResponseFactory.php index 1980d42..2eeb186 100644 --- a/src/Factories/ResponseFactory.php +++ b/src/Factories/ResponseFactory.php @@ -41,7 +41,7 @@ public function __construct(Container $container) * @return Response * @throws BindingResolutionException */ - public function make(mixed $value = null, iterable $options = []): BaseResponse + public function make($value = null, iterable $options = []): BaseResponse { $response = $options['response'] ?? null; diff --git a/src/FastRoute/Routes.php b/src/FastRoute/Routes.php index 43fb378..ef10b5e 100644 --- a/src/FastRoute/Routes.php +++ b/src/FastRoute/Routes.php @@ -2,6 +2,7 @@ namespace CodeZone\Router\FastRoute; +use Closure; use CodeZone\Router\Controllers\CallbackController; use CodeZone\Router\Factories\ConditionFactory; use FastRoute\RouteCollector; @@ -61,7 +62,7 @@ protected function normalizeHandler( $httpMethod, $route, $handler ): array { $handler = explode( '@', $handler, 2 ); } - if ( is_callable( $handler ) ) { + if ( $handler instanceof Closure ) { $handler = [ CallbackController::class, 'handle', [ 'handler' => $handler ] ]; } diff --git a/src/Middleware/DispatchController.php b/src/Middleware/DispatchController.php index 1da3f7a..5a41be5 100644 --- a/src/Middleware/DispatchController.php +++ b/src/Middleware/DispatchController.php @@ -72,17 +72,13 @@ public function handle(Request $request, Response $response, $next) } } - //Call the controller method + $parameters = array_merge($vars, $config); + $parameters = array_merge($parameters, ['request' => $request, 'response' => $response]); + $controller = container()->make($class); + $action = container()->call([$controller, $method], $parameters); $response = $this->response_factory->make( - container()->call([ container()->make($class), $method ], [ - ...$vars, - ...$config, - $request, - $response, - ]), - [ - 'response' => $response_before_controller - ] + $action, + ['response' => $response_before_controller] ); return $next($request, $response); diff --git a/src/Middleware/UserHasCap.php b/src/Middleware/UserHasCap.php index 46ca79e..37d14d4 100644 --- a/src/Middleware/UserHasCap.php +++ b/src/Middleware/UserHasCap.php @@ -29,7 +29,7 @@ class UserHasCap implements Middleware * The variable that holds the URL to redirect to. * It can either be a string representing a valid URL or null if no redirection is needed. */ - protected mixed $redirect_to; + protected $redirect_to; /** * __construct method. diff --git a/tests/DispatchMiddlewareTest.php b/tests/DispatchMiddlewareTest.php index c7fa453..06565f9 100644 --- a/tests/DispatchMiddlewareTest.php +++ b/tests/DispatchMiddlewareTest.php @@ -7,58 +7,58 @@ use Illuminate\Http\Response; use function CodeZone\Router\container; -class DispatchMiddlewareTest extends TestCase { - use HasRouter; +class DispatchMiddlewareTest extends TestCase +{ + use HasRouter; - /** - * @test - */ - public function it_dispatches_responses () { - $this->router(); - $request = container()->make(Request::class); - $response = container()->make(Response::class); - $request->routes = $this->router()->routes(function($router) { - $router->get('/', [Controller::class, 'request']); - })->dispatch('GET', '/'); - $middleware = container()->make(DispatchController::class); - $middleware->handle($request, $response, function ($request, $response) { - $this->assertStringContainsString('Hello', $response->getContent()); - }); - } + /** + * @test + */ + public function it_dispatches_responses() + { + $this->router(); + $request = container()->make(Request::class); + $response = container()->make(Response::class); + $request->routes = $this->router()->routes(function ($router) { + $router->get('/', [Controller::class, 'request']); + })->dispatch('GET', '/'); + $middleware = container()->make(DispatchController::class); + $middleware->handle($request, $response, function ($request, $response) { + $this->assertStringContainsString('Hello', $response->getContent()); + }); + } - /** - * @test - */ - public function it_dispatches_responses_with_params () { - $this->router(); - $request = container()->make(Request::class); - $response = container()->make(Response::class); - $request->routes = $this->router()->routes(function($router) { - $router->get('/{param}', [Controller::class, 'withParam']); - })->dispatch('GET', '/hello'); - $middleware = container()->make(DispatchController::class); - $middleware->handle($request, $response, function ($request, $response) { - $this->assertStringContainsString('hello', $response->getContent()); - }); - } + /** + * @test + */ + public function it_dispatches_responses_with_params() + { + $this->router(); + $request = container()->make(Request::class); + $response = container()->make(Response::class); + $request->routes = $this->router()->routes(function ($router) { + $router->get('/{param}', [Controller::class, 'withParam']); + })->dispatch('GET', '/hello'); + $middleware = container()->make(DispatchController::class); + $middleware->handle($request, $response, function ($request, $response) { + $this->assertStringContainsString('hello', $response->getContent()); + }); + } - /** - * @test - */ - public function it_dispatches_strings () { - $this->router(); - $request = container()->make(Request::class); - $response = container()->make(Response::class); - $request->routes = $this->router()->routes(function($router) { - $router->get('/', [Controller::class, 'returnsString']); - })->dispatch('GET', '/'); - $middleware = container()->make(DispatchController::class); - $middleware->handle($request, $response, function ($request, $response) { - $this->assertStringContainsString('Hello', $response->getContent()); - }); - } - - - - -} \ No newline at end of file + /** + * @test + */ + public function it_dispatches_strings() + { + $this->router(); + $request = container()->make(Request::class); + $response = container()->make(Response::class); + $request->routes = $this->router()->routes(function ($router) { + $router->get('/', [Controller::class, 'returnsString']); + })->dispatch('GET', '/'); + $middleware = container()->make(DispatchController::class); + $middleware->handle($request, $response, function ($request, $response) { + $this->assertStringContainsString('Hello', $response->getContent()); + }); + } +}