Skip to content

Commit 34f8bbd

Browse files
committed
adding phpcs rules and using short arrays
1 parent e3f5fa8 commit 34f8bbd

18 files changed

+99
-81
lines changed

.php_cs.dist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
if (!file_exists(__DIR__.'/src')) {
4+
exit(0);
5+
}
6+
return PhpCsFixer\Config::create()
7+
->setRules(array(
8+
'@Symfony' => true,
9+
'@Symfony:risky' => true,
10+
'array_syntax' => array('syntax' => 'short'),
11+
'protected_to_private' => false,
12+
))
13+
->setRiskyAllowed(true)
14+
->setFinder(
15+
PhpCsFixer\Finder::create()
16+
->in(__DIR__.'/src')
17+
)
18+
;

src/Command/MakerCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
7878
continue;
7979
}
8080

81-
$value = $this->io->ask($argument->getDescription(), $argument->getDefault(), array(Validator::class, 'notBlank'));
81+
$value = $this->io->ask($argument->getDescription(), $argument->getDefault(), [Validator::class, 'notBlank']);
8282
$input->setArgument($argument->getName(), $value);
8383
}
8484

src/DependencyInjection/CompilerPass/MakeCommandRegistrationPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public function process(ContainerBuilder $container)
2626
$container->register(
2727
sprintf('maker.auto_command.%s', Str::asTwigVariable($class::getCommandName())),
2828
MakerCommand::class
29-
)->setArguments(array(
29+
)->setArguments([
3030
new Reference($id),
3131
new Reference('maker.generator'),
32-
))->addTag('console.command', array('command' => $class::getCommandName()));
32+
])->addTag('console.command', ['command' => $class::getCommandName()]);
3333
}
3434
}
3535
}

