PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.3
3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 All 196 releases
convertkit / vendor / wordpress / php-mcp-schema / src / Common / Protocol / DTO / CancelledNotification.php

CancelledNotification.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 3.4.3, at vendor/wordpress/php-mcp-schema/src/Common/Protocol/DTO/CancelledNotification.php

107 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Common\Protocol\DTO;
6
7 use WP\McpSchema\Common\JsonRpc\DTO\JSONRPCNotification;
8 use WP\McpSchema\Common\Protocol\Union\ClientNotificationInterface;
9 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
10 use WP\McpSchema\Server\Lifecycle\Union\ServerNotificationInterface;
11
12 /**
13 * This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
14 *
15 * The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.
16 *
17 * This notification indicates that the result will be unused, so any associated processing SHOULD cease.
18 *
19 * A client MUST NOT attempt to cancel its `initialize` request.
20 *
21 * For task cancellation, use the `tasks/cancel` request instead of this notification.
22 *
23 * @since 2024-11-05
24 * @last-updated 2025-11-25 (modified property: params)
25 *
26 * @mcp-domain Common
27 * @mcp-subdomain Protocol
28 * @mcp-version 2025-11-25
29 */
30 class CancelledNotification extends JSONRPCNotification implements ClientNotificationInterface, ServerNotificationInterface
31 {
32 use ValidatesRequiredFields;
33
34 public const METHOD = 'notifications/cancelled';
35
36 public const DISCRIMINATOR_FIELD = 'method';
37 public const DISCRIMINATOR_VALUE = 'notifications/cancelled';
38
39 /**
40 * @var \WP\McpSchema\Common\Protocol\DTO\CancelledNotificationParams
41 */
42 protected CancelledNotificationParams $typedParams;
43
44 /**
45 * @param '2.0' $jsonrpc @since 2025-11-25
46 * @param \WP\McpSchema\Common\Protocol\DTO\CancelledNotificationParams $params @since 2024-11-05
47 */
48 public function __construct(
49 string $jsonrpc,
50 CancelledNotificationParams $params
51 ) {
52 parent::__construct(self::METHOD, $jsonrpc, null);
53 $this->typedParams = $params;
54 }
55
56 /**
57 * Creates an instance from an array.
58 *
59 * @param array{
60 * jsonrpc: '2.0',
61 * method: 'notifications/cancelled',
62 * params: array<string, mixed>|\WP\McpSchema\Common\Protocol\DTO\CancelledNotificationParams
63 * } $data
64 * @phpstan-param array<string, mixed> $data
65 * @return self
66 */
67 public static function fromArray(array $data): self
68 {
69 self::assertRequired($data, ['jsonrpc', 'params']);
70
71 /** @var '2.0' $jsonrpc */
72 $jsonrpc = self::asString($data['jsonrpc']);
73
74 /** @var \WP\McpSchema\Common\Protocol\DTO\CancelledNotificationParams $params */
75 $params = is_array($data['params'])
76 ? CancelledNotificationParams::fromArray(self::asArray($data['params']))
77 : $data['params'];
78
79 return new self(
80 $jsonrpc,
81 $params
82 );
83 }
84
85 /**
86 * Converts the instance to an array.
87 *
88 * @return array<string, mixed>
89 */
90 public function toArray(): array
91 {
92 $result = parent::toArray();
93
94 $result['params'] = $this->typedParams->toArray();
95
96 return $result;
97 }
98
99 /**
100 * @return \WP\McpSchema\Common\Protocol\DTO\CancelledNotificationParams
101 */
102 public function getTypedParams(): CancelledNotificationParams
103 {
104 return $this->typedParams;
105 }
106 }
107