MCP PHP SDK

HandlerResolver

Utility class to validate and resolve MCP element handlers.

Tags
phpstan-import-type

Handler from ElementReference

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(Handler $handler) : ReflectionMethod|ReflectionFunction

A handler can be:

  • A Closure: function() { ... }
  • An array: [ClassName::class, 'methodName'] (resolved on a new or container-provided instance)
  • An array: [$instance, 'methodName'] (method on a pre-built object instance)
  • An array: [ClassName::class, 'staticMethod'] (static method, if callable)
  • A string: InvokableClassName::class (which will resolve to its '__invoke' method)
Parameters
$handler : Handler

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