Skip to content

Commit

Permalink
Update: 修复代码风格
Browse files Browse the repository at this point in the history
  • Loading branch information
NHZEX committed Oct 19, 2023
1 parent 4ebff3d commit 2db0c80
Show file tree
Hide file tree
Showing 43 changed files with 226 additions and 212 deletions.
9 changes: 5 additions & 4 deletions src/Components/access-control/src/AccessControl/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ class Member

protected OperationService $operationService;

public function __construct(/**
* 用户 ID.
*/
private readonly int $memberId)
public function __construct(
/**
* 用户 ID.
*/
private readonly int $memberId)
{
$this->__autoInject();
$this->memberService = App::getBean($this->memberServiceBean);
Expand Down
9 changes: 5 additions & 4 deletions src/Components/amqp/src/Pool/AMQPResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ class AMQPResource extends BasePoolResource

private bool $closed = false;

public function __construct(\Imi\Pool\Interfaces\IPool $pool, /**
* AMQP 客户端.
*/
private AbstractConnection $connection)
public function __construct(\Imi\Pool\Interfaces\IPool $pool,
/**
* AMQP 客户端.
*/
private AbstractConnection $connection)
{
parent::__construct($pool);
$this->closed = !$connection->isConnected();
Expand Down
9 changes: 5 additions & 4 deletions src/Components/amqp/src/Queue/AMQPQueueDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ class AMQPQueueDriver implements IQueueDriver
*/
private array $args = [];

public function __construct(/**
* 队列名称.
*/
protected string $name, array $config = [])
public function __construct(
/**
* 队列名称.
*/
protected string $name, array $config = [])
{
$this->traitConstruct($config);
$this->args = \func_get_args();
Expand Down
9 changes: 5 additions & 4 deletions src/Components/amqp/src/Queue/AMQPQueueDriverHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ class AMQPQueueDriverHandler implements IQueueDriver
*/
private string $timeoutQueueName = '';

public function __construct(/**
* 队列名称.
*/
protected string $name, array $config = [])
public function __construct(
/**
* 队列名称.
*/
protected string $name, array $config = [])
{
$this->traitConstruct($config);

Expand Down
9 changes: 5 additions & 4 deletions src/Components/amqp/src/Queue/QueueConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ class QueueConsumer extends BaseConsumer implements IQueueConsumer
*/
private ?\SplQueue $queue = null;

public function __construct(/**
* 本地缓存的队列长度.
*/
protected int $queueLength, array $exchanges, array $queues, array $consumers, ?string $poolName = null)
public function __construct(
/**
* 本地缓存的队列长度.
*/
protected int $queueLength, array $exchanges, array $queues, array $consumers, ?string $poolName = null)
{
parent::__construct();
$this->poolName = $poolName;
Expand Down
9 changes: 5 additions & 4 deletions src/Components/amqp/src/Queue/SwooleQueueConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ class SwooleQueueConsumer extends BaseConsumer implements IQueueConsumer
*/
private ?Channel $resultChannel = null;

public function __construct(/**
* 本地缓存的队列长度.
*/
protected int $queueLength, array $exchanges, array $queues, array $consumers, ?string $poolName = null)
public function __construct(
/**
* 本地缓存的队列长度.
*/
protected int $queueLength, array $exchanges, array $queues, array $consumers, ?string $poolName = null)
{
parent::__construct();
$this->poolName = $poolName;
Expand Down
23 changes: 13 additions & 10 deletions src/Components/grpc/src/Client/GrpcService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ class GrpcService implements IGrpcService
*/
protected GrpcInterfaceManager $interfaceManager;

public function __construct(/**
* 客户端.
*/
protected GrpcClient $client, /**
* 完整服务名称.
*/
protected string $name, /**
* 服务接口.
*/
protected ?string $interface = null)
public function __construct(
/**
* 客户端.
*/
protected GrpcClient $client,
/**
* 完整服务名称.
*/
protected string $name,
/**
* 服务接口.
*/
protected ?string $interface = null)
{
if (preg_match('/^(.+)\.([^\.]+)$/', $name, $matches) > 0)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Components/grpc/src/Client/ServiceAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public function __construct(
* 服务接口.
*/
public string $interface
)
{
) {
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Components/grpc/src/Util/ProtobufUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ public static function getMessageValue($message, array $options = [])
}
if ($message instanceof \Google\Protobuf\EnumValue)
{
return match ($enumReturnType = ($options['enumReturnType'] ?? 'value')) {
return match ($enumReturnType = ($options['enumReturnType'] ?? 'value'))
{
'value' => $message->getNumber(),
'name' => $message->getName(),
'name' => $message->getName(),
default => throw new \RuntimeException(sprintf('Unknown enumReturnType %s', $enumReturnType)),
};
}
Expand Down
2 changes: 0 additions & 2 deletions src/Components/jwt/src/Model/JWTConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ class JWTConfig
* 设为 true 则为当前时间
* 设为 false 不设置
* 其它值则直接写入.
*
* @var bool
*/
private bool $issuedAt = true;

Expand Down
9 changes: 5 additions & 4 deletions src/Components/kafka/src/Pool/KafkaResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
*/
class KafkaResource extends BasePoolResource
{
public function __construct(\Imi\Pool\Interfaces\IPool $pool, /**
* Kafka 生产者.
*/
private readonly Producer $connection)
public function __construct(\Imi\Pool\Interfaces\IPool $pool,
/**
* Kafka 生产者.
*/
private readonly Producer $connection)
{
parent::__construct($pool);
}
Expand Down
9 changes: 5 additions & 4 deletions src/Components/kafka/src/Queue/KafkaQueueDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ class KafkaQueueDriver implements IQueueDriver
*/
private array $consumers = [];

public function __construct(/**
* 队列名称.
*/
protected string $name, array $config = [])
public function __construct(
/**
* 队列名称.
*/
protected string $name, array $config = [])
{
$this->traitConstruct($config);
}
Expand Down
9 changes: 5 additions & 4 deletions src/Components/mqtt/src/Client/MQTTClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ class MQTTClient
Packet::TYPE_PINGRESP => 'ping',
];

public function __construct(array $config, /**
* 事件监听器.
*/
private readonly IMQTTClientListener $listener)
public function __construct(array $config,
/**
* 事件监听器.
*/
private readonly IMQTTClientListener $listener)
{
if (!isset($config['host']))
{
Expand Down
16 changes: 9 additions & 7 deletions src/Components/mqtt/src/imi/Server/MQTT/Message/ReceiveData.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ class ReceiveData implements IReceiveData
*/
protected ?IPEndPoint $clientAddress = null;

public function __construct(/**
* 客户端连接的标识符.
*/
protected int|string $clientId, /**
* Reactor线程ID.
*/
protected int $reactorId, protected string $data)
public function __construct(
/**
* 客户端连接的标识符.
*/
protected int|string $clientId,
/**
* Reactor线程ID.
*/
protected int $reactorId, protected string $data)
{
$this->formatData = RequestContext::getServerBean(DataParser::class)->decode($data);
}
Expand Down
30 changes: 17 additions & 13 deletions src/Components/pgsql/src/Db/Drivers/Swoole/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,23 @@ class Statement extends PgsqlBaseStatement implements IPgsqlStatement
/**
* @param mixed $queryResult
*/
public function __construct(/**
* 数据库操作对象
*/
protected ?IPgsqlDb $db, protected $queryResult, /**
* 最后执行过的SQL语句.
*/
protected string $lastSql, /**
* statement 名字.
*/
protected ?string $statementName = null, /**
* SQL 参数映射.
*/
protected ?array $sqlParamsMap = null)
public function __construct(
/**
* 数据库操作对象
*/
protected ?IPgsqlDb $db, protected $queryResult,
/**
* 最后执行过的SQL语句.
*/
protected string $lastSql,
/**
* statement 名字.
*/
protected ?string $statementName = null,
/**
* SQL 参数映射.
*/
protected ?array $sqlParamsMap = null)
{
if ($queryResult)
{
Expand Down
23 changes: 13 additions & 10 deletions src/Components/pgsql/src/Db/Drivers/SwooleNew/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ class Statement extends PgsqlBaseStatement implements IPgsqlStatement
*/
protected string $lastInsertId = '';

public function __construct(/**
* 数据库操作对象
*/
protected ?IPgsqlDb $db, protected ?PostgreSQLStatement $stmt, /**
* 最后执行过的SQL语句.
*/
protected string $lastSql, /**
* SQL 参数映射.
*/
protected ?array $sqlParamsMap = null, bool $isExecuted = false)
public function __construct(
/**
* 数据库操作对象
*/
protected ?IPgsqlDb $db, protected ?PostgreSQLStatement $stmt,
/**
* 最后执行过的SQL语句.
*/
protected string $lastSql,
/**
* SQL 参数映射.
*/
protected ?array $sqlParamsMap = null, bool $isExecuted = false)
{
if ($isExecuted)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Components/pgsql/src/Model/Cli/Model/ModelGenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,9 @@ private function parseFieldDefaultValue(?string $poolName, string $type, $defaul
{
$resultAfterExec = $default;
}
return match ($type) {

return match ($type)
{
'int', 'int2', 'int4', 'int8', 'smallint', 'bigint', 'smallserial', 'serial', 'bigserial', 'serial2', 'serial4', 'serial8' => (int) $resultAfterExec,
'bool', 'boolean' => (bool) $resultAfterExec,
'double', 'float4', 'float8' => (float) $resultAfterExec,
Expand Down
16 changes: 9 additions & 7 deletions src/Components/queue/src/Driver/RedisQueueDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ class RedisQueueDriver implements IQueueDriver

private ?string $keyName = null;

public function __construct(/**
* 队列名称.
*/
protected string $name, array $config = [])
public function __construct(
/**
* 队列名称.
*/
protected string $name, array $config = [])
{
$this->traitConstruct($config);
}
Expand Down Expand Up @@ -401,9 +402,10 @@ public function status(): QueueStatus
foreach (QueueType::getValues() as $value)
{
$data = QueueType::getData($value);
$count = match ($data['type']) {
'list' => $redis->lLen($this->getQueueKey($value)),
'zset' => $redis->zCard($this->getQueueKey($value)),
$count = match ($data['type'])
{
'list' => $redis->lLen($this->getQueueKey($value)),
'zset' => $redis->zCard($this->getQueueKey($value)),
default => throw new QueueException('Invalid type ' . $data['type']),
};
$status[strtolower(QueueType::getName($value))] = $count;
Expand Down
9 changes: 5 additions & 4 deletions src/Components/queue/src/Driver/RedisStreamQueueDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ class RedisStreamQueueDriver implements IQueueDriver

private ?string $keyName = null;

public function __construct(/**
* 队列名称.
*/
protected string $name, array $config = [])
public function __construct(
/**
* 队列名称.
*/
protected string $name, array $config = [])
{
$this->traitConstruct($config);
}
Expand Down
9 changes: 5 additions & 4 deletions src/Components/queue/src/Model/QueueConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ class QueueConfig
*/
private string $consumer = '';

public function __construct(/**
* 队列名称.
*/
private readonly string $name, array $data)
public function __construct(
/**
* 队列名称.
*/
private readonly string $name, array $data)
{
if (isset($data['driver']))
{
Expand Down
3 changes: 1 addition & 2 deletions src/Components/queue/src/Service/BaseQueueConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public function __construct(
* 队列名称.
*/
protected ?string $name = null
)
{
) {
}

/**
Expand Down
Loading

0 comments on commit 2db0c80

Please sign in to comment.