Skip to content

Commit

Permalink
changes from automatic review
Browse files Browse the repository at this point in the history
  • Loading branch information
JMSBot committed Oct 2, 2012
1 parent 570a248 commit 82fa574
Show file tree
Hide file tree
Showing 35 changed files with 165 additions and 45 deletions.
1 change: 1 addition & 0 deletions Command/RoleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

/**
* @see Command
* @param boolean $super
*/
abstract protected function executeRoleCommand(UserManipulator $manipulator, OutputInterface $output, $username, $super, $role);

Expand Down
4 changes: 4 additions & 0 deletions Controller/ChangePasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ protected function getRedirectionUrl(UserInterface $user)
return $this->container->get('router')->generate('fos_user_profile_show');
}

/**
* @param string $action
* @param string $value
*/
protected function setFlash($action, $value)
{
$this->container->get('session')->setFlash($action, $value);
Expand Down
4 changes: 4 additions & 0 deletions Controller/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ protected function getEngine()
return $this->container->getParameter('fos_user.template.engine');
}

/**
* @param string $action
* @param string $value
*/
protected function setFlash($action, $value)
{
$this->container->get('session')->setFlash($action, $value);
Expand Down
4 changes: 4 additions & 0 deletions Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ protected function getRedirectionUrl(UserInterface $user)
return $this->container->get('router')->generate('fos_user_profile_show');
}

/**
* @param string $action
* @param string $value
*/
protected function setFlash($action, $value)
{
$this->container->get('session')->setFlash($action, $value);
Expand Down
4 changes: 4 additions & 0 deletions Controller/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ protected function authenticateUser(UserInterface $user, Response $response)
}
}

/**
* @param string $action
* @param string $value
*/
protected function setFlash($action, $value)
{
$this->container->get('session')->setFlash($action, $value);
Expand Down
4 changes: 4 additions & 0 deletions Controller/ResettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ protected function getObfuscatedEmail(UserInterface $user)
return $email;
}

/**
* @param string $action
* @param string $value
*/
protected function setFlash($action, $value)
{
$this->container->get('session')->setFlash($action, $value);
Expand Down
2 changes: 1 addition & 1 deletion Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function loginAction()
* Renders the login template with the given parameters. Overwrite this function in
* an extended controller to provide additional data for the login template.
*
* @param array $data
* @param array $data
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderLogin(array $data)
Expand Down
1 change: 0 additions & 1 deletion CouchDocument/GroupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace FOS\UserBundle\CouchDocument;

use FOS\UserBundle\Model\GroupInterface;
use Doctrine\ODM\CouchDB\DocumentManager;
use FOS\UserBundle\Doctrine\GroupManager as BaseGroupManager;

Expand Down
1 change: 0 additions & 1 deletion CouchDocument/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace FOS\UserBundle\CouchDocument;

use Doctrine\ODM\CouchDB\DocumentManager;
use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Doctrine\UserManager as BaseUserManager;
use FOS\UserBundle\Util\CanonicalizerInterface;
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
Expand Down
1 change: 0 additions & 1 deletion Document/GroupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace FOS\UserBundle\Document;

use FOS\UserBundle\Model\GroupInterface;
use Doctrine\ODM\MongoDB\DocumentManager;
use FOS\UserBundle\Doctrine\GroupManager as BaseGroupManager;

Expand Down
1 change: 0 additions & 1 deletion Document/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace FOS\UserBundle\Document;

use Doctrine\ODM\MongoDB\DocumentManager;
use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Doctrine\UserManager as BaseUserManager;
use FOS\UserBundle\Util\CanonicalizerInterface;
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
Expand Down
1 change: 0 additions & 1 deletion Entity/GroupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace FOS\UserBundle\Entity;

use FOS\UserBundle\Model\GroupInterface;
use Doctrine\ORM\EntityManager;
use FOS\UserBundle\Doctrine\GroupManager as BaseGroupManager;

Expand Down
1 change: 0 additions & 1 deletion Entity/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace FOS\UserBundle\Entity;

use Doctrine\ORM\EntityManager;
use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Doctrine\UserManager as BaseUserManager;
use FOS\UserBundle\Util\CanonicalizerInterface;
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
Expand Down
2 changes: 1 addition & 1 deletion Form/DataTransformer/UserToUsernameTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(UserManagerInterface $userManager)
*
* @param mixed $value UserInterface instance
*
* @return string Username
* @return null|string Username
*
* @throws UnexpectedTypeException if the given value is not a UserInterface instance
*/
Expand Down
3 changes: 3 additions & 0 deletions Form/Handler/ChangePasswordFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public function __construct(FormInterface $form, Request $request, UserManagerIn
$this->userManager = $userManager;
}

/**
* @return string
*/
public function getNewPassword()
{
return $this->form->getData()->new;
Expand Down
9 changes: 9 additions & 0 deletions Form/Handler/RegistrationFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public function __construct(FormInterface $form, Request $request, UserManagerIn
$this->tokenGenerator = $tokenGenerator;
}

/**
* @param boolean $confirmation
*/
public function process($confirmation = false)
{
$user = $this->createUser();
Expand All @@ -53,6 +56,9 @@ public function process($confirmation = false)
return false;
}

/**
* @param boolean $confirmation
*/
protected function onSuccess(UserInterface $user, $confirmation)
{
if ($confirmation) {
Expand All @@ -69,6 +75,9 @@ protected function onSuccess(UserInterface $user, $confirmation)
$this->userManager->updateUser($user);
}

/**
* @return boolean|UserInterface
*/
protected function createUser()
{
return $this->userManager->createUser();
Expand Down
3 changes: 3 additions & 0 deletions Form/Handler/ResettingFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public function __construct(FormInterface $form, Request $request, UserManagerIn
$this->userManager = $userManager;
}

/**
* @return string
*/
public function getNewPassword()
{
return $this->form->getData()->new;
Expand Down
4 changes: 4 additions & 0 deletions Mailer/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function sendResettingEmailMessage(UserInterface $user)
$this->sendEmailMessage($rendered, $this->parameters['from_email']['resetting'], $user->getEmail());
}

/**
* @param string $renderedTemplate
* @param string $toEmail
*/
protected function sendEmailMessage($renderedTemplate, $fromEmail, $toEmail)
{
// Render the email, use the first line as the subject, and the rest as the body
Expand Down
6 changes: 4 additions & 2 deletions Mailer/MailerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ interface MailerInterface
/**
* Send an email to a user to confirm the account creation
*
* @param UserInterface $user
* @param UserInterface $user
* @return void
*/
public function sendConfirmationEmailMessage(UserInterface $user);

/**
* Send an email to a user to confirm the password reset
*
* @param UserInterface $user
* @param UserInterface $user
* @return void
*/
public function sendResettingEmailMessage(UserInterface $user);
}
4 changes: 4 additions & 0 deletions Mailer/TwigSwiftMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function sendResettingEmailMessage(UserInterface $user)
$this->sendMessage($template, $context, $this->parameters['from_email']['resetting'], $user->getEmail());
}

/**
* @param array<string,UserInterface|string> $context
* @param string $toEmail
*/
protected function sendMessage($templateName, $context, $fromEmail, $toEmail)
{
$template = $this->twig->loadTemplate($templateName);
Expand Down
3 changes: 3 additions & 0 deletions Model/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public function getName()
return $this->name;
}

/**
* @param string $role
*/
public function hasRole($role)
{
return in_array(strtoupper($role), $this->roles, true);
Expand Down
23 changes: 23 additions & 0 deletions Model/GroupInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,42 @@
*/
interface GroupInterface
{
/**
* @return Group
*/
public function addRole($role);

public function getId();

/**
* @return string
*/
public function getName();

/**
* @return boolean
*/
public function hasRole($role);

/**
* @return array
*/
public function getRoles();

/**
* @return Group
*/
public function removeRole($role);

/**
* @param string $name
*
* @return Group
*/
public function setName($name);

/**
* @return Group
*/
public function setRoles(array $roles);
}
3 changes: 2 additions & 1 deletion Model/GroupManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public function getClass();
/**
* Updates a group.
*
* @param GroupInterface $group
* @param GroupInterface $group
* @return void
*/
public function updateGroup(GroupInterface $group);
}
6 changes: 4 additions & 2 deletions Model/GroupableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ public function hasGroup($name);
/**
* Add a group to the user groups.
*
* @param GroupInterface $group
* @param GroupInterface $group
* @return User
*/
public function addGroup(GroupInterface $group);

/**
* Remove a group from the user groups.
*
* @param GroupInterface $group
* @param GroupInterface $group
* @return User
*/
public function removeGroup(GroupInterface $group);
}
10 changes: 5 additions & 5 deletions Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public function getPassword()
/**
* Gets the plain password.
*
* @return string
* @return null|string
*/
public function getPlainPassword()
{
Expand Down Expand Up @@ -434,7 +434,7 @@ public function isSuperAdmin()
*
* Useful when not hydrating all fields.
*
* @param UserInterface $user
* @param null|UserInterface $user
*
* @return Boolean
*/
Expand Down Expand Up @@ -665,7 +665,7 @@ public function setConfirmationToken($confirmationToken)
/**
* Sets the timestamp that the user requested a password reset.
*
* @param \DateTime $date
* @param null|\DateTime $date
*
* @return User
*/
Expand All @@ -679,7 +679,7 @@ public function setPasswordRequestedAt(\DateTime $date = null)
/**
* Gets the timestamp that the user requested a password reset.
*
* @return \DateTime
* @return null|\DateTime
*/
public function getPasswordRequestedAt()
{
Expand Down Expand Up @@ -722,7 +722,7 @@ public function setRoles(array $roles)
/**
* Gets the groups granted to the user.
*
* @return Collection
* @return ArrayCollection
*/
public function getGroups()
{
Expand Down
Loading

0 comments on commit 82fa574

Please sign in to comment.