Skip to content

Commit

Permalink
updates gettting the methods to match php7
Browse files Browse the repository at this point in the history
  • Loading branch information
detain committed Feb 17, 2023
1 parent 812fbe7 commit b81e76f
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/Memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Memcached implements \SessionHandlerInterface, \SessionIdInterface, \Sessi
/**
* @var string The namespace prefix to prepend to session IDs
*/
protected $prefix;
protected $prefix = '';

/**
* Create new memcached session save handler
Expand All @@ -32,7 +32,8 @@ public function __construct(\Memcached $memcached, string $prefix = 'sess-')
* @param string $name
* @return boolean
*/
public function open(string $path, string $name): bool
//public function open(string $path, string $name): bool
public function open($path, $name)
{
// Note: session save path is not used
$this->sessionName = $name;
Expand All @@ -58,7 +59,8 @@ public function close(): bool
* @return string|false
*/
#[\ReturnTypeWillChange]
public function read(string $id) //: string|false
public function read($id) //: string|false
//public function read(string $id) //: string|false
{
$_SESSION = json_decode((string) $this->memcached->get($this->prefix . $id), true);
if (isset($_SESSION) && !empty($_SESSION) && $_SESSION != null) {
Expand All @@ -74,7 +76,8 @@ public function read(string $id) //: string|false
* @param string $data
* @return boolean
*/
public function write(string $id, string $data): bool
public function write($id, $data)
//public function write(string $id, string $data): bool
{
// note: $data is not used as it has already been serialised by PHP,
// so we use $_SESSION which is an unserialised version of $data.
Expand All @@ -88,7 +91,8 @@ public function write(string $id, string $data): bool
* @param string $id
* @return boolean
*/
public function destroy(string $id): bool
public function destroy($id)
//public function destroy(string $id): bool
{
return (bool) $this->memcached->delete($this->prefix . $id);
}
Expand All @@ -100,7 +104,8 @@ public function destroy(string $id): bool
* @return int|false true successs false failure?
*/
#[\ReturnTypeWillChange]
public function gc(int $max_lifetime) //: int|false
public function gc($max_lifetime) //: int|false
//public function gc(int $max_lifetime) //: int|false
{
// let memcached handle this with expiration time
$this->expire = $max_lifetime;
Expand All @@ -112,7 +117,8 @@ public function gc(int $max_lifetime) //: int|false
*
* @return string
*/
public function create_sid(): string
public function create_sid()
//public function create_sid(): string
{
// available since PHP 5.5.1
// invoked internally when a new session id is needed
Expand All @@ -131,7 +137,8 @@ public function create_sid(): string
* @param string $data
* @return bool
*/
public function updateTimestamp(string $id, string $data): bool
public function updateTimestamp($id, $data)
//public function updateTimestamp(string $id, string $data): bool
{
// implements SessionUpdateTimestampHandlerInterface::validateId()
// available since PHP 7.0
Expand All @@ -145,7 +152,8 @@ public function updateTimestamp(string $id, string $data): bool
* @param string $id
* @return bool
*/
public function validateId(string $id): bool
public function validateId($id)
//public function validateId(string $id): bool
{
// implements SessionUpdateTimestampHandlerInterface::validateId()
// available since PHP 7.0
Expand Down

0 comments on commit b81e76f

Please sign in to comment.