ReferenceHandler implements ReferenceHandlerInterface
FinalYes
Tags
Table of Contents
Interfaces
- ReferenceHandlerInterface
- Interface for handling execution of MCP elements.
Properties
- $container : ContainerInterface|null
Methods
- __construct() : mixed
- handle() : mixed
- Handles execution of an MCP element reference.
- castArgumentType() : mixed
- Attempts type casting based on ReflectionParameter type hints.
- castToArray() : array<int, mixed>
- Helper to cast strictly to array.
- castToBoolean() : bool
- Helper to cast strictly to boolean.
- castToFloat() : float
- Helper to cast strictly to float.
- castToInt() : int
- Helper to cast strictly to integer.
- getClassInstance() : object
- getReflectionForCallable() : ReflectionMethod|ReflectionFunction
- Gets a ReflectionMethod or ReflectionFunction for a callable.
- prepareArguments() : array<int, mixed>
Properties
$container read-only
private
ContainerInterface|null
$container
= null
Methods
__construct()
public
__construct([ContainerInterface|null $container = null ]) : mixed
Parameters
- $container : ContainerInterface|null = null
handle()
Handles execution of an MCP element reference.
public
handle(ElementReference $reference, array<string, mixed> $arguments) : mixed
Parameters
- $reference : ElementReference
-
the element reference to execute
- $arguments : array<string, mixed>
Return values
mixed —the result of the element execution
castArgumentType()
Attempts type casting based on ReflectionParameter type hints.
private
castArgumentType(mixed $argument, ReflectionParameter $parameter) : mixed
Parameters
- $argument : mixed
- $parameter : ReflectionParameter
Tags
castToArray()
Helper to cast strictly to array.
private
castToArray(mixed $argument) : array<int, mixed>
Parameters
- $argument : mixed
Return values
array<int, mixed>castToBoolean()
Helper to cast strictly to boolean.
private
castToBoolean(mixed $argument) : bool
Parameters
- $argument : mixed
Return values
boolcastToFloat()
Helper to cast strictly to float.
private
castToFloat(mixed $argument) : float
Parameters
- $argument : mixed
Return values
floatcastToInt()
Helper to cast strictly to integer.
private
castToInt(mixed $argument) : int
Parameters
- $argument : mixed
Return values
intgetClassInstance()
private
getClassInstance(string $className) : object
Parameters
- $className : string
Return values
objectgetReflectionForCallable()
Gets a ReflectionMethod or ReflectionFunction for a callable.
private
getReflectionForCallable(callable $handler, SessionInterface $session) : ReflectionMethod|ReflectionFunction
Parameters
- $handler : callable
- $session : SessionInterface
Return values
ReflectionMethod|ReflectionFunctionprepareArguments()
private
prepareArguments(ReflectionFunctionAbstract $reflection, array<string, mixed> $arguments) : array<int, mixed>
Parameters
- $reflection : ReflectionFunctionAbstract
- $arguments : array<string, mixed>