From 2b2af75a8a6b842d51d853ca9962b3f032e3a643 Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Sat, 23 Nov 2024 15:40:05 -0500 Subject: [PATCH 01/11] Applied Laminas Coding Standards v3 and fix coding standards issues. Added psalm static analysis scripts and fixed ignorefiles in psalm.xml Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- .gitignore | 1 + composer.json | 5 +- composer.lock | 198 ++++++++++++------ config/module.config.php | 6 +- psalm.xml | 1 - src/ConfigProvider.php | 7 +- src/Exception/DisallowedOriginException.php | 7 +- src/Exception/ExceptionInterface.php | 7 +- src/Exception/InvalidOriginException.php | 6 +- src/Factory/CorsOptionsFactory.php | 16 +- src/Factory/CorsRequestListenerFactory.php | 19 +- src/Factory/CorsServiceFactory.php | 17 +- src/Module.php | 18 +- src/Mvc/CorsRequestListener.php | 28 +-- src/Options/CorsOptions.php | 64 +----- src/Service/CorsService.php | 69 +++--- test/Bootstrap.php | 4 +- test/ConfigProviderTest.php | 4 +- test/Factory/CorsOptionsFactoryTest.php | 11 +- .../CorsRequestListenerFactoryTest.php | 10 +- test/Factory/CorsServiceFactoryTest.php | 12 +- test/ModuleTest.php | 30 ++- test/Mvc/CorsRequestListenerTest.php | 66 +++--- test/Options/CorsOptionsTest.php | 9 +- test/Service/CorsServiceTest.php | 73 +++---- test/Util/ServiceManagerFactory.php | 25 +-- test/testing.config.php | 7 +- 27 files changed, 338 insertions(+), 382 deletions(-) diff --git a/.gitignore b/.gitignore index a7d4c63..4b64650 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build/ /.idea/ .phpunit* #/composer.lock +/.phpcs-cache diff --git a/composer.json b/composer.json index e8afbe9..c0a45f3 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "laminas/laminas-modulemanager": "^2.7.2", "laminas/laminas-view": "^2.8.1", "phpunit/phpunit": "^10.5 || ^11.0", - "laminas/laminas-coding-standard": "^2.5", + "laminas/laminas-coding-standard": "^3.0", "vimeo/psalm": "^5.26.0", "psalm/plugin-phpunit": "^0.19.0" }, @@ -69,7 +69,8 @@ "cs-fix": "phpcbf", "test": "phpunit", "test-coverage": "phpunit --colors=always --coverage-clover build/logs/clover.xml", - "test-coverage-html": "phpunit --colors=always --coverage-html build/html" + "test-coverage-html": "phpunit --colors=always --coverage-html build/html", + "static-analysis": "psalm --shepherd --stats" }, "config": { "allow-plugins": { diff --git a/composer.lock b/composer.lock index 61a1acc..0fbb8ec 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": "36e82c1a2b708c5675333aa1cd4bf99c", + "content-hash": "3f525aaf42abe902f1697c1c1fc7ef67", "packages": [ { "name": "brick/varexporter", @@ -1731,35 +1731,38 @@ }, { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.7.2", + "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "4be43904336affa5c2f70744a348312336afd0da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", + "reference": "4be43904336affa5c2f70744a348312336afd0da", "shasum": "" }, "require": { "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.3", + "php": ">=5.4", "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" }, "require-dev": { "composer/composer": "*", + "ext-json": "*", + "ext-zip": "*", "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpcompatibility/php-compatibility": "^9.0" + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" }, "type": "composer-plugin", "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" }, "autoload": { "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1775,7 +1778,7 @@ }, { "name": "Contributors", - "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" } ], "description": "PHP_CodeSniffer Standards Composer Installer Plugin", @@ -1799,10 +1802,10 @@ "tests" ], "support": { - "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", - "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "source": "https://github.com/PHPCSStandards/composer-installer" }, - "time": "2022-02-04T12:51:07+00:00" + "time": "2023-01-05T11:28:13+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -1841,6 +1844,53 @@ }, "time": "2019-12-04T15:06:13+00:00" }, + { + "name": "doctrine/deprecations", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/doctrine/deprecations.git", + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9", + "phpstan/phpstan": "1.4.10 || 1.10.15", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "0.18.4", + "psr/log": "^1 || ^2 || ^3", + "vimeo/psalm": "4.30.0 || 5.12.0" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/1.1.3" + }, + "time": "2024-01-30T19:34:25+00:00" + }, { "name": "felixfbecker/advanced-json-rpc", "version": "v3.2.1", @@ -2005,27 +2055,24 @@ }, { "name": "laminas/laminas-coding-standard", - "version": "2.5.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-coding-standard.git", - "reference": "c1aaa18a7c860c6932677a3e4ec13161f9fc7d61" + "reference": "ac809f5b27f0b22d0c1ec0cbc78cb67f92bfebcb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/c1aaa18a7c860c6932677a3e4ec13161f9fc7d61", - "reference": "c1aaa18a7c860c6932677a3e4ec13161f9fc7d61", + "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/ac809f5b27f0b22d0c1ec0cbc78cb67f92bfebcb", + "reference": "ac809f5b27f0b22d0c1ec0cbc78cb67f92bfebcb", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0", "php": "^7.4 || ^8.0", - "slevomat/coding-standard": "^7.0", - "squizlabs/php_codesniffer": "^3.6", - "webimpress/coding-standard": "^1.2" - }, - "conflict": { - "phpstan/phpdoc-parser": ">=1.6.0" + "slevomat/coding-standard": "^8.15.0", + "squizlabs/php_codesniffer": "^3.10", + "webimpress/coding-standard": "^1.3" }, "type": "phpcodesniffer-standard", "autoload": { @@ -2057,7 +2104,7 @@ "type": "community_bridge" } ], - "time": "2023-01-05T15:53:40+00:00" + "time": "2024-10-16T09:23:09+00:00" }, { "name": "laminas/laminas-i18n", @@ -2570,28 +2617,35 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", + "version": "5.6.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" + "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/f3558a4c23426d12bffeaab463f8a8d8b681193c", + "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c", "shasum": "" }, "require": { + "doctrine/deprecations": "^1.1", "ext-filter": "*", - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", + "phpdocumentor/type-resolver": "^1.7", + "phpstan/phpdoc-parser": "^1.7|^2.0", "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" + "mockery/mockery": "~1.3.5 || ~1.6.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-webmozart-assert": "^1.2", + "phpunit/phpunit": "^9.5", + "psalm/phar": "^5.26" }, "type": "library", "extra": { @@ -2615,36 +2669,39 @@ }, { "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" + "email": "opensource@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.0" }, - "time": "2021-10-19T17:43:47+00:00" + "time": "2024-11-12T11:25:25+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.6.2", + "version": "1.10.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d" + "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d", - "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a", + "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a", "shasum": "" }, "require": { - "php": "^7.4 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" + "doctrine/deprecations": "^1.0", + "php": "^7.3 || ^8.0", + "phpdocumentor/reflection-common": "^2.0", + "phpstan/phpdoc-parser": "^1.18|^2.0" }, "require-dev": { "ext-tokenizer": "*", + "phpbench/phpbench": "^1.2", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.8", "phpstan/phpstan-phpunit": "^1.1", @@ -2676,31 +2733,34 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.10.0" }, - "time": "2022-10-14T12:47:21+00:00" + "time": "2024-11-09T15:12:26+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "1.5.1", + "version": "1.33.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "981cc368a216c988e862a75e526b6076987d1b50" + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/981cc368a216c988e862a75e526b6076987d1b50", - "reference": "981cc368a216c988e862a75e526b6076987d1b50", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140", + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^4.15", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^1.5", + "phpstan/phpstan-phpunit": "^1.1", "phpstan/phpstan-strict-rules": "^1.0", "phpunit/phpunit": "^9.5", "symfony/process": "^5.2" @@ -2720,9 +2780,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.5.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.33.0" }, - "time": "2022-05-05T11:32:40+00:00" + "time": "2024-10-13T11:25:22+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4174,42 +4234,42 @@ }, { "name": "slevomat/coding-standard", - "version": "7.2.1", + "version": "8.15.0", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90" + "reference": "7d1d957421618a3803b593ec31ace470177d7817" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/aff06ae7a84e4534bf6f821dc982a93a5d477c90", - "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7d1d957421618a3803b593ec31ace470177d7817", + "reference": "7d1d957421618a3803b593ec31ace470177d7817", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": "^1.5.1", - "squizlabs/php_codesniffer": "^3.6.2" + "phpstan/phpdoc-parser": "^1.23.1", + "squizlabs/php_codesniffer": "^3.9.0" }, "require-dev": { - "phing/phing": "2.17.3", + "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.4.10|1.7.1", - "phpstan/phpstan-deprecation-rules": "1.0.0", - "phpstan/phpstan-phpunit": "1.0.0|1.1.1", - "phpstan/phpstan-strict-rules": "1.2.3", - "phpunit/phpunit": "7.5.20|8.5.21|9.5.20" + "phpstan/phpstan": "1.10.60", + "phpstan/phpstan-deprecation-rules": "1.1.4", + "phpstan/phpstan-phpunit": "1.3.16", + "phpstan/phpstan-strict-rules": "1.5.2", + "phpunit/phpunit": "8.5.21|9.6.8|10.5.11" }, "type": "phpcodesniffer-standard", "extra": { "branch-alias": { - "dev-master": "7.x-dev" + "dev-master": "8.x-dev" } }, "autoload": { "psr-4": { - "SlevomatCodingStandard\\": "SlevomatCodingStandard" + "SlevomatCodingStandard\\": "SlevomatCodingStandard/" } }, "notification-url": "https://packagist.org/downloads/", @@ -4217,9 +4277,13 @@ "MIT" ], "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "keywords": [ + "dev", + "phpcs" + ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/7.2.1" + "source": "https://github.com/slevomat/coding-standard/tree/8.15.0" }, "funding": [ { @@ -4231,7 +4295,7 @@ "type": "tidelift" } ], - "time": "2022-05-25T10:58:12+00:00" + "time": "2024-03-09T15:20:58+00:00" }, { "name": "spatie/array-to-xml", diff --git a/config/module.config.php b/config/module.config.php index 60ce070..15fde12 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -1,4 +1,7 @@ Factory\CorsServiceFactory::class, ], ], - - 'lmc_cors' => [], + 'lmc_cors' => [], ]; diff --git a/psalm.xml b/psalm.xml index 852b9fd..ed5e3d3 100644 --- a/psalm.xml +++ b/psalm.xml @@ -13,7 +13,6 @@ - diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php index f731f00..b6757a7 100644 --- a/src/ConfigProvider.php +++ b/src/ConfigProvider.php @@ -1,5 +1,7 @@ $this->getDependencyConfig(), - 'lmc_cors' => $this->getModuleConfig(), + 'lmc_cors' => $this->getModuleConfig(), ]; } @@ -25,7 +27,6 @@ public function getDependencyConfig(): array public function getModuleConfig(): array { - return [ - ]; + return []; } } diff --git a/src/Exception/DisallowedOriginException.php b/src/Exception/DisallowedOriginException.php index 1fb75b0..21cd7f4 100644 --- a/src/Exception/DisallowedOriginException.php +++ b/src/Exception/DisallowedOriginException.php @@ -1,4 +1,7 @@ - */ class DisallowedOriginException extends DomainException implements ExceptionInterface { } diff --git a/src/Exception/ExceptionInterface.php b/src/Exception/ExceptionInterface.php index e5aa171..ac5d4db 100644 --- a/src/Exception/ExceptionInterface.php +++ b/src/Exception/ExceptionInterface.php @@ -1,4 +1,7 @@ - */ interface ExceptionInterface { } diff --git a/src/Exception/InvalidOriginException.php b/src/Exception/InvalidOriginException.php index 42fa5a1..c2dc461 100644 --- a/src/Exception/InvalidOriginException.php +++ b/src/Exception/InvalidOriginException.php @@ -1,13 +1,11 @@ - */ class InvalidOriginException extends DomainException implements ExceptionInterface { /** diff --git a/src/Factory/CorsOptionsFactory.php b/src/Factory/CorsOptionsFactory.php index 74f615d..2eefb29 100644 --- a/src/Factory/CorsOptionsFactory.php +++ b/src/Factory/CorsOptionsFactory.php @@ -1,4 +1,7 @@ */ class CorsOptionsFactory implements FactoryInterface { /** - * @param ContainerInterface $container - * @param $requestedName - * @param array|null $options - * @return CorsOptions + * @param string $requestedName * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): CorsOptions { - /* @var $config array */ + /** @var array $config */ $config = $container->has('config') ? $container->get('config') : []; $config = $config['lmc_cors'] ?? []; diff --git a/src/Factory/CorsRequestListenerFactory.php b/src/Factory/CorsRequestListenerFactory.php index 163938c..2160b96 100644 --- a/src/Factory/CorsRequestListenerFactory.php +++ b/src/Factory/CorsRequestListenerFactory.php @@ -1,4 +1,7 @@ */ class CorsRequestListenerFactory implements FactoryInterface { /** - * @param ContainerInterface $container - * @param $requestedName - * @param $options - * @return CorsRequestListener + * @param string $requestedName * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function __invoke(ContainerInterface $container, $requestedName, $options = null): CorsRequestListener + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): CorsRequestListener { - /* @var $corsService CorsService */ + /** @var CorsService $corsService */ $corsService = $container->get(CorsService::class); return new CorsRequestListener($corsService); diff --git a/src/Factory/CorsServiceFactory.php b/src/Factory/CorsServiceFactory.php index 9485865..3e15755 100644 --- a/src/Factory/CorsServiceFactory.php +++ b/src/Factory/CorsServiceFactory.php @@ -1,4 +1,7 @@ */ class CorsServiceFactory implements FactoryInterface { /** - * @param ContainerInterface $container - * @param $requestedName - * @param $options - * @return CorsService + * @param string $requestedName * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function __invoke(ContainerInterface $container, $requestedName, $options = null): CorsService + public function __invoke(containerinterface $container, $requestedName, ?array $options = null): CorsService { - /* @var $corsOptions CorsOptions */ + /** @var CorsOptions $corsOptions */ $corsOptions = $container->get(CorsOptions::class); return new CorsService($corsOptions); diff --git a/src/Module.php b/src/Module.php index 48394b7..3bb60c2 100644 --- a/src/Module.php +++ b/src/Module.php @@ -1,4 +1,7 @@ */ class Module implements BootstrapListenerInterface, ConfigProviderInterface { - /** * {@inheritDoc} */ public function onBootstrap(EventInterface $e): void { - /* @var $application Application */ - $application = $e->getTarget(); - $serviceManager = $application->getServiceManager(); - $eventManager = $application->getEventManager(); + /** @var Application $application */ + $application = $e->getTarget(); + $serviceManager = $application->getServiceManager(); + $eventManager = $application->getEventManager(); /** @var CorsRequestListener $listener */ - $listener = $serviceManager->get('LmcCors\Mvc\CorsRequestListener'); + $listener = $serviceManager->get(CorsRequestListener::class); $listener->attach($eventManager); } @@ -55,7 +55,7 @@ public function getConfig(): array return [ 'service_manager' => $configProvider->getDependencyConfig(), - 'lmc_cors' => $configProvider->getModuleConfig(), + 'lmc_cors' => $configProvider->getModuleConfig(), ]; } } diff --git a/src/Mvc/CorsRequestListener.php b/src/Mvc/CorsRequestListener.php index 8d84bc7..76df458 100644 --- a/src/Mvc/CorsRequestListener.php +++ b/src/Mvc/CorsRequestListener.php @@ -1,4 +1,7 @@ */ class CorsRequestListener extends AbstractListenerAggregate { - /** - * @var CorsService - */ protected CorsService $corsService; /** * Whether or not a preflight request was detected - * - * @var bool */ protected bool $isPreflight = false; - /** - * @param CorsService $corsService - */ public function __construct(CorsService $corsService) { $this->corsService = $corsService; @@ -70,7 +62,6 @@ public function attach(EventManagerInterface $events, $priority = 1): void /** * Handle a CORS preflight request * - * @param MvcEvent $event * @return null|HttpResponse|void */ public function onCorsPreflight(MvcEvent $event) @@ -78,7 +69,7 @@ public function onCorsPreflight(MvcEvent $event) // Reset state flag $this->isPreflight = false; - /** @var $request HttpRequest */ + /** @var HttpRequest $request */ $request = $event->getRequest(); if (! $request instanceof HttpRequest) { @@ -116,8 +107,6 @@ public function onCorsPreflight(MvcEvent $event) /** * Handle a CORS request (non-preflight, normal CORS request) - * - * @param MvcEvent $event */ public function onCorsRequest(MvcEvent $event): void { @@ -126,12 +115,11 @@ public function onCorsRequest(MvcEvent $event): void return; } - /** @var $request HttpRequest */ - $request = $event->getRequest(); - /** @var $response HttpResponse */ + /** @var HttpRequest $request */ + $request = $event->getRequest(); + /** @var HttpResponse $response */ $response = $event->getResponse(); - if (! $request instanceof HttpRequest) { return; } diff --git a/src/Options/CorsOptions.php b/src/Options/CorsOptions.php index f3a508d..93e2ec1 100644 --- a/src/Options/CorsOptions.php +++ b/src/Options/CorsOptions.php @@ -1,4 +1,7 @@ */ class CorsOptions extends AbstractOptions { - const ROUTE_PARAM = 'cors'; + public const ROUTE_PARAM = 'cors'; /** * Set the list of allowed origins domain with protocol. - * - * @var array */ protected array $allowedOrigins = []; /** * Set the list of HTTP verbs. - * - * @var array */ protected array $allowedMethods = []; /** * Set the list of headers. - * - * @var array */ protected array $allowedHeaders = []; /** * Set the max age of the authorize request in seconds. - * - * @var int */ protected int $maxAge = 0; /** * Set the list of exposed headers. - * - * @var array */ protected array $exposedHeaders = []; /** * Allow CORS request with credential. - * - * @var bool */ protected bool $allowedCredentials = false; - /** - * @param array $allowedOrigins - * @return void - */ public function setAllowedOrigins(array $allowedOrigins): void { $this->allowedOrigins = $allowedOrigins; } - /** - * @return array - */ public function getAllowedOrigins(): array { return $this->allowedOrigins; } - /** - * @param array $allowedMethods - * @return void - */ public function setAllowedMethods(array $allowedMethods): void { foreach ($allowedMethods as &$allowedMethod) { @@ -102,77 +81,46 @@ public function setAllowedMethods(array $allowedMethods): void $this->allowedMethods = $allowedMethods; } - /** - * @return array - */ public function getAllowedMethods(): array { return $this->allowedMethods; } - /** - * @param array $allowedHeaders - * @return void - */ public function setAllowedHeaders(array $allowedHeaders): void { $this->allowedHeaders = $allowedHeaders; } - /** - * @return array - */ public function getAllowedHeaders(): array { return $this->allowedHeaders; } - /** - * @param int $maxAge - * @return void - */ public function setMaxAge(int $maxAge): void { $this->maxAge = (int) $maxAge; } - /** - * @return int - */ public function getMaxAge(): int { return $this->maxAge; } - /** - * @param array $exposedHeaders - * @return void - */ public function setExposedHeaders(array $exposedHeaders): void { $this->exposedHeaders = $exposedHeaders; } - /** - * @return array - */ public function getExposedHeaders(): array { return $this->exposedHeaders; } - /** - * @param bool $allowedCredentials - * @return void - */ public function setAllowedCredentials(bool $allowedCredentials): void { $this->allowedCredentials = (bool) $allowedCredentials; } - /** - * @return boolean - */ public function getAllowedCredentials(): bool { return $this->allowedCredentials; diff --git a/src/Service/CorsService.php b/src/Service/CorsService.php index b0cb36c..65dfa49 100644 --- a/src/Service/CorsService.php +++ b/src/Service/CorsService.php @@ -1,4 +1,7 @@ */ class CorsService { - /** - * @var CorsOptions - */ protected CorsOptions $options; - /** - * @param CorsOptions $options - */ public function __construct(CorsOptions $options) { $this->options = $options; @@ -55,9 +55,6 @@ public function __construct(CorsOptions $options) /** * Check if the HTTP request is a CORS request by checking if the Origin header is present and that the * request URI is not the same as the one in the Origin - * - * @param HttpRequest $request - * @return bool */ public function isCorsRequest(HttpRequest $request): bool { @@ -78,17 +75,13 @@ public function isCorsRequest(HttpRequest $request): bool // According to the spec (http://tools.ietf.org/html/rfc6454#section-4), we should check host, port and scheme - return (! ($originUri->getHost() === $requestUri->getHost()) + return ! ($originUri->getHost() === $requestUri->getHost()) || ! ($originUri->getPort() === $requestUri->getPort()) - || ! ($originUri->getScheme() === $requestUri->getScheme()) - ); + || ! ($originUri->getScheme() === $requestUri->getScheme()); } /** * Check if the CORS request is a preflight request - * - * @param HttpRequest $request - * @return bool */ public function isPreflightRequest(HttpRequest $request): bool { @@ -99,9 +92,6 @@ public function isPreflightRequest(HttpRequest $request): bool /** * Create a preflight response by adding the corresponding headers - * - * @param HttpRequest $request - * @return HttpResponse */ public function createPreflightCorsResponse(HttpRequest $request): HttpResponse { @@ -125,14 +115,11 @@ public function createPreflightCorsResponse(HttpRequest $request): HttpResponse /** * Create a preflight response by adding the corresponding headers which are merged with per-route configuration - * - * @param HttpRequest $request - * @param RouteMatch|null $routeMatch - * - * @return HttpResponse */ - public function createPreflightCorsResponseWithRouteOptions(HttpRequest $request, RouteMatch|null $routeMatch = null): HttpResponse - { + public function createPreflightCorsResponseWithRouteOptions( + HttpRequest $request, + RouteMatch|null $routeMatch = null + ): HttpResponse { $options = $this->options; if ($routeMatch instanceof RouteMatch) { $options->setFromArray($routeMatch->getParam(CorsOptions::ROUTE_PARAM) ?: []); @@ -143,14 +130,13 @@ public function createPreflightCorsResponseWithRouteOptions(HttpRequest $request /** * Populate a simple CORS response * - * @param HttpRequest $request - * @param HttpResponse $response - * @param RouteMatch|null $routeMatch - * @return HttpResponse - * @throws DisallowedOriginException If the origin is not allowed + * @throws DisallowedOriginException */ - public function populateCorsResponse(HttpRequest $request, HttpResponse $response, RouteMatch|null $routeMatch = null): HttpResponse - { + public function populateCorsResponse( + HttpRequest $request, + HttpResponse $response, + RouteMatch|null $routeMatch = null + ): HttpResponse { if ($routeMatch instanceof RouteMatch) { $this->options->setFromArray($routeMatch->getParam(CorsOptions::ROUTE_PARAM) ?: []); } @@ -161,7 +147,7 @@ public function populateCorsResponse(HttpRequest $request, HttpResponse $respons // a simple request, it is useless to continue the processing as it will be refused // by the browser anyway, so we throw an exception if ($origin === 'null') { - $origin = $request->getHeader('Origin'); + $origin = $request->getHeader('Origin'); $originHeader = $origin ? $origin->getFieldValue() : ''; throw new DisallowedOriginException( sprintf( @@ -193,8 +179,6 @@ public function populateCorsResponse(HttpRequest $request, HttpResponse $respons * value are wildcard ("*"), an exact domain or a null string. * * @link http://www.w3.org/TR/cors/#access-control-allow-origin-response-header - * @param HttpRequest $request - * @return string */ protected function getAllowedOriginValue(HttpRequest $request): string { @@ -220,10 +204,7 @@ protected function getAllowedOriginValue(HttpRequest $request): string /** * Ensure that the Vary header is set. * - * * @link http://www.w3.org/TR/cors/#resource-implementation - * @param HttpResponse $response - * @return Headers */ public function ensureVaryHeader(HttpResponse $response): Headers { diff --git a/test/Bootstrap.php b/test/Bootstrap.php index 95d2c5b..0cdf036 100644 --- a/test/Bootstrap.php +++ b/test/Bootstrap.php @@ -1,4 +1,7 @@ assertArrayHasKey('dependencies', $config); $this->assertArrayHasKey('lmc_cors', $config); $this->assertArrayHasKey('factories', $config['dependencies']); diff --git a/test/Factory/CorsOptionsFactoryTest.php b/test/Factory/CorsOptionsFactoryTest.php index e332e45..1218179 100644 --- a/test/Factory/CorsOptionsFactoryTest.php +++ b/test/Factory/CorsOptionsFactoryTest.php @@ -1,4 +1,7 @@ - * * @group Coverage */ -#[CoversClass('\LmcCors\Factory\CorsOptionsFactory')] +#[CoversClass(CorsOptionsFactory::class)] class CorsOptionsFactoryTest extends TestCase { /** - * @return void * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ diff --git a/test/Factory/CorsRequestListenerFactoryTest.php b/test/Factory/CorsRequestListenerFactoryTest.php index 158e727..08c46cf 100644 --- a/test/Factory/CorsRequestListenerFactoryTest.php +++ b/test/Factory/CorsRequestListenerFactoryTest.php @@ -1,4 +1,7 @@ - * * @group Coverage */ -#[CoversClass('\LmcCors\Factory\CorsRequestListenerFactory')] +#[CoversClass(CorsRequestListenerFactory::class)] class CorsRequestListenerFactoryTest extends TestCase { public function testCanCreateCorsRequestListener() diff --git a/test/Factory/CorsServiceFactoryTest.php b/test/Factory/CorsServiceFactoryTest.php index 8117aec..b7ba5cc 100644 --- a/test/Factory/CorsServiceFactoryTest.php +++ b/test/Factory/CorsServiceFactoryTest.php @@ -1,4 +1,7 @@ - * * @group Coverage */ -#[CoversClass('\LmcCors\Factory\CorsServiceFactory')] +#[CoversClass(CorsServiceFactory::class)] class CorsServiceFactoryTest extends TestCase { public function testCanCreateCorsService() diff --git a/test/ModuleTest.php b/test/ModuleTest.php index 707fae0..019bbb8 100644 --- a/test/ModuleTest.php +++ b/test/ModuleTest.php @@ -1,4 +1,7 @@ - * * @group Coverage */ -#[CoversClass('\LmcCors\Module')] +#[CoversClass(Module::class)] class ModuleTest extends TestCase { public function testGetConfig() @@ -44,13 +52,13 @@ public function testGetConfig() public function testAssertListenerIsCorrectlyRegistered() { $module = new Module(); - $mvcEvent = $this->getMockBuilder('Laminas\Mvc\MvcEvent')->getMock(); - $application = $this->getMockBuilder('Laminas\Mvc\Application') + $mvcEvent = $this->getMockBuilder(MvcEvent::class)->getMock(); + $application = $this->getMockBuilder(Application::class) ->disableOriginalConstructor() ->getMock(); - $eventManager = $this->getMockBuilder('Laminas\EventManager\EventManagerInterface')->getMock(); - $serviceManager = $this->getMockBuilder('Laminas\ServiceManager\ServiceManager')->getMock(); - $corsListener = $this->getMockBuilder('LmcCors\Mvc\CorsRequestListener') + $eventManager = $this->getMockBuilder(EventManagerInterface::class)->getMock(); + $serviceManager = $this->getMockBuilder(ServiceManager::class)->getMock(); + $corsListener = $this->getMockBuilder(CorsRequestListener::class) ->disableOriginalConstructor() ->getMock(); @@ -60,7 +68,7 @@ public function testAssertListenerIsCorrectlyRegistered() $serviceManager ->expects($this->any()) ->method('get') - ->with('LmcCors\Mvc\CorsRequestListener') + ->with(CorsRequestListener::class) ->willReturn($corsListener); $corsListener->expects($this->once())->method('attach')->with($eventManager); diff --git a/test/Mvc/CorsRequestListenerTest.php b/test/Mvc/CorsRequestListenerTest.php index afa0073..b2a22de 100644 --- a/test/Mvc/CorsRequestListenerTest.php +++ b/test/Mvc/CorsRequestListenerTest.php @@ -1,4 +1,7 @@ - * * @group Coverage */ -#[CoversClass('\LmcCors\Mvc\CorsRequestListener')] +#[CoversClass(CorsRequestListener::class)] class CorsRequestListenerTest extends TestCase { - - /** - * @var CorsService - */ protected CorsService $corsService; - /** - * @var CorsOptions - */ protected CorsOptions $corsOptions; - /** - * @var CorsRequestListener - */ protected CorsRequestListener $corsListener; public function setUp(): void { - $this->corsOptions = new CorsOptions(); - $this->corsService = new CorsService($this->corsOptions); + $this->corsOptions = new CorsOptions(); + $this->corsService = new CorsService($this->corsOptions); $this->corsListener = new CorsRequestListener($this->corsService); } public function testAttach() { - $eventManager = $this->getMockBuilder('Laminas\EventManager\EventManagerInterface')->getMock(); + $eventManager = $this->getMockBuilder(EventManagerInterface::class)->getMock(); $matcher = $this->exactly(2); $eventManager ->expects($matcher) ->method('attach') - ->willReturnCallback(function (string $event, callable $callback, int $priority) use ($matcher) { + ->willReturnCallback(function (string $event, callable $callback, int $priority) { match ($event) { MvcEvent::EVENT_ROUTE => '', MvcEvent::EVENT_FINISH => '', @@ -84,7 +76,7 @@ public function testAttach() public function testReturnNothingForNonCorsRequest() { $mvcEvent = new MvcEvent(); - $request = new HttpRequest(); + $request = new HttpRequest(); $response = new HttpResponse(); $mvcEvent @@ -98,9 +90,9 @@ public function testReturnNothingForNonCorsRequest() public function testImmediatelyReturnResponseForPreflightCorsRequest() { $mvcEvent = new MvcEvent(); - $request = new HttpRequest(); + $request = new HttpRequest(); $response = new HttpResponse(); - $router = new TreeRouteStack(); + $router = new TreeRouteStack(); $request->setMethod('OPTIONS'); $request->getHeaders()->addHeaderLine('Origin', 'http://example.com'); @@ -111,13 +103,13 @@ public function testImmediatelyReturnResponseForPreflightCorsRequest() ->setResponse($response) ->setRouter($router); - $this->assertInstanceOf('Laminas\Http\Response', $this->corsListener->onCorsPreflight($mvcEvent)); + $this->assertInstanceOf(HttpResponse::class, $this->corsListener->onCorsPreflight($mvcEvent)); } public function testReturnNothingForNormalAuthorizedCorsRequest() { $mvcEvent = new MvcEvent(); - $request = new HttpRequest(); + $request = new HttpRequest(); $response = new HttpResponse(); $request->getHeaders()->addHeaderLine('Origin', 'http://example.com'); @@ -134,7 +126,7 @@ public function testReturnNothingForNormalAuthorizedCorsRequest() public function testReturnUnauthorizedResponseForNormalUnauthorizedCorsRequest() { $mvcEvent = new MvcEvent(); - $request = new HttpRequest(); + $request = new HttpRequest(); $response = new HttpResponse(); $request->getHeaders()->addHeaderLine('Origin', 'http://unauthorized-domain.com'); @@ -155,9 +147,9 @@ public function testReturnUnauthorizedResponseForNormalUnauthorizedCorsRequest() public function testImmediatelyReturnBadRequestResponseForInvalidOriginHeaderValue() { $mvcEvent = new MvcEvent(); - $request = new HttpRequest(); + $request = new HttpRequest(); $response = new HttpResponse(); - $router = new TreeRouteStack(); + $router = new TreeRouteStack(); $request->getHeaders()->addHeaderLine('Origin', 'file:'); @@ -177,13 +169,12 @@ public function testImmediatelyReturnBadRequestResponseForInvalidOriginHeaderVal * Application always triggers `MvcEvent::EVENT_FINISH` and since the `CorsRequestListener` is listening on it, we * should handle the exception aswell. * - * * @return void */ public function testOnCorsRequestCanHandleInvalidOriginHeaderValue() { $mvcEvent = new MvcEvent(); - $request = new HttpRequest(); + $request = new HttpRequest(); $response = new HttpResponse(); $request->getHeaders()->addHeaderLine('Origin', 'file:'); @@ -195,36 +186,35 @@ public function testOnCorsRequestCanHandleInvalidOriginHeaderValue() $this->assertNull($this->corsListener->onCorsRequest($mvcEvent)); } - public function testPreflightWorksWithMethodRoutes() { $mvcEvent = new MvcEvent(); - $request = new HttpRequest(); + $request = new HttpRequest(); $request->setUri('/foo'); $request->setMethod('OPTIONS'); $request->getHeaders()->addHeaderLine('Origin', 'http://example.com'); $request->getHeaders()->addHeaderLine('Access-Control-Request-Method', 'GET'); $response = new HttpResponse(); - $router = new TreeRouteStack(); + $router = new TreeRouteStack(); $router ->addRoutes([ 'home' => [ - 'type' => 'literal', - 'options' => [ + 'type' => 'literal', + 'options' => [ 'route' => '/foo', ], 'may_terminate' => false, - 'child_routes' => [ + 'child_routes' => [ 'get' => [ - 'type' => 'method', + 'type' => 'method', 'options' => [ - 'verb' => 'get', + 'verb' => 'get', 'defaults' => [ CorsOptions::ROUTE_PARAM => [ 'allowed_origins' => ['http://example.com'], 'allowed_methods' => ['GET'], ], - ] + ], ], ], ], diff --git a/test/Options/CorsOptionsTest.php b/test/Options/CorsOptionsTest.php index 83fc2a5..8f5523b 100644 --- a/test/Options/CorsOptionsTest.php +++ b/test/Options/CorsOptionsTest.php @@ -1,4 +1,7 @@ - * * @group Coverage */ -#[CoversClass('\LmcCors\Options\CorsOptions')] +#[CoversClass(CorsOptions::class)] class CorsOptionsTest extends TestCase { public function testCorsOptionsAreSecuredByDefault() diff --git a/test/Service/CorsServiceTest.php b/test/Service/CorsServiceTest.php index 7b52f23..9b36133 100644 --- a/test/Service/CorsServiceTest.php +++ b/test/Service/CorsServiceTest.php @@ -1,4 +1,7 @@ - * * @group Coverage */ -#[CoversClass('\LmcCors\Service\CorsService')] +#[CoversClass(CorsService::class)] class CorsServiceTest extends TestCase { - /** - * @var CorsService - */ protected CorsService $corsService; - /** - * @var HttpResponse - */ protected HttpResponse $response; - /** - * @var HttpRequest - */ protected HttpRequest $request; - /** - * @var MvcEvent - */ protected MvcEvent $event; - /** - * @var CorsOptions - */ protected CorsOptions $corsOptions; /** @@ -122,7 +108,7 @@ public function testCanDetectPreflightRequest() public function testProperlyCreatePreflightResponse() { - $request = new HttpRequest(); + $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://example.com'); $response = $this->corsService->createPreflightCorsResponse($request); @@ -145,7 +131,7 @@ public function testProperlyCreatePreflightResponse() public function testDoesNotAddAllowCredentialsHeadersIfAsked() { - $request = new HttpRequest(); + $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://example.com'); $this->corsOptions->setAllowedCredentials(false); @@ -157,7 +143,7 @@ public function testDoesNotAddAllowCredentialsHeadersIfAsked() public function testCanReturnWildCardAllowOrigin() { - $request = new HttpRequest(); + $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://funny-origin.com'); $this->corsOptions->setAllowedOrigins(['*']); @@ -169,33 +155,33 @@ public function testCanReturnWildCardAllowOrigin() public function testCanReturnWildCardSubDomainAllowOrigin() { - $request = new HttpRequest(); + $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://subdomain.example.com'); $this->corsOptions->setAllowedOrigins(['*.example.com']); $response = $this->corsService->createPreflightCorsResponse($request); - $headers = $response->getHeaders(); + $headers = $response->getHeaders(); $headerValue = $headers->get('Access-Control-Allow-Origin')->getFieldValue(); $this->assertEquals('http://subdomain.example.com', $headerValue); } public function testCanReturnWildCardSubDomainWithSchemeAllowOrigin() { - $request = new HttpRequest(); + $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'https://subdomain.example.com'); $this->corsOptions->setAllowedOrigins(['https://*.example.com']); $response = $this->corsService->createPreflightCorsResponse($request); - $headers = $response->getHeaders(); + $headers = $response->getHeaders(); $headerValue = $headers->get('Access-Control-Allow-Origin')->getFieldValue(); $this->assertEquals('https://subdomain.example.com', $headerValue); } public function testReturnNullForMissMatchedWildcardSubDomainOrigin() { - $request = new HttpRequest(); + $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://subdomain.example.org'); $this->corsOptions->setAllowedOrigins(['*.example.com']); @@ -207,7 +193,7 @@ public function testReturnNullForMissMatchedWildcardSubDomainOrigin() public function testReturnNullForRootDomainOnWildcardSubDomainOrigin() { - $request = new HttpRequest(); + $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://example.com'); $this->corsOptions->setAllowedOrigins(['*.example.com']); @@ -219,7 +205,7 @@ public function testReturnNullForRootDomainOnWildcardSubDomainOrigin() public function testReturnNullForDifferentSchemeOnWildcardSubDomainOrigin() { - $request = new HttpRequest(); + $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'https://example.com'); $this->corsOptions->setAllowedOrigins(['http://*.example.com']); @@ -231,7 +217,7 @@ public function testReturnNullForDifferentSchemeOnWildcardSubDomainOrigin() public function testReturnNullForUnknownOrigin() { - $request = new HttpRequest(); + $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://unauthorized-origin.com'); $response = $this->corsService->createPreflightCorsResponse($request); @@ -256,9 +242,9 @@ public function testEnsureVaryHeaderForNoOrigin() public function testEnsureNoVaryHeaderWhenAcceptsAnyOrigin() { - $response = new HttpResponse(); + $response = new HttpResponse(); $corsService = new CorsService(new CorsOptions([ - 'allowed_origins' => ['*'] + 'allowed_origins' => ['*'], ])); $corsService->ensureVaryHeader($response); @@ -381,7 +367,6 @@ public function testCanHandleUnconfiguredRouteMatch() public function testCanHandleConfiguredRouteMatch() { - $routeMatchParameters = [ CorsOptions::ROUTE_PARAM => [ 'allowed_origins' => ['http://example.org'], @@ -434,11 +419,11 @@ public function testDoesNotCrashApplicationOnInvalidOriginValue() */ public function testCanPopulateNormalCorsRequestWithRouteMatch() { - $request = new HttpRequest(); - $response = new HttpResponse(); + $request = new HttpRequest(); + $response = new HttpResponse(); $routeMatchParameters = [ CorsOptions::ROUTE_PARAM => [ - 'allowed_origins' => ['http://example.org'] + 'allowed_origins' => ['http://example.org'], ], ]; @@ -447,7 +432,7 @@ public function testCanPopulateNormalCorsRequestWithRouteMatch() $request->getHeaders()->addHeaderLine('Origin', 'http://example.org'); $response = $this->corsService->populateCorsResponse($request, $response, $routeMatch); - $this->assertInstanceOf(\Laminas\Http\Response::class, $response); + $this->assertInstanceOf(HttpResponse::class, $response); $this->assertEquals( 'http://example.org', $response->getHeaders()->get('Access-Control-Allow-Origin')->getFieldValue() @@ -459,11 +444,11 @@ public function testCanPopulateNormalCorsRequestWithRouteMatch() */ public function testCanPopulateNormalCorsRequestWithRouteMatchRewriteException() { - $request = new HttpRequest(); - $response = new HttpResponse(); + $request = new HttpRequest(); + $response = new HttpResponse(); $routeMatchParameters = [ CorsOptions::ROUTE_PARAM => [ - 'allowed_origins' => ['http://example.org'] + 'allowed_origins' => ['http://example.org'], ], ]; diff --git a/test/Util/ServiceManagerFactory.php b/test/Util/ServiceManagerFactory.php index 2de167a..385415b 100644 --- a/test/Util/ServiceManagerFactory.php +++ b/test/Util/ServiceManagerFactory.php @@ -1,4 +1,7 @@ - * @author Florent Blaison */ -abstract class ServiceManagerFactory +class ServiceManagerFactory { - /** - * @var array - */ private static array $config = []; /** * @static - * @param array $config - * @return void */ public static function setApplicationConfig(array $config): void { @@ -52,7 +46,6 @@ public static function setApplicationConfig(array $config): void /** * @static - * @return array */ public static function getApplicationConfig(): array { @@ -60,15 +53,13 @@ public static function getApplicationConfig(): array } /** - * @param array|null $config - * @return ServiceManager * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public static function getServiceManager(array|null $config = null): ServiceManager { - $config = $config ?: static::getApplicationConfig(); - $serviceManager = new ServiceManager(); + $config = $config ?: static::getApplicationConfig(); + $serviceManager = new ServiceManager(); $serviceManagerConfig = new ServiceManagerConfig( $config['service_manager'] ?? [] ); @@ -76,7 +67,7 @@ public static function getServiceManager(array|null $config = null): ServiceMana $serviceManager->setService('ApplicationConfig', $config); - /* @var $moduleManager ModuleManagerInterface */ + /** @var ModuleManagerInterface $moduleManager */ $moduleManager = $serviceManager->get('ModuleManager'); $moduleManager->loadModules(); diff --git a/test/testing.config.php b/test/testing.config.php index 41a6edf..6eeda09 100644 --- a/test/testing.config.php +++ b/test/testing.config.php @@ -1,4 +1,7 @@ [ - - ], + 'lmc_cors' => [], ]; From 37bd5f340a79a33c3044f82ad6a0f9f68b40fcf1 Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Sat, 23 Nov 2024 16:28:47 -0500 Subject: [PATCH 02/11] Fixed some issues from static-analysis. Baselined the remaining issues. Removed unused module.config.php Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- config/module.config.php | 33 -- psalm.baseline.xml | 295 +++++++++++++++++- psalm.xml | 1 + src/Module.php | 1 + src/Options/CorsOptions.php | 5 +- .../CorsRequestListenerFactoryTest.php | 2 +- test/Factory/CorsServiceFactoryTest.php | 2 +- test/Mvc/CorsRequestListenerTest.php | 16 +- test/Options/CorsOptionsTest.php | 6 +- test/Service/CorsServiceTest.php | 54 ++-- test/Util/ServiceManagerFactory.php | 3 +- 11 files changed, 342 insertions(+), 76 deletions(-) delete mode 100644 config/module.config.php diff --git a/config/module.config.php b/config/module.config.php deleted file mode 100644 index 15fde12..0000000 --- a/config/module.config.php +++ /dev/null @@ -1,33 +0,0 @@ - [ - 'factories' => [ - Mvc\CorsRequestListener::class => Factory\CorsRequestListenerFactory::class, - Options\CorsOptions::class => Factory\CorsOptionsFactory::class, - Service\CorsService::class => Factory\CorsServiceFactory::class, - ], - ], - 'lmc_cors' => [], -]; diff --git a/psalm.baseline.xml b/psalm.baseline.xml index 31edb87..c4dc2a9 100644 --- a/psalm.baseline.xml +++ b/psalm.baseline.xml @@ -1,3 +1,296 @@ - + + + + + + + + + + + + getRouteMatch()]]> + + + + getHeader('Access-Control-Request-Method')->getFieldValue()]]> + + + + + + + + + + + + + + + + + + + + + + options->getMaxAge()]]> + + + + + + + getParam(CorsOptions::ROUTE_PARAM) ?: []]]> + getParam(CorsOptions::ROUTE_PARAM) ?: []]]> + + + options->getAllowedHeaders()]]> + options->getAllowedMethods()]]> + options->getExposedHeaders()]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + get('Vary')->getFieldValue()]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/psalm.xml b/psalm.xml index ed5e3d3..a70a675 100644 --- a/psalm.xml +++ b/psalm.xml @@ -7,6 +7,7 @@ findUnusedBaselineEntry="true" findUnusedCode="true" findUnusedPsalmSuppress="true" + errorBaseline="psalm.baseline.xml" > diff --git a/src/Module.php b/src/Module.php index 3bb60c2..0020d0b 100644 --- a/src/Module.php +++ b/src/Module.php @@ -24,6 +24,7 @@ use Laminas\EventManager\EventInterface; use Laminas\ModuleManager\Feature\BootstrapListenerInterface; use Laminas\ModuleManager\Feature\ConfigProviderInterface; +use Laminas\Mvc\Application; use LmcCors\Mvc\CorsRequestListener; /** diff --git a/src/Options/CorsOptions.php b/src/Options/CorsOptions.php index 93e2ec1..9744454 100644 --- a/src/Options/CorsOptions.php +++ b/src/Options/CorsOptions.php @@ -27,6 +27,9 @@ /** * CorsOptions + * + * @template TValue + * @extends AbstractOptions */ class CorsOptions extends AbstractOptions { @@ -118,7 +121,7 @@ public function getExposedHeaders(): array public function setAllowedCredentials(bool $allowedCredentials): void { - $this->allowedCredentials = (bool) $allowedCredentials; + $this->allowedCredentials = $allowedCredentials; } public function getAllowedCredentials(): bool diff --git a/test/Factory/CorsRequestListenerFactoryTest.php b/test/Factory/CorsRequestListenerFactoryTest.php index 08c46cf..da01f10 100644 --- a/test/Factory/CorsRequestListenerFactoryTest.php +++ b/test/Factory/CorsRequestListenerFactoryTest.php @@ -35,7 +35,7 @@ #[CoversClass(CorsRequestListenerFactory::class)] class CorsRequestListenerFactoryTest extends TestCase { - public function testCanCreateCorsRequestListener() + public function testCanCreateCorsRequestListener(): void { $serviceManager = ServiceManagerFactory::getServiceManager(); $listener = $serviceManager->get(CorsRequestListener::class); diff --git a/test/Factory/CorsServiceFactoryTest.php b/test/Factory/CorsServiceFactoryTest.php index b7ba5cc..d4642f7 100644 --- a/test/Factory/CorsServiceFactoryTest.php +++ b/test/Factory/CorsServiceFactoryTest.php @@ -35,7 +35,7 @@ #[CoversClass(CorsServiceFactory::class)] class CorsServiceFactoryTest extends TestCase { - public function testCanCreateCorsService() + public function testCanCreateCorsService(): void { $serviceManager = ServiceManagerFactory::getServiceManager(); $service = $serviceManager->get(CorsService::class); diff --git a/test/Mvc/CorsRequestListenerTest.php b/test/Mvc/CorsRequestListenerTest.php index b2a22de..81f044c 100644 --- a/test/Mvc/CorsRequestListenerTest.php +++ b/test/Mvc/CorsRequestListenerTest.php @@ -55,7 +55,7 @@ public function setUp(): void $this->corsListener = new CorsRequestListener($this->corsService); } - public function testAttach() + public function testAttach(): void { $eventManager = $this->getMockBuilder(EventManagerInterface::class)->getMock(); @@ -73,7 +73,7 @@ public function testAttach() $this->corsListener->attach($eventManager); } - public function testReturnNothingForNonCorsRequest() + public function testReturnNothingForNonCorsRequest(): void { $mvcEvent = new MvcEvent(); $request = new HttpRequest(); @@ -87,7 +87,7 @@ public function testReturnNothingForNonCorsRequest() $this->assertNull($this->corsListener->onCorsRequest($mvcEvent)); } - public function testImmediatelyReturnResponseForPreflightCorsRequest() + public function testImmediatelyReturnResponseForPreflightCorsRequest(): void { $mvcEvent = new MvcEvent(); $request = new HttpRequest(); @@ -106,7 +106,7 @@ public function testImmediatelyReturnResponseForPreflightCorsRequest() $this->assertInstanceOf(HttpResponse::class, $this->corsListener->onCorsPreflight($mvcEvent)); } - public function testReturnNothingForNormalAuthorizedCorsRequest() + public function testReturnNothingForNormalAuthorizedCorsRequest(): void { $mvcEvent = new MvcEvent(); $request = new HttpRequest(); @@ -123,7 +123,7 @@ public function testReturnNothingForNormalAuthorizedCorsRequest() $this->assertNull($this->corsListener->onCorsRequest($mvcEvent)); } - public function testReturnUnauthorizedResponseForNormalUnauthorizedCorsRequest() + public function testReturnUnauthorizedResponseForNormalUnauthorizedCorsRequest(): void { $mvcEvent = new MvcEvent(); $request = new HttpRequest(); @@ -144,7 +144,7 @@ public function testReturnUnauthorizedResponseForNormalUnauthorizedCorsRequest() $this->assertEquals('', $newResponse->getContent()); } - public function testImmediatelyReturnBadRequestResponseForInvalidOriginHeaderValue() + public function testImmediatelyReturnBadRequestResponseForInvalidOriginHeaderValue(): void { $mvcEvent = new MvcEvent(); $request = new HttpRequest(); @@ -171,7 +171,7 @@ public function testImmediatelyReturnBadRequestResponseForInvalidOriginHeaderVal * * @return void */ - public function testOnCorsRequestCanHandleInvalidOriginHeaderValue() + public function testOnCorsRequestCanHandleInvalidOriginHeaderValue(): void { $mvcEvent = new MvcEvent(); $request = new HttpRequest(); @@ -186,7 +186,7 @@ public function testOnCorsRequestCanHandleInvalidOriginHeaderValue() $this->assertNull($this->corsListener->onCorsRequest($mvcEvent)); } - public function testPreflightWorksWithMethodRoutes() + public function testPreflightWorksWithMethodRoutes(): void { $mvcEvent = new MvcEvent(); $request = new HttpRequest(); diff --git a/test/Options/CorsOptionsTest.php b/test/Options/CorsOptionsTest.php index 8f5523b..41b54c0 100644 --- a/test/Options/CorsOptionsTest.php +++ b/test/Options/CorsOptionsTest.php @@ -33,7 +33,7 @@ #[CoversClass(CorsOptions::class)] class CorsOptionsTest extends TestCase { - public function testCorsOptionsAreSecuredByDefault() + public function testCorsOptionsAreSecuredByDefault(): void { $options = new CorsOptions(); @@ -45,7 +45,7 @@ public function testCorsOptionsAreSecuredByDefault() $this->assertFalse($options->getAllowedCredentials(), 'Cookies are not allowed'); } - public function testCanModifyOptions() + public function testCanModifyOptions(): void { $options = new CorsOptions(); @@ -68,7 +68,7 @@ public function testCanModifyOptions() $this->assertTrue($options->getAllowedCredentials()); } - public function testNormalizeHttpMethods() + public function testNormalizeHttpMethods(): void { $options = new CorsOptions(); diff --git a/test/Service/CorsServiceTest.php b/test/Service/CorsServiceTest.php index 9b36133..623e535 100644 --- a/test/Service/CorsServiceTest.php +++ b/test/Service/CorsServiceTest.php @@ -71,7 +71,7 @@ public function setUp(): void $this->corsService = new CorsService($this->corsOptions); } - public function testCanDetectCorsRequest() + public function testCanDetectCorsRequest(): void { $request = new HttpRequest(); @@ -81,7 +81,7 @@ public function testCanDetectCorsRequest() $this->assertTrue($this->corsService->isCorsRequest($request)); } - public function testIsNotCorsRequestIfNotACrossRequest() + public function testIsNotCorsRequestIfNotACrossRequest(): void { $request = new HttpRequest(); $request->setUri('http://example.com'); @@ -90,7 +90,7 @@ public function testIsNotCorsRequestIfNotACrossRequest() $this->assertFalse($this->corsService->isCorsRequest($request)); } - public function testCanDetectPreflightRequest() + public function testCanDetectPreflightRequest(): void { $request = new HttpRequest(); @@ -106,7 +106,7 @@ public function testCanDetectPreflightRequest() $this->assertTrue($this->corsService->isPreflightRequest($request)); } - public function testProperlyCreatePreflightResponse() + public function testProperlyCreatePreflightResponse(): void { $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://example.com'); @@ -129,7 +129,7 @@ public function testProperlyCreatePreflightResponse() $this->assertEquals('true', $headers->get('Access-Control-Allow-Credentials')->getFieldValue()); } - public function testDoesNotAddAllowCredentialsHeadersIfAsked() + public function testDoesNotAddAllowCredentialsHeadersIfAsked(): void { $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://example.com'); @@ -141,7 +141,7 @@ public function testDoesNotAddAllowCredentialsHeadersIfAsked() $this->assertFalse($headers->has('Access-Control-Allow-Credentials')); } - public function testCanReturnWildCardAllowOrigin() + public function testCanReturnWildCardAllowOrigin(): void { $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://funny-origin.com'); @@ -153,7 +153,7 @@ public function testCanReturnWildCardAllowOrigin() $this->assertEquals('http://funny-origin.com', $headers->get('Access-Control-Allow-Origin')->getFieldValue()); } - public function testCanReturnWildCardSubDomainAllowOrigin() + public function testCanReturnWildCardSubDomainAllowOrigin(): void { $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://subdomain.example.com'); @@ -166,7 +166,7 @@ public function testCanReturnWildCardSubDomainAllowOrigin() $this->assertEquals('http://subdomain.example.com', $headerValue); } - public function testCanReturnWildCardSubDomainWithSchemeAllowOrigin() + public function testCanReturnWildCardSubDomainWithSchemeAllowOrigin(): void { $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'https://subdomain.example.com'); @@ -179,7 +179,7 @@ public function testCanReturnWildCardSubDomainWithSchemeAllowOrigin() $this->assertEquals('https://subdomain.example.com', $headerValue); } - public function testReturnNullForMissMatchedWildcardSubDomainOrigin() + public function testReturnNullForMissMatchedWildcardSubDomainOrigin(): void { $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://subdomain.example.org'); @@ -191,7 +191,7 @@ public function testReturnNullForMissMatchedWildcardSubDomainOrigin() $this->assertEquals('null', $headers->get('Access-Control-Allow-Origin')->getFieldValue()); } - public function testReturnNullForRootDomainOnWildcardSubDomainOrigin() + public function testReturnNullForRootDomainOnWildcardSubDomainOrigin(): void { $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://example.com'); @@ -203,7 +203,7 @@ public function testReturnNullForRootDomainOnWildcardSubDomainOrigin() $this->assertEquals('null', $headers->get('Access-Control-Allow-Origin')->getFieldValue()); } - public function testReturnNullForDifferentSchemeOnWildcardSubDomainOrigin() + public function testReturnNullForDifferentSchemeOnWildcardSubDomainOrigin(): void { $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'https://example.com'); @@ -215,7 +215,7 @@ public function testReturnNullForDifferentSchemeOnWildcardSubDomainOrigin() $this->assertEquals('null', $headers->get('Access-Control-Allow-Origin')->getFieldValue()); } - public function testReturnNullForUnknownOrigin() + public function testReturnNullForUnknownOrigin(): void { $request = new HttpRequest(); $request->getHeaders()->addHeaderLine('Origin', 'http://unauthorized-origin.com'); @@ -226,7 +226,7 @@ public function testReturnNullForUnknownOrigin() $this->assertEquals('null', $headers->get('Access-Control-Allow-Origin')->getFieldValue()); } - public function testEnsureVaryHeaderForNoOrigin() + public function testEnsureVaryHeaderForNoOrigin(): void { $response = new HttpResponse(); @@ -240,7 +240,7 @@ public function testEnsureVaryHeaderForNoOrigin() $this->assertStringContainsString('Origin', $headers->get('Vary')->getFieldValue()); } - public function testEnsureNoVaryHeaderWhenAcceptsAnyOrigin() + public function testEnsureNoVaryHeaderWhenAcceptsAnyOrigin(): void { $response = new HttpResponse(); $corsService = new CorsService(new CorsOptions([ @@ -255,7 +255,7 @@ public function testEnsureNoVaryHeaderWhenAcceptsAnyOrigin() $this->assertFalse($headers->get('Vary')); } - public function testCanPopulateNormalCorsRequest() + public function testCanPopulateNormalCorsRequest(): void { $request = new HttpRequest(); $response = new HttpResponse(); @@ -270,7 +270,7 @@ public function testCanPopulateNormalCorsRequest() $this->assertEquals('Location', $headers->get('Access-Control-Expose-Headers')->getFieldValue()); } - public function testRefuseNormalCorsRequestIfUnauthorized() + public function testRefuseNormalCorsRequestIfUnauthorized(): void { $request = new HttpRequest(); $response = new HttpResponse(); @@ -283,7 +283,7 @@ public function testRefuseNormalCorsRequestIfUnauthorized() $this->corsService->populateCorsResponse($request, $response); } - public function testAddVaryHeaderInNormalRequest() + public function testAddVaryHeaderInNormalRequest(): void { $request = new HttpRequest(); $response = new HttpResponse(); @@ -296,7 +296,7 @@ public function testAddVaryHeaderInNormalRequest() $this->assertTrue($headers->has('Vary')); } - public function testAppendVaryHeaderInNormalRequest() + public function testAppendVaryHeaderInNormalRequest(): void { $request = new HttpRequest(); $response = new HttpResponse(); @@ -311,7 +311,7 @@ public function testAppendVaryHeaderInNormalRequest() $this->assertEquals('Foo, Origin', $headers->get('Vary')->getFieldValue()); } - public function testPopulatesAllowCredentialsNormalCorsRequest() + public function testPopulatesAllowCredentialsNormalCorsRequest(): void { $request = new HttpRequest(); $response = new HttpResponse(); @@ -321,11 +321,11 @@ public function testPopulatesAllowCredentialsNormalCorsRequest() $this->corsService->populateCorsResponse($request, $response); $headers = $response->getHeaders(); - + $this->assertNotNull($headers); $this->assertEquals('true', $headers->get('Access-Control-Allow-Credentials')->getFieldValue()); } - public function testCanDetectCorsRequestFromSameHostButDifferentPort() + public function testCanDetectCorsRequestFromSameHostButDifferentPort(): void { $request = new HttpRequest(); $request->setUri('http://example.com'); @@ -333,7 +333,7 @@ public function testCanDetectCorsRequestFromSameHostButDifferentPort() $this->assertTrue($this->corsService->isCorsRequest($request)); } - public function testCanDetectCorsRequestFromSameHostButDifferentScheme() + public function testCanDetectCorsRequestFromSameHostButDifferentScheme(): void { $request = new HttpRequest(); $request->setUri('https://example.com'); @@ -341,7 +341,7 @@ public function testCanDetectCorsRequestFromSameHostButDifferentScheme() $this->assertTrue($this->corsService->isCorsRequest($request)); } - public function testCanHandleUnconfiguredRouteMatch() + public function testCanHandleUnconfiguredRouteMatch(): void { $routeMatch = new RouteMatch([]); @@ -365,7 +365,7 @@ public function testCanHandleUnconfiguredRouteMatch() $this->assertEquals('true', $headers->get('Access-Control-Allow-Credentials')->getFieldValue()); } - public function testCanHandleConfiguredRouteMatch() + public function testCanHandleConfiguredRouteMatch(): void { $routeMatchParameters = [ CorsOptions::ROUTE_PARAM => [ @@ -405,7 +405,7 @@ public function testCanHandleConfiguredRouteMatch() /** * @see https://github.com/zf-fr/zfr-cors/issues/44 */ - public function testDoesNotCrashApplicationOnInvalidOriginValue() + public function testDoesNotCrashApplicationOnInvalidOriginValue(): void { $request = new HttpRequest(); $request->setUri('https://example.com'); @@ -417,7 +417,7 @@ public function testDoesNotCrashApplicationOnInvalidOriginValue() /** * @see https://github.com/zf-fr/zfr-cors/issues/57 */ - public function testCanPopulateNormalCorsRequestWithRouteMatch() + public function testCanPopulateNormalCorsRequestWithRouteMatch(): void { $request = new HttpRequest(); $response = new HttpResponse(); @@ -442,7 +442,7 @@ public function testCanPopulateNormalCorsRequestWithRouteMatch() /** * @see https://github.com/zf-fr/zfr-cors/issues/57 */ - public function testCanPopulateNormalCorsRequestWithRouteMatchRewriteException() + public function testCanPopulateNormalCorsRequestWithRouteMatchRewriteException(): void { $request = new HttpRequest(); $response = new HttpResponse(); diff --git a/test/Util/ServiceManagerFactory.php b/test/Util/ServiceManagerFactory.php index 385415b..931b26e 100644 --- a/test/Util/ServiceManagerFactory.php +++ b/test/Util/ServiceManagerFactory.php @@ -22,6 +22,7 @@ namespace LmcCorsTest\Util; +use Laminas\ModuleManager\ModuleManagerInterface; use Laminas\Mvc\Service\ServiceManagerConfig; use Laminas\ServiceManager\ServiceManager; use Psr\Container\ContainerExceptionInterface; @@ -58,7 +59,7 @@ public static function getApplicationConfig(): array */ public static function getServiceManager(array|null $config = null): ServiceManager { - $config = $config ?: static::getApplicationConfig(); + $config = $config !== null ?: static::getApplicationConfig(); $serviceManager = new ServiceManager(); $serviceManagerConfig = new ServiceManagerConfig( $config['service_manager'] ?? [] From 894e9dbd2ca0e2ea363ac481b38e9d0343b935c4 Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Sat, 23 Nov 2024 16:31:57 -0500 Subject: [PATCH 03/11] Fixed minor coding standard issue in CorsRequestListenerTest.php Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- test/Mvc/CorsRequestListenerTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/Mvc/CorsRequestListenerTest.php b/test/Mvc/CorsRequestListenerTest.php index 81f044c..70b3f81 100644 --- a/test/Mvc/CorsRequestListenerTest.php +++ b/test/Mvc/CorsRequestListenerTest.php @@ -167,9 +167,7 @@ public function testImmediatelyReturnBadRequestResponseForInvalidOriginHeaderVal /** * Application always triggers `MvcEvent::EVENT_FINISH` and since the `CorsRequestListener` is listening on it, we - * should handle the exception aswell. - * - * @return void + * should handle the exception as well */ public function testOnCorsRequestCanHandleInvalidOriginHeaderValue(): void { From 414ff4435d88b012be19f12a067b4315aec4fcd2 Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Sat, 23 Nov 2024 16:36:50 -0500 Subject: [PATCH 04/11] Moved to Laminas CI Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- .github/workflows/build-test.yml | 66 --------------------- .github/workflows/continous-integration.yml | 11 ++++ 2 files changed, 11 insertions(+), 66 deletions(-) delete mode 100644 .github/workflows/build-test.yml create mode 100644 .github/workflows/continous-integration.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml deleted file mode 100644 index 20dda7e..0000000 --- a/.github/workflows/build-test.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Continuous Integration - -on: - push: - # Avoid running tests on changes to documentation - paths-ignore: - - 'docs/**' - pull_request: - paths-ignore: - - 'docs/**' - -jobs: - build: - strategy: - matrix: - php_version: ['8.1', '8.2', '8.3', '8.4'] - deps: ['--prefer-lowest', '--prefer-dist'] - include: - - code-coverage: 'yes' - php_version: '8.3' - deps: '' - - runs-on: ubuntu-latest - - steps: - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{matrix.php_version}} - - - name: Check PHP version - run: php -v - - - name: test deps - run: echo ${{ matrix.deps }} - - - uses: actions/checkout@v4 - name: Checkout branch - - - name: Validate composer.json and composer.lock - run: composer validate --strict - - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v4 - with: - path: vendor - key: ${{ runner.os }}-php--${{matrix.php_version}}-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php--${{matrix.php_version}} - - - name: Install/update dependencies - run: composer update ${{matrix.deps}} - - - name: Run PHPUnit test suite with coverage - if: ${{ matrix.code-coverage == 'yes' }} - run: composer test-coverage - - - name: Run PHPUnit test suite no coverage - if: ${{ matrix.code-coverage != 'yes' }} - run: composer test - - - name: Upload coverage results to Coverall - if: ${{ matrix.code-coverage == 'yes' }} - uses: coverallsapp/github-action@v2 - diff --git a/.github/workflows/continous-integration.yml b/.github/workflows/continous-integration.yml new file mode 100644 index 0000000..26c5802 --- /dev/null +++ b/.github/workflows/continous-integration.yml @@ -0,0 +1,11 @@ +name: "Continuous Integration" + +on: + pull_request: + push: + branches: + tags: + +jobs: + ci: + uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x From 3d2bbac8fd8b7b89f0b34f18731b1ffd6cc0999d Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Sat, 23 Nov 2024 16:44:37 -0500 Subject: [PATCH 05/11] Fixed linting issues in README.md Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8cead5c..e5d86ca 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # LmcCors - ![Build Status](https://github.com/lm-commons/lmccors/actions/workflows/build-test.yml/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/LM-Commons/LmcCors/badge.svg?branch=master)](https://coveralls.io/github/LM-Commons/LmcCors?branch=master) [![Latest Stable Version](https://poser.pugx.org/lm-commons/lmc-cors/v)](//packagist.org/packages/lm-commons/lmc-cors) @@ -45,8 +44,8 @@ With CORS, you can allow your server to reply to such requests. You can find better documentation on how CORS works on the web: - * [Mozilla documentation about CORS](https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS) - * [CORS server flowchart](http://www.html5rocks.com/static/images/cors_server_flowchart.png) +* [Mozilla documentation about CORS](https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS) +* [CORS server flowchart](http://www.html5rocks.com/static/images/cors_server_flowchart.png) ### Event registration @@ -57,20 +56,20 @@ of 2. This means that this listener is executed BEFORE the route has been matche As by default, all the various options are set globally for all routes: -- `allowed_origins`: (array) List of allowed origins. To allow any origin, you can use the wildcard (`*`) character. If +* `allowed_origins`: (array) List of allowed origins. To allow any origin, you can use the wildcard (`*`) character. If multiple origins are specified, LmcCors will automatically check the `"Origin"` header's value, and only return the allowed domain (if any) in the `"Allow-Access-Control-Origin"` response header. To allow any sub-domain, you can prefix the domain with the wildcard character (i.e. `*.example.com`). Please note that you don't need to add your host URI (so if your website is hosted as "example.com", "example.com" is automatically allowed. -- `allowed_methods`: (array) List of allowed HTTP methods. Those methods will be returned for the preflight request to +* `allowed_methods`: (array) List of allowed HTTP methods. Those methods will be returned for the preflight request to indicate which methods are allowed to the user agent. You can even specify custom HTTP verbs. -- `allowed_headers`: (array) List of allowed headers that will be returned for the preflight request. This indicates +* `allowed_headers`: (array) List of allowed headers that will be returned for the preflight request. This indicates to the user agent which headers are permitted to be sent when doing the actual request. -- `max_age`: (int) Maximum age (seconds) the preflight request should be cached by the user agent. This prevents the +* `max_age`: (int) Maximum age (seconds) the preflight request should be cached by the user agent. This prevents the user agent from sending a preflight request for each request. -- `exposed_headers`: (array) List of response headers that are allowed to be read in the user agent. Please note that +* `exposed_headers`: (array) List of response headers that are allowed to be read in the user agent. Please note that some browsers do not implement this feature correctly. -- `allowed_credentials`: (boolean) If true, it allows the browser to send cookies along with the request. +* `allowed_credentials`: (boolean) If true, it allows the browser to send cookies along with the request. If you want to configure specific routes, you can add `LmcCors\Options\CorsOptions::ROUTE_PARAM` to your route configuration: @@ -178,6 +177,7 @@ testing your API with some Google Chrome extensions), you need to add support fo the `UriFactory` config (please [refer to the doc](https://docs.laminas.dev/laminas-uri/usage/#creating-a-new-custom-class-uri)). ### Example + To register the `chrome-extension` custom scheme in your API, simply add: ```php From 972c0327569e8b16d750a4976528dd6c669167fe Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Sat, 23 Nov 2024 16:44:37 -0500 Subject: [PATCH 06/11] Fixed linting issues in README.md Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 8cead5c..62905ac 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # LmcCors - ![Build Status](https://github.com/lm-commons/lmccors/actions/workflows/build-test.yml/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/LM-Commons/LmcCors/badge.svg?branch=master)](https://coveralls.io/github/LM-Commons/LmcCors?branch=master) [![Latest Stable Version](https://poser.pugx.org/lm-commons/lmc-cors/v)](//packagist.org/packages/lm-commons/lmc-cors) @@ -45,8 +44,8 @@ With CORS, you can allow your server to reply to such requests. You can find better documentation on how CORS works on the web: - * [Mozilla documentation about CORS](https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS) - * [CORS server flowchart](http://www.html5rocks.com/static/images/cors_server_flowchart.png) +* [Mozilla documentation about CORS](https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS) +* [CORS server flowchart](http://www.html5rocks.com/static/images/cors_server_flowchart.png) ### Event registration @@ -57,20 +56,20 @@ of 2. This means that this listener is executed BEFORE the route has been matche As by default, all the various options are set globally for all routes: -- `allowed_origins`: (array) List of allowed origins. To allow any origin, you can use the wildcard (`*`) character. If +* `allowed_origins`: (array) List of allowed origins. To allow any origin, you can use the wildcard (`*`) character. If multiple origins are specified, LmcCors will automatically check the `"Origin"` header's value, and only return the - allowed domain (if any) in the `"Allow-Access-Control-Origin"` response header. To allow any sub-domain, you can prefix + allowed domain (if any) in the `"Allow-Access-Control-Origin"` response header. To allow any sub-domain, you can prefix the domain with the wildcard character (i.e. `*.example.com`). Please note that you don't need to add your host URI (so if your website is hosted as "example.com", "example.com" is automatically allowed. -- `allowed_methods`: (array) List of allowed HTTP methods. Those methods will be returned for the preflight request to +* `allowed_methods`: (array) List of allowed HTTP methods. Those methods will be returned for the preflight request to indicate which methods are allowed to the user agent. You can even specify custom HTTP verbs. -- `allowed_headers`: (array) List of allowed headers that will be returned for the preflight request. This indicates +* `allowed_headers`: (array) List of allowed headers that will be returned for the preflight request. This indicates to the user agent which headers are permitted to be sent when doing the actual request. -- `max_age`: (int) Maximum age (seconds) the preflight request should be cached by the user agent. This prevents the +* `max_age`: (int) Maximum age (seconds) the preflight request should be cached by the user agent. This prevents the user agent from sending a preflight request for each request. -- `exposed_headers`: (array) List of response headers that are allowed to be read in the user agent. Please note that +* `exposed_headers`: (array) List of response headers that are allowed to be read in the user agent. Please note that some browsers do not implement this feature correctly. -- `allowed_credentials`: (boolean) If true, it allows the browser to send cookies along with the request. +* `allowed_credentials`: (boolean) If true, it allows the browser to send cookies along with the request. If you want to configure specific routes, you can add `LmcCors\Options\CorsOptions::ROUTE_PARAM` to your route configuration: @@ -178,6 +177,7 @@ testing your API with some Google Chrome extensions), you need to add support fo the `UriFactory` config (please [refer to the doc](https://docs.laminas.dev/laminas-uri/usage/#creating-a-new-custom-class-uri)). ### Example + To register the `chrome-extension` custom scheme in your API, simply add: ```php From 6df919693a95cda2858f4ed48411cd252f7a5f72 Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Sat, 23 Nov 2024 17:00:37 -0500 Subject: [PATCH 07/11] Removed unused component in test Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- composer.json | 3 - composer.lock | 247 ++------------------------------------------------ 2 files changed, 10 insertions(+), 240 deletions(-) diff --git a/composer.json b/composer.json index c0a45f3..9ff2ca4 100644 --- a/composer.json +++ b/composer.json @@ -41,10 +41,7 @@ "laminas/laminas-servicemanager": "^2.7.9 || ^3.4.0" }, "require-dev": { - "laminas/laminas-i18n": "^2.9", - "laminas/laminas-log": "^2.10", "laminas/laminas-modulemanager": "^2.7.2", - "laminas/laminas-view": "^2.8.1", "phpunit/phpunit": "^10.5 || ^11.0", "laminas/laminas-coding-standard": "^3.0", "vimeo/psalm": "^5.26.0", diff --git a/composer.lock b/composer.lock index 0fbb8ec..0d02cdc 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": "3f525aaf42abe902f1697c1c1fc7ef67", + "content-hash": "5f4efca55d003f99b6c8c60f813e3a48", "packages": [ { "name": "brick/varexporter", @@ -2106,233 +2106,6 @@ ], "time": "2024-10-16T09:23:09+00:00" }, - { - "name": "laminas/laminas-i18n", - "version": "2.29.0", - "source": { - "type": "git", - "url": "https://github.com/laminas/laminas-i18n.git", - "reference": "9aa7ef6073556e9b4cfd8d9a0cb8e41cd3883454" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-i18n/zipball/9aa7ef6073556e9b4cfd8d9a0cb8e41cd3883454", - "reference": "9aa7ef6073556e9b4cfd8d9a0cb8e41cd3883454", - "shasum": "" - }, - "require": { - "ext-intl": "*", - "laminas/laminas-servicemanager": "^3.21.0", - "laminas/laminas-stdlib": "^3.0", - "laminas/laminas-translator": "^1.0", - "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" - }, - "conflict": { - "laminas/laminas-view": "<2.20.0", - "zendframework/zend-i18n": "*" - }, - "require-dev": { - "laminas/laminas-cache": "^3.12.1", - "laminas/laminas-cache-storage-adapter-memory": "^2.3.0", - "laminas/laminas-cache-storage-deprecated-factory": "^1.2", - "laminas/laminas-coding-standard": "~2.5.0", - "laminas/laminas-config": "^3.9.0", - "laminas/laminas-eventmanager": "^3.13", - "laminas/laminas-filter": "^2.34", - "laminas/laminas-validator": "^2.49", - "laminas/laminas-view": "^2.34", - "phpunit/phpunit": "^10.5.11", - "psalm/plugin-phpunit": "^0.19.0", - "vimeo/psalm": "^5.22.2" - }, - "suggest": { - "laminas/laminas-cache": "You should install this package to cache the translations", - "laminas/laminas-config": "You should install this package to use the INI translation format", - "laminas/laminas-eventmanager": "You should install this package to use the events in the translator", - "laminas/laminas-filter": "You should install this package to use the provided filters", - "laminas/laminas-i18n-resources": "This package provides validator and captcha translations", - "laminas/laminas-validator": "You should install this package to use the provided validators", - "laminas/laminas-view": "You should install this package to use the provided view helpers" - }, - "type": "library", - "extra": { - "laminas": { - "component": "Laminas\\I18n", - "config-provider": "Laminas\\I18n\\ConfigProvider" - } - }, - "autoload": { - "psr-4": { - "Laminas\\I18n\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Provide translations for your application, and filter and validate internationalized values", - "homepage": "https://laminas.dev", - "keywords": [ - "i18n", - "laminas" - ], - "support": { - "chat": "https://laminas.dev/chat", - "docs": "https://docs.laminas.dev/laminas-i18n/", - "forum": "https://discourse.laminas.dev", - "issues": "https://github.com/laminas/laminas-i18n/issues", - "rss": "https://github.com/laminas/laminas-i18n/releases.atom", - "source": "https://github.com/laminas/laminas-i18n" - }, - "funding": [ - { - "url": "https://funding.communitybridge.org/projects/laminas-project", - "type": "community_bridge" - } - ], - "time": "2024-10-11T09:44:53+00:00" - }, - { - "name": "laminas/laminas-log", - "version": "2.17.0", - "source": { - "type": "git", - "url": "https://github.com/laminas/laminas-log.git", - "reference": "f24c4c78d3024bb59610845328d7876d6c797065" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-log/zipball/f24c4c78d3024bb59610845328d7876d6c797065", - "reference": "f24c4c78d3024bb59610845328d7876d6c797065", - "shasum": "" - }, - "require": { - "laminas/laminas-servicemanager": "^3.21.0", - "laminas/laminas-stdlib": "^3.0", - "php": "~8.1.0 || ~8.2.0 || ~8.3.0", - "psr/log": "^1.1.2" - }, - "conflict": { - "zendframework/zend-log": "*" - }, - "provide": { - "psr/log-implementation": "1.0.0" - }, - "require-dev": { - "ext-dom": "*", - "ext-json": "*", - "ext-xml": "*", - "firephp/firephp-core": "^0.5.3", - "laminas/laminas-coding-standard": "~2.3.0", - "laminas/laminas-db": "^2.6", - "laminas/laminas-escaper": "^2.5", - "laminas/laminas-filter": "^2.5", - "laminas/laminas-mail": "^2.6.1", - "laminas/laminas-validator": "^2.10.1", - "mikey179/vfsstream": "^1.6.7", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5.10" - }, - "suggest": { - "ext-mongo": "mongo extension to use Mongo writer", - "ext-mongodb": "mongodb extension to use MongoDB writer", - "laminas/laminas-db": "Laminas\\Db component to use the database log writer", - "laminas/laminas-escaper": "Laminas\\Escaper component, for use in the XML log formatter", - "laminas/laminas-mail": "Laminas\\Mail component to use the email log writer", - "laminas/laminas-validator": "Laminas\\Validator component to block invalid log messages" - }, - "type": "library", - "extra": { - "laminas": { - "component": "Laminas\\Log", - "config-provider": "Laminas\\Log\\ConfigProvider" - } - }, - "autoload": { - "psr-4": { - "Laminas\\Log\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Robust, composite logger with filtering, formatting, and PSR-3 support", - "homepage": "https://laminas.dev", - "keywords": [ - "laminas", - "log", - "logging" - ], - "support": { - "chat": "https://laminas.dev/chat", - "docs": "https://docs.laminas.dev/laminas-log/", - "forum": "https://discourse.laminas.dev", - "issues": "https://github.com/laminas/laminas-log/issues", - "rss": "https://github.com/laminas/laminas-log/releases.atom", - "source": "https://github.com/laminas/laminas-log" - }, - "funding": [ - { - "url": "https://funding.communitybridge.org/projects/laminas-project", - "type": "community_bridge" - } - ], - "time": "2023-12-05T18:27:50+00:00" - }, - { - "name": "laminas/laminas-translator", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/laminas/laminas-translator.git", - "reference": "12897e710e21413c1f93fc38fe9dead6b51c5218" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-translator/zipball/12897e710e21413c1f93fc38fe9dead6b51c5218", - "reference": "12897e710e21413c1f93fc38fe9dead6b51c5218", - "shasum": "" - }, - "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" - }, - "require-dev": { - "laminas/laminas-coding-standard": "~3.0.0", - "vimeo/psalm": "^5.24.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Laminas\\Translator\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Interfaces for the Translator component of laminas-i18n", - "homepage": "https://laminas.dev", - "keywords": [ - "i18n", - "laminas" - ], - "support": { - "chat": "https://laminas.dev/chat", - "docs": "https://docs.laminas.dev/laminas-i18n/", - "forum": "https://discourse.laminas.dev", - "issues": "https://github.com/laminas/laminas-translator/issues", - "rss": "https://github.com/laminas/laminas-translator/releases.atom", - "source": "https://github.com/laminas/laminas-translator" - }, - "funding": [ - { - "url": "https://funding.communitybridge.org/projects/laminas-project", - "type": "community_bridge" - } - ], - "time": "2024-10-21T15:33:01+00:00" - }, { "name": "myclabs/deep-copy", "version": "1.12.1", @@ -3268,30 +3041,30 @@ }, { "name": "psr/log", - "version": "1.1.4", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" }, "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/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", "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/", @@ -3312,9 +3085,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.2" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2024-09-11T13:17:53+00:00" }, { "name": "sebastian/cli-parser", From 5f719d21be516f11980722be653eb9b3bd5738ac Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Mon, 25 Nov 2024 19:36:06 -0500 Subject: [PATCH 08/11] Setting CI to ignore platform requirements for PHP 8.4 Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- .laminas-ci.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .laminas-ci.json diff --git a/.laminas-ci.json b/.laminas-ci.json new file mode 100644 index 0000000..6fc4f6b --- /dev/null +++ b/.laminas-ci.json @@ -0,0 +1,6 @@ +{ + "backwardCompatibilityCheck": true, + "ignore_php_platform_requirements": { + "8.4": true + } +} From 3d9f7c4c5c6e58f96f1aafad581c6825823488c3 Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Mon, 25 Nov 2024 20:08:42 -0500 Subject: [PATCH 09/11] Updated dependencies to remove old versions and unused components Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- composer.json | 6 +++--- composer.lock | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 9ff2ca4..df5a96b 100644 --- a/composer.json +++ b/composer.json @@ -35,10 +35,10 @@ }, "require": { "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", - "laminas/laminas-eventmanager": "^2.6.4 || ^3.2.1", + "laminas/laminas-eventmanager": "^3.2.1", "laminas/laminas-http": "^2.10", - "laminas/laminas-mvc": "^2.7.15 || ^3.1.1", - "laminas/laminas-servicemanager": "^2.7.9 || ^3.4.0" + "laminas/laminas-mvc": "^3.1.1", + "laminas/laminas-servicemanager": "^3.4.0" }, "require-dev": { "laminas/laminas-modulemanager": "^2.7.2", diff --git a/composer.lock b/composer.lock index 0d02cdc..07751a6 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": "5f4efca55d003f99b6c8c60f813e3a48", + "content-hash": "efb8689f64b1f970138750e3a6ce4c63", "packages": [ { "name": "brick/varexporter", From ab54488b583ec990bea5d7e18f4835b3737224c8 Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Mon, 25 Nov 2024 21:47:49 -0500 Subject: [PATCH 10/11] Removing BackwardCompatibilityChecks in CI pipeline Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- .laminas-ci.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.laminas-ci.json b/.laminas-ci.json index 6fc4f6b..cc00d67 100644 --- a/.laminas-ci.json +++ b/.laminas-ci.json @@ -1,5 +1,4 @@ { - "backwardCompatibilityCheck": true, "ignore_php_platform_requirements": { "8.4": true } From d0fe843b27ee6f64191bc32dc1d0b27bf0d40f6d Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Mon, 25 Nov 2024 21:48:19 -0500 Subject: [PATCH 11/11] Replaced a lingering reference to Interop Container Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- src/Factory/CorsServiceFactory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Factory/CorsServiceFactory.php b/src/Factory/CorsServiceFactory.php index 3e15755..7507c8a 100644 --- a/src/Factory/CorsServiceFactory.php +++ b/src/Factory/CorsServiceFactory.php @@ -21,11 +21,11 @@ namespace LmcCors\Factory; -use interop\container\containerinterface; use Laminas\ServiceManager\Factory\FactoryInterface; use LmcCors\Options\CorsOptions; use LmcCors\Service\CorsService; use Psr\Container\ContainerExceptionInterface; +use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; /** @@ -38,7 +38,7 @@ class CorsServiceFactory implements FactoryInterface * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function __invoke(containerinterface $container, $requestedName, ?array $options = null): CorsService + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): CorsService { /** @var CorsOptions $corsOptions */ $corsOptions = $container->get(CorsOptions::class);