fix:更新已知bug,优化代码
This commit is contained in:
@@ -18,8 +18,8 @@ namespace Symfony\Component\HttpFoundation\Session\Attribute;
|
||||
*/
|
||||
class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Countable
|
||||
{
|
||||
private $name = 'attributes';
|
||||
private $storageKey;
|
||||
private string $name = 'attributes';
|
||||
private string $storageKey;
|
||||
|
||||
protected $attributes = [];
|
||||
|
||||
@@ -34,7 +34,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStorageKey()
|
||||
public function getStorageKey(): string
|
||||
{
|
||||
return $this->storageKey;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has(string $name)
|
||||
public function has(string $name): bool
|
||||
{
|
||||
return \array_key_exists($name, $this->attributes);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get(string $name, $default = null)
|
||||
public function get(string $name, mixed $default = null): mixed
|
||||
{
|
||||
return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set(string $name, $value)
|
||||
public function set(string $name, mixed $value)
|
||||
{
|
||||
$this->attributes[$name] = $value;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function all()
|
||||
public function all(): array
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function remove(string $name)
|
||||
public function remove(string $name): mixed
|
||||
{
|
||||
$retval = null;
|
||||
if (\array_key_exists($name, $this->attributes)) {
|
||||
@@ -120,7 +120,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear()
|
||||
public function clear(): mixed
|
||||
{
|
||||
$return = $this->attributes;
|
||||
$this->attributes = [];
|
||||
@@ -133,19 +133,15 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
*
|
||||
* @return \ArrayIterator<string, mixed>
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
public function getIterator(): \ArrayIterator
|
||||
{
|
||||
return new \ArrayIterator($this->attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of attributes.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return \count($this->attributes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user