Skip to content

Commit

Permalink
Fix a range of minor psalm issues
Browse files Browse the repository at this point in the history
Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Jan 8, 2024
1 parent ff7aa3c commit 136c24e
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 242 deletions.
354 changes: 154 additions & 200 deletions psalm-baseline.xml

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/AbstractContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,16 +392,16 @@ protected function expireByHops(Storage $storage, $name, $key)
/**
* Store a value within the container
*
* @param string $key
* @param string $offset
* @param mixed $value
* @return void
*/
public function offsetSet($key, $value)
public function offsetSet($offset, $value)
{
$this->expireKeys($key);
$storage = $this->verifyNamespace();
$name = $this->getName();
$storage[$name][$key] = $value;
$this->expireKeys($offset);
$storage = $this->verifyNamespace();
$name = $this->getName();
$storage[$name][$offset] = $value;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/SaveHandler/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public function __construct(CacheStorage $cacheStorage)
/**
* Open Session
*
* @param string $savePath
* @param string $path
* @param string $name
* @return bool
*/
#[ReturnTypeWillChange]
public function open($savePath, $name)
public function open($path, $name)
{
// @todo figure out if we want to use these
$this->sessionSavePath = $savePath;
$this->sessionSavePath = $path;
$this->sessionName = $name;

return true;
Expand Down
6 changes: 3 additions & 3 deletions src/SaveHandler/DbTableGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public function __construct(
/**
* Open Session
*
* @param string $savePath
* @param string $path
* @param string $name
* @return bool
*/
#[ReturnTypeWillChange]
public function open($savePath, $name)
public function open($path, $name)
{
$this->sessionSavePath = $savePath;
$this->sessionSavePath = $path;
$this->sessionName = $name;
$this->lifetime = ini_get('session.gc_maxlifetime');

Expand Down
4 changes: 2 additions & 2 deletions src/SaveHandler/MongoDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public function __construct(protected $mongoClient, MongoDBOptions $options)
/**
* Open session
*
* @param string $savePath
* @param string $path
* @param string $name
* @return bool
*/
#[ReturnTypeWillChange]
public function open($savePath, $name)
public function open($path, $name)
{
// Note: session save path is not used
$this->sessionName = $name;
Expand Down
8 changes: 4 additions & 4 deletions src/Storage/AbstractSessionArrayStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ public function offsetGet(mixed $key)
* @return void
*/
#[ReturnTypeWillChange]
public function offsetSet(mixed $key, mixed $value)
public function offsetSet(mixed $offset, mixed $value)
{
$_SESSION[$key] = $value;
$_SESSION[$offset] = $value;
}

/**
Expand All @@ -161,9 +161,9 @@ public function offsetSet(mixed $key, mixed $value)
* @return void
*/
#[ReturnTypeWillChange]
public function offsetUnset(mixed $key)
public function offsetUnset(mixed $offset)
{
unset($_SESSION[$key]);
unset($_SESSION[$offset]);
}

/**
Expand Down
19 changes: 7 additions & 12 deletions src/Storage/ArrayStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,31 +85,26 @@ public function getRequestAccessTime()
* If the object is marked as isImmutable, or the object or key is marked as
* locked, raises an exception.
*
* @param string $key
* @param mixed $value
* @param array-key $offset
* @param mixed $value
* @return void
*/

/**
* @param mixed $key
* @param mixed $value
* @throws Exception\RuntimeException
*/
#[ReturnTypeWillChange]
public function offsetSet($key, $value)
public function offsetSet($offset, $value)
{
if ($this->isImmutable()) {
throw new Exception\RuntimeException(
sprintf('Cannot set key "%s" as storage is marked isImmutable', $key)
sprintf('Cannot set key "%s" as storage is marked isImmutable', $offset)
);
}
if ($this->isLocked($key)) {
if ($this->isLocked($offset)) {
throw new Exception\RuntimeException(
sprintf('Cannot set key "%s" due to locking', $key)
sprintf('Cannot set key "%s" due to locking', $offset)
);
}

parent::offsetSet($key, $value);
parent::offsetSet($offset, $value);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion test/SessionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ public function testRememberMeShouldSendNewSessionCookieWithUpdatedTimestamp():

self::assertTrue($found, 'No session cookie found: ' . var_export($headers, true));

self::assertIsString($cookie);
$ts = $this->getTimestampFromCookie($cookie);
if (! $ts) {
self::fail('Cookie did not contain expiry? ' . var_export($headers, true));
Expand All @@ -629,7 +630,7 @@ public function testRememberMeShouldSendNewSessionCookieWithUpdatedTimestamp():
self::assertGreaterThan(
$_SERVER['REQUEST_TIME'],
$ts->getTimestamp(),
'Session cookie: ' . var_export($headers, 1)
'Session cookie: ' . var_export($headers, true)
);
}

Expand Down Expand Up @@ -663,6 +664,7 @@ public function testRememberMeShouldSetTimestampBasedOnConfigurationByDefault():
}

self::assertTrue($found, 'No session cookie found: ' . var_export($headers, true));
self::assertIsString($cookie);

$ts = $this->getTimestampFromCookie($cookie);
if (! $ts) {
Expand Down
7 changes: 2 additions & 5 deletions test/TestAsset/TestSaveHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@
*/
class TestSaveHandler implements SaveHandler
{
/**
* @param string $savePath
* @param string $name
*/
#[ReturnTypeWillChange]
public function open($savePath, $name): void
public function open(string $path, string $name): bool
{
return true;
}

public function close(): bool
Expand Down
7 changes: 1 addition & 6 deletions test/TestAsset/TestSaveHandlerWithValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
*/
class TestSaveHandlerWithValidator implements SaveHandler
{
/**
* @param string $savePath
* @param string $name
* @return string
*/
public function open($savePath, $name): bool
public function open(string $path, string $name): bool
{
return true;
}
Expand Down

0 comments on commit 136c24e

Please sign in to comment.