diff --git a/composer.json b/composer.json index ed051cbb..6fb5dada 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "mongodb/mongodb": "~1.13.0", "phpunit/phpunit": "^9.5.26", "psalm/plugin-phpunit": "^0.18.0", - "vimeo/psalm": "^4.30" + "vimeo/psalm": "^5.0" }, "suggest": { "laminas/laminas-cache": "Laminas\\Cache component", diff --git a/composer.lock b/composer.lock index 769c02e9..fc36618f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d560169eacfc56328edde5b196422e20", + "content-hash": "dea9f95c3fff0c3de3a17554ec05110e", "packages": [ { "name": "laminas/laminas-eventmanager", - "version": "3.6.0", + "version": "3.7.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-eventmanager.git", - "reference": "3f1afbad86cd34a431fdc069f265cfe6f8fc8308" + "reference": "b954c360182b9160026a8393d7b1b716dcae25d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-eventmanager/zipball/3f1afbad86cd34a431fdc069f265cfe6f8fc8308", - "reference": "3f1afbad86cd34a431fdc069f265cfe6f8fc8308", + "url": "https://api.github.com/repos/laminas/laminas-eventmanager/zipball/b954c360182b9160026a8393d7b1b716dcae25d7", + "reference": "b954c360182b9160026a8393d7b1b716dcae25d7", "shasum": "" }, "require": { @@ -30,11 +30,11 @@ "require-dev": { "laminas/laminas-coding-standard": "~2.4.0", "laminas/laminas-stdlib": "^3.15", - "phpbench/phpbench": "^1.2.6", - "phpunit/phpunit": "^9.5.25", - "psalm/plugin-phpunit": "^0.17.0", + "phpbench/phpbench": "^1.2.7", + "phpunit/phpunit": "^9.5.26", + "psalm/plugin-phpunit": "^0.18.0", "psr/container": "^1.1.2 || ^2.0.2", - "vimeo/psalm": "^4.28" + "vimeo/psalm": "^5.0.0" }, "suggest": { "laminas/laminas-stdlib": "^2.7.3 || ^3.0, to use the FilterChain feature", @@ -72,20 +72,20 @@ "type": "community_bridge" } ], - "time": "2022-10-11T12:46:13+00:00" + "time": "2022-12-01T16:12:47+00:00" }, { "name": "laminas/laminas-servicemanager", - "version": "3.19.0", + "version": "3.20.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-servicemanager.git", - "reference": "ed160729bb8721127efdaac799f9a298963345b1" + "reference": "bc2c2cbe2dd90db8b9d16b0618f542692b76ab59" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/ed160729bb8721127efdaac799f9a298963345b1", - "reference": "ed160729bb8721127efdaac799f9a298963345b1", + "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/bc2c2cbe2dd90db8b9d16b0618f542692b76ab59", + "reference": "bc2c2cbe2dd90db8b9d16b0618f542692b76ab59", "shasum": "" }, "require": { @@ -108,14 +108,14 @@ "require-dev": { "composer/package-versions-deprecated": "^1.11.99.5", "laminas/laminas-coding-standard": "~2.4.0", - "laminas/laminas-container-config-test": "^0.7", + "laminas/laminas-container-config-test": "^0.8", "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.28" + "phpbench/phpbench": "^1.2.7", + "phpunit/phpunit": "^9.5.26", + "psalm/plugin-phpunit": "^0.18.0", + "vimeo/psalm": "^5.0.0" }, "suggest": { "ocramius/proxy-manager": "ProxyManager ^2.1.1 to handle lazy initialization of services" @@ -162,20 +162,20 @@ "type": "community_bridge" } ], - "time": "2022-10-10T20:59:22+00:00" + "time": "2022-12-01T17:03:38+00:00" }, { "name": "laminas/laminas-stdlib", - "version": "3.15.0", + "version": "3.16.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-stdlib.git", - "reference": "63b66bd4b696f024f42616b9d95cdb10e5109c27" + "reference": "f4f773641807c7ccee59b758bfe4ac4ba33ecb17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/63b66bd4b696f024f42616b9d95cdb10e5109c27", - "reference": "63b66bd4b696f024f42616b9d95cdb10e5109c27", + "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/f4f773641807c7ccee59b758bfe4ac4ba33ecb17", + "reference": "f4f773641807c7ccee59b758bfe4ac4ba33ecb17", "shasum": "" }, "require": { @@ -186,10 +186,10 @@ }, "require-dev": { "laminas/laminas-coding-standard": "^2.4.0", - "phpbench/phpbench": "^1.2.6", - "phpunit/phpunit": "^9.5.25", - "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.28" + "phpbench/phpbench": "^1.2.7", + "phpunit/phpunit": "^9.5.26", + "psalm/plugin-phpunit": "^0.18.0", + "vimeo/psalm": "^5.0.0" }, "type": "library", "autoload": { @@ -221,7 +221,7 @@ "type": "community_bridge" } ], - "time": "2022-10-10T19:10:24+00:00" + "time": "2022-12-03T18:48:01+00:00" }, { "name": "psr/container", @@ -4321,6 +4321,69 @@ ], "time": "2022-01-02T09:55:41+00:00" }, + { + "name": "symfony/filesystem", + "version": "v6.0.13", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "3adca49133bd055ebe6011ed1e012be3c908af79" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/3adca49133bd055ebe6011ed1e012be3c908af79", + "reference": "3adca49133bd055ebe6011ed1e012be3c908af79", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v6.0.13" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-09-21T20:25:27+00:00" + }, { "name": "symfony/polyfill-ctype", "version": "v1.27.0", @@ -4954,24 +5017,24 @@ }, { "name": "vimeo/psalm", - "version": "4.30.0", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "d0bc6e25d89f649e4f36a534f330f8bb4643dd69" + "reference": "4defa177c89397c5e14737a80fe4896584130674" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/d0bc6e25d89f649e4f36a534f330f8bb4643dd69", - "reference": "d0bc6e25d89f649e4f36a534f330f8bb4643dd69", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/4defa177c89397c5e14737a80fe4896584130674", + "reference": "4defa177c89397c5e14737a80fe4896584130674", "shasum": "" }, "require": { "amphp/amp": "^2.4.2", "amphp/byte-stream": "^1.5", - "composer/package-versions-deprecated": "^1.8.0", + "composer/package-versions-deprecated": "^1.10.0", "composer/semver": "^1.4 || ^2.0 || ^3.0", - "composer/xdebug-handler": "^1.1 || ^2.0 || ^3.0", + "composer/xdebug-handler": "^2.0 || ^3.0", "dnoegel/php-xdg-base-dir": "^0.1.1", "ext-ctype": "*", "ext-dom": "*", @@ -4980,35 +5043,34 @@ "ext-mbstring": "*", "ext-simplexml": "*", "ext-tokenizer": "*", - "felixfbecker/advanced-json-rpc": "^3.0.3", - "felixfbecker/language-server-protocol": "^1.5", + "felixfbecker/advanced-json-rpc": "^3.1", + "felixfbecker/language-server-protocol": "^1.5.2", "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", "nikic/php-parser": "^4.13", "openlss/lib-array2xml": "^1.0", - "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" + "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0", + "sebastian/diff": "^4.0", + "symfony/console": "^4.1.6 || ^5.0 || ^6.0", + "symfony/filesystem": "^5.4 || ^6.0", + "symfony/polyfill-php80": "^1.25" }, "provide": { "psalm/psalm": "self.version" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.2", - "brianium/paratest": "^4.0||^6.0", + "bamarni/composer-bin-plugin": "^1.4", + "brianium/paratest": "^6.0", "ext-curl": "*", + "mockery/mockery": "^1.5", + "nunomaduro/mock-final-classes": "^1.1", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpdocumentor/reflection-docblock": "^5", - "phpmyadmin/sql-parser": "5.1.0||dev-master", - "phpspec/prophecy": ">=1.9.0", - "phpstan/phpdoc-parser": "1.2.* || 1.6.4", - "phpunit/phpunit": "^9.0", - "psalm/plugin-phpunit": "^0.16", - "slevomat/coding-standard": "^7.0", - "squizlabs/php_codesniffer": "^3.5", - "symfony/process": "^4.3 || ^5.0 || ^6.0", - "weirdan/prophecy-shim": "^1.0 || ^2.0" + "phpstan/phpdoc-parser": "^1.6", + "phpunit/phpunit": "^9.5", + "psalm/plugin-mockery": "^1.1", + "psalm/plugin-phpunit": "^0.18", + "slevomat/coding-standard": "^8.4", + "squizlabs/php_codesniffer": "^3.6", + "symfony/process": "^4.4 || ^5.0 || ^6.0" }, "suggest": { "ext-curl": "In order to send data to shepherd", @@ -5024,17 +5086,14 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev", + "dev-master": "5.x-dev", + "dev-4.x": "4.x-dev", "dev-3.x": "3.x-dev", "dev-2.x": "2.x-dev", "dev-1.x": "1.x-dev" } }, "autoload": { - "files": [ - "src/functions.php", - "src/spl_object_id.php" - ], "psr-4": { "Psalm\\": "src/Psalm/" } @@ -5056,9 +5115,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/4.30.0" + "source": "https://github.com/vimeo/psalm/tree/5.1.0" }, - "time": "2022-11-06T20:37:08+00:00" + "time": "2022-12-02T01:23:35+00:00" }, { "name": "webimpress/coding-standard", @@ -5172,57 +5231,6 @@ "source": "https://github.com/webmozarts/assert/tree/1.11.0" }, "time": "2022-06-03T18:03:27+00:00" - }, - { - "name": "webmozart/path-util", - "version": "2.3.0", - "source": { - "type": "git", - "url": "https://github.com/webmozart/path-util.git", - "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozart/path-util/zipball/d939f7edc24c9a1bb9c0dee5cb05d8e859490725", - "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "webmozart/assert": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\PathUtil\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "A robust cross-platform utility for normalizing, comparing and modifying file paths.", - "support": { - "issues": "https://github.com/webmozart/path-util/issues", - "source": "https://github.com/webmozart/path-util/tree/2.3.0" - }, - "abandoned": "symfony/filesystem", - "time": "2015-12-17T08:42:14+00:00" } ], "aliases": [], diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 7d3ad9f6..2c5f28d4 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + null === $key @@ -22,12 +22,14 @@ $value $value - + $metadata['EXPIRE_HOPS']['hops'] $metadata['EXPIRE_HOPS']['ts'] $metadata['EXPIRE_HOPS_KEYS'][$key] $metadata['EXPIRE_HOPS_KEYS'][$key] $metadata['EXPIRE_HOPS_KEYS'][$key]['hops'] + $metadata['EXPIRE_HOPS_KEYS'][$key]['hops'] + $metadata['EXPIRE_HOPS_KEYS'][$key]['ts'] $metadata['EXPIRE_HOPS_KEYS'][$key]['ts'] $metadata['EXPIRE_KEYS'][$key] $metadata['EXPIRE_KEYS'][$key] @@ -37,14 +39,17 @@ $storage[$name][$key] $storage[$name][$key] - + $metadata['EXPIRE_HOPS']['hops'] $metadata['EXPIRE_HOPS']['ts'] $metadata['EXPIRE_HOPS_KEYS'][$key] $metadata['EXPIRE_HOPS_KEYS'][$key] $metadata['EXPIRE_HOPS_KEYS'][$key] $metadata['EXPIRE_HOPS_KEYS'][$key] - $storage[$name][$key] + $metadata['EXPIRE_HOPS_KEYS'][$key]['hops'] + $metadata['EXPIRE_HOPS_KEYS'][$key]['hops'] + $metadata['EXPIRE_HOPS_KEYS'][$key]['ts'] + $metadata['EXPIRE_HOPS_KEYS'][$key]['ts'] $container @@ -58,34 +63,35 @@ $storage[$name][$key] - array - array + exchangeArray + getArrayCopy $metadata['EXPIRE_HOPS']['hops'] $metadata['EXPIRE_HOPS_KEYS'][$key]['hops'] $metadata['EXPIRE_HOPS_KEYS'][$key]['hops'] - + + $container instanceof ArrayObject ? $container->getArrayCopy() : $container $container instanceof ArrayObject ? $container->getArrayCopy() : $container $old + $old - - $key - $key - $key - $key - - + + $old->getArrayCopy() + getIterator + new ArrayIterator($container) + + Container Container Container - Iterator $input - + + $key $key $name $storage @@ -196,7 +202,8 @@ - + + ! is_array($options) && ! $options instanceof Traversable ! is_numeric($sidLength) is_numeric($cacheExpire) is_numeric($cookieLifetime) @@ -307,15 +314,22 @@ string string|null - + $this->cookieDomain + $this->cookieDomain + $this->cookieHttpOnly $this->cookieHttpOnly $this->cookieLifetime + $this->cookieLifetime $this->cookiePath + $this->cookiePath + $this->cookieSameSite $this->cookieSameSite $this->cookieSecure + $this->cookieSecure $this->getOption('hash_function') $this->name + $this->name $this->options['cache_expire'] $this->options['entropy_file'] $this->options['entropy_length'] @@ -326,13 +340,13 @@ $this->options['sid_bits_per_character'] $this->options['sid_length'] $this->rememberMeSeconds + $this->rememberMeSeconds $this->savePath + $this->savePath + $this->useCookies $this->useCookies - - (int) $sidLength - - + (bool) $cookieHttpOnly (bool) $cookieSecure (bool) $useCookies @@ -344,13 +358,13 @@ (int) $hashBitsPerCharacter (int) $rememberMeSeconds (int) $sidBitsPerCharacter + (int) $sidLength (string) $cookiePath (string) $cookieSameSite (string) $name - ConfigInterface StorageInterface @@ -362,18 +376,9 @@ $storage[$name][$key] - - $ret - - - $key - Container - - $ret - @@ -477,13 +482,16 @@ (string) $data - - $collection - $database - + + Binary + Binary + UTCDateTime + UTCDateTime + - + + $this->saveOptions === ['w' => 1] $this->saveOptions === ['w' => 1] @@ -536,7 +544,8 @@ null|ManagerInterface - + + $this->sessionManager $this->sessionManager @@ -632,6 +641,9 @@ $id + + $oldSessionData + $_SERVER['REQUEST_TIME'] @@ -645,42 +657,32 @@ (bool) $config->getCookieSecure() (bool) $deleteOldSession - + ! empty($oldSessionData) && is_array($oldSessionData) is_array($oldSessionData) - + $oldSessionData instanceof Traversable - + $_SESSION $this $this - $this - $this - $this - $this - $this - $this - $this - $this - $this + $values + $values + new ArrayIterator($_SESSION) - - ArrayStorage - ArrayStorage - ArrayStorage - ArrayStorage - ArrayStorage + SessionStorage SessionStorage array + array<TKey, TValue> + getIterator - + $_SESSION - $key $_SESSION['__Laminas'] @@ -717,21 +719,41 @@ $metaData - + + $key + + $_SESSION instanceof ArrayObject - - $locks - + is_object($input) - + + $flags + $iteratorClass + + + $key + $key + $key + '__Laminas' + '__Laminas' + '__Laminas' + '__Laminas' + '__Laminas' + '__Laminas' + '__Laminas' + '__Laminas' + '__Laminas' + '__Laminas' + '__Laminas' + '__Laminas' + + $key - - $key $key $key @@ -740,7 +762,12 @@ $locks $this['__Laminas'] $this['__Laminas'][$key] + $value + + $this['__Laminas'] + $this['__Laminas'] + $array[$key] $locks[$key] @@ -771,6 +798,15 @@ $metaData + + $key + + + $this['__Laminas'] + + + $this['__Laminas'][$key] + ArrayStorage @@ -812,6 +848,11 @@ + + '_IMMUTABLE' + '_IMMUTABLE' + '_IMMUTABLE' + SessionStorage @@ -836,7 +877,7 @@ CallbackHandler - $this->attachValidator($eventName, $callback, $priority) + $this->attachValidator($eventName, $listener, $priority) CallbackHandler @@ -849,9 +890,6 @@ new $validator($data) - - $callback - CallbackHandler @@ -885,9 +923,6 @@ new $validator($data) - - $callback - @@ -898,15 +933,9 @@ 'InvalidArgumentException' - + $handler $saveHandler - - - $handler - $saveHandler - - 'foobar_bogus' 'foobar_bogus' 'foobar_bogus' @@ -914,9 +943,15 @@ 'foobar_bogus' 'foobar_bogus' 'foobar_bogus' - 1 24 24 + + + $handler + $saveHandler + + + 1 static function (?string $module = null) { @@ -966,7 +1001,7 @@ setHashBitsPerCharacter setHashFunction - + 'foobar_bogus' 'foobar_bogus' 'foobar_bogus' @@ -977,7 +1012,7 @@ 'foobar_bogus' 24 24 - + testCookieSameSiteIsMutable @@ -1036,34 +1071,29 @@ $metadata['EXPIRE_HOPS_KEYS'] $metadata['EXPIRE_KEYS'] - + $metadata['EXPIRE'] $metadata['EXPIRE'] $metadata['EXPIRE_HOPS'] $metadata['EXPIRE_HOPS_KEYS'] $metadata['EXPIRE_HOPS_KEYS'] $metadata['EXPIRE_HOPS_KEYS'] + $metadata['EXPIRE_HOPS_KEYS']['foo'] $metadata['EXPIRE_KEYS'] $metadata['EXPIRE_KEYS'] $metadata['EXPIRE_KEYS'] $metadata['EXPIRE_KEYS'] $metadata['EXPIRE_KEYS'] + $metadata['EXPIRE_KEYS']['bat'] + $metadata['EXPIRE_KEYS']['baz'] + $metadata['EXPIRE_KEYS']['foo'] + $metadata['EXPIRE_KEYS']['foo'] $storage['Default']['foo'] $storage['foo']['baz'] $this->container['foo']['bar'] - - $test[$key] - $test[$key] - $test[$key] - $test[$key] - - + $hops - $key - $key - $key - $key $metadata $metadata $metadata @@ -1073,14 +1103,6 @@ $metadata $metadata $metadata - $test[$key] - $test[$key] - $test[$key] - $test[$key] - $value - $value - $value - $value $this->manager->started @@ -1113,8 +1135,7 @@ count - - $this->adapter + $this->adapter assertTrue is_string($data) @@ -1155,26 +1176,29 @@ count count - + 0 - - 123 123 123 456 456 456 - + + + RuntimeException::class + getenv('TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MONGODB_CONNECTION_STRING') - - $this->mongoCollection + $this->mongoCollection assertTrue is_string($data) + + RuntimeException + @@ -1265,8 +1289,9 @@ - + $config['session_storage']['options'] + $config['session_storage']['options']['input'] $storage @@ -1285,17 +1310,21 @@ $_SESSION $_SESSION - + $_SESSION['test']['foo'] $this->storage['foo']['bar'] $this->storage['foo']['bar'] $this->storage['foo']['bar'] + $this->storage['foo']['bar']['baz'] $_SESSION['foo']['bar'] $this->storage['bar'][] $this->storage['baz']['foo'] + + assertSame + @@ -1371,6 +1400,9 @@ $_SESSION->key1 $_SESSION->key2 + + $_SESSION + var_export($headers, 1) var_export($headers, 1) @@ -1433,10 +1465,16 @@ - + $this->storage['foo']['bar'] $this->storage['foo']['bar'] + $this->storage['foo']['bar']['baz'] + + $this->storage['foo']['bar'] + $this->storage['foo']['bar'] + $this->storage['foo']['bar']['baz'] + @@ -1460,10 +1498,10 @@ - + $id $id - + TestDbTableGatewaySaveHandler TestDbTableGatewaySaveHandler diff --git a/psalm.xml b/psalm.xml index c4e98ee1..bece6c29 100644 --- a/psalm.xml +++ b/psalm.xml @@ -14,19 +14,6 @@ - - - - - - - - - - - - - diff --git a/src/AbstractContainer.php b/src/AbstractContainer.php index 80b525fa..3fca8412 100644 --- a/src/AbstractContainer.php +++ b/src/AbstractContainer.php @@ -3,7 +3,6 @@ namespace Laminas\Session; use ArrayIterator; -use Iterator; use Laminas\Session\ManagerInterface as Manager; use Laminas\Session\Storage\StorageInterface as Storage; use Laminas\Stdlib\ArrayObject; @@ -26,6 +25,10 @@ * may have their own expiries, or even expiries per key in the container. * Additionally, expiries may be absolute TTLs or measured in "hops", which * are based on how many times the key or container were accessed. + * + * @template TKey of string + * @template TValue + * @template-extends ArrayObject */ abstract class AbstractContainer extends ArrayObject { @@ -458,14 +461,7 @@ public function offsetUnset($key) unset($storage[$name][$key]); } - /** - * Exchange the current array with another array or object. - * - * @see ArrayObject::exchangeArray() - * - * @param array|object $input - * @return array Returns the old array - */ + /** @inheritDoc */ public function exchangeArray($input) { // handle arrayobject, iterators and the like: @@ -488,11 +484,7 @@ public function exchangeArray($input) return $old; } - /** - * Iterate over session container - * - * @return Iterator - */ + /** @inheritDoc */ public function getIterator() { $this->expireKeys(); @@ -601,11 +593,7 @@ public function setExpirationHops($hops, $vars = null) return $this; } - /** - * Creates a copy of the specific container name - * - * @return array - */ + /** @inheritDoc */ public function getArrayCopy() { $storage = $this->verifyNamespace(); diff --git a/src/Container.php b/src/Container.php index e3c0c990..7469fbee 100644 --- a/src/Container.php +++ b/src/Container.php @@ -9,6 +9,10 @@ * may have their own expiries, or even expiries per key in the container. * Additionally, expiries may be absolute TTLs or measured in "hops", which * are based on how many times the key or container were accessed. + * + * @template TKey of string + * @template TValue + * @template-extends AbstractContainer */ class Container extends AbstractContainer { diff --git a/src/Storage/AbstractSessionArrayStorage.php b/src/Storage/AbstractSessionArrayStorage.php index 659f3104..58f61759 100644 --- a/src/Storage/AbstractSessionArrayStorage.php +++ b/src/Storage/AbstractSessionArrayStorage.php @@ -27,6 +27,11 @@ * property access, metadata storage, locking, and immutability. * * @see ReturnTypeWillChange + * + * @template TKey of array-key + * @template TValue + * @template-implements IteratorAggregate + * @template-implements StorageInterface */ abstract class AbstractSessionArrayStorage implements IteratorAggregate, @@ -193,11 +198,7 @@ public function unserialize($session) return unserialize($session); } - /** - * Get Iterator - * - * @return ArrayIterator - */ + /** @inheritDoc */ #[ReturnTypeWillChange] public function getIterator() { @@ -247,7 +248,7 @@ public function isImmutable() * Lock this storage instance, or a key within it * * @param null|int|string $key - * @return ArrayStorage + * @return $this */ public function lock($key = null) { @@ -304,7 +305,7 @@ public function isLocked($key = null) * Unlock an object or key marked as locked * * @param null|int|string $key - * @return ArrayStorage + * @return $this */ public function unlock($key = null) { @@ -348,7 +349,7 @@ public function unlock($key = null) * @param string $key * @param mixed $value * @param bool $overwriteArray Whether to overwrite or merge array values; by default, merges - * @return ArrayStorage + * @return $this * @throws Exception\RuntimeException */ public function setMetadata($key, $value, $overwriteArray = false) @@ -412,7 +413,7 @@ public function getMetadata($key = null) * Clear the storage object or a subkey of the object * * @param null|int|string $key - * @return ArrayStorage + * @return $this * @throws Exception\RuntimeException */ public function clear($key = null) @@ -447,7 +448,7 @@ public function getRequestAccessTime() * Set the request access time * * @param float $time - * @return ArrayStorage + * @return $this */ protected function setRequestAccessTime($time) { @@ -460,7 +461,7 @@ protected function setRequestAccessTime($time) * Cast the object to an array * * @param bool $metaData Whether to include metadata - * @return array + * @return array */ public function toArray($metaData = false) { diff --git a/src/Storage/ArrayStorage.php b/src/Storage/ArrayStorage.php index ee855572..e9f80cf8 100644 --- a/src/Storage/ArrayStorage.php +++ b/src/Storage/ArrayStorage.php @@ -22,6 +22,11 @@ * for setting metadata, locking, and marking as isImmutable. * * @see ReturnTypeWillChange + * + * @template TKey of array-key + * @template TValue + * @template-extends ArrayObject + * @template-implements StorageInterface */ class ArrayStorage extends ArrayObject implements StorageInterface { @@ -55,7 +60,7 @@ public function __construct( * Set the request access time * * @param float $time - * @return ArrayStorage + * @return $this */ protected function setRequestAccessTime($time) { @@ -111,7 +116,7 @@ public function offsetSet($key, $value) * Lock this storage instance, or a key within it * * @param null|int|string $key - * @return ArrayStorage + * @return $this */ public function lock($key = null) { @@ -167,7 +172,7 @@ public function isLocked($key = null) * Unlock an object or key marked as locked * * @param null|int|string $key - * @return ArrayStorage + * @return $this */ public function unlock($key = null) { @@ -201,7 +206,7 @@ public function unlock($key = null) /** * Mark the storage container as isImmutable * - * @return ArrayStorage + * @return $this */ public function markImmutable() { @@ -233,7 +238,7 @@ public function isImmutable() * @param string $key * @param mixed $value * @param bool $overwriteArray Whether to overwrite or merge array values; by default, merges - * @return ArrayStorage + * @return $this * @throws Exception\RuntimeException */ public function setMetadata($key, $value, $overwriteArray = false) @@ -301,7 +306,7 @@ public function getMetadata($key = null) * Clear the storage object or a subkey of the object * * @param null|int|string $key - * @return ArrayStorage + * @return $this * @throws Exception\RuntimeException */ public function clear($key = null) @@ -335,7 +340,7 @@ public function clear($key = null) * Overwrites any data that was previously set. * * @param array $array - * @return ArrayStorage + * @return $this */ public function fromArray(array $array) { @@ -350,7 +355,7 @@ public function fromArray(array $array) * Cast the object to an array * * @param bool $metaData Whether to include metadata - * @return array + * @return array */ public function toArray($metaData = false) { diff --git a/src/Storage/SessionArrayStorage.php b/src/Storage/SessionArrayStorage.php index 065b12bb..cdfac79e 100644 --- a/src/Storage/SessionArrayStorage.php +++ b/src/Storage/SessionArrayStorage.php @@ -3,7 +3,11 @@ namespace Laminas\Session\Storage; /** - * Session storage in $_SESSION + * Session storage in $_SESSION' + * + * @template TKey of array-key + * @template TValue + * @template-extends AbstractSessionArrayStorage */ class SessionArrayStorage extends AbstractSessionArrayStorage { diff --git a/src/Storage/SessionStorage.php b/src/Storage/SessionStorage.php index 79342fe1..baa9fdf5 100644 --- a/src/Storage/SessionStorage.php +++ b/src/Storage/SessionStorage.php @@ -12,6 +12,10 @@ * * Replaces the $_SESSION superglobal with an ArrayObject that allows for * property access, metadata storage, locking, and immutability. + * + * @template TKey of array-key + * @template TValue + * @template-extends ArrayStorage */ class SessionStorage extends ArrayStorage { @@ -66,8 +70,8 @@ public function __destruct() * * Ensures $_SESSION is set to an instance of the object when complete. * - * @param array $array - * @return SessionStorage + * @param array $array + * @return $this */ public function fromArray(array $array) { @@ -82,7 +86,7 @@ public function fromArray(array $array) /** * Mark object as isImmutable * - * @return SessionStorage + * @return $this */ public function markImmutable() { diff --git a/src/Storage/StorageInterface.php b/src/Storage/StorageInterface.php index b80927e5..6ef8e740 100644 --- a/src/Storage/StorageInterface.php +++ b/src/Storage/StorageInterface.php @@ -12,6 +12,11 @@ * * Defines the minimum requirements for handling userland, in-script session * storage (e.g., the $_SESSION superglobal array). + * + * @template TKey of array-key + * @template TValue + * @template-extends Traversable + * @template-extends ArrayAccess */ interface StorageInterface extends Traversable, ArrayAccess, Serializable, Countable { diff --git a/src/Validator/AbstractValidatorChainEM3.php b/src/Validator/AbstractValidatorChainEM3.php index 075b7e36..a1d25a49 100644 --- a/src/Validator/AbstractValidatorChainEM3.php +++ b/src/Validator/AbstractValidatorChainEM3.php @@ -42,8 +42,8 @@ public function __construct(StorageInterface $storage) * @param int $priority * @return CallbackHandler */ - public function attach($eventName, callable $callback, $priority = 1) + public function attach($eventName, callable $listener, $priority = 1) { - return $this->attachValidator($eventName, $callback, $priority); + return $this->attachValidator($eventName, $listener, $priority); } } diff --git a/src/ValidatorChain.php b/src/ValidatorChain.php index 50f24974..7e222819 100644 --- a/src/ValidatorChain.php +++ b/src/ValidatorChain.php @@ -30,9 +30,9 @@ public function __construct(protected StorageInterface $storage) * @param int $priority * @return callable */ - public function attach($eventName, callable $callback, $priority = 1) + public function attach($eventName, callable $listener, $priority = 1) { - return $this->attachValidator($eventName, $callback, $priority); + return $this->attachValidator($eventName, $listener, $priority); } /** diff --git a/test/StorageTest.php b/test/StorageTest.php index 08eaf8cd..d6e529cc 100644 --- a/test/StorageTest.php +++ b/test/StorageTest.php @@ -11,10 +11,9 @@ /** * @covers \Laminas\Session\Storage\ArrayStorage */ -class StorageTest extends TestCase +final class StorageTest extends TestCase { - /** @var ArrayStorage */ - protected $storage; + private ArrayStorage $storage; protected function setUp(): void { diff --git a/test/TestAsset/Php81CompatibleStorageInterface.php b/test/TestAsset/Php81CompatibleStorageInterface.php index ce468a76..510397bf 100644 --- a/test/TestAsset/Php81CompatibleStorageInterface.php +++ b/test/TestAsset/Php81CompatibleStorageInterface.php @@ -6,6 +6,11 @@ use Laminas\Session\Storage\StorageInterface; +/** + * @template TKey of array-key + * @template TValue + * @template-extends StorageInterface + */ interface Php81CompatibleStorageInterface extends StorageInterface { public function __serialize(): array; diff --git a/test/TestAsset/TestContainer.php b/test/TestAsset/TestContainer.php index 1635099b..9299390a 100644 --- a/test/TestAsset/TestContainer.php +++ b/test/TestAsset/TestContainer.php @@ -6,6 +6,11 @@ use Laminas\Session\AbstractContainer; +/** + * @template TKey of string + * @template TValue + * @template-extends AbstractContainer + */ class TestContainer extends AbstractContainer { // do nothing