From 88c3dea0703c6b4bf2006d7951056c5dc6287cc9 Mon Sep 17 00:00:00 2001 From: Titouan Galopin Date: Sat, 3 Sep 2016 11:19:45 +0200 Subject: [PATCH] Fix #287 and improve CS/readability of various parts of the code --- Command/MongoDBMigrateMetadataCommand.php | 24 +++--- Composer/ComposerInterface.php | 9 +- Controller/MessageController.php | 2 +- DataTransformer/RecipientsDataTransformer.php | 10 +-- Deleter/Deleter.php | 9 +- Deleter/DeleterInterface.php | 8 +- DependencyInjection/Configuration.php | 1 - Document/Message.php | 5 +- Document/Thread.php | 9 +- DocumentManager/MessageManager.php | 37 ++------ DocumentManager/ThreadManager.php | 86 ++++--------------- Entity/Message.php | 2 +- Entity/MessageMetadata.php | 7 -- Entity/Thread.php | 28 ++---- Entity/ThreadMetadata.php | 5 -- EntityManager/MessageManager.php | 32 ++----- EntityManager/ThreadManager.php | 86 +++---------------- Event/MessageEvent.php | 6 -- Event/ReadableEvent.php | 4 - Event/ThreadEvent.php | 4 - FormFactory/AbstractMessageFormFactory.php | 4 +- FormFactory/NewThreadMessageFormFactory.php | 8 +- FormFactory/ReplyMessageFormFactory.php | 3 +- FormHandler/AbstractMessageFormHandler.php | 3 +- FormHandler/NewThreadMessageFormHandler.php | 3 +- .../NewThreadMultipleMessageFormHandler.php | 2 + FormHandler/ReplyMessageFormHandler.php | 3 +- FormModel/AbstractMessage.php | 5 +- FormModel/NewThreadMessage.php | 9 +- FormModel/NewThreadMultipleMessage.php | 11 +-- FormModel/ReplyMessage.php | 4 - MessageBuilder/NewThreadMessageBuilder.php | 2 - MessageBuilder/ReplyMessageBuilder.php | 5 -- Model/Message.php | 23 +++-- Model/MessageInterface.php | 20 ++--- Model/MessageMetadata.php | 5 -- Model/ParticipantInterface.php | 2 +- Model/ReadableInterface.php | 6 +- Model/Thread.php | 40 ++++----- Model/ThreadInterface.php | 40 ++++----- Model/ThreadMetadata.php | 19 ++-- ModelManager/MessageManager.php | 5 +- ModelManager/MessageManagerInterface.php | 8 +- ModelManager/ReadableManagerInterface.php | 4 +- ModelManager/ThreadManager.php | 5 +- ModelManager/ThreadManagerInterface.php | 26 +++--- Provider/Provider.php | 19 ++-- Provider/ProviderInterface.php | 10 +-- Reader/Reader.php | 9 +- Reader/ReaderInterface.php | 4 +- Search/Finder.php | 11 +-- Search/FinderInterface.php | 4 +- Search/Query.php | 8 +- Search/QueryFactory.php | 8 +- Search/QueryFactoryInterface.php | 2 +- Security/Authorizer.php | 22 +---- Security/AuthorizerInterface.php | 6 +- Security/ParticipantProvider.php | 6 +- Security/ParticipantProviderInterface.php | 2 +- Sender/Sender.php | 11 +-- Sender/SenderInterface.php | 2 +- SpamDetection/AkismetSpamDetector.php | 9 +- SpamDetection/NoopSpamDetector.php | 5 +- SpamDetection/SpamDetectorInterface.php | 2 +- Twig/Extension/MessageExtension.php | 9 +- Validator/AuthorizationValidator.php | 5 -- Validator/ReplyAuthorizationValidator.php | 9 +- Validator/SelfRecipientValidator.php | 5 -- Validator/SpamValidator.php | 5 -- 69 files changed, 245 insertions(+), 567 deletions(-) diff --git a/Command/MongoDBMigrateMetadataCommand.php b/Command/MongoDBMigrateMetadataCommand.php index dfda098c..d8fe41dd 100644 --- a/Command/MongoDBMigrateMetadataCommand.php +++ b/Command/MongoDBMigrateMetadataCommand.php @@ -3,6 +3,8 @@ namespace FOS\MessageBundle\Command; use Doctrine\Common\Persistence\ManagerRegistry; +use FOS\MessageBundle\Document\Message; +use FOS\MessageBundle\Document\Thread; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -37,7 +39,7 @@ class MongoDBMigrateMetadataCommand extends ContainerAwareCommand private $printStatusCallback; /** - * @see Symfony\Component\Console\Command\Command::isEnabled() + * {@inheritdoc} */ public function isEnabled() { @@ -49,7 +51,7 @@ public function isEnabled() } /** - * @see Symfony\Component\Console\Command\Command::configure() + * {@inheritdoc} */ protected function configure() { @@ -92,7 +94,7 @@ protected function configure() } /** - * @see Symfony\Bundle\FrameworkBundle\Command\Command::initialize() + * {@inheritdoc} */ protected function initialize(InputInterface $input, OutputInterface $output) { @@ -113,7 +115,7 @@ protected function initialize(InputInterface $input, OutputInterface $output) } /** - * @see Symfony\Component\Console\Command\Command::execute() + * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -122,13 +124,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $size = memory_get_peak_usage(true); $unit = array('b', 'k', 'm', 'g', 't', 'p'); - $output->writeln(sprintf("Peak Memory Usage: %s", round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).$unit[$i])); + $output->writeln(sprintf('Peak Memory Usage: %s', round($size / pow(1024, $i = floor(log($size, 1024))), 2).$unit[$i])); } /** * Migrate message documents - * - * @param OutputInterface $output */ private function migrateMessages(OutputInterface $output) { @@ -175,8 +175,6 @@ private function migrateMessages(OutputInterface $output) /** * Migrate thread documents - * - * @param OutputInterface $output */ private function migrateThreads(OutputInterface $output) { @@ -233,8 +231,6 @@ private function migrateThreads(OutputInterface $output) * * By default, Mongo will not include "$db" when creating the participant * reference. We'll add that manually to be consistent with Doctrine. - * - * @param array &$message */ private function createMessageMetadata(array &$message) { @@ -253,7 +249,7 @@ private function createMessageMetadata(array &$message) /** * Sets the unreadForParticipants array on the message. * - * @see FOS\MessageBundle\Document\Message::doEnsureUnreadForParticipantsArray() + * @see Message::doEnsureUnreadForParticipantsArray() * @param array &$message */ private function createMessageUnreadForParticipants(array &$message) @@ -331,7 +327,7 @@ private function createThreadLastMessageDate(array &$thread) /** * Sets the active participant arrays on the thread. * - * @see FOS\MessageBundle\Document\Thread::doEnsureActiveParticipantArrays() + * @see Thread::doEnsureActiveParticipantArrays() * @param array $thread */ private function createThreadActiveParticipantArrays(array &$thread) @@ -342,7 +338,7 @@ private function createThreadActiveParticipantArrays(array &$thread) foreach ($thread['participants'] as $participantRef) { foreach ($thread['metadata'] as $metadata) { - if ($participantRef['$id'] == $metadata['participant']['$id'] && $metadata['isDeleted']) { + if ($metadata['isDeleted'] && $participantRef['$id'] === $metadata['participant']['$id']) { continue 2; } } diff --git a/Composer/ComposerInterface.php b/Composer/ComposerInterface.php index 94b3ff57..8b9b9ef2 100644 --- a/Composer/ComposerInterface.php +++ b/Composer/ComposerInterface.php @@ -2,6 +2,7 @@ namespace FOS\MessageBundle\Composer; +use FOS\MessageBundle\MessageBuilder\AbstractMessageBuilder; use FOS\MessageBundle\Model\ThreadInterface; /** @@ -14,14 +15,14 @@ interface ComposerInterface /** * Starts composing a message, starting a new thread * - * @return MessageBuilderInterface + * @return AbstractMessageBuilder */ - function newThread(); + public function newThread(); /** * Starts composing a message in a reply to a thread * - * @return MessageBuilderInterface + * @return AbstractMessageBuilder */ - function reply(ThreadInterface $thread); + public function reply(ThreadInterface $thread); } diff --git a/Controller/MessageController.php b/Controller/MessageController.php index 28c06a63..ffb9f8a5 100644 --- a/Controller/MessageController.php +++ b/Controller/MessageController.php @@ -2,10 +2,10 @@ namespace FOS\MessageBundle\Controller; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\HttpFoundation\RedirectResponse; use FOS\MessageBundle\Provider\ProviderInterface; +use Symfony\Component\HttpFoundation\Response; class MessageController extends ContainerAware { diff --git a/DataTransformer/RecipientsDataTransformer.php b/DataTransformer/RecipientsDataTransformer.php index 39cd4d07..50e4356d 100644 --- a/DataTransformer/RecipientsDataTransformer.php +++ b/DataTransformer/RecipientsDataTransformer.php @@ -5,7 +5,6 @@ use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Security\Core\User\UserInterface; -use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; /** @@ -20,9 +19,6 @@ class RecipientsDataTransformer implements DataTransformerInterface */ private $userToUsernameTransformer; - /** - * @param DataTransformerInterface $userToUsernameTransformer - */ public function __construct(DataTransformerInterface $userToUsernameTransformer) { $this->userToUsernameTransformer = $userToUsernameTransformer; @@ -37,8 +33,8 @@ public function __construct(DataTransformerInterface $userToUsernameTransformer) */ public function transform($recipients) { - if ($recipients === null || $recipients->count() == 0) { - return ""; + if ($recipients === null || $recipients->count() === 0) { + return ''; } $usernames = array(); @@ -84,4 +80,4 @@ public function reverseTransform($usernames) return $recipients; } -} \ No newline at end of file +} diff --git a/Deleter/Deleter.php b/Deleter/Deleter.php index c1a943ad..33fa346b 100644 --- a/Deleter/Deleter.php +++ b/Deleter/Deleter.php @@ -2,6 +2,7 @@ namespace FOS\MessageBundle\Deleter; +use FOS\MessageBundle\Model\ParticipantInterface; use FOS\MessageBundle\Security\AuthorizerInterface; use FOS\MessageBundle\Model\ThreadInterface; use FOS\MessageBundle\Security\ParticipantProviderInterface; @@ -46,9 +47,7 @@ public function __construct(AuthorizerInterface $authorizer, ParticipantProvider } /** - * Marks the thread as deleted by the current authenticated user - * - * @param ThreadInterface $thread + * {@inheritdoc} */ public function markAsDeleted(ThreadInterface $thread) { @@ -61,9 +60,7 @@ public function markAsDeleted(ThreadInterface $thread) } /** - * Marks the thread as undeleted by the current authenticated user - * - * @param ThreadInterface $thread + * {@inheritdoc} */ public function markAsUndeleted(ThreadInterface $thread) { diff --git a/Deleter/DeleterInterface.php b/Deleter/DeleterInterface.php index 76c9b4f0..dc1badf9 100644 --- a/Deleter/DeleterInterface.php +++ b/Deleter/DeleterInterface.php @@ -13,15 +13,11 @@ interface DeleterInterface { /** * Marks the thread as deleted by the current authenticated user - * - * @param ThreadInterface $thread */ - function markAsDeleted(ThreadInterface $thread); + public function markAsDeleted(ThreadInterface $thread); /** * Marks the thread as undeleted by the current authenticated user - * - * @param ThreadInterface $thread */ - function markAsUndeleted(ThreadInterface $thread); + public function markAsUndeleted(ThreadInterface $thread); } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 777fed9a..d2f6ebf5 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -3,7 +3,6 @@ namespace FOS\MessageBundle\DependencyInjection; use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\ConfigurationInterface; /** diff --git a/Document/Message.php b/Document/Message.php index e951a1bc..7f49e0ea 100644 --- a/Document/Message.php +++ b/Document/Message.php @@ -23,15 +23,14 @@ abstract class Message extends BaseMessage protected $unreadForParticipants = array(); /** - * @param boolean - * @return null + * @param boolean $isSpam */ public function setIsSpam($isSpam) { $this->isSpam = (boolean) $isSpam; } - /** + /* * DENORMALIZATION * * All following methods are relative to denormalization diff --git a/Document/Thread.php b/Document/Thread.php index 5083e9bb..f19571c4 100644 --- a/Document/Thread.php +++ b/Document/Thread.php @@ -3,9 +3,6 @@ namespace FOS\MessageBundle\Document; use FOS\MessageBundle\Model\Thread as AbstractThread; -use FOS\MessageBundle\Model\MessageInterface; -use Doctrine\Common\Collections\Collection; -use Doctrine\Common\Collections\ArrayCollection; use FOS\MessageBundle\Model\ParticipantInterface; abstract class Thread extends AbstractThread @@ -16,7 +13,7 @@ abstract class Thread extends AbstractThread * This denormalization field is used for sorting threads in the inbox and * sent list. * - * @var DateTime + * @var \DateTime */ protected $lastMessageDate; @@ -69,7 +66,7 @@ public function getParticipants() * If it already exists, nothing is done. * * @param ParticipantInterface $participant - * @return null + * @return void */ public function addParticipant(ParticipantInterface $participant) { @@ -89,7 +86,7 @@ public function isParticipant(ParticipantInterface $participant) return $this->participants->contains($participant); } - /** + /* * DENORMALIZATION * * All following methods are relative to denormalization diff --git a/DocumentManager/MessageManager.php b/DocumentManager/MessageManager.php index f925a6e6..b2a8f718 100644 --- a/DocumentManager/MessageManager.php +++ b/DocumentManager/MessageManager.php @@ -4,6 +4,7 @@ use Doctrine\ODM\MongoDB\DocumentManager; use FOS\MessageBundle\Document\Message; +use FOS\MessageBundle\Document\MessageMetadata; use FOS\MessageBundle\Model\MessageInterface; use FOS\MessageBundle\ModelManager\MessageManager as BaseMessageManager; use FOS\MessageBundle\Model\ReadableInterface; @@ -39,8 +40,6 @@ class MessageManager extends BaseMessageManager protected $metaClass; /** - * Constructor. - * * @param DocumentManager $dm * @param string $class * @param string $metaClass @@ -54,10 +53,7 @@ public function __construct(DocumentManager $dm, $class, $metaClass) } /** - * Tells how many unread, non-spam, messages this participant has - * - * @param ParticipantInterface $participant - * @return int the number of unread messages + * {@inheritDoc} */ public function getNbUnreadMessageByParticipant(ParticipantInterface $participant) { @@ -68,29 +64,19 @@ public function getNbUnreadMessageByParticipant(ParticipantInterface $participan } /** - * Marks the readable as read by this participant - * Must be applied directly to the storage, - * without modifying the readable state. - * We want to show the unread readables on the page, - * as well as marking the as read. - * - * @param ReadableInterface $readable - * @param ParticipantInterface $participant + * {@inheritDoc} */ public function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterface $participant) { - return $this->markIsReadByParticipant($readable, $participant, true); + $this->markIsReadByParticipant($readable, $participant, true); } /** - * Marks the readable as unread by this participant - * - * @param ReadableInterface $readable - * @param ParticipantInterface $participant + * {@inheritDoc} */ public function markAsUnreadByParticipant(ReadableInterface $readable, ParticipantInterface $participant) { - return $this->markIsReadByParticipant($readable, $participant, false); + $this->markIsReadByParticipant($readable, $participant, false); } /** @@ -167,10 +153,7 @@ protected function markIsReadByCondition(ParticipantInterface $participant, $isR } /** - * Saves a message - * - * @param MessageInterface $message - * @param Boolean $andFlush Whether to flush the changes (default true) + * {@inheritDoc} */ public function saveMessage(MessageInterface $message, $andFlush = true) { @@ -182,9 +165,7 @@ public function saveMessage(MessageInterface $message, $andFlush = true) } /** - * Returns the fully qualified comment thread class name - * - * @return string + * {@inheritDoc} */ public function getClass() { @@ -201,7 +182,7 @@ protected function createMessageMetadata() return new $this->metaClass(); } - /** + /* * DENORMALIZATION * * All following methods are relative to denormalization diff --git a/DocumentManager/ThreadManager.php b/DocumentManager/ThreadManager.php index 60848c64..2a3e5007 100644 --- a/DocumentManager/ThreadManager.php +++ b/DocumentManager/ThreadManager.php @@ -4,6 +4,7 @@ use Doctrine\ODM\MongoDB\DocumentManager; use FOS\MessageBundle\Document\Thread; +use FOS\MessageBundle\Document\ThreadMetadata; use FOS\MessageBundle\Model\ThreadInterface; use FOS\MessageBundle\Model\ReadableInterface; use FOS\MessageBundle\ModelManager\ThreadManager as BaseThreadManager; @@ -62,9 +63,7 @@ public function __construct(DocumentManager $dm, $class, $metaClass, MessageMana } /** - * Finds a thread by its ID - * - * @return ThreadInterface or null + * {@inheritDoc} */ public function findThreadById($id) { @@ -72,13 +71,7 @@ public function findThreadById($id) } /** - * Finds not deleted, non-spam threads for a participant, - * containing at least one message not written by this participant, - * ordered by last message not written by this participant in reverse order. - * In one word: an inbox. - * - * @param ParticipantInterface $participant - * @return Builder a query builder suitable for pagination + * {@inheritDoc} */ public function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $participant) { @@ -92,13 +85,7 @@ public function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $par } /** - * Finds not deleted, non-spam threads for a participant, - * containing at least one message not written by this participant, - * ordered by last message not written by this participant in reverse order. - * In one word: an inbox. - * - * @param ParticipantInterface $participant - * @return ThreadInterface[] + * {@inheritDoc} */ public function findParticipantInboxThreads(ParticipantInterface $participant) { @@ -106,13 +93,7 @@ public function findParticipantInboxThreads(ParticipantInterface $participant) } /** - * Finds not deleted threads from a participant, - * containing at least one message written by this participant, - * ordered by last message written by this participant in reverse order. - * In one word: an sentbox. - * - * @param ParticipantInterface $participant - * @return Builder a query builder suitable for pagination + * {@inheritDoc} */ public function getParticipantSentThreadsQueryBuilder(ParticipantInterface $participant) { @@ -126,13 +107,7 @@ public function getParticipantSentThreadsQueryBuilder(ParticipantInterface $part } /** - * Finds not deleted threads from a participant, - * containing at least one message written by this participant, - * ordered by last message written by this participant in reverse order. - * In one word: an sentbox. - * - * @param ParticipantInterface $participant - * @return ThreadInterface[] + * {@inheritDoc} */ public function findParticipantSentThreads(ParticipantInterface $participant) { @@ -159,13 +134,7 @@ public function findParticipantDeletedThreads(ParticipantInterface $participant) } /** - * Finds not deleted threads for a participant, - * matching the given search term - * ordered by last message not written by this participant in reverse order. - * - * @param ParticipantInterface $participant - * @param string $search - * @return Builder a query builder suitable for pagination + * {@inheritDoc} */ public function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $participant, $search) { @@ -186,24 +155,15 @@ public function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $ } /** - * Finds not deleted threads for a participant, - * matching the given search term - * ordered by last message not written by this participant in reverse order. - * - * @param ParticipantInterface $participant - * @param string $search - * @return ThreadInterface[] + * {@inheritDoc} */ - public function findParticipantThreadsBySearch(participantinterface $participant, $search) + public function findParticipantThreadsBySearch(ParticipantInterface $participant, $search) { return $this->getParticipantThreadsBySearchQueryBuilder($participant, $search)->getQuery()->execute(); } /** - * Gets threads created by a participant - * - * @param ParticipantInterface $participant - * @return ThreadInterface[] + * {@inheritDoc} */ public function findThreadsCreatedBy(ParticipantInterface $participant) { @@ -214,14 +174,7 @@ public function findThreadsCreatedBy(ParticipantInterface $participant) } /** - * Marks the readable as read by this participant - * Must be applied directly to the storage, - * without modifying the readable state. - * We want to show the unread readables on the page, - * as well as marking the as read. - * - * @param ReadableInterface $readable - * @param ParticipantInterface $participant + * {@inheritDoc} */ public function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterface $participant) { @@ -229,10 +182,7 @@ public function markAsReadByParticipant(ReadableInterface $readable, Participant } /** - * Marks the readable as unread by this participant - * - * @param ReadableInterface $readable - * @param ParticipantInterface $participant + * {@inheritDoc} */ public function markAsUnreadByParticipant(ReadableInterface $readable, ParticipantInterface $participant) { @@ -240,10 +190,7 @@ public function markAsUnreadByParticipant(ReadableInterface $readable, Participa } /** - * Saves a thread - * - * @param ThreadInterface $thread - * @param Boolean $andFlush Whether to flush the changes (default true) + * {@inheritDoc} */ public function saveThread(ThreadInterface $thread, $andFlush = true) { @@ -255,10 +202,7 @@ public function saveThread(ThreadInterface $thread, $andFlush = true) } /** - * Deletes a thread - * This is not participant deletion but real deletion - * - * @param ThreadInterface $thread the thread to delete + * {@inheritDoc} */ public function deleteThread(ThreadInterface $thread) { @@ -286,7 +230,7 @@ protected function createThreadMetadata() return new $this->metaClass(); } - /** + /* * DENORMALIZATION * * All following methods are relative to denormalization diff --git a/Entity/Message.php b/Entity/Message.php index ba076a9f..3c80b359 100644 --- a/Entity/Message.php +++ b/Entity/Message.php @@ -20,7 +20,7 @@ public function getAllMetadata() } /** - * @see FOS\MessageBundle\Model\Message::addMetadata() + * {@inheritDoc} */ public function addMetadata(ModelMessageMetadata $meta) { diff --git a/Entity/MessageMetadata.php b/Entity/MessageMetadata.php index 8ae0ccf9..f76e3164 100644 --- a/Entity/MessageMetadata.php +++ b/Entity/MessageMetadata.php @@ -8,12 +8,9 @@ abstract class MessageMetadata extends BaseMessageMetadata { protected $id; - protected $message; /** - * Gets the metadata id - * * @return integer */ public function getId() @@ -29,10 +26,6 @@ public function getMessage() return $this->message; } - /** - * @param MessageInterface $message - * @return null - */ public function setMessage(MessageInterface $message) { $this->message = $message; diff --git a/Entity/Thread.php b/Entity/Thread.php index c6aba6a5..adfd36f1 100644 --- a/Entity/Thread.php +++ b/Entity/Thread.php @@ -9,7 +9,6 @@ use FOS\MessageBundle\Model\ParticipantInterface; use FOS\MessageBundle\Model\ThreadMetadata as ModelThreadMetadata; -use FOS\MessageBundle\Model\ThreadMetadata; abstract class Thread extends BaseThread { @@ -30,7 +29,7 @@ abstract class Thread extends BaseThread /** * Thread metadata * - * @var Collection|ThreadMetadata[] + * @var Collection|ModelThreadMetadata[] */ protected $metadata; @@ -52,14 +51,12 @@ abstract class Thread extends BaseThread /** * Date this thread was created at * - * @var DateTime + * @var \DateTime */ protected $createdAt; /** - * Gets the users participating in this conversation - * - * @return ParticipantInterface[] + * {@inheritDoc} */ public function getParticipants() { @@ -76,7 +73,7 @@ public function getParticipants() */ protected function getParticipantsCollection() { - if ($this->participants == null) { + if (null === $this->participants) { $this->participants = new ArrayCollection(); foreach ($this->metadata as $data) { @@ -88,11 +85,7 @@ protected function getParticipantsCollection() } /** - * Adds a participant to the thread - * If it already exists, nothing is done. - * - * @param ParticipantInterface $participant - * @return null + * {@inheritDoc} */ public function addParticipant(ParticipantInterface $participant) { @@ -112,7 +105,7 @@ public function addParticipant(ParticipantInterface $participant) public function addParticipants($participants) { if (!is_array($participants) && !$participants instanceof \Traversable) { - throw new \InvalidArgumentException("Participants must be an array or instanceof Traversable"); + throw new \InvalidArgumentException('Participants must be an array or instance of Traversable'); } foreach ($participants as $participant) { @@ -123,10 +116,7 @@ public function addParticipants($participants) } /** - * Tells if the user participates to the conversation - * - * @param ParticipantInterface $participant - * @return boolean + * {@inheritDoc} */ public function isParticipant(ParticipantInterface $participant) { @@ -134,7 +124,7 @@ public function isParticipant(ParticipantInterface $participant) } /** - * Get the collection of ThreadMetadata. + * Get the collection of ModelThreadMetadata. * * @return Collection */ @@ -144,7 +134,7 @@ public function getAllMetadata() } /** - * @see FOS\MessageBundle\Model\Thread::addMetadata() + * {@inheritDoc} */ public function addMetadata(ModelThreadMetadata $meta) { diff --git a/Entity/ThreadMetadata.php b/Entity/ThreadMetadata.php index b38d1ee8..bcbbf354 100644 --- a/Entity/ThreadMetadata.php +++ b/Entity/ThreadMetadata.php @@ -8,7 +8,6 @@ abstract class ThreadMetadata extends BaseThreadMetadata { protected $id; - protected $thread; /** @@ -29,10 +28,6 @@ public function getThread() return $this->thread; } - /** - * @param ThreadInterface $thread - * @return null - */ public function setThread(ThreadInterface $thread) { $this->thread = $thread; diff --git a/EntityManager/MessageManager.php b/EntityManager/MessageManager.php index cba01273..10a5eea7 100644 --- a/EntityManager/MessageManager.php +++ b/EntityManager/MessageManager.php @@ -38,8 +38,6 @@ class MessageManager extends BaseMessageManager protected $metaClass; /** - * Constructor. - * * @param EntityManager $em * @param string $class * @param string $metaClass @@ -53,10 +51,7 @@ public function __construct(EntityManager $em, $class, $metaClass) } /** - * Tells how many unread messages this participant has - * - * @param ParticipantInterface $participant - * @return int the number of unread messages + * {@inheritDoc} */ public function getNbUnreadMessageByParticipant(ParticipantInterface $participant) { @@ -82,14 +77,7 @@ public function getNbUnreadMessageByParticipant(ParticipantInterface $participan } /** - * Marks the readable as read by this participant - * Must be applied directly to the storage, - * without modifying the readable state. - * We want to show the unread readables on the page, - * as well as marking the as read. - * - * @param ReadableInterface $readable - * @param ParticipantInterface $participant + * {@inheritDoc} */ public function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterface $participant) { @@ -97,10 +85,7 @@ public function markAsReadByParticipant(ReadableInterface $readable, Participant } /** - * Marks the readable as unread by this participant - * - * @param ReadableInterface $readable - * @param ParticipantInterface $participant + * {@inheritDoc} */ public function markAsUnreadByParticipant(ReadableInterface $readable, ParticipantInterface $participant) { @@ -148,10 +133,7 @@ protected function markIsReadByParticipant(MessageInterface $message, Participan } /** - * Saves a message - * - * @param MessageInterface $message - * @param Boolean $andFlush Whether to flush the changes (default true) + * {@inheritDoc} */ public function saveMessage(MessageInterface $message, $andFlush = true) { @@ -163,16 +145,14 @@ public function saveMessage(MessageInterface $message, $andFlush = true) } /** - * Returns the fully qualified comment thread class name - * - * @return string + * {@inheritDoc} */ public function getClass() { return $this->class; } - /** + /* * DENORMALIZATION * * All following methods are relative to denormalization diff --git a/EntityManager/ThreadManager.php b/EntityManager/ThreadManager.php index 4df65097..03ff7253 100644 --- a/EntityManager/ThreadManager.php +++ b/EntityManager/ThreadManager.php @@ -49,8 +49,6 @@ class ThreadManager extends BaseThreadManager protected $messageManager; /** - * Constructor. - * * @param EntityManager $em * @param string $class * @param string $metaClass @@ -66,9 +64,7 @@ public function __construct(EntityManager $em, $class, $metaClass, MessageManage } /** - * Finds a thread by its ID - * - * @return ThreadInterface or null + * {@inheritDoc} */ public function findThreadById($id) { @@ -76,13 +72,7 @@ public function findThreadById($id) } /** - * Finds not deleted threads for a participant, - * containing at least one message not written by this participant, - * ordered by last message not written by this participant in reverse order. - * In one word: an inbox. - * - * @param ParticipantInterface $participant - * @return Builder a query builder suitable for pagination + * {@inheritDoc} */ public function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $participant) { @@ -111,13 +101,7 @@ public function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $par } /** - * Finds not deleted threads for a participant, - * containing at least one message not written by this participant, - * ordered by last message not written by this participant in reverse order. - * In one word: an inbox. - * - * @param ParticipantInterface $participant - * @return ThreadInterface[] + * {@inheritDoc} */ public function findParticipantInboxThreads(ParticipantInterface $participant) { @@ -127,13 +111,7 @@ public function findParticipantInboxThreads(ParticipantInterface $participant) } /** - * Finds not deleted threads from a participant, - * containing at least one message written by this participant, - * ordered by last message written by this participant in reverse order. - * In one word: an sentbox. - * - * @param ParticipantInterface $participant - * @return Builder a query builder suitable for pagination + * {@inheritDoc} */ public function getParticipantSentThreadsQueryBuilder(ParticipantInterface $participant) { @@ -162,13 +140,7 @@ public function getParticipantSentThreadsQueryBuilder(ParticipantInterface $part } /** - * Finds not deleted threads from a participant, - * containing at least one message written by this participant, - * ordered by last message written by this participant in reverse order. - * In one word: an sentbox. - * - * @param ParticipantInterface $participant - * @return ThreadInterface[] + * {@inheritDoc} */ public function findParticipantSentThreads(ParticipantInterface $participant) { @@ -210,13 +182,7 @@ public function findParticipantDeletedThreads(ParticipantInterface $participant) } /** - * Finds not deleted threads for a participant, - * matching the given search term - * ordered by last message not written by this participant in reverse order. - * - * @param ParticipantInterface $participant - * @param string $search - * @return Builder a query builder suitable for pagination + * {@inheritDoc} */ public function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $participant, $search) { @@ -229,15 +195,9 @@ public function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $ } /** - * Finds not deleted threads for a participant, - * matching the given search term - * ordered by last message not written by this participant in reverse order. - * - * @param ParticipantInterface $participant - * @param string $search - * @return ThreadInterface[] + * {@inheritDoc} */ - public function findParticipantThreadsBySearch(participantinterface $participant, $search) + public function findParticipantThreadsBySearch(ParticipantInterface $participant, $search) { return $this->getParticipantThreadsBySearchQueryBuilder($participant, $search) ->getQuery() @@ -245,10 +205,7 @@ public function findParticipantThreadsBySearch(participantinterface $participant } /** - * Gets threads created by a participant - * - * @param ParticipantInterface $participant - * @return ThreadInterface[] + * {@inheritDoc} */ public function findThreadsCreatedBy(ParticipantInterface $participant) { @@ -263,14 +220,7 @@ public function findThreadsCreatedBy(ParticipantInterface $participant) } /** - * Marks the readable as read by this participant - * Must be applied directly to the storage, - * without modifying the readable state. - * We want to show the unread readables on the page, - * as well as marking the as read. - * - * @param ReadableInterface $readable - * @param ParticipantInterface $participant + * {@inheritDoc} */ public function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterface $participant) { @@ -278,10 +228,7 @@ public function markAsReadByParticipant(ReadableInterface $readable, Participant } /** - * Marks the readable as unread by this participant - * - * @param ReadableInterface $readable - * @param ParticipantInterface $participant + * {@inheritDoc} */ public function markAsUnreadByParticipant(ReadableInterface $readable, ParticipantInterface $participant) { @@ -289,10 +236,7 @@ public function markAsUnreadByParticipant(ReadableInterface $readable, Participa } /** - * Saves a thread - * - * @param ThreadInterface $thread - * @param Boolean $andFlush Whether to flush the changes (default true) + * {@inheritDoc} */ public function saveThread(ThreadInterface $thread, $andFlush = true) { @@ -304,9 +248,7 @@ public function saveThread(ThreadInterface $thread, $andFlush = true) } /** - * Deletes a thread - * - * @param ThreadInterface $thread the thread to delete + * {@inheritDoc} */ public function deleteThread(ThreadInterface $thread) { @@ -324,7 +266,7 @@ public function getClass() return $this->class; } - /** + /* * DENORMALIZATION * * All following methods are relative to denormalization diff --git a/Event/MessageEvent.php b/Event/MessageEvent.php index df553ec7..23a58a46 100644 --- a/Event/MessageEvent.php +++ b/Event/MessageEvent.php @@ -2,15 +2,11 @@ namespace FOS\MessageBundle\Event; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\EventDispatcher\Event; use FOS\MessageBundle\Model\MessageInterface; -use FOS\MessageBundle\Model\ThreadInterface; class MessageEvent extends ThreadEvent { /** - * The message * @var MessageInterface */ private $message; @@ -23,8 +19,6 @@ public function __construct(MessageInterface $message) } /** - * Returns the message - * * @return MessageInterface */ public function getMessage() diff --git a/Event/ReadableEvent.php b/Event/ReadableEvent.php index b7340d78..d0dfc8ed 100644 --- a/Event/ReadableEvent.php +++ b/Event/ReadableEvent.php @@ -2,14 +2,12 @@ namespace FOS\MessageBundle\Event; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\EventDispatcher\Event; use FOS\MessageBundle\Model\ReadableInterface; class ReadableEvent extends Event { /** - * The readable * @var ReadableInterface */ private $readable; @@ -20,8 +18,6 @@ public function __construct(ReadableInterface $readable) } /** - * Returns the readable - * * @return ReadableInterface */ public function getReadable() diff --git a/Event/ThreadEvent.php b/Event/ThreadEvent.php index 76c9807d..9af2cf7b 100644 --- a/Event/ThreadEvent.php +++ b/Event/ThreadEvent.php @@ -2,14 +2,12 @@ namespace FOS\MessageBundle\Event; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\EventDispatcher\Event; use FOS\MessageBundle\Model\ThreadInterface; class ThreadEvent extends Event { /** - * The thread * @var ThreadInterface */ private $thread; @@ -20,8 +18,6 @@ public function __construct(ThreadInterface $thread) } /** - * Returns the thread - * * @return ThreadInterface */ public function getThread() diff --git a/FormFactory/AbstractMessageFormFactory.php b/FormFactory/AbstractMessageFormFactory.php index 49806c0b..77eef977 100644 --- a/FormFactory/AbstractMessageFormFactory.php +++ b/FormFactory/AbstractMessageFormFactory.php @@ -56,8 +56,6 @@ public function __construct(FormFactoryInterface $formFactory, AbstractType $for */ protected function createModelInstance() { - $class = $this->messageClass; - - return new $class(); + return new $this->messageClass(); } } diff --git a/FormFactory/NewThreadMessageFormFactory.php b/FormFactory/NewThreadMessageFormFactory.php index 5e00668f..29d49879 100644 --- a/FormFactory/NewThreadMessageFormFactory.php +++ b/FormFactory/NewThreadMessageFormFactory.php @@ -2,6 +2,8 @@ namespace FOS\MessageBundle\FormFactory; +use Symfony\Component\Form\FormInterface; + /** * Instanciates message forms * @@ -12,12 +14,10 @@ class NewThreadMessageFormFactory extends AbstractMessageFormFactory /** * Creates a new thread message * - * @return Form + * @return FormInterface */ public function create() { - $message = $this->createModelInstance(); - - return $this->formFactory->createNamed($this->formName, $this->formType, $message); + return $this->formFactory->createNamed($this->formName, $this->formType, $this->createModelInstance()); } } diff --git a/FormFactory/ReplyMessageFormFactory.php b/FormFactory/ReplyMessageFormFactory.php index cc24ed9a..98cfb700 100644 --- a/FormFactory/ReplyMessageFormFactory.php +++ b/FormFactory/ReplyMessageFormFactory.php @@ -3,6 +3,7 @@ namespace FOS\MessageBundle\FormFactory; use FOS\MessageBundle\Model\ThreadInterface; +use Symfony\Component\Form\FormInterface; /** * Instanciates message forms @@ -15,7 +16,7 @@ class ReplyMessageFormFactory extends AbstractMessageFormFactory * Creates a reply message * * @param ThreadInterface $thread the thread we answer to - * @return Form + * @return FormInterface */ public function create(ThreadInterface $thread) { diff --git a/FormHandler/AbstractMessageFormHandler.php b/FormHandler/AbstractMessageFormHandler.php index 07a8ad73..923aa592 100644 --- a/FormHandler/AbstractMessageFormHandler.php +++ b/FormHandler/AbstractMessageFormHandler.php @@ -2,6 +2,7 @@ namespace FOS\MessageBundle\FormHandler; +use FOS\MessageBundle\Model\MessageInterface; use Symfony\Component\Form\Form; use Symfony\Component\HttpFoundation\Request; use FOS\MessageBundle\Composer\ComposerInterface; @@ -34,7 +35,7 @@ public function __construct(Request $request, ComposerInterface $composer, Sende * Processes the form with the request * * @param Form $form - * @return Message|false the sent message if the form is bound and valid, false otherwise + * @return MessageInterface|false the sent message if the form is bound and valid, false otherwise */ public function process(Form $form) { diff --git a/FormHandler/NewThreadMessageFormHandler.php b/FormHandler/NewThreadMessageFormHandler.php index d7748556..3ac3faa4 100644 --- a/FormHandler/NewThreadMessageFormHandler.php +++ b/FormHandler/NewThreadMessageFormHandler.php @@ -4,6 +4,7 @@ use FOS\MessageBundle\FormModel\AbstractMessage; use FOS\MessageBundle\FormModel\NewThreadMessage; +use FOS\MessageBundle\Model\MessageInterface; class NewThreadMessageFormHandler extends AbstractMessageFormHandler { @@ -12,7 +13,7 @@ class NewThreadMessageFormHandler extends AbstractMessageFormHandler * * @param AbstractMessage $message * @return MessageInterface the composed message ready to be sent - * @throws InvalidArgumentException if the message is not a NewThreadMessage + * @throws \InvalidArgumentException if the message is not a NewThreadMessage */ public function composeMessage(AbstractMessage $message) { diff --git a/FormHandler/NewThreadMultipleMessageFormHandler.php b/FormHandler/NewThreadMultipleMessageFormHandler.php index e76f00ee..9eea3e6c 100644 --- a/FormHandler/NewThreadMultipleMessageFormHandler.php +++ b/FormHandler/NewThreadMultipleMessageFormHandler.php @@ -3,6 +3,8 @@ use FOS\MessageBundle\FormModel\AbstractMessage; use FOS\MessageBundle\FormModel\NewThreadMultipleMessage; +use FOS\MessageBundle\Model\MessageInterface; + /** * Form handler for multiple recipients support * diff --git a/FormHandler/ReplyMessageFormHandler.php b/FormHandler/ReplyMessageFormHandler.php index 0b83d8de..c703bb22 100644 --- a/FormHandler/ReplyMessageFormHandler.php +++ b/FormHandler/ReplyMessageFormHandler.php @@ -4,6 +4,7 @@ use FOS\MessageBundle\FormModel\AbstractMessage; use FOS\MessageBundle\FormModel\ReplyMessage; +use FOS\MessageBundle\Model\MessageInterface; class ReplyMessageFormHandler extends AbstractMessageFormHandler { @@ -12,7 +13,7 @@ class ReplyMessageFormHandler extends AbstractMessageFormHandler * * @param AbstractMessage $message * @return MessageInterface the composed message ready to be sent - * @throws InvalidArgumentException if the message is not a ReplyMessage + * @throws \InvalidArgumentException if the message is not a ReplyMessage */ public function composeMessage(AbstractMessage $message) { diff --git a/FormModel/AbstractMessage.php b/FormModel/AbstractMessage.php index 0df57922..e8b9a89d 100644 --- a/FormModel/AbstractMessage.php +++ b/FormModel/AbstractMessage.php @@ -5,8 +5,6 @@ abstract class AbstractMessage { /** - * The message body - * * @var string */ protected $body; @@ -20,8 +18,7 @@ public function getBody() } /** - * @param string - * @return null + * @param string */ public function setBody($body) { diff --git a/FormModel/NewThreadMessage.php b/FormModel/NewThreadMessage.php index 42a1be73..06f8c65a 100644 --- a/FormModel/NewThreadMessage.php +++ b/FormModel/NewThreadMessage.php @@ -2,6 +2,8 @@ namespace FOS\MessageBundle\FormModel; +use FOS\MessageBundle\Model\ParticipantInterface; + class NewThreadMessage extends AbstractMessage { /** @@ -27,8 +29,7 @@ public function getSubject() } /** - * @param string - * @return null + * @param string */ public function setSubject($subject) { @@ -44,12 +45,10 @@ public function getRecipient() } /** - * @param ParticipantInterface - * @return null + * @param ParticipantInterface */ public function setRecipient($recipient) { $this->recipient = $recipient; } - } diff --git a/FormModel/NewThreadMultipleMessage.php b/FormModel/NewThreadMultipleMessage.php index 40e03947..1fa8de23 100644 --- a/FormModel/NewThreadMultipleMessage.php +++ b/FormModel/NewThreadMultipleMessage.php @@ -25,7 +25,7 @@ class NewThreadMultipleMessage extends AbstractMessage public function __construct() { - $this->recipients = new ArrayCollection; + $this->recipients = new ArrayCollection(); } /** @@ -38,8 +38,6 @@ public function getSubject() /** * @param string $subject - * - * @return null */ public function setSubject($subject) { @@ -58,8 +56,6 @@ public function getRecipients() * Adds single recipient to collection * * @param ParticipantInterface $recipient - * - * @return null */ public function addRecipient(ParticipantInterface $recipient) { @@ -68,18 +64,13 @@ public function addRecipient(ParticipantInterface $recipient) } } - /** * Removes recipient from collection * * @param ParticipantInterface $recipient - * - * @return null - * */ public function removeRecipient(ParticipantInterface $recipient) { $this->recipients->removeElement($recipient); } - } diff --git a/FormModel/ReplyMessage.php b/FormModel/ReplyMessage.php index 9102a487..1761124e 100644 --- a/FormModel/ReplyMessage.php +++ b/FormModel/ReplyMessage.php @@ -21,10 +21,6 @@ public function getThread() return $this->thread; } - /** - * @param ThreadInterface $thread - * @return null - */ public function setThread(ThreadInterface $thread) { $this->thread = $thread; diff --git a/MessageBuilder/NewThreadMessageBuilder.php b/MessageBuilder/NewThreadMessageBuilder.php index 6cd13d5e..3e319aa5 100644 --- a/MessageBuilder/NewThreadMessageBuilder.php +++ b/MessageBuilder/NewThreadMessageBuilder.php @@ -2,9 +2,7 @@ namespace FOS\MessageBundle\MessageBuilder; -use FOS\MessageBundle\Model\MessageInterface; use FOS\MessageBundle\Model\ParticipantInterface; -use FOS\MessageBundle\Sender\SenderInterface; use Doctrine\Common\Collections\Collection; /** diff --git a/MessageBuilder/ReplyMessageBuilder.php b/MessageBuilder/ReplyMessageBuilder.php index 964a0135..c0bc9959 100644 --- a/MessageBuilder/ReplyMessageBuilder.php +++ b/MessageBuilder/ReplyMessageBuilder.php @@ -2,11 +2,6 @@ namespace FOS\MessageBundle\MessageBuilder; -use FOS\MessageBundle\Model\MessageInterface; -use FOS\MessageBundle\Model\ParticipantInterface; -use FOS\MessageBundle\Sender\SenderInterface; -use FOS\MessageBundle\Model\ThreadInterface; - /** * Fluent interface message builder for reply to a thread * diff --git a/Model/Message.php b/Model/Message.php index 15d07367..a8b48d57 100644 --- a/Model/Message.php +++ b/Model/Message.php @@ -4,7 +4,6 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use FOS\MessageBundle\Model\ParticipantInterface; /** * Abstract message model @@ -37,7 +36,7 @@ abstract class Message implements MessageInterface /** * Date when the message was sent * - * @var DateTime + * @var \DateTime */ protected $createdAt; @@ -65,7 +64,7 @@ public function __construct() } /** - * @see FOS\MessageBundle\Model\MessageInterface::getId() + * {@inheritdoc} */ public function getId() { @@ -73,7 +72,7 @@ public function getId() } /** - * @see FOS\MessageBundle\Model\MessageInterface::getThread() + * {@inheritdoc} */ public function getThread() { @@ -81,7 +80,7 @@ public function getThread() } /** - * @see FOS\MessageBundle\Model\MessageInterface::setThread() + * {@inheritdoc} */ public function setThread(ThreadInterface $thread) { @@ -89,7 +88,7 @@ public function setThread(ThreadInterface $thread) } /** - * @see FOS\MessageBundle\Model\MessageInterface::getCreatedAt() + * {@inheritdoc} */ public function getCreatedAt() { @@ -97,7 +96,7 @@ public function getCreatedAt() } /** - * @see FOS\MessageBundle\Model\MessageInterface::getBody() + * {@inheritdoc} */ public function getBody() { @@ -105,7 +104,7 @@ public function getBody() } /** - * @see FOS\MessageBundle\Model\MessageInterface::setBody() + * {@inheritdoc} */ public function setBody($body) { @@ -113,7 +112,7 @@ public function setBody($body) } /** - * @see FOS\MessageBundle\Model\MessageInterface::getSender() + * {@inheritdoc} */ public function getSender() { @@ -121,7 +120,7 @@ public function getSender() } /** - * @see FOS\MessageBundle\Model\MessageInterface::setSender() + * {@inheritdoc} */ public function setSender(ParticipantInterface $sender) { @@ -166,7 +165,7 @@ public function getMetadataForParticipant(ParticipantInterface $participant) } /** - * @see FOS\MessageBundle\Model\ReadableInterface::isReadByParticipant() + * {@inheritdoc} */ public function isReadByParticipant(ParticipantInterface $participant) { @@ -178,7 +177,7 @@ public function isReadByParticipant(ParticipantInterface $participant) } /** - * @see FOS\MessageBundle\Model\ReadableInterface::setIsReadByParticipant() + * {@inheritdoc} */ public function setIsReadByParticipant(ParticipantInterface $participant, $isRead) { diff --git a/Model/MessageInterface.php b/Model/MessageInterface.php index 650533f2..c1e77c44 100644 --- a/Model/MessageInterface.php +++ b/Model/MessageInterface.php @@ -2,8 +2,6 @@ namespace FOS\MessageBundle\Model; -use FOS\MessageBundle\Model\ParticipantInterface; - /** * Message model * @@ -16,43 +14,43 @@ interface MessageInterface extends ReadableInterface * * @return mixed */ - function getId(); + public function getId(); /** * @return ThreadInterface */ - function getThread(); + public function getThread(); /** * @param ThreadInterface * @return null */ - function setThread(ThreadInterface $thread); + public function setThread(ThreadInterface $thread); /** - * @return DateTime + * @return \DateTime */ - function getCreatedAt(); + public function getCreatedAt(); /** * @return string */ - function getBody(); + public function getBody(); /** * @param string * @return null */ - function setBody($body); + public function setBody($body); /** * @return ParticipantInterface */ - function getSender(); + public function getSender(); /** * @param ParticipantInterface * @return null */ - function setSender(ParticipantInterface $sender); + public function setSender(ParticipantInterface $sender); } diff --git a/Model/MessageMetadata.php b/Model/MessageMetadata.php index 5e2cf03f..39b27871 100644 --- a/Model/MessageMetadata.php +++ b/Model/MessageMetadata.php @@ -2,12 +2,9 @@ namespace FOS\MessageBundle\Model; -use FOS\MessageBundle\Model\ParticipantInterface; - abstract class MessageMetadata { protected $participant; - protected $isRead = false; /** @@ -20,7 +17,6 @@ public function getParticipant() /** * @param ParticipantInterface $participant - * @return null */ public function setParticipant(ParticipantInterface $participant) { @@ -37,7 +33,6 @@ public function getIsRead() /** * @param boolean $isRead - * @return null */ public function setIsRead($isRead) { diff --git a/Model/ParticipantInterface.php b/Model/ParticipantInterface.php index 0f0c4072..40222450 100644 --- a/Model/ParticipantInterface.php +++ b/Model/ParticipantInterface.php @@ -16,5 +16,5 @@ interface ParticipantInterface * * @return string */ - function getId(); + public function getId(); } diff --git a/Model/ReadableInterface.php b/Model/ReadableInterface.php index dd079478..142839b5 100644 --- a/Model/ReadableInterface.php +++ b/Model/ReadableInterface.php @@ -2,8 +2,6 @@ namespace FOS\MessageBundle\Model; -use FOS\MessageBundle\Model\ParticipantInterface; - interface ReadableInterface { /** @@ -11,7 +9,7 @@ interface ReadableInterface * * @return bool */ - function isReadByParticipant(ParticipantInterface $participant); + public function isReadByParticipant(ParticipantInterface $participant); /** * Sets whether or not this participant has read this @@ -19,5 +17,5 @@ function isReadByParticipant(ParticipantInterface $participant); * @param ParticipantInterface $participant * @param boolean $isRead */ - function setIsReadByParticipant(ParticipantInterface $participant, $isRead); + public function setIsReadByParticipant(ParticipantInterface $participant, $isRead); } diff --git a/Model/Thread.php b/Model/Thread.php index 20bf9d92..7083f24b 100644 --- a/Model/Thread.php +++ b/Model/Thread.php @@ -4,7 +4,6 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use FOS\MessageBundle\Model\ParticipantInterface; /** * Abstract thread model @@ -58,7 +57,7 @@ abstract class Thread implements ThreadInterface /** * Date this thread was created at * - * @var DateTime + * @var \DateTime */ protected $createdAt; @@ -80,7 +79,7 @@ public function __construct() } /** - * @see FOS\MessageBundle\Model\ThreadInterface::getId() + * {@inheritdoc} */ public function getId() { @@ -88,7 +87,7 @@ public function getId() } /** - * @see FOS\MessageBundle\Model\ThreadInterface::getCreatedAt() + * {@inheritdoc} */ public function getCreatedAt() { @@ -96,7 +95,7 @@ public function getCreatedAt() } /** - * @see FOS\MessageBundle\Model\ThreadInterface::setCreatedAt() + * {@inheritdoc} */ public function setCreatedAt(\DateTime $createdAt) { @@ -104,7 +103,7 @@ public function setCreatedAt(\DateTime $createdAt) } /** - * @see FOS\MessageBundle\Model\ThreadInterface::getCreatedBy() + * {@inheritdoc} */ public function getCreatedBy() { @@ -112,7 +111,7 @@ public function getCreatedBy() } /** - * @see FOS\MessageBundle\Model\ThreadInterface::setCreatedBy() + * {@inheritdoc} */ public function setCreatedBy(ParticipantInterface $participant) { @@ -120,7 +119,7 @@ public function setCreatedBy(ParticipantInterface $participant) } /** - * @see FOS\MessageBundle\Model\ThreadInterface::getSubject() + * {@inheritdoc} */ public function getSubject() { @@ -128,7 +127,7 @@ public function getSubject() } /** - * @see FOS\MessageBundle\Model\ThreadInterface::setSubject() + * {@inheritdoc} */ public function setSubject($subject) { @@ -144,8 +143,7 @@ public function getIsSpam() } /** - * @param boolean - * @return null + * @param boolean */ public function setIsSpam($isSpam) { @@ -153,7 +151,7 @@ public function setIsSpam($isSpam) } /** - * @see FOS\MessageBundle\Model\ThreadInterface::addMessage() + * {@inheritdoc} */ public function addMessage(MessageInterface $message) { @@ -161,7 +159,7 @@ public function addMessage(MessageInterface $message) } /** - * @see FOS\MessageBundle\Model\ThreadInterface::getMessages() + * {@inheritdoc} */ public function getMessages() { @@ -169,7 +167,7 @@ public function getMessages() } /** - * @see FOS\MessageBundle\Model\ThreadInterface::getFirstMessage() + * {@inheritdoc} */ public function getFirstMessage() { @@ -177,7 +175,7 @@ public function getFirstMessage() } /** - * @see FOS\MessageBundle\Model\ThreadInterface::getLastMessage() + * {@inheritdoc} */ public function getLastMessage() { @@ -185,7 +183,7 @@ public function getLastMessage() } /** - * @see FOS\MessageBundle\Model\ThreadInterface::isDeletedByParticipant() + * {@inheritdoc} */ public function isDeletedByParticipant(ParticipantInterface $participant) { @@ -197,7 +195,7 @@ public function isDeletedByParticipant(ParticipantInterface $participant) } /** - * @see FOS\MessageBundle\Model\ThreadInterface::setIsDeletedByParticipant() + * {@inheritdoc} */ public function setIsDeletedByParticipant(ParticipantInterface $participant, $isDeleted) { @@ -216,7 +214,7 @@ public function setIsDeletedByParticipant(ParticipantInterface $participant, $is } /** - * @see FOS\MessageBundle\Model\ThreadInterface::setIsDeleted() + * {@inheritdoc} */ public function setIsDeleted($isDeleted) { @@ -226,7 +224,7 @@ public function setIsDeleted($isDeleted) } /** - * @see FOS\MessageBundle\Model\ReadableInterface::isReadByParticipant() + * {@inheritdoc} */ public function isReadByParticipant(ParticipantInterface $participant) { @@ -240,7 +238,7 @@ public function isReadByParticipant(ParticipantInterface $participant) } /** - * @see FOS\MessageBundle\Model\ReadableInterface::setIsReadByParticipant() + * {@inheritdoc} */ public function setIsReadByParticipant(ParticipantInterface $participant, $isRead) { @@ -277,7 +275,7 @@ public function getMetadataForParticipant(ParticipantInterface $participant) } /** - * @see FOS\MessageBundle\Model\ThreadInterface::getOtherParticipants() + * {@inheritdoc} */ public function getOtherParticipants(ParticipantInterface $participant) { diff --git a/Model/ThreadInterface.php b/Model/ThreadInterface.php index a84c2064..181e928c 100644 --- a/Model/ThreadInterface.php +++ b/Model/ThreadInterface.php @@ -2,7 +2,7 @@ namespace FOS\MessageBundle\Model; -use FOS\MessageBundle\Model\ParticipantInterface; +use Doctrine\Common\Collections\Collection; interface ThreadInterface extends ReadableInterface { @@ -11,46 +11,46 @@ interface ThreadInterface extends ReadableInterface * * @return mixed */ - function getId(); + public function getId(); /** * @return string */ - function getSubject(); + public function getSubject(); /** * @param string * @return null */ - function setSubject($subject); + public function setSubject($subject); /** * Gets the messages contained in the thread * * @return Collection of MessageInterface */ - function getMessages(); + public function getMessages(); /** * Adds a new message to the thread * * @param MessageInterface $message */ - function addMessage(MessageInterface $message); + public function addMessage(MessageInterface $message); /** * Gets the first message of the thread * * @return MessageInterface the first message */ - function getFirstMessage(); + public function getFirstMessage(); /** * Gets the last message of the thread * * @return MessageInterface the last message */ - function getLastMessage(); + public function getLastMessage(); /** * Gets the participant that created the thread @@ -58,7 +58,7 @@ function getLastMessage(); * * @return ParticipantInterface */ - function getCreatedBy(); + public function getCreatedBy(); /** * Sets the participant that created the thread @@ -66,15 +66,15 @@ function getCreatedBy(); * * @param ParticipantInterface */ - function setCreatedBy(ParticipantInterface $participant); + public function setCreatedBy(ParticipantInterface $participant); /** * Gets the date this thread was created at * Generally the date of the first message * - * @return DateTime + * @return \DateTime */ - function getCreatedAt(); + public function getCreatedAt(); /** * Sets the date this thread was created at @@ -82,14 +82,14 @@ function getCreatedAt(); * * @param \DateTime $createdAt */ - function setCreatedAt(\DateTime $createdAt); + public function setCreatedAt(\DateTime $createdAt); /** * Gets the users participating in this conversation * * @return ParticipantInterface[] */ - function getParticipants(); + public function getParticipants(); /** * Tells if the user participates to the conversation @@ -97,7 +97,7 @@ function getParticipants(); * @param ParticipantInterface $participant * @return boolean */ - function isParticipant(ParticipantInterface $participant); + public function isParticipant(ParticipantInterface $participant); /** * Adds a participant to the thread @@ -106,14 +106,14 @@ function isParticipant(ParticipantInterface $participant); * @param ParticipantInterface $participant * @return null */ - function addParticipant(ParticipantInterface $participant); + public function addParticipant(ParticipantInterface $participant); /** * Tells if this thread is deleted by this participant * * @return bool */ - function isDeletedByParticipant(ParticipantInterface $participant); + public function isDeletedByParticipant(ParticipantInterface $participant); /** * Sets whether or not this participant has deleted this thread @@ -121,14 +121,14 @@ function isDeletedByParticipant(ParticipantInterface $participant); * @param ParticipantInterface $participant * @param boolean $isDeleted */ - function setIsDeletedByParticipant(ParticipantInterface $participant, $isDeleted); + public function setIsDeletedByParticipant(ParticipantInterface $participant, $isDeleted); /** * Sets the thread as deleted or not deleted for all participants * * @param boolean $isDeleted */ - function setIsDeleted($isDeleted); + public function setIsDeleted($isDeleted); /** * Get the participants this participant is talking with. @@ -137,5 +137,5 @@ function setIsDeleted($isDeleted); * * @return ParticipantInterface[] */ - function getOtherParticipants(ParticipantInterface $participant); + public function getOtherParticipants(ParticipantInterface $participant); } diff --git a/Model/ThreadMetadata.php b/Model/ThreadMetadata.php index 9f3ac2bd..f988db8a 100644 --- a/Model/ThreadMetadata.php +++ b/Model/ThreadMetadata.php @@ -2,25 +2,22 @@ namespace FOS\MessageBundle\Model; -use FOS\MessageBundle\Model\ParticipantInterface; - abstract class ThreadMetadata { protected $participant; - protected $isDeleted = false; /** * Date of last message written by the participant * - * @var DateTime + * @var \DateTime */ protected $lastParticipantMessageDate; /** * Date of last message written by another participant * - * @var DateTime + * @var \DateTime */ protected $lastMessageDate; @@ -34,7 +31,6 @@ public function getParticipant() /** * @param ParticipantInterface - * @return null */ public function setParticipant(ParticipantInterface $participant) { @@ -51,7 +47,6 @@ public function getIsDeleted() /** * @param boolean $isDeleted - * @return null */ public function setIsDeleted($isDeleted) { @@ -59,7 +54,7 @@ public function setIsDeleted($isDeleted) } /** - * @return DateTime + * @return \DateTime */ public function getLastParticipantMessageDate() { @@ -67,8 +62,7 @@ public function getLastParticipantMessageDate() } /** - * @param DateTime $date - * @return null + * @param \DateTime $date */ public function setLastParticipantMessageDate(\DateTime $date) { @@ -76,7 +70,7 @@ public function setLastParticipantMessageDate(\DateTime $date) } /** - * @return DateTime + * @return \DateTime */ public function getLastMessageDate() { @@ -84,8 +78,7 @@ public function getLastMessageDate() } /** - * @param DateTime $date - * @return null + * @param \DateTime $date */ public function setLastMessageDate(\DateTime $date) { diff --git a/ModelManager/MessageManager.php b/ModelManager/MessageManager.php index e6b4a35b..16e00ec5 100644 --- a/ModelManager/MessageManager.php +++ b/ModelManager/MessageManager.php @@ -2,6 +2,8 @@ namespace FOS\MessageBundle\ModelManager; +use FOS\MessageBundle\Model\MessageInterface; + /** * Abstract Message Manager implementation which can be used as base by * your concrete manager. @@ -18,8 +20,7 @@ abstract class MessageManager implements MessageManagerInterface public function createMessage() { $class = $this->getClass(); - $message = new $class; - return $message; + return new $class(); } } diff --git a/ModelManager/MessageManagerInterface.php b/ModelManager/MessageManagerInterface.php index 4b142209..072b0ceb 100644 --- a/ModelManager/MessageManagerInterface.php +++ b/ModelManager/MessageManagerInterface.php @@ -21,14 +21,14 @@ interface MessageManagerInterface extends ReadableManagerInterface * @param ParticipantInterface $participant * @return int the number of unread messages */ - function getNbUnreadMessageByParticipant(ParticipantInterface $participant); + public function getNbUnreadMessageByParticipant(ParticipantInterface $participant); /** * Creates an empty message instance * * @return MessageInterface */ - function createMessage(); + public function createMessage(); /** * Saves a message @@ -36,12 +36,12 @@ function createMessage(); * @param MessageInterface $message * @param Boolean $andFlush Whether to flush the changes (default true) */ - function saveMessage(MessageInterface $message, $andFlush = true); + public function saveMessage(MessageInterface $message, $andFlush = true); /** * Returns the message's fully qualified class MessageManagerInterface. * * @return string */ - function getClass(); + public function getClass(); } diff --git a/ModelManager/ReadableManagerInterface.php b/ModelManager/ReadableManagerInterface.php index 94b90868..c284e7d4 100644 --- a/ModelManager/ReadableManagerInterface.php +++ b/ModelManager/ReadableManagerInterface.php @@ -23,7 +23,7 @@ interface ReadableManagerInterface * @param ReadableInterface $readable * @param ParticipantInterface $user */ - function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterface $user); + public function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterface $user); /** * Marks the readable as unread by this participant @@ -31,5 +31,5 @@ function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterfa * @param ReadableInterface $readable * @param ParticipantInterface $user */ - function markAsUnreadByParticipant(ReadableInterface $readable, ParticipantInterface $user); + public function markAsUnreadByParticipant(ReadableInterface $readable, ParticipantInterface $user); } diff --git a/ModelManager/ThreadManager.php b/ModelManager/ThreadManager.php index baa6234e..bab2e4ed 100644 --- a/ModelManager/ThreadManager.php +++ b/ModelManager/ThreadManager.php @@ -2,6 +2,8 @@ namespace FOS\MessageBundle\ModelManager; +use FOS\MessageBundle\Model\ThreadInterface; + /** * Abstract Thread Manager implementation which can be used as base class by your * concrete manager. @@ -18,8 +20,7 @@ abstract class ThreadManager implements ThreadManagerInterface public function createThread() { $class = $this->getClass(); - $commentThread = new $class; - return $commentThread; + return new $class(); } } diff --git a/ModelManager/ThreadManagerInterface.php b/ModelManager/ThreadManagerInterface.php index 5177263a..17e848d5 100644 --- a/ModelManager/ThreadManagerInterface.php +++ b/ModelManager/ThreadManagerInterface.php @@ -20,7 +20,7 @@ interface ThreadManagerInterface extends ReadableManagerInterface * * @return ThreadInterface or null */ - function findThreadById($id); + public function findThreadById($id); /** * Finds not deleted threads for a participant, @@ -31,7 +31,7 @@ function findThreadById($id); * @param ParticipantInterface $participant * @return Builder a query builder suitable for pagination */ - function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $participant); + public function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $participant); /** * Finds not deleted threads for a participant, @@ -42,7 +42,7 @@ function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $participan * @param ParticipantInterface $participant * @return ThreadInterface[] */ - function findParticipantInboxThreads(ParticipantInterface $participant); + public function findParticipantInboxThreads(ParticipantInterface $participant); /** * Finds not deleted threads from a participant, @@ -53,7 +53,7 @@ function findParticipantInboxThreads(ParticipantInterface $participant); * @param ParticipantInterface $participant * @return Builder a query builder suitable for pagination */ - function getParticipantSentThreadsQueryBuilder(ParticipantInterface $participant); + public function getParticipantSentThreadsQueryBuilder(ParticipantInterface $participant); /** * Finds not deleted threads from a participant, @@ -64,7 +64,7 @@ function getParticipantSentThreadsQueryBuilder(ParticipantInterface $participant * @param ParticipantInterface $participant * @return ThreadInterface[] */ - function findParticipantSentThreads(ParticipantInterface $participant); + public function findParticipantSentThreads(ParticipantInterface $participant); /** * Finds deleted threads from a participant, @@ -73,7 +73,7 @@ function findParticipantSentThreads(ParticipantInterface $participant); * @param ParticipantInterface $participant * @return Builder a query builder suitable for pagination */ - function getParticipantDeletedThreadsQueryBuilder(ParticipantInterface $participant); + public function getParticipantDeletedThreadsQueryBuilder(ParticipantInterface $participant); /** * Finds deleted threads from a participant, @@ -82,7 +82,7 @@ function getParticipantDeletedThreadsQueryBuilder(ParticipantInterface $particip * @param ParticipantInterface $participant * @return ThreadInterface[] */ - function findParticipantDeletedThreads(ParticipantInterface $participant); + public function findParticipantDeletedThreads(ParticipantInterface $participant); /** * Finds not deleted threads for a participant, @@ -93,7 +93,7 @@ function findParticipantDeletedThreads(ParticipantInterface $participant); * @param string $search * @return Builder a query builder suitable for pagination */ - function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $participant, $search); + public function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $participant, $search); /** * Finds not deleted threads for a participant, @@ -104,7 +104,7 @@ function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $partici * @param string $search * @return ThreadInterface[] */ - function findParticipantThreadsBySearch(ParticipantInterface $participant, $search); + public function findParticipantThreadsBySearch(ParticipantInterface $participant, $search); /** * Gets threads created by a participant @@ -112,14 +112,14 @@ function findParticipantThreadsBySearch(ParticipantInterface $participant, $sear * @param ParticipantInterface $participant * @return ThreadInterface[] */ - function findThreadsCreatedBy(ParticipantInterface $participant); + public function findThreadsCreatedBy(ParticipantInterface $participant); /** * Creates an empty comment thread instance * * @return ThreadInterface */ - function createThread(); + public function createThread(); /** * Saves a thread @@ -127,7 +127,7 @@ function createThread(); * @param ThreadInterface $thread * @param Boolean $andFlush Whether to flush the changes (default true) */ - function saveThread(ThreadInterface $thread, $andFlush = true); + public function saveThread(ThreadInterface $thread, $andFlush = true); /** * Deletes a thread @@ -135,5 +135,5 @@ function saveThread(ThreadInterface $thread, $andFlush = true); * * @param ThreadInterface $thread the thread to delete */ - function deleteThread(ThreadInterface $thread); + public function deleteThread(ThreadInterface $thread); } diff --git a/Provider/Provider.php b/Provider/Provider.php index 90432752..56287583 100644 --- a/Provider/Provider.php +++ b/Provider/Provider.php @@ -2,6 +2,7 @@ namespace FOS\MessageBundle\Provider; +use FOS\MessageBundle\Model\ParticipantInterface; use FOS\MessageBundle\Model\ThreadInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Security\Core\Exception\AccessDeniedException; @@ -63,9 +64,7 @@ public function __construct(ThreadManagerInterface $threadManager, MessageManage } /** - * Gets the thread in the inbox of the current user - * - * @return ThreadInterface[] + * {@inheritdoc} */ public function getInboxThreads() { @@ -75,9 +74,7 @@ public function getInboxThreads() } /** - * Gets the thread in the sentbox of the current user - * - * @return ThreadInterface[] + * {@inheritdoc} */ public function getSentThreads() { @@ -97,11 +94,7 @@ public function getDeletedThreads() } /** - * Gets a thread by its ID - * Performs authorization checks - * Marks the thread as read - * - * @return ThreadInterface + * {@inheritdoc} */ public function getThread($threadId) { @@ -121,9 +114,7 @@ public function getThread($threadId) } /** - * Tells how many unread messages the authenticated participant has - * - * @return int the number of unread messages + * {@inheritdoc} */ public function getNbUnreadMessages() { diff --git a/Provider/ProviderInterface.php b/Provider/ProviderInterface.php index 9be5e039..ec7c02ee 100644 --- a/Provider/ProviderInterface.php +++ b/Provider/ProviderInterface.php @@ -16,21 +16,21 @@ interface ProviderInterface * * @return ThreadInterface[] */ - function getInboxThreads(); + public function getInboxThreads(); /** * Gets the thread in the sentbox of the current user * * @return ThreadInterface[] */ - function getSentThreads(); + public function getSentThreads(); /** * Gets the deleted threads of the current user * * @return ThreadInterface[] */ - function getDeletedThreads(); + public function getDeletedThreads(); /** * Gets a thread by its ID @@ -39,12 +39,12 @@ function getDeletedThreads(); * * @return ThreadInterface */ - function getThread($threadId); + public function getThread($threadId); /** * Tells how many unread messages the authenticated participant has * * @return int the number of unread messages */ - function getNbUnreadMessages(); + public function getNbUnreadMessages(); } diff --git a/Reader/Reader.php b/Reader/Reader.php index 1ddcf463..fd5442c7 100644 --- a/Reader/Reader.php +++ b/Reader/Reader.php @@ -2,6 +2,7 @@ namespace FOS\MessageBundle\Reader; +use FOS\MessageBundle\Model\ParticipantInterface; use FOS\MessageBundle\Security\ParticipantProviderInterface; use FOS\MessageBundle\Model\ReadableInterface; use FOS\MessageBundle\ModelManager\ReadableManagerInterface; @@ -45,9 +46,7 @@ public function __construct(ParticipantProviderInterface $participantProvider, R } /** - * Marks the readable as read by the current authenticated user - * - * @param ReadableInterface $readable + * {@inheritdoc} */ public function markAsRead(ReadableInterface $readable) { @@ -61,9 +60,7 @@ public function markAsRead(ReadableInterface $readable) } /** - * Marks the readable as unread by the current authenticated user - * - * @param ReadableInterface $readable + * {@inheritdoc} */ public function markAsUnread(ReadableInterface $readable) { diff --git a/Reader/ReaderInterface.php b/Reader/ReaderInterface.php index e31d98ee..ad1acdb2 100644 --- a/Reader/ReaderInterface.php +++ b/Reader/ReaderInterface.php @@ -16,12 +16,12 @@ interface ReaderInterface * * @param ReadableInterface $readable */ - function markAsRead(ReadableInterface $readable); + public function markAsRead(ReadableInterface $readable); /** * Marks the readable as unread by the current authenticated user * * @param ReadableInterface $readable */ - function markAsUnread(ReadableInterface $readable); + public function markAsUnread(ReadableInterface $readable); } diff --git a/Search/Finder.php b/Search/Finder.php index c72ee4a2..53d3d0f4 100644 --- a/Search/Finder.php +++ b/Search/Finder.php @@ -2,6 +2,7 @@ namespace FOS\MessageBundle\Search; +use FOS\MessageBundle\Model\ParticipantInterface; use FOS\MessageBundle\Model\ThreadInterface; use FOS\MessageBundle\ModelManager\ThreadManagerInterface; use FOS\MessageBundle\Security\ParticipantProviderInterface; @@ -34,10 +35,7 @@ public function __construct(ParticipantProviderInterface $participantProvider, T } /** - * Finds threads of a participant, matching a given query - * - * @param Query $query - * @return ThreadInterface[] + * {@inheritdoc} */ public function find(Query $query) { @@ -45,10 +43,7 @@ public function find(Query $query) } /** - * Finds threads of a participant, matching a given query - * - * @param Query $query - * @return mixed a query builder suitable for pagination + * {@inheritdoc} */ public function getQueryBuilder(Query $query) { diff --git a/Search/FinderInterface.php b/Search/FinderInterface.php index f3708eff..597dd9ed 100644 --- a/Search/FinderInterface.php +++ b/Search/FinderInterface.php @@ -17,7 +17,7 @@ interface FinderInterface * @param Query $query * @return ThreadInterface[] */ - function find(Query $query); + public function find(Query $query); /** * Finds threads of a participant, matching a given query @@ -25,5 +25,5 @@ function find(Query $query); * @param Query $query * @return Builder a query builder suitable for pagination */ - function getQueryBuilder(Query $query); + public function getQueryBuilder(Query $query); } diff --git a/Search/Query.php b/Search/Query.php index 68acf70a..eab152f9 100644 --- a/Search/Query.php +++ b/Search/Query.php @@ -18,8 +18,8 @@ class Query protected $escaped = null; /** - * @param string original - * @param string escaped + * @param string $original + * @param string $escaped */ public function __construct($original, $escaped) { @@ -36,7 +36,7 @@ public function getOriginal() } /** - * @param string original + * @param string $original */ public function setOriginal($original) { @@ -52,7 +52,7 @@ public function getEscaped() } /** - * @param string escaped + * @param string $escaped */ public function setEscaped($escaped) { diff --git a/Search/QueryFactory.php b/Search/QueryFactory.php index a735205c..70e801a3 100644 --- a/Search/QueryFactory.php +++ b/Search/QueryFactory.php @@ -12,7 +12,7 @@ class QueryFactory implements QueryFactoryInterface /** * @var Request */ - protected $request = null; + protected $request; /** * the query parameter containing the search term @@ -34,9 +34,7 @@ public function __construct(Request $request, $queryParameter) } /** - * Gets the search term - * - * @return Term the term object + * {@inheritdoc} */ public function createFromRequest() { @@ -51,7 +49,7 @@ public function createFromRequest() /** * Sets: the query parameter containing the search term * - * @param string queryParameter + * @param string $queryParameter */ public function setQueryParameter($queryParameter) { diff --git a/Search/QueryFactoryInterface.php b/Search/QueryFactoryInterface.php index 7ffd89fb..ceaee7bf 100644 --- a/Search/QueryFactoryInterface.php +++ b/Search/QueryFactoryInterface.php @@ -12,5 +12,5 @@ interface QueryFactoryInterface * * @return Query the term object */ - function createFromRequest(); + public function createFromRequest(); } diff --git a/Security/Authorizer.php b/Security/Authorizer.php index 432af194..b699ae57 100644 --- a/Security/Authorizer.php +++ b/Security/Authorizer.php @@ -3,9 +3,7 @@ namespace FOS\MessageBundle\Security; use FOS\MessageBundle\Model\ThreadInterface; -use Symfony\Component\Security\Core\Exception\AccessDeniedException; use FOS\MessageBundle\Model\ParticipantInterface; -use FOS\MessageBundle\Security\ParticipantProviderInterface; /** * Manages permissions to manipulate threads and messages @@ -15,8 +13,6 @@ class Authorizer implements AuthorizerInterface { /** - * The participant provider - * * @var ParticipantProviderInterface */ protected $participantProvider; @@ -27,11 +23,7 @@ public function __construct(ParticipantProviderInterface $participantProvider) } /** - * Tells if the current participant is allowed - * to see this thread - * - * @param ThreadInterface $thread - * @return boolean + * {@inheritdoc} */ public function canSeeThread(ThreadInterface $thread) { @@ -39,11 +31,7 @@ public function canSeeThread(ThreadInterface $thread) } /** - * Tells if the current participant is allowed - * to delete this thread - * - * @param ThreadInterface $thread - * @return boolean + * {@inheritdoc} */ public function canDeleteThread(ThreadInterface $thread) { @@ -51,11 +39,7 @@ public function canDeleteThread(ThreadInterface $thread) } /** - * Tells if the current participant is allowed - * to send a message to this other participant - * - * @param ParticipantInterface $participant the one we want to send a message to - * @return boolean + * {@inheritdoc} */ public function canMessageParticipant(ParticipantInterface $participant) { diff --git a/Security/AuthorizerInterface.php b/Security/AuthorizerInterface.php index f4ec91ec..a922efd4 100644 --- a/Security/AuthorizerInterface.php +++ b/Security/AuthorizerInterface.php @@ -19,7 +19,7 @@ interface AuthorizerInterface * @param ThreadInterface $thread * @return boolean */ - function canSeeThread(ThreadInterface $thread); + public function canSeeThread(ThreadInterface $thread); /** * Tells if the current participant is allowed @@ -28,7 +28,7 @@ function canSeeThread(ThreadInterface $thread); * @param ThreadInterface $thread * @return boolean */ - function canDeleteThread(ThreadInterface $thread); + public function canDeleteThread(ThreadInterface $thread); /** * Tells if the current participant is allowed @@ -37,5 +37,5 @@ function canDeleteThread(ThreadInterface $thread); * @param ParticipantInterface $participant the one we want to send a message to * @return boolean */ - function canMessageParticipant(ParticipantInterface $participant); + public function canMessageParticipant(ParticipantInterface $participant); } diff --git a/Security/ParticipantProvider.php b/Security/ParticipantProvider.php index f1fd7b70..0fbc89d4 100644 --- a/Security/ParticipantProvider.php +++ b/Security/ParticipantProvider.php @@ -14,8 +14,6 @@ class ParticipantProvider implements ParticipantProviderInterface { /** - * The security context - * * @var SecurityContextInterface */ protected $securityContext; @@ -26,9 +24,7 @@ public function __construct(SecurityContextInterface $securityContext) } /** - * Gets the current authenticated user - * - * @return ParticipantInterface + * {@inheritdoc} */ public function getAuthenticatedParticipant() { diff --git a/Security/ParticipantProviderInterface.php b/Security/ParticipantProviderInterface.php index c966bc64..a49a1763 100644 --- a/Security/ParticipantProviderInterface.php +++ b/Security/ParticipantProviderInterface.php @@ -16,5 +16,5 @@ interface ParticipantProviderInterface * * @return ParticipantInterface */ - function getAuthenticatedParticipant(); + public function getAuthenticatedParticipant(); } diff --git a/Sender/Sender.php b/Sender/Sender.php index 5fa3cc33..0fb607bf 100644 --- a/Sender/Sender.php +++ b/Sender/Sender.php @@ -17,22 +17,16 @@ class Sender implements SenderInterface { /** - * The message manager - * * @var MessageManagerInterface */ protected $messageManager; /** - * The thread manager - * * @var ThreadManagerInterface */ protected $threadManager; /** - * The event dispatcher - * * @var EventDispatcherInterface */ protected $dispatcher; @@ -45,10 +39,7 @@ public function __construct(MessageManagerInterface $messageManager, ThreadManag } /** - * Sends the message by persisting it to the message manager and undeletes - * the thread for all participants. - * - * @param MessageInterface $message + * {@inheritdoc} */ public function send(MessageInterface $message) { diff --git a/Sender/SenderInterface.php b/Sender/SenderInterface.php index 9f3873e9..c038ebdb 100644 --- a/Sender/SenderInterface.php +++ b/Sender/SenderInterface.php @@ -16,5 +16,5 @@ interface SenderInterface * * @param MessageInterface $message */ - function send(MessageInterface $message); + public function send(MessageInterface $message); } diff --git a/SpamDetection/AkismetSpamDetector.php b/SpamDetection/AkismetSpamDetector.php index 6bba9bd8..5e5ebd40 100644 --- a/SpamDetection/AkismetSpamDetector.php +++ b/SpamDetection/AkismetSpamDetector.php @@ -9,15 +9,11 @@ class AkismetSpamDetector implements SpamDetectorInterface { /** - * Akismet instance - * * @var AkismetInterface */ protected $akismet; /** - * The participantProvider instance - * * @var ParticipantProviderInterface */ protected $participantProvider; @@ -29,10 +25,7 @@ public function __construct(AkismetInterface $akismet, ParticipantProviderInterf } /** - * Tells whether or not a new message looks like spam - * - * @param NewThreadMessage $message - * @return boolean true if it is spam, false otherwise + * {@inheritdoc} */ public function isSpam(NewThreadMessage $message) { diff --git a/SpamDetection/NoopSpamDetector.php b/SpamDetection/NoopSpamDetector.php index 155d1dc3..610b82e1 100644 --- a/SpamDetection/NoopSpamDetector.php +++ b/SpamDetection/NoopSpamDetector.php @@ -7,10 +7,7 @@ class NoopSpamDetector implements SpamDetectorInterface { /** - * Tells whether or not a new message looks like spam - * - * @param NewThreadMessage $message - * @return boolean true if it is spam, false otherwise + * {@inheritdoc} */ public function isSpam(NewThreadMessage $message) { diff --git a/SpamDetection/SpamDetectorInterface.php b/SpamDetection/SpamDetectorInterface.php index 6d412af7..cfa38a14 100644 --- a/SpamDetection/SpamDetectorInterface.php +++ b/SpamDetection/SpamDetectorInterface.php @@ -17,5 +17,5 @@ interface SpamDetectorInterface * @param NewThreadMessage $message * @return boolean true if it is spam, false otherwise */ - function isSpam(NewThreadMessage $message); + public function isSpam(NewThreadMessage $message); } diff --git a/Twig/Extension/MessageExtension.php b/Twig/Extension/MessageExtension.php index 80943d17..84cdbc5e 100644 --- a/Twig/Extension/MessageExtension.php +++ b/Twig/Extension/MessageExtension.php @@ -2,6 +2,7 @@ namespace FOS\MessageBundle\Twig\Extension; +use FOS\MessageBundle\Model\ParticipantInterface; use FOS\MessageBundle\Security\ParticipantProviderInterface; use FOS\MessageBundle\Model\ReadableInterface; use FOS\MessageBundle\Provider\ProviderInterface; @@ -24,9 +25,7 @@ public function __construct(ParticipantProviderInterface $participantProvider, P } /** - * Returns a list of global functions to add to the existing list. - * - * @return array An array of global functions + * {@inheritdoc} */ public function getFunctions() { @@ -98,9 +97,7 @@ protected function getAuthenticatedParticipant() } /** - * Returns the name of the extension. - * - * @return string The extension name + * {@inheritdoc} */ public function getName() { diff --git a/Validator/AuthorizationValidator.php b/Validator/AuthorizationValidator.php index 65db2386..328017e2 100644 --- a/Validator/AuthorizationValidator.php +++ b/Validator/AuthorizationValidator.php @@ -13,11 +13,6 @@ class AuthorizationValidator extends ConstraintValidator */ protected $authorizer; - /** - * Constructor - * - * @param AuthorizerInterface $authorizer - */ public function __construct(AuthorizerInterface $authorizer) { $this->authorizer = $authorizer; diff --git a/Validator/ReplyAuthorizationValidator.php b/Validator/ReplyAuthorizationValidator.php index 3e797b5f..e7cc65f3 100644 --- a/Validator/ReplyAuthorizationValidator.php +++ b/Validator/ReplyAuthorizationValidator.php @@ -15,11 +15,10 @@ class ReplyAuthorizationValidator extends ConstraintValidator protected $authorizer; /** - * Constructor - * - * @param AuthorizerInterface $authorizer - * @param ParticipantProviderInterface $participantProvider + * @var ParticipantProviderInterface */ + protected $participantProvider; + public function __construct(AuthorizerInterface $authorizer, ParticipantProviderInterface $participantProvider) { $this->authorizer = $authorizer; @@ -36,10 +35,10 @@ public function validate($value, Constraint $constraint) { $sender = $this->participantProvider->getAuthenticatedParticipant(); $recipients = $value->getThread()->getOtherParticipants($sender); + foreach ($recipients as $recipient) { if (!$this->authorizer->canMessageParticipant($recipient)) { $this->context->addViolation($constraint->message); - return; } } diff --git a/Validator/SelfRecipientValidator.php b/Validator/SelfRecipientValidator.php index 1a7aea88..f48b8fb2 100644 --- a/Validator/SelfRecipientValidator.php +++ b/Validator/SelfRecipientValidator.php @@ -13,11 +13,6 @@ class SelfRecipientValidator extends ConstraintValidator */ protected $participantProvider; - /** - * Constructor - * - * @param ParticipantProviderInterface $participantProvider - */ public function __construct(ParticipantProviderInterface $participantProvider) { $this->participantProvider = $participantProvider; diff --git a/Validator/SpamValidator.php b/Validator/SpamValidator.php index 729b6d8e..db0530f2 100644 --- a/Validator/SpamValidator.php +++ b/Validator/SpamValidator.php @@ -13,11 +13,6 @@ class SpamValidator extends ConstraintValidator */ protected $spamDetector; - /** - * Constructor - * - * @param SpamDetectorInterface $spamDetector - */ public function __construct(SpamDetectorInterface $spamDetector) { $this->spamDetector = $spamDetector;