Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

Commit 85d9e46

Browse files
php cs fixer
1 parent 7a65076 commit 85d9e46

34 files changed

+222
-159
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ yarn-error.log
2828
/phpcs.xml
2929
/.php-cs-fixer.cache
3030
###< squizlabs/php_codesniffer ###
31+
32+
###> friendsofphp/php-cs-fixer ###
33+
/.php-cs-fixer.php
34+
/.php-cs-fixer.cache
35+
###< friendsofphp/php-cs-fixer ###

.php-cs-fixer.dist.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

33
$finder = PhpCsFixer\Finder::create()
4-
->in(__DIR__)
4+
->in(__DIR__.'/src')
55
->ignoreDotFiles(true)
66
->ignoreVCS(true)
7-
->exclude(array('build', 'vendor'))
7+
->exclude(['build', 'vendor'])
88
->files()
99
->name('*.php')
1010
;
@@ -15,19 +15,17 @@
1515
->setUsingCache(true)
1616
->setRiskyAllowed(true)
1717
->setFinder($finder)
18-
->setRules(array(
18+
->setRules([
19+
'@PHP80Migration' => true,
20+
'@PHP80Migration:risky' => true,
1921
'@Symfony' => true,
2022
'@Symfony:risky' => true,
2123
'array_syntax' => ['syntax' => 'short'],
2224
'fopen_flags' => false,
2325
'ordered_imports' => true,
2426
'protected_to_private' => false,
25-
// Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading
26-
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced', 'strict' => true],
27-
// Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading
28-
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
2927
'single_line_throw' => false,
3028
// this must be disabled because the output of some tests include NBSP characters
3129
'non_printable_character' => false,
32-
))
30+
])
3331
;

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
},
5757
"require-dev": {
5858
"doctrine/doctrine-fixtures-bundle": "^3.4",
59-
"phpmd/phpmd": "^2.10",
59+
"friendsofphp/php-cs-fixer": "^3.6",
6060
"phpstan/phpstan": "^1",
6161
"rector/rector": "^0.12.13",
6262
"roave/security-advisories": "dev-latest",

src/CleverAgeProcessUiBundle.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace CleverAge\ProcessUiBundle;
46

57
use CleverAge\ProcessUiBundle\DependencyInjection\Compiler\RegisterLogHandlerCompilerPass;
@@ -18,7 +20,6 @@ class CleverAgeProcessUiBundle extends Bundle
1820
public const CLASS_EDIT = 'text-warning';
1921
public const CLASS_DELETE = '';
2022

21-
2223
public function build(ContainerBuilder $container): void
2324
{
2425
parent::build($container);

src/Command/PurgeProcessExecution.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace CleverAge\ProcessUiBundle\Command;
46

57
use CleverAge\ProcessUiBundle\Entity\ProcessExecution;
@@ -54,7 +56,7 @@ protected function configure(): void
5456
InputOption::VALUE_NEGATABLE,
5557
'Remove log files ? (default false)',
5658
false
57-
)
59+
),
5860
])
5961
);
6062
}
@@ -68,7 +70,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
6870
if ($removeFiles) {
6971
$finder = new Finder();
7072
$fs = new Filesystem();
71-
$finder->in($this->processLogDir)->date("before " . $date->format(DateTimeInterface::ATOM));
73+
$finder->in($this->processLogDir)->date('before '.$date->format(DateTimeInterface::ATOM));
7274
$count = $finder->count();
7375
$fs->remove($finder);
7476
$output->writeln("<info>$count log files are deleted on filesystem.</info>");
@@ -78,8 +80,9 @@ public function execute(InputInterface $input, OutputInterface $output): int
7880
$repository->deleteBefore($date);
7981

8082
$output->writeln(<<<EOT
81-
<info>Process Execution before {$date->format(DateTimeInterface::ATOM)} are deleted into database.</info>
82-
EOT);
83+
<info>Process Execution before {$date->format(DateTimeInterface::ATOM)} are deleted into database.</info>
84+
EOT);
85+
8386
return Command::SUCCESS;
8487
}
8588
}

