Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #376

Open
wants to merge 1 commit into
base: 4.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public function __get($key)
public static function pullPoolConfig(&$config)
{
return [
'minActive' => Arr::pull($config, 'min_active', 0),
'maxActive' => Arr::pull($config, 'max_active', 10),
'maxWaitTime' => Arr::pull($config, 'max_wait_time', 5),
'maxIdleTime' => Arr::pull($config, 'max_idle_time', 20),
'minActive' => Arr::pull($config, 'min_active', 0),
'maxActive' => Arr::pull($config, 'max_active', 10),
'maxWaitTime' => Arr::pull($config, 'max_wait_time', 5),
'maxIdleTime' => Arr::pull($config, 'max_idle_time', 20),
'idleCheckInterval' => Arr::pull($config, 'idle_check_interval', 10),
];
}
Expand Down
6 changes: 3 additions & 3 deletions src/Sandbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Sandbox

/** @var ResetterInterface[] */
protected $resetters = [];
protected $services = [];
protected $services = [];

public function __construct(Container $app)
{
Expand Down Expand Up @@ -152,7 +152,7 @@ public function setInstance(Container $app)
$app->instance('app', $app);
$app->instance(Container::class, $app);

$reflectObject = new ReflectionObject($app);
$reflectObject = new ReflectionObject($app);
$reflectProperty = $reflectObject->getProperty('services');
$reflectProperty->setAccessible(true);
$services = $reflectProperty->getValue($app);
Expand Down Expand Up @@ -201,7 +201,7 @@ protected function setInitialServices()

foreach ($services as $service) {
if (class_exists($service) && !in_array($service, $this->services)) {
$serviceObj = new $service($app);
$serviceObj = new $service($app);
$this->services[$service] = $serviceObj;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Websocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class Websocket
*/
public function __construct(\think\App $app, Room $room, Event $event)
{
$this->app = $app;
$this->room = $room;
$this->app = $app;
$this->room = $room;
$this->event = $event;
}

Expand Down
32 changes: 16 additions & 16 deletions src/concerns/InteractsWithHttp.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function createHttpServer()
{
$this->preloadHttp();

$host = $this->getConfig('http.host');
$port = $this->getConfig('http.port');
$host = $this->getConfig('http.host');
$port = $this->getConfig('http.port');
$options = $this->getConfig('http.options', []);

$server = new Server($host, $port, false, true);
Expand Down Expand Up @@ -203,11 +203,11 @@ protected function getFiles(Request $req)
if (!Arr::isAssoc($file)) {
$files = [];
foreach ($file as $f) {
$files['name'][] = $f['name'];
$files['type'][] = $f['type'];
$files['name'][] = $f['name'];
$files['type'][] = $f['type'];
$files['tmp_name'][] = $f['tmp_name'];
$files['error'][] = $f['error'];
$files['size'][] = $f['size'];
$files['error'][] = $f['error'];
$files['size'][] = $f['size'];
}
return $files;
}
Expand Down Expand Up @@ -264,16 +264,16 @@ protected function sendIterator(Response $res, IteratorResponse $response)
protected function sendFile(Response $res, \think\Request $request, FileResponse $response)
{
$ifNoneMatch = $request->header('If-None-Match');
$ifRange = $request->header('If-Range');
$ifRange = $request->header('If-Range');

$code = $response->getCode();
$file = $response->getFile();
$eTag = $response->getHeader('ETag');
$code = $response->getCode();
$file = $response->getFile();
$eTag = $response->getHeader('ETag');
$lastModified = $response->getHeader('Last-Modified');

$fileSize = $file->getSize();
$offset = 0;
$length = -1;
$offset = 0;
$length = -1;

if ($ifNoneMatch == $eTag) {
$code = 304;
Expand All @@ -286,7 +286,7 @@ protected function sendFile(Response $res, \think\Request $request, FileResponse

if ('' === $start) {
$start = $fileSize - $end;
$end = $fileSize - 1;
$end = $fileSize - 1;
} else {
$start = (int) $start;
}
Expand All @@ -301,9 +301,9 @@ protected function sendFile(Response $res, \think\Request $request, FileResponse
} elseif ($end - $start < $fileSize - 1) {
$length = $end < $fileSize ? $end - $start + 1 : -1;
$offset = $start;
$code = 206;
$code = 206;
$response->header([
'Content-Range' => sprintf('bytes %s-%s/%s', $start, $end, $fileSize),
'Content-Range' => sprintf('bytes %s-%s/%s', $start, $end, $fileSize),
'Content-Length' => $end - $start + 1,
]);
}
Expand All @@ -329,7 +329,7 @@ protected function sendContent(Response $res, \think\Response $response)
$content = $response->getContent();
if ($content) {
$contentSize = strlen($content);
$chunkSize = 8192;
$chunkSize = 8192;

if ($contentSize > $chunkSize) {
$sendSize = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/concerns/InteractsWithQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ protected function createQueueWorkers()
$workerNum = Arr::get($options, 'worker_num', 1);

$this->addBatchWorker($workerNum, function (Process\Pool $pool) use ($options, $connection, $queue) {
$delay = Arr::get($options, 'delay', 0);
$sleep = Arr::get($options, 'sleep', 3);
$tries = Arr::get($options, 'tries', 0);
$delay = Arr::get($options, 'delay', 0);
$sleep = Arr::get($options, 'sleep', 3);
$tries = Arr::get($options, 'tries', 0);
$timeout = Arr::get($options, 'timeout', 60);

/** @var Worker $worker */
Expand Down
6 changes: 3 additions & 3 deletions src/concerns/InteractsWithRpcClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ protected function bindRpcInterface()
try {
foreach ($rpcServices as $name => $abstracts) {
$parserClass = $this->getConfig("rpc.client.{$name}.parser", JsonParser::class);
$tries = $this->getConfig("rpc.client.{$name}.tries", 2);
$middleware = $this->getConfig("rpc.client.{$name}.middleware", []);
$tries = $this->getConfig("rpc.client.{$name}.tries", 2);
$middleware = $this->getConfig("rpc.client.{$name}.middleware", []);

$parser = $this->getApplication()->make($parserClass);
$parser = $this->getApplication()->make($parserClass);
$gateway = new Gateway($this->createRpcConnector($name), $parser, $tries);

foreach ($abstracts as $abstract) {
Expand Down
2 changes: 1 addition & 1 deletion src/concerns/InteractsWithRpcConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract protected function runWithClient($callback);
protected function recv(Client $client, callable $decoder)
{
$handler = null;
$file = null;
$file = null;

while ($data = $client->recv()) {
begin:
Expand Down
2 changes: 1 addition & 1 deletion src/concerns/InteractsWithRpcServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function prepareRpcServer()

protected function bindRpcDispatcher()
{
$services = $this->getConfig('rpc.server.services', []);
$services = $this->getConfig('rpc.server.services', []);
$middleware = $this->getConfig('rpc.server.middleware', []);

$this->app->make(Dispatcher::class, [$services, $middleware]);
Expand Down
2 changes: 1 addition & 1 deletion src/concerns/InteractsWithServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function start(string $envName): void

Runtime::enableCoroutine();

$this->pool = $pool;
$this->pool = $pool;
$this->workerId = $workerId;

[$func, $name] = $this->startFuncMap[$workerId];
Expand Down
2 changes: 1 addition & 1 deletion src/concerns/InteractsWithSwooleTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function registerTables()
$tables = $this->container->make('config')->get('swoole.tables', []);

foreach ($tables as $key => $value) {
$table = new SwooleTable($value['size']);
$table = new SwooleTable($value['size']);
$columns = $value['columns'] ?? [];
foreach ($columns as $column) {
if (isset($column['size'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/concerns/InteractsWithTracing.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait InteractsWithTracing
protected function prepareTracing()
{
if (class_exists(Tracer::class)) {
$tracers = $this->container->config->get('tracing.tracers');
$tracers = $this->container->config->get('tracing.tracers');
$hasAsync = false;
foreach ($tracers as $name => $tracer) {
if (Arr::get($tracer, 'async', false)) {
Expand Down
10 changes: 5 additions & 5 deletions src/concerns/InteractsWithWebsocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public function onHandShake($req, $res)

$this->runWithBarrier(function () use ($handler, $res) {

$cid = Coroutine::getCid();
$cid = Coroutine::getCid();
$messages = 0;
$wait = false;
$wait = false;

$frame = null;
while (true) {
Expand All @@ -104,10 +104,10 @@ public function onHandShake($req, $res)
}

if (empty($frame)) {
$frame = new Frame();
$frame = new Frame();
$frame->opcode = $recv->opcode;
$frame->flags = $recv->flags;
$frame->fd = $recv->fd;
$frame->flags = $recv->flags;
$frame->fd = $recv->fd;
$frame->finish = false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/concerns/WithMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected function middleware($middleware, ...$params)

$this->middleware[] = [
'middleware' => [$middleware, $params],
'options' => &$options,
'options' => &$options,
];

return new class($options) {
Expand Down
6 changes: 3 additions & 3 deletions src/concerns/WithRpcClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ protected function bindRpcInterface()
$config = $this->app->config->get("swoole.rpc.client.{$name}", []);

$parserClass = Arr::pull($config, 'parser', JsonParser::class);
$tries = Arr::pull($config, 'tries', 2);
$middleware = Arr::pull($config, 'middleware', []);
$tries = Arr::pull($config, 'tries', 2);
$middleware = Arr::pull($config, 'middleware', []);

$parser = $this->app->make($parserClass);
$parser = $this->app->make($parserClass);
$gateway = new Gateway($config, $parser, $tries);

foreach ($abstracts as $abstract) {
Expand Down
Loading