[Schema] Fix: correct Resource type hints in ListResourcesResult (#191)

* fix: correct Resource type hints in ListResourcesResult

* fix: phpstan errors

* fix: phpstan errors
This commit is contained in:
Kyrian Obikwelu 2025-12-20 08:49:29 +01:00 • committed by GitHub
commit 3818173d2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,20 +14,20 @@ namespace Mcp\Schema\Result;
use Mcp\Exception\InvalidArgumentException;
use Mcp\Schema\JsonRpc\Response;
use Mcp\Schema\JsonRpc\ResultInterface;
use Mcp\Schema\Resource;
use Mcp\Schema\Resource as ResourceSchema;
/**
* The server's response to a resources/list request from the client.
*
* @phpstan-import-type ResourceData from Resource
* @phpstan-import-type ResourceData from ResourceSchema
*
* @author Kyrian Obikwelu <koshnawaza@gmail.com>
*/
class ListResourcesResult implements ResultInterface
{
/**
* @param array<resource> $resources the list of resource definitions
* @param string|null $nextCursor An opaque token representing the pagination position after the last returned result.
* @param array<ResourceSchema> $resources the list of resource definitions
* @param string|null $nextCursor An opaque token representing the pagination position after the last returned result.
*
* If present, there may be more results available.
*/
@ -50,14 +50,14 @@ class ListResourcesResult implements ResultInterface
}
return new self(
array_map(fn (array $resource) => Resource::fromArray($resource), $data['resources']),
array_map(fn (array $resource) => ResourceSchema::fromArray($resource), $data['resources']),
$data['nextCursor'] ?? null
);
}
/**
* @return array{
* resources: array<resource>,
* resources: array<ResourceSchema>,
* nextCursor?: string,
* }
*/