update lock clucknut
All checks were successful
All checks were successful
This commit is contained in:
11
vendor/doctrine/event-manager/composer.json
vendored
11
vendor/doctrine/event-manager/composer.json
vendored
@@ -41,10 +41,10 @@
|
||||
"php": "^8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^12",
|
||||
"phpstan/phpstan": "^1.8.8",
|
||||
"phpunit/phpunit": "^10.5",
|
||||
"vimeo/psalm": "^5.24"
|
||||
"doctrine/coding-standard": "^14",
|
||||
"phpdocumentor/guides-cli": "^1.4",
|
||||
"phpstan/phpstan": "^2.1.32",
|
||||
"phpunit/phpunit": "^10.5.58"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/common": "<2.9"
|
||||
@@ -64,5 +64,8 @@
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
},
|
||||
"sort-packages": true
|
||||
},
|
||||
"scripts": {
|
||||
"docs": "composer --working-dir docs update && ./docs/vendor/bin/build-docs.sh @additional_args"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<files psalm-version="5.24.0@462c80e31c34e58cc4f750c656be3927e80e550e">
|
||||
<file src="src/EventManager.php">
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[empty($this->listeners[$event])]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
</files>
|
||||
24
vendor/doctrine/event-manager/src/EventDispatcher.php
vendored
Normal file
24
vendor/doctrine/event-manager/src/EventDispatcher.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common;
|
||||
|
||||
/**
|
||||
* Interface for event dispatching.
|
||||
*
|
||||
* This minimal interface is suitable for type-hinting in code that only needs
|
||||
* to dispatch events without configuring listeners.
|
||||
*/
|
||||
interface EventDispatcher
|
||||
{
|
||||
/**
|
||||
* Dispatches an event to all registered listeners.
|
||||
*
|
||||
* @param string $eventName The name of the event to dispatch. The name of the event is
|
||||
* the name of the method that is invoked on listeners.
|
||||
* @param EventArgs|null $eventArgs The event arguments to pass to the event handlers/listeners.
|
||||
* If not supplied, the single empty EventArgs instance is used.
|
||||
*/
|
||||
public function dispatchEvent(string $eventName, EventArgs|null $eventArgs = null): void;
|
||||
}
|
||||
34
vendor/doctrine/event-manager/src/EventListenerIntrospector.php
vendored
Normal file
34
vendor/doctrine/event-manager/src/EventListenerIntrospector.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common;
|
||||
|
||||
/**
|
||||
* Interface for introspecting event listeners.
|
||||
*
|
||||
* Provides methods to query registered listeners without modifying them.
|
||||
*/
|
||||
interface EventListenerIntrospector extends EventDispatcher
|
||||
{
|
||||
/**
|
||||
* Gets the listeners of a specific event.
|
||||
*
|
||||
* @param string $event The name of the event.
|
||||
*
|
||||
* @return object[]
|
||||
*/
|
||||
public function getListeners(string $event): array;
|
||||
|
||||
/**
|
||||
* Gets all listeners keyed by event name.
|
||||
*
|
||||
* @return array<string, object[]>
|
||||
*/
|
||||
public function getAllListeners(): array;
|
||||
|
||||
/**
|
||||
* Checks whether an event has any registered listeners.
|
||||
*/
|
||||
public function hasListeners(string $event): bool;
|
||||
}
|
||||
26
vendor/doctrine/event-manager/src/EventListenerRegistry.php
vendored
Normal file
26
vendor/doctrine/event-manager/src/EventListenerRegistry.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common;
|
||||
|
||||
/**
|
||||
* Interface for registering and unregistering event listeners.
|
||||
*/
|
||||
interface EventListenerRegistry extends EventDispatcher
|
||||
{
|
||||
/**
|
||||
* Adds an event listener that listens on the specified events.
|
||||
*
|
||||
* @param string|string[] $events The event(s) to listen on.
|
||||
* @param object $listener The listener object.
|
||||
*/
|
||||
public function addEventListener(string|array $events, object $listener): void;
|
||||
|
||||
/**
|
||||
* Removes an event listener from the specified events.
|
||||
*
|
||||
* @param string|string[] $events
|
||||
*/
|
||||
public function removeEventListener(string|array $events, object $listener): void;
|
||||
}
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
namespace Doctrine\Common;
|
||||
|
||||
use function spl_object_hash;
|
||||
use function spl_object_id;
|
||||
|
||||
/**
|
||||
* The EventManager is the central point of Doctrine's event listener system.
|
||||
* Listeners are registered on the manager and events are dispatched through the
|
||||
* manager.
|
||||
*/
|
||||
class EventManager
|
||||
class EventManager implements EventManagerInterface
|
||||
{
|
||||
/**
|
||||
* Map of registered listeners.
|
||||
@@ -21,14 +21,7 @@ class EventManager
|
||||
*/
|
||||
private array $listeners = [];
|
||||
|
||||
/**
|
||||
* Dispatches an event to all registered listeners.
|
||||
*
|
||||
* @param string $eventName The name of the event to dispatch. The name of the event is
|
||||
* the name of the method that is invoked on listeners.
|
||||
* @param EventArgs|null $eventArgs The event arguments to pass to the event handlers/listeners.
|
||||
* If not supplied, the single empty EventArgs instance is used.
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
public function dispatchEvent(string $eventName, EventArgs|null $eventArgs = null): void
|
||||
{
|
||||
if (! isset($this->listeners[$eventName])) {
|
||||
@@ -42,86 +35,55 @@ public function dispatchEvent(string $eventName, EventArgs|null $eventArgs = nul
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the listeners of a specific event.
|
||||
*
|
||||
* @param string $event The name of the event.
|
||||
*
|
||||
* @return object[]
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
public function getListeners(string $event): array
|
||||
{
|
||||
return $this->listeners[$event] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all listeners keyed by event name.
|
||||
*
|
||||
* @return array<string, object[]> The event listeners for the specified event, or all event listeners.
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
public function getAllListeners(): array
|
||||
{
|
||||
return $this->listeners;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether an event has any registered listeners.
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
public function hasListeners(string $event): bool
|
||||
{
|
||||
return ! empty($this->listeners[$event]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an event listener that listens on the specified events.
|
||||
*
|
||||
* @param string|string[] $events The event(s) to listen on.
|
||||
* @param object $listener The listener object.
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
public function addEventListener(string|array $events, object $listener): void
|
||||
{
|
||||
// Picks the hash code related to that listener
|
||||
$hash = spl_object_hash($listener);
|
||||
$oid = spl_object_id($listener);
|
||||
|
||||
foreach ((array) $events as $event) {
|
||||
// Overrides listener if a previous one was associated already
|
||||
// Prevents duplicate listeners on same event (same instance only)
|
||||
$this->listeners[$event][$hash] = $listener;
|
||||
$this->listeners[$event][$oid] = $listener;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an event listener from the specified events.
|
||||
*
|
||||
* @param string|string[] $events
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
public function removeEventListener(string|array $events, object $listener): void
|
||||
{
|
||||
// Picks the hash code related to that listener
|
||||
$hash = spl_object_hash($listener);
|
||||
$oid = spl_object_id($listener);
|
||||
|
||||
foreach ((array) $events as $event) {
|
||||
unset($this->listeners[$event][$hash]);
|
||||
unset($this->listeners[$event][$oid]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an EventSubscriber.
|
||||
*
|
||||
* The subscriber is asked for all the events it is interested in and added
|
||||
* as a listener for these events.
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
public function addEventSubscriber(EventSubscriber $subscriber): void
|
||||
{
|
||||
$this->addEventListener($subscriber->getSubscribedEvents(), $subscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an EventSubscriber.
|
||||
*
|
||||
* The subscriber is asked for all the events it is interested in and removed
|
||||
* as a listener for these events.
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
public function removeEventSubscriber(EventSubscriber $subscriber): void
|
||||
{
|
||||
$this->removeEventListener($subscriber->getSubscribedEvents(), $subscriber);
|
||||
|
||||
13
vendor/doctrine/event-manager/src/EventManagerInterface.php
vendored
Normal file
13
vendor/doctrine/event-manager/src/EventManagerInterface.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common;
|
||||
|
||||
/** Provided for convenience, but consider using the individual interfaces directly. */
|
||||
interface EventManagerInterface extends
|
||||
EventListenerIntrospector,
|
||||
EventListenerRegistry,
|
||||
EventSubscriberRegistry
|
||||
{
|
||||
}
|
||||
27
vendor/doctrine/event-manager/src/EventSubscriberRegistry.php
vendored
Normal file
27
vendor/doctrine/event-manager/src/EventSubscriberRegistry.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common;
|
||||
|
||||
/**
|
||||
* Interface for registering and unregistering event subscribers.
|
||||
*/
|
||||
interface EventSubscriberRegistry extends EventDispatcher
|
||||
{
|
||||
/**
|
||||
* Adds an EventSubscriber.
|
||||
*
|
||||
* The subscriber is asked for all the events it is interested in and added
|
||||
* as a listener for these events.
|
||||
*/
|
||||
public function addEventSubscriber(EventSubscriber $subscriber): void;
|
||||
|
||||
/**
|
||||
* Removes an EventSubscriber.
|
||||
*
|
||||
* The subscriber is asked for all the events it is interested in and removed
|
||||
* as a listener for these events.
|
||||
*/
|
||||
public function removeEventSubscriber(EventSubscriber $subscriber): void;
|
||||
}
|
||||
Reference in New Issue
Block a user