Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
fix : php 8.1 compatibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ipranjal committed Jul 22, 2022
1 parent 03abdca commit ae1e3ae
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
Binary file modified .DS_Store
Binary file not shown.
31 changes: 15 additions & 16 deletions src/Adapters/Session/DatabaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
use Scrawler\Scrawler;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler;

Class DatabaseHandler extends AbstractSessionHandler
class DatabaseHandler extends AbstractSessionHandler
{
/**
* Store Database instance
*
* @var \Scrawler\Service\Database
*/
*/
private $db;

/**
Expand All @@ -27,13 +27,15 @@
private $gcCalled = false;


public function __construct() {
public function __construct()
{
$this->db = Scrawler::engine()->db();
}

protected function doWrite($sessionId, $data) {
protected function doWrite(string $sessionId, string $data):bool
{
$maxlifetime = (int) ini_get('session.gc_maxlifetime');
$session = $this->db->findOne('session', 'sessionid LIKE ?', [$sessionId]);
$session = $this->db->findOne('session', 'sessionid LIKE ?', [$sessionId]);
if ($session == null) {
$session = $this->db->create('session');
}
Expand All @@ -44,32 +46,34 @@ protected function doWrite($sessionId, $data) {
return true;
}

protected function doRead($sessionId) {
protected function doRead(string $sessionId):string
{
$session = $this->db->findOne('session', 'sessionid = ? AND session_expire > ?', [$sessionId, time()]);
if ($session == null) {
return '';
}
return $session->session_data;
}

protected function doDestroy($sessionId) {
protected function doDestroy(string $sessionId):bool
{
$session = $this->db->findOne('session', 'sessionid LIKE ?', [$sessionId]);
$this->db->delete($session);
return true;
}

public function updateTimestamp($sessionId, $data) {
public function updateTimestamp(string $sessionId, string $data):bool
{
return true;
}

public function gc($maxlifetime)
public function gc(int $maxlifetime): int|false
{

$this->gcCalled = true;
return true;
}

public function close()
public function close():bool
{
if ($this->gcCalled) {
$this->gcCalled = false;
Expand All @@ -79,9 +83,4 @@ public function close()
}
return true;
}


}



2 changes: 1 addition & 1 deletion src/Service/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __call($name, $arguments)
return $this->toolbox->load($arguments[0], $arguments[1]);
}
if (count($arguments) == 1) {
return $this->finder->find($arguments[0], null, []);
return $this->finder->find($arguments[0], '', []);
}
}
return R::__callStatic($name, $arguments);
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Http/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __get($key)
* @param string $key
* @return bool
*/
public function has($key)
public function has(string $key):bool
{
if (parent::has($key) || parent::getFlashBag()->has($key)) {
return true;
Expand Down
Binary file added tests/.DS_Store
Binary file not shown.
Binary file added tests/app/.DS_Store
Binary file not shown.

0 comments on commit ae1e3ae

Please sign in to comment.