Skip to content

Commit bac7277

Browse files
committed
foramt codes
1 parent 946e0ab commit bac7277

7 files changed

Lines changed: 15 additions & 29 deletions

File tree

src/rpc-client/src/Annotation/Parser/ReferenceParser.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ public function parse(int $type, $annotationObject): array
4343
$propClassType = $phpReader->getPropertyClass($reflectProperty);
4444

4545
if (empty($propClassType)) {
46-
throw new RpcClientException(
47-
sprintf('`@Reference`(%s->%s) must to define `@var xxx`', $this->className, $this->propertyName)
48-
);
46+
throw new RpcClientException(sprintf('`@Reference`(%s->%s) must to define `@var xxx`', $this->className,
47+
$this->propertyName));
4948
}
5049

5150
$className = Proxy::newClassName($propClassType);
@@ -57,4 +56,4 @@ public function parse(int $type, $annotationObject): array
5756
ReferenceRegister::register($className, $annotationObject->getPool(), $annotationObject->getVersion());
5857
return [$className, true];
5958
}
60-
}
59+
}

src/rpc-client/src/Client.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ public function getSetting(): array
9797
public function getPacket(): PacketInterface
9898
{
9999
if (empty($this->packet)) {
100-
throw new RpcClientException(
101-
sprintf('Client(%s) packet can not be null', __CLASS__)
102-
);
100+
throw new RpcClientException(sprintf('Client(%s) packet can not be null', __CLASS__));
103101
}
104102

105103
return $this->packet;

src/rpc-client/src/Concern/ServiceTrait.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ protected function __proxyCall(string $interfaceClass, string $methodName, array
4949

5050
$protocol = Protocol::new($version, $interfaceClass, $methodName, $params, $ext);
5151
$data = $packet->encode($protocol);
52-
$message = sprintf(
53-
'Rpc call failed.interface=%s method=%s pool=%s version=%s',
54-
$interfaceClass, $methodName, $poolName, $version
55-
);
52+
$message = sprintf('Rpc call failed.interface=%s method=%s pool=%s version=%s', $interfaceClass, $methodName,
53+
$poolName, $version);
5654

5755
$result = $this->sendAndRecv($connection, $data, $message);
5856
$connection->release();
@@ -64,10 +62,8 @@ protected function __proxyCall(string $interfaceClass, string $methodName, array
6462
$errorData = $response->getError()->getData();
6563

6664
// Record rpc error message
67-
$errorMsg = sprintf(
68-
'Rpc call error!code=%d message=%s data=%s pool=%s version=%s',
69-
$code, $message, JsonHelper::encode($errorData), $poolName, $version
70-
);
65+
$errorMsg = sprintf('Rpc call error!code=%d message=%s data=%s pool=%s version=%s', $code, $message,
66+
JsonHelper::encode($errorData), $poolName, $version);
7167

7268
Error::log($errorMsg);
7369

src/rpc-client/src/Connection.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Swoft\Log\Debug;
99
use Swoft\Rpc\Client\Client as RpcClient;
1010
use Swoft\Rpc\Client\Contract\ConnectionInterface;
11-
use Swoft\Rpc\Client\Contract\ProviderInterface;
1211
use Swoft\Rpc\Client\Exception\RpcClientException;
1312
use Swoft\Rpc\Contract\PacketInterface;
1413
use Swoft\Stdlib\Helper\JsonHelper;
@@ -141,7 +140,7 @@ public function recv()
141140
private function getHostPort(): array
142141
{
143142
$provider = $this->client->getProvider();
144-
if (!$provider || !$provider instanceof ProviderInterface) {
143+
if (!$provider) {
145144
return [$this->client->getHost(), $this->client->getPort()];
146145
}
147146

src/rpc-client/src/Pool.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ class Pool extends AbstractPool
2525
public function createConnection(): ConnectionInterface
2626
{
2727
if (empty($this->client)) {
28-
throw new RpcClientException(
29-
sprintf('Pool(%s) client can not be null!', __CLASS__)
30-
);
28+
throw new RpcClientException(sprintf('Pool(%s) client can not be null!', __CLASS__));
3129
}
3230

3331
return $this->client->createConnection($this);

src/rpc-client/src/Proxy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public static function newClassName(string $className): string
3030
throw new RpcClientException('`@var` for `@Reference` must be exist interface!');
3131
}
3232

33-
$proxyId = sprintf('IGNORE_%s', Str::getUniqid());
34-
$visitor = new ProxyVisitor($proxyId);
33+
$proxyId = sprintf('IGNORE_%s', Str::getUniqid());
34+
$visitor = new ProxyVisitor($proxyId);
3535

3636
return BaseProxy::newClassName($className, $visitor);
3737
}

src/rpc-client/src/ReferenceRegister.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ public static function getPool(string $className): string
4646
{
4747
$pool = self::$references[$className]['pool'] ?? '';
4848
if (empty($pool)) {
49-
throw new RpcClientException(
50-
sprintf('`@Reference` pool (%s) is not exist!', $className)
51-
);
49+
throw new RpcClientException(sprintf('`@Reference` pool (%s) is not exist!', $className));
5250
}
5351

5452
return $pool;
@@ -64,11 +62,9 @@ public static function getVersion(string $className): string
6462
{
6563
$version = self::$references[$className]['version'] ?? '';
6664
if ($version == '') {
67-
throw new RpcClientException(
68-
sprintf('`@Reference` version(%s) is not exist!', $className)
69-
);
65+
throw new RpcClientException(sprintf('`@Reference` version(%s) is not exist!', $className));
7066
}
7167

7268
return $version;
7369
}
74-
}
70+
}

0 commit comments

Comments
 (0)