Upgrade framework

This commit is contained in:
2023-11-14 16:54:35 +01:00
parent 1648a5cd42
commit 4fcf6fffcc
10548 changed files with 693138 additions and 466698 deletions

View File

@@ -18,28 +18,14 @@ namespace Symfony\Component\HttpFoundation\Session\Flash;
*/
class AutoExpireFlashBag implements FlashBagInterface
{
private $name = 'flashes';
private string $name = 'flashes';
private array $flashes = ['display' => [], 'new' => []];
private string $storageKey;
/**
* Flash messages.
*
* @var array
*/
private $flashes = array('display' => array(), 'new' => array());
/**
* The storage key for flashes in the session.
*
* @var string
*/
private $storageKey;
/**
* Constructor.
*
* @param string $storageKey The key used to store flashes in the session
*/
public function __construct($storageKey = '_sf2_flashes')
public function __construct(string $storageKey = '_symfony_flashes')
{
$this->storageKey = $storageKey;
}
@@ -47,12 +33,12 @@ class AutoExpireFlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return $this->name;
}
public function setName($name)
public function setName(string $name)
{
$this->name = $name;
}
@@ -67,14 +53,14 @@ class AutoExpireFlashBag implements FlashBagInterface
// The logic: messages from the last request will be stored in new, so we move them to previous
// This request we will show what is in 'display'. What is placed into 'new' this time round will
// be moved to display next time round.
$this->flashes['display'] = array_key_exists('new', $this->flashes) ? $this->flashes['new'] : array();
$this->flashes['new'] = array();
$this->flashes['display'] = \array_key_exists('new', $this->flashes) ? $this->flashes['new'] : [];
$this->flashes['new'] = [];
}
/**
* {@inheritdoc}
*/
public function add($type, $message)
public function add(string $type, mixed $message)
{
$this->flashes['new'][$type][] = $message;
}
@@ -82,7 +68,7 @@ class AutoExpireFlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function peek($type, array $default = array())
public function peek(string $type, array $default = []): array
{
return $this->has($type) ? $this->flashes['display'][$type] : $default;
}
@@ -90,15 +76,15 @@ class AutoExpireFlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function peekAll()
public function peekAll(): array
{
return array_key_exists('display', $this->flashes) ? (array) $this->flashes['display'] : array();
return \array_key_exists('display', $this->flashes) ? $this->flashes['display'] : [];
}
/**
* {@inheritdoc}
*/
public function get($type, array $default = array())
public function get(string $type, array $default = []): array
{
$return = $default;
@@ -117,10 +103,10 @@ class AutoExpireFlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function all()
public function all(): array
{
$return = $this->flashes['display'];
$this->flashes = array('new' => array(), 'display' => array());
$this->flashes['display'] = [];
return $return;
}
@@ -136,7 +122,7 @@ class AutoExpireFlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function set($type, $messages)
public function set(string $type, string|array $messages)
{
$this->flashes['new'][$type] = (array) $messages;
}
@@ -144,15 +130,15 @@ class AutoExpireFlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function has($type)
public function has(string $type): bool
{
return array_key_exists($type, $this->flashes['display']) && $this->flashes['display'][$type];
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']);
}
@@ -160,7 +146,7 @@ class AutoExpireFlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function getStorageKey()
public function getStorageKey(): string
{
return $this->storageKey;
}
@@ -168,7 +154,7 @@ class AutoExpireFlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function clear()
public function clear(): mixed
{
return $this->all();
}

View File

@@ -18,28 +18,14 @@ namespace Symfony\Component\HttpFoundation\Session\Flash;
*/
class FlashBag implements FlashBagInterface
{
private $name = 'flashes';
private string $name = 'flashes';
private array $flashes = [];
private string $storageKey;
/**
* Flash messages.
*
* @var array
*/
private $flashes = array();
/**
* The storage key for flashes in the session.
*
* @var string
*/
private $storageKey;
/**
* Constructor.
*
* @param string $storageKey The key used to store flashes in the session
*/
public function __construct($storageKey = '_sf2_flashes')
public function __construct(string $storageKey = '_symfony_flashes')
{
$this->storageKey = $storageKey;
}
@@ -47,12 +33,12 @@ class FlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return $this->name;
}
public function setName($name)
public function setName(string $name)
{
$this->name = $name;
}
@@ -68,7 +54,7 @@ class FlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function add($type, $message)
public function add(string $type, mixed $message)
{
$this->flashes[$type][] = $message;
}
@@ -76,7 +62,7 @@ class FlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function peek($type, array $default = array())
public function peek(string $type, array $default = []): array
{
return $this->has($type) ? $this->flashes[$type] : $default;
}
@@ -84,7 +70,7 @@ class FlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function peekAll()
public function peekAll(): array
{
return $this->flashes;
}
@@ -92,7 +78,7 @@ class FlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function get($type, array $default = array())
public function get(string $type, array $default = []): array
{
if (!$this->has($type)) {
return $default;
@@ -108,10 +94,10 @@ class FlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function all()
public function all(): array
{
$return = $this->peekAll();
$this->flashes = array();
$this->flashes = [];
return $return;
}
@@ -119,7 +105,7 @@ class FlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function set($type, $messages)
public function set(string $type, string|array $messages)
{
$this->flashes[$type] = (array) $messages;
}
@@ -135,15 +121,15 @@ class FlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function has($type)
public function has(string $type): bool
{
return array_key_exists($type, $this->flashes) && $this->flashes[$type];
return \array_key_exists($type, $this->flashes) && $this->flashes[$type];
}
/**
* {@inheritdoc}
*/
public function keys()
public function keys(): array
{
return array_keys($this->flashes);
}
@@ -151,7 +137,7 @@ class FlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function getStorageKey()
public function getStorageKey(): string
{
return $this->storageKey;
}
@@ -159,7 +145,7 @@ class FlashBag implements FlashBagInterface
/**
* {@inheritdoc}
*/
public function clear()
public function clear(): mixed
{
return $this->all();
}

View File

@@ -21,75 +21,52 @@ use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
interface FlashBagInterface extends SessionBagInterface
{
/**
* Adds a flash message for type.
*
* @param string $type
* @param string $message
* Adds a flash message for the given type.
*/
public function add($type, $message);
public function add(string $type, mixed $message);
/**
* Registers a message for a given type.
*
* @param string $type
* @param string|array $message
* Registers one or more messages for a given type.
*/
public function set($type, $message);
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($type, array $default = array());
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 string $type
* @param array $default Default value if $type does not exist
*
* @return array
* @param array $default Default value if $type does not exist
*/
public function get($type, array $default = array());
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.
*
* @param array $messages
*/
public function setAll(array $messages);
/**
* Has flash messages for a given type?
*
* @param string $type
*
* @return bool
*/
public function has($type);
public function has(string $type): bool;
/**
* Returns a list of all defined types.
*
* @return array
*/
public function keys();
public function keys(): array;
}