Upgrade framework
This commit is contained in:
@@ -22,44 +22,30 @@ use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
|
||||
*/
|
||||
class MetadataBag implements SessionBagInterface
|
||||
{
|
||||
const CREATED = 'c';
|
||||
const UPDATED = 'u';
|
||||
const LIFETIME = 'l';
|
||||
public const CREATED = 'c';
|
||||
public const UPDATED = 'u';
|
||||
public const LIFETIME = 'l';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name = '__metadata';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $storageKey;
|
||||
private string $name = '__metadata';
|
||||
private string $storageKey;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $meta = array(self::CREATED => 0, self::UPDATED => 0, self::LIFETIME => 0);
|
||||
protected $meta = [self::CREATED => 0, self::UPDATED => 0, self::LIFETIME => 0];
|
||||
|
||||
/**
|
||||
* Unix timestamp.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $lastUsed;
|
||||
private int $lastUsed;
|
||||
|
||||
private int $updateThreshold;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $updateThreshold;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $storageKey The key used to store bag in the session
|
||||
* @param int $updateThreshold The time to wait between two UPDATED updates
|
||||
*/
|
||||
public function __construct($storageKey = '_sf2_meta', $updateThreshold = 0)
|
||||
public function __construct(string $storageKey = '_sf2_meta', int $updateThreshold = 0)
|
||||
{
|
||||
$this->storageKey = $storageKey;
|
||||
$this->updateThreshold = $updateThreshold;
|
||||
@@ -86,10 +72,8 @@ class MetadataBag implements SessionBagInterface
|
||||
|
||||
/**
|
||||
* Gets the lifetime that the session cookie was set with.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLifetime()
|
||||
public function getLifetime(): int
|
||||
{
|
||||
return $this->meta[self::LIFETIME];
|
||||
}
|
||||
@@ -102,7 +86,7 @@ class MetadataBag implements SessionBagInterface
|
||||
* to expire with browser session. Time is in seconds, and is
|
||||
* not a Unix timestamp.
|
||||
*/
|
||||
public function stampNew($lifetime = null)
|
||||
public function stampNew(int $lifetime = null)
|
||||
{
|
||||
$this->stampCreated($lifetime);
|
||||
}
|
||||
@@ -110,7 +94,7 @@ class MetadataBag implements SessionBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStorageKey()
|
||||
public function getStorageKey(): string
|
||||
{
|
||||
return $this->storageKey;
|
||||
}
|
||||
@@ -120,7 +104,7 @@ class MetadataBag implements SessionBagInterface
|
||||
*
|
||||
* @return int Unix timestamp
|
||||
*/
|
||||
public function getCreated()
|
||||
public function getCreated(): int
|
||||
{
|
||||
return $this->meta[self::CREATED];
|
||||
}
|
||||
@@ -130,7 +114,7 @@ class MetadataBag implements SessionBagInterface
|
||||
*
|
||||
* @return int Unix timestamp
|
||||
*/
|
||||
public function getLastUsed()
|
||||
public function getLastUsed(): int
|
||||
{
|
||||
return $this->lastUsed;
|
||||
}
|
||||
@@ -138,33 +122,32 @@ class MetadataBag implements SessionBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear()
|
||||
public function clear(): mixed
|
||||
{
|
||||
// nothing to do
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets name.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name)
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
private function stampCreated($lifetime = null)
|
||||
private function stampCreated(int $lifetime = null): void
|
||||
{
|
||||
$timeStamp = time();
|
||||
$this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp;
|
||||
$this->meta[self::LIFETIME] = (null === $lifetime) ? ini_get('session.cookie_lifetime') : $lifetime;
|
||||
$this->meta[self::LIFETIME] = $lifetime ?? (int) \ini_get('session.cookie_lifetime');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user