SchemaBuilder
Less than 1 minute
SchemaBuilder
class SchemaBuilderConstants
TYPE_MAP
private const TYPE_MAP = array (
'string' => 'string',
'int' => 'integer',
'float' => 'number',
'bool' => 'boolean',
'array' => 'array',
'iterable' => 'array',
'object' => 'object',
'null' => 'null',
)Methods
__construct
private __construct(): voidforFunction
Builds the inputSchema for a tool from its parameters.
public forFunction(\ReflectionFunctionAbstract $function): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$function | ReflectionFunctionAbstract | the tool implementation |
forParameter
Builds the schema for a single parameter.
public forParameter(\ReflectionParameter $parameter): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$parameter | ReflectionParameter |
refine
Applies #[Param] refinements over a generated schema.
private refine(array $schema, Param $param): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$schema | array | |
$param | Hazaar\MCP\Attribute\Param |
forType
Maps a reflected type onto a JSON Schema fragment.
private forType(?\ReflectionType $type): arrayReturns: array
An untyped or mixed parameter yields the empty schema, which accepts anything.
Parameters
| Parameter | Type | Description |
|---|---|---|
$type | ReflectionType |
forClass
Maps a class-typed parameter onto a schema fragment.
private forClass(string $class): arrayReturns: array
Backed enums are the case worth handling: they are the one place PHP expresses a closed value set that JSON Schema can represent exactly, which meaningfully constrains what a model sends.
Parameters
| Parameter | Type | Description |
|---|---|---|
$class | string |
Generated by Hazaar API Doc Generator on Sun, 23 Aug 2026 10:49:44 +0000