Skip to content

Commit

Permalink
Enforce maximum line length
Browse files Browse the repository at this point in the history
  • Loading branch information
yann-eugone committed Jan 5, 2024
1 parent a3c72ba commit 8d22335
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 17 deletions.
4 changes: 4 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer;
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

Expand Down Expand Up @@ -41,6 +42,9 @@
'identical' => false,
'less_and_greater' => false,
]);
$ecsConfig->ruleWithConfiguration(LineLengthFixer::class, [
LineLengthFixer::INLINE_SHORT_LINES => false,
]);
$ecsConfig->ruleWithConfiguration(ForbiddenFunctionsSniff::class, [
'forbiddenFunctions' => ['dump' => null, 'dd' => null, 'var_dump' => null, 'die' => null],
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public function __construct(

public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository
{
return $this->repositories[$entityName] ??= new $this->class($this->decorated->getRepository($entityManager, $entityName));
return $this->repositories[$entityName] ??= new $this->class(
$this->decorated->getRepository($entityManager, $entityName)
);
}
}
9 changes: 7 additions & 2 deletions src/batch-doctrine-persistence/tests/ObjectRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ public function testFindOneBy(): void
self::assertSame($this->lucy, $registry->findOneBy(User::class, ['name' => 'Lucy']));
self::assertNull($registry->findOneBy(User::class, ['name' => 'John']));

self::assertSame($this->galaxyExplorer, $registry->findOneBy(Product::class, ['name' => 'Galaxy Explorer']));
self::assertSame(
$this->galaxyExplorer,
$registry->findOneBy(Product::class, ['name' => 'Galaxy Explorer'])
);
self::assertSame($this->boutiqueHotel, $registry->findOneBy(Product::class, ['name' => 'Boutique Hotel']));
self::assertNull($registry->findOneBy(Product::class, ['name' => 'Haunted House']));
}
Expand Down Expand Up @@ -115,7 +118,9 @@ public function testReset(): void
// But here in the test, it is not possible to call the repository more than once
// Hence, if we call reset after using the registry at least once, the repository will fail
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Method findOneBy with args a:1:{i:0;a:1:{s:4:"name";s:5:"Emmet";}} has already been called');
$this->expectExceptionMessage(
'Method findOneBy with args a:1:{i:0;a:1:{s:4:"name";s:5:"Emmet";}} has already been called'
);

$registry = new ObjectRegistry($this->doctrine);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ class YokaiBatchExtensionTest extends TestCase
/**
* @dataProvider configs
*/
public function test(array $config, ?callable $configure, string $storage, ?callable $templating, ?array $security): void
{
public function test(
array $config,
?callable $configure,
string $storage,
?callable $templating,
?array $security
): void {
$container = new ContainerBuilder();
if ($configure !== null) {
$configure($container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ public static function view(): \Generator
new JobParameters(['type' => 'complete']),
new Summary(['count' => 156]),
);
$exportExecution->addWarning(new Warning('Skipped suspicious record', [], ['suspicious_record' => 2]));
$exportExecution->addWarning(
new Warning('Skipped suspicious record', [], ['suspicious_record' => 2])
);
$exportExecution->addFailure(new Failure('RuntimeException', 'Missing record #2', 0));
$exportExecution->setStartTime(new \DateTimeImmutable('2021-01-01 10:00'));
$exportExecution->setEndTime(new \DateTimeImmutable('2021-01-01 11:00'));
Expand Down Expand Up @@ -516,7 +518,9 @@ private static function fixtures(int $count, array $attributes = []): void
BatchStatus::FAILED,
])),
'startTime' => $start = (new \DateTimeImmutable())->setTimestamp(\random_int(0, \time() - 10)),
'endTime' => (new \DateTimeImmutable())->setTimestamp(\random_int($start->getTimestamp(), \time() - 10)),
'endTime' => (new \DateTimeImmutable())->setTimestamp(
\random_int($start->getTimestamp(), \time() - 10)
),
],
$attributes,
);
Expand Down
7 changes: 5 additions & 2 deletions src/batch-symfony-serializer/tests/Dummy/DummyNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ public function supportsNormalization(mixed $data, string $format = null, array
return $this->supports;
}

public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
public function normalize(
mixed $object,
string $format = null,
array $context = []
): array|string|int|float|bool|\ArrayObject|null {
return $this->value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ public function supportsNormalization(mixed $data, string $format = null, array
return true;
}

public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
public function normalize(
mixed $object,
string $format = null,
array $context = []
): array|string|int|float|bool|\ArrayObject|null {
throw $this->exception;
}

Expand Down
30 changes: 24 additions & 6 deletions tests/symfony/tests/UserInterfaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,34 @@ static function (string $content) {
self::assertStringContainsString('Starting job {"job":"star-wars.import"}', $content);

self::assertStringContainsString('Starting child job {"job":"star-wars.import:planet"}', $content);
self::assertStringContainsString('Job produced summary {"job":"star-wars.import:planet","read":61,"processed":60,"skipped":1,"invalid":1,"write":60}', $content);
self::assertStringContainsString('Job executed successfully {"job":"star-wars.import:planet"', $content);
self::assertStringContainsString(
'Job produced summary {"job":"star-wars.import:planet","read":61,"processed":60,"skipped":1,"invalid":1,"write":60}',
$content
);
self::assertStringContainsString(
'Job executed successfully {"job":"star-wars.import:planet"',
$content
);

self::assertStringContainsString('Starting child job {"job":"star-wars.import:specie"}', $content);
self::assertStringContainsString('Job produced summary {"job":"star-wars.import:specie","read":37,"processed":37,"write":37}', $content);
self::assertStringContainsString('Job executed successfully {"job":"star-wars.import:specie"', $content);
self::assertStringContainsString(
'Job produced summary {"job":"star-wars.import:specie","read":37,"processed":37,"write":37}',
$content
);
self::assertStringContainsString(
'Job executed successfully {"job":"star-wars.import:specie"',
$content
);

self::assertStringContainsString('Starting child job {"job":"star-wars.import:character"}', $content);
self::assertStringContainsString('Job produced summary {"job":"star-wars.import:character","read":87,"processed":87,"write":87}', $content);
self::assertStringContainsString('Job executed successfully {"job":"star-wars.import:character"', $content);
self::assertStringContainsString(
'Job produced summary {"job":"star-wars.import:character","read":87,"processed":87,"write":87}',
$content
);
self::assertStringContainsString(
'Job executed successfully {"job":"star-wars.import:character"',
$content
);

self::assertStringContainsString('Job executed successfully {"job":"star-wars.import"', $content);
},
Expand Down

0 comments on commit 8d22335

Please sign in to comment.