Use constant for gracefully shutdown value

This commit is contained in:
2021-01-20 18:38:48 +03:00
parent 46f0e8bea5
commit c7970f9902
2 changed files with 5 additions and 3 deletions

View File

@@ -8,6 +8,8 @@ use Generator;
final class Subscriber extends Reader
{
public const STOP = true;
/**
* @psalm-return Generator<int, Envelope|null, true|null, void>
*/
@@ -20,14 +22,14 @@ final class Subscriber extends Reader
$message = $this->consume($timeout);
if (null === $message) {
if (true === yield null) {
if (self::STOP === yield null) {
break;
}
continue;
}
if (true === yield new Envelope($message, $this)) {
if (self::STOP === yield new Envelope($message, $this)) {
break;
}