fix:更新已知bug,优化代码
This commit is contained in:
@@ -18,9 +18,9 @@ namespace Symfony\Component\HttpFoundation\Session\Flash;
|
||||
*/
|
||||
class AutoExpireFlashBag implements FlashBagInterface
|
||||
{
|
||||
private $name = 'flashes';
|
||||
private $flashes = ['display' => [], 'new' => []];
|
||||
private $storageKey;
|
||||
private string $name = 'flashes';
|
||||
private array $flashes = ['display' => [], 'new' => []];
|
||||
private string $storageKey;
|
||||
|
||||
/**
|
||||
* @param string $storageKey The key used to store flashes in the session
|
||||
@@ -33,7 +33,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function add(string $type, $message)
|
||||
public function add(string $type, mixed $message)
|
||||
{
|
||||
$this->flashes['new'][$type][] = $message;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function peek(string $type, array $default = [])
|
||||
public function peek(string $type, array $default = []): array
|
||||
{
|
||||
return $this->has($type) ? $this->flashes['display'][$type] : $default;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function peekAll()
|
||||
public function peekAll(): array
|
||||
{
|
||||
return \array_key_exists('display', $this->flashes) ? $this->flashes['display'] : [];
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get(string $type, array $default = [])
|
||||
public function get(string $type, array $default = []): array
|
||||
{
|
||||
$return = $default;
|
||||
|
||||
@@ -103,7 +103,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function all()
|
||||
public function all(): array
|
||||
{
|
||||
$return = $this->flashes['display'];
|
||||
$this->flashes['display'] = [];
|
||||
@@ -122,7 +122,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set(string $type, $messages)
|
||||
public function set(string $type, string|array $messages)
|
||||
{
|
||||
$this->flashes['new'][$type] = (array) $messages;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has(string $type)
|
||||
public function has(string $type): bool
|
||||
{
|
||||
return \array_key_exists($type, $this->flashes['display']) && $this->flashes['display'][$type];
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function keys()
|
||||
public function keys(): array
|
||||
{
|
||||
return array_keys($this->flashes['display']);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStorageKey()
|
||||
public function getStorageKey(): string
|
||||
{
|
||||
return $this->storageKey;
|
||||
}
|
||||
@@ -154,7 +154,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear()
|
||||
public function clear(): mixed
|
||||
{
|
||||
return $this->all();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user