diff --git a/.laminas-ci.json b/.laminas-ci.json index bce3fa21..7dad22d9 100644 --- a/.laminas-ci.json +++ b/.laminas-ci.json @@ -1,5 +1,6 @@ { "ignore_php_platform_requirements": { - "8.1": true + "8.1": false, + "8.2": true } } diff --git a/composer.json b/composer.json index 3207f5a3..c56454f0 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "homepage": "https://laminas.dev", "license": "BSD-3-Clause", "require": { - "php": "~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "ext-iconv": "*", "laminas/laminas-loader": "^2.8.0", "laminas/laminas-mime": "^2.10.0", @@ -22,11 +22,11 @@ "laminas/laminas-coding-standard": "~2.4.0", "laminas/laminas-crypt": "^3.8.0", "laminas/laminas-db": "^2.15.0", - "laminas/laminas-servicemanager": "^3.16.0", - "phpunit/phpunit": "^9.5.21", + "laminas/laminas-servicemanager": "^3.19", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", "symfony/process": "^6.0.11", - "vimeo/psalm": "^4.26.0" + "vimeo/psalm": "^4.29" }, "suggest": { "laminas/laminas-crypt": "^3.8 Crammd5 support in SMTP Auth", diff --git a/composer.lock b/composer.lock index 8032a507..513caf1d 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": "ed7025b74317fcb35ea684cb1ecf50a3", + "content-hash": "30b60c003e22654fe4965b3897fd7092", "packages": [ { "name": "laminas/laminas-loader", @@ -125,21 +125,21 @@ }, { "name": "laminas/laminas-servicemanager", - "version": "3.17.0", + "version": "3.19.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-servicemanager.git", - "reference": "360be5f16955dd1edbcce1cfaa98ed82a17f02ec" + "reference": "ed160729bb8721127efdaac799f9a298963345b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/360be5f16955dd1edbcce1cfaa98ed82a17f02ec", - "reference": "360be5f16955dd1edbcce1cfaa98ed82a17f02ec", + "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/ed160729bb8721127efdaac799f9a298963345b1", + "reference": "ed160729bb8721127efdaac799f9a298963345b1", "shasum": "" }, "require": { "laminas/laminas-stdlib": "^3.2.1", - "php": "~7.4.0 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "psr/container": "^1.0" }, "conflict": { @@ -155,17 +155,16 @@ "container-interop/container-interop": "^1.2.0" }, "require-dev": { - "composer/package-versions-deprecated": "^1.0", + "composer/package-versions-deprecated": "^1.11.99.5", "laminas/laminas-coding-standard": "~2.4.0", "laminas/laminas-container-config-test": "^0.7", - "laminas/laminas-dependency-plugin": "^2.1.2", - "mikey179/vfsstream": "^1.6.10@alpha", - "ocramius/proxy-manager": "^2.11", - "phpbench/phpbench": "^1.1", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5.5", + "laminas/laminas-dependency-plugin": "^2.2", + "mikey179/vfsstream": "^1.6.11@alpha", + "ocramius/proxy-manager": "^2.14.1", + "phpbench/phpbench": "^1.2.6", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.8" + "vimeo/psalm": "^4.28" }, "suggest": { "ocramius/proxy-manager": "ProxyManager ^2.1.1 to handle lazy initialization of services" @@ -212,35 +211,34 @@ "type": "community_bridge" } ], - "time": "2022-09-22T11:33:46+00:00" + "time": "2022-10-10T20:59:22+00:00" }, { "name": "laminas/laminas-stdlib", - "version": "3.13.0", + "version": "3.15.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-stdlib.git", - "reference": "66a6d03c381f6c9f1dd988bf8244f9afb9380d76" + "reference": "63b66bd4b696f024f42616b9d95cdb10e5109c27" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/66a6d03c381f6c9f1dd988bf8244f9afb9380d76", - "reference": "66a6d03c381f6c9f1dd988bf8244f9afb9380d76", + "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/63b66bd4b696f024f42616b9d95cdb10e5109c27", + "reference": "63b66bd4b696f024f42616b9d95cdb10e5109c27", "shasum": "" }, "require": { - "php": "^7.4 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "zendframework/zend-stdlib": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~2.3.0", + "laminas/laminas-coding-standard": "^2.4.0", "phpbench/phpbench": "^1.2.6", - "phpstan/phpdoc-parser": "^0.5.4", - "phpunit/phpunit": "^9.5.23", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.26" + "vimeo/psalm": "^4.28" }, "type": "library", "autoload": { @@ -272,26 +270,26 @@ "type": "community_bridge" } ], - "time": "2022-08-24T13:56:50+00:00" + "time": "2022-10-10T19:10:24+00:00" }, { "name": "laminas/laminas-validator", - "version": "2.25.0", + "version": "2.26.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-validator.git", - "reference": "42de39b78e73b321db7d948cf8530a2764f8b9aa" + "reference": "a995b21d18c63cd1f5d123d0d2cd31a1c2d828dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/42de39b78e73b321db7d948cf8530a2764f8b9aa", - "reference": "42de39b78e73b321db7d948cf8530a2764f8b9aa", + "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/a995b21d18c63cd1f5d123d0d2cd31a1c2d828dc", + "reference": "a995b21d18c63cd1f5d123d0d2cd31a1c2d828dc", "shasum": "" }, "require": { "laminas/laminas-servicemanager": "^3.12.0", "laminas/laminas-stdlib": "^3.13", - "php": "^7.4 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "zendframework/zend-validator": "*" @@ -299,18 +297,17 @@ "require-dev": { "laminas/laminas-coding-standard": "^2.4.0", "laminas/laminas-db": "^2.15.0", - "laminas/laminas-filter": "^2.18.0", + "laminas/laminas-filter": "^2.22", "laminas/laminas-http": "^2.16.0", - "laminas/laminas-i18n": "^2.17.0", + "laminas/laminas-i18n": "^2.19", "laminas/laminas-session": "^2.13.0", "laminas/laminas-uri": "^2.9.1", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5.24", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "psr/http-client": "^1.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^1.0", - "vimeo/psalm": "^4.27.0" + "psr/http-client": "^1.0.1", + "psr/http-factory": "^1.0.1", + "psr/http-message": "^1.0.1", + "vimeo/psalm": "^4.28" }, "suggest": { "laminas/laminas-db": "Laminas\\Db component, required by the (No)RecordExists validator", @@ -358,7 +355,7 @@ "type": "community_bridge" } ], - "time": "2022-09-20T11:33:19+00:00" + "time": "2022-10-11T12:58:36+00:00" }, { "name": "psr/container", @@ -3943,16 +3940,16 @@ }, { "name": "symfony/console", - "version": "v6.0.13", + "version": "v6.0.14", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "8f14753b865651c2aad107ef97475740a9b0730f" + "reference": "1f89cab8d52c84424f798495b3f10342a7b1a070" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/8f14753b865651c2aad107ef97475740a9b0730f", - "reference": "8f14753b865651c2aad107ef97475740a9b0730f", + "url": "https://api.github.com/repos/symfony/console/zipball/1f89cab8d52c84424f798495b3f10342a7b1a070", + "reference": "1f89cab8d52c84424f798495b3f10342a7b1a070", "shasum": "" }, "require": { @@ -4018,7 +4015,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.0.13" + "source": "https://github.com/symfony/console/tree/v6.0.14" }, "funding": [ { @@ -4034,7 +4031,7 @@ "type": "tidelift" } ], - "time": "2022-09-03T14:23:25+00:00" + "time": "2022-10-07T08:02:12+00:00" }, { "name": "symfony/deprecation-contracts", @@ -4495,16 +4492,16 @@ }, { "name": "symfony/string", - "version": "v6.0.13", + "version": "v6.0.14", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "65e99fb179e7241606377e4042cd2161f3dd1c05" + "reference": "3db7da820a6e4a584b714b3933c34c6a7db4d86c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/65e99fb179e7241606377e4042cd2161f3dd1c05", - "reference": "65e99fb179e7241606377e4042cd2161f3dd1c05", + "url": "https://api.github.com/repos/symfony/string/zipball/3db7da820a6e4a584b714b3933c34c6a7db4d86c", + "reference": "3db7da820a6e4a584b714b3933c34c6a7db4d86c", "shasum": "" }, "require": { @@ -4560,7 +4557,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.0.13" + "source": "https://github.com/symfony/string/tree/v6.0.14" }, "funding": [ { @@ -4576,7 +4573,7 @@ "type": "tidelift" } ], - "time": "2022-09-02T08:05:03+00:00" + "time": "2022-10-10T09:34:08+00:00" }, { "name": "theseer/tokenizer", @@ -4630,16 +4627,16 @@ }, { "name": "vimeo/psalm", - "version": "4.28.0", + "version": "4.29.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "52e96bea381e6cb07a672aefec791a5817694a26" + "reference": "7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/52e96bea381e6cb07a672aefec791a5817694a26", - "reference": "52e96bea381e6cb07a672aefec791a5817694a26", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3", + "reference": "7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3", "shasum": "" }, "require": { @@ -4732,9 +4729,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/4.28.0" + "source": "https://github.com/vimeo/psalm/tree/4.29.0" }, - "time": "2022-10-07T16:13:24+00:00" + "time": "2022-10-11T17:09:17+00:00" }, { "name": "webimpress/coding-standard", @@ -4849,7 +4846,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "ext-iconv": "*" }, "platform-dev": [], diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 608f3349..8d03b5a2 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + ! is_string($email) @@ -54,12 +54,6 @@ is_object($emailOrAddress) - - - - SmtpPluginManager - - null === $this->addressList @@ -80,15 +74,6 @@ $value - - $conversionInfo['errors'] - - - string - - - $ascii - $format !== HeaderInterface::FORMAT_RAW @@ -854,17 +839,10 @@ validatePlugin - $aliases $instanceOf - - Crammd5 - Login - Plain - \Zend\Mail\Protocol\Smtp - diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php index 9d442520..5c79a4cf 100644 --- a/src/ConfigProvider.php +++ b/src/ConfigProvider.php @@ -2,8 +2,6 @@ namespace Laminas\Mail; -use Zend\Mail\Protocol\SmtpPluginManager; - class ConfigProvider { /** @@ -28,7 +26,7 @@ public function getDependencyConfig() return [ // Legacy Zend Framework aliases 'aliases' => [ - SmtpPluginManager::class => Protocol\SmtpPluginManager::class, + 'Zend\Mail\Protocol\SmtpPluginManager' => Protocol\SmtpPluginManager::class, ], 'factories' => [ Protocol\SmtpPluginManager::class => Protocol\SmtpPluginManagerFactory::class, diff --git a/src/Header/AbstractAddressList.php b/src/Header/AbstractAddressList.php index 11a9a758..7ad4af48 100644 --- a/src/Header/AbstractAddressList.php +++ b/src/Header/AbstractAddressList.php @@ -9,8 +9,11 @@ use function array_filter; use function array_map; +use function assert; use function idn_to_ascii; use function implode; +use function is_array; +use function is_string; use function preg_match; use function preg_match_all; use function preg_replace; @@ -146,13 +149,16 @@ public function getFieldName() */ protected function idnToAscii($domainName): string { + /** @psalm-var string|false $ascii */ $ascii = idn_to_ascii($domainName, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $conversionInfo); - if (false !== $ascii) { + if (is_string($ascii)) { return $ascii; } $messages = []; - $errors = (int) $conversionInfo['errors']; + assert(is_array($conversionInfo)); + /* @psalm-var array{errors: numeric-string} $conversionInfo */ + $errors = (int) $conversionInfo['errors']; foreach (self::IDNA_ERROR_MAP as $flag => $message) { if (($flag & $errors) === $flag) { diff --git a/src/Protocol/SmtpPluginManager.php b/src/Protocol/SmtpPluginManager.php index 51c7c008..734901bb 100644 --- a/src/Protocol/SmtpPluginManager.php +++ b/src/Protocol/SmtpPluginManager.php @@ -6,9 +6,6 @@ use Laminas\ServiceManager\ConfigInterface; use Laminas\ServiceManager\Exception\InvalidServiceException; use Laminas\ServiceManager\Factory\InvokableFactory; -use Zend\Mail\Protocol\Smtp\Auth\Crammd5; -use Zend\Mail\Protocol\Smtp\Auth\Login; -use Zend\Mail\Protocol\Smtp\Auth\Plain; use function gettype; use function is_object; @@ -24,8 +21,8 @@ * * @psalm-import-type FactoriesConfigurationType from ConfigInterface * - * @template InstanceType of Smtp - * @extends AbstractPluginManager + * @extends AbstractPluginManager + * @final */ class SmtpPluginManager extends AbstractPluginManager { @@ -47,18 +44,20 @@ class SmtpPluginManager extends AbstractPluginManager 'smtp' => Smtp::class, 'Smtp' => Smtp::class, 'SMTP' => Smtp::class, - // Legacy Zend Framework aliases - Crammd5::class => Smtp\Auth\Crammd5::class, - Login::class => Smtp\Auth\Login::class, - Plain::class => Smtp\Auth\Plain::class, - \Zend\Mail\Protocol\Smtp::class => Smtp::class, - + 'Zend\Mail\Protocol\Smtp\Auth\Crammd5' => Smtp\Auth\Crammd5::class, + 'Zend\Mail\Protocol\Smtp\Auth\Login' => Smtp\Auth\Login::class, + 'Zend\Mail\Protocol\Smtp\Auth\Plain' => Smtp\Auth\Plain::class, + 'Zend\Mail\Protocol\Smtp' => Smtp::class, // v2 normalized FQCNs - 'zendmailprotocolsmtpauthcrammd5' => Smtp\Auth\Crammd5::class, - 'zendmailprotocolsmtpauthlogin' => Smtp\Auth\Login::class, - 'zendmailprotocolsmtpauthplain' => Smtp\Auth\Plain::class, - 'zendmailprotocolsmtp' => Smtp::class, + 'zendmailprotocolsmtpauthcrammd5' => Smtp\Auth\Crammd5::class, + 'zendmailprotocolsmtpauthlogin' => Smtp\Auth\Login::class, + 'zendmailprotocolsmtpauthplain' => Smtp\Auth\Plain::class, + 'zendmailprotocolsmtp' => Smtp::class, + 'laminasmailprotocolsmtpauthcrammd5' => Smtp\Auth\Crammd5::class, + 'laminasmailprotocolsmtpauthlogin' => Smtp\Auth\Login::class, + 'laminasmailprotocolsmtpauthplain' => Smtp\Auth\Plain::class, + 'laminasmailprotocolsmtp' => Smtp::class, ]; /** @@ -71,18 +70,12 @@ class SmtpPluginManager extends AbstractPluginManager Smtp\Auth\Login::class => InvokableFactory::class, Smtp\Auth\Plain::class => InvokableFactory::class, Smtp::class => InvokableFactory::class, - - // v2 normalized service names - 'laminasmailprotocolsmtpauthcrammd5' => InvokableFactory::class, - 'laminasmailprotocolsmtpauthlogin' => InvokableFactory::class, - 'laminasmailprotocolsmtpauthplain' => InvokableFactory::class, - 'laminasmailprotocolsmtp' => InvokableFactory::class, ]; /** * Plugins must be an instance of the Smtp class * - * @var string + * @var class-string */ protected $instanceOf = Smtp::class; @@ -91,7 +84,7 @@ class SmtpPluginManager extends AbstractPluginManager * * {@inheritDoc} */ - public function validate($instance) + public function validate(mixed $instance) { if (! $instance instanceof $this->instanceOf) { throw new InvalidServiceException(sprintf( @@ -105,10 +98,12 @@ public function validate($instance) /** * Validate a retrieved plugin instance (v2). * + * @deprecated + * * @param object $plugin * @throws Exception\InvalidArgumentException */ - public function validatePlugin($plugin) + public function validatePlugin(mixed $plugin) { try { $this->validate($plugin);