diff --git a/src/Message/PlainMessage.php b/src/Message/PlainMessage.php index 00590424..a2acf1bb 100644 --- a/src/Message/PlainMessage.php +++ b/src/Message/PlainMessage.php @@ -9,18 +9,15 @@ /** * Simple message that gets you started. * It has a name and an array of arguments. - * It does not enforce any types or properties so be careful on relying them + * It does not enforce any types or properties so be careful relying on them * being there. */ final class PlainMessage implements Message, \ArrayAccess { - private $name; - private $arguments; + private string $name; + private array $arguments; - /** - * @param string $name - */ - public function __construct($name, array $arguments = []) + public function __construct(string $name, array $arguments = []) { $this->name = $name; $this->arguments = $arguments; @@ -29,59 +26,48 @@ public function __construct($name, array $arguments = []) /** * {@inheritdoc} */ - public function getName() + public function getName() : string { return $this->name; } - /** - * @return array - */ - public function all() + public function all() : array { return $this->arguments; } /** * Returns the argument if found or null. - * - * @param string $name - * - * @return mixed */ - public function get($name) + public function get(string $name) : mixed { return $this->has($name) ? $this->arguments[$name] : null; } /** * Checks whether the arguments contain the given key. - * - * @param string $name - * - * @return bool */ - public function has($name) + public function has(string $name) : bool { return \array_key_exists($name, $this->arguments); } - public function offsetGet($offset) + public function offsetGet(mixed $offset) : mixed { return $this->get($offset); } - public function offsetExists($offset) + public function offsetExists(mixed $offset) : bool { return $this->has($offset); } - public function offsetSet($offset, $value): void + public function offsetSet(mixed $offset, mixed $value): void { throw new \LogicException('Message is immutable'); } - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { throw new \LogicException('Message is immutable'); } diff --git a/src/Queue/PersistentQueue.php b/src/Queue/PersistentQueue.php index 6057a05e..d6d9cc5d 100644 --- a/src/Queue/PersistentQueue.php +++ b/src/Queue/PersistentQueue.php @@ -7,23 +7,21 @@ use Bernard\Driver; use Bernard\Envelope; use Bernard\Serializer; +use SplObjectStorage; class PersistentQueue extends AbstractQueue { - protected $driver; - protected $serializer; - protected $receipts; - - /** - * @param string $name - */ - public function __construct($name, Driver $driver, Serializer $serializer) + protected Driver $driver; + protected Serializer $serializer; + protected SplObjectStorage $receipts; + + public function __construct(string $name, Driver $driver, Serializer $serializer) { parent::__construct($name); $this->driver = $driver; $this->serializer = $serializer; - $this->receipts = new \SplObjectStorage(); + $this->receipts = new SplObjectStorage(); $this->register(); } @@ -41,7 +39,7 @@ public function register(): void /** * {@inheritdoc} */ - public function count() + public function count() : int { $this->errorIfClosed();