Skip to content

Commit 0451881

Browse files
committed
Upgrade CS fixer
1 parent 3d8f8f4 commit 0451881

23 files changed

+192
-187
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.php_cs
12
.php_cs.cache
23
composer.lock
34
phpunit.xml

.php_cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

.php_cs.dist

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
$header = <<<EOF
4+
This file is part of the FOSUserBundle package.
5+
6+
(c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+
8+
For the full copyright and license information, please view the LICENSE
9+
file that was distributed with this source code.
10+
EOF;
11+
12+
return PhpCsFixer\Config::create()
13+
->setRules([
14+
'@Symfony' => true,
15+
'array_syntax' => ['syntax' => 'long'],
16+
'combine_consecutive_unsets' => true,
17+
'header_comment' => ['header' => $header],
18+
'linebreak_after_opening_tag' => true,
19+
'no_php4_constructor' => true,
20+
'no_useless_else' => true,
21+
'ordered_class_elements' => true,
22+
'ordered_imports' => true,
23+
'php_unit_construct' => true,
24+
'php_unit_strict' => true,
25+
'phpdoc_no_empty_return' => false,
26+
])
27+
->setUsingCache(true)
28+
->setRiskyAllowed(true)
29+
->setFinder(
30+
PhpCsFixer\Finder::create()
31+
->in(__DIR__)
32+
)
33+
;

Controller/ProfileController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
use Symfony\Component\HttpFoundation\Request;
2828
use Symfony\Component\HttpFoundation\Response;
2929
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
30-
use Symfony\Component\Translation\Translator;
3130
use Symfony\Component\Translation\TranslatorInterface;
3231

3332
/**

Controller/SecurityController.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ public function loginAction(Request $request)
8181
));
8282
}
8383

84+
public function checkAction()
85+
{
86+
throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
87+
}
88+
89+
public function logoutAction()
90+
{
91+
throw new \RuntimeException('You must activate the logout in your security firewall configuration.');
92+
}
93+
8494
/**
8595
* Renders the login template with the given parameters. Overwrite this function in
8696
* an extended controller to provide additional data for the login template.
@@ -93,14 +103,4 @@ protected function renderLogin(array $data)
93103
{
94104
return $this->render('@FOSUser/Security/login.html.twig', $data);
95105
}
96-
97-
public function checkAction()
98-
{
99-
throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
100-
}
101-
102-
public function logoutAction()
103-
{
104-
throw new \RuntimeException('You must activate the logout in your security firewall configuration.');
105-
}
106106
}

DependencyInjection/FOSUserExtension.php

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,54 @@ public function load(array $configs, ContainerBuilder $container)
133133
}
134134
}
135135

136+
/**
137+
* {@inheritdoc}
138+
*/
139+
public function getNamespace()
140+
{
141+
return 'http://friendsofsymfony.github.io/schema/dic/user';
142+
}
143+
144+
/**
145+
* @param array $config
146+
* @param ContainerBuilder $container
147+
* @param array $map
148+
*/
149+
protected function remapParameters(array $config, ContainerBuilder $container, array $map)
150+
{
151+
foreach ($map as $name => $paramName) {
152+
if (array_key_exists($name, $config)) {
153+
$container->setParameter($paramName, $config[$name]);
154+
}
155+
}
156+
}
157+
158+
/**
159+
* @param array $config
160+
* @param ContainerBuilder $container
161+
* @param array $namespaces
162+
*/
163+
protected function remapParametersNamespaces(array $config, ContainerBuilder $container, array $namespaces)
164+
{
165+
foreach ($namespaces as $ns => $map) {
166+
if ($ns) {
167+
if (!array_key_exists($ns, $config)) {
168+
continue;
169+
}
170+
$namespaceConfig = $config[$ns];
171+
} else {
172+
$namespaceConfig = $config;
173+
}
174+
if (is_array($map)) {
175+
$this->remapParameters($namespaceConfig, $container, $map);
176+
} else {
177+
foreach ($namespaceConfig as $name => $value) {
178+
$container->setParameter(sprintf($map, $name), $value);
179+
}
180+
}
181+
}
182+
}
183+
136184
/**
137185
* @param array $config
138186
* @param ContainerBuilder $container
@@ -254,52 +302,4 @@ private function loadGroups(array $config, ContainerBuilder $container, XmlFileL
254302
'form' => 'fos_user.group.form.%s',
255303
));
256304
}
257-
258-
/**
259-
* @param array $config
260-
* @param ContainerBuilder $container
261-
* @param array $map
262-
*/
263-
protected function remapParameters(array $config, ContainerBuilder $container, array $map)
264-
{
265-
foreach ($map as $name => $paramName) {
266-
if (array_key_exists($name, $config)) {
267-
$container->setParameter($paramName, $config[$name]);
268-
}
269-
}
270-
}
271-
272-
/**
273-
* @param array $config
274-
* @param ContainerBuilder $container
275-
* @param array $namespaces
276-
*/
277-
protected function remapParametersNamespaces(array $config, ContainerBuilder $container, array $namespaces)
278-
{
279-
foreach ($namespaces as $ns => $map) {
280-
if ($ns) {
281-
if (!array_key_exists($ns, $config)) {
282-
continue;
283-
}
284-
$namespaceConfig = $config[$ns];
285-
} else {
286-
$namespaceConfig = $config;
287-
}
288-
if (is_array($map)) {
289-
$this->remapParameters($namespaceConfig, $container, $map);
290-
} else {
291-
foreach ($namespaceConfig as $name => $value) {
292-
$container->setParameter(sprintf($map, $name), $value);
293-
}
294-
}
295-
}
296-
}
297-
298-
/**
299-
* {@inheritdoc}
300-
*/
301-
public function getNamespace()
302-
{
303-
return 'http://friendsofsymfony.github.io/schema/dic/user';
304-
}
305305
}

