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
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion UPGRADE-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions src/RevisionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down