diff --git a/composer.json b/composer.json index 16852c02..973f22fb 100644 --- a/composer.json +++ b/composer.json @@ -44,12 +44,12 @@ "laminas/laminas-coding-standard": "~2.5.0", "laminas/laminas-config": "^3.8.0", "laminas/laminas-eventmanager": "^3.10", - "laminas/laminas-filter": "^2.31", - "laminas/laminas-validator": "^2.30.1", - "laminas/laminas-view": "^2.27", - "phpunit/phpunit": "^10.1.3", + "laminas/laminas-filter": "^2.32", + "laminas/laminas-validator": "^2.33", + "laminas/laminas-view": "^2.28", + "phpunit/phpunit": "^10.2.2", "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.11" + "vimeo/psalm": "^5.13.1" }, "conflict": { "laminas/laminas-view": "<2.20.0", diff --git a/composer.lock b/composer.lock index 9f3c0389..30481791 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": "13e8859c7d0d4bbbdd524f993f78fac2", + "content-hash": "c2b7028984f112cd3a7804a1f0556ab7", "packages": [ { "name": "laminas/laminas-servicemanager", @@ -1558,16 +1558,16 @@ }, { "name": "laminas/laminas-validator", - "version": "2.31.0", + "version": "2.33.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-validator.git", - "reference": "7dc274aa5afd5e23be0dbea13363e3d66ba5808b" + "reference": "1d82b5c0ede9316263e14d11e9284dfb3130f158" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/7dc274aa5afd5e23be0dbea13363e3d66ba5808b", - "reference": "7dc274aa5afd5e23be0dbea13363e3d66ba5808b", + "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/1d82b5c0ede9316263e14d11e9284dfb3130f158", + "reference": "1d82b5c0ede9316263e14d11e9284dfb3130f158", "shasum": "" }, "require": { @@ -1583,7 +1583,6 @@ "laminas/laminas-coding-standard": "^2.5", "laminas/laminas-db": "^2.18", "laminas/laminas-filter": "^2.32", - "laminas/laminas-http": "^2.18", "laminas/laminas-i18n": "^2.23", "laminas/laminas-session": "^2.16", "laminas/laminas-uri": "^2.10.0", @@ -1591,7 +1590,7 @@ "psalm/plugin-phpunit": "^0.18.4", "psr/http-client": "^1.0.2", "psr/http-factory": "^1.0.2", - "vimeo/psalm": "^5.11" + "vimeo/psalm": "^5.12" }, "suggest": { "laminas/laminas-db": "Laminas\\Db component, required by the (No)RecordExists validator", @@ -1639,20 +1638,20 @@ "type": "community_bridge" } ], - "time": "2023-05-19T09:42:26+00:00" + "time": "2023-06-12T09:43:54+00:00" }, { "name": "laminas/laminas-view", - "version": "2.27.0", + "version": "2.28.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-view.git", - "reference": "b7e66e148ccd55c815b9626ee0cfd358dbb28be4" + "reference": "c43dd9f89febb79a76cfa01c5cb2b90836d7d748" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-view/zipball/b7e66e148ccd55c815b9626ee0cfd358dbb28be4", - "reference": "b7e66e148ccd55c815b9626ee0cfd358dbb28be4", + "url": "https://api.github.com/repos/laminas/laminas-view/zipball/c43dd9f89febb79a76cfa01c5cb2b90836d7d748", + "reference": "c43dd9f89febb79a76cfa01c5cb2b90836d7d748", "shasum": "" }, "require": { @@ -1662,9 +1661,9 @@ "laminas/laminas-escaper": "^2.5", "laminas/laminas-eventmanager": "^3.4", "laminas/laminas-json": "^3.3", - "laminas/laminas-servicemanager": "^3.14.0", + "laminas/laminas-servicemanager": "^3.21.0", "laminas/laminas-stdlib": "^3.10.1", - "php": "~8.0.0 || ~8.1.0 || ~8.2.0", + "php": "~8.1.0 || ~8.2.0", "psr/container": "^1 || ^2" }, "conflict": { @@ -1677,21 +1676,21 @@ "laminas/laminas-authentication": "^2.13", "laminas/laminas-coding-standard": "~2.5.0", "laminas/laminas-feed": "^2.20", - "laminas/laminas-filter": "^2.31", + "laminas/laminas-filter": "^2.32", "laminas/laminas-http": "^2.18", - "laminas/laminas-i18n": "^2.21", + "laminas/laminas-i18n": "^2.23", "laminas/laminas-modulemanager": "^2.14", - "laminas/laminas-mvc": "^3.6", + "laminas/laminas-mvc": "^3.6.1", "laminas/laminas-mvc-i18n": "^1.7", "laminas/laminas-mvc-plugin-flashmessenger": "^1.9", "laminas/laminas-navigation": "^2.18.1", "laminas/laminas-paginator": "^2.17", - "laminas/laminas-permissions-acl": "^2.13", + "laminas/laminas-permissions-acl": "^2.14", "laminas/laminas-router": "^3.11.1", "laminas/laminas-uri": "^2.10", - "phpunit/phpunit": "^9.5.28", + "phpunit/phpunit": "^9.6.8", "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.4" + "vimeo/psalm": "^5.12" }, "suggest": { "laminas/laminas-authentication": "Laminas\\Authentication component", @@ -1739,7 +1738,7 @@ "type": "community_bridge" } ], - "time": "2023-02-09T16:07:15+00:00" + "time": "2023-05-30T11:38:25+00:00" }, { "name": "myclabs/deep-copy", @@ -1853,16 +1852,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.15.5", + "version": "v4.16.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "11e2663a5bc9db5d714eedb4277ee300403b4a9e" + "reference": "19526a33fb561ef417e822e85f08a00db4059c17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/11e2663a5bc9db5d714eedb4277ee300403b4a9e", - "reference": "11e2663a5bc9db5d714eedb4277ee300403b4a9e", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17", + "reference": "19526a33fb561ef417e822e85f08a00db4059c17", "shasum": "" }, "require": { @@ -1903,9 +1902,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.5" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.16.0" }, - "time": "2023-05-19T20:20:00+00:00" + "time": "2023-06-25T14:52:30+00:00" }, { "name": "phar-io/manifest", @@ -2229,16 +2228,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "10.1.1", + "version": "10.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "884a0da7f9f46f28b2cb69134217fd810b793974" + "reference": "db1497ec8dd382e82c962f7abbe0320e4882ee4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/884a0da7f9f46f28b2cb69134217fd810b793974", - "reference": "884a0da7f9f46f28b2cb69134217fd810b793974", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/db1497ec8dd382e82c962f7abbe0320e4882ee4e", + "reference": "db1497ec8dd382e82c962f7abbe0320e4882ee4e", "shasum": "" }, "require": { @@ -2295,7 +2294,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.1" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.2" }, "funding": [ { @@ -2303,7 +2302,7 @@ "type": "github" } ], - "time": "2023-04-17T12:15:40+00:00" + "time": "2023-05-22T09:04:27+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2549,16 +2548,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.1.3", + "version": "10.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "2379ebafc1737e71cdc84f402acb6b7f04198b9d" + "reference": "1ab521b24b88b88310c40c26c0cc4a94ba40ff95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2379ebafc1737e71cdc84f402acb6b7f04198b9d", - "reference": "2379ebafc1737e71cdc84f402acb6b7f04198b9d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1ab521b24b88b88310c40c26c0cc4a94ba40ff95", + "reference": "1ab521b24b88b88310c40c26c0cc4a94ba40ff95", "shasum": "" }, "require": { @@ -2598,7 +2597,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.1-dev" + "dev-main": "10.2-dev" } }, "autoload": { @@ -2630,7 +2629,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.1.3" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.2.2" }, "funding": [ { @@ -2646,7 +2645,7 @@ "type": "tidelift" } ], - "time": "2023-05-11T05:16:22+00:00" + "time": "2023-06-11T06:15:20+00:00" }, { "name": "psalm/plugin-phpunit", @@ -4099,23 +4098,23 @@ }, { "name": "symfony/console", - "version": "v6.2.10", + "version": "v6.3.0", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "12288d9f4500f84a4d02254d4aa968b15488476f" + "reference": "8788808b07cf0bdd6e4b7fdd23d8ddb1470c83b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/12288d9f4500f84a4d02254d4aa968b15488476f", - "reference": "12288d9f4500f84a4d02254d4aa968b15488476f", + "url": "https://api.github.com/repos/symfony/console/zipball/8788808b07cf0bdd6e4b7fdd23d8ddb1470c83b7", + "reference": "8788808b07cf0bdd6e4b7fdd23d8ddb1470c83b7", "shasum": "" }, "require": { "php": ">=8.1", - "symfony/deprecation-contracts": "^2.1|^3", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0", - "symfony/service-contracts": "^1.1|^2|^3", + "symfony/service-contracts": "^2.5|^3", "symfony/string": "^5.4|^6.0" }, "conflict": { @@ -4137,12 +4136,6 @@ "symfony/process": "^5.4|^6.0", "symfony/var-dumper": "^5.4|^6.0" }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" - }, "type": "library", "autoload": { "psr-4": { @@ -4175,7 +4168,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.2.10" + "source": "https://github.com/symfony/console/tree/v6.3.0" }, "funding": [ { @@ -4191,20 +4184,20 @@ "type": "tidelift" } ], - "time": "2023-04-28T13:37:43+00:00" + "time": "2023-05-29T12:49:39+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.2.1", + "version": "v3.3.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e" + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", - "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", "shasum": "" }, "require": { @@ -4213,7 +4206,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.3-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -4242,7 +4235,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.1" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" }, "funding": [ { @@ -4258,20 +4251,20 @@ "type": "tidelift" } ], - "time": "2023-03-01T10:25:55+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "symfony/filesystem", - "version": "v6.2.10", + "version": "v6.3.1", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "fd588debf7d1bc16a2c84b4b3b71145d9946b894" + "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/fd588debf7d1bc16a2c84b4b3b71145d9946b894", - "reference": "fd588debf7d1bc16a2c84b4b3b71145d9946b894", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", + "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", "shasum": "" }, "require": { @@ -4305,7 +4298,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.2.10" + "source": "https://github.com/symfony/filesystem/tree/v6.3.1" }, "funding": [ { @@ -4321,7 +4314,7 @@ "type": "tidelift" } ], - "time": "2023-04-18T13:46:08+00:00" + "time": "2023-06-01T08:30:39+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4738,16 +4731,16 @@ }, { "name": "symfony/string", - "version": "v6.2.8", + "version": "v6.3.0", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "193e83bbd6617d6b2151c37fff10fa7168ebddef" + "reference": "f2e190ee75ff0f5eced645ec0be5c66fac81f51f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/193e83bbd6617d6b2151c37fff10fa7168ebddef", - "reference": "193e83bbd6617d6b2151c37fff10fa7168ebddef", + "url": "https://api.github.com/repos/symfony/string/zipball/f2e190ee75ff0f5eced645ec0be5c66fac81f51f", + "reference": "f2e190ee75ff0f5eced645ec0be5c66fac81f51f", "shasum": "" }, "require": { @@ -4758,13 +4751,13 @@ "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/translation-contracts": "<2.0" + "symfony/translation-contracts": "<2.5" }, "require-dev": { "symfony/error-handler": "^5.4|^6.0", "symfony/http-client": "^5.4|^6.0", "symfony/intl": "^6.2", - "symfony/translation-contracts": "^2.0|^3.0", + "symfony/translation-contracts": "^2.5|^3.0", "symfony/var-exporter": "^5.4|^6.0" }, "type": "library", @@ -4804,7 +4797,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.2.8" + "source": "https://github.com/symfony/string/tree/v6.3.0" }, "funding": [ { @@ -4820,7 +4813,7 @@ "type": "tidelift" } ], - "time": "2023-03-20T16:06:02+00:00" + "time": "2023-03-21T21:06:29+00:00" }, { "name": "theseer/tokenizer", @@ -4874,16 +4867,16 @@ }, { "name": "vimeo/psalm", - "version": "5.11.0", + "version": "5.13.1", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "c9b192ab8400fdaf04b2b13d110575adc879aa90" + "reference": "086b94371304750d1c673315321a55d15fc59015" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/c9b192ab8400fdaf04b2b13d110575adc879aa90", - "reference": "c9b192ab8400fdaf04b2b13d110575adc879aa90", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/086b94371304750d1c673315321a55d15fc59015", + "reference": "086b94371304750d1c673315321a55d15fc59015", "shasum": "" }, "require": { @@ -4974,9 +4967,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/5.11.0" + "source": "https://github.com/vimeo/psalm/tree/5.13.1" }, - "time": "2023-05-04T21:35:44+00:00" + "time": "2023-06-27T16:39:49+00:00" }, { "name": "webimpress/coding-standard", diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 7cb0e215..9007c0d5 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + ExtensionNotLoadedException @@ -556,35 +556,18 @@ - - - - - - - - $country - $pattern - $pattern - $pattern - $pattern $valueNoCountry $valueNoCountry - $country - $pattern - $pattern - $type - $type static::$phone[$code] - array[]|false + >}|false]]> static::$phone[$code] @@ -691,12 +674,6 @@ - - getPluralRule()]]> - - - $rule - string diff --git a/src/Validator/PhoneNumber.php b/src/Validator/PhoneNumber.php index d5146321..51f92ddc 100644 --- a/src/Validator/PhoneNumber.php +++ b/src/Validator/PhoneNumber.php @@ -11,6 +11,7 @@ use function file_exists; use function in_array; use function is_scalar; +use function is_string; use function preg_match; use function strlen; use function strpos; @@ -167,7 +168,7 @@ public function setCountry($country) * Load Pattern * * @param string $code - * @return array[]|false + * @return array{code: string, patterns: array>}|false */ protected function loadPattern($code) { @@ -203,18 +204,18 @@ public function isValid($value = null, $context = null) } $this->setValue($value); - $country = $this->getCountry(); + $country = $this->getCountry(); + $countryPattern = $this->loadPattern(strtoupper($country)); - if (! $countryPattern = $this->loadPattern(strtoupper($country))) { - if (isset($context[$country])) { - $country = $context[$country]; - } + if (! $countryPattern && isset($context[$country]) && is_string($context[$country])) { + $country = $context[$country]; + $countryPattern = $this->loadPattern(strtoupper($country)); + } - if (! $countryPattern = $this->loadPattern(strtoupper($country))) { - $this->error(self::UNSUPPORTED); + if (! $countryPattern) { + $this->error(self::UNSUPPORTED); - return false; - } + return false; } $codeLength = strlen($countryPattern['code']); diff --git a/src/View/Helper/Plural.php b/src/View/Helper/Plural.php index e7639f35..d6d9c940 100644 --- a/src/View/Helper/Plural.php +++ b/src/View/Helper/Plural.php @@ -8,7 +8,6 @@ use Laminas\View\Helper\DeprecatedAbstractHelperHierarchyTrait; use function is_array; -use function sprintf; /** * Helper for rendering text based on a count number (like the I18n plural translation helper, but when translation @@ -29,7 +28,7 @@ class Plural extends AbstractHelper /** * Plural rule to use * - * @var PluralRule + * @var PluralRule|null */ protected $rule; @@ -44,17 +43,16 @@ class Plural extends AbstractHelper */ public function __invoke($strings, $number) { - if (null === $this->getPluralRule()) { - throw new Exception\InvalidArgumentException(sprintf( - 'No plural rule was set' - )); + $rule = $this->getPluralRule(); + if ($rule === null) { + throw new Exception\InvalidArgumentException('No plural rule was set'); } if (! is_array($strings)) { $strings = (array) $strings; } - $pluralIndex = $this->getPluralRule()->evaluate($number); + $pluralIndex = $rule->evaluate($number); return $strings[$pluralIndex]; } @@ -79,7 +77,7 @@ public function setPluralRule($pluralRule) /** * Get the plural rule to use * - * @return PluralRule + * @return PluralRule|null */ public function getPluralRule() {