Skip to content

Commit

Permalink
[storage] improvement: use null coalescing operator
Browse files Browse the repository at this point in the history
  • Loading branch information
connorhu committed Apr 9, 2024
1 parent c90af2c commit 1c5e9e7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
8 changes: 1 addition & 7 deletions lib/storage/sfCacheSessionStorage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,7 @@ public function write($key, $data)
*/
public function read($key)
{
$retval = null;

if (isset($this->data[$key])) {
$retval = &$this->data[$key];
}

return $retval;
return $this->data[$key] ?? null;
}

/**
Expand Down
8 changes: 1 addition & 7 deletions lib/storage/sfSessionStorage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,7 @@ public function initialize($options = null)
*/
public function read($key)
{
$retval = null;

if (isset($_SESSION[$key])) {
$retval = $_SESSION[$key];
}

return $retval;
return $_SESSION[$key] ?? null;
}

/**
Expand Down
8 changes: 1 addition & 7 deletions lib/storage/sfSessionTestStorage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,7 @@ public function getSessionId()
*/
public function read($key)
{
$retval = null;

if (isset($this->sessionData[$key])) {
$retval = $this->sessionData[$key];
}

return $retval;
return $this->sessionData[$key] ?? null;
}

/**
Expand Down

0 comments on commit 1c5e9e7

Please sign in to comment.