diff --git a/src/MemorySession.php b/src/MemorySession.php index 3eafa4b..7f090a9 100644 --- a/src/MemorySession.php +++ b/src/MemorySession.php @@ -77,7 +77,7 @@ public function getName(): string return $this->options['name']; } - public function get(string $key, $default = null) + public function get(string $key, mixed $default = null): mixed { return $this->storage[$key] ?? $default; } @@ -87,7 +87,7 @@ public function all(): array return (array)$this->storage; } - public function set(string $key, $value): void + public function set(string $key, mixed $value): void { $this->storage[$key] = $value; } diff --git a/src/PhpSession.php b/src/PhpSession.php index 8bfdba6..e882e03 100644 --- a/src/PhpSession.php +++ b/src/PhpSession.php @@ -149,7 +149,7 @@ public function getName(): string return (string)session_name(); } - public function get(string $key, $default = null) + public function get(string $key, mixed $default = null): mixed { return $this->storage[$key] ?? $default; } @@ -159,7 +159,7 @@ public function all(): array return (array)$this->storage; } - public function set(string $key, $value): void + public function set(string $key, mixed $value): void { $this->storage[$key] = $value; } diff --git a/src/SessionInterface.php b/src/SessionInterface.php index 2f63579..fc76307 100644 --- a/src/SessionInterface.php +++ b/src/SessionInterface.php @@ -3,7 +3,7 @@ namespace Odan\Session; /** - * Interface. + * The session data operations. */ interface SessionInterface { @@ -11,11 +11,11 @@ interface SessionInterface * Gets an attribute by key. * * @param string $key The key name or null to get all values - * @param null $default The default value + * @param mixed $default The default value * - * @return mixed|null Should return null if the key is not found + * @return mixed The value. Returns null if the key is not found */ - public function get(string $key, $default = null); + public function get(string $key, mixed $default = null): mixed; /** * Gets all values as array. @@ -32,7 +32,7 @@ public function all(): array; * * @return void */ - public function set(string $key, $value): void; + public function set(string $key, mixed $value): void; /** * Sets multiple attributes at once: takes a keyed array and sets each key => value pair.