Skip to content

Commit 44b87a7

Browse files
author
tourze-ci
committed
chore(symfony-aop-bundle): 移除不必要的依赖并简化代码
1 parent 89c9afa commit 44b87a7

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/Model/ProcessContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function getPid(): int
1818
public static function instance(int $pid): ProcessContext
1919
{
2020
if (!isset(static::$instances[$pid])) {
21-
static::$instances[$pid] = new static($pid);
21+
static::$instances[$pid] = new self($pid);
2222
}
2323
return static::$instances[$pid];
2424
}

src/Service/ContextService.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
use Symfony\Component\HttpKernel\KernelEvents;
99
use Symfony\Contracts\Service\ResetInterface;
1010
use Tourze\Symfony\Aop\Model\ProcessContext;
11-
use Workerman\Timer;
12-
use Workerman\Worker;
1311

1412
/**
1513
* 上下文管理
@@ -42,7 +40,7 @@ public function isCoroutineRuntime(): bool
4240
*/
4341
public function isWorkerman(): bool
4442
{
45-
return Worker::$pidFile !== '';
43+
return class_exists(\Workerman\Worker::class) && \Workerman\Worker::$pidFile !== '';
4644
}
4745

4846
public function isSwoole(): bool
@@ -78,7 +76,7 @@ public function defer(callable $callback): void
7876
}
7977

8078
if ($this->isWorkerman()) {
81-
Timer::add(0.001, $callback, persistent: false);
79+
\Workerman\Timer::add(0.001, $callback, persistent: false);
8280
return;
8381
}
8482

0 commit comments

Comments
 (0)