From 86c130bbac17da36e4e3de4cd808c951e9b96855 Mon Sep 17 00:00:00 2001 From: Nathanael Esayeas Date: Wed, 16 Nov 2022 00:32:32 -0600 Subject: [PATCH 1/5] Update composer config `platform.php` to `8.0.99` Signed-off-by: Nathanael Esayeas --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d73c29a..d3e55dd 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "config": { "sort-packages": true, "platform": { - "php": "7.4.99" + "php": "8.0.99" }, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true From 83500d2a6498cfd90f5154a33ef1d1c47f1b1af6 Mon Sep 17 00:00:00 2001 From: Nathanael Esayeas Date: Wed, 16 Nov 2022 00:32:39 -0600 Subject: [PATCH 2/5] Update composer `php` to `~8.0.0 || ~8.1.0 || ~8.2.0` Signed-off-by: Nathanael Esayeas --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d3e55dd..3beb347 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ } }, "require": { - "php": "^7.4 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "laminas/laminas-escaper": "^2.5", "league/plates": "^3.3", "mezzio/mezzio-helpers": "^5.2", From ac9cb985a71fa400b418ddddf2dcc241e2538baa Mon Sep 17 00:00:00 2001 From: Nathanael Esayeas Date: Wed, 16 Nov 2022 00:32:39 -0600 Subject: [PATCH 3/5] Ignore PHP platform requirements via `.laminas-ci.json` Signed-off-by: Nathanael Esayeas --- .laminas-ci.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.laminas-ci.json b/.laminas-ci.json index 2c63c08..89ee608 100644 --- a/.laminas-ci.json +++ b/.laminas-ci.json @@ -1,2 +1,5 @@ { -} + "ignore_php_platform_requirements": { + "8.2": true + } +} \ No newline at end of file From 9aa0b06dd837f76da4ec8f08c52d0b71fc234358 Mon Sep 17 00:00:00 2001 From: Nathanael Esayeas Date: Wed, 16 Nov 2022 10:41:14 -0600 Subject: [PATCH 4/5] Update composer.lock Signed-off-by: Nathanael Esayeas --- composer.lock | 344 +++++++++++++++----------------------------------- 1 file changed, 105 insertions(+), 239 deletions(-) diff --git a/composer.lock b/composer.lock index af4ddea..1261c1b 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": "3c03ae5d1d0ffeaaf8abf6b2aafaa813", + "content-hash": "7dd607b535a10d2d2c84f2f7bd25b21b", "packages": [ { "name": "fig/http-message-util", @@ -190,21 +190,21 @@ }, { "name": "mezzio/mezzio-helpers", - "version": "5.9.0", + "version": "5.11.0", "source": { "type": "git", "url": "https://github.com/mezzio/mezzio-helpers.git", - "reference": "b460d1d9ded9af5b9e257005afe2da1c4323ea13" + "reference": "ac47b19c92e050e53fe9172d3ccf7ab7cf9e9945" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mezzio/mezzio-helpers/zipball/b460d1d9ded9af5b9e257005afe2da1c4323ea13", - "reference": "b460d1d9ded9af5b9e257005afe2da1c4323ea13", + "url": "https://api.github.com/repos/mezzio/mezzio-helpers/zipball/ac47b19c92e050e53fe9172d3ccf7ab7cf9e9945", + "reference": "ac47b19c92e050e53fe9172d3ccf7ab7cf9e9945", "shasum": "" }, "require": { "mezzio/mezzio-router": "^3.0", - "php": "^7.4 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "psr/container": "^1.0 || ^2.0", "psr/http-message": "^1.0.1", "psr/http-server-middleware": "^1.0" @@ -215,12 +215,10 @@ "require-dev": { "ext-json": "*", "laminas/laminas-coding-standard": "~2.4.0", - "laminas/laminas-diactoros": "^2.11.1", - "mockery/mockery": "^1.4.2", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5.11", - "psalm/plugin-phpunit": "^0.15.1", - "vimeo/psalm": "^4.17" + "laminas/laminas-diactoros": "^2.19", + "phpunit/phpunit": "^9.5.25", + "psalm/plugin-phpunit": "^0.17.0", + "vimeo/psalm": "^4.29" }, "suggest": { "ext-json": "If you wish to use the JsonStrategy with BodyParamsMiddleware" @@ -264,25 +262,25 @@ "type": "community_bridge" } ], - "time": "2022-09-14T07:33:03+00:00" + "time": "2022-10-12T21:00:46+00:00" }, { "name": "mezzio/mezzio-router", - "version": "3.8.0", + "version": "3.9.0", "source": { "type": "git", "url": "https://github.com/mezzio/mezzio-router.git", - "reference": "27075d3e9b407791abf7ba5e62954a59be4b18df" + "reference": "5b03ab8ef9ae8323a9093d5b9d79a69a3733968f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mezzio/mezzio-router/zipball/27075d3e9b407791abf7ba5e62954a59be4b18df", - "reference": "27075d3e9b407791abf7ba5e62954a59be4b18df", + "url": "https://api.github.com/repos/mezzio/mezzio-router/zipball/5b03ab8ef9ae8323a9093d5b9d79a69a3733968f", + "reference": "5b03ab8ef9ae8323a9093d5b9d79a69a3733968f", "shasum": "" }, "require": { "fig/http-message-util": "^1.1.2", - "php": "^7.4 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "psr/container": "^1.0 || ^2.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.0.1", @@ -294,14 +292,12 @@ "zendframework/zend-expressive-router": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~2.3.0", - "laminas/laminas-diactoros": "^2.6", - "laminas/laminas-stratigility": "^3.4", - "phpspec/prophecy": "^1.9", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5.11", - "psalm/plugin-phpunit": "^0.15.0", - "vimeo/psalm": "^4.17" + "laminas/laminas-coding-standard": "~2.4.0", + "laminas/laminas-diactoros": "^2.18", + "laminas/laminas-stratigility": "^3.8", + "phpunit/phpunit": "^9.5.25", + "psalm/plugin-phpunit": "^0.17.0", + "vimeo/psalm": "^4.28" }, "suggest": { "mezzio/mezzio-aurarouter": "^3.0 to use the Aura.Router routing adapter", @@ -347,33 +343,33 @@ "type": "community_bridge" } ], - "time": "2022-01-06T16:27:49+00:00" + "time": "2022-10-10T19:40:00+00:00" }, { "name": "mezzio/mezzio-template", - "version": "2.5.0", + "version": "2.7.0", "source": { "type": "git", "url": "https://github.com/mezzio/mezzio-template.git", - "reference": "55b5ab7988ff495a9cdb5cbfc3e81dfb49cd06a6" + "reference": "ac7c34aa8b11efdd1a039af16f00bb625eab45bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mezzio/mezzio-template/zipball/55b5ab7988ff495a9cdb5cbfc3e81dfb49cd06a6", - "reference": "55b5ab7988ff495a9cdb5cbfc3e81dfb49cd06a6", + "url": "https://api.github.com/repos/mezzio/mezzio-template/zipball/ac7c34aa8b11efdd1a039af16f00bb625eab45bd", + "reference": "ac7c34aa8b11efdd1a039af16f00bb625eab45bd", "shasum": "" }, "require": { - "php": "^7.4 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "zendframework/zend-expressive-template": "*" }, "require-dev": { "laminas/laminas-coding-standard": "~2.4.0", - "phpunit/phpunit": "^9.5.24", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.27.0" + "vimeo/psalm": "^4.28" }, "suggest": { "mezzio/mezzio-laminasviewrenderer": "^2.0 to use the laminas-view PhpRenderer template renderer", @@ -411,7 +407,7 @@ "type": "community_bridge" } ], - "time": "2022-09-14T08:07:39+00:00" + "time": "2022-10-10T21:46:43+00:00" }, { "name": "psr/container", @@ -2684,30 +2680,30 @@ }, { "name": "psr/log", - "version": "1.1.4", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "3.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -2728,9 +2724,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/3.0.0" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2021-07-14T16:46:02+00:00" }, { "name": "sebastian/cli-parser", @@ -3815,46 +3811,42 @@ }, { "name": "symfony/console", - "version": "v5.4.15", + "version": "v6.0.15", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "ea59bb0edfaf9f28d18d8791410ee0355f317669" + "reference": "b0b910724a0a0326b4481e4f8a30abb2dd442efb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/ea59bb0edfaf9f28d18d8791410ee0355f317669", - "reference": "ea59bb0edfaf9f28d18d8791410ee0355f317669", + "url": "https://api.github.com/repos/symfony/console/zipball/b0b910724a0a0326b4481e4f8a30abb2dd442efb", + "reference": "b0b910724a0a0326b4481e4f8a30abb2dd442efb", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", + "php": ">=8.0.2", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.9", - "symfony/polyfill-php80": "^1.16", "symfony/service-contracts": "^1.1|^2|^3", - "symfony/string": "^5.1|^6.0" + "symfony/string": "^5.4|^6.0" }, "conflict": { - "psr/log": ">=3", - "symfony/dependency-injection": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/event-dispatcher": "<4.4", - "symfony/lock": "<4.4", - "symfony/process": "<4.4" + "symfony/dependency-injection": "<5.4", + "symfony/dotenv": "<5.4", + "symfony/event-dispatcher": "<5.4", + "symfony/lock": "<5.4", + "symfony/process": "<5.4" }, "provide": { - "psr/log-implementation": "1.0|2.0" + "psr/log-implementation": "1.0|2.0|3.0" }, "require-dev": { - "psr/log": "^1|^2", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/lock": "^4.4|^5.0|^6.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/var-dumper": "^4.4|^5.0|^6.0" + "psr/log": "^1|^2|^3", + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/event-dispatcher": "^5.4|^6.0", + "symfony/lock": "^5.4|^6.0", + "symfony/process": "^5.4|^6.0", + "symfony/var-dumper": "^5.4|^6.0" }, "suggest": { "psr/log": "For using the console logger", @@ -3894,7 +3886,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.15" + "source": "https://github.com/symfony/console/tree/v6.0.15" }, "funding": [ { @@ -3910,74 +3902,7 @@ "type": "tidelift" } ], - "time": "2022-10-26T21:41:52+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.5.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2022-10-26T21:42:20+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4309,85 +4234,6 @@ ], "time": "2022-11-03T14:55:06+00:00" }, - { - "name": "symfony/polyfill-php73", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9", - "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, { "name": "symfony/polyfill-php80", "version": "v1.27.0", @@ -4473,29 +4319,36 @@ }, { "name": "symfony/service-contracts", - "version": "v1.1.2", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0" + "reference": "d78d39c1599bd1188b8e26bb341da52c3c6d8a66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/191afdcb5804db960d26d8566b7e9a2843cab3a0", - "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d78d39c1599bd1188b8e26bb341da52c3c6d8a66", + "reference": "d78d39c1599bd1188b8e26bb341da52c3c6d8a66", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": ">=8.0.2", + "psr/container": "^2.0" + }, + "conflict": { + "ext-psr": "<1.1|>=2" }, "suggest": { - "psr/container": "", "symfony/service-implementation": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-main": "3.0-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -4528,40 +4381,53 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v1.1.2" + "source": "https://github.com/symfony/service-contracts/tree/v3.0.2" }, - "time": "2019-05-28T07:50:59+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-05-30T19:17:58+00:00" }, { "name": "symfony/string", - "version": "v5.4.15", + "version": "v6.0.15", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed" + "reference": "51ac0fa0ccf132a00519b87c97e8f775fa14e771" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", - "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", + "url": "https://api.github.com/repos/symfony/string/zipball/51ac0fa0ccf132a00519b87c97e8f775fa14e771", + "reference": "51ac0fa0ccf132a00519b87c97e8f775fa14e771", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.0.2", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "~1.15" + "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/translation-contracts": ">=3.0" + "symfony/translation-contracts": "<2.0" }, "require-dev": { - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/http-client": "^4.4|^5.0|^6.0", - "symfony/translation-contracts": "^1.1|^2", - "symfony/var-exporter": "^4.4|^5.0|^6.0" + "symfony/error-handler": "^5.4|^6.0", + "symfony/http-client": "^5.4|^6.0", + "symfony/translation-contracts": "^2.0|^3.0", + "symfony/var-exporter": "^5.4|^6.0" }, "type": "library", "autoload": { @@ -4600,7 +4466,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.15" + "source": "https://github.com/symfony/string/tree/v6.0.15" }, "funding": [ { @@ -4616,7 +4482,7 @@ "type": "tidelift" } ], - "time": "2022-10-05T15:16:54+00:00" + "time": "2022-10-10T09:34:08+00:00" }, { "name": "theseer/tokenizer", @@ -4893,7 +4759,7 @@ }, "platform-dev": [], "platform-overrides": { - "php": "7.4.99" + "php": "8.0.99" }, "plugin-api-version": "2.3.0" } From 49d2826af22a55cd69e53e933788b2a5145d95fe Mon Sep 17 00:00:00 2001 From: Nathanael Esayeas Date: Wed, 16 Nov 2022 10:41:31 -0600 Subject: [PATCH 5/5] Fix CS Issues Signed-off-by: Nathanael Esayeas --- src/Extension/UrlExtension.php | 8 +------- src/PlatesEngineFactory.php | 23 +++++++---------------- src/PlatesRenderer.php | 16 +++++++--------- test/PlatesEngineFactoryTest.php | 11 +---------- 4 files changed, 16 insertions(+), 42 deletions(-) diff --git a/src/Extension/UrlExtension.php b/src/Extension/UrlExtension.php index a4b3cbf..616cbb4 100644 --- a/src/Extension/UrlExtension.php +++ b/src/Extension/UrlExtension.php @@ -12,14 +12,8 @@ class UrlExtension implements ExtensionInterface { - private ServerUrlHelper $serverUrlHelper; - - private UrlHelper $urlHelper; - - public function __construct(UrlHelper $urlHelper, ServerUrlHelper $serverUrlHelper) + public function __construct(private UrlHelper $urlHelper, private ServerUrlHelper $serverUrlHelper) { - $this->urlHelper = $urlHelper; - $this->serverUrlHelper = $serverUrlHelper; } /** diff --git a/src/PlatesEngineFactory.php b/src/PlatesEngineFactory.php index 90be966..3d3c0c0 100644 --- a/src/PlatesEngineFactory.php +++ b/src/PlatesEngineFactory.php @@ -11,12 +11,9 @@ use function array_replace_recursive; use function class_exists; -use function get_class; -use function gettype; +use function get_debug_type; use function is_array; use function is_numeric; -use function is_object; -use function is_string; use function sprintf; use function trigger_error; @@ -165,27 +162,21 @@ private function injectExtensions(ContainerInterface $container, PlatesEngine $e * * If anything else is provided, an exception is raised. * - * @param ExtensionInterface|string $extension * @throws Exception\InvalidExtensionException For non-string, * non-extension $extension values. * @throws Exception\InvalidExtensionException For string $extension values * that do not resolve to an extension instance. */ - private function injectExtension(ContainerInterface $container, PlatesEngine $engine, $extension): void - { + private function injectExtension( + ContainerInterface $container, + PlatesEngine $engine, + ExtensionInterface|string $extension + ): void { if ($extension instanceof ExtensionInterface) { $engine->loadExtension($extension); return; } - if (! is_string($extension)) { - throw new Exception\InvalidExtensionException(sprintf( - '%s expects extension instances, service names, or class names; received %s', - self::class, - is_object($extension) ? get_class($extension) : gettype($extension) - )); - } - if (! $container->has($extension) && ! class_exists($extension)) { throw new Exception\InvalidExtensionException(sprintf( '%s expects extension service names or class names; "%s" does not resolve to either', @@ -203,7 +194,7 @@ private function injectExtension(ContainerInterface $container, PlatesEngine $en '%s expects extension services to implement %s ; received %s', self::class, ExtensionInterface::class, - is_object($extension) ? get_class($extension) : gettype($extension) + get_debug_type($extension) )); } diff --git a/src/PlatesRenderer.php b/src/PlatesRenderer.php index bb13084..3a34db1 100644 --- a/src/PlatesRenderer.php +++ b/src/PlatesRenderer.php @@ -12,12 +12,10 @@ use Mezzio\Template\TemplateRendererInterface; use ReflectionProperty; -use function get_class; -use function gettype; -use function is_object; -use function is_string; +use function get_debug_type; use function sprintf; use function trigger_error; +use function trim; use const E_USER_WARNING; @@ -90,19 +88,19 @@ public function getPaths(): array * * {@inheritDoc} */ - public function addDefaultParam(string $templateName, string $param, $value): void + public function addDefaultParam(string $templateName, string $param, mixed $value): void { - if (! is_string($templateName) || empty($templateName)) { + if ('' === trim($templateName)) { throw new Exception\InvalidArgumentException(sprintf( '$templateName must be a non-empty string; received %s', - is_object($templateName) ? get_class($templateName) : gettype($templateName) + get_debug_type($templateName) )); } - if (! is_string($param) || empty($param)) { + if ('' === trim($param)) { throw new Exception\InvalidArgumentException(sprintf( '$param must be a non-empty string; received %s', - is_object($param) ? get_class($param) : gettype($param) + get_debug_type($param) )); } diff --git a/test/PlatesEngineFactoryTest.php b/test/PlatesEngineFactoryTest.php index 69a8a16..ef05c34 100644 --- a/test/PlatesEngineFactoryTest.php +++ b/test/PlatesEngineFactoryTest.php @@ -146,16 +146,7 @@ public function testFactoryCanRegisterConfiguredExtensions(): void public function invalidExtensions(): array { return [ - 'null' => [null], - 'true' => [true], - 'false' => [false], - 'zero' => [0], - 'int' => [1], - 'zero-float' => [0.0], - 'float' => [1.1], - 'non-class-string' => ['not-a-class'], - 'array' => [['not-an-extension']], - 'non-extension-object' => [(object) ['extension' => 'not-really']], + 'non-class-string' => ['not-a-class'], ]; }