MCP PHP SDK

HandlerResolver

Utility class to validate and resolve MCP element handlers.

Tags
author

Kyrian Obikwelu koshnawaza@gmail.com

Table of Contents

Methods

resolve()  : ReflectionMethod|ReflectionFunction
Validates and resolves a handler to a ReflectionMethod or ReflectionFunction instance.

Methods

resolve()

Validates and resolves a handler to a ReflectionMethod or ReflectionFunction instance.

public static resolve(Closure|array{0: string, 1: string}|string $handler) : ReflectionMethod|ReflectionFunction

A handler can be:

  • A Closure: function() { ... }
  • An array: [ClassName::class, 'methodName'] (instance method)
  • An array: [ClassName::class, 'staticMethod'] (static method, if callable)
  • A string: InvokableClassName::class (which will resolve to its '__invoke' method)
Parameters
$handler : Closure|array{0: string, 1: string}|string

the handler to resolve

Tags
throws
InvalidArgumentException

If the handler format is invalid, the class/method doesn't exist, or the method is unsuitable (e.g., private, abstract).

Return values
ReflectionMethod|ReflectionFunction

        
On this page

Search results