package and depencies

This commit is contained in:
RafficMohammed
2023-01-08 02:57:24 +05:30
parent d5332eb421
commit 1d54b8bc7f
4309 changed files with 193331 additions and 172289 deletions

View File

@@ -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
@@ -30,10 +30,7 @@ class AutoExpireFlashBag implements FlashBagInterface
$this->storageKey = $storageKey;
}
/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return $this->name;
}
@@ -43,9 +40,6 @@ class AutoExpireFlashBag implements FlashBagInterface
$this->name = $name;
}
/**
* {@inheritdoc}
*/
public function initialize(array &$flashes)
{
$this->flashes = &$flashes;
@@ -57,34 +51,22 @@ class AutoExpireFlashBag implements FlashBagInterface
$this->flashes['new'] = [];
}
/**
* {@inheritdoc}
*/
public function add(string $type, $message)
public function add(string $type, mixed $message)
{
$this->flashes['new'][$type][] = $message;
}
/**
* {@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;
}
/**
* {@inheritdoc}
*/
public function peekAll()
public function peekAll(): array
{
return \array_key_exists('display', $this->flashes) ? $this->flashes['display'] : [];
}
/**
* {@inheritdoc}
*/
public function get(string $type, array $default = [])
public function get(string $type, array $default = []): array
{
$return = $default;
@@ -100,10 +82,7 @@ class AutoExpireFlashBag implements FlashBagInterface
return $return;
}
/**
* {@inheritdoc}
*/
public function all()
public function all(): array
{
$return = $this->flashes['display'];
$this->flashes['display'] = [];
@@ -111,50 +90,32 @@ class AutoExpireFlashBag implements FlashBagInterface
return $return;
}
/**
* {@inheritdoc}
*/
public function setAll(array $messages)
{
$this->flashes['new'] = $messages;
}
/**
* {@inheritdoc}
*/
public function set(string $type, $messages)
public function set(string $type, string|array $messages)
{
$this->flashes['new'][$type] = (array) $messages;
}
/**
* {@inheritdoc}
*/
public function has(string $type)
public function has(string $type): bool
{
return \array_key_exists($type, $this->flashes['display']) && $this->flashes['display'][$type];
}
/**
* {@inheritdoc}
*/
public function keys()
public function keys(): array
{
return array_keys($this->flashes['display']);
}
/**
* {@inheritdoc}
*/
public function getStorageKey()
public function getStorageKey(): string
{
return $this->storageKey;
}
/**
* {@inheritdoc}
*/
public function clear()
public function clear(): mixed
{
return $this->all();
}

View File

@@ -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
@@ -30,10 +30,7 @@ class FlashBag implements FlashBagInterface
$this->storageKey = $storageKey;
}
/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return $this->name;
}
@@ -43,42 +40,27 @@ class FlashBag implements FlashBagInterface
$this->name = $name;
}
/**
* {@inheritdoc}
*/
public function initialize(array &$flashes)
{
$this->flashes = &$flashes;
}
/**
* {@inheritdoc}
*/
public function add(string $type, $message)
public function add(string $type, mixed $message)
{
$this->flashes[$type][] = $message;
}
/**
* {@inheritdoc}
*/
public function peek(string $type, array $default = [])
public function peek(string $type, array $default = []): array
{
return $this->has($type) ? $this->flashes[$type] : $default;
}
/**
* {@inheritdoc}
*/
public function peekAll()
public function peekAll(): array
{
return $this->flashes;
}
/**
* {@inheritdoc}
*/
public function get(string $type, array $default = [])
public function get(string $type, array $default = []): array
{
if (!$this->has($type)) {
return $default;
@@ -91,10 +73,7 @@ class FlashBag implements FlashBagInterface
return $return;
}
/**
* {@inheritdoc}
*/
public function all()
public function all(): array
{
$return = $this->peekAll();
$this->flashes = [];
@@ -102,50 +81,32 @@ class FlashBag implements FlashBagInterface
return $return;
}
/**
* {@inheritdoc}
*/
public function set(string $type, $messages)
public function set(string $type, string|array $messages)
{
$this->flashes[$type] = (array) $messages;
}
/**
* {@inheritdoc}
*/
public function setAll(array $messages)
{
$this->flashes = $messages;
}
/**
* {@inheritdoc}
*/
public function has(string $type)
public function has(string $type): bool
{
return \array_key_exists($type, $this->flashes) && $this->flashes[$type];
}
/**
* {@inheritdoc}
*/
public function keys()
public function keys(): array
{
return array_keys($this->flashes);
}
/**
* {@inheritdoc}
*/
public function getStorageKey()
public function getStorageKey(): string
{
return $this->storageKey;
}
/**
* {@inheritdoc}
*/
public function clear()
public function clear(): mixed
{
return $this->all();
}

View File

@@ -22,50 +22,38 @@ interface FlashBagInterface extends SessionBagInterface
{
/**
* Adds a flash message for the given type.
*
* @param mixed $message
*/
public function add(string $type, $message);
public function add(string $type, mixed $message);
/**
* Registers one or more messages for a given type.
*
* @param string|array $messages
*/
public function set(string $type, $messages);
public function set(string $type, string|array $messages);
/**
* Gets flash messages for a given type.
*
* @param string $type Message category type
* @param array $default Default value if $type does not exist
*
* @return array
*/
public function peek(string $type, array $default = []);
public function peek(string $type, array $default = []): array;
/**
* Gets all flash messages.
*
* @return array
*/
public function peekAll();
public function peekAll(): array;
/**
* Gets and clears flash from the stack.
*
* @param array $default Default value if $type does not exist
*
* @return array
*/
public function get(string $type, array $default = []);
public function get(string $type, array $default = []): array;
/**
* Gets and clears flashes from the stack.
*
* @return array
*/
public function all();
public function all(): array;
/**
* Sets all flash messages.
@@ -74,15 +62,11 @@ interface FlashBagInterface extends SessionBagInterface
/**
* Has flash messages for a given type?
*
* @return bool
*/
public function has(string $type);
public function has(string $type): bool;
/**
* Returns a list of all defined types.
*
* @return array
*/
public function keys();
public function keys(): array;
}