protected function recycleTokens()
    {
        if (!$this->expire_old) {
            // This is turned off.
            return $this;
        }

        if ($this->useNativeSession) {
            /** @var array<string, array<string, string|int>> $sess */
            $sess =& $_SESSION[$this->sessionIndex];
        } else {
            /** @var array<string, array<string, string|int>> $sess */
            $sess =& $this->session[$this->sessionIndex];
        }
        // Sort by creation time
        \uasort(
            $sess,
            function (array $a, array $b): int {
                return (int) ($a['created'] <=> $b['created']);
            }
        );
        while (\count($sess) > $this->recycle_after) {
            // Let's knock off the oldest one
            \array_shift($sess);
        }
        return $this;
    }
protected function recycleTokens()
    {
        if (!$this->expire_old) {
            // This is turned off.
            return $this;
        }

        if ($this->useNativeSession) {
            /** @var array<string, array<string, string|int>> $sess */
            $sess =& $_SESSION[$this->sessionIndex];
        } else {
            /** @var array<string, array<string, string|int>> $sess */
            $sess =& $this->session[$this->sessionIndex];
        }
        // Sort by creation time
        \uasort(
            $sess,
            function (array $a, array $b): int {
                return (int) ($a['created'] <=> $b['created']);
            }
        );
        while (\count($sess) > $this->recycle_after) {
            // Let's knock off the oldest one
            \array_shift($sess);
        }
        return $this;
    }
protected function recycleTokens ( ) { if ( ! $ this -> expire_old ) { // This is turned off. return $ this ; } if ( $ this -> useNativeSession ) { /** @var array<string, array<string, string|int>> $sess */ $ sess = & $ _SESSION [ $ this -> sessionIndex ] ; } else { /** @var array<string, array<string, string|int>> $sess */ $ sess = & $ this -> session [ $ this -> sessionIndex ] ; } // Sort by creation time \ uasort ( $ sess , function ( array $ a , array $ b ) : int { return ( int ) ( $ a [ 'created' ] <=> $ b [ 'created' ] ) ; } ) ; while ( \ count ( $ sess ) > $ this -> recycle_after ) { // Let's knock off the oldest one \ array_shift ( $ sess ) ; } return $ this ; }
Enforce an upper limit on the number of tokens stored in session state
by removing the oldest tokens first.

@return self
Enforce an upper limit on the number of tokens stored in session state by removing the oldest tokens first .