(Grav GitSync) Automatic Commit from smokephil
This commit is contained in:
parent
ab8f386766
commit
54730a9480
251 changed files with 5008 additions and 8945 deletions
|
|
@ -42,7 +42,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
|||
private $requestStack;
|
||||
private $currentRequestHash = '';
|
||||
|
||||
public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, LoggerInterface $logger = null, RequestStack $requestStack = null)
|
||||
public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, ?LoggerInterface $logger = null, ?RequestStack $requestStack = null)
|
||||
{
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->stopwatch = $stopwatch;
|
||||
|
|
@ -97,7 +97,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getListeners(string $eventName = null)
|
||||
public function getListeners(?string $eventName = null)
|
||||
{
|
||||
return $this->dispatcher->getListeners($eventName);
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasListeners(string $eventName = null)
|
||||
public function hasListeners(?string $eventName = null)
|
||||
{
|
||||
return $this->dispatcher->hasListeners($eventName);
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dispatch(object $event, string $eventName = null): object
|
||||
public function dispatch(object $event, ?string $eventName = null): object
|
||||
{
|
||||
$eventName = $eventName ?? \get_class($event);
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
|||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCalledListeners(Request $request = null)
|
||||
public function getCalledListeners(?Request $request = null)
|
||||
{
|
||||
if (null === $this->callStack) {
|
||||
return [];
|
||||
|
|
@ -192,7 +192,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
|||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getNotCalledListeners(Request $request = null)
|
||||
public function getNotCalledListeners(?Request $request = null)
|
||||
{
|
||||
try {
|
||||
$allListeners = $this->getListeners();
|
||||
|
|
@ -235,7 +235,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
|||
return $notCalled;
|
||||
}
|
||||
|
||||
public function getOrphanedEvents(Request $request = null): array
|
||||
public function getOrphanedEvents(?Request $request = null): array
|
||||
{
|
||||
if ($request) {
|
||||
return $this->orphanedEvents[spl_object_hash($request)] ?? [];
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ final class WrappedListener
|
|||
private $priority;
|
||||
private static $hasClassStub;
|
||||
|
||||
public function __construct($listener, ?string $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null)
|
||||
public function __construct($listener, ?string $name, Stopwatch $stopwatch, ?EventDispatcherInterface $dispatcher = null)
|
||||
{
|
||||
$this->listener = $listener;
|
||||
$this->optimizedListener = $listener instanceof \Closure ? $listener : (\is_callable($listener) ? \Closure::fromCallable($listener) : null);
|
||||
|
|
@ -49,7 +49,7 @@ final class WrappedListener
|
|||
$r = new \ReflectionFunction($listener);
|
||||
if (str_contains($r->name, '{closure}')) {
|
||||
$this->pretty = $this->name = 'closure';
|
||||
} elseif ($class = $r->getClosureScopeClass()) {
|
||||
} elseif ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
|
||||
$this->name = $class->name;
|
||||
$this->pretty = $this->name.'::'.$r->name;
|
||||
} else {
|
||||
|
|
@ -114,10 +114,12 @@ final class WrappedListener
|
|||
|
||||
$e = $this->stopwatch->start($this->name, 'event_listener');
|
||||
|
||||
($this->optimizedListener ?? $this->listener)($event, $eventName, $dispatcher);
|
||||
|
||||
if ($e->isStarted()) {
|
||||
$e->stop();
|
||||
try {
|
||||
($this->optimizedListener ?? $this->listener)($event, $eventName, $dispatcher);
|
||||
} finally {
|
||||
if ($e->isStarted()) {
|
||||
$e->stop();
|
||||
}
|
||||
}
|
||||
|
||||
if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue