Skip to content

Commit

Permalink
Add doc blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Sep 20, 2024
1 parent 6a879c8 commit cf90588
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/Flash.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
*/
final class Flash implements FlashInterface
{
/**
* @var array<string, mixed>|ArrayAccess<string, mixed>
*/
private array|ArrayAccess $storage;

private string $storageKey;

/**
* @param array<string, mixed>|ArrayAccess<string, mixed> $storage
*/
public function __construct(array|ArrayAccess &$storage, string $storageKey = '_flash')
{
$this->storage = &$storage;
Expand Down
4 changes: 2 additions & 2 deletions src/FlashInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function add(string $key, string $message): void;
*
* @param string $key The key to get the message from
*
* @return array The messages
* @return array<int, string> The messages
*/
public function get(string $key): array;

Expand Down Expand Up @@ -55,7 +55,7 @@ public function set(string $key, array $messages): void;
/**
* Gets all flash messages.
*
* @return array All messages. Can be an empty array.
* @return array<int, string> All messages. Can be an empty array.
*/
public function all(): array;
}
9 changes: 9 additions & 0 deletions src/MemorySession.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
*/
final class MemorySession implements SessionInterface, SessionManagerInterface
{
/**
* @var array<string, mixed>
*/
private array $options = [
'name' => 'app',
'lifetime' => 7200,
];

/**
* @var array<string, mixed>
*/
private array $storage;

private Flash $flash;
Expand All @@ -20,6 +26,9 @@ final class MemorySession implements SessionInterface, SessionManagerInterface

private bool $started = false;

/**
* @param array<string, mixed> $options
*/
public function __construct(array $options = [])
{
$keys = array_keys($this->options);
Expand Down
9 changes: 9 additions & 0 deletions src/PhpSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
*/
final class PhpSession implements SessionInterface, SessionManagerInterface
{
/**
* @var array<string, mixed>
*/
private array $storage;

private FlashInterface $flash;

/**
* @var array<string, mixed>
*/
private array $options = [
'id' => null,
'name' => 'app',
Expand All @@ -26,6 +32,9 @@ final class PhpSession implements SessionInterface, SessionManagerInterface
'cache_limiter' => 'nocache',
];

/**
* @param array<string, mixed> $options
*/
public function __construct(array $options = [])
{
// Prevent uninitialized state
Expand Down
4 changes: 2 additions & 2 deletions src/SessionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function get(string $key, mixed $default = null): mixed;
/**
* Gets all values as array.
*
* @return array The session values
* @return array<string, mixed> The session values
*/
public function all(): array;

Expand All @@ -37,7 +37,7 @@ public function set(string $key, mixed $value): void;
/**
* Sets multiple attributes at once: takes a keyed array and sets each key => value pair.
*
* @param array $values The new values
* @param array<string, mixed> $values The new values
*/
public function setValues(array $values): void;

Expand Down

0 comments on commit cf90588

Please sign in to comment.