Upgrade to 4.0.0

This commit is contained in:
Bastian Allgeier
2023-11-28 09:33:56 +01:00
parent f96b96af76
commit 3b0b6546ca
480 changed files with 21371 additions and 13327 deletions

View File

@@ -24,41 +24,31 @@ class Event
/**
* The full event name
* (e.g. `page.create:after`)
*
* @var string
*/
protected $name;
protected string $name;
/**
* The event type
* (e.g. `page` in `page.create:after`)
*
* @var string
*/
protected $type;
protected string $type;
/**
* The event action
* (e.g. `create` in `page.create:after`)
*
* @var string|null
*/
protected $action;
protected string|null $action;
/**
* The event state
* (e.g. `after` in `page.create:after`)
*
* @var string|null
*/
protected $state;
protected string|null $state;
/**
* The event arguments
*
* @var array
*/
protected $arguments = [];
protected array $arguments = [];
/**
* Class constructor
@@ -83,20 +73,15 @@ class Event
/**
* Magic caller for event arguments
*
* @param string $method
* @param array $arguments
* @return mixed
*/
public function __call(string $method, array $arguments = [])
public function __call(string $method, array $arguments = []): mixed
{
return $this->argument($method);
}
/**
* Improved `var_dump` output
*
* @return array
* @codeCoverageIgnore
*/
public function __debugInfo(): array
{
@@ -106,8 +91,6 @@ class Event
/**
* Makes it possible to simply echo
* or stringify the entire object
*
* @return string
*/
public function __toString(): string
{
@@ -117,8 +100,6 @@ class Event
/**
* Returns the action of the event (e.g. `create`)
* or `null` if the event name does not include an action
*
* @return string|null
*/
public function action(): string|null
{
@@ -127,19 +108,14 @@ class Event
/**
* Returns a specific event argument
*
* @param string $name
* @return mixed
*/
public function argument(string $name)
public function argument(string $name): mixed
{
return $this->arguments[$name] ?? null;
}
/**
* Returns the arguments of the event
*
* @return array
*/
public function arguments(): array
{
@@ -151,10 +127,8 @@ class Event
* the hook's return value
*
* @param object|null $bind Optional object to bind to the hook function
* @param \Closure $hook
* @return mixed
*/
public function call(object|null $bind, Closure $hook)
public function call(object|null $bind, Closure $hook): mixed
{
// collect the list of possible hook arguments
$data = $this->arguments();
@@ -167,8 +141,6 @@ class Event
/**
* Returns the full name of the event
*
* @return string
*/
public function name(): string
{
@@ -178,13 +150,16 @@ class Event
/**
* Returns the full list of possible wildcard
* event names based on the current event name
*
* @return array
*/
public function nameWildcards(): array
{
// if the event is already a wildcard event, no further variation is possible
if ($this->type === '*' || $this->action === '*' || $this->state === '*') {
// if the event is already a wildcard event,
// no further variation is possible
if (
$this->type === '*' ||
$this->action === '*' ||
$this->state === '*'
) {
return [];
}
@@ -228,8 +203,6 @@ class Event
/**
* Returns the state of the event (e.g. `after`)
*
* @return string|null
*/
public function state(): string|null
{
@@ -238,8 +211,6 @@ class Event
/**
* Returns the event data as array
*
* @return array
*/
public function toArray(): array
{
@@ -251,8 +222,6 @@ class Event
/**
* Returns the event name as string
*
* @return string
*/
public function toString(): string
{
@@ -261,8 +230,6 @@ class Event
/**
* Returns the type of the event (e.g. `page`)
*
* @return string
*/
public function type(): string
{
@@ -273,9 +240,6 @@ class Event
* Updates a given argument with a new value
*
* @internal
* @param string $name
* @param mixed $value
* @return void
* @throws \Kirby\Exception\InvalidArgumentException
*/
public function updateArgument(string $name, $value): void