src/EventRegistry.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
class EventRegistry
3535
{
3636
// list of *known* events to always include (if they exist)
37-
private static $eventsMap = array(
37+
private static $eventsMap = [
3838
'console.command' => ConsoleCommandEvent::class,
3939
'console.terminate' => ConsoleTerminateEvent::class,
4040
'console.error' => ConsoleErrorEvent::class,
@@ -50,7 +50,7 @@ class EventRegistry
5050
'security.authentication.failure' => AuthenticationFailureEvent::class,
5151
'security.interactive_login' => InteractiveLoginEvent::class,
5252
'security.switch_user' => SwitchUserEvent::class,
53-
);
53+
];
5454

5555
private $eventDispatcher;
5656

@@ -64,7 +64,7 @@ public function __construct(EventDispatcherInterface $eventDispatcher)
6464
*/
6565
public function getAllActiveEvents(): array
6666
{
67-
$activeEvents = array();
67+
$activeEvents = [];
6868
foreach (self::$eventsMap as $eventName => $eventClass) {
6969
if (!class_exists($eventClass)) {
7070
continue;

src/InputConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
final class InputConfiguration
66
{
7-
private $nonInteractiveArguments = array();
7+
private $nonInteractiveArguments = [];
88

99
/**
1010
* Call in MakerInterface::configureCommand() to disable the automatic interactive

src/Maker/MakeAuthenticator.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,24 @@ public function getParameters(InputInterface $input): array
5050
$className = Str::asClassName($input->getArgument('authenticator-class'));
5151
Validator::validateClassName($className);
5252

53-
return array(
53+
return [
5454
'class_name' => $className,
55-
);
55+
];
5656
}
5757

5858
public function getFiles(array $params): array
5959
{
60-
return array(
60+
return [
6161
__DIR__.'/../Resources/skeleton/authenticator/Empty.php.txt' => 'src/Security/'.$params['class_name'].'.php',
62-
);
62+
];
6363
}
6464

6565
public function writeNextStepsMessage(array $params, ConsoleStyle $io): void
6666
{
67-
$io->text(array(
67+
$io->text([
6868
'Next: Customize your new authenticator.',
6969
'Then, configure the "guard" key on your firewall to use it.',
70-
));
70+
]);
7171
}
7272

7373
public function configureDependencies(DependencyBuilder $dependencies): void

src/Maker/MakeCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,25 @@ public function getParameters(InputInterface $input): array
5151
$commandClassName = Str::asClassName($commandName, 'Command');
5252
Validator::validateClassName($commandClassName, sprintf('The "%s" command name is not valid because it would be implemented by "%s" class, which is not valid as a PHP class name (it must start with a letter or underscore, followed by any number of letters, numbers, or underscores).', $commandName, $commandClassName));
5353

54-
return array(
54+
return [
5555
'command_name' => $commandName,
5656
'command_class_name' => $commandClassName,
57-
);
57+
];
5858
}
5959

6060
public function getFiles(array $params): array
6161
{
62-
return array(
62+
return [
6363
__DIR__.'/../Resources/skeleton/command/Command.php.txt' => 'src/Command/'.$params['command_class_name'].'.php',
64-
);
64+
];
6565
}
6666

6767
public function writeNextStepsMessage(array $params, ConsoleStyle $io): void
6868
{
69-
$io->text(array(
69+
$io->text([
7070
'Next: open your new command class and customize it!',
7171
'Find the documentation at <fg=yellow>https://symfony.com/doc/current/console.html</>',
72-
));
72+
]);
7373
}
7474

7575
public function configureDependencies(DependencyBuilder $dependencies): void

src/Maker/MakeController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,20 @@ public function getParameters(InputInterface $input): array
6060
$controllerClassName = Str::asClassName($input->getArgument('controller-class'), 'Controller');
6161
Validator::validateClassName($controllerClassName);
6262

63-
return array(
63+
return [
6464
'controller_class_name' => $controllerClassName,
6565
'route_path' => Str::asRoutePath(str_replace('Controller', '', $controllerClassName)),
6666
'route_name' => Str::asRouteName(str_replace('Controller', '', $controllerClassName)),
67-
);
67+
];
6868
}
6969

7070
public function getFiles(array $params): array
7171
{
7272
$skeletonFile = $this->isTwigInstalled() ? 'ControllerWithTwig.php.txt' : 'Controller.php.txt';
7373

74-
return array(
74+
return [
7575
__DIR__.'/../Resources/skeleton/controller/'.$skeletonFile => 'src/Controller/'.$params['controller_class_name'].'.php',
76-
);
76+
];
7777
}
7878

7979
public function writeNextStepsMessage(array $params, ConsoleStyle $io): void

src/Maker/MakeEntity.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,27 @@ public function getParameters(InputInterface $input): array
5353
$entityAlias = strtolower($entityClassName[0]);
5454
$repositoryClassName = Str::addSuffix($entityClassName, 'Repository');
5555

56-
return array(
56+
return [
5757
'entity_class_name' => $entityClassName,
5858
'entity_alias' => $entityAlias,
5959
'repository_class_name' => $repositoryClassName,
60-
);
60+
];
6161
}
6262

6363
public function getFiles(array $params): array
6464
{
65-
return array(
65+
return [
6666
__DIR__.'/../Resources/skeleton/doctrine/Entity.php.txt' => 'src/Entity/'.$params['entity_class_name'].'.php',
6767
__DIR__.'/../Resources/skeleton/doctrine/Repository.php.txt' => 'src/Repository/'.$params['repository_class_name'].'.php',
68-
);
68+
];
6969
}
7070

7171
public function writeNextStepsMessage(array $params, ConsoleStyle $io): void
7272
{
73-
$io->text(array(
73+
$io->text([
7474
'Next: Add more fields to your entity and start using it.',
7575
'Find the documentation at <fg=yellow>https://symfony.com/doc/current/doctrine.html#creating-an-entity-class</>',
76-
));
76+
]);
7777
}
7878

7979
public function configureDependencies(DependencyBuilder $dependencies): void

src/Maker/MakeForm.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,25 @@ public function getParameters(InputInterface $input): array
5353
Validator::validateClassName($formClassName);
5454
$entityClassName = Str::removeSuffix($formClassName, 'Type');
5555

56-
return array(
56+
return [
5757
'form_class_name' => $formClassName,
5858
'entity_class_name' => $entityClassName,
59-
);
59+
];
6060
}
6161

6262
public function getFiles(array $params): array
6363
{
64-
return array(
64+
return [
6565
__DIR__.'/../Resources/skeleton/form/Type.php.txt' => 'src/Form/'.$params['form_class_name'].'.php',
66-
);
66+
];
6767
}
6868

6969
public function writeNextStepsMessage(array $params, ConsoleStyle $io): void
7070
{
71-
$io->text(array(
71+
$io->text([
7272
'Next: Add fields to your form and start using it.',
7373
'Find the documentation at <fg=yellow>https://symfony.com/doc/current/forms.html</>',
74-
));
74+
]);
7575
}
7676

7777
public function configureDependencies(DependencyBuilder $dependencies): void

0 commit comments

Comments
 (0)