diff --git a/README.md b/README.md index 09b4472..6dc2859 100644 --- a/README.md +++ b/README.md @@ -119,23 +119,23 @@ use Hostnet\Component\EntityRevision\RevisionInterface; class Revision implements RevisionInterface { #[ORM\...] - private $author; + private ?string $author; #[ORM\...] - private $created_at; + private \DateTimeInterface $created_at; - public function __construct($author, \DateTime $created_at) + public function __construct(?string $author, \DateTimeInterface $created_at) { $this->author = $author; $this->created_at = $created_at; } - - public function getUser() - { + + public function getUser(): ?string + { return $this->author; } - public function getCreatedAt() + public function getCreatedAt(): \DateTimeInterface { return $this->created_at; } @@ -188,17 +188,15 @@ The factory is responsible for providing a revision Entity. You're free to fill namespace Acme\Bundle\AcmeBundle; use Hostnet\Component\EntityRevision\Factory\RevisionFactoryInterface; +use Hostnet\Component\EntityRevision\RevisionInterface; class AcmeRevisionFactory implements RevisionFactoryInterface { - private $author; - - public function __construct($author) + public function __construct(private string $author) { - $this->author = $author; } - public function createRevision(\DateTime $created_at) + public function createRevision(\DateTime $created_at): RevisionInterface { return new Revision($this->author, $created_at); } diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md index 7d389d8..b484e4f 100644 --- a/UPGRADE-2.0.md +++ b/UPGRADE-2.0.md @@ -16,7 +16,7 @@ UPGRADE FROM 1.x to 2.0 matching return types: - `RevisionableInterface::setRevision()`: `static` (now fluent, must `return $this;`) - `RevisionableInterface::getRevision()`: `RevisionInterface` - - `RevisionInterface::getUser()`: `string` + - `RevisionInterface::getUser()`: `?string` - `RevisionInterface::getCreatedAt()`: `\DateTimeInterface` - `RevisionFactoryInterface::createRevision()`: `RevisionInterface` (no longer nullable) diff --git a/src/RevisionInterface.php b/src/RevisionInterface.php index 42489f6..0cd1a7e 100644 --- a/src/RevisionInterface.php +++ b/src/RevisionInterface.php @@ -9,9 +9,9 @@ interface RevisionInterface { /** - * Return the user that created the revision. + * Return the user that created the revision, or null if there is none. */ - public function getUser(): string; + public function getUser(): ?string; /** * Return the date on which the revision was created.