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
|
|
@ -36,7 +36,7 @@ abstract class Request implements HasMethodInterface, MessageInterface
|
|||
/**
|
||||
* @param RequestData $data
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
public static function fromArray(array $data): static
|
||||
{
|
||||
if (($data['jsonrpc'] ?? null) !== MessageInterface::JSONRPC_VERSION) {
|
||||
throw new InvalidArgumentException('Invalid or missing "jsonrpc" version for Request.');
|
||||
|
|
@ -68,7 +68,7 @@ abstract class Request implements HasMethodInterface, MessageInterface
|
|||
/**
|
||||
* @param array<string, mixed>|null $params
|
||||
*/
|
||||
abstract protected static function fromParams(?array $params): self;
|
||||
abstract protected static function fromParams(?array $params): static;
|
||||
|
||||
public function getId(): string|int
|
||||
{
|
||||
|
|
@ -97,7 +97,7 @@ abstract class Request implements HasMethodInterface, MessageInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>|null
|
||||
* @return array<non-empty-string, mixed>|null
|
||||
*/
|
||||
abstract protected function getParams(): ?array;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue