Skip to content

Commit

Permalink
Normalize coding style to the whole project
Browse files Browse the repository at this point in the history
  • Loading branch information
tgalopin committed Sep 4, 2016
1 parent 4e6c19e commit 96cefae
Show file tree
Hide file tree
Showing 83 changed files with 501 additions and 452 deletions.
10 changes: 10 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$finder = Symfony\CS\Finder::create()
->exclude('Resources')
->in(__DIR__)
;

return Symfony\CS\Config::create()
->finder($finder)
;
25 changes: 16 additions & 9 deletions Command/MongoDBMigrateMetadataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ protected function initialize(InputInterface $input, OutputInterface $output)
'fsync' => $input->getOption('fsync'),
);

$this->printStatusCallback = function() {};
$this->printStatusCallback = function () {
};
register_tick_function(array($this, 'printStatus'));
}

Expand All @@ -128,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

/**
* Migrate message documents
* Migrate message documents.
*/
private function migrateMessages(OutputInterface $output)
{
Expand All @@ -145,10 +146,11 @@ private function migrateMessages(OutputInterface $output)

if (!$numTotal = $cursor->count()) {
$output->writeln('There are no message documents to migrate.');

return;
}

$this->printStatusCallback = function() use ($output, &$numProcessed, $numTotal) {
$this->printStatusCallback = function () use ($output, &$numProcessed, $numTotal) {
$output->write(sprintf("Processed: <info>%d</info> / Complete: <info>%d%%</info>\r", $numProcessed, round(100 * ($numProcessed / $numTotal))));
};

Expand All @@ -169,12 +171,12 @@ private function migrateMessages(OutputInterface $output)
}
}

$output->write(str_repeat(' ', 28 + ceil(log10($numProcessed))) . "\r");
$output->write(str_repeat(' ', 28 + ceil(log10($numProcessed)))."\r");
$output->writeln(sprintf('Migrated <info>%d</info> message documents.', $numProcessed));
}

/**
* Migrate thread documents
* Migrate thread documents.
*/
private function migrateThreads(OutputInterface $output)
{
Expand All @@ -194,10 +196,11 @@ private function migrateThreads(OutputInterface $output)

if (!$numTotal = $cursor->count()) {
$output->writeln('There are no thread documents to migrate.');

return;
}

$this->printStatusCallback = function() use ($output, &$numProcessed, $numTotal) {
$this->printStatusCallback = function () use ($output, &$numProcessed, $numTotal) {
$output->write(sprintf("Processed: <info>%d</info> / Complete: <info>%d%%</info>\r", $numProcessed, round(100 * ($numProcessed / $numTotal))));
};

Expand All @@ -222,7 +225,7 @@ private function migrateThreads(OutputInterface $output)
}
}

$output->write(str_repeat(' ', 28 + ceil(log10($numProcessed))) . "\r");
$output->write(str_repeat(' ', 28 + ceil(log10($numProcessed)))."\r");
$output->writeln(sprintf('Migrated <info>%d</info> thread documents.', $numProcessed));
}

Expand Down Expand Up @@ -250,6 +253,7 @@ private function createMessageMetadata(array &$message)
* Sets the unreadForParticipants array on the message.
*
* @see Message::doEnsureUnreadForParticipantsArray()
*
* @param array &$message
*/
private function createMessageUnreadForParticipants(array &$message)
Expand Down Expand Up @@ -328,6 +332,7 @@ private function createThreadLastMessageDate(array &$thread)
* Sets the active participant arrays on the thread.
*
* @see Thread::doEnsureActiveParticipantArrays()
*
* @param array $thread
*/
private function createThreadActiveParticipantArrays(array &$thread)
Expand Down Expand Up @@ -386,11 +391,13 @@ private function createThreadActiveParticipantArrays(array &$thread)
}

/**
* Get the MongoCollection for the given class
* Get the MongoCollection for the given class.
*
* @param ManagerRegistry $registry
* @param string $class
*
* @return \MongoCollection
*
* @throws \RuntimeException if the class has no DocumentManager
*/
private function getMongoCollectionForClass(ManagerRegistry $registry, $class)
Expand All @@ -403,7 +410,7 @@ private function getMongoCollectionForClass(ManagerRegistry $registry, $class)
}

/**
* Invokes the print status callback
* Invokes the print status callback.
*
* Since unregister_tick_function() does not support anonymous functions, it
* is easier to register one method (this) and invoke a dynamic callback.
Expand Down
11 changes: 5 additions & 6 deletions Composer/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@
namespace FOS\MessageBundle\Composer;

use FOS\MessageBundle\ModelManager\MessageManagerInterface;
use FOS\MessageBundle\Sender\SenderInterface;
use FOS\MessageBundle\Model\ThreadInterface;
use FOS\MessageBundle\ModelManager\ThreadManagerInterface;
use FOS\MessageBundle\MessageBuilder\NewThreadMessageBuilder;
use FOS\MessageBundle\MessageBuilder\ReplyMessageBuilder;

/**
* Factory for message builders
* Factory for message builders.
*
* @author Thibault Duplessis <[email protected]>
*/
class Composer implements ComposerInterface
{
/**
* Message manager
* Message manager.
*
* @var MessageManagerInterface
*/
protected $messageManager;

/**
* Thread manager
* Thread manager.
*
* @var ThreadManagerInterface
*/
Expand All @@ -37,7 +36,7 @@ public function __construct(MessageManagerInterface $messageManager, ThreadManag
}

/**
* Starts composing a message, starting a new thread
* Starts composing a message, starting a new thread.
*
* @return NewThreadMessageBuilder
*/
Expand All @@ -50,7 +49,7 @@ public function newThread()
}

/**
* Starts composing a message in a reply to a thread
* Starts composing a message in a reply to a thread.
*
* @return ReplyMessageBuilder
*/
Expand Down
6 changes: 3 additions & 3 deletions Composer/ComposerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
use FOS\MessageBundle\Model\ThreadInterface;

/**
* Factory for message builders
* Factory for message builders.
*
* @author Thibault Duplessis <[email protected]>
*/
interface ComposerInterface
{
/**
* Starts composing a message, starting a new thread
* Starts composing a message, starting a new thread.
*
* @return AbstractMessageBuilder
*/
public function newThread();

/**
* Starts composing a message in a reply to a thread
* Starts composing a message in a reply to a thread.
*
* @return AbstractMessageBuilder
*/
Expand Down
36 changes: 18 additions & 18 deletions Controller/MessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MessageController implements ContainerAwareInterface
protected $container;

/**
* Displays the authenticated participant inbox
* Displays the authenticated participant inbox.
*
* @return Response
*/
Expand All @@ -25,12 +25,12 @@ public function inboxAction()
$threads = $this->getProvider()->getInboxThreads();

return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:inbox.html.twig', array(
'threads' => $threads
'threads' => $threads,
));
}

/**
* Displays the authenticated participant messages sent
* Displays the authenticated participant messages sent.
*
* @return Response
*/
Expand All @@ -39,12 +39,12 @@ public function sentAction()
$threads = $this->getProvider()->getSentThreads();

return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:sent.html.twig', array(
'threads' => $threads
'threads' => $threads,
));
}

/**
* Displays the authenticated participant deleted threads
* Displays the authenticated participant deleted threads.
*
* @return Response
*/
Expand All @@ -53,12 +53,12 @@ public function deletedAction()
$threads = $this->getProvider()->getDeletedThreads();

return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:deleted.html.twig', array(
'threads' => $threads
'threads' => $threads,
));
}

/**
* Displays a thread, also allows to reply to it
* Displays a thread, also allows to reply to it.
*
* @param string $threadId the thread id
*
Expand All @@ -72,18 +72,18 @@ public function threadAction($threadId)

if ($message = $formHandler->process($form)) {
return new RedirectResponse($this->container->get('router')->generate('fos_message_thread_view', array(
'threadId' => $message->getThread()->getId()
'threadId' => $message->getThread()->getId(),
)));
}

return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:thread.html.twig', array(
'form' => $form->createView(),
'thread' => $thread
'thread' => $thread,
));
}

/**
* Create a new message thread
* Create a new message thread.
*
* @return Response
*/
Expand All @@ -94,18 +94,18 @@ public function newThreadAction()

if ($message = $formHandler->process($form)) {
return new RedirectResponse($this->container->get('router')->generate('fos_message_thread_view', array(
'threadId' => $message->getThread()->getId()
'threadId' => $message->getThread()->getId(),
)));
}

return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:newThread.html.twig', array(
'form' => $form->createView(),
'data' => $form->getData()
'data' => $form->getData(),
));
}

/**
* Deletes a thread
* Deletes a thread.
*
* @param string $threadId the thread id
*
Expand All @@ -119,9 +119,9 @@ public function deleteAction($threadId)

return new RedirectResponse($this->container->get('router')->generate('fos_message_inbox'));
}

/**
* Undeletes a thread
* Undeletes a thread.
*
* @param string $threadId
*
Expand All @@ -137,7 +137,7 @@ public function undeleteAction($threadId)
}

/**
* Searches for messages in the inbox and sentbox
* Searches for messages in the inbox and sentbox.
*
* @return Response
*/
Expand All @@ -148,12 +148,12 @@ public function searchAction()

return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:search.html.twig', array(
'query' => $query,
'threads' => $threads
'threads' => $threads,
));
}

/**
* Gets the provider service
* Gets the provider service.
*
* @return ProviderInterface
*/
Expand Down
9 changes: 6 additions & 3 deletions DataTransformer/RecipientsDataTransformer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace FOS\MessageBundle\DataTransformer;

use Symfony\Component\Form\DataTransformerInterface;
Expand All @@ -7,8 +8,9 @@
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;

/**
* Transforms collection of UserInterface into strings separated with coma
* Transforms collection of UserInterface into strings separated with coma.
*
* @author Łukasz Pospiech <[email protected]>
*/
Expand All @@ -25,7 +27,7 @@ public function __construct(DataTransformerInterface $userToUsernameTransformer)
}

/**
* Transforms a collection of recipients into a string
* Transforms a collection of recipients into a string.
*
* @param Collection $recipients
*
Expand All @@ -47,12 +49,13 @@ public function transform($recipients)
}

/**
* Transforms a string (usernames) to a Collection of UserInterface
* Transforms a string (usernames) to a Collection of UserInterface.
*
* @param string $usernames
*
* @throws UnexpectedTypeException
* @throws TransformationFailedException
*
* @return Collection $recipients
*/
public function reverseTransform($usernames)
Expand Down
Loading

0 comments on commit 96cefae

Please sign in to comment.