From a79609b3855cb8e712bcf2870c1f5ecbfa78064d Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Tue, 7 Dec 2021 20:54:57 +0100 Subject: [PATCH] Support for PHP 8.1 Signed-off-by: Witold Wasiczko --- composer.json | 6 +- composer.lock | 265 +++++++++--------- config/module.config.php | 2 + src/ApiProblem.php | 6 +- src/ApiProblemResponse.php | 7 +- src/Exception/DomainException.php | 2 + src/Exception/ExceptionInterface.php | 2 + src/Exception/InvalidArgumentException.php | 2 + src/Exception/ProblemExceptionInterface.php | 2 + src/Factory/ApiProblemListenerFactory.php | 2 + src/Factory/ApiProblemRendererFactory.php | 2 + src/Factory/ApiProblemStrategyFactory.php | 2 + src/Factory/RenderErrorListenerFactory.php | 2 + .../SendApiProblemResponseListenerFactory.php | 2 + src/Listener/ApiProblemListener.php | 2 + src/Listener/RenderErrorListener.php | 2 + .../SendApiProblemResponseListener.php | 2 + src/Module.php | 2 + src/View/ApiProblemModel.php | 2 + src/View/ApiProblemRenderer.php | 2 + src/View/ApiProblemStrategy.php | 2 + test/ApiProblemResponseTest.php | 19 +- test/ApiProblemTest.php | 4 +- test/Listener/ApiProblemListenerTest.php | 2 + test/Listener/RenderErrorListenerTest.php | 2 + .../SendApiProblemResponseListenerTest.php | 2 + test/ModuleTest.php | 2 + test/View/ApiProblemRendererTest.php | 2 + test/View/ApiProblemStrategyTest.php | 2 + 29 files changed, 203 insertions(+), 150 deletions(-) diff --git a/composer.json b/composer.json index de09c00..70c6875 100644 --- a/composer.json +++ b/composer.json @@ -27,17 +27,17 @@ } }, "require": { - "php": "^7.3 || ~8.0.0", + "php": "^7.3 || ~8.0.0 || ~8.1.0", "ext-json": "*", "laminas/laminas-eventmanager": "^2.6.3 || ^3.0.1", - "laminas/laminas-http": "^2.5.4", + "laminas/laminas-http": "^2.15.1", "laminas/laminas-json": "^2.6.1 || ^3.0", "laminas/laminas-mvc": "^2.7.15 || ^3.0.4", "laminas/laminas-view": "^2.8.1", "laminas/laminas-zendframework-bridge": "^1.0" }, "require-dev": { - "laminas/laminas-coding-standard": "~2.2.0", + "laminas/laminas-coding-standard": "~2.3.0", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.3", "psalm/plugin-phpunit": "^0.16.0", diff --git a/composer.lock b/composer.lock index 85aa3c1..a0fa149 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": "3017d27dd3106ad26749bb4f327d9558", + "content-hash": "6ebd3717042cb3db41d9d4571c65fbe6", "packages": [ { "name": "brick/varexporter", @@ -159,27 +159,26 @@ }, { "name": "laminas/laminas-escaper", - "version": "2.7.0", + "version": "2.9.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-escaper.git", - "reference": "5e04bc5ae5990b17159d79d331055e2c645e5cc5" + "reference": "891ad70986729e20ed2e86355fcf93c9dc238a5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/5e04bc5ae5990b17159d79d331055e2c645e5cc5", - "reference": "5e04bc5ae5990b17159d79d331055e2c645e5cc5", + "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/891ad70986729e20ed2e86355fcf93c9dc238a5f", + "reference": "891ad70986729e20ed2e86355fcf93c9dc238a5f", "shasum": "" }, "require": { - "laminas/laminas-zendframework-bridge": "^1.0", - "php": "^7.3 || ~8.0.0" + "php": "^7.3 || ~8.0.0 || ~8.1.0" }, - "replace": { - "zendframework/zend-escaper": "^2.6.1" + "conflict": { + "zendframework/zend-escaper": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~1.0.0", + "laminas/laminas-coding-standard": "~2.3.0", "phpunit/phpunit": "^9.3", "psalm/plugin-phpunit": "^0.12.2", "vimeo/psalm": "^3.16" @@ -218,7 +217,7 @@ "type": "community_bridge" } ], - "time": "2020-11-17T21:26:43+00:00" + "time": "2021-09-02T17:10:53+00:00" }, { "name": "laminas/laminas-eventmanager", @@ -288,33 +287,32 @@ }, { "name": "laminas/laminas-http", - "version": "2.14.3", + "version": "2.15.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-http.git", - "reference": "bfaab8093e382274efed7fdc3ceb15f09ba352bb" + "reference": "261f079c3dffcf6f123484db43c40e44c4bf1c79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-http/zipball/bfaab8093e382274efed7fdc3ceb15f09ba352bb", - "reference": "bfaab8093e382274efed7fdc3ceb15f09ba352bb", + "url": "https://api.github.com/repos/laminas/laminas-http/zipball/261f079c3dffcf6f123484db43c40e44c4bf1c79", + "reference": "261f079c3dffcf6f123484db43c40e44c4bf1c79", "shasum": "" }, "require": { - "laminas/laminas-loader": "^2.5.1", - "laminas/laminas-stdlib": "^3.2.1", - "laminas/laminas-uri": "^2.5.2", - "laminas/laminas-validator": "^2.10.1", - "laminas/laminas-zendframework-bridge": "^1.0", - "php": "^7.3 || ~8.0.0" + "laminas/laminas-loader": "^2.8", + "laminas/laminas-stdlib": "^3.6", + "laminas/laminas-uri": "^2.9.1", + "laminas/laminas-validator": "^2.15", + "php": "^7.3 || ~8.0.0 || ~8.1.0" }, - "replace": { - "zendframework/zend-http": "^2.11.2" + "conflict": { + "zendframework/zend-http": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~1.0.0", - "laminas/laminas-config": "^3.1 || ^2.6", - "phpunit/phpunit": "^9.3" + "ext-curl": "*", + "laminas/laminas-coding-standard": "~2.2.1", + "phpunit/phpunit": "^9.5.5" }, "suggest": { "paragonie/certainty": "For automated management of cacert.pem" @@ -350,7 +348,7 @@ "type": "community_bridge" } ], - "time": "2021-02-18T21:58:11+00:00" + "time": "2021-12-03T10:17:11+00:00" }, { "name": "laminas/laminas-json", @@ -416,27 +414,26 @@ }, { "name": "laminas/laminas-loader", - "version": "2.7.0", + "version": "2.8.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-loader.git", - "reference": "bcf8a566cb9925a2e7cc41a16db09235ec9fb616" + "reference": "d0589ec9dd48365fd95ad10d1c906efd7711c16b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-loader/zipball/bcf8a566cb9925a2e7cc41a16db09235ec9fb616", - "reference": "bcf8a566cb9925a2e7cc41a16db09235ec9fb616", + "url": "https://api.github.com/repos/laminas/laminas-loader/zipball/d0589ec9dd48365fd95ad10d1c906efd7711c16b", + "reference": "d0589ec9dd48365fd95ad10d1c906efd7711c16b", "shasum": "" }, "require": { - "laminas/laminas-zendframework-bridge": "^1.0", - "php": "^7.3 || ~8.0.0" + "php": "^7.3 || ~8.0.0 || ~8.1.0" }, - "replace": { - "zendframework/zend-loader": "^2.6.1" + "conflict": { + "zendframework/zend-loader": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~1.0.0", + "laminas/laminas-coding-standard": "~2.2.1", "phpunit/phpunit": "^9.3" }, "type": "library", @@ -469,7 +466,7 @@ "type": "community_bridge" } ], - "time": "2021-02-12T16:08:18+00:00" + "time": "2021-09-02T18:30:53+00:00" }, { "name": "laminas/laminas-modulemanager", @@ -787,29 +784,30 @@ }, { "name": "laminas/laminas-stdlib", - "version": "3.3.1", + "version": "3.6.2", "source": { "type": "git", "url": "https://github.com/laminas/laminas-stdlib.git", - "reference": "d81c7ffe602ed0e6ecb18691019111c0f4bf1efe" + "reference": "6fe0842909638ca6bea8401b7e8168fb154bffb5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/d81c7ffe602ed0e6ecb18691019111c0f4bf1efe", - "reference": "d81c7ffe602ed0e6ecb18691019111c0f4bf1efe", + "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/6fe0842909638ca6bea8401b7e8168fb154bffb5", + "reference": "6fe0842909638ca6bea8401b7e8168fb154bffb5", "shasum": "" }, "require": { - "laminas/laminas-zendframework-bridge": "^1.0", - "php": "^7.3 || ^8.0" + "php": "^7.3 || ~8.0.0 || ~8.1.0" }, - "replace": { - "zendframework/zend-stdlib": "^3.2.1" + "conflict": { + "zendframework/zend-stdlib": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~1.0.0", + "laminas/laminas-coding-standard": "~2.3.0", "phpbench/phpbench": "^0.17.1", - "phpunit/phpunit": "~9.3.7" + "phpunit/phpunit": "~9.3.7", + "psalm/plugin-phpunit": "^0.16.0", + "vimeo/psalm": "^4.7" }, "type": "library", "autoload": { @@ -841,34 +839,33 @@ "type": "community_bridge" } ], - "time": "2020-11-19T20:18:59+00:00" + "time": "2021-12-07T21:06:58+00:00" }, { "name": "laminas/laminas-uri", - "version": "2.8.1", + "version": "2.9.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-uri.git", - "reference": "79bd4c614c8cf9a6ba715a49fca8061e84933d87" + "reference": "7e837dc15c8fd3949df7d1213246fd7c8640032b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-uri/zipball/79bd4c614c8cf9a6ba715a49fca8061e84933d87", - "reference": "79bd4c614c8cf9a6ba715a49fca8061e84933d87", + "url": "https://api.github.com/repos/laminas/laminas-uri/zipball/7e837dc15c8fd3949df7d1213246fd7c8640032b", + "reference": "7e837dc15c8fd3949df7d1213246fd7c8640032b", "shasum": "" }, "require": { - "laminas/laminas-escaper": "^2.5", - "laminas/laminas-validator": "^2.10", - "laminas/laminas-zendframework-bridge": "^1.0", - "php": "^7.3 || ~8.0.0" + "laminas/laminas-escaper": "^2.9", + "laminas/laminas-validator": "^2.15", + "php": "^7.3 || ~8.0.0 || ~8.1.0" }, - "replace": { - "zendframework/zend-uri": "^2.7.1" + "conflict": { + "zendframework/zend-uri": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "^2.1", - "phpunit/phpunit": "^9.3" + "laminas/laminas-coding-standard": "~2.2.1", + "phpunit/phpunit": "^9.5.5" }, "type": "library", "autoload": { @@ -900,35 +897,33 @@ "type": "community_bridge" } ], - "time": "2021-02-17T21:53:05+00:00" + "time": "2021-09-09T18:37:15+00:00" }, { "name": "laminas/laminas-validator", - "version": "2.14.4", + "version": "2.15.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-validator.git", - "reference": "e370c4695db1c81e6dfad38d8c4dbdb37b23d776" + "reference": "fbd87f30c0a27aaeeee8adb2f934c14fb6046c80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/e370c4695db1c81e6dfad38d8c4dbdb37b23d776", - "reference": "e370c4695db1c81e6dfad38d8c4dbdb37b23d776", + "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/fbd87f30c0a27aaeeee8adb2f934c14fb6046c80", + "reference": "fbd87f30c0a27aaeeee8adb2f934c14fb6046c80", "shasum": "" }, "require": { "container-interop/container-interop": "^1.1", - "laminas/laminas-stdlib": "^3.3", - "laminas/laminas-zendframework-bridge": "^1.0", - "php": "^7.3 || ~8.0.0" + "laminas/laminas-stdlib": "^3.6", + "php": "^7.3 || ~8.0.0 || ~8.1.0" }, - "replace": { - "zendframework/zend-validator": "^2.13.0" + "conflict": { + "zendframework/zend-validator": "*" }, "require-dev": { "laminas/laminas-cache": "^2.6.1", - "laminas/laminas-coding-standard": "~1.0.0", - "laminas/laminas-config": "^2.6", + "laminas/laminas-coding-standard": "~2.2.1", "laminas/laminas-db": "^2.7", "laminas/laminas-filter": "^2.6", "laminas/laminas-http": "^2.14.2", @@ -938,7 +933,7 @@ "laminas/laminas-session": "^2.8", "laminas/laminas-uri": "^2.7", "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.3", + "phpunit/phpunit": "^9.5.5", "psalm/plugin-phpunit": "^0.15.0", "psr/http-client": "^1.0", "psr/http-factory": "^1.0", @@ -992,7 +987,7 @@ "type": "community_bridge" } ], - "time": "2021-01-24T20:45:49+00:00" + "time": "2021-12-02T14:23:06+00:00" }, { "name": "laminas/laminas-view", @@ -1100,23 +1095,23 @@ }, { "name": "laminas/laminas-zendframework-bridge", - "version": "1.2.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-zendframework-bridge.git", - "reference": "6cccbddfcfc742eb02158d6137ca5687d92cee32" + "reference": "bf180a382393e7db5c1e8d0f2ec0c4af9c724baf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/6cccbddfcfc742eb02158d6137ca5687d92cee32", - "reference": "6cccbddfcfc742eb02158d6137ca5687d92cee32", + "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/bf180a382393e7db5c1e8d0f2ec0c4af9c724baf", + "reference": "bf180a382393e7db5c1e8d0f2ec0c4af9c724baf", "shasum": "" }, "require": { - "php": "^7.3 || ^8.0" + "php": "^7.3 || ~8.0.0 || ~8.1.0" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1 || ^9.3", + "phpunit/phpunit": "^9.3", "psalm/plugin-phpunit": "^0.15.1", "squizlabs/php_codesniffer": "^3.5", "vimeo/psalm": "^4.6" @@ -1158,7 +1153,7 @@ "type": "community_bridge" } ], - "time": "2021-02-25T21:54:58+00:00" + "time": "2021-09-03T17:53:30+00:00" }, { "name": "nikic/php-parser", @@ -1988,24 +1983,24 @@ }, { "name": "laminas/laminas-coding-standard", - "version": "2.2.1", + "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-coding-standard.git", - "reference": "c953ecb1d37034f4aa326046e2c24a10fe0a2845" + "reference": "bcf6e07fe4690240be7beb6d884d0b0fafa6a251" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/c953ecb1d37034f4aa326046e2c24a10fe0a2845", - "reference": "c953ecb1d37034f4aa326046e2c24a10fe0a2845", + "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/bcf6e07fe4690240be7beb6d884d0b0fafa6a251", + "reference": "bcf6e07fe4690240be7beb6d884d0b0fafa6a251", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", - "php": "^7.3 || ~8.0.0", - "slevomat/coding-standard": "^6.4.1", - "squizlabs/php_codesniffer": "^3.5.8", - "webimpress/coding-standard": "^1.1.6" + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "php": "^7.3 || ^8.0", + "slevomat/coding-standard": "^7.0", + "squizlabs/php_codesniffer": "^3.6", + "webimpress/coding-standard": "^1.2" }, "type": "phpcodesniffer-standard", "autoload": { @@ -2037,7 +2032,7 @@ "type": "community_bridge" } ], - "time": "2021-05-17T17:39:41+00:00" + "time": "2021-05-29T15:53:59+00:00" }, { "name": "myclabs/deep-copy", @@ -2591,37 +2586,33 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "0.4.9", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531" + "reference": "dbc093d7af60eff5cd575d2ed761b15ed40bd08e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/98a088b17966bdf6ee25c8a4b634df313d8aa531", - "reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/dbc093d7af60eff5cd575d2ed761b15ed40bd08e", + "reference": "dbc093d7af60eff5cd575d2ed761b15ed40bd08e", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "consistence/coding-standard": "^3.5", - "ergebnis/composer-normalize": "^2.0.2", - "jakub-onderka/php-parallel-lint": "^0.9.2", - "phing/phing": "^2.16.0", + "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12.26", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^6.3", - "slevomat/coding-standard": "^4.7.2", - "symfony/process": "^4.0" + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5", + "symfony/process": "^5.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "0.4-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -2638,9 +2629,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/master" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.2.0" }, - "time": "2020-08-03T20:32:43+00:00" + "time": "2021-09-16T20:46:02+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4139,37 +4130,37 @@ }, { "name": "slevomat/coding-standard", - "version": "6.4.1", + "version": "7.0.18", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "696dcca217d0c9da2c40d02731526c1e25b65346" + "reference": "b81ac84f41a4797dc25c8ede1b0718e2a74be0fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/696dcca217d0c9da2c40d02731526c1e25b65346", - "reference": "696dcca217d0c9da2c40d02731526c1e25b65346", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/b81ac84f41a4797dc25c8ede1b0718e2a74be0fc", + "reference": "b81ac84f41a4797dc25c8ede1b0718e2a74be0fc", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", "php": "^7.1 || ^8.0", - "phpstan/phpdoc-parser": "0.4.5 - 0.4.9", - "squizlabs/php_codesniffer": "^3.5.6" + "phpstan/phpdoc-parser": "^1.0.0", + "squizlabs/php_codesniffer": "^3.6.1" }, "require-dev": { - "phing/phing": "2.16.3", - "php-parallel-lint/php-parallel-lint": "1.2.0", - "phpstan/phpstan": "0.12.48", - "phpstan/phpstan-deprecation-rules": "0.12.5", - "phpstan/phpstan-phpunit": "0.12.16", - "phpstan/phpstan-strict-rules": "0.12.5", - "phpunit/phpunit": "7.5.20|8.5.5|9.4.0" + "phing/phing": "2.17.0", + "php-parallel-lint/php-parallel-lint": "1.3.1", + "phpstan/phpstan": "1.2.0", + "phpstan/phpstan-deprecation-rules": "1.0.0", + "phpstan/phpstan-phpunit": "1.0.0", + "phpstan/phpstan-strict-rules": "1.1.0", + "phpunit/phpunit": "7.5.20|8.5.21|9.5.10" }, "type": "phpcodesniffer-standard", "extra": { "branch-alias": { - "dev-master": "6.x-dev" + "dev-master": "7.x-dev" } }, "autoload": { @@ -4184,7 +4175,7 @@ "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/6.4.1" + "source": "https://github.com/slevomat/coding-standard/tree/7.0.18" }, "funding": [ { @@ -4196,20 +4187,20 @@ "type": "tidelift" } ], - "time": "2020-10-05T12:39:37+00:00" + "time": "2021-12-07T17:19:06+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.6.0", + "version": "3.6.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" + "reference": "f268ca40d54617c6e06757f83f699775c9b3ff2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", - "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/f268ca40d54617c6e06757f83f699775c9b3ff2e", + "reference": "f268ca40d54617c6e06757f83f699775c9b3ff2e", "shasum": "" }, "require": { @@ -4252,7 +4243,7 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2021-04-09T00:54:41+00:00" + "time": "2021-10-11T04:00:11+00:00" }, { "name": "symfony/console", @@ -5224,24 +5215,24 @@ }, { "name": "webimpress/coding-standard", - "version": "1.2.2", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/webimpress/coding-standard.git", - "reference": "8f4a220de33f471a8101836f7ec72b852c3f9f03" + "reference": "7a71421c7fc85827488f10c4c510fe80f94d1a74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webimpress/coding-standard/zipball/8f4a220de33f471a8101836f7ec72b852c3f9f03", - "reference": "8f4a220de33f471a8101836f7ec72b852c3f9f03", + "url": "https://api.github.com/repos/webimpress/coding-standard/zipball/7a71421c7fc85827488f10c4c510fe80f94d1a74", + "reference": "7a71421c7fc85827488f10c4c510fe80f94d1a74", "shasum": "" }, "require": { "php": "^7.3 || ^8.0", - "squizlabs/php_codesniffer": "^3.6" + "squizlabs/php_codesniffer": "^3.6.1" }, "require-dev": { - "phpunit/phpunit": "^9.5.4" + "phpunit/phpunit": "^9.5.10" }, "type": "phpcodesniffer-standard", "extra": { @@ -5267,7 +5258,7 @@ ], "support": { "issues": "https://github.com/webimpress/coding-standard/issues", - "source": "https://github.com/webimpress/coding-standard/tree/1.2.2" + "source": "https://github.com/webimpress/coding-standard/tree/1.2.3" }, "funding": [ { @@ -5275,7 +5266,7 @@ "type": "github" } ], - "time": "2021-04-12T12:51:27+00:00" + "time": "2021-10-28T21:18:17+00:00" }, { "name": "webmozart/assert", @@ -5392,7 +5383,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.3 || ~8.0.0", + "php": "^7.3 || ~8.0.0 || ~8.1.0", "ext-json": "*" }, "platform-dev": [], diff --git a/config/module.config.php b/config/module.config.php index bac3933..6720fde 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -1,5 +1,7 @@ status = $status; + $this->status = (int) $status; $this->detail = $detail; $this->title = $title; diff --git a/src/ApiProblemResponse.php b/src/ApiProblemResponse.php index 5a4d381..29ee95a 100644 --- a/src/ApiProblemResponse.php +++ b/src/ApiProblemResponse.php @@ -1,5 +1,7 @@ apiProblem = $apiProblem; $this->setCustomStatusCode($apiProblem->status); - $this->setReasonPhrase($apiProblem->title); + + if ($apiProblem->title !== null) { + $this->setReasonPhrase($apiProblem->title); + } $this->jsonFlags = JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR; } diff --git a/src/Exception/DomainException.php b/src/Exception/DomainException.php index 90af177..1672cd8 100644 --- a/src/Exception/DomainException.php +++ b/src/Exception/DomainException.php @@ -1,5 +1,7 @@ assertInstanceOf(Response::class, $response); } - /** - * @depends testApiProblemResponseIsAnHttpResponse - */ public function testApiProblemResponseSetsStatusCodeAndReasonPhrase(): void { $response = new ApiProblemResponse(new ApiProblem(400, 'Random error')); @@ -32,6 +32,16 @@ public function testApiProblemResponseSetsStatusCodeAndReasonPhrase(): void $this->assertEquals('bad request', strtolower($response->getReasonPhrase())); } + public function testApiProblemResponseSetsStatusCodeAndReasonPhraseUsingException(): void + { + $exception = new DomainException('Random error', 400); + $response = new ApiProblemResponse(new ApiProblem(400, $exception)); + $this->assertEquals(400, $response->getStatusCode()); + $this->assertIsString($response->getReasonPhrase()); + $this->assertNotEmpty($response->getReasonPhrase()); + $this->assertEquals('bad request', strtolower($response->getReasonPhrase())); + } + public function testApiProblemResponseBodyIsSerializedApiProblem(): void { $additional = [ @@ -51,9 +61,6 @@ public function testApiProblemResponseBodyIsSerializedApiProblem(): void $this->assertEquals($expected, json_decode($response->getContent(), true)); } - /** - * @depends testApiProblemResponseIsAnHttpResponse - */ public function testApiProblemResponseSetsContentTypeHeader(): void { $response = new ApiProblemResponse(new ApiProblem(400, 'Random error')); diff --git a/test/ApiProblemTest.php b/test/ApiProblemTest.php index 5c351bf..f80ed08 100644 --- a/test/ApiProblemTest.php +++ b/test/ApiProblemTest.php @@ -1,5 +1,7 @@ setDetailIncludesStackTrace(true); diff --git a/test/Listener/ApiProblemListenerTest.php b/test/Listener/ApiProblemListenerTest.php index d095cde..10b478a 100644 --- a/test/Listener/ApiProblemListenerTest.php +++ b/test/Listener/ApiProblemListenerTest.php @@ -1,5 +1,7 @@