fix:更新已知bug,优化代码
This commit is contained in:
@@ -18,9 +18,9 @@ namespace Symfony\Component\HttpFoundation\Session\Flash;
|
||||
*/
|
||||
class FlashBag implements FlashBagInterface
|
||||
{
|
||||
private $name = 'flashes';
|
||||
private $flashes = [];
|
||||
private $storageKey;
|
||||
private string $name = 'flashes';
|
||||
private array $flashes = [];
|
||||
private string $storageKey;
|
||||
|
||||
/**
|
||||
* @param string $storageKey The key used to store flashes in the session
|
||||
@@ -33,7 +33,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function add(string $type, $message)
|
||||
public function add(string $type, mixed $message)
|
||||
{
|
||||
$this->flashes[$type][] = $message;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function peek(string $type, array $default = [])
|
||||
public function peek(string $type, array $default = []): array
|
||||
{
|
||||
return $this->has($type) ? $this->flashes[$type] : $default;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function peekAll()
|
||||
public function peekAll(): array
|
||||
{
|
||||
return $this->flashes;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get(string $type, array $default = [])
|
||||
public function get(string $type, array $default = []): array
|
||||
{
|
||||
if (!$this->has($type)) {
|
||||
return $default;
|
||||
@@ -94,7 +94,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function all()
|
||||
public function all(): array
|
||||
{
|
||||
$return = $this->peekAll();
|
||||
$this->flashes = [];
|
||||
@@ -105,7 +105,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set(string $type, $messages)
|
||||
public function set(string $type, string|array $messages)
|
||||
{
|
||||
$this->flashes[$type] = (array) $messages;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has(string $type)
|
||||
public function has(string $type): bool
|
||||
{
|
||||
return \array_key_exists($type, $this->flashes) && $this->flashes[$type];
|
||||
}
|
||||
@@ -129,7 +129,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function keys()
|
||||
public function keys(): array
|
||||
{
|
||||
return array_keys($this->flashes);
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStorageKey()
|
||||
public function getStorageKey(): string
|
||||
{
|
||||
return $this->storageKey;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear()
|
||||
public function clear(): mixed
|
||||
{
|
||||
return $this->all();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user