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

@@ -11,36 +11,30 @@
namespace Symfony\Component\EventDispatcher;
use Symfony\Contracts\EventDispatcher\Event;
/**
* Event encapsulation class.
*
* Encapsulates events thus decoupling the observer from the subject they encapsulate.
*
* @author Drak <drak@zikula.org>
*
* @implements \ArrayAccess<string, mixed>
* @implements \IteratorAggregate<string, mixed>
*/
class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
{
/**
* Event subject.
*
* @var mixed usually object or callable
*/
protected $subject;
/**
* Array of arguments.
*
* @var array
*/
protected $arguments;
/**
* Encapsulate an event with $subject and $args.
*
* @param mixed $subject The subject of the event, usually an object
* @param mixed $subject The subject of the event, usually an object or a callable
* @param array $arguments Arguments to store in the event
*/
public function __construct($subject = null, array $arguments = array())
public function __construct(mixed $subject = null, array $arguments = [])
{
$this->subject = $subject;
$this->arguments = $arguments;
@@ -48,10 +42,8 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
/**
* Getter for subject property.
*
* @return mixed $subject The observer subject
*/
public function getSubject()
public function getSubject(): mixed
{
return $this->subject;
}
@@ -59,13 +51,9 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
/**
* Get argument by key.
*
* @param string $key Key
*
* @return mixed Contents of array key
*
* @throws \InvalidArgumentException If key is not found.
* @throws \InvalidArgumentException if key is not found
*/
public function getArgument($key)
public function getArgument(string $key): mixed
{
if ($this->hasArgument($key)) {
return $this->arguments[$key];
@@ -77,12 +65,9 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
/**
* Add argument to event.
*
* @param string $key Argument name
* @param mixed $value Value
*
* @return $this
*/
public function setArgument($key, $value)
public function setArgument(string $key, mixed $value): static
{
$this->arguments[$key] = $value;
@@ -91,10 +76,8 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
/**
* Getter for all arguments.
*
* @return array
*/
public function getArguments()
public function getArguments(): array
{
return $this->arguments;
}
@@ -102,11 +85,9 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
/**
* Set args property.
*
* @param array $args Arguments
*
* @return $this
*/
public function setArguments(array $args = array())
public function setArguments(array $args = []): static
{
$this->arguments = $args;
@@ -115,14 +96,10 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
/**
* Has argument.
*
* @param string $key Key of arguments array
*
* @return bool
*/
public function hasArgument($key)
public function hasArgument(string $key): bool
{
return array_key_exists($key, $this->arguments);
return \array_key_exists($key, $this->arguments);
}
/**
@@ -130,11 +107,9 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
*
* @param string $key Array key
*
* @return mixed
*
* @throws \InvalidArgumentException If key does not exist in $this->args.
* @throws \InvalidArgumentException if key does not exist in $this->args
*/
public function offsetGet($key)
public function offsetGet(mixed $key): mixed
{
return $this->getArgument($key);
}
@@ -142,10 +117,9 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
/**
* ArrayAccess for argument setter.
*
* @param string $key Array key to set
* @param mixed $value Value
* @param string $key Array key to set
*/
public function offsetSet($key, $value)
public function offsetSet(mixed $key, mixed $value): void
{
$this->setArgument($key, $value);
}
@@ -155,7 +129,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
*
* @param string $key Array key
*/
public function offsetUnset($key)
public function offsetUnset(mixed $key): void
{
if ($this->hasArgument($key)) {
unset($this->arguments[$key]);
@@ -166,10 +140,8 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
* ArrayAccess has argument.
*
* @param string $key Array key
*
* @return bool
*/
public function offsetExists($key)
public function offsetExists(mixed $key): bool
{
return $this->hasArgument($key);
}
@@ -177,9 +149,9 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
/**
* IteratorAggregate for iterating over the object like an array.
*
* @return \ArrayIterator
* @return \ArrayIterator<string, mixed>
*/
public function getIterator()
public function getIterator(): \ArrayIterator
{
return new \ArrayIterator($this->arguments);
}