diff options
Diffstat (limited to 'vendor/doctrine/event-manager')
-rw-r--r-- | vendor/doctrine/event-manager/LICENSE | 19 | ||||
-rw-r--r-- | vendor/doctrine/event-manager/README.md | 13 | ||||
-rw-r--r-- | vendor/doctrine/event-manager/UPGRADE.md | 15 | ||||
-rw-r--r-- | vendor/doctrine/event-manager/composer.json | 68 | ||||
-rw-r--r-- | vendor/doctrine/event-manager/phpstan.neon.dist | 5 | ||||
-rw-r--r-- | vendor/doctrine/event-manager/psalm-baseline.xml | 8 | ||||
-rw-r--r-- | vendor/doctrine/event-manager/psalm.xml | 15 | ||||
-rw-r--r-- | vendor/doctrine/event-manager/src/EventArgs.php | 37 | ||||
-rw-r--r-- | vendor/doctrine/event-manager/src/EventManager.php | 129 | ||||
-rw-r--r-- | vendor/doctrine/event-manager/src/EventSubscriber.php | 21 |
10 files changed, 330 insertions, 0 deletions
diff --git a/vendor/doctrine/event-manager/LICENSE b/vendor/doctrine/event-manager/LICENSE new file mode 100644 index 0000000..8c38cc1 --- /dev/null +++ b/vendor/doctrine/event-manager/LICENSE | |||
@@ -0,0 +1,19 @@ | |||
1 | Copyright (c) 2006-2015 Doctrine Project | ||
2 | |||
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
4 | this software and associated documentation files (the "Software"), to deal in | ||
5 | the Software without restriction, including without limitation the rights to | ||
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
7 | of the Software, and to permit persons to whom the Software is furnished to do | ||
8 | so, subject to the following conditions: | ||
9 | |||
10 | The above copyright notice and this permission notice shall be included in all | ||
11 | copies or substantial portions of the Software. | ||
12 | |||
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
19 | SOFTWARE. | ||
diff --git a/vendor/doctrine/event-manager/README.md b/vendor/doctrine/event-manager/README.md new file mode 100644 index 0000000..5b36f54 --- /dev/null +++ b/vendor/doctrine/event-manager/README.md | |||
@@ -0,0 +1,13 @@ | |||
1 | # Doctrine Event Manager | ||
2 | |||
3 | [](https://github.com/doctrine/event-manager/actions) | ||
4 | [](https://scrutinizer-ci.com/g/doctrine/event-manager/?branch=1.2.x) | ||
5 | [](https://scrutinizer-ci.com/g/doctrine/event-manager/?branch=1.2.x) | ||
6 | |||
7 | The Doctrine Event Manager is a library that provides a simple event system. | ||
8 | |||
9 | ## More resources: | ||
10 | |||
11 | * [Website](https://www.doctrine-project.org/) | ||
12 | * [Documentation](https://www.doctrine-project.org/projects/doctrine-event-manager/en/latest/) | ||
13 | * [Downloads](https://github.com/doctrine/event-manager/releases) | ||
diff --git a/vendor/doctrine/event-manager/UPGRADE.md b/vendor/doctrine/event-manager/UPGRADE.md new file mode 100644 index 0000000..25154ef --- /dev/null +++ b/vendor/doctrine/event-manager/UPGRADE.md | |||
@@ -0,0 +1,15 @@ | |||
1 | # Upgrade to 2.0 | ||
2 | |||
3 | ## Made the `$event` parameter of `EventManager::getListeners()` mandatory | ||
4 | |||
5 | When calling `EventManager::getListeners()` you need to specify the event that | ||
6 | you want to fetch the listeners for. Call `getAllListeners()` instead if you | ||
7 | want to access the listeners of all events. | ||
8 | |||
9 | # Upgrade to 1.2 | ||
10 | |||
11 | ## Deprecated calling `EventManager::getListeners()` without an event name | ||
12 | |||
13 | When calling `EventManager::getListeners()` without an event name, all | ||
14 | listeners were returned, keyed by event name. A new method `getAllListeners()` | ||
15 | has been added to provide this functionality. It should be used instead. | ||
diff --git a/vendor/doctrine/event-manager/composer.json b/vendor/doctrine/event-manager/composer.json new file mode 100644 index 0000000..4ea788b --- /dev/null +++ b/vendor/doctrine/event-manager/composer.json | |||
@@ -0,0 +1,68 @@ | |||
1 | { | ||
2 | "name": "doctrine/event-manager", | ||
3 | "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.", | ||
4 | "license": "MIT", | ||
5 | "type": "library", | ||
6 | "keywords": [ | ||
7 | "events", | ||
8 | "event", | ||
9 | "event dispatcher", | ||
10 | "event manager", | ||
11 | "event system" | ||
12 | ], | ||
13 | "authors": [ | ||
14 | { | ||
15 | "name": "Guilherme Blanco", | ||
16 | "email": "guilhermeblanco@gmail.com" | ||
17 | }, | ||
18 | { | ||
19 | "name": "Roman Borschel", | ||
20 | "email": "roman@code-factory.org" | ||
21 | }, | ||
22 | { | ||
23 | "name": "Benjamin Eberlei", | ||
24 | "email": "kontakt@beberlei.de" | ||
25 | }, | ||
26 | { | ||
27 | "name": "Jonathan Wage", | ||
28 | "email": "jonwage@gmail.com" | ||
29 | }, | ||
30 | { | ||
31 | "name": "Johannes Schmitt", | ||
32 | "email": "schmittjoh@gmail.com" | ||
33 | }, | ||
34 | { | ||
35 | "name": "Marco Pivetta", | ||
36 | "email": "ocramius@gmail.com" | ||
37 | } | ||
38 | ], | ||
39 | "homepage": "https://www.doctrine-project.org/projects/event-manager.html", | ||
40 | "require": { | ||
41 | "php": "^8.1" | ||
42 | }, | ||
43 | "require-dev": { | ||
44 | "doctrine/coding-standard": "^12", | ||
45 | "phpstan/phpstan": "^1.8.8", | ||
46 | "phpunit/phpunit": "^10.5", | ||
47 | "vimeo/psalm": "^5.24" | ||
48 | }, | ||
49 | "conflict": { | ||
50 | "doctrine/common": "<2.9" | ||
51 | }, | ||
52 | "autoload": { | ||
53 | "psr-4": { | ||
54 | "Doctrine\\Common\\": "src" | ||
55 | } | ||
56 | }, | ||
57 | "autoload-dev": { | ||
58 | "psr-4": { | ||
59 | "Doctrine\\Tests\\Common\\": "tests" | ||
60 | } | ||
61 | }, | ||
62 | "config": { | ||
63 | "allow-plugins": { | ||
64 | "dealerdirect/phpcodesniffer-composer-installer": true | ||
65 | }, | ||
66 | "sort-packages": true | ||
67 | } | ||
68 | } | ||
diff --git a/vendor/doctrine/event-manager/phpstan.neon.dist b/vendor/doctrine/event-manager/phpstan.neon.dist new file mode 100644 index 0000000..1517ec8 --- /dev/null +++ b/vendor/doctrine/event-manager/phpstan.neon.dist | |||
@@ -0,0 +1,5 @@ | |||
1 | parameters: | ||
2 | level: 9 | ||
3 | paths: | ||
4 | - src/ | ||
5 | - tests/ | ||
diff --git a/vendor/doctrine/event-manager/psalm-baseline.xml b/vendor/doctrine/event-manager/psalm-baseline.xml new file mode 100644 index 0000000..bc48ad8 --- /dev/null +++ b/vendor/doctrine/event-manager/psalm-baseline.xml | |||
@@ -0,0 +1,8 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <files psalm-version="5.24.0@462c80e31c34e58cc4f750c656be3927e80e550e"> | ||
3 | <file src="src/EventManager.php"> | ||
4 | <RiskyTruthyFalsyComparison> | ||
5 | <code><![CDATA[empty($this->listeners[$event])]]></code> | ||
6 | </RiskyTruthyFalsyComparison> | ||
7 | </file> | ||
8 | </files> | ||
diff --git a/vendor/doctrine/event-manager/psalm.xml b/vendor/doctrine/event-manager/psalm.xml new file mode 100644 index 0000000..4e9226b --- /dev/null +++ b/vendor/doctrine/event-manager/psalm.xml | |||
@@ -0,0 +1,15 @@ | |||
1 | <?xml version="1.0"?> | ||
2 | <psalm | ||
3 | errorLevel="2" | ||
4 | resolveFromConfigFile="true" | ||
5 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
6 | xmlns="https://getpsalm.org/schema/config" | ||
7 | xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | ||
8 | > | ||
9 | <projectFiles> | ||
10 | <directory name="src" /> | ||
11 | <ignoreFiles> | ||
12 | <directory name="vendor" /> | ||
13 | </ignoreFiles> | ||
14 | </projectFiles> | ||
15 | </psalm> | ||
diff --git a/vendor/doctrine/event-manager/src/EventArgs.php b/vendor/doctrine/event-manager/src/EventArgs.php new file mode 100644 index 0000000..eea3d8a --- /dev/null +++ b/vendor/doctrine/event-manager/src/EventArgs.php | |||
@@ -0,0 +1,37 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\Common; | ||
6 | |||
7 | /** | ||
8 | * EventArgs is the base class for classes containing event data. | ||
9 | * | ||
10 | * This class contains no event data. It is used by events that do not pass state | ||
11 | * information to an event handler when an event is raised. The single empty EventArgs | ||
12 | * instance can be obtained through {@link getEmptyInstance}. | ||
13 | */ | ||
14 | class EventArgs | ||
15 | { | ||
16 | /** | ||
17 | * Single instance of EventArgs. | ||
18 | */ | ||
19 | private static EventArgs|null $emptyEventArgsInstance = null; | ||
20 | |||
21 | /** | ||
22 | * Gets the single, empty and immutable EventArgs instance. | ||
23 | * | ||
24 | * This instance will be used when events are dispatched without any parameter, | ||
25 | * like this: EventManager::dispatchEvent('eventname'); | ||
26 | * | ||
27 | * The benefit from this is that only one empty instance is instantiated and shared | ||
28 | * (otherwise there would be instances for every dispatched in the abovementioned form). | ||
29 | * | ||
30 | * @link https://msdn.microsoft.com/en-us/library/system.eventargs.aspx | ||
31 | * @see EventManager::dispatchEvent | ||
32 | */ | ||
33 | public static function getEmptyInstance(): EventArgs | ||
34 | { | ||
35 | return self::$emptyEventArgsInstance ??= new EventArgs(); | ||
36 | } | ||
37 | } | ||
diff --git a/vendor/doctrine/event-manager/src/EventManager.php b/vendor/doctrine/event-manager/src/EventManager.php new file mode 100644 index 0000000..86f5e45 --- /dev/null +++ b/vendor/doctrine/event-manager/src/EventManager.php | |||
@@ -0,0 +1,129 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\Common; | ||
6 | |||
7 | use function spl_object_hash; | ||
8 | |||
9 | /** | ||
10 | * The EventManager is the central point of Doctrine's event listener system. | ||
11 | * Listeners are registered on the manager and events are dispatched through the | ||
12 | * manager. | ||
13 | */ | ||
14 | class EventManager | ||
15 | { | ||
16 | /** | ||
17 | * Map of registered listeners. | ||
18 | * <event> => <listeners> | ||
19 | * | ||
20 | * @var array<string, object[]> | ||
21 | */ | ||
22 | private array $listeners = []; | ||
23 | |||
24 | /** | ||
25 | * Dispatches an event to all registered listeners. | ||
26 | * | ||
27 | * @param string $eventName The name of the event to dispatch. The name of the event is | ||
28 | * the name of the method that is invoked on listeners. | ||
29 | * @param EventArgs|null $eventArgs The event arguments to pass to the event handlers/listeners. | ||
30 | * If not supplied, the single empty EventArgs instance is used. | ||
31 | */ | ||
32 | public function dispatchEvent(string $eventName, EventArgs|null $eventArgs = null): void | ||
33 | { | ||
34 | if (! isset($this->listeners[$eventName])) { | ||
35 | return; | ||
36 | } | ||
37 | |||
38 | $eventArgs ??= EventArgs::getEmptyInstance(); | ||
39 | |||
40 | foreach ($this->listeners[$eventName] as $listener) { | ||
41 | $listener->$eventName($eventArgs); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * Gets the listeners of a specific event. | ||
47 | * | ||
48 | * @param string $event The name of the event. | ||
49 | * | ||
50 | * @return object[] | ||
51 | */ | ||
52 | public function getListeners(string $event): array | ||
53 | { | ||
54 | return $this->listeners[$event] ?? []; | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * Gets all listeners keyed by event name. | ||
59 | * | ||
60 | * @return array<string, object[]> The event listeners for the specified event, or all event listeners. | ||
61 | */ | ||
62 | public function getAllListeners(): array | ||
63 | { | ||
64 | return $this->listeners; | ||
65 | } | ||
66 | |||
67 | /** | ||
68 | * Checks whether an event has any registered listeners. | ||
69 | */ | ||
70 | public function hasListeners(string $event): bool | ||
71 | { | ||
72 | return ! empty($this->listeners[$event]); | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * Adds an event listener that listens on the specified events. | ||
77 | * | ||
78 | * @param string|string[] $events The event(s) to listen on. | ||
79 | * @param object $listener The listener object. | ||
80 | */ | ||
81 | public function addEventListener(string|array $events, object $listener): void | ||
82 | { | ||
83 | // Picks the hash code related to that listener | ||
84 | $hash = spl_object_hash($listener); | ||
85 | |||
86 | foreach ((array) $events as $event) { | ||
87 | // Overrides listener if a previous one was associated already | ||
88 | // Prevents duplicate listeners on same event (same instance only) | ||
89 | $this->listeners[$event][$hash] = $listener; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * Removes an event listener from the specified events. | ||
95 | * | ||
96 | * @param string|string[] $events | ||
97 | */ | ||
98 | public function removeEventListener(string|array $events, object $listener): void | ||
99 | { | ||
100 | // Picks the hash code related to that listener | ||
101 | $hash = spl_object_hash($listener); | ||
102 | |||
103 | foreach ((array) $events as $event) { | ||
104 | unset($this->listeners[$event][$hash]); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | /** | ||
109 | * Adds an EventSubscriber. | ||
110 | * | ||
111 | * The subscriber is asked for all the events it is interested in and added | ||
112 | * as a listener for these events. | ||
113 | */ | ||
114 | public function addEventSubscriber(EventSubscriber $subscriber): void | ||
115 | { | ||
116 | $this->addEventListener($subscriber->getSubscribedEvents(), $subscriber); | ||
117 | } | ||
118 | |||
119 | /** | ||
120 | * Removes an EventSubscriber. | ||
121 | * | ||
122 | * The subscriber is asked for all the events it is interested in and removed | ||
123 | * as a listener for these events. | ||
124 | */ | ||
125 | public function removeEventSubscriber(EventSubscriber $subscriber): void | ||
126 | { | ||
127 | $this->removeEventListener($subscriber->getSubscribedEvents(), $subscriber); | ||
128 | } | ||
129 | } | ||
diff --git a/vendor/doctrine/event-manager/src/EventSubscriber.php b/vendor/doctrine/event-manager/src/EventSubscriber.php new file mode 100644 index 0000000..89cef55 --- /dev/null +++ b/vendor/doctrine/event-manager/src/EventSubscriber.php | |||
@@ -0,0 +1,21 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\Common; | ||
6 | |||
7 | /** | ||
8 | * An EventSubscriber knows what events it is interested in. | ||
9 | * If an EventSubscriber is added to an EventManager, the manager invokes | ||
10 | * {@link getSubscribedEvents} and registers the subscriber as a listener for all | ||
11 | * returned events. | ||
12 | */ | ||
13 | interface EventSubscriber | ||
14 | { | ||
15 | /** | ||
16 | * Returns an array of events this subscriber wants to listen to. | ||
17 | * | ||
18 | * @return string[] | ||
19 | */ | ||
20 | public function getSubscribedEvents(); | ||
21 | } | ||