Skip to content
Merged
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
6 changes: 3 additions & 3 deletions src/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ public function stop(): void
$this->send('', $this->encode(['stop' => true]));
}

public function hasPayload(string $class = null): bool
public function hasPayload(?string $class = null): bool
{
return $this->findPayload($class) !== null;
}

public function getPayload(string $class = null): ?Payload
public function getPayload(?string $class = null): ?Payload
{
$pos = $this->findPayload($class);
if ($pos === null) {
Expand All @@ -140,7 +140,7 @@ public function getPayload(string $class = null): ?Payload
*
* @return null|int Index in {@see $this->payloads} or null if not found
*/
private function findPayload(string $class = null): ?int
private function findPayload(?string $class = null): ?int
{
// Find in existing payloads
if ($this->payloads !== []) {
Expand Down
4 changes: 2 additions & 2 deletions src/WorkerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public function stop(): void;
*
* @return bool Returns {@see true} if worker is ready to accept new payload.
*/
public function hasPayload(string $class = null): bool;
public function hasPayload(?string $class = null): bool;

/**
* @param class-string<Payload>|null $class
*
* @return Payload|null Returns {@see null} if worker is not ready to accept new payload and has no cached payload
* of the given type.
*/
public function getPayload(string $class = null): ?Payload;
public function getPayload(?string $class = null): ?Payload;
}