Skip to content

Commit

Permalink
add types to FakeSession class inherited from SimpleSAML\Session [ski…
Browse files Browse the repository at this point in the history
…p ci]
  • Loading branch information
briskt committed Jun 14, 2024
1 parent 158c240 commit 4e045f0
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions modules/silauth/src/Auth/Source/tests/unit/csrf/FakeSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,32 @@

namespace SimpleSAML\Module\silauth\Auth\Source\tests\unit\csrf;

use SimpleSAML\Session;

/**
* Class to mimic the bare basics of the SimpleSAML\Session class in order to
* allow good testing of the CsrfProtector class.
*/
class FakeSession extends \SimpleSAML\Session
class FakeSession extends Session
{
private $inMemoryDataStore;
private array $inMemoryDataStore;

private function __construct($transient = false)
private function __construct(bool $transient = false)
{
$this->inMemoryDataStore = [];
}

/**
* @param string $type
* @param string|null $id
* @return mixed
*/
public function getData($type, $id)
public function getData(string $type, ?string $id): mixed
{
return $this->inMemoryDataStore[$type][$id] ?? null;
}

public static function getSessionFromRequest($sessionId = null)
public static function getSessionFromRequest(): Session
{
return new self();
}

public function setData($type, $id, $data, $timeout = null)
public function setData(string $type, string $id, mixed $data, int|string|null $timeout = null): void
{
// Make sure an array exists for that type of data.
$this->inMemoryDataStore[$type] = $this->inMemoryDataStore[$type] ?? [];
Expand Down

0 comments on commit 4e045f0

Please sign in to comment.