Skip to content

Commit 6c9dbab

Browse files
authored
Enhanced code style (#113)
* Forbid yoda style condition * Enforce maximum line length * Enforce trailing slash on native functions invocation
1 parent ccb5c1f commit 6c9dbab

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private function ui(): ArrayNodeDefinition
110110
->addDefaultsIfNotSet()
111111
->beforeNormalization()
112112
->always(function (string|array $value) {
113-
if (is_string($value)) {
113+
if (\is_string($value)) {
114114
$value = match ($value) {
115115
'bootstrap4' => ['prefix' => '@YokaiBatch/bootstrap4', 'service' => null],
116116
'sonata' => ['service' => 'yokai_batch.ui.sonata_templating', 'prefix' => null],

src/DependencyInjection/YokaiBatchExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function load(array $configs, ContainerBuilder $container): void
5656
'symfony/validator/' => $this->installed('symfony-validator'),
5757
];
5858

59-
foreach (array_keys(array_filter($bridges)) as $resource) {
59+
foreach (\array_keys(\array_filter($bridges)) as $resource) {
6060
$loader->load($resource);
6161
}
6262

@@ -127,7 +127,7 @@ private function configureStorage(ContainerBuilder $container, array $config): v
127127
$defaultStorageDefinition = $container->getDefinition($defaultStorage);
128128
} catch (ServiceNotFoundException $exception) {
129129
throw new LogicException(
130-
sprintf('Configured default job execution storage service "%s" does not exists.', $defaultStorage),
130+
\sprintf('Configured default job execution storage service "%s" does not exists.', $defaultStorage),
131131
0,
132132
$exception
133133
);
@@ -146,7 +146,7 @@ private function configureStorage(ContainerBuilder $container, array $config): v
146146
QueryableJobExecutionStorageInterface::class => false,
147147
];
148148
foreach ($interfaces as $interface => $required) {
149-
if (!is_a($defaultStorageClass, $interface, true)) {
149+
if (!\is_a($defaultStorageClass, $interface, true)) {
150150
if ($required) {
151151
throw new LogicException(
152152
\sprintf(
@@ -207,7 +207,7 @@ private function configureUserInterface(ContainerBuilder $container, LoaderInter
207207
}
208208
} catch (ServiceNotFoundException $exception) {
209209
throw new LogicException(
210-
sprintf('Configured UI templating service "%s" does not exists.', $templating['service']),
210+
\sprintf('Configured UI templating service "%s" does not exists.', $templating['service']),
211211
0,
212212
$exception
213213
);

src/UserInterface/Form/JobFilterType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
3939
ChoiceType::class,
4040
[
4141
'label' => 'job.field.job_name',
42-
'choice_label' => fn($choice, string $key, $value) => sprintf('job.job_name.%s', $key),
42+
'choice_label' => fn($choice, string $key, $value) => \sprintf('job.job_name.%s', $key),
4343
'choices' => \array_combine($this->jobs, $this->jobs),
4444
'required' => false,
4545
'multiple' => true,
@@ -50,7 +50,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5050
ChoiceType::class,
5151
[
5252
'label' => 'job.field.status',
53-
'choice_label' => fn($choice, string $key, $value) => sprintf('job.status.%s', $key),
53+
'choice_label' => fn($choice, string $key, $value) => \sprintf('job.status.%s', $key),
5454
'choices' => self::STATUSES,
5555
'required' => false,
5656
'multiple' => true,

tests/DependencyInjection/YokaiBatchExtensionTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ class YokaiBatchExtensionTest extends TestCase
2222
/**
2323
* @dataProvider configs
2424
*/
25-
public function test(array $config, ?callable $configure, string $storage, ?callable $templating, ?array $security): void
26-
{
25+
public function test(
26+
array $config,
27+
?callable $configure,
28+
string $storage,
29+
?callable $templating,
30+
?array $security
31+
): void {
2732
$container = new ContainerBuilder();
2833
if ($configure !== null) {
2934
$configure($container);

tests/UserInterface/Controller/JobControllerTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ public static function view(): \Generator
234234
new JobParameters(['type' => 'complete']),
235235
new Summary(['count' => 156]),
236236
);
237-
$exportExecution->addWarning(new Warning('Skipped suspicious record', [], ['suspicious_record' => 2]));
237+
$exportExecution->addWarning(
238+
new Warning('Skipped suspicious record', [], ['suspicious_record' => 2])
239+
);
238240
$exportExecution->addFailure(new Failure('RuntimeException', 'Missing record #2', 0));
239241
$exportExecution->setStartTime(new \DateTimeImmutable('2021-01-01 10:00'));
240242
$exportExecution->setEndTime(new \DateTimeImmutable('2021-01-01 11:00'));
@@ -516,7 +518,9 @@ private static function fixtures(int $count, array $attributes = []): void
516518
BatchStatus::FAILED,
517519
])),
518520
'startTime' => $start = (new \DateTimeImmutable())->setTimestamp(\random_int(0, \time() - 10)),
519-
'endTime' => (new \DateTimeImmutable())->setTimestamp(\random_int($start->getTimestamp(), \time() - 10)),
521+
'endTime' => (new \DateTimeImmutable())->setTimestamp(
522+
\random_int($start->getTimestamp(), \time() - 10)
523+
),
520524
],
521525
$attributes,
522526
);

tests/UserInterface/JobSecurityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(private array $attributes)
4141

4242
public function isGranted(mixed $attribute, mixed $subject = null): bool
4343
{
44-
return in_array($attribute, $this->attributes, true)
44+
return \in_array($attribute, $this->attributes, true)
4545
&& ($subject === null || $subject instanceof JobExecution);
4646
}
4747
};

0 commit comments

Comments
 (0)