Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
24 lines
489 B
PHP
24 lines
489 B
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace LIT\MCP\Abilities;
|
||
|
||
use stdClass;
|
||
|
||
/**
|
||
* PHP encodes an empty array as JSON [] – for schema type "object" the client
|
||
* must see {}. WordPress' output validation accepts stdClass for objects.
|
||
*/
|
||
final class JsonMap
|
||
{
|
||
/**
|
||
* @param array<string, mixed> $map
|
||
* @return array<string, mixed>|stdClass
|
||
*/
|
||
public static function of(array $map): array|stdClass
|
||
{
|
||
return $map === [] ? new stdClass() : $map;
|
||
}
|
||
}
|