diff --git a/src/Worker.php b/src/Worker.php index 16a7281..1fdf43d 100644 --- a/src/Worker.php +++ b/src/Worker.php @@ -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) { @@ -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 !== []) { diff --git a/src/WorkerInterface.php b/src/WorkerInterface.php index 6cde848..af852fe 100644 --- a/src/WorkerInterface.php +++ b/src/WorkerInterface.php @@ -51,7 +51,7 @@ 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|null $class @@ -59,5 +59,5 @@ public function hasPayload(string $class = null): bool; * @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; }