Doctrine/UserManager.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ public function __construct(PasswordUpdaterInterface $passwordUpdater, Canonical
4646
$this->class = $class;
4747
}
4848

49-
/**
50-
* @return ObjectRepository
51-
*/
52-
protected function getRepository()
53-
{
54-
return $this->objectManager->getRepository($this->getClass());
55-
}
56-
5749
/**
5850
* {@inheritdoc}
5951
*/
@@ -113,4 +105,12 @@ public function updateUser(UserInterface $user, $andFlush = true)
113105
$this->objectManager->flush();
114106
}
115107
}
108+
109+
/**
110+
* @return ObjectRepository
111+
*/
112+
protected function getRepository()
113+
{
114+
return $this->objectManager->getRepository($this->getClass());
115+
}
116116
}

Form/Type/ChangePasswordFormType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function configureOptions(OptionsResolver $resolver)
8686
}
8787

8888
// BC for SF < 3.0
89+
8990
/**
9091
* {@inheritdoc}
9192
*/

Form/Type/GroupFormType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function configureOptions(OptionsResolver $resolver)
5050
}
5151

5252
// BC for SF < 3.0
53+
5354
/**
5455
* {@inheritdoc}
5556
*/

Form/Type/ProfileFormType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public function configureOptions(OptionsResolver $resolver)
7575
}
7676

7777
// BC for SF < 3.0
78+
7879
/**
7980
* {@inheritdoc}
8081
*/

Form/Type/RegistrationFormType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function configureOptions(OptionsResolver $resolver)
6868
}
6969

7070
// BC for SF < 3.0
71+
7172
/**
7273
* {@inheritdoc}
7374
*/

Form/Type/ResettingFormType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function configureOptions(OptionsResolver $resolver)
6363
}
6464

6565
// BC for SF < 3.0
66+
6667
/**
6768
* {@inheritdoc}
6869
*/

Form/Type/UsernameFormType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function getParent()
5555
}
5656

5757
// BC for SF < 3.0
58+
5859
/**
5960
* @return string
6061
*/

Mailer/TwigSwiftMailer.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,26 @@ public function sendResettingEmailMessage(UserInterface $user)
8787
$this->sendMessage($template, $context, $this->parameters['from_email']['resetting'], (string) $user->getEmail());
8888
}
8989

90+
/**
91+
* Send confirmation link to specified new user email.
92+
*
93+
* @param UserInterface $user
94+
* @param $confirmationUrl
95+
* @param $toEmail
96+
*
97+
* @return bool
98+
*/
99+
public function sendUpdateEmailConfirmation(UserInterface $user, $confirmationUrl, $toEmail)
100+
{
101+
$template = $this->parameters['template']['email_updating'];
102+
$context = array(
103+
'user' => $user,
104+
'confirmationUrl' => $confirmationUrl,
105+
);
106+
107+
$this->sendMessage($template, $context, $this->parameters['from_email']['confirmation'], $toEmail);
108+
}
109+
90110
/**
91111
* @param string $templateName
92112
* @param array $context
@@ -119,24 +139,4 @@ protected function sendMessage($templateName, $context, $fromEmail, $toEmail)
119139

120140
$this->mailer->send($message);
121141
}
122-
123-
/**
124-
* Send confirmation link to specified new user email.
125-
*
126-
* @param UserInterface $user
127-
* @param $confirmationUrl
128-
* @param $toEmail
129-
*
130-
* @return bool
131-
*/
132-
public function sendUpdateEmailConfirmation(UserInterface $user, $confirmationUrl, $toEmail)
133-
{
134-
$template = $this->parameters['template']['email_updating'];
135-
$context = array(
136-
'user' => $user,
137-
'confirmationUrl' => $confirmationUrl,
138-
);
139-
140-
$this->sendMessage($template, $context, $this->parameters['from_email']['confirmation'], $toEmail);
141-
}
142142
}

Model/GroupManager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function createGroup($name)
2828

2929
return new $class($name);
3030
}
31+
3132
/**
3233
* {@inheritdoc}
3334
*/

Model/User.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ public function __construct()
109109
$this->roles = array();
110110
}
111111

112+
/**
113+
* @return string
114+
*/
115+
public function __toString()
116+
{
117+
return (string) $this->getUsername();
118+
}
119+
112120
/**
113121
* {@inheritdoc}
114122
*/
@@ -546,12 +554,4 @@ public function removeGroup(GroupInterface $group)
546554

547555
return $this;
548556
}
549-
550-
/**
551-
* @return string
552-
*/
553-
public function __toString()
554-
{
555-
return (string) $this->getUsername();
556-
}
557557
}

Model/UserManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function findUserByUsernameOrEmail($usernameOrEmail)
6565
{
6666
if (preg_match('/^.+\@\S+\.\S+$/', $usernameOrEmail)) {
6767
$user = $this->findUserByEmail($usernameOrEmail);
68-
if ($user !== null) {
68+
if (null !== $user) {
6969
return $user;
7070
}
7171
}

0 commit comments

Comments
 (0)