Skip to content

Commit

Permalink
Upgrade CS fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
XWB committed Dec 19, 2017
1 parent 3d8f8f4 commit 0451881
Show file tree
Hide file tree
Showing 23 changed files with 192 additions and 187 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.php_cs
.php_cs.cache
composer.lock
phpunit.xml
Expand Down
35 changes: 0 additions & 35 deletions .php_cs

This file was deleted.

33 changes: 33 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

$header = <<<EOF
This file is part of the FOSUserBundle package.
(c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;

return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'long'],
'combine_consecutive_unsets' => true,
'header_comment' => ['header' => $header],
'linebreak_after_opening_tag' => true,
'no_php4_constructor' => true,
'no_useless_else' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_construct' => true,
'php_unit_strict' => true,
'phpdoc_no_empty_return' => false,
])
->setUsingCache(true)
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
)
;
1 change: 0 additions & 1 deletion Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\TranslatorInterface;

/**
Expand Down
20 changes: 10 additions & 10 deletions Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ public function loginAction(Request $request)
));
}

public function checkAction()
{
throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
}

public function logoutAction()
{
throw new \RuntimeException('You must activate the logout in your security firewall configuration.');
}

/**
* Renders the login template with the given parameters. Overwrite this function in
* an extended controller to provide additional data for the login template.
Expand All @@ -93,14 +103,4 @@ protected function renderLogin(array $data)
{
return $this->render('@FOSUser/Security/login.html.twig', $data);
}

public function checkAction()
{
throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
}

public function logoutAction()
{
throw new \RuntimeException('You must activate the logout in your security firewall configuration.');
}
}
96 changes: 48 additions & 48 deletions DependencyInjection/FOSUserExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,54 @@ public function load(array $configs, ContainerBuilder $container)
}
}

/**
* {@inheritdoc}
*/
public function getNamespace()
{
return 'http://friendsofsymfony.github.io/schema/dic/user';
}

/**
* @param array $config
* @param ContainerBuilder $container
* @param array $map
*/
protected function remapParameters(array $config, ContainerBuilder $container, array $map)
{
foreach ($map as $name => $paramName) {
if (array_key_exists($name, $config)) {
$container->setParameter($paramName, $config[$name]);
}
}
}

/**
* @param array $config
* @param ContainerBuilder $container
* @param array $namespaces
*/
protected function remapParametersNamespaces(array $config, ContainerBuilder $container, array $namespaces)
{
foreach ($namespaces as $ns => $map) {
if ($ns) {
if (!array_key_exists($ns, $config)) {
continue;
}
$namespaceConfig = $config[$ns];
} else {
$namespaceConfig = $config;
}
if (is_array($map)) {
$this->remapParameters($namespaceConfig, $container, $map);
} else {
foreach ($namespaceConfig as $name => $value) {
$container->setParameter(sprintf($map, $name), $value);
}
}
}
}

/**
* @param array $config
* @param ContainerBuilder $container
Expand Down Expand Up @@ -254,52 +302,4 @@ private function loadGroups(array $config, ContainerBuilder $container, XmlFileL
'form' => 'fos_user.group.form.%s',
));
}

/**
* @param array $config
* @param ContainerBuilder $container
* @param array $map
*/
protected function remapParameters(array $config, ContainerBuilder $container, array $map)
{
foreach ($map as $name => $paramName) {
if (array_key_exists($name, $config)) {
$container->setParameter($paramName, $config[$name]);
}
}
}

/**
* @param array $config
* @param ContainerBuilder $container
* @param array $namespaces
*/
protected function remapParametersNamespaces(array $config, ContainerBuilder $container, array $namespaces)
{
foreach ($namespaces as $ns => $map) {
if ($ns) {
if (!array_key_exists($ns, $config)) {
continue;
}
$namespaceConfig = $config[$ns];
} else {
$namespaceConfig = $config;
}
if (is_array($map)) {
$this->remapParameters($namespaceConfig, $container, $map);
} else {
foreach ($namespaceConfig as $name => $value) {
$container->setParameter(sprintf($map, $name), $value);
}
}
}
}

/**
* {@inheritdoc}
*/
public function getNamespace()
{
return 'http://friendsofsymfony.github.io/schema/dic/user';
}
}
16 changes: 8 additions & 8 deletions Doctrine/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ public function __construct(PasswordUpdaterInterface $passwordUpdater, Canonical
$this->class = $class;
}

/**
* @return ObjectRepository
*/
protected function getRepository()
{
return $this->objectManager->getRepository($this->getClass());
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -113,4 +105,12 @@ public function updateUser(UserInterface $user, $andFlush = true)
$this->objectManager->flush();
}
}

/**
* @return ObjectRepository
*/
protected function getRepository()
{
return $this->objectManager->getRepository($this->getClass());
}
}
1 change: 1 addition & 0 deletions Form/Type/ChangePasswordFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function configureOptions(OptionsResolver $resolver)
}

// BC for SF < 3.0

/**
* {@inheritdoc}
*/
Expand Down
1 change: 1 addition & 0 deletions Form/Type/GroupFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function configureOptions(OptionsResolver $resolver)
}

// BC for SF < 3.0

/**
* {@inheritdoc}
*/
Expand Down
1 change: 1 addition & 0 deletions Form/Type/ProfileFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function configureOptions(OptionsResolver $resolver)
}

// BC for SF < 3.0

/**
* {@inheritdoc}
*/
Expand Down
1 change: 1 addition & 0 deletions Form/Type/RegistrationFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function configureOptions(OptionsResolver $resolver)
}

// BC for SF < 3.0

/**
* {@inheritdoc}
*/
Expand Down
1 change: 1 addition & 0 deletions Form/Type/ResettingFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function configureOptions(OptionsResolver $resolver)
}

// BC for SF < 3.0

/**
* {@inheritdoc}
*/
Expand Down
1 change: 1 addition & 0 deletions Form/Type/UsernameFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function getParent()
}

// BC for SF < 3.0

/**
* @return string
*/
Expand Down
40 changes: 20 additions & 20 deletions Mailer/TwigSwiftMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ public function sendResettingEmailMessage(UserInterface $user)
$this->sendMessage($template, $context, $this->parameters['from_email']['resetting'], (string) $user->getEmail());
}

/**
* Send confirmation link to specified new user email.
*
* @param UserInterface $user
* @param $confirmationUrl
* @param $toEmail
*
* @return bool
*/
public function sendUpdateEmailConfirmation(UserInterface $user, $confirmationUrl, $toEmail)
{
$template = $this->parameters['template']['email_updating'];
$context = array(
'user' => $user,
'confirmationUrl' => $confirmationUrl,
);

$this->sendMessage($template, $context, $this->parameters['from_email']['confirmation'], $toEmail);
}

/**
* @param string $templateName
* @param array $context
Expand Down Expand Up @@ -119,24 +139,4 @@ protected function sendMessage($templateName, $context, $fromEmail, $toEmail)

$this->mailer->send($message);
}

/**
* Send confirmation link to specified new user email.
*
* @param UserInterface $user
* @param $confirmationUrl
* @param $toEmail
*
* @return bool
*/
public function sendUpdateEmailConfirmation(UserInterface $user, $confirmationUrl, $toEmail)
{
$template = $this->parameters['template']['email_updating'];
$context = array(
'user' => $user,
'confirmationUrl' => $confirmationUrl,
);

$this->sendMessage($template, $context, $this->parameters['from_email']['confirmation'], $toEmail);
}
}
1 change: 1 addition & 0 deletions Model/GroupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function createGroup($name)

return new $class($name);
}

/**
* {@inheritdoc}
*/
Expand Down
16 changes: 8 additions & 8 deletions Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ public function __construct()
$this->roles = array();
}

/**
* @return string
*/
public function __toString()
{
return (string) $this->getUsername();
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -546,12 +554,4 @@ public function removeGroup(GroupInterface $group)

return $this;
}

/**
* @return string
*/
public function __toString()
{
return (string) $this->getUsername();
}
}
2 changes: 1 addition & 1 deletion Model/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function findUserByUsernameOrEmail($usernameOrEmail)
{
if (preg_match('/^.+\@\S+\.\S+$/', $usernameOrEmail)) {
$user = $this->findUserByEmail($usernameOrEmail);
if ($user !== null) {
if (null !== $user) {
return $user;
}
}
Expand Down
Loading

0 comments on commit 0451881

Please sign in to comment.