Skip to content

Commit b0bebfa

Browse files
committed
up
1 parent d46ed37 commit b0bebfa

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/Context/Swoole.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class Swoole implements ContextInterface
1414
public static function get(?string $name = null, mixed $default = null): mixed
1515
{
1616
$context = Coroutine::getContext();
17+
if (!$context) {
18+
return $default;
19+
}
1720
$context->setFlags(ArrayObject::ARRAY_AS_PROPS);
1821
if ($name === null) {
1922
return $context;
@@ -57,4 +60,4 @@ public static function destroy(): void
5760
$context->exchangeArray([]);
5861
}
5962

60-
}
63+
}

0 commit comments

Comments
 (0)