1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus MCP SDK package.
7: *
8: * (c) 2026 John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9: *
10: * For the full copyright and license information, please view
11: * the LICENSE file that was distributed with this source code.
12: */
13:
14: namespace Nexus\Mcp\Core\Schema;
15:
16: /**
17: * Interface for classes that can be converted to and from arrays.
18: *
19: * @template-covariant T of array<string, mixed> = array<string, mixed>
20: */
21: interface Arrayable extends \JsonSerializable
22: {
23: /**
24: * Create an instance of the class from an array.
25: *
26: * @template TData of array<string, mixed>
27: *
28: * @param TData $data
29: *
30: * @todo See ROADMAP.md (PHP 8.5 language compatibility).
31: */
32: public static function fromArray(array $data): static;
33:
34: /**
35: * Convert the instance to an array.
36: *
37: * @return T
38: */
39: public function toArray(): array;
40:
41: /**
42: * Implementations substitute `\stdClass` for the empty-object case so
43: * `json_encode` emits `{}` rather than `[]`.
44: *
45: * @return array<string, mixed>|\stdClass
46: */
47: #[\Override]
48: public function jsonSerialize(): array|\stdClass;
49: }
50: