Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Null fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
theUniC committed Apr 2, 2021
1 parent 0f53d09 commit c801da5
Show file tree
Hide file tree
Showing 47 changed files with 163 additions and 261 deletions.
2 changes: 1 addition & 1 deletion Composer/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use FOS\MessageBundle\ModelManager\MessageManagerInterface;
use FOS\MessageBundle\ModelManager\ThreadManagerInterface;

final class Composer implements ComposerInterface
class Composer implements ComposerInterface
{
public function __construct(
private MessageManagerInterface $messageManager,
Expand Down
2 changes: 1 addition & 1 deletion Deleter/Deleter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Thibault Duplessis <[email protected]>
*/
final class Deleter implements DeleterInterface
class Deleter implements DeleterInterface
{
public function __construct(
private AuthorizerInterface $authorizer,
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* This class defines the configuration information for the bundle.
*/
class Configuration implements ConfigurationInterface
final class Configuration implements ConfigurationInterface
{
/**
* Generates the configuration tree.
Expand Down
8 changes: 4 additions & 4 deletions Entity/MessageMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

abstract class MessageMetadata extends BaseMessageMetadata
{
protected int $id;
protected MessageInterface $message;
protected ?int $id = null;
protected ?MessageInterface $message = null;

public function getId(): int
public function getId(): ?int
{
return $this->id;
}

public function getMessage(): MessageInterface
public function getMessage(): ?MessageInterface
{
return $this->message;
}
Expand Down
10 changes: 6 additions & 4 deletions Entity/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use FOS\MessageBundle\Model\ParticipantInterface;
use FOS\MessageBundle\Model\Thread as BaseThread;
use FOS\MessageBundle\Model\ThreadMetadata as ModelThreadMetadata;
use InvalidArgumentException;
use Traversable;

abstract class Thread extends BaseThread
{
Expand Down Expand Up @@ -44,12 +46,12 @@ abstract class Thread extends BaseThread
/**
* Participant that created the thread.
*/
protected ParticipantInterface $createdBy;
protected ?ParticipantInterface $createdBy = null;

/**
* Date this thread was created at.
*/
protected DateTimeInterface $createdAt;
protected ?DateTimeInterface $createdAt = null;

public function getParticipants(): Collection | array
{
Expand Down Expand Up @@ -87,9 +89,9 @@ public function addParticipant(ParticipantInterface $participant): void
/**
* Adds many participants to the thread.
*
* @param array|\Traversable
* @param array|Traversable
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*
* @return Thread
*/
Expand Down
16 changes: 4 additions & 12 deletions Entity/ThreadMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,15 @@

abstract class ThreadMetadata extends BaseThreadMetadata
{
protected int $id;
protected ThreadInterface $thread;
protected ?int $id = null;
protected ?ThreadInterface $thread = null;

/**
* Gets the thread map id.
*
* @return int
*/
public function getId(): int
public function getId(): ?int
{
return $this->id;
}

/**
* @return ThreadInterface
*/
public function getThread(): ThreadInterface
public function getThread(): ?ThreadInterface
{
return $this->thread;
}
Expand Down
4 changes: 1 addition & 3 deletions EntityManager/MessageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@
*/
class MessageManager extends BaseMessageManager
{
protected EntityManagerInterface $em;
protected ObjectRepository $repository;
protected string $class;
protected string $metaClass;

public function __construct(EntityManagerInterface $em, string $class, string $metaClass)
public function __construct(protected EntityManagerInterface $em, string $class, string $metaClass)
{
$this->em = $em;
$this->repository = $em->getRepository($class);
$this->class = $em->getClassMetadata($class)->name;
$this->metaClass = $em->getClassMetadata($metaClass)->name;
Expand Down
11 changes: 1 addition & 10 deletions EntityManager/ThreadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,15 @@
*/
class ThreadManager extends BaseThreadManager
{
protected EntityManagerInterface $em;
protected ObjectRepository $repository;
protected string $class;
protected string $metaClass;

/**
* The message manager, required to mark
* the messages of a thread as read/unread.
*/
protected MessageManager $messageManager;

public function __construct(EntityManagerInterface $em, string $class, string $metaClass, MessageManager $messageManager)
public function __construct(protected EntityManagerInterface $em, string $class, string $metaClass, protected MessageManager $messageManager)
{
$this->em = $em;
$this->repository = $em->getRepository($class);
$this->class = $em->getClassMetadata($class)->name;
$this->metaClass = $em->getClassMetadata($metaClass)->name;
$this->messageManager = $messageManager;
}

public function findThreadById(int $id): ?ThreadInterface
Expand Down
9 changes: 3 additions & 6 deletions Event/MessageEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@

class MessageEvent extends ThreadEvent
{
private MessageInterface $message;

public function __construct(MessageInterface $message)
{
public function __construct(
private MessageInterface $message
) {
parent::__construct($message->getThread());

$this->message = $message;
}

public function getMessage(): MessageInterface
Expand Down
8 changes: 3 additions & 5 deletions Event/ReadableEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@

class ReadableEvent extends Event
{
private ReadableInterface $readable;

public function __construct(ReadableInterface $readable)
{
$this->readable = $readable;
public function __construct(
private ReadableInterface $readable
) {
}

public function getReadable(): ReadableInterface
Expand Down
8 changes: 3 additions & 5 deletions Event/ThreadEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@

class ThreadEvent extends Event
{
private ThreadInterface $thread;

public function __construct(ThreadInterface $thread)
{
$this->thread = $thread;
public function __construct(
private ThreadInterface $thread
) {
}

public function getThread(): ThreadInterface
Expand Down
17 changes: 6 additions & 11 deletions FormFactory/AbstractMessageFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@
*/
abstract class AbstractMessageFormFactory
{
protected FormFactoryInterface $formFactory;
protected string | AbstractType $formType;
protected string $formName;
protected string $messageClass;

public function __construct(FormFactoryInterface $formFactory, string | AbstractType $formType, string $formName, string $messageClass)
{
$this->formFactory = $formFactory;
$this->formType = $formType;
$this->formName = $formName;
$this->messageClass = $messageClass;
public function __construct(
protected FormFactoryInterface $formFactory,
protected string | AbstractType $formType,
protected string $formName,
protected string $messageClass
) {
}

protected function createModelInstance(): AbstractMessage
Expand Down
4 changes: 2 additions & 2 deletions FormModel/AbstractMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

abstract class AbstractMessage
{
protected string $body;
protected ?string $body = null;

public function getBody(): string
public function getBody(): ?string
{
return $this->body;
}
Expand Down
8 changes: 4 additions & 4 deletions FormModel/NewThreadMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

class NewThreadMessage extends AbstractMessage
{
protected ParticipantInterface $recipient;
protected string $subject;
protected ?ParticipantInterface $recipient = null;
protected ?string $subject = null;

public function getSubject(): string
public function getSubject(): ?string
{
return $this->subject;
}
Expand All @@ -21,7 +21,7 @@ public function setSubject(string $subject): void
$this->subject = $subject;
}

public function getRecipient(): ParticipantInterface
public function getRecipient(): ?ParticipantInterface
{
return $this->recipient;
}
Expand Down
4 changes: 2 additions & 2 deletions FormModel/NewThreadMultipleMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
class NewThreadMultipleMessage extends AbstractMessage
{
protected Collection $recipients;
protected string $subject;
protected ?string $subject;

public function __construct()
{
$this->recipients = new ArrayCollection();
}

public function getSubject(): string
public function getSubject(): ?string
{
return $this->subject;
}
Expand Down
4 changes: 2 additions & 2 deletions FormModel/ReplyMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

class ReplyMessage extends AbstractMessage
{
protected ThreadInterface $thread;
protected ?ThreadInterface $thread;

public function getThread(): ThreadInterface
public function getThread(): ?ThreadInterface
{
return $this->thread;
}
Expand Down
1 change: 0 additions & 1 deletion FormType/NewThreadMessageFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;

Expand Down
2 changes: 1 addition & 1 deletion FormType/NewThreadMultipleMessageFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return 'fos_message_new_multiperson_thread';
}
Expand Down
16 changes: 6 additions & 10 deletions MessageBuilder/AbstractMessageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@
*/
abstract class AbstractMessageBuilder
{
protected MessageInterface $message;
protected ThreadInterface $thread;

public function __construct(MessageInterface $message, ThreadInterface $thread)
{
$this->message = $message;
$this->thread = $thread;

$this->message->setThread($thread);
$thread->addMessage($message);
public function __construct(
protected MessageInterface $message,
protected ThreadInterface $thread
) {
$this->message->setThread($this->thread);
$this->thread->addMessage($message);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions Model/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
abstract class Message implements MessageInterface
{
protected int $id;
protected ParticipantInterface $sender;
protected string $body;
protected DateTimeInterface $createdAt;
protected ThreadInterface $thread;
protected ?int $id = null;
protected ?ParticipantInterface $sender = null;
protected ?string $body = null;
protected ?DateTimeInterface $createdAt = null;
protected ?ThreadInterface $thread = null;
protected Collection | array $metadata;

public function __construct()
Expand Down
10 changes: 5 additions & 5 deletions Model/MessageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
*/
interface MessageInterface extends ReadableInterface
{
public function getId(): int;
public function getThread(): ThreadInterface;
public function getId(): ?int;
public function getThread(): ?ThreadInterface;
public function setThread(ThreadInterface $thread): void;
public function getCreatedAt(): DateTimeInterface;
public function getBody(): string;
public function getCreatedAt(): ?DateTimeInterface;
public function getBody(): ?string;
public function setBody(string $body): void;
public function getSender(): ParticipantInterface;
public function getSender(): ?ParticipantInterface;
public function setSender(ParticipantInterface $sender): void;
}
4 changes: 2 additions & 2 deletions Model/MessageMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

abstract class MessageMetadata
{
protected ParticipantInterface $participant;
protected ?ParticipantInterface $participant;
protected bool $isRead = false;

public function getParticipant(): ParticipantInterface
public function getParticipant(): ?ParticipantInterface
{
return $this->participant;
}
Expand Down
2 changes: 1 addition & 1 deletion Model/ParticipantInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ interface ParticipantInterface
/**
* Gets the unique identifier of the participant.
*/
public function getId(): int;
public function getId(): ?int;
}
Loading

0 comments on commit c801da5

Please sign in to comment.