update lock clucknut
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 14s
Build, Push and Deploy / build-and-push (push) Successful in 3m14s
Build, Push and Deploy / deploy-staging (push) Successful in 25s
Build, Push and Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-18 20:32:18 +07:00
parent 4554035227
commit dcaf267458
3359 changed files with 153185 additions and 205489 deletions

View File

@@ -180,9 +180,7 @@ ## Displaying deprecations after running a PHPUnit test suite
```
Note that you can still trigger Deprecations in your code, provided you use the
`#[WithoutErrorHandler]` attribute to disable PHPUnit's error handler for tests
that call it. Be wary that this will disable all error handling, meaning it
will mask any warnings or errors that would otherwise be caught by PHPUnit.
`#[IgnoreDeprecations]` to ignore them for tests that call it.
At the moment, it is not possible to disable deduplication with an environment
variable, but you can use a bootstrap file to achieve that:

View File

@@ -8,14 +8,14 @@
"php": "^7.1 || ^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^9 || ^12 || ^13",
"phpstan/phpstan": "1.4.10 || 2.1.11",
"doctrine/coding-standard": "^9 || ^12 || ^14",
"phpstan/phpstan": "1.4.10 || 2.1.30",
"phpstan/phpstan-phpunit": "^1.0 || ^2",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12.4 || ^13.0",
"psr/log": "^1 || ^2 || ^3"
},
"conflict": {
"phpunit/phpunit": "<=7.5 || >=13"
"phpunit/phpunit": "<=7.5 || >=14"
},
"suggest": {
"psr/log": "Allows logging deprecations via PSR-3 logger implementation"

View File

@@ -57,7 +57,7 @@ public function verifyDeprecationsAreTriggered(): void
$this->assertTrue(
$actualCount === $expectation,
sprintf(
"Expected deprecation with identifier '%s' was triggered by code executed in test, but expected not to.",
"Deprecation with identifier '%s' was triggered by code executed in test, but expected not to.",
$identifier
)
);

View File

@@ -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"
}
}

View File

@@ -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>

View 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;
}

View 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;
}

View 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;
}

View File

@@ -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);

View 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
{
}

View 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;
}