Skip to content

Commit 42691e1

Browse files
core23XWB
authored andcommitted
Added php-cs-fixer to format and check code (FriendsOfSymfony#2240)
* Added php-cs-fixer to format and check code * Fixed tests * Execute php-cs-fixer
1 parent 9ddfc7e commit 42691e1

File tree

87 files changed

+466
-291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+466
-291
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/Tests export-ignore
22
/.gitattributes export-ignore
33
/.gitignore export-ignore
4+
/.php_cs export-ignore
45
/.travis.yml export-ignore
56
/README.markdown export-ignore
67
/Upgrade.md export-ignore

.gitignore

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

.php_cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);
13+
14+
$finder = Symfony\CS\Finder\DefaultFinder::create()
15+
->in(array(__DIR__))
16+
->exclude(array('Tests/Fixtures'))
17+
;
18+
19+
return Symfony\CS\Config\Config::create()
20+
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
21+
->fixers(array(
22+
'combine_consecutive_unsets',
23+
'header_comment',
24+
'long_array_syntax',
25+
'newline_after_open_tag',
26+
'no_php4_constructor',
27+
'no_useless_else',
28+
'ordered_class_elements',
29+
'ordered_use',
30+
'php_unit_construct',
31+
'php_unit_strict',
32+
))
33+
->setUsingCache(true)
34+
->finder($finder)
35+
;

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ php:
88
- 7.0
99
- hhvm
1010

11+
env:
12+
global:
13+
- TARGET=test
14+
1115
matrix:
1216
fast_finish: true
1317
include:
18+
- php: 7.0
19+
env: TARGET=cs_dry_run
1420
- php: 5.3
1521
env: COMPOSER_FLAGS="--prefer-lowest"
1622
- php: 5.6
@@ -36,7 +42,7 @@ before_install:
3642
install: composer update --prefer-dist --no-interaction $COMPOSER_FLAGS
3743

3844
script:
39-
- phpunit --coverage-text
45+
- make $TARGET
4046

4147
notifications:
4248