src/Command/UserCreateCommand.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace CleverAge\ProcessUiBundle\Command;
46

57
use CleverAge\ProcessUiBundle\Entity\User;
@@ -10,13 +12,12 @@
1012
use Symfony\Component\Console\Style\SymfonyStyle;
1113
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
1214
use Symfony\Component\Validator\Constraints\Email;
13-
use Symfony\Component\Validator\Constraints\NotBlank;
1415
use Symfony\Component\Validator\Constraints\Length;
16+
use Symfony\Component\Validator\Constraints\NotBlank;
1517
use Symfony\Component\Validator\Validator\ValidatorInterface;
1618

1719
/**
18-
* Class UserCreateCommand
19-
* @package App\Command
20+
* Class UserCreateCommand.
2021
*/
2122
final class UserCreateCommand extends Command
2223
{
@@ -45,7 +46,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4546
{
4647
$style = new SymfonyStyle($input, $output);
4748
$username = $this->ask('Please enter the email.', $style, [new Email()]);
48-
$password = $this->ask('Please enter the user password.', $style, [new NotBlank(), new Length(min:8)]);
49+
$password = $this->ask('Please enter the user password.', $style, [new NotBlank(), new Length(min: 8)]);
4950

5051
$user = new User();
5152
$user->setEmail($username);
@@ -61,10 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6162
}
6263

6364
/**
64-
* @param string $question
65-
* @param SymfonyStyle $style
6665
* @param array <int, mixed> $constraints
67-
* @return mixed
6866
*/
6967
private function ask(string $question, SymfonyStyle $style, array $constraints = []): mixed
7068
{

src/Controller/Crud/ProcessCrudController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace CleverAge\ProcessUiBundle\Controller\Crud;
46

57
use CleverAge\ProcessUiBundle\Entity\Process;
@@ -58,7 +60,7 @@ public function configureFields(string $pageName): array
5860
'target',
5961
'lastExecutionDate',
6062
IntegerField::new('lastExecutionStatus')->formatValue(static function (?int $value) {
61-
/** @phpstan-ignore-next-line */
63+
/* @phpstan-ignore-next-line */
6264
return match ($value) {
6365
ProcessExecution::STATUS_FAIL => '<button class="btn btn-danger btn-lm">failed</button>',
6466
ProcessExecution::STATUS_START => '<button class="btn btn-warning btn-lm">started</button>',
@@ -77,9 +79,7 @@ public function configureActions(Actions $actions): Actions
7779
$runProcess = Action::new('run', '', 'fa fa-rocket')
7880
->linkToCrudAction('runProcessAction');
7981
$runProcess->setHtmlAttributes(['data-toggle' => 'tooltip', 'title' => 'Run process in background']);
80-
$runProcess->displayIf(function (Process $process) {
81-
return $this->processUiConfigurationManager->canRun($process);
82-
});
82+
$runProcess->displayIf(fn (Process $process) => $this->processUiConfigurationManager->canRun($process));
8383
$viewHistoryAction = Action::new('viewHistory', '', 'fa fa-history')
8484
->linkToCrudAction('viewHistoryAction');
8585
$viewHistoryAction->setHtmlAttributes(['data-toggle' => 'tooltip', 'title' => 'View executions history']);
@@ -133,8 +133,8 @@ public function viewHistoryAction(AdminContext $adminContext): RedirectResponse
133133
->setAction(Action::INDEX)
134134
->setAll([
135135
'filters' => [
136-
'processCode' => ['comparison' => ComparisonType::EQ, 'value' => $process->getProcessCode()]
137-
]
136+
'processCode' => ['comparison' => ComparisonType::EQ, 'value' => $process->getProcessCode()],
137+
],
138138
])
139139
->generateUrl()
140140
);

src/Controller/Crud/ProcessExecutionCrudController.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace CleverAge\ProcessUiBundle\Controller\Crud;
46

57
use CleverAge\ProcessUiBundle\Entity\ProcessExecution;
@@ -57,7 +59,7 @@ public function configureCrud(Crud $crud): Crud
5759
$crud->showEntityActionsInlined();
5860
$crud->setDefaultSort(['startDate' => SortOrder::DESC]);
5961
$crud->setEntityPermission('ROLE_ADMIN');
60-
$crud->setSearchFields($this->indexLogs === true ? ['logRecords.message'] : null);
62+
$crud->setSearchFields(true === $this->indexLogs ? ['logRecords.message'] : null);
6163

6264
return $crud;
6365
}
@@ -67,15 +69,14 @@ public function configureCrud(Crud $crud): Crud
6769
*/
6870
public function configureFields(string $pageName): array
6971
{
70-
7172
return [
7273
Field::new('processCode', 'Process'),
7374
'source',
7475
'target',
7576
'startDate',
7677
'endDate',
7778
IntegerField::new('status')->formatValue(static function (int $value) {
78-
/** @phpstan-ignore-next-line */
79+
/* @phpstan-ignore-next-line */
7980
return match ($value) {
8081
ProcessExecution::STATUS_FAIL => '<button class="btn btn-danger btn-lm">failed</button>',
8182
ProcessExecution::STATUS_START => '<button class="btn btn-warning btn-lm">started</button>',
@@ -88,17 +89,17 @@ public function configureFields(string $pageName): array
8889
public function configureFilters(Filters $filters): Filters
8990
{
9091
$processCodeChoices = $this->processUiConfigurationManager->getProcessChoices();
91-
if (count($processCodeChoices) > 0) {
92+
if (\count($processCodeChoices) > 0) {
9293
$filters->add(ChoiceFilter::new('processCode', 'Process')->setChoices($processCodeChoices));
9394
}
9495

9596
$sourceChoices = $this->processUiConfigurationManager->getSourceChoices();
96-
if (count($sourceChoices) > 0) {
97+
if (\count($sourceChoices) > 0) {
9798
$filters->add(ChoiceFilter::new('source')->setChoices($sourceChoices));
9899
}
99100

100101
$targetChoices = $this->processUiConfigurationManager->getTargetChoices();
101-
if (count($targetChoices) > 0) {
102+
if (\count($targetChoices) > 0) {
102103
$filters->add(ChoiceFilter::new('target')->setChoices($targetChoices));
103104
}
104105
$filters->add(ChoiceFilter::new('status')->setChoices([
@@ -130,11 +131,11 @@ public function downloadLog(AdminContext $context): Response
130131
{
131132
/** @var ProcessExecution $processExecution */
132133
$processExecution = $context->getEntity()->getInstance();
133-
$filepath = $this->processLogDir . DIRECTORY_SEPARATOR . $processExecution->getLog();
134+
$filepath = $this->processLogDir.\DIRECTORY_SEPARATOR.$processExecution->getLog();
134135
$basename = basename($filepath);
135136
$content = file_get_contents($filepath);
136137
if (false === $content) {
137-
throw new NotFoundHttpException("Log file not found.");
138+
throw new NotFoundHttpException('Log file not found.');
138139
}
139140
$response = new Response($content);
140141
$response->headers->set('Content-Type', 'text/plain; charset=utf-8');

src/Controller/Crud/UserCrudController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace CleverAge\ProcessUiBundle\Controller\Crud;
46

57
use CleverAge\ProcessUiBundle\CleverAgeProcessUiBundle;
@@ -114,7 +116,7 @@ public function createNewFormBuilder(
114116

115117
protected function addEncodePasswordEventListener(FormBuilderInterface $formBuilder): void
116118
{
117-
$formBuilder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) {
119+
$formBuilder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event): void {
118120
/** @var User $user */
119121
$user = $event->getData();
120122
$password = $user->getPassword();

src/Controller/DashboardController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace CleverAge\ProcessUiBundle\Controller;
46

57
use CleverAge\ProcessUiBundle\Controller\Crud\ProcessCrudController;

0 commit comments

Comments
 (0)