Fix return type in abstract methods from self to static (#53)
* Change return type of abstract request methods * Change return type of `fromParams` method to `static` in request classes (cherry picked from commit 94799ab66ff60d4b2305aadb6b73aaa4c805221e) * Make request classes final and update `getParams` return types for improved type safety (cherry picked from commit d6be496f89cc0e6d30f519792d0dc902685c4178)
This commit is contained in:
parent
4b667327e7
commit
20e789d402
1 changed files with 97 additions and 46 deletions
|
|
@ -20,7 +20,7 @@ use Mcp\Schema\JsonRpc\Request;
|
|||
*
|
||||
* @author Kyrian Obikwelu <koshnawaza@gmail.com>
|
||||
*/
|
||||
class SetLogLevelRequest extends Request
|
||||
final class SetLogLevelRequest extends Request
|
||||
{
|
||||
/**
|
||||
* @param LoggingLevel $level The level of logging that the client wants to receive from the server. The server
|
||||
|
|
@ -37,7 +37,7 @@ class SetLogLevelRequest extends Request
|
|||
return 'logging/setLevel';
|
||||
}
|
||||
|
||||
protected static function fromParams(?array $params): self
|
||||
protected static function fromParams(?array $params): static
|
||||
{
|
||||
if (!isset($params['level']) || !\is_string($params['level']) || empty($params['level'])) {
|
||||
throw new InvalidArgumentException('Missing or invalid "level" parameter for "logging/setLevel".');
|
||||
|
|
@ -46,7 +46,10 @@ class SetLogLevelRequest extends Request
|
|||
return new self(LoggingLevel::from($params['level']));
|
||||
}
|
||||
|
||||
protected function getParams(): ?array
|
||||
/**
|
||||
* @return array{level: value-of<LoggingLevel>}
|
||||
*/
|
||||
protected function getParams(): array
|
||||
{
|
||||
return [
|
||||
'level' => $this->level->value,
|
||||
|
|
|
|||
Loading…
Reference in a new issue