From 7e1556c49a5a5fb06da5211dda5a157ebd9e0313 Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 7 Jun 2022 12:33:21 +0100 Subject: [PATCH 1/8] Remove ServiceManager V2 compatibility - Removes SMv2 compat in the InputFilterPluginManager because it cannot possibly be installed anymore - Replaces usage of aliases for Input|Filter|Validator plugin managers with FQCN - Adds a psalm plugin to dev dependencies for typical Psr Container methods - Updates locked dependencies on 7.4 - Fixes a number of psalm issues, updating baseline Signed-off-by: George Steel --- composer.json | 1 + composer.lock | 436 ++++++++++++------ docs/book/specs.md | 5 +- psalm-baseline.xml | 94 +--- psalm.xml.dist | 3 +- src/Factory.php | 3 +- src/InputFilterAbstractServiceFactory.php | 23 +- src/InputFilterPluginManager.php | 54 ++- src/InputFilterPluginManagerFactory.php | 29 +- test/FactoryTest.php | 23 +- .../InputFilterAbstractServiceFactoryTest.php | 47 +- ...utFilterPluginManagerCompatibilityTest.php | 6 + test/InputFilterPluginManagerFactoryTest.php | 31 +- test/InputFilterPluginManagerTest.php | 4 +- test/InputTest.php | 22 +- 15 files changed, 431 insertions(+), 350 deletions(-) diff --git a/composer.json b/composer.json index 6d8ae2cb..cbc15053 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,7 @@ "require-dev": { "laminas/laminas-coding-standard": "~2.2.1", "laminas/laminas-db": "^2.13.4", + "lctrs/psalm-psr-container-plugin": "^1.6", "phpspec/prophecy": "^1.14", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.5.5", diff --git a/composer.lock b/composer.lock index 5e19f74d..f2b35946 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": "53f38233dacf2b64b07daad58d574517", + "content-hash": "1e6e782cccb2eaf302c4c3e3297ba80b", "packages": [ { "name": "container-interop/container-interop", @@ -408,16 +408,16 @@ "packages-dev": [ { "name": "amphp/amp", - "version": "v2.6.1", + "version": "v2.6.2", "source": { "type": "git", "url": "https://github.com/amphp/amp.git", - "reference": "c5fc66a78ee38d7ac9195a37bacaf940eb3f65ae" + "reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/c5fc66a78ee38d7ac9195a37bacaf940eb3f65ae", - "reference": "c5fc66a78ee38d7ac9195a37bacaf940eb3f65ae", + "url": "https://api.github.com/repos/amphp/amp/zipball/9d5100cebffa729aaffecd3ad25dc5aeea4f13bb", + "reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb", "shasum": "" }, "require": { @@ -470,7 +470,7 @@ } ], "description": "A non-blocking concurrency framework for PHP applications.", - "homepage": "http://amphp.org/amp", + "homepage": "https://amphp.org/amp", "keywords": [ "async", "asynchronous", @@ -485,7 +485,7 @@ "support": { "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/v2.6.1" + "source": "https://github.com/amphp/amp/tree/v2.6.2" }, "funding": [ { @@ -493,7 +493,7 @@ "type": "github" } ], - "time": "2021-09-23T18:43:08+00:00" + "time": "2022-02-20T17:52:18+00:00" }, { "name": "amphp/byte-stream", @@ -574,16 +574,16 @@ }, { "name": "composer/package-versions-deprecated", - "version": "1.11.99.4", + "version": "1.11.99.5", "source": { "type": "git", "url": "https://github.com/composer/package-versions-deprecated.git", - "reference": "b174585d1fe49ceed21928a945138948cb394600" + "reference": "b4f54f74ef3453349c24a845d22392cd31e65f1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/b174585d1fe49ceed21928a945138948cb394600", - "reference": "b174585d1fe49ceed21928a945138948cb394600", + "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/b4f54f74ef3453349c24a845d22392cd31e65f1d", + "reference": "b4f54f74ef3453349c24a845d22392cd31e65f1d", "shasum": "" }, "require": { @@ -627,7 +627,7 @@ "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", "support": { "issues": "https://github.com/composer/package-versions-deprecated/issues", - "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.4" + "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.5" }, "funding": [ { @@ -643,27 +643,98 @@ "type": "tidelift" } ], - "time": "2021-09-13T08:41:34+00:00" + "time": "2022-01-17T14:14:24+00:00" + }, + { + "name": "composer/pcre", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "e300eb6c535192decd27a85bc72a9290f0d6b3bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/e300eb6c535192decd27a85bc72a9290f0d6b3bd", + "reference": "e300eb6c535192decd27a85bc72a9290f0d6b3bd", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.3", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.0.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-02-25T20:21:48+00:00" }, { "name": "composer/semver", - "version": "3.2.6", + "version": "3.3.2", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "83e511e247de329283478496f7a1e114c9517506" + "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/83e511e247de329283478496f7a1e114c9517506", - "reference": "83e511e247de329283478496f7a1e114c9517506", + "url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9", + "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^0.12.54", + "phpstan/phpstan": "^1.4", "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", @@ -708,7 +779,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.2.6" + "source": "https://github.com/composer/semver/tree/3.3.2" }, "funding": [ { @@ -724,29 +795,31 @@ "type": "tidelift" } ], - "time": "2021-10-25T11:34:17+00:00" + "time": "2022-04-01T19:23:25+00:00" }, { "name": "composer/xdebug-handler", - "version": "2.0.2", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339" + "reference": "ced299686f41dce890debac69273b47ffe98a40c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/84674dd3a7575ba617f5a76d7e9e29a7d3891339", - "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c", + "reference": "ced299686f41dce890debac69273b47ffe98a40c", "shasum": "" }, "require": { - "php": "^5.3.2 || ^7.0 || ^8.0", + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", "psr/log": "^1 || ^2 || ^3" }, "require-dev": { - "phpstan/phpstan": "^0.12.55", - "symfony/phpunit-bridge": "^4.2 || ^5" + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^6.0" }, "type": "library", "autoload": { @@ -772,7 +845,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/2.0.2" + "source": "https://github.com/composer/xdebug-handler/tree/3.0.3" }, "funding": [ { @@ -788,7 +861,7 @@ "type": "tidelift" } ], - "time": "2021-07-31T17:03:58+00:00" + "time": "2022-02-25T21:32:43+00:00" }, { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -1013,16 +1086,16 @@ }, { "name": "felixfbecker/language-server-protocol", - "version": "1.5.1", + "version": "v1.5.2", "source": { "type": "git", "url": "https://github.com/felixfbecker/php-language-server-protocol.git", - "reference": "9d846d1f5cf101deee7a61c8ba7caa0a975cd730" + "reference": "6e82196ffd7c62f7794d778ca52b69feec9f2842" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/9d846d1f5cf101deee7a61c8ba7caa0a975cd730", - "reference": "9d846d1f5cf101deee7a61c8ba7caa0a975cd730", + "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/6e82196ffd7c62f7794d778ca52b69feec9f2842", + "reference": "6e82196ffd7c62f7794d778ca52b69feec9f2842", "shasum": "" }, "require": { @@ -1063,9 +1136,9 @@ ], "support": { "issues": "https://github.com/felixfbecker/php-language-server-protocol/issues", - "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/1.5.1" + "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/v1.5.2" }, - "time": "2021-02-22T14:02:09+00:00" + "time": "2022-03-02T22:36:06+00:00" }, { "name": "laminas/laminas-coding-standard", @@ -1191,6 +1264,84 @@ ], "time": "2021-09-21T18:59:44+00:00" }, + { + "name": "lctrs/psalm-psr-container-plugin", + "version": "1.6.0", + "source": { + "type": "git", + "url": "https://github.com/Lctrs/psalm-psr-container-plugin.git", + "reference": "799bd0af3ccf0f524e43527780e1b15ec9a60990" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Lctrs/psalm-psr-container-plugin/zipball/799bd0af3ccf0f524e43527780e1b15ec9a60990", + "reference": "799bd0af3ccf0f524e43527780e1b15ec9a60990", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "nikic/php-parser": "^4.13.2", + "php": "^7.3.0 || >=8.0.0 <8.2.0", + "psr/container": "^1.1.1", + "vimeo/psalm": "^4.16.1" + }, + "require-dev": { + "codeception/codeception": "^4.1.27", + "codeception/module-asserts": "^1.3.1", + "codeception/module-cli": "^1.1.1", + "codeception/module-filesystem": "^1.0.3", + "doctrine/coding-standard": "^9.0.0", + "ergebnis/composer-normalize": "^2.20.0", + "ergebnis/license": "^1.1.0", + "phpstan/extension-installer": "^1.1.0", + "phpstan/phpstan": "^1.3.0", + "phpstan/phpstan-deprecation-rules": "^1.0.0", + "phpstan/phpstan-phpunit": "^1.0.0", + "phpstan/phpstan-strict-rules": "^1.1.0", + "phpunit/phpunit": "^9.5.11", + "psalm/plugin-phpunit": "^0.16.1", + "symfony/yaml": "^5.4.0", + "weirdan/codeception-psalm-module": "^0.13.1" + }, + "type": "psalm-plugin", + "extra": { + "psalm": { + "pluginClass": "Lctrs\\PsalmPsrContainerPlugin\\Plugin" + } + }, + "autoload": { + "psr-4": { + "Lctrs\\PsalmPsrContainerPlugin\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jérôme Parmentier", + "email": "jerome@prmntr.me" + } + ], + "description": "Let Psalm understand better psr11 containers", + "homepage": "https://github.com/Lctrs/psalm-psr-container-plugin", + "keywords": [ + "code", + "container", + "inspection", + "php", + "psalm", + "psalm-plugin", + "psr", + "psr11" + ], + "support": { + "issues": "https://github.com/Lctrs/psalm-psr-container-plugin/issues", + "source": "https://github.com/Lctrs/psalm-psr-container-plugin" + }, + "time": "2021-12-29T20:10:48+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.10.2", @@ -1299,16 +1450,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.13.2", + "version": "v4.14.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "210577fe3cf7badcc5814d99455df46564f3c077" + "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", - "reference": "210577fe3cf7badcc5814d99455df46564f3c077", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/34bea19b6e03d8153165d8f30bba4c3be86184c1", + "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1", "shasum": "" }, "require": { @@ -1349,9 +1500,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.14.0" }, - "time": "2021-11-30T19:35:32+00:00" + "time": "2022-05-31T20:59:12+00:00" }, { "name": "openlss/lib-array2xml", @@ -1629,16 +1780,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.5.1", + "version": "1.6.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae" + "reference": "77a32518733312af16a44300404e945338981de3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/a12f7e301eb7258bb68acd89d4aefa05c2906cae", - "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3", + "reference": "77a32518733312af16a44300404e945338981de3", "shasum": "" }, "require": { @@ -1673,9 +1824,9 @@ "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.5.1" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1" }, - "time": "2021-10-02T14:08:47+00:00" + "time": "2022-03-15T21:29:03+00:00" }, { "name": "phpspec/prophecy", @@ -3516,23 +3667,23 @@ }, { "name": "symfony/console", - "version": "v5.4.0", + "version": "v5.4.9", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "ec3661faca1d110d6c307e124b44f99ac54179e3" + "reference": "829d5d1bf60b2efeb0887b7436873becc71a45eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/ec3661faca1d110d6c307e124b44f99ac54179e3", - "reference": "ec3661faca1d110d6c307e124b44f99ac54179e3", + "url": "https://api.github.com/repos/symfony/console/zipball/829d5d1bf60b2efeb0887b7436873becc71a45eb", + "reference": "829d5d1bf60b2efeb0887b7436873becc71a45eb", "shasum": "" }, "require": { "php": ">=7.2.5", "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php73": "^1.9", "symfony/polyfill-php80": "^1.16", "symfony/service-contracts": "^1.1|^2|^3", "symfony/string": "^5.1|^6.0" @@ -3595,7 +3746,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.0" + "source": "https://github.com/symfony/console/tree/v5.4.9" }, "funding": [ { @@ -3611,20 +3762,20 @@ "type": "tidelift" } ], - "time": "2021-11-29T15:30:56+00:00" + "time": "2022-05-18T06:17:34+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.0", + "version": "v2.5.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8" + "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/6f981ee24cf69ee7ce9736146d1c57c2780598a8", - "reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", "shasum": "" }, "require": { @@ -3662,7 +3813,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.1" }, "funding": [ { @@ -3678,32 +3829,35 @@ "type": "tidelift" } ], - "time": "2021-07-12T14:48:14+00:00" + "time": "2022-01-02T09:53:40+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.23.0", + "version": "v1.26.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" + "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", + "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", "shasum": "" }, "require": { "php": ">=7.1" }, + "provide": { + "ext-ctype": "*" + }, "suggest": { "ext-ctype": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.26-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3711,12 +3865,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3741,7 +3895,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0" }, "funding": [ { @@ -3757,20 +3911,20 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2022-05-24T11:49:31+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.23.1", + "version": "v1.26.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "16880ba9c5ebe3642d1995ab866db29270b36535" + "reference": "433d05519ce6990bf3530fba6957499d327395c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/16880ba9c5ebe3642d1995ab866db29270b36535", - "reference": "16880ba9c5ebe3642d1995ab866db29270b36535", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/433d05519ce6990bf3530fba6957499d327395c2", + "reference": "433d05519ce6990bf3530fba6957499d327395c2", "shasum": "" }, "require": { @@ -3782,7 +3936,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.26-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3822,7 +3976,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.1" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.26.0" }, "funding": [ { @@ -3838,20 +3992,20 @@ "type": "tidelift" } ], - "time": "2021-05-27T12:26:48+00:00" + "time": "2022-05-24T11:49:31+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.23.0", + "version": "v1.26.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" + "reference": "219aa369ceff116e673852dce47c3a41794c14bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", - "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/219aa369ceff116e673852dce47c3a41794c14bd", + "reference": "219aa369ceff116e673852dce47c3a41794c14bd", "shasum": "" }, "require": { @@ -3863,7 +4017,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.26-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3906,7 +4060,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.26.0" }, "funding": [ { @@ -3922,32 +4076,35 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2022-05-24T11:49:31+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.23.1", + "version": "v1.26.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" + "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", - "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", + "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", "shasum": "" }, "require": { "php": ">=7.1" }, + "provide": { + "ext-mbstring": "*" + }, "suggest": { "ext-mbstring": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.26-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3986,7 +4143,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0" }, "funding": [ { @@ -4002,20 +4159,20 @@ "type": "tidelift" } ], - "time": "2021-05-27T12:26:48+00:00" + "time": "2022-05-24T11:49:31+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.23.0", + "version": "v1.26.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010" + "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010", - "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85", + "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85", "shasum": "" }, "require": { @@ -4024,7 +4181,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.26-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4065,7 +4222,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.26.0" }, "funding": [ { @@ -4081,20 +4238,20 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2022-05-24T11:49:31+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.23.1", + "version": "v1.26.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" + "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", - "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace", + "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace", "shasum": "" }, "require": { @@ -4103,7 +4260,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.26-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4148,7 +4305,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0" }, "funding": [ { @@ -4164,26 +4321,26 @@ "type": "tidelift" } ], - "time": "2021-07-28T13:41:28+00:00" + "time": "2022-05-10T07:21:04+00:00" }, { "name": "symfony/service-contracts", - "version": "v2.5.0", + "version": "v2.5.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "1ab11b933cd6bc5464b08e81e2c5b07dec58b0fc" + "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/1ab11b933cd6bc5464b08e81e2c5b07dec58b0fc", - "reference": "1ab11b933cd6bc5464b08e81e2c5b07dec58b0fc", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/24d9dc654b83e91aa59f9d167b131bc3b5bea24c", + "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c", "shasum": "" }, "require": { "php": ">=7.2.5", "psr/container": "^1.1", - "symfony/deprecation-contracts": "^2.1" + "symfony/deprecation-contracts": "^2.1|^3" }, "conflict": { "ext-psr": "<1.1|>=2" @@ -4231,7 +4388,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.0" + "source": "https://github.com/symfony/service-contracts/tree/v2.5.1" }, "funding": [ { @@ -4247,20 +4404,20 @@ "type": "tidelift" } ], - "time": "2021-11-04T16:48:04+00:00" + "time": "2022-03-13T20:07:29+00:00" }, { "name": "symfony/string", - "version": "v5.4.0", + "version": "v5.4.9", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "9ffaaba53c61ba75a3c7a3a779051d1e9ec4fd2d" + "reference": "985e6a9703ef5ce32ba617c9c7d97873bb7b2a99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/9ffaaba53c61ba75a3c7a3a779051d1e9ec4fd2d", - "reference": "9ffaaba53c61ba75a3c7a3a779051d1e9ec4fd2d", + "url": "https://api.github.com/repos/symfony/string/zipball/985e6a9703ef5ce32ba617c9c7d97873bb7b2a99", + "reference": "985e6a9703ef5ce32ba617c9c7d97873bb7b2a99", "shasum": "" }, "require": { @@ -4282,12 +4439,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "Symfony\\Component\\String\\": "" - }, "files": [ "Resources/functions.php" ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, "exclude-from-classmap": [ "/Tests/" ] @@ -4317,7 +4474,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.0" + "source": "https://github.com/symfony/string/tree/v5.4.9" }, "funding": [ { @@ -4333,7 +4490,7 @@ "type": "tidelift" } ], - "time": "2021-11-24T10:02:00+00:00" + "time": "2022-04-19T10:40:37+00:00" }, { "name": "theseer/tokenizer", @@ -4387,16 +4544,16 @@ }, { "name": "vimeo/psalm", - "version": "4.13.1", + "version": "4.23.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "5cf660f63b548ccd4a56f62d916ee4d6028e01a3" + "reference": "f1fe6ff483bf325c803df9f510d09a03fd796f88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/5cf660f63b548ccd4a56f62d916ee4d6028e01a3", - "reference": "5cf660f63b548ccd4a56f62d916ee4d6028e01a3", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/f1fe6ff483bf325c803df9f510d09a03fd796f88", + "reference": "f1fe6ff483bf325c803df9f510d09a03fd796f88", "shasum": "" }, "require": { @@ -4404,7 +4561,7 @@ "amphp/byte-stream": "^1.5", "composer/package-versions-deprecated": "^1.8.0", "composer/semver": "^1.4 || ^2.0 || ^3.0", - "composer/xdebug-handler": "^1.1 || ^2.0", + "composer/xdebug-handler": "^1.1 || ^2.0 || ^3.0", "dnoegel/php-xdg-base-dir": "^0.1.1", "ext-ctype": "*", "ext-dom": "*", @@ -4421,6 +4578,7 @@ "php": "^7.1|^8", "sebastian/diff": "^3.0 || ^4.0", "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0 || ^6.0", + "symfony/polyfill-php80": "^1.25", "webmozart/path-util": "^2.3" }, "provide": { @@ -4487,9 +4645,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/4.13.1" + "source": "https://github.com/vimeo/psalm/tree/4.23.0" }, - "time": "2021-11-23T23:52:49+00:00" + "time": "2022-04-28T17:35:49+00:00" }, { "name": "webimpress/coding-standard", @@ -4548,21 +4706,21 @@ }, { "name": "webmozart/assert", - "version": "1.10.0", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/webmozarts/assert.git", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "symfony/polyfill-ctype": "^1.8" + "ext-ctype": "*", + "php": "^7.2 || ^8.0" }, "conflict": { "phpstan/phpstan": "<0.12.20", @@ -4600,9 +4758,9 @@ ], "support": { "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.10.0" + "source": "https://github.com/webmozarts/assert/tree/1.11.0" }, - "time": "2021-03-09T10:59:23+00:00" + "time": "2022-06-03T18:03:27+00:00" }, { "name": "webmozart/path-util", @@ -4668,5 +4826,5 @@ "platform-overrides": { "php": "7.4.99" }, - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/docs/book/specs.md b/docs/book/specs.md index 08635389..9c6a6642 100644 --- a/docs/book/specs.md +++ b/docs/book/specs.md @@ -59,10 +59,11 @@ return [ ]; ``` -When creating a controller, we might then pull the `InputFilterManager`, and +When creating a controller, we might then pull the `InputFilterPluginManager`, and retrieve the `foobar` input filter we've defined in order to inject it: ```php +use Laminas\InputFilter\InputFilterPluginManager; use Laminas\ServiceManager\FactoryInterface; use Laminas\ServiceManager\ServiceLocatorInterface; @@ -74,7 +75,7 @@ class MyValidatingControllerFactory implements FactoryInterface $services = $controllers->getServiceLocator(); // Retrieve the InputFilterManager - $filters = $services->get('InputFilterManager'); + $filters = $services->get(InputFilterPluginManager::class); // Instantiate the controller and pass it the foobar input filter return new MyValidatingController($filters->get('foobar')); diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 646a80f2..a476fe57 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + ArrayInput @@ -141,11 +141,10 @@ setAllowEmpty setContinueIfEmpty - + ! is_array($inputFilterSpecification) && ! $inputFilterSpecification instanceof Traversable ! is_array($inputSpecification) && ! $inputSpecification instanceof Traversable is_array($validator) - null === $this->inputFilterManager $inputFilter @@ -213,9 +212,6 @@ add add - - $inputFilterManager - $input->getFilterChain() $input->getValidatorChain() @@ -414,16 +410,8 @@ InputFilterAbstractServiceFactory - - getServiceLocator - getServiceLocator - - - $factory - - + $config - $container->get('InputFilterManager') $allConfig['input_filter_specs'] @@ -432,14 +420,6 @@ $allConfig $config - - FilterPluginManager - ValidatorPluginManager - - - $container->get('FilterManager') - $container->get('ValidatorManager') - $cName $container @@ -452,61 +432,19 @@ setPluginManager setPluginManager - - $container->getServiceLocator() - $container->getServiceLocator() - $this->factory instanceof Factory - - - $e->getCode() - - - populateFactory - - - $container->get('FilterManager') - $container->get('ValidatorManager') - - - $v3config - - - $container - - - get - get - has - has - $factories - - setPluginManager - setPluginManager - $this->initializers - - $this->serviceLocator - InputFilterPluginManagerFactory - - $name - $name - $requestedName - - - $config['input_filters'] - $container @@ -886,7 +824,7 @@ 'invalid_value' 'invalid_value' - + testCanCreateInputFilterFromProvider testCanCreateInputFilterWithNullInputs testCanCreateInputFromProvider @@ -938,7 +876,6 @@ testGetInputFilterManagerWhenYouConstructFactoryWithIt testInputFromPluginManagerMayBeFurtherConfiguredWithSpec testSetInputFilterManagerOnConstruct - testSetInputFilterManagerWithServiceManager testSetInputFilterManagerWithoutServiceManager testSetsBreakChainOnFailure testSuggestedTypeMayBePluginNameInInputFilterPluginManager @@ -1130,7 +1067,7 @@ - + function () { function () { @@ -1158,9 +1095,7 @@ $inputFilter $validatorChain - - addAbstractFactory - addAbstractFactory + get get get @@ -1203,13 +1138,12 @@ function () use ($inputFilter) { - + testConfiguresInputFilterServicesWhenFound testDoesNotConfigureInputFilterServicesWhenConfigServiceDoesNotContainInputFiltersConfig testDoesNotConfigureInputFilterServicesWhenConfigServiceNotPresent testDoesNotConfigureInputFilterServicesWhenServiceListenerPresent testFactoryConfiguresPluginManagerUnderContainerInterop - testFactoryConfiguresPluginManagerUnderServiceManagerV2 testFactoryReturnsPluginManager @@ -1355,17 +1289,15 @@ testValidationOperatesOnFilteredValue testValueMayBeInjected - - $messageTemplates[NotEmptyValidator::IS_EMPTY] + $validators[0]['instance'] $validators[1]['instance'] $value['filtered'] $value['raw'] - + $isValidMethod $isValidMethod - $messageTemplates $tmpTemplate[4] $value @@ -1443,9 +1375,6 @@ isArray - - assertIsArray - @@ -1481,11 +1410,6 @@ testValidationFailureWhenInvalidDataSetIsProvided - - - CustomFactory - - CustomInput diff --git a/psalm.xml.dist b/psalm.xml.dist index 54aed230..6e0e2ee6 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -1,7 +1,7 @@ + diff --git a/src/Factory.php b/src/Factory.php index edab9eda..95c3c518 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -27,7 +27,7 @@ class Factory /** @var ValidatorChain */ protected $defaultValidatorChain; - /** @var InputFilterPluginManager */ + /** @var InputFilterPluginManager|null */ protected $inputFilterManager; public function __construct(?InputFilterPluginManager $inputFilterManager = null) @@ -103,6 +103,7 @@ public function clearDefaultValidatorChain() } /** + * @psalm-assert InputFilterPluginManager $this->inputFilterManager * @return self */ public function setInputFilterManager(InputFilterPluginManager $inputFilterManager) diff --git a/src/InputFilterAbstractServiceFactory.php b/src/InputFilterAbstractServiceFactory.php index f0d99b44..d381bb0d 100644 --- a/src/InputFilterAbstractServiceFactory.php +++ b/src/InputFilterAbstractServiceFactory.php @@ -5,7 +5,6 @@ use Interop\Container\ContainerInterface; use Laminas\Filter\FilterPluginManager; use Laminas\ServiceManager\AbstractFactoryInterface; -use Laminas\ServiceManager\AbstractPluginManager; use Laminas\ServiceManager\ServiceLocatorInterface; use Laminas\Validator\ValidatorPluginManager; @@ -13,7 +12,7 @@ class InputFilterAbstractServiceFactory implements AbstractFactoryInterface { - /** @var Factory */ + /** @var Factory|null */ protected $factory; /** @@ -60,11 +59,6 @@ public function canCreate(ContainerInterface $services, $rName) */ public function canCreateServiceWithName(ServiceLocatorInterface $container, $name, $requestedName) { - // v2 => may need to get parent service locator - if ($container instanceof AbstractPluginManager) { - $container = $container->getServiceLocator() ?: $container; - } - return $this->canCreate($container, $requestedName); } @@ -77,11 +71,6 @@ public function canCreateServiceWithName(ServiceLocatorInterface $container, $na */ public function createServiceWithName(ServiceLocatorInterface $container, $cName, $rName) { - // v2 => may need to get parent service locator - if ($container instanceof AbstractPluginManager) { - $container = $container->getServiceLocator() ?: $container; - } - return $this($container, $rName); } @@ -102,7 +91,7 @@ protected function getInputFilterFactory(ContainerInterface $container) ->getDefaultValidatorChain() ->setPluginManager($this->getValidatorPluginManager($container)); - $this->factory->setInputFilterManager($container->get('InputFilterManager')); + $this->factory->setInputFilterManager($container->get(InputFilterPluginManager::class)); return $this->factory; } @@ -112,8 +101,8 @@ protected function getInputFilterFactory(ContainerInterface $container) */ protected function getFilterPluginManager(ContainerInterface $container) { - if ($container->has('FilterManager')) { - return $container->get('FilterManager'); + if ($container->has(FilterPluginManager::class)) { + return $container->get(FilterPluginManager::class); } return new FilterPluginManager($container); @@ -124,8 +113,8 @@ protected function getFilterPluginManager(ContainerInterface $container) */ protected function getValidatorPluginManager(ContainerInterface $container) { - if ($container->has('ValidatorManager')) { - return $container->get('ValidatorManager'); + if ($container->has(ValidatorPluginManager::class)) { + return $container->get(ValidatorPluginManager::class); } return new ValidatorPluginManager($container); diff --git a/src/InputFilterPluginManager.php b/src/InputFilterPluginManager.php index 87a68c2f..5e143eb9 100644 --- a/src/InputFilterPluginManager.php +++ b/src/InputFilterPluginManager.php @@ -3,22 +3,28 @@ namespace Laminas\InputFilter; use Interop\Container\ContainerInterface; +use Laminas\Filter\FilterPluginManager; use Laminas\ServiceManager\AbstractPluginManager; use Laminas\ServiceManager\ConfigInterface; use Laminas\ServiceManager\Exception\InvalidServiceException; use Laminas\ServiceManager\Factory\InvokableFactory; +use Laminas\ServiceManager\ServiceManager; use Laminas\Stdlib\InitializableInterface; +use Laminas\Validator\ValidatorPluginManager; +use Psr\Container\ContainerInterface as PsrContainerInterface; use function get_class; use function gettype; use function is_object; -use function property_exists; use function sprintf; /** * Plugin manager implementation for input filters. * + * @link ServiceManager + * * @method InputFilterInterface|InputInterface get($name, ?array $options = null) + * @psalm-import-type ServiceManagerConfiguration from ServiceManager */ class InputFilterPluginManager extends AbstractPluginManager { @@ -71,17 +77,9 @@ class InputFilterPluginManager extends AbstractPluginManager protected $sharedByDefault = false; /** - * Whether or not to share by default (v2) - * - * @var bool - */ - protected $shareByDefault = false; - - /** - * @param null|ConfigInterface|ContainerInterface $configOrContainer For laminas-servicemanager v2, - * null or a ConfigInterface instance are allowed; for v3, a - * ContainerInterface is expected. - * @param array $v3config Optional configuration array (laminas-servicemanager v3 only) + * @param null|ConfigInterface|ContainerInterface|PsrContainerInterface $configOrContainer + * @param array $v3config + * @psalm-param ServiceManagerConfiguration $v3config */ public function __construct($configOrContainer = null, array $v3config = []) { @@ -92,13 +90,13 @@ public function __construct($configOrContainer = null, array $v3config = []) /** * Inject this and populate the factory with filter chain and validator chain * - * @param ContainerInterface|InputFilter $containerOrInputFilter When using ServiceManager v3 - * this will be the plugin manager instance - * @param InputFilter $inputFilter This is only used with ServiceManager v3 + * @param self|InputFilter $containerOrInputFilter + * @param InputFilter|null $inputFilter + * @return void */ public function populateFactory($containerOrInputFilter, $inputFilter = null) { - $inputFilter = $containerOrInputFilter instanceof ContainerInterface ? $inputFilter : $containerOrInputFilter; + $inputFilter = $inputFilter ?: $containerOrInputFilter; if (! $inputFilter instanceof InputFilter) { return; @@ -115,21 +113,26 @@ public function populateFactory($containerOrInputFilter, $inputFilter = null) */ public function populateFactoryPluginManagers(Factory $factory) { - $container = property_exists($this, 'creationContext') - ? $this->creationContext // v3 - : $this->serviceLocator; // v2 + /** @psalm-suppress DocblockTypeContradiction */ + if (! $this->creationContext) { + return; + } - if ($container && $container->has('FilterManager')) { - $factory->getDefaultFilterChain()->setPluginManager($container->get('FilterManager')); + $filterChain = $factory->getDefaultFilterChain(); + if ($filterChain !== null && $this->creationContext->has(FilterPluginManager::class)) { + $filterChain->setPluginManager($this->creationContext->get(FilterPluginManager::class)); } - if ($container && $container->has('ValidatorManager')) { - $factory->getDefaultValidatorChain()->setPluginManager($container->get('ValidatorManager')); + $validatorChain = $factory->getDefaultValidatorChain(); + if ($validatorChain !== null && $this->creationContext->has(ValidatorPluginManager::class)) { + $validatorChain->setPluginManager($this->creationContext->get(ValidatorPluginManager::class)); } } /** * {@inheritDoc} (v3) + * + * @psalm-assert InputFilterInterface|InputInterface $instance */ public function validate($instance) { @@ -157,6 +160,11 @@ public function validate($instance) * Checks that the filter loaded is either a valid callback or an instance * of FilterInterface. * + * @deprecated Since 2.14.0. This method is only relevant to version 2 of laminas-servicemanager which is no + * longer installable in this library. + * + * @see validate() + * * @param mixed $plugin * @return void * @throws Exception\RuntimeException If invalid. diff --git a/src/InputFilterPluginManagerFactory.php b/src/InputFilterPluginManagerFactory.php index de42b7aa..693ea4bd 100644 --- a/src/InputFilterPluginManagerFactory.php +++ b/src/InputFilterPluginManagerFactory.php @@ -2,28 +2,39 @@ namespace Laminas\InputFilter; +use ArrayAccess; use Interop\Container\ContainerInterface; use Laminas\ServiceManager\Config; use Laminas\ServiceManager\FactoryInterface; use Laminas\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\ServiceManager; +use Psr\Container\ContainerInterface as PsrContainer; +use function assert; use function is_array; +/** + * @link ServiceManager + * + * @psalm-import-type ServiceManagerConfiguration from ServiceManager + */ class InputFilterPluginManagerFactory implements FactoryInterface { /** * laminas-servicemanager v2 support for invocation options. * - * @var null|array + * @var null|ServiceManagerConfiguration */ protected $creationOptions; /** - * {@inheritDoc} - * + * @param ContainerInterface|PsrContainer $container + * @param string|null $name + * @param ServiceManagerConfiguration|null $options * @return InputFilterPluginManager + * @psalm-suppress MoreSpecificImplementedParamType,MismatchingDocblockParamType */ - public function __invoke(ContainerInterface $container, $name, ?array $options = null) + public function __invoke(ContainerInterface $container, $name = null, ?array $options = null) { $pluginManager = new InputFilterPluginManager($container, $options ?: []); @@ -39,12 +50,15 @@ public function __invoke(ContainerInterface $container, $name, ?array $options = } $config = $container->get('config'); + assert(is_array($config) || $config instanceof ArrayAccess); // If we do not have input_filters configuration, nothing more to do if (! isset($config['input_filters']) || ! is_array($config['input_filters'])) { return $pluginManager; } + /** @psalm-var ServiceManagerConfiguration $config['input_filters'] */ + // Wire service configuration for input_filters (new Config($config['input_filters']))->configureServiceManager($pluginManager); @@ -52,9 +66,10 @@ public function __invoke(ContainerInterface $container, $name, ?array $options = } /** - * {@inheritDoc} - * + * @param string|null $name + * @param string|null $requestedName * @return InputFilterPluginManager + * @psalm-suppress MoreSpecificImplementedParamType,MismatchingDocblockParamType */ public function createService(ServiceLocatorInterface $container, $name = null, $requestedName = null) { @@ -64,7 +79,7 @@ public function createService(ServiceLocatorInterface $container, $name = null, /** * laminas-servicemanager v2 support for invocation options. * - * @param array $options + * @param ServiceManagerConfiguration $options * @return void */ public function setCreationOptions(array $options) diff --git a/test/FactoryTest.php b/test/FactoryTest.php index 88d7506d..f588b65a 100644 --- a/test/FactoryTest.php +++ b/test/FactoryTest.php @@ -826,21 +826,18 @@ public function testCanSetInputErrorMessage() $this->assertEquals('Custom error message', $input->getErrorMessage()); } - public function testSetInputFilterManagerWithServiceManager() + public function testSetInputFilterManagerWithServiceManager(): void { - $serviceManager = new ServiceManager\ServiceManager(); - $inputFilterManager = new InputFilterPluginManager($serviceManager); - $serviceManager->setService('ValidatorManager', new Validator\ValidatorPluginManager($serviceManager)); - $serviceManager->setService('FilterManager', new Filter\FilterPluginManager($serviceManager)); + $serviceManager = new ServiceManager\ServiceManager(); + $inputFilterManager = new InputFilterPluginManager($serviceManager); + $validatorPluginManager = new Validator\ValidatorPluginManager($serviceManager); + $filterPluginManager = new Filter\FilterPluginManager($serviceManager); + $serviceManager->setService(Validator\ValidatorPluginManager::class, $validatorPluginManager); + $serviceManager->setService(Filter\FilterPluginManager::class, $filterPluginManager); $factory = new Factory($inputFilterManager); - $this->assertInstanceOf( - Validator\ValidatorPluginManager::class, - $factory->getDefaultValidatorChain()->getPluginManager() - ); - $this->assertInstanceOf( - Filter\FilterPluginManager::class, - $factory->getDefaultFilterChain()->getPluginManager() - ); + + self::assertSame($validatorPluginManager, $factory->getDefaultValidatorChain()->getPluginManager()); + self::assertSame($filterPluginManager, $factory->getDefaultFilterChain()->getPluginManager()); } public function testSetInputFilterManagerWithoutServiceManager() diff --git a/test/InputFilterAbstractServiceFactoryTest.php b/test/InputFilterAbstractServiceFactoryTest.php index 9fc738ad..11eaf545 100644 --- a/test/InputFilterAbstractServiceFactoryTest.php +++ b/test/InputFilterAbstractServiceFactoryTest.php @@ -40,7 +40,7 @@ protected function setUp(): void { $this->services = new ServiceManager(); $this->filters = new InputFilterPluginManager($this->services); - $this->services->setService('InputFilterManager', $this->filters); + $this->services->setService(InputFilterPluginManager::class, $this->filters); $this->factory = new InputFilterAbstractServiceFactory(); } @@ -48,7 +48,7 @@ protected function setUp(): void public function testCannotCreateServiceIfNoConfigServicePresent() { $method = 'canCreate'; - $args = [$this->getCompatContainer(), 'filter']; + $args = [$this->services, 'filter']; $this->assertFalse(call_user_func_array([$this->factory, $method], $args)); } @@ -56,7 +56,7 @@ public function testCannotCreateServiceIfConfigServiceDoesNotHaveInputFiltersCon { $this->services->setService('config', []); $method = 'canCreate'; - $args = [$this->getCompatContainer(), 'filter']; + $args = [$this->services, 'filter']; $this->assertFalse(call_user_func_array([$this->factory, $method], $args)); } @@ -67,7 +67,7 @@ public function testCannotCreateServiceIfConfigInputFiltersDoesNotContainMatchin 'input_filter_specs' => [], ]); $method = 'canCreate'; - $args = [$this->getCompatContainer(), 'filter']; + $args = [$this->services, 'filter']; $this->assertFalse(call_user_func_array([$this->factory, $method], $args)); } @@ -79,7 +79,7 @@ public function testCanCreateServiceIfConfigInputFiltersContainsMatchingServiceN ], ]); $method = 'canCreate'; - $args = [$this->getCompatContainer(), 'filter']; + $args = [$this->services, 'filter']; $this->assertTrue(call_user_func_array([$this->factory, $method], $args)); } @@ -91,7 +91,7 @@ public function testCreatesInputFilterInstance() ], ]); $method = '__invoke'; - $args = [$this->getCompatContainer(), 'filter']; + $args = [$this->services, 'filter']; $filter = call_user_func_array([$this->factory, $method], $args); $this->assertInstanceOf(InputFilterInterface::class, $filter); } @@ -111,8 +111,8 @@ public function testUsesConfiguredValidationAndFilterManagerServicesWhenCreating $validator = $this->createMock(ValidatorInterface::class); $validators->setService('foo', $validator); - $this->services->setService('FilterManager', $filters); - $this->services->setService('ValidatorManager', $validators); + $this->services->setService(FilterPluginManager::class, $filters); + $this->services->setService(ValidatorPluginManager::class, $validators); $this->services->setService('config', [ 'input_filter_specs' => [ 'filter' => [ @@ -131,7 +131,7 @@ public function testUsesConfiguredValidationAndFilterManagerServicesWhenCreating ]); $method = '__invoke'; - $args = [$this->getCompatContainer(), 'filter']; + $args = [$this->services, 'filter']; $inputFilter = call_user_func_array([$this->factory, $method], $args); $this->assertTrue($inputFilter->has('input')); @@ -171,31 +171,22 @@ public function testRetrieveInputFilterFromInputFilterPluginManager() $validators = new ValidatorPluginManager($this->services); /** @var ValidatorInterface|MockObject $validator */ $validator = $this->createMock(ValidatorInterface::class); - $this->services->setService('ValidatorManager', $validators); + $this->services->setService(ValidatorPluginManager::class, $validators); $validators->setService('foo', $validator); $filters = new FilterPluginManager($this->services); - $filter = function () { + $filter = static function (): void { }; $filters->setService('foo', $filter); - $this->services->setService('FilterManager', $filters); - $this->services->get('InputFilterManager')->addAbstractFactory(InputFilterAbstractServiceFactory::class); + $this->services->setService(FilterPluginManager::class, $filters); + $this->services->get(InputFilterPluginManager::class) + ->addAbstractFactory(InputFilterAbstractServiceFactory::class); - $inputFilter = $this->services->get('InputFilterManager')->get('foobar'); + $inputFilter = $this->services->get(InputFilterPluginManager::class)->get('foobar'); $this->assertInstanceOf(InputFilterInterface::class, $inputFilter); } - /** - * Returns appropriate instance to pass to `canCreate()` et al depending on SM version - * - * v3 passes the 'creationContext' (ie the root SM) to the AbstractFactory - */ - protected function getCompatContainer(): ServiceManager - { - return $this->services; - } - /** * @depends testCreatesInputFilterInstance */ @@ -244,8 +235,8 @@ public function testWillUseCustomFiltersWhenProvided() $validators = new ValidatorPluginManager($this->services); - $this->services->setService('FilterManager', $filters); - $this->services->setService('ValidatorManager', $validators); + $this->services->setService(FilterPluginManager::class, $filters); + $this->services->setService(ValidatorPluginManager::class, $validators); $this->services->setService('config', [ 'input_filter_specs' => [ @@ -284,10 +275,10 @@ public function testWillUseCustomFiltersWhenProvided() ], ]); - $this->services->get('InputFilterManager') + $this->services->get(InputFilterPluginManager::class) ->addAbstractFactory(InputFilterAbstractServiceFactory::class); - $inputFilter = $this->services->get('InputFilterManager')->get('test'); + $inputFilter = $this->services->get(InputFilterPluginManager::class)->get('test'); $this->assertInstanceOf(InputFilterInterface::class, $inputFilter); $input = $inputFilter->get('a-file-element'); diff --git a/test/InputFilterPluginManagerCompatibilityTest.php b/test/InputFilterPluginManagerCompatibilityTest.php index af67a254..72423b5d 100644 --- a/test/InputFilterPluginManagerCompatibilityTest.php +++ b/test/InputFilterPluginManagerCompatibilityTest.php @@ -31,4 +31,10 @@ protected function getInstanceOf() { // InputFilterManager accepts multiple instance types } + + public function testShareByDefaultAndSharedByDefault(): void + { + // The plugin manager no longer supports V2 so this inherited test is forced to pass + self::assertTrue(true); + } } diff --git a/test/InputFilterPluginManagerFactoryTest.php b/test/InputFilterPluginManagerFactoryTest.php index 0ea7baac..0215ee01 100644 --- a/test/InputFilterPluginManagerFactoryTest.php +++ b/test/InputFilterPluginManagerFactoryTest.php @@ -58,29 +58,6 @@ public function testFactoryConfiguresPluginManagerUnderContainerInterop(string $ $this->assertSame($plugin, $filters->get('test')); } - /** - * @depends testFactoryReturnsPluginManager - * @dataProvider pluginProvider - * @psalm-param class-string $pluginType - */ - public function testFactoryConfiguresPluginManagerUnderServiceManagerV2(string $pluginType) - { - $container = $this->prophesize(ServiceLocatorInterface::class); - $container->willImplement(ContainerInterface::class); - - $plugin = $this->prophesize($pluginType)->reveal(); - - $factory = new InputFilterPluginManagerFactory(); - $factory->setCreationOptions([ - 'services' => [ - 'test' => $plugin, - ], - ]); - - $filters = $factory->createService($container->reveal()); - $this->assertSame($plugin, $filters->get('test')); - } - public function testConfiguresInputFilterServicesWhenFound() { $inputFilter = $this->prophesize(InputFilterInterface::class)->reveal(); @@ -105,7 +82,7 @@ public function testConfiguresInputFilterServicesWhenFound() $container->get('config')->willReturn($config); $factory = new InputFilterPluginManagerFactory(); - $inputFilters = $factory($container->reveal(), 'InputFilterManager'); + $inputFilters = $factory($container->reveal()); $this->assertInstanceOf(InputFilterPluginManager::class, $inputFilters); $this->assertTrue($inputFilters->has('test')); @@ -124,7 +101,7 @@ public function testDoesNotConfigureInputFilterServicesWhenServiceListenerPresen $container->get('config')->shouldNotBeCalled(); $factory = new InputFilterPluginManagerFactory(); - $inputFilters = $factory($container->reveal(), 'InputFilterManager'); + $inputFilters = $factory($container->reveal()); $this->assertInstanceOf(InputFilterPluginManager::class, $inputFilters); $this->assertFalse($inputFilters->has('test')); @@ -141,7 +118,7 @@ public function testDoesNotConfigureInputFilterServicesWhenConfigServiceNotPrese $container->get('config')->shouldNotBeCalled(); $factory = new InputFilterPluginManagerFactory(); - $inputFilters = $factory($container->reveal(), 'InputFilterManager'); + $inputFilters = $factory($container->reveal()); $this->assertInstanceOf(InputFilterPluginManager::class, $inputFilters); } @@ -156,7 +133,7 @@ public function testDoesNotConfigureInputFilterServicesWhenConfigServiceDoesNotC $container->get('config')->willReturn(['foo' => 'bar']); $factory = new InputFilterPluginManagerFactory(); - $inputFilters = $factory($container->reveal(), 'InputFilterManager'); + $inputFilters = $factory($container->reveal()); $this->assertInstanceOf(InputFilterPluginManager::class, $inputFilters); $this->assertFalse($inputFilters->has('foo')); diff --git a/test/InputFilterPluginManagerTest.php b/test/InputFilterPluginManagerTest.php index 681f2780..4d9d5231 100644 --- a/test/InputFilterPluginManagerTest.php +++ b/test/InputFilterPluginManagerTest.php @@ -114,8 +114,8 @@ public function testInputFilterInvokableClassSMDependenciesArePopulatedWithServi ->disableOriginalConstructor() ->getMock(); - $this->services->setService('FilterManager', $filterManager); - $this->services->setService('ValidatorManager', $validatorManager); + $this->services->setService(FilterPluginManager::class, $filterManager); + $this->services->setService(ValidatorPluginManager::class, $validatorManager); /** @var InputFilter $service */ $service = $this->manager->get('inputfilter'); diff --git a/test/InputTest.php b/test/InputTest.php index 18a59d57..9c25d604 100644 --- a/test/InputTest.php +++ b/test/InputTest.php @@ -48,14 +48,26 @@ public function assertRequiredValidationErrorMessage(Input $input, string $messa $message = $message ?: 'Expected failure message for required input'; $message .= ';'; - $messages = $input->getMessages(); - $this->assertIsArray($messages, $message . ' non-array messages array'); + $expectedKey = NotEmptyValidator::IS_EMPTY; + $messages = $input->getMessages(); + /** @psalm-suppress RedundantConditionGivenDocblockType */ + self::assertIsArray($messages, $message . ' non-array messages array'); + self::assertArrayHasKey($expectedKey, $messages); $notEmpty = new NotEmptyValidator(); $messageTemplates = $notEmpty->getOption('messageTemplates'); - $this->assertSame([ - NotEmptyValidator::IS_EMPTY => $messageTemplates[NotEmptyValidator::IS_EMPTY], - ], $messages, $message . ' missing NotEmpty::IS_EMPTY key and/or contains additional messages'); + self::assertIsArray($messageTemplates); + self::assertArrayHasKey($expectedKey, $messageTemplates); + self::assertEquals( + $messageTemplates[$expectedKey], + $messages[$expectedKey], + $message . ' missing NotEmpty::IS_EMPTY key and/or contains additional messages' + ); + self::assertCount( + 1, + $messages, + $message . ' missing NotEmpty::IS_EMPTY key and/or contains additional messages' + ); } public function testConstructorRequiresAName() From ad417f2dc022bb44a9e8265c8ea2a88e2654e715 Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 7 Jun 2022 14:48:01 +0100 Subject: [PATCH 2/8] Replace psalm psr-container plugin with a local stub Signed-off-by: George Steel --- .stub.php | 19 ++++++++ composer.json | 1 - composer.lock | 80 +------------------------------- psalm.xml.dist | 5 +- src/InputFilterPluginManager.php | 2 +- 5 files changed, 25 insertions(+), 82 deletions(-) create mode 100644 .stub.php diff --git a/.stub.php b/.stub.php new file mode 100644 index 00000000..be1e3f09 --- /dev/null +++ b/.stub.php @@ -0,0 +1,19 @@ + $name + * @psalm-return ($name is class-string ? T : mixed) + */ + public function get(string $name): object; + } +} diff --git a/composer.json b/composer.json index cbc15053..6d8ae2cb 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,6 @@ "require-dev": { "laminas/laminas-coding-standard": "~2.2.1", "laminas/laminas-db": "^2.13.4", - "lctrs/psalm-psr-container-plugin": "^1.6", "phpspec/prophecy": "^1.14", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.5.5", diff --git a/composer.lock b/composer.lock index f2b35946..767fe062 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": "1e6e782cccb2eaf302c4c3e3297ba80b", + "content-hash": "53f38233dacf2b64b07daad58d574517", "packages": [ { "name": "container-interop/container-interop", @@ -1264,84 +1264,6 @@ ], "time": "2021-09-21T18:59:44+00:00" }, - { - "name": "lctrs/psalm-psr-container-plugin", - "version": "1.6.0", - "source": { - "type": "git", - "url": "https://github.com/Lctrs/psalm-psr-container-plugin.git", - "reference": "799bd0af3ccf0f524e43527780e1b15ec9a60990" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Lctrs/psalm-psr-container-plugin/zipball/799bd0af3ccf0f524e43527780e1b15ec9a60990", - "reference": "799bd0af3ccf0f524e43527780e1b15ec9a60990", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "nikic/php-parser": "^4.13.2", - "php": "^7.3.0 || >=8.0.0 <8.2.0", - "psr/container": "^1.1.1", - "vimeo/psalm": "^4.16.1" - }, - "require-dev": { - "codeception/codeception": "^4.1.27", - "codeception/module-asserts": "^1.3.1", - "codeception/module-cli": "^1.1.1", - "codeception/module-filesystem": "^1.0.3", - "doctrine/coding-standard": "^9.0.0", - "ergebnis/composer-normalize": "^2.20.0", - "ergebnis/license": "^1.1.0", - "phpstan/extension-installer": "^1.1.0", - "phpstan/phpstan": "^1.3.0", - "phpstan/phpstan-deprecation-rules": "^1.0.0", - "phpstan/phpstan-phpunit": "^1.0.0", - "phpstan/phpstan-strict-rules": "^1.1.0", - "phpunit/phpunit": "^9.5.11", - "psalm/plugin-phpunit": "^0.16.1", - "symfony/yaml": "^5.4.0", - "weirdan/codeception-psalm-module": "^0.13.1" - }, - "type": "psalm-plugin", - "extra": { - "psalm": { - "pluginClass": "Lctrs\\PsalmPsrContainerPlugin\\Plugin" - } - }, - "autoload": { - "psr-4": { - "Lctrs\\PsalmPsrContainerPlugin\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jérôme Parmentier", - "email": "jerome@prmntr.me" - } - ], - "description": "Let Psalm understand better psr11 containers", - "homepage": "https://github.com/Lctrs/psalm-psr-container-plugin", - "keywords": [ - "code", - "container", - "inspection", - "php", - "psalm", - "psalm-plugin", - "psr", - "psr11" - ], - "support": { - "issues": "https://github.com/Lctrs/psalm-psr-container-plugin/issues", - "source": "https://github.com/Lctrs/psalm-psr-container-plugin" - }, - "time": "2021-12-29T20:10:48+00:00" - }, { "name": "myclabs/deep-copy", "version": "1.10.2", diff --git a/psalm.xml.dist b/psalm.xml.dist index 6e0e2ee6..853b2d3d 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -41,6 +41,9 @@ - + + + + diff --git a/src/InputFilterPluginManager.php b/src/InputFilterPluginManager.php index 5e143eb9..f4e98f4c 100644 --- a/src/InputFilterPluginManager.php +++ b/src/InputFilterPluginManager.php @@ -23,7 +23,7 @@ * * @link ServiceManager * - * @method InputFilterInterface|InputInterface get($name, ?array $options = null) + * @method InputFilterInterface|InputInterface get(string $name, ?array $options = null) * @psalm-import-type ServiceManagerConfiguration from ServiceManager */ class InputFilterPluginManager extends AbstractPluginManager From 11080cf5a67fd2368d31b50e28403fb21cbf2f14 Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 7 Jun 2022 14:50:50 +0100 Subject: [PATCH 3/8] Baseline method signature mismatch caused by `ServiceManager::has()` Psalm error reads: Method Laminas\ServiceManager\ServiceManager::has with return type '' is different to return type 'bool' of inherited method Psr\Container\ContainerInterface::has - This is possibly due to @\inheritDoc Signed-off-by: George Steel --- psalm-baseline.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index a476fe57..a84f51f2 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -434,6 +434,9 @@ + + InputFilterPluginManager + $factories @@ -1069,7 +1072,6 @@ function () { - function () { testAllowsPassingNonPluginManagerContainerToFactoryWithServiceManagerV2 @@ -1096,8 +1098,6 @@ $validatorChain - get - get get getFilterChain getInputFilterManager From 844cd44020972c996c66bda2e4b2589a73d89d0e Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 7 Jun 2022 14:56:44 +0100 Subject: [PATCH 4/8] Revert removal of legacy property `$shareByDefault` and mark deprecated Signed-off-by: George Steel --- src/InputFilterPluginManager.php | 10 ++++++++++ test/InputFilterPluginManagerCompatibilityTest.php | 6 ------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/InputFilterPluginManager.php b/src/InputFilterPluginManager.php index f4e98f4c..cfff55dd 100644 --- a/src/InputFilterPluginManager.php +++ b/src/InputFilterPluginManager.php @@ -76,6 +76,16 @@ class InputFilterPluginManager extends AbstractPluginManager */ protected $sharedByDefault = false; + /** + * Whether or not to share by default (v2) + * + * @deprecated Since 2.15.0 This property will be removed in version 3.0 because + * it is only relevant to ServiceManager version 2.x + * + * @var bool + */ + protected $shareByDefault = false; + /** * @param null|ConfigInterface|ContainerInterface|PsrContainerInterface $configOrContainer * @param array $v3config diff --git a/test/InputFilterPluginManagerCompatibilityTest.php b/test/InputFilterPluginManagerCompatibilityTest.php index 72423b5d..af67a254 100644 --- a/test/InputFilterPluginManagerCompatibilityTest.php +++ b/test/InputFilterPluginManagerCompatibilityTest.php @@ -31,10 +31,4 @@ protected function getInstanceOf() { // InputFilterManager accepts multiple instance types } - - public function testShareByDefaultAndSharedByDefault(): void - { - // The plugin manager no longer supports V2 so this inherited test is forced to pass - self::assertTrue(true); - } } From 4a4bf617dd7f524776cdde5961d72fcccad457c6 Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 7 Jun 2022 15:04:04 +0100 Subject: [PATCH 5/8] Remove duplicate parameter doc Signed-off-by: George Steel --- src/InputFilterPluginManager.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/InputFilterPluginManager.php b/src/InputFilterPluginManager.php index cfff55dd..b7000356 100644 --- a/src/InputFilterPluginManager.php +++ b/src/InputFilterPluginManager.php @@ -88,8 +88,7 @@ class InputFilterPluginManager extends AbstractPluginManager /** * @param null|ConfigInterface|ContainerInterface|PsrContainerInterface $configOrContainer - * @param array $v3config - * @psalm-param ServiceManagerConfiguration $v3config + * @param ServiceManagerConfiguration $v3config */ public function __construct($configOrContainer = null, array $v3config = []) { From 2eeeef17df77292a20f6233cc4a570948a2f544d Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 7 Jun 2022 23:45:49 +0100 Subject: [PATCH 6/8] Document the stub purpose and provide a more descriptive name Signed-off-by: George Steel --- .psr-container-stub.php | 21 +++++++++++++++++++++ .stub.php | 19 ------------------- psalm.xml.dist | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 .psr-container-stub.php delete mode 100644 .stub.php diff --git a/.psr-container-stub.php b/.psr-container-stub.php new file mode 100644 index 00000000..68444cb0 --- /dev/null +++ b/.psr-container-stub.php @@ -0,0 +1,21 @@ + $id + * @psalm-return ($id is class-string ? T : mixed) + */ + public function get(string $id): object; + } +} diff --git a/.stub.php b/.stub.php deleted file mode 100644 index be1e3f09..00000000 --- a/.stub.php +++ /dev/null @@ -1,19 +0,0 @@ - $name - * @psalm-return ($name is class-string ? T : mixed) - */ - public function get(string $name): object; - } -} diff --git a/psalm.xml.dist b/psalm.xml.dist index 853b2d3d..f09ee546 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -44,6 +44,6 @@ - + From df257ac4aee7263c8f1ed546e5a72136259646f3 Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 7 Jun 2022 23:50:55 +0100 Subject: [PATCH 7/8] Deprecate v2 compatibility methods Signed-off-by: George Steel --- src/InputFilterAbstractServiceFactory.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/InputFilterAbstractServiceFactory.php b/src/InputFilterAbstractServiceFactory.php index d381bb0d..ef1a0f1f 100644 --- a/src/InputFilterAbstractServiceFactory.php +++ b/src/InputFilterAbstractServiceFactory.php @@ -53,6 +53,9 @@ public function canCreate(ContainerInterface $services, $rName) /** * Determine if we can create a service with name (v2) * + * @deprecated This library is no longer compatible with Service manager V2 and this method will be dropped in the + * next major release. + * * @param string $name * @param string $requestedName * @return bool @@ -65,6 +68,9 @@ public function canCreateServiceWithName(ServiceLocatorInterface $container, $na /** * Create the requested service (v2) * + * @deprecated This library is no longer compatible with Service manager V2 and this method will be dropped in the + * next major release. + * * @param string $cName * @param string $rName * @return InputFilterInterface From 884e7bac70eb5c9f140c6706d8d4e1523ca266b0 Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 7 Jun 2022 23:53:23 +0100 Subject: [PATCH 8/8] Drop unnecessary assertion Signed-off-by: George Steel --- test/InputTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/InputTest.php b/test/InputTest.php index 9c25d604..7fad50de 100644 --- a/test/InputTest.php +++ b/test/InputTest.php @@ -50,8 +50,6 @@ public function assertRequiredValidationErrorMessage(Input $input, string $messa $expectedKey = NotEmptyValidator::IS_EMPTY; $messages = $input->getMessages(); - /** @psalm-suppress RedundantConditionGivenDocblockType */ - self::assertIsArray($messages, $message . ' non-array messages array'); self::assertArrayHasKey($expectedKey, $messages); $notEmpty = new NotEmptyValidator();