Skip to content

Commit

Permalink
Remove dependency on Zend. Add ReturnTypeWillChange annotation to sup…
Browse files Browse the repository at this point in the history
…press warnings in PHP 8.2
  • Loading branch information
colinmollenhour committed Oct 3, 2023
1 parent ad2cfeb commit 4f10ca7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions app/code/community/Cm/RedisSession/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

class Cm_RedisSession_Model_Session implements \Zend_Session_SaveHandler_Interface
class Cm_RedisSession_Model_Session implements SessionHandlerInterface
{

const FLAG_READ_ONLY = 'cm-redissession-read-only';
Expand Down Expand Up @@ -96,12 +96,13 @@ public static function setStaticSaveHandler()
* @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
#[\ReturnTypeWillChange]
public function open($savePath, $sessionName)
{
try {
return $this->sessionHandler->open($savePath, $sessionName);
} catch (Throwable $e) {
$this->handleException($e);
throw $this->handleException($e);
}
}

Expand All @@ -111,6 +112,7 @@ public function open($savePath, $sessionName)
* @param string $sessionId
* @return string|bool
*/
#[\ReturnTypeWillChange]
public function read($sessionId)
{
try {
Expand All @@ -119,7 +121,7 @@ public function read($sessionId)
return $data;
} catch (Throwable $e) {
self::$failedLockAttempts = $this->sessionHandler->getFailedLockAttempts();
$this->handleException($e);
throw $this->handleException($e);
}
}

Expand All @@ -130,6 +132,7 @@ public function read($sessionId)
* @param string $sessionData
* @return boolean
*/
#[\ReturnTypeWillChange]
public function write($sessionId, $sessionData)
{
return $this->sessionHandler->write($sessionId, $sessionData);
Expand All @@ -141,6 +144,7 @@ public function write($sessionId, $sessionData)
* @param string $sessionId
* @return boolean
*/
#[\ReturnTypeWillChange]
public function destroy($sessionId)
{
return $this->sessionHandler->destroy($sessionId);
Expand All @@ -151,6 +155,7 @@ public function destroy($sessionId)
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function close()
{
return $this->sessionHandler->close();
Expand All @@ -162,14 +167,15 @@ public function close()
* @param int $maxLifeTime ignored
* @return boolean
*/
#[\ReturnTypeWillChange]
public function gc($maxLifeTime)
{
return $this->sessionHandler->gc($maxLifeTime);
}

/**
* @param Throwable $e
* @return void
* @return Throwable
*/
protected function handleException(Throwable $e)
{
Expand All @@ -185,6 +191,6 @@ protected function handleException(Throwable $e)
} else if ($this->dieOnError) {
Mage::printException($e);
}
throw $e;
return $e;
}
}

0 comments on commit 4f10ca7

Please sign in to comment.