PKZ..ConsoleCommandEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Event; /** * Allows to do things before the command is executed, like skipping the command or executing code before the command is * going to be executed. * * Changing the input arguments will have no effect. * * @author Fabien Potencier */ final class ConsoleCommandEvent extends ConsoleEvent { /** * The return code for skipped commands, this will also be passed into the terminate event. */ public const RETURN_CODE_DISABLED = 113; /** * Indicates if the command should be run or skipped. */ private bool $commandShouldRun = true; /** * Disables the command, so it won't be run. */ public function disableCommand(): bool { return $this->commandShouldRun = false; } public function enableCommand(): bool { return $this->commandShouldRun = true; } /** * Returns true if the command is runnable, false otherwise. */ public function commandShouldRun(): bool { return $this->commandShouldRun; } } PKZ99ConsoleTerminateEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Event; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * Allows to manipulate the exit code of a command after its execution. * * @author Francesco Levorato * @author Jules Pietri */ final class ConsoleTerminateEvent extends ConsoleEvent { public function __construct( Command $command, InputInterface $input, OutputInterface $output, private int $exitCode, private readonly ?int $interruptingSignal = null, ) { parent::__construct($command, $input, $output); } public function setExitCode(int $exitCode): void { $this->exitCode = $exitCode; } public function getExitCode(): int { return $this->exitCode; } public function getInterruptingSignal(): ?int { return $this->interruptingSignal; } } PKZ_WConsoleSignalEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Event; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * @author marie */ final class ConsoleSignalEvent extends ConsoleEvent { private int $handlingSignal; private int|false $exitCode; public function __construct(Command $command, InputInterface $input, OutputInterface $output, int $handlingSignal, int|false $exitCode = 0) { parent::__construct($command, $input, $output); $this->handlingSignal = $handlingSignal; $this->exitCode = $exitCode; } public function getHandlingSignal(): int { return $this->handlingSignal; } public function setExitCode(int $exitCode): void { if ($exitCode < 0 || $exitCode > 255) { throw new \InvalidArgumentException('Exit code must be between 0 and 255.'); } $this->exitCode = $exitCode; } public function abortExit(): void { $this->exitCode = false; } public function getExitCode(): int|false { return $this->exitCode; } } PKZ^OPPConsoleEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Event; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Contracts\EventDispatcher\Event; /** * Allows to inspect input and output of a command. * * @author Francesco Levorato */ class ConsoleEvent extends Event { protected $command; private InputInterface $input; private OutputInterface $output; public function __construct(?Command $command, InputInterface $input, OutputInterface $output) { $this->command = $command; $this->input = $input; $this->output = $output; } /** * Gets the command that is executed. */ public function getCommand(): ?Command { return $this->command; } /** * Gets the input instance. */ public function getInput(): InputInterface { return $this->input; } /** * Gets the output instance. */ public function getOutput(): OutputInterface { return $this->output; } } PKZaMConsoleErrorEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Event; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * Allows to handle throwables thrown while running a command. * * @author Wouter de Jong */ final class ConsoleErrorEvent extends ConsoleEvent { private \Throwable $error; private int $exitCode; public function __construct(InputInterface $input, OutputInterface $output, \Throwable $error, ?Command $command = null) { parent::__construct($command, $input, $output); $this->error = $error; } public function getError(): \Throwable { return $this->error; } public function setError(\Throwable $error): void { $this->error = $error; } public function setExitCode(int $exitCode): void { $this->exitCode = $exitCode; $r = new \ReflectionProperty($this->error, 'code'); $r->setValue($this->error, $this->exitCode); } public function getExitCode(): int { return $this->exitCode ?? (\is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1); } } PKiZ | ViewEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Event; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Allows to create a response for the return value of a controller. * * Call setResponse() to set the response that will be returned for the * current request. The propagation of this event is stopped as soon as a * response is set. * * @author Bernhard Schussek */ final class ViewEvent extends RequestEvent { public readonly ?ControllerArgumentsEvent $controllerArgumentsEvent; private mixed $controllerResult; public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, mixed $controllerResult, ?ControllerArgumentsEvent $controllerArgumentsEvent = null) { parent::__construct($kernel, $request, $requestType); $this->controllerResult = $controllerResult; $this->controllerArgumentsEvent = $controllerArgumentsEvent; } public function getControllerResult(): mixed { return $this->controllerResult; } public function setControllerResult(mixed $controllerResult): void { $this->controllerResult = $controllerResult; } } PKiZ,`FinishRequestEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Event; /** * Triggered whenever a request is fully processed. * * @author Benjamin Eberlei */ final class FinishRequestEvent extends KernelEvent { } PKiZ+DKernelEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Event; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Contracts\EventDispatcher\Event; /** * Base class for events dispatched in the HttpKernel component. * * @author Bernhard Schussek */ class KernelEvent extends Event { private HttpKernelInterface $kernel; private Request $request; private ?int $requestType; /** * @param int $requestType The request type the kernel is currently processing; one of * HttpKernelInterface::MAIN_REQUEST or HttpKernelInterface::SUB_REQUEST */ public function __construct(HttpKernelInterface $kernel, Request $request, ?int $requestType) { $this->kernel = $kernel; $this->request = $request; $this->requestType = $requestType; } /** * Returns the kernel in which this event was thrown. */ public function getKernel(): HttpKernelInterface { return $this->kernel; } /** * Returns the request the kernel is currently processing. */ public function getRequest(): Request { return $this->request; } /** * Returns the request type the kernel is currently processing. * * @return int One of HttpKernelInterface::MAIN_REQUEST and * HttpKernelInterface::SUB_REQUEST */ public function getRequestType(): int { return $this->requestType; } /** * Checks if this is the main request. */ public function isMainRequest(): bool { return HttpKernelInterface::MAIN_REQUEST === $this->requestType; } } PKiZn]==ControllerEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Event; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Allows filtering of a controller callable. * * You can call getController() to retrieve the current controller. With * setController() you can set a new controller that is used in the processing * of the request. * * Controllers should be callables. * * @author Bernhard Schussek */ final class ControllerEvent extends KernelEvent { private string|array|object $controller; private \ReflectionFunctionAbstract $controllerReflector; private array $attributes; public function __construct(HttpKernelInterface $kernel, callable $controller, Request $request, ?int $requestType) { parent::__construct($kernel, $request, $requestType); $this->setController($controller); } public function getController(): callable { return $this->controller; } public function getControllerReflector(): \ReflectionFunctionAbstract { return $this->controllerReflector; } /** * @param array>|null $attributes */ public function setController(callable $controller, ?array $attributes = null): void { if (null !== $attributes) { $this->attributes = $attributes; } if (isset($this->controller) && ($controller instanceof \Closure ? $controller == $this->controller : $controller === $this->controller)) { $this->controller = $controller; return; } if (null === $attributes) { unset($this->attributes); } if (\is_array($controller) && method_exists(...$controller)) { $this->controllerReflector = new \ReflectionMethod(...$controller); } elseif (\is_string($controller) && str_contains($controller, '::')) { $this->controllerReflector = new \ReflectionMethod(...explode('::', $controller, 2)); } else { $this->controllerReflector = new \ReflectionFunction($controller(...)); } $this->controller = $controller; } /** * @template T of class-string|null * * @param T $className * * @return array>|list * * @psalm-return (T is null ? array> : list) */ public function getAttributes(?string $className = null): array { if (isset($this->attributes)) { return null === $className ? $this->attributes : $this->attributes[$className] ?? []; } if (\is_array($this->controller) && method_exists(...$this->controller)) { $class = new \ReflectionClass($this->controller[0]); } elseif (\is_string($this->controller) && false !== $i = strpos($this->controller, '::')) { $class = new \ReflectionClass(substr($this->controller, 0, $i)); } else { $class = str_contains($this->controllerReflector->name, '{closure') ? null : (\PHP_VERSION_ID >= 80111 ? $this->controllerReflector->getClosureCalledClass() : $this->controllerReflector->getClosureScopeClass()); } $this->attributes = []; foreach (array_merge($class?->getAttributes() ?? [], $this->controllerReflector->getAttributes()) as $attribute) { if (class_exists($attribute->getName())) { $this->attributes[$attribute->getName()][] = $attribute->newInstance(); } } return null === $className ? $this->attributes : $this->attributes[$className] ?? []; } } PKiZ-f} ControllerArgumentsEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Event; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Allows filtering of controller arguments. * * You can call getController() to retrieve the controller and getArguments * to retrieve the current arguments. With setArguments() you can replace * arguments that are used to call the controller. * * Arguments set in the event must be compatible with the signature of the * controller. * * @author Christophe Coevoet */ final class ControllerArgumentsEvent extends KernelEvent { private ControllerEvent $controllerEvent; private array $arguments; private array $namedArguments; public function __construct(HttpKernelInterface $kernel, callable|ControllerEvent $controller, array $arguments, Request $request, ?int $requestType) { parent::__construct($kernel, $request, $requestType); if (!$controller instanceof ControllerEvent) { $controller = new ControllerEvent($kernel, $controller, $request, $requestType); } $this->controllerEvent = $controller; $this->arguments = $arguments; } public function getController(): callable { return $this->controllerEvent->getController(); } /** * @param array>|null $attributes */ public function setController(callable $controller, ?array $attributes = null): void { $this->controllerEvent->setController($controller, $attributes); unset($this->namedArguments); } public function getArguments(): array { return $this->arguments; } public function setArguments(array $arguments): void { $this->arguments = $arguments; unset($this->namedArguments); } public function getNamedArguments(): array { if (isset($this->namedArguments)) { return $this->namedArguments; } $namedArguments = []; $arguments = $this->arguments; foreach ($this->controllerEvent->getControllerReflector()->getParameters() as $i => $param) { if ($param->isVariadic()) { $namedArguments[$param->name] = \array_slice($arguments, $i); break; } if (\array_key_exists($i, $arguments)) { $namedArguments[$param->name] = $arguments[$i]; } elseif ($param->isDefaultvalueAvailable()) { $namedArguments[$param->name] = $param->getDefaultValue(); } } return $this->namedArguments = $namedArguments; } /** * @template T of class-string|null * * @param T $className * * @return array>|list * * @psalm-return (T is null ? array> : list) */ public function getAttributes(?string $className = null): array { return $this->controllerEvent->getAttributes($className); } } PKiZw7|~~ExceptionEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Event; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Allows to create a response for a thrown exception. * * Call setResponse() to set the response that will be returned for the * current request. The propagation of this event is stopped as soon as a * response is set. * * You can also call setThrowable() to replace the thrown exception. This * exception will be thrown if no response is set during processing of this * event. * * @author Bernhard Schussek */ final class ExceptionEvent extends RequestEvent { private \Throwable $throwable; private bool $allowCustomResponseCode = false; public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, \Throwable $e) { parent::__construct($kernel, $request, $requestType); $this->setThrowable($e); } public function getThrowable(): \Throwable { return $this->throwable; } /** * Replaces the thrown exception. * * This exception will be thrown if no response is set in the event. */ public function setThrowable(\Throwable $exception): void { $this->throwable = $exception; } /** * Mark the event as allowing a custom response code. */ public function allowCustomResponseCode(): void { $this->allowCustomResponseCode = true; } /** * Returns true if the event allows a custom response code. */ public function isAllowingCustomResponseCode(): bool { return $this->allowCustomResponseCode; } } PKiZ#lNNTerminateEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Event; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Allows to execute logic after a response was sent. * * Since it's only triggered on main requests, the `getRequestType()` method * will always return the value of `HttpKernelInterface::MAIN_REQUEST`. * * @author Jordi Boggiano */ final class TerminateEvent extends KernelEvent { private Response $response; public function __construct(HttpKernelInterface $kernel, Request $request, Response $response) { parent::__construct($kernel, $request, HttpKernelInterface::MAIN_REQUEST); $this->response = $response; } public function getResponse(): Response { return $this->response; } } PKiZDaRequestEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Event; use Symfony\Component\HttpFoundation\Response; /** * Allows to create a response for a request. * * Call setResponse() to set the response that will be returned for the * current request. The propagation of this event is stopped as soon as a * response is set. * * @author Bernhard Schussek */ class RequestEvent extends KernelEvent { private ?Response $response = null; /** * Returns the response object. */ public function getResponse(): ?Response { return $this->response; } /** * Sets a response and stops event propagation. * * @return void */ public function setResponse(Response $response) { $this->response = $response; $this->stopPropagation(); } /** * Returns whether a response was set. */ public function hasResponse(): bool { return null !== $this->response; } } PKiZResponseEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Event; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Allows to filter a Response object. * * You can call getResponse() to retrieve the current response. With * setResponse() you can set a new response that will be returned to the * browser. * * @author Bernhard Schussek */ final class ResponseEvent extends KernelEvent { private Response $response; public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, Response $response) { parent::__construct($kernel, $request, $requestType); $this->setResponse($response); } public function getResponse(): Response { return $this->response; } public function setResponse(Response $response): void { $this->response = $response; } } PK6Z0!AbstractEvent.phpnuW+A * * Original code based on the Symfony EventDispatcher "Event" contract * - (c) 2018-2019 Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace League\CommonMark\Event; use Psr\EventDispatcher\StoppableEventInterface; /** * Base class for classes containing event data. * * This class contains no event data. It is used by events that do not pass * state information to an event handler when an event is raised. * * You can call the method stopPropagation() to abort the execution of * further listeners in your event listener. */ abstract class AbstractEvent implements StoppableEventInterface { /** @psalm-readonly-allow-private-mutation */ private bool $propagationStopped = false; /** * Returns whether further event listeners should be triggered. */ final public function isPropagationStopped(): bool { return $this->propagationStopped; } /** * Stops the propagation of the event to further event listeners. * * If multiple event listeners are connected to the same event, no * further event listener will be triggered once any trigger calls * stopPropagation(). */ final public function stopPropagation(): void { $this->propagationStopped = true; } } PK6ZoF/DocumentRenderedEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace League\CommonMark\Event; use League\CommonMark\Output\RenderedContentInterface; final class DocumentRenderedEvent extends AbstractEvent { private RenderedContentInterface $output; public function __construct(RenderedContentInterface $output) { $this->output = $output; } /** * @psalm-mutation-free */ public function getOutput(): RenderedContentInterface { return $this->output; } /** * @psalm-external-mutation-free */ public function replaceOutput(RenderedContentInterface $output): void { $this->output = $output; } } PK6ZttDocumentPreParsedEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace League\CommonMark\Event; use League\CommonMark\Input\MarkdownInputInterface; use League\CommonMark\Node\Block\Document; /** * Event dispatched when the document is about to be parsed */ final class DocumentPreParsedEvent extends AbstractEvent { /** @psalm-readonly */ private Document $document; private MarkdownInputInterface $markdown; public function __construct(Document $document, MarkdownInputInterface $markdown) { $this->document = $document; $this->markdown = $markdown; } public function getDocument(): Document { return $this->document; } public function getMarkdown(): MarkdownInputInterface { return $this->markdown; } public function replaceMarkdown(MarkdownInputInterface $markdownInput): void { $this->markdown = $markdownInput; } } PK6Z /EListenerData.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace League\CommonMark\Event; /** * @internal * * @psalm-immutable */ final class ListenerData { /** @var class-string */ private string $event; /** @var callable */ private $listener; /** * @param class-string $event */ public function __construct(string $event, callable $listener) { $this->event = $event; $this->listener = $listener; } /** * @return class-string */ public function getEvent(): string { return $this->event; } public function getListener(): callable { return $this->listener; } } PK6Z V2DocumentParsedEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace League\CommonMark\Event; use League\CommonMark\Node\Block\Document; /** * Event dispatched when the document has been fully parsed */ final class DocumentParsedEvent extends AbstractEvent { /** @psalm-readonly */ private Document $document; public function __construct(Document $document) { $this->document = $document; } public function getDocument(): Document { return $this->document; } } PK6ZA2hێDocumentPreRenderEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace League\CommonMark\Event; use League\CommonMark\Node\Block\Document; /** * Event dispatched just before rendering begins */ final class DocumentPreRenderEvent extends AbstractEvent { /** @psalm-readonly */ private Document $document; /** @psalm-readonly */ private string $format; public function __construct(Document $document, string $format) { $this->document = $document; $this->format = $format; } public function getDocument(): Document { return $this->document; } public function getFormat(): string { return $this->format; } } PKQrZZCCAttributesListener.phpnuW+A * (c) 2015 Martin Hasoň * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace League\CommonMark\Extension\Attributes\Event; use League\CommonMark\Event\DocumentParsedEvent; use League\CommonMark\Extension\Attributes\Node\Attributes; use League\CommonMark\Extension\Attributes\Node\AttributesInline; use League\CommonMark\Extension\Attributes\Util\AttributesHelper; use League\CommonMark\Extension\CommonMark\Node\Block\FencedCode; use League\CommonMark\Extension\CommonMark\Node\Block\ListBlock; use League\CommonMark\Extension\CommonMark\Node\Block\ListItem; use League\CommonMark\Node\Inline\AbstractInline; use League\CommonMark\Node\Node; final class AttributesListener { private const DIRECTION_PREFIX = 'prefix'; private const DIRECTION_SUFFIX = 'suffix'; public function processDocument(DocumentParsedEvent $event): void { foreach ($event->getDocument()->iterator() as $node) { if (! ($node instanceof Attributes || $node instanceof AttributesInline)) { continue; } [$target, $direction] = self::findTargetAndDirection($node); if ($target instanceof Node) { $parent = $target->parent(); if ($parent instanceof ListItem && $parent->parent() instanceof ListBlock && $parent->parent()->isTight()) { $target = $parent; } if ($direction === self::DIRECTION_SUFFIX) { $attributes = AttributesHelper::mergeAttributes($target, $node->getAttributes()); } else { $attributes = AttributesHelper::mergeAttributes($node->getAttributes(), $target); } $target->data->set('attributes', $attributes); } $node->detach(); } } /** * @param Attributes|AttributesInline $node * * @return array */ private static function findTargetAndDirection($node): array { $target = null; $direction = null; $previous = $next = $node; while (true) { $previous = self::getPrevious($previous); $next = self::getNext($next); if ($previous === null && $next === null) { if (! $node->parent() instanceof FencedCode) { $target = $node->parent(); $direction = self::DIRECTION_SUFFIX; } break; } if ($node instanceof AttributesInline && ($previous === null || ($previous instanceof AbstractInline && $node->isBlock()))) { continue; } if ($previous !== null && ! self::isAttributesNode($previous)) { $target = $previous; $direction = self::DIRECTION_SUFFIX; break; } if ($next !== null && ! self::isAttributesNode($next)) { $target = $next; $direction = self::DIRECTION_PREFIX; break; } } return [$target, $direction]; } /** * Get any previous block (sibling or parent) this might apply to */ private static function getPrevious(?Node $node = null): ?Node { if ($node instanceof Attributes) { if ($node->getTarget() === Attributes::TARGET_NEXT) { return null; } if ($node->getTarget() === Attributes::TARGET_PARENT) { return $node->parent(); } } return $node instanceof Node ? $node->previous() : null; } /** * Get any previous block (sibling or parent) this might apply to */ private static function getNext(?Node $node = null): ?Node { if ($node instanceof Attributes && $node->getTarget() !== Attributes::TARGET_NEXT) { return null; } return $node instanceof Node ? $node->next() : null; } private static function isAttributesNode(Node $node): bool { return $node instanceof Attributes || $node instanceof AttributesInline; } } PKEZdC$ConsecutiveDescriptionListMerger.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace League\CommonMark\Extension\DescriptionList\Event; use League\CommonMark\Event\DocumentParsedEvent; use League\CommonMark\Extension\DescriptionList\Node\DescriptionList; use League\CommonMark\Node\NodeIterator; final class ConsecutiveDescriptionListMerger { public function __invoke(DocumentParsedEvent $event): void { foreach ($event->getDocument()->iterator(NodeIterator::FLAG_BLOCKS_ONLY) as $node) { if (! $node instanceof DescriptionList) { continue; } if (! ($prev = $node->previous()) instanceof DescriptionList) { continue; } // There's another description list behind this one; merge the current one into that foreach ($node->children() as $child) { $prev->appendChild($child); } $node->detach(); } } } PKEZ#_LooseDescriptionHandler.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace League\CommonMark\Extension\DescriptionList\Event; use League\CommonMark\Event\DocumentParsedEvent; use League\CommonMark\Extension\DescriptionList\Node\Description; use League\CommonMark\Extension\DescriptionList\Node\DescriptionList; use League\CommonMark\Extension\DescriptionList\Node\DescriptionTerm; use League\CommonMark\Node\Block\Paragraph; use League\CommonMark\Node\Inline\Newline; use League\CommonMark\Node\NodeIterator; final class LooseDescriptionHandler { public function __invoke(DocumentParsedEvent $event): void { foreach ($event->getDocument()->iterator(NodeIterator::FLAG_BLOCKS_ONLY) as $description) { if (! $description instanceof Description) { continue; } // Does this description need to be added to a list? if (! $description->parent() instanceof DescriptionList) { $list = new DescriptionList(); // Taking any preceding paragraphs with it if (($paragraph = $description->previous()) instanceof Paragraph) { $list->appendChild($paragraph); } $description->replaceWith($list); $list->appendChild($description); } // Is this description preceded by a paragraph that should really be a term? if (! (($paragraph = $description->previous()) instanceof Paragraph)) { continue; } // Convert the paragraph into one or more terms $term = new DescriptionTerm(); $paragraph->replaceWith($term); foreach ($paragraph->children() as $child) { if ($child instanceof Newline) { $newTerm = new DescriptionTerm(); $term->insertAfter($newTerm); $term = $newTerm; continue; } $term->appendChild($child); } } } } PKZpܵ1 1 'FixOrphanedFootnotesAndRefsListener.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace League\CommonMark\Extension\Footnote\Event; use League\CommonMark\Event\DocumentParsedEvent; use League\CommonMark\Extension\Footnote\Node\Footnote; use League\CommonMark\Extension\Footnote\Node\FootnoteRef; use League\CommonMark\Node\Block\Document; use League\CommonMark\Node\Inline\Text; final class FixOrphanedFootnotesAndRefsListener { public function onDocumentParsed(DocumentParsedEvent $event): void { $document = $event->getDocument(); $map = $this->buildMapOfKnownFootnotesAndRefs($document); foreach ($map['_flat'] as $node) { if ($node instanceof FootnoteRef && ! isset($map[Footnote::class][$node->getReference()->getLabel()])) { // Found an orphaned FootnoteRef without a corresponding Footnote // Restore the original footnote ref text $node->replaceWith(new Text(\sprintf('[^%s]', $node->getReference()->getLabel()))); } // phpcs:disable SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed if ($node instanceof Footnote && ! isset($map[FootnoteRef::class][$node->getReference()->getLabel()])) { // Found an orphaned Footnote without a corresponding FootnoteRef // Remove the footnote $node->detach(); } } } /** @phpstan-ignore-next-line */ private function buildMapOfKnownFootnotesAndRefs(Document $document): array // @phpcs:ignore { $map = [ Footnote::class => [], FootnoteRef::class => [], '_flat' => [], ]; foreach ($document->iterator() as $node) { if ($node instanceof Footnote) { $map[Footnote::class][$node->getReference()->getLabel()] = true; $map['_flat'][] = $node; } elseif ($node instanceof FootnoteRef) { $map[FootnoteRef::class][$node->getReference()->getLabel()] = true; $map['_flat'][] = $node; } } return $map; } } PKZ~& & NumberFootnotesListener.phpnuW+A * (c) Rezo Zero / Ambroise Maupate * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace League\CommonMark\Extension\Footnote\Event; use League\CommonMark\Event\DocumentParsedEvent; use League\CommonMark\Extension\Footnote\Node\FootnoteRef; use League\CommonMark\Reference\Reference; final class NumberFootnotesListener { public function onDocumentParsed(DocumentParsedEvent $event): void { $document = $event->getDocument(); $nextCounter = 1; $usedLabels = []; $usedCounters = []; foreach ($document->iterator() as $node) { if (! $node instanceof FootnoteRef) { continue; } $existingReference = $node->getReference(); $label = $existingReference->getLabel(); $counter = $nextCounter; $canIncrementCounter = true; if (\array_key_exists($label, $usedLabels)) { /* * Reference is used again, we need to point * to the same footnote. But with a different ID */ $counter = $usedCounters[$label]; $label .= '__' . ++$usedLabels[$label]; $canIncrementCounter = false; } // rewrite reference title to use a numeric link $newReference = new Reference( $label, $existingReference->getDestination(), (string) $counter ); // Override reference with numeric link $node->setReference($newReference); $document->getReferenceMap()->add($newReference); /* * Store created references in document for * creating FootnoteBackrefs */ $document->data->append($existingReference->getDestination(), $newReference); $usedLabels[$label] = 1; $usedCounters[$label] = $nextCounter; if ($canIncrementCounter) { $nextCounter++; } } } } PKZM66AnonymousFootnotesListener.phpnuW+A * (c) Rezo Zero / Ambroise Maupate * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace League\CommonMark\Extension\Footnote\Event; use League\CommonMark\Event\DocumentParsedEvent; use League\CommonMark\Extension\Footnote\Node\Footnote; use League\CommonMark\Extension\Footnote\Node\FootnoteBackref; use League\CommonMark\Extension\Footnote\Node\FootnoteRef; use League\CommonMark\Node\Block\Paragraph; use League\CommonMark\Node\Inline\Text; use League\CommonMark\Reference\Reference; use League\Config\ConfigurationAwareInterface; use League\Config\ConfigurationInterface; final class AnonymousFootnotesListener implements ConfigurationAwareInterface { private ConfigurationInterface $config; public function onDocumentParsed(DocumentParsedEvent $event): void { $document = $event->getDocument(); foreach ($document->iterator() as $node) { if (! $node instanceof FootnoteRef || ($text = $node->getContent()) === null) { continue; } // Anonymous footnote needs to create a footnote from its content $existingReference = $node->getReference(); $newReference = new Reference( $existingReference->getLabel(), '#' . $this->config->get('footnote/ref_id_prefix') . $existingReference->getLabel(), $existingReference->getTitle() ); $paragraph = new Paragraph(); $paragraph->appendChild(new Text($text)); $paragraph->appendChild(new FootnoteBackref($newReference)); $footnote = new Footnote($newReference); $footnote->appendChild($paragraph); $document->appendChild($footnote); } } public function setConfiguration(ConfigurationInterface $configuration): void { $this->config = $configuration; } } PKZ>r GatherFootnotesListener.phpnuW+A * (c) Rezo Zero / Ambroise Maupate * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace League\CommonMark\Extension\Footnote\Event; use League\CommonMark\Event\DocumentParsedEvent; use League\CommonMark\Extension\Footnote\Node\Footnote; use League\CommonMark\Extension\Footnote\Node\FootnoteBackref; use League\CommonMark\Extension\Footnote\Node\FootnoteContainer; use League\CommonMark\Node\Block\Document; use League\CommonMark\Node\NodeIterator; use League\CommonMark\Reference\Reference; use League\Config\ConfigurationAwareInterface; use League\Config\ConfigurationInterface; final class GatherFootnotesListener implements ConfigurationAwareInterface { private ConfigurationInterface $config; public function onDocumentParsed(DocumentParsedEvent $event): void { $document = $event->getDocument(); $footnotes = []; foreach ($document->iterator(NodeIterator::FLAG_BLOCKS_ONLY) as $node) { if (! $node instanceof Footnote) { continue; } // Look for existing reference with footnote label $ref = $document->getReferenceMap()->get($node->getReference()->getLabel()); if ($ref !== null) { // Use numeric title to get footnotes order $footnotes[(int) $ref->getTitle()] = $node; } else { // Footnote call is missing, append footnote at the end $footnotes[\PHP_INT_MAX] = $node; } $key = '#' . $this->config->get('footnote/footnote_id_prefix') . $node->getReference()->getDestination(); if ($document->data->has($key)) { $this->createBackrefs($node, $document->data->get($key)); } } // Only add a footnote container if there are any if (\count($footnotes) === 0) { return; } $container = $this->getFootnotesContainer($document); \ksort($footnotes); foreach ($footnotes as $footnote) { $container->appendChild($footnote); } } private function getFootnotesContainer(Document $document): FootnoteContainer { $footnoteContainer = new FootnoteContainer(); $document->appendChild($footnoteContainer); return $footnoteContainer; } /** * Look for all footnote refs pointing to this footnote and create each footnote backrefs. * * @param Footnote $node The target footnote * @param Reference[] $backrefs References to create backrefs for */ private function createBackrefs(Footnote $node, array $backrefs): void { // Backrefs should be added to the child paragraph $target = $node->lastChild(); if ($target === null) { // This should never happen, but you never know $target = $node; } foreach ($backrefs as $backref) { $target->appendChild(new FootnoteBackref(new Reference( $backref->getLabel(), '#' . $this->config->get('footnote/ref_id_prefix') . $backref->getLabel(), $backref->getTitle() ))); } } public function setConfiguration(ConfigurationInterface $configuration): void { $this->config = $configuration; } } PKZ-l5 MessageEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mailer\Event; use Symfony\Component\Mailer\Envelope; use Symfony\Component\Mailer\Exception\LogicException; use Symfony\Component\Messenger\Stamp\StampInterface; use Symfony\Component\Mime\RawMessage; use Symfony\Contracts\EventDispatcher\Event; /** * Allows the transformation of a Message and the Envelope before the email is sent. * * @author Fabien Potencier */ final class MessageEvent extends Event { private RawMessage $message; private Envelope $envelope; private string $transport; private bool $queued; private bool $rejected = false; /** @var StampInterface[] */ private array $stamps = []; public function __construct(RawMessage $message, Envelope $envelope, string $transport, bool $queued = false) { $this->message = $message; $this->envelope = $envelope; $this->transport = $transport; $this->queued = $queued; } public function getMessage(): RawMessage { return $this->message; } public function setMessage(RawMessage $message): void { $this->message = $message; } public function getEnvelope(): Envelope { return $this->envelope; } public function setEnvelope(Envelope $envelope): void { $this->envelope = $envelope; } public function getTransport(): string { return $this->transport; } public function isQueued(): bool { return $this->queued; } public function isRejected(): bool { return $this->rejected; } public function reject(): void { $this->rejected = true; $this->stopPropagation(); } public function addStamp(StampInterface $stamp): void { if (!$this->queued) { throw new LogicException(sprintf('Cannot call "%s()" on a message that is not meant to be queued.', __METHOD__)); } $this->stamps[] = $stamp; } /** * @return StampInterface[] */ public function getStamps(): array { if (!$this->queued) { throw new LogicException(sprintf('Cannot call "%s()" on a message that is not meant to be queued.', __METHOD__)); } return $this->stamps; } } PKZFFailedMessageEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mailer\Event; use Symfony\Component\Mime\RawMessage; use Symfony\Contracts\EventDispatcher\Event; /** * @author Fabien Potencier */ final class FailedMessageEvent extends Event { public function __construct( private RawMessage $message, private \Throwable $error, ) { } public function getMessage(): RawMessage { return $this->message; } public function getError(): \Throwable { return $this->error; } } PKZU }}SentMessageEvent.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mailer\Event; use Symfony\Component\Mailer\SentMessage; use Symfony\Contracts\EventDispatcher\Event; /** * @author Fabien Potencier */ final class SentMessageEvent extends Event { public function __construct(private SentMessage $message) { } public function getMessage(): SentMessage { return $this->message; } } PKZMessageEvents.phpnuW+A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mailer\Event; use Symfony\Component\Mime\RawMessage; /** * @author Fabien Potencier */ class MessageEvents { /** * @var MessageEvent[] */ private array $events = []; /** * @var array */ private array $transports = []; public function add(MessageEvent $event): void { $this->events[] = $event; $this->transports[$event->getTransport()] = true; } public function getTransports(): array { return array_keys($this->transports); } /** * @return MessageEvent[] */ public function getEvents(string $name = null): array { if (null === $name) { return $this->events; } $events = []; foreach ($this->events as $event) { if ($name === $event->getTransport()) { $events[] = $event; } } return $events; } /** * @return RawMessage[] */ public function getMessages(string $name = null): array { $events = $this->getEvents($name); $messages = []; foreach ($events as $event) { $messages[] = $event->getMessage(); } return $messages; } } PKZ..ConsoleCommandEvent.phpnuW+APKZ99uConsoleTerminateEvent.phpnuW+APKZ_W ConsoleSignalEvent.phpnuW+APKZ^OPP}ConsoleEvent.phpnuW+APKZaM ConsoleErrorEvent.phpnuW+APKiZ | ViewEvent.phpnuW+APKiZ,` "FinishRequestEvent.phpnuW+APKiZ+D$KernelEvent.phpnuW+APKiZn]==+ControllerEvent.phpnuW+APKiZ-f} p;ControllerArgumentsEvent.phpnuW+APKiZw7|~~HExceptionEvent.phpnuW+APKiZ#lNNTPTerminateEvent.phpnuW+APKiZDaTRequestEvent.phpnuW+APKiZYResponseEvent.phpnuW+APK6Z0!^AbstractEvent.phpnuW+APK6ZoF/eDocumentRenderedEvent.phpnuW+APK6ZtthDocumentPreParsedEvent.phpnuW+APK6Z /EmListenerData.phpnuW+APK6Z V2VqDocumentParsedEvent.phpnuW+APK6ZA2hێutDocumentPreRenderEvent.phpnuW+APKQrZZCCMxAttributesListener.phpnuW+APKEZdC$։ConsecutiveDescriptionListMerger.phpnuW+APKEZ#_LooseDescriptionHandler.phpnuW+APKZpܵ1 1 'FixOrphanedFootnotesAndRefsListener.phpnuW+APKZ~& & nNumberFootnotesListener.phpnuW+APKZM66ߪAnonymousFootnotesListener.phpnuW+APKZ>r cGatherFootnotesListener.phpnuW+APKZ-l5 MessageEvent.phpnuW+APKZFFailedMessageEvent.phpnuW+APKZU }}SentMessageEvent.phpnuW+APKZMessageEvents.phpnuW+APKq