diff --git a/src/AbstractContainer.php b/src/AbstractContainer.php index da0b17cc..7b0571ed 100644 --- a/src/AbstractContainer.php +++ b/src/AbstractContainer.php @@ -532,15 +532,11 @@ public function setExpirationSeconds($ttl, $vars = null) $container = $this; // Filter out any items not in our container - $expires = array_filter($vars, function ($value) use ($container) { - return $container->offsetExists($value); - }); + $expires = array_filter($vars, static fn($value) => $container->offsetExists($value)); // Map item keys => timestamp $expires = array_flip($expires); - $expires = array_map(function () use ($ts) { - return $ts; - }, $expires); + $expires = array_map(static fn() => $ts, $expires); // Create metadata array to merge in $data = ['EXPIRE_KEYS' => $expires]; @@ -583,15 +579,11 @@ public function setExpirationHops($hops, $vars = null) $container = $this; // FilterInterface out any items not in our container - $expires = array_filter($vars, function ($value) use ($container) { - return $container->offsetExists($value); - }); + $expires = array_filter($vars, static fn($value) => $container->offsetExists($value)); // Map item keys => timestamp $expires = array_flip($expires); - $expires = array_map(function () use ($hops, $ts) { - return ['hops' => $hops, 'ts' => $ts]; - }, $expires); + $expires = array_map(static fn() => ['hops' => $hops, 'ts' => $ts], $expires); // Create metadata array to merge in $data = ['EXPIRE_HOPS_KEYS' => $expires]; diff --git a/src/Config/SessionConfig.php b/src/Config/SessionConfig.php index 33f70d54..6bd79437 100644 --- a/src/Config/SessionConfig.php +++ b/src/Config/SessionConfig.php @@ -82,7 +82,7 @@ class SessionConfig extends StandardConfig protected $phpErrorMessage = false; /** @var int Default number of seconds to make session sticky, when rememberMe() is called */ - protected $rememberMeSeconds = 1209600; // 2 weeks + protected $rememberMeSeconds = 1_209_600; // 2 weeks /** * Name of the save handler currently in use. This will either be a PHP diff --git a/src/SessionManager.php b/src/SessionManager.php index a7c0397e..e151873c 100644 --- a/src/SessionManager.php +++ b/src/SessionManager.php @@ -415,9 +415,7 @@ public function isValid() $event->setTarget($this); $event->setParams($this); - $falseResult = function ($test) { - return false === $test; - }; + $falseResult = static fn($test) => false === $test; $responses = $validator->triggerEventUntil($falseResult, $event); diff --git a/test/Config/SessionConfigTest.php b/test/Config/SessionConfigTest.php index 9612e723..044866a6 100644 --- a/test/Config/SessionConfigTest.php +++ b/test/Config/SessionConfigTest.php @@ -807,7 +807,7 @@ public function testUrlRewriterTagsAltersIniSetting(): void public function testRememberMeSecondsDefaultsToTwoWeeks(): void { - self::assertEquals(1209600, $this->config->getRememberMeSeconds()); + self::assertEquals(1_209_600, $this->config->getRememberMeSeconds()); } public function testRememberMeSecondsIsMutable(): void @@ -1021,18 +1021,16 @@ public function testProvidingNonSessionHandlerToSetPhpSaveHandlerResultsInExcept public function testProvidingValidKnownSessionHandlerToSetPhpSaveHandlerResultsInNoErrors(): void { /** @return string */ - $this->config::$phpinfo = function () { + $this->config::$phpinfo = static function () { echo "Registered save handlers => user files unittest"; }; /** @return bool|string */ - $this->config::$sessionModuleName = function (?string $module = null) { + $this->config::$sessionModuleName = static function (?string $module = null) { static $moduleName; - if ($module !== null) { $moduleName = $module; } - return $moduleName; }; @@ -1042,18 +1040,16 @@ public function testProvidingValidKnownSessionHandlerToSetPhpSaveHandlerResultsI public function testCanProvidePathWhenUsingRedisSaveHandler(): void { - $this->config::$phpinfo = function () { + $this->config::$phpinfo = static function () { echo "Registered save handlers => user files redis"; }; /** @return bool|string */ - $this->config::$sessionModuleName = function (?string $module = null) { + $this->config::$sessionModuleName = static function (?string $module = null) { static $moduleName; - if ($module !== null) { $moduleName = $module; } - return $moduleName; }; @@ -1069,7 +1065,7 @@ public function testNotCallLocateRegisteredSaveHandlersMethodIfSessionHandlerInt { $spy = new stdClass(); $spy->seen = false; - $this->config::$phpinfo = function () use ($spy): void { + $this->config::$phpinfo = static function () use ($spy): void { $spy->seen = true; }; diff --git a/test/ConfigProviderTest.php b/test/ConfigProviderTest.php index 94775a57..59cd2903 100644 --- a/test/ConfigProviderTest.php +++ b/test/ConfigProviderTest.php @@ -22,7 +22,7 @@ class ConfigProviderTest extends TestCase { /** @var array */ - private $config; + private array $config; protected function setUp(): void { diff --git a/test/SaveHandler/AbstractDbTableGatewayTest.php b/test/SaveHandler/AbstractDbTableGatewayTest.php index fcddd73a..190ee2f7 100644 --- a/test/SaveHandler/AbstractDbTableGatewayTest.php +++ b/test/SaveHandler/AbstractDbTableGatewayTest.php @@ -43,10 +43,8 @@ abstract class AbstractDbTableGatewayTest extends TestCase /** * Test data container. - * - * @var array */ - private $testArray; + private array $testArray; /** * @return Adapter diff --git a/test/SaveHandler/CacheTest.php b/test/SaveHandler/CacheTest.php index 169bccec..e45a346d 100644 --- a/test/SaveHandler/CacheTest.php +++ b/test/SaveHandler/CacheTest.php @@ -145,9 +145,7 @@ public function testDestroyReturnsTrueWhenSessionIsDeleted(): void function ($args) { $this->getItem('242', Argument::any()) ->will( - function ($args) { - return $args[1]; - } + fn($args) => $args[1] ); return true; } diff --git a/test/Service/SessionConfigFactoryTest.php b/test/Service/SessionConfigFactoryTest.php index 0dd88e00..36de6996 100644 --- a/test/Service/SessionConfigFactoryTest.php +++ b/test/Service/SessionConfigFactoryTest.php @@ -19,8 +19,7 @@ */ class SessionConfigFactoryTest extends TestCase { - /** @var ServiceManager */ - private $services; + private ServiceManager $services; protected function setUp(): void { diff --git a/test/Service/SessionManagerFactoryTest.php b/test/Service/SessionManagerFactoryTest.php index 94de8e1c..0adbe3a5 100644 --- a/test/Service/SessionManagerFactoryTest.php +++ b/test/Service/SessionManagerFactoryTest.php @@ -33,8 +33,7 @@ class SessionManagerFactoryTest extends TestCase use EventListenerIntrospectionTrait; use ReflectionPropertyTrait; - /** @var ServiceManager */ - private $services; + private ServiceManager $services; protected function setUp(): void { diff --git a/test/Service/StorageFactoryTest.php b/test/Service/StorageFactoryTest.php index 30f9946d..d17046f8 100644 --- a/test/Service/StorageFactoryTest.php +++ b/test/Service/StorageFactoryTest.php @@ -20,8 +20,7 @@ */ class StorageFactoryTest extends TestCase { - /** @var ServiceManager */ - private $services; + private ServiceManager $services; protected function setUp(): void { diff --git a/test/SessionArrayStorageTest.php b/test/SessionArrayStorageTest.php index 6148b8ea..fdc789e5 100644 --- a/test/SessionArrayStorageTest.php +++ b/test/SessionArrayStorageTest.php @@ -16,8 +16,7 @@ */ class SessionArrayStorageTest extends TestCase { - /** @var SessionArrayStorage */ - private $storage; + private SessionArrayStorage $storage; protected function setUp(): void { diff --git a/test/SessionManagerTest.php b/test/SessionManagerTest.php index ab1f323e..5ef46b14 100644 --- a/test/SessionManagerTest.php +++ b/test/SessionManagerTest.php @@ -532,9 +532,7 @@ public function testIdShouldNotBeMutableAfterSessionStarted(): void { $this->manager = new SessionManager(); $this->expectException( - RuntimeException::class, - 'Session has already been started); - $this->expectExceptionMessage(to change the session ID call regenerateId()' + RuntimeException::class ); $this->manager->start(); $origId = $this->manager->getId(); @@ -751,7 +749,7 @@ public function testSessionValidationDoesNotHaltOnNoopListener(): void { $this->manager = new SessionManager(); $validatorCalled = false; - $validator = function () use (&$validatorCalled) { + $validator = static function () use (&$validatorCalled) { $validatorCalled = true; }; diff --git a/test/Validator/ValidatorChainTest.php b/test/Validator/ValidatorChainTest.php index e001b166..76508bee 100644 --- a/test/Validator/ValidatorChainTest.php +++ b/test/Validator/ValidatorChainTest.php @@ -16,8 +16,7 @@ class ValidatorChainTest extends TestCase { - /** @var ValidatorChain */ - private $validatorChain; + private ValidatorChain $validatorChain; protected function setUp(): void {