| 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 T of array<string, mixed> |
| 20: | */ |
| 21: | interface Arrayable extends \JsonSerializable |
| 22: | { |
| 23: | /** |
| 24: | * Create an instance of the class from an array. |
| 25: | * |
| 26: | * @param T $data |
| 27: | * |
| 28: | * @todo See ROADMAP.md (PHP 8.5 language compatibility). |
| 29: | */ |
| 30: | public static function fromArray(array $data): static; |
| 31: | |
| 32: | /** |
| 33: | * Convert the instance to an array. |
| 34: | * |
| 35: | * @return T |
| 36: | */ |
| 37: | public function toArray(): array; |
| 38: | |
| 39: | /** |
| 40: | * Implementations substitute `\stdClass` for the empty-object case so |
| 41: | * `json_encode` emits `{}` rather than `[]`. |
| 42: | * |
| 43: | * @return array<string, mixed>|\stdClass |
| 44: | */ |
| 45: | #[\Override] |
| 46: | public function jsonSerialize(): array|\stdClass; |
| 47: | } |
| 48: |