From 603fee6463d0f77f72a3ad43a0c2bd7f7faf0abf Mon Sep 17 00:00:00 2001 From: inhere Date: Sun, 13 Sep 2020 23:44:32 +0800 Subject: [PATCH] fix: swoft-cloud/swoft/issues/1297 rpc client version invalid error --- src/aop/test/unit/AopTest.php | 3 --- src/proxy/src/Proxy.php | 10 ++++++---- .../src/Annotation/Parser/ReferenceParser.php | 9 +++++---- src/rpc-client/src/Exception/RpcClientException.php | 4 ++-- src/rpc-client/src/Proxy.php | 7 ++++--- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/aop/test/unit/AopTest.php b/src/aop/test/unit/AopTest.php index 2a92ec109..fe4ae6f1b 100644 --- a/src/aop/test/unit/AopTest.php +++ b/src/aop/test/unit/AopTest.php @@ -1,9 +1,7 @@ getVersion(); + $className = Proxy::newClassName($propClassType, $refVersion); $this->definitions[$className] = [ 'class' => $className, ]; - ReferenceRegister::register($className, $annotationObject->getPool(), $annotationObject->getVersion()); + ReferenceRegister::register($className, $refObject->getPool(), $refVersion); return [$className, true]; } } diff --git a/src/rpc-client/src/Exception/RpcClientException.php b/src/rpc-client/src/Exception/RpcClientException.php index 1cad8fb26..392899369 100644 --- a/src/rpc-client/src/Exception/RpcClientException.php +++ b/src/rpc-client/src/Exception/RpcClientException.php @@ -10,13 +10,13 @@ namespace Swoft\Rpc\Client\Exception; -use Exception; +use RuntimeException; /** * Class RpcClientException * * @since 2.0 */ -class RpcClientException extends Exception +class RpcClientException extends RuntimeException { } diff --git a/src/rpc-client/src/Proxy.php b/src/rpc-client/src/Proxy.php index 3e7afaa8d..096be6020 100644 --- a/src/rpc-client/src/Proxy.php +++ b/src/rpc-client/src/Proxy.php @@ -27,12 +27,13 @@ class Proxy { /** * @param string $className + * @param string $version Rpc version. For resolve https://github.com/swoft-cloud/swoft/issues/1297 * * @return string - * @throws RpcClientException * @throws ProxyException + * @throws RpcClientException */ - public static function newClassName(string $className): string + public static function newClassName(string $className, string $version): string { if (!interface_exists($className)) { throw new RpcClientException('`@var` for `@Reference` must be exist interface!'); @@ -41,6 +42,6 @@ public static function newClassName(string $className): string $proxyId = sprintf('IGNORE_%s', Str::getUniqid()); $visitor = new ProxyVisitor($proxyId); - return BaseProxy::newClassName($className, $visitor); + return BaseProxy::newClassName($className, $visitor, $version); } }