for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Tomaj\Hermes;
use Ramsey\Uuid\Uuid;
class Message implements MessageInterface
{
/**
* @var string
*/
private $type;
* @var array
private $payload;
private $messageId;
* @var float
private $created;
private $executeAt;
* @var int
private $retries;
* Native implementation of message.
*
* @var string $type
* @var array $payload
* @var string $messageId
* @var float $created timestamp (microtime(true))
* @var float $executeAt timestamp (microtime(true))
* @var int $retries
public function __construct(string $type, array $payload = null, string $messageId = null, float $created = null, float $executeAt = null, int $retries = 0)
$this->messageId = $messageId;
if (!$messageId) {
try {
$this->messageId = Uuid::uuid4()->toString();
} catch (\Exception $e) {
$this->messageId = rand(10000, 99999999);
$messageId
string
rand(10000, 99999999)
integer
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.
$answer = 42; $correct = false; $correct = (bool) $answer;
}
$this->created = $created;
if (!$created) {
$this->created = microtime(true);
$this->type = $type;
$this->payload = $payload;
$this->executeAt = $executeAt;
$executeAt
double
$this->retries = $retries;
* {@inheritdoc}
public function getId(): string
return $this->messageId;
public function getCreated(): float
return $this->created;
public function getExecuteAt(): ?float
return $this->executeAt;
public function getType(): string
return $this->type;
public function getPayload(): ?array
return $this->payload;
public function getRetries(): int
return $this->retries;
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.