Optimized code for identifer established by the rpc client that must contain a string,number or null if included. (#5901)

This commit is contained in:
李铭昕 2023-07-04 09:56:13 +08:00 committed by GitHub
parent bea995fb37
commit e736786d15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 7 deletions

View File

@ -34,6 +34,7 @@
- [#5866](https://github.com/hyperf/hyperf/pull/5866) Use `StrCache` instead of `Str` in special cases.
- [#5872](https://github.com/hyperf/hyperf/pull/5872) Avoid to execute the refresh callback more than once when calling `refresh()` multi times.
- [#5879](https://github.com/hyperf/hyperf/pull/5879) [#5878](https://github.com/hyperf/hyperf/pull/5878) Improve `Command`.
- [#5901](https://github.com/hyperf/hyperf/pull/5901) Optimized code for identifer established by the rpc client that must contain a string,number or null if included.
## Removed

View File

@ -102,7 +102,7 @@ abstract class AbstractServiceClient
return $this->pathGenerator->generate($this->serviceName, $methodName);
}
protected function __generateData(string $methodName, array $params, ?string $id)
protected function __generateData(string $methodName, array $params, null|int|string $id)
{
return $this->dataFormatter->formatRequest(new Request($this->__generateRpcPath($methodName), $params, $id));
}

View File

@ -13,11 +13,11 @@ namespace Hyperf\Rpc;
class ErrorResponse
{
public function __construct(protected ?string $id, protected int $code, protected string $message, protected mixed $exception)
public function __construct(protected null|int|string $id, protected int $code, protected string $message, protected mixed $exception)
{
}
public function getId(): ?string
public function getId(): null|int|string
{
return $this->id;
}

View File

@ -13,7 +13,7 @@ namespace Hyperf\Rpc;
class Request
{
public function __construct(protected string $path, protected array $params, protected ?string $id = null)
public function __construct(protected string $path, protected array $params, protected null|int|string $id = null)
{
}
@ -33,7 +33,7 @@ class Request
return $this->params;
}
public function getId(): ?string
public function getId(): null|int|string
{
return $this->id;
}

View File

@ -13,11 +13,11 @@ namespace Hyperf\Rpc;
class Response
{
public function __construct(protected ?string $id, protected mixed $result)
public function __construct(protected null|int|string $id, protected mixed $result)
{
}
public function getId(): ?string
public function getId(): null|int|string
{
return $this->id;
}