Command/ActivateUserCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function configure()
3333
->setDefinition(array(
3434
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
3535
))
36-
->setHelp(<<<EOT
36+
->setHelp(<<<'EOT'
3737
The <info>fos:user:activate</info> command activates a user (so they will be able to log in):
3838
3939
<info>php %command.full_name% matthieu</info>
@@ -61,7 +61,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
6161
{
6262
if (!$input->getArgument('username')) {
6363
$question = new Question('Please choose a username:');
64-
$question->setValidator(function($username) {
64+
$question->setValidator(function ($username) {
6565
if (empty($username)) {
6666
throw new \Exception('Username can not be empty');
6767
}

Command/ChangePasswordCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Component\Console\Question\Question;
1919

2020
/**
21-
* ChangePasswordCommand
21+
* ChangePasswordCommand.
2222
*/
2323
class ChangePasswordCommand extends ContainerAwareCommand
2424
{
@@ -34,7 +34,7 @@ protected function configure()
3434
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
3535
new InputArgument('password', InputArgument::REQUIRED, 'The password'),
3636
))
37-
->setHelp(<<<EOT
37+
->setHelp(<<<'EOT'
3838
The <info>fos:user:change-password</info> command changes the password of a user:
3939
4040
<info>php %command.full_name% matthieu</info>
@@ -72,7 +72,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
7272

7373
if (!$input->getArgument('username')) {
7474
$question = new Question('Please give the username:');
75-
$question->setValidator(function($username) {
75+
$question->setValidator(function ($username) {
7676
if (empty($username)) {
7777
throw new \Exception('Username can not be empty');
7878
}
@@ -84,7 +84,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
8484

8585
if (!$input->getArgument('password')) {
8686
$question = new Question('Please enter the new password:');
87-
$question->setValidator(function($password) {
87+
$question->setValidator(function ($password) {
8888
if (empty($password)) {
8989
throw new \Exception('Password can not be empty');
9090
}

Command/CreateUserCommand.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
1515
use Symfony\Component\Console\Input\InputArgument;
16-
use Symfony\Component\Console\Input\InputOption;
1716
use Symfony\Component\Console\Input\InputInterface;
17+
use Symfony\Component\Console\Input\InputOption;
1818
use Symfony\Component\Console\Output\OutputInterface;
1919
use Symfony\Component\Console\Question\Question;
2020

@@ -40,7 +40,7 @@ protected function configure()
4040
new InputOption('super-admin', null, InputOption::VALUE_NONE, 'Set the user as super admin'),
4141
new InputOption('inactive', null, InputOption::VALUE_NONE, 'Set the user as inactive'),
4242
))
43-
->setHelp(<<<EOT
43+
->setHelp(<<<'EOT'
4444
The <info>fos:user:create</info> command creates a user:
4545
4646
<info>php %command.full_name% matthieu</info>
@@ -68,10 +68,10 @@ protected function configure()
6868
*/
6969
protected function execute(InputInterface $input, OutputInterface $output)
7070
{
71-
$username = $input->getArgument('username');
72-
$email = $input->getArgument('email');
73-
$password = $input->getArgument('password');
74-
$inactive = $input->getOption('inactive');
71+
$username = $input->getArgument('username');
72+
$email = $input->getArgument('email');
73+
$password = $input->getArgument('password');
74+
$inactive = $input->getOption('inactive');
7575
$superadmin = $input->getOption('super-admin');
7676

7777
$manipulator = $this->getContainer()->get('fos_user.util.user_manipulator');
@@ -89,7 +89,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
8989

9090
if (!$input->getArgument('username')) {
9191
$question = new Question('Please choose a username:');
92-
$question->setValidator(function($username) {
92+
$question->setValidator(function ($username) {
9393
if (empty($username)) {
9494
throw new \Exception('Username can not be empty');
9595
}
@@ -101,7 +101,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
101101

102102
if (!$input->getArgument('email')) {
103103
$question = new Question('Please choose an email:');
104-
$question->setValidator(function($email) {
104+
$question->setValidator(function ($email) {
105105
if (empty($email)) {
106106
throw new \Exception('Email can not be empty');
107107
}
@@ -113,7 +113,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
113113

114114
if (!$input->getArgument('password')) {
115115
$question = new Question('Please choose a password:');
116-
$question->setValidator(function($password) {
116+
$question->setValidator(function ($password) {
117117
if (empty($password)) {
118118
throw new \Exception('Password can not be empty');
119119
}

Command/DeactivateUserCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function configure()
3333
->setDefinition(array(
3434
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
3535
))
36-
->setHelp(<<<EOT
36+
->setHelp(<<<'EOT'
3737
The <info>fos:user:deactivate</info> command deactivates a user (will not be able to log in)
3838
3939
<info>php %command.full_name% matthieu</info>
@@ -61,7 +61,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
6161
{
6262
if (!$input->getArgument('username')) {
6363
$question = new Question('Please choose a username:');
64-
$question->setValidator(function($username) {
64+
$question->setValidator(function ($username) {
6565
if (empty($username)) {
6666
throw new \Exception('Username can not be empty');
6767
}

Command/DemoteUserCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace FOS\UserBundle\Command;
1313

14-
use Symfony\Component\Console\Output\OutputInterface;
1514
use FOS\UserBundle\Util\UserManipulator;
15+
use Symfony\Component\Console\Output\OutputInterface;
1616

1717
/**
1818
* @author Antoine Hérault <[email protected]>
@@ -30,7 +30,7 @@ protected function configure()
3030
$this
3131
->setName('fos:user:demote')
3232
->setDescription('Demote a user by removing a role')
33-
->setHelp(<<<EOT
33+
->setHelp(<<<'EOT'
3434
The <info>fos:user:demote</info> command demotes a user by removing a role
3535
3636
<info>php %command.full_name% matthieu ROLE_CUSTOM</info>

Command/PromoteUserCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace FOS\UserBundle\Command;
1313

14-
use Symfony\Component\Console\Output\OutputInterface;
1514
use FOS\UserBundle\Util\UserManipulator;
15+
use Symfony\Component\Console\Output\OutputInterface;
1616

1717
/**
1818
* @author Matthieu Bontemps <[email protected]>
@@ -32,7 +32,7 @@ protected function configure()
3232
$this
3333
->setName('fos:user:promote')
3434
->setDescription('Promotes a user by adding a role')
35-
->setHelp(<<<EOT
35+
->setHelp(<<<'EOT'
3636
The <info>fos:user:promote</info> command promotes a user by adding a role
3737
3838
<info>php %command.full_name% matthieu ROLE_CUSTOM</info>

Command/RoleCommand.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace FOS\UserBundle\Command;
1313

14+
use FOS\UserBundle\Util\UserManipulator;
1415
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
1516
use Symfony\Component\Console\Input\InputArgument;
16-
use Symfony\Component\Console\Input\InputOption;
1717
use Symfony\Component\Console\Input\InputInterface;
18+
use Symfony\Component\Console\Input\InputOption;
1819
use Symfony\Component\Console\Output\OutputInterface;
19-
use FOS\UserBundle\Util\UserManipulator;
2020
use Symfony\Component\Console\Question\Question;
2121

2222
/**
@@ -64,10 +64,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
6464
* @param UserManipulator $manipulator
6565
* @param OutputInterface $output
6666
* @param string $username
67-
* @param boolean $super
67+
* @param bool $super
6868
* @param string $role
69-
*
70-
* @return void
7169
*/
7270
abstract protected function executeRoleCommand(UserManipulator $manipulator, OutputInterface $output, $username, $super, $role);
7371

@@ -80,7 +78,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
8078

8179
if (!$input->getArgument('username')) {
8280
$question = new Question('Please choose a username:');
83-
$question->setValidator(function($username) {
81+
$question->setValidator(function ($username) {
8482
if (empty($username)) {
8583
throw new \Exception('Username can not be empty');
8684
}
@@ -92,7 +90,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
9290

9391
if ((true !== $input->getOption('super')) && !$input->getArgument('role')) {
9492
$question = new Question('Please choose a role:');
95-
$question->setValidator(function($role) {
93+
$question->setValidator(function ($role) {
9694
if (empty($role)) {
9795
throw new \Exception('Role can not be empty');
9896
}

Controller/ChangePasswordController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@
1111

1212
namespace FOS\UserBundle\Controller;
1313

14-
use FOS\UserBundle\Form\Factory\FactoryInterface;
15-
use FOS\UserBundle\FOSUserEvents;
16-
use FOS\UserBundle\Event\FormEvent;
1714
use FOS\UserBundle\Event\FilterUserResponseEvent;
15+
use FOS\UserBundle\Event\FormEvent;
1816
use FOS\UserBundle\Event\GetResponseUserEvent;
17+
use FOS\UserBundle\Form\Factory\FactoryInterface;
18+
use FOS\UserBundle\FOSUserEvents;
1919
use FOS\UserBundle\Model\UserInterface;
2020
use FOS\UserBundle\Model\UserManagerInterface;
2121
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
2222
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
23-
use Symfony\Component\HttpFoundation\Request;
2423
use Symfony\Component\HttpFoundation\RedirectResponse;
24+
use Symfony\Component\HttpFoundation\Request;
2525
use Symfony\Component\HttpFoundation\Response;
2626
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
2727

2828
/**
29-
* Controller managing the password change
29+
* Controller managing the password change.
3030
*
3131
* @author Thibault Duplessis <[email protected]>
3232
* @author Christophe Coevoet <[email protected]>
3333
*/
3434
class ChangePasswordController extends Controller
3535
{
3636
/**
37-
* Change user password
37+
* Change user password.
3838
*
3939
* @param Request $request
4040
*
@@ -85,7 +85,7 @@ public function changePasswordAction(Request $request)
8585
}
8686

8787
return $this->render('FOSUserBundle:ChangePassword:change_password.html.twig', array(
88-
'form' => $form->createView()
88+
'form' => $form->createView(),
8989
));
9090
}
9191
}

0 commit comments

Comments
 (0)