diff --git a/composer.json b/composer.json index 8256cd30..eee38fe6 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,7 @@ "symfony/translation": "^6.4|^7.0", "symfony/twig-bundle": "^6.4|^7.0", "symfony/yaml": "^6.4|^7.0", - "symplify/easy-coding-standard": "^11.3" + "symplify/easy-coding-standard": "^12.5" }, "replace": { "yokai/batch": "self.version", diff --git a/ecs.php b/ecs.php index 955ba4f8..3216af61 100644 --- a/ecs.php +++ b/ecs.php @@ -3,57 +3,79 @@ declare(strict_types=1); use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff; +use PhpCsFixer\Fixer\Basic\SingleLineEmptyBodyFixer; +use PhpCsFixer\Fixer\CastNotation\CastSpacesFixer; +use PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer; use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer; use PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer; use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer; +use PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer; +use PhpCsFixer\Fixer\StringNotation\ExplicitStringVariableFixer; +use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer; 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; -return function (ECSConfig $ecsConfig): void { - $ecsConfig->paths([ - __DIR__ . '/src', - __DIR__ . '/tests/convention', - __DIR__ . '/tests/integration', - __DIR__ . '/tests/symfony/src', - __DIR__ . '/tests/symfony/tests', - ]); +$composer = \json_decode(\file_get_contents(__DIR__.'/composer.json'), true); - $ecsConfig->sets([ - SetList::ARRAY, - SetList::DOCBLOCK, - SetList::NAMESPACES, - SetList::COMMENTS, - SetList::STRICT, - SetList::PSR_12, - ]); - - $ecsConfig->skip([ - /* Do not force array on multiple lines : ['foo' => $foo, 'bar' => $bar] */ - ArrayOpenerAndCloserNewlineFixer::class, - ArrayListItemNewlineFixer::class, - StandaloneLineInMultilineArrayFixer::class, - ]); - - $ecsConfig->ruleWithConfiguration(YodaStyleFixer::class, [ - 'equal' => false, - 'identical' => false, - 'less_and_greater' => false, - ]); - $ecsConfig->ruleWithConfiguration(LineLengthFixer::class, [ - LineLengthFixer::INLINE_SHORT_LINES => false, - ]); - $ecsConfig->ruleWithConfiguration(ForbiddenFunctionsSniff::class, [ +return ECSConfig::configure() + ->withPaths(\array_map( + fn(string $path) => __DIR__ . '/' . $path, + [ + ...\array_values($composer['autoload']['psr-4']), + ...\array_values($composer['autoload-dev']['psr-4']), + ] + )) + ->withPhpCsFixerSets( + // https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/ruleSets/PER-CS2.0.rst + perCS20: true, + ) + ->withPreparedSets( + arrays: true, + comments: true, + docblocks: true, + namespaces: true, + phpunit: true, + strict: true, + ) + ->withConfiguredRule(BlankLineBeforeStatementFixer::class, [ + 'statements' => ['case', 'continue', 'declare', 'default', 'return', 'throw', 'try'], + ]) + ->withConfiguredRule(CastSpacesFixer::class, [ + 'space' => 'none', + ]) + ->withConfiguredRule(ForbiddenFunctionsSniff::class, [ 'forbiddenFunctions' => ['dump' => null, 'dd' => null, 'var_dump' => null, 'die' => null], - ]); - $ecsConfig->ruleWithConfiguration(FunctionDeclarationFixer::class, [ + ]) + ->withConfiguredRule(FunctionDeclarationFixer::class, [ 'closure_fn_spacing' => 'none', - ]); - $ecsConfig->ruleWithConfiguration(NativeFunctionInvocationFixer::class, [ + ]) + ->withConfiguredRule(LineLengthFixer::class, [ + LineLengthFixer::INLINE_SHORT_LINES => false, + ]) + ->withConfiguredRule(NativeFunctionInvocationFixer::class, [ 'scope' => 'namespaced', 'include' => ['@all'], - ]); -}; + ]) + ->withConfiguredRule(NullableTypeDeclarationFixer::class, [ + 'syntax' => 'union', + ]) + ->withConfiguredRule(YodaStyleFixer::class, [ + 'equal' => false, + 'identical' => false, + 'less_and_greater' => false, + ]) + ->withConfiguredRule(ClassDefinitionFixer::class, [ + 'inline_constructor_arguments' => false, + 'space_before_parenthesis' => false, + ]) + ->withSkip([ + SingleLineEmptyBodyFixer::class, + ArrayListItemNewlineFixer::class, + ArrayOpenerAndCloserNewlineFixer::class, + ExplicitStringVariableFixer::class, + StandaloneLineInMultilineArrayFixer::class, + ]) +; diff --git a/src/batch-doctrine-dbal/src/DoctrineDBALJobExecutionStorage.php b/src/batch-doctrine-dbal/src/DoctrineDBALJobExecutionStorage.php index 294a97bf..d4db9084 100644 --- a/src/batch-doctrine-dbal/src/DoctrineDBALJobExecutionStorage.php +++ b/src/batch-doctrine-dbal/src/DoctrineDBALJobExecutionStorage.php @@ -162,12 +162,15 @@ public function query(Query $query): iterable case Query::SORT_BY_START_ASC: $qb->orderBy('start_time', 'asc'); break; + case Query::SORT_BY_START_DESC: $qb->orderBy('start_time', 'desc'); break; + case Query::SORT_BY_END_ASC: $qb->orderBy('end_time', 'asc'); break; + case Query::SORT_BY_END_DESC: $qb->orderBy('end_time', 'desc'); break; @@ -273,7 +276,7 @@ private function fetchRow(string $jobName, string $id): array $statement = $this->connection->executeQuery( $qb->getSQL(), ['jobName' => $jobName, 'id' => $id], - ['jobName' => Types::STRING, 'id' => Types::STRING] + ['jobName' => Types::STRING, 'id' => Types::STRING], ); /** @var array|null $row */ diff --git a/src/batch-doctrine-dbal/src/DoctrineDBALQueryCursorReader.php b/src/batch-doctrine-dbal/src/DoctrineDBALQueryCursorReader.php index eb1f85e9..8270a114 100644 --- a/src/batch-doctrine-dbal/src/DoctrineDBALQueryCursorReader.php +++ b/src/batch-doctrine-dbal/src/DoctrineDBALQueryCursorReader.php @@ -39,12 +39,12 @@ public function __construct( ) { if (!\str_contains($sql, '{after}') || !\str_contains($sql, '{limit}')) { throw new InvalidArgumentException( - \sprintf('%s $sql argument must contains "{after}" and "{limit}" for pagination.', __METHOD__) + \sprintf('%s $sql argument must contains "{after}" and "{limit}" for pagination.', __METHOD__), ); } if ($batch <= 0) { throw new InvalidArgumentException( - \sprintf('%s $batch argument must be a positive integer.', __METHOD__) + \sprintf('%s $batch argument must be a positive integer.', __METHOD__), ); } @@ -64,7 +64,7 @@ public function read(): Generator do { /** @var Result $statement */ $statement = $this->connection->executeQuery( - \strtr($this->sql, ['{limit}' => $this->batch, '{after}' => $after]) + \strtr($this->sql, ['{limit}' => $this->batch, '{after}' => $after]), ); /** @var array> $rows */ @@ -74,7 +74,7 @@ public function read(): Generator if ($lastRowIdx !== null) { if (!isset($rows[$lastRowIdx][$this->column])) { throw new LogicException( - \sprintf('Query must include "%s" column in results.', $this->column) + \sprintf('Query must include "%s" column in results.', $this->column), ); } $after = $rows[$lastRowIdx][$this->column]; diff --git a/src/batch-doctrine-dbal/src/DoctrineDBALQueryOffsetReader.php b/src/batch-doctrine-dbal/src/DoctrineDBALQueryOffsetReader.php index 677a6e1c..15514497 100644 --- a/src/batch-doctrine-dbal/src/DoctrineDBALQueryOffsetReader.php +++ b/src/batch-doctrine-dbal/src/DoctrineDBALQueryOffsetReader.php @@ -25,12 +25,12 @@ public function __construct(ConnectionRegistry $doctrine, string $sql, string $c { if (\mb_strpos($sql, '{limit}') === false || \mb_strpos($sql, '{offset}') === false) { throw new InvalidArgumentException( - \sprintf('%s $sql argument must contains "{limit}" and "{offset}" for pagination.', __METHOD__) + \sprintf('%s $sql argument must contains "{limit}" and "{offset}" for pagination.', __METHOD__), ); } if ($batch <= 0) { throw new InvalidArgumentException( - \sprintf('%s $batch argument must be a positive integer.', __METHOD__) + \sprintf('%s $batch argument must be a positive integer.', __METHOD__), ); } @@ -52,7 +52,7 @@ public function read(): Generator do { /** @var Result $statement */ $statement = $this->connection->executeQuery( - \strtr($this->sql, ['{limit}' => $this->batch, '{offset}' => $iteration * $this->batch]) + \strtr($this->sql, ['{limit}' => $this->batch, '{offset}' => $iteration * $this->batch]), ); /** @var array> $rows */ diff --git a/src/batch-doctrine-dbal/src/DoctrineDBALUpsertWriter.php b/src/batch-doctrine-dbal/src/DoctrineDBALUpsertWriter.php index 3f0a0759..9a6ee3ca 100644 --- a/src/batch-doctrine-dbal/src/DoctrineDBALUpsertWriter.php +++ b/src/batch-doctrine-dbal/src/DoctrineDBALUpsertWriter.php @@ -49,8 +49,8 @@ public function write(iterable $items): void new Warning( 'Update affected more than one line.', [], - ['table' => $item->getTable(), 'identity' => $item->getIdentity(), 'count' => $affected] - ) + ['table' => $item->getTable(), 'identity' => $item->getIdentity(), 'count' => $affected], + ), ); } diff --git a/src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php b/src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php index e6f6e1c6..3f760c6a 100644 --- a/src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php +++ b/src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php @@ -77,7 +77,7 @@ public function fromRow(array $data, JobExecution $parent = null): JobExecution $status, $parameters, $summary, - new JobExecutionLogs($data['logs']) + new JobExecutionLogs($data['logs']), ); } @@ -134,7 +134,7 @@ private function jsonFromString(array|string $value): array return $value; } - private function dateFromString(?string $date): ?DateTimeImmutable + private function dateFromString(null|string $date): null|DateTimeImmutable { if ($date === null) { return null; @@ -167,7 +167,7 @@ private function failureFromArray(array $array): Failure $array['message'], $array['code'], $array['parameters'], - $array['trace'] + $array['trace'], ); } @@ -191,7 +191,7 @@ private function warningFromArray(array $array): Warning return new Warning($array['message'], $array['parameters'], $array['context']); } - private function toDateString(?DateTimeInterface $date): ?string + private function toDateString(null|DateTimeInterface $date): null|string { if ($date === null) { return null; diff --git a/src/batch-doctrine-dbal/tests/DoctrineDBALJobExecutionStorageTest.php b/src/batch-doctrine-dbal/tests/DoctrineDBALJobExecutionStorageTest.php index 09f00733..9e378182 100644 --- a/src/batch-doctrine-dbal/tests/DoctrineDBALJobExecutionStorageTest.php +++ b/src/batch-doctrine-dbal/tests/DoctrineDBALJobExecutionStorageTest.php @@ -54,7 +54,7 @@ public function testCreateStandardTable(): void 'child_executions', 'logs', ], - \array_keys($columns) + \array_keys($columns), ); } @@ -81,7 +81,7 @@ public function testCreateCustomTable(): void 'child_executions', 'logs', ], - \array_keys($columns) + \array_keys($columns), ); } diff --git a/src/batch-doctrine-dbal/tests/DoctrineDBALQueryCursorReaderTest.php b/src/batch-doctrine-dbal/tests/DoctrineDBALQueryCursorReaderTest.php index 914f3777..01fdf0b7 100644 --- a/src/batch-doctrine-dbal/tests/DoctrineDBALQueryCursorReaderTest.php +++ b/src/batch-doctrine-dbal/tests/DoctrineDBALQueryCursorReaderTest.php @@ -33,12 +33,12 @@ public function test(): void 'id', 0, null, - 4 // we will take 4 records at once : 3 queries expected + 4, // we will take 4 records at once : 3 queries expected ); $read = \array_map( fn(array $row) => \array_map('strval', $row), - \iterator_to_array($reader->read(), false) + \iterator_to_array($reader->read(), false), ); self::assertSame([ @@ -61,7 +61,7 @@ public function testQueryMustContainsAfterPlaceholder(): void $this->doctrine, 'SELECT * FROM some table WHERE id > 0 LIMIT {limit};', 'id', - 0 + 0, ); } @@ -72,7 +72,7 @@ public function testQueryMustContainsLimitPlaceholder(): void $this->doctrine, 'SELECT * FROM some table WHERE id > {after} LIMIT 1;', 'id', - 0 + 0, ); } @@ -85,7 +85,7 @@ public function testBatchMustBePositiveInteger(): void 'id', 0, null, - -1 // must be > 0 + -1, // must be > 0 ); } diff --git a/src/batch-doctrine-dbal/tests/DoctrineDBALQueryOffsetReaderTest.php b/src/batch-doctrine-dbal/tests/DoctrineDBALQueryOffsetReaderTest.php index e9c60372..81a1cb45 100644 --- a/src/batch-doctrine-dbal/tests/DoctrineDBALQueryOffsetReaderTest.php +++ b/src/batch-doctrine-dbal/tests/DoctrineDBALQueryOffsetReaderTest.php @@ -31,12 +31,12 @@ public function test(): void $this->doctrine, 'SELECT * FROM numbers LIMIT {limit} OFFSET {offset};', null, - 4 // we will take 4 records at once : 3 queries expected + 4, // we will take 4 records at once : 3 queries expected ); $read = \array_map( fn(array $row) => \array_map('strval', $row), - \iterator_to_array($reader->read(), false) + \iterator_to_array($reader->read(), false), ); self::assertSame([ @@ -72,7 +72,7 @@ public function testBatchMustBePositiveInteger(): void $this->doctrine, 'SELECT * FROM some table LIMIT {limit} OFFSET {offset};', null, - 0 // must be > 0 + 0, // must be > 0 ); } } diff --git a/src/batch-doctrine-dbal/tests/DoctrineDBALTestCase.php b/src/batch-doctrine-dbal/tests/DoctrineDBALTestCase.php index ecef0b07..92acd3bc 100644 --- a/src/batch-doctrine-dbal/tests/DoctrineDBALTestCase.php +++ b/src/batch-doctrine-dbal/tests/DoctrineDBALTestCase.php @@ -39,7 +39,7 @@ protected function findAll(string $table): array return \array_map( fn(array $row) => \array_map('strval', $row), - $results->fetchAllAssociative() + $results->fetchAllAssociative(), ); } } diff --git a/src/batch-doctrine-dbal/tests/DoctrineDBALUpsertWriterTest.php b/src/batch-doctrine-dbal/tests/DoctrineDBALUpsertWriterTest.php index 8667a93e..0060a1d0 100644 --- a/src/batch-doctrine-dbal/tests/DoctrineDBALUpsertWriterTest.php +++ b/src/batch-doctrine-dbal/tests/DoctrineDBALUpsertWriterTest.php @@ -68,7 +68,7 @@ public function test(): void self::assertSame('Update affected more than one line.', $warnings[0]->getMessage()); self::assertSame( ['table' => 'food', 'identity' => ['type' => 'fruit'], 'count' => 2], - $warnings[0]->getContext() + $warnings[0]->getContext(), ); } diff --git a/src/batch-doctrine-orm/src/EntityReader.php b/src/batch-doctrine-orm/src/EntityReader.php index 6ac7374d..e1767a45 100644 --- a/src/batch-doctrine-orm/src/EntityReader.php +++ b/src/batch-doctrine-orm/src/EntityReader.php @@ -30,7 +30,7 @@ public function read(): iterable throw UnexpectedValueException::type( EntityManagerInterface::class, $manager, - 'Provided class must be a valid Doctrine entity.' + 'Provided class must be a valid Doctrine entity.', ); } diff --git a/src/batch-doctrine-persistence/src/ObjectRegistry.php b/src/batch-doctrine-persistence/src/ObjectRegistry.php index b3d5c0fc..7c2439ce 100644 --- a/src/batch-doctrine-persistence/src/ObjectRegistry.php +++ b/src/batch-doctrine-persistence/src/ObjectRegistry.php @@ -35,7 +35,7 @@ public function __construct( * * @return T|null */ - public function findOneBy(string $class, array $criteria): ?object + public function findOneBy(string $class, array $criteria): null|object { return $this->findOneUsing( $class, @@ -44,7 +44,7 @@ function ($repository) use ($criteria) { return $repository->findOneBy($criteria); }, - \serialize($criteria) + \serialize($criteria), ); } @@ -58,7 +58,7 @@ function ($repository) use ($criteria) { * * @return T|null */ - public function findOneUsing(string $class, \Closure $closure, string $key = null): ?object + public function findOneUsing(string $class, \Closure $closure, string $key = null): null|object { $manager = $this->doctrine->getManagerForClass($class); if ($manager === null) { diff --git a/src/batch-doctrine-persistence/src/ObjectWriter.php b/src/batch-doctrine-persistence/src/ObjectWriter.php index a1766c6b..6ec3b158 100644 --- a/src/batch-doctrine-persistence/src/ObjectWriter.php +++ b/src/batch-doctrine-persistence/src/ObjectWriter.php @@ -70,7 +70,7 @@ private function getManagerForClass(object $item): ObjectManager private function createInvalidItemException(mixed $item): InvalidArgumentException { return new InvalidArgumentException( - \sprintf('Items to write must be object managed by Doctrine. Got "%s".', \get_debug_type($item)) + \sprintf('Items to write must be object managed by Doctrine. Got "%s".', \get_debug_type($item)), ); } } diff --git a/src/batch-doctrine-persistence/tests/Dummy/DecoratedRepositoryFactory.php b/src/batch-doctrine-persistence/tests/Dummy/DecoratedRepositoryFactory.php index 2fac3b11..e2a5d1cb 100644 --- a/src/batch-doctrine-persistence/tests/Dummy/DecoratedRepositoryFactory.php +++ b/src/batch-doctrine-persistence/tests/Dummy/DecoratedRepositoryFactory.php @@ -27,7 +27,7 @@ public function __construct( public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository { return $this->repositories[$entityName] ??= new $this->class( - $this->decorated->getRepository($entityManager, $entityName) + $this->decorated->getRepository($entityManager, $entityName), ); } } diff --git a/src/batch-doctrine-persistence/tests/Dummy/FindOneByCalledOnlyOnceWhenFoundRepositoryDecorator.php b/src/batch-doctrine-persistence/tests/Dummy/FindOneByCalledOnlyOnceWhenFoundRepositoryDecorator.php index a64c9b22..7c75580b 100644 --- a/src/batch-doctrine-persistence/tests/Dummy/FindOneByCalledOnlyOnceWhenFoundRepositoryDecorator.php +++ b/src/batch-doctrine-persistence/tests/Dummy/FindOneByCalledOnlyOnceWhenFoundRepositoryDecorator.php @@ -25,7 +25,7 @@ public function findAll() return $this->decorated->findAll(); } - public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) + public function findBy(array $criteria, null|array $orderBy = null, $limit = null, $offset = null) { return $this->decorated->findBy($criteria, $orderBy, $limit, $offset); } @@ -52,7 +52,7 @@ private function ensureNotCalledAlready(string $method, array $args): void $key = \md5($method . $serializedArgs = \serialize($args)); if (isset($this->calls[$key])) { throw new \LogicException( - 'Method ' . $method . ' with args ' . $serializedArgs . ' has already been called' + 'Method ' . $method . ' with args ' . $serializedArgs . ' has already been called', ); } diff --git a/src/batch-doctrine-persistence/tests/Dummy/SimpleManagerRegistry.php b/src/batch-doctrine-persistence/tests/Dummy/SimpleManagerRegistry.php index 3dbe246c..d8c1e155 100644 --- a/src/batch-doctrine-persistence/tests/Dummy/SimpleManagerRegistry.php +++ b/src/batch-doctrine-persistence/tests/Dummy/SimpleManagerRegistry.php @@ -32,7 +32,7 @@ public function __construct( $managers, $defaultConnection ?? 'unknown', $defaultEntityManager ?? 'unknown', - Proxy::class + Proxy::class, ); } diff --git a/src/batch-doctrine-persistence/tests/ObjectRegistryTest.php b/src/batch-doctrine-persistence/tests/ObjectRegistryTest.php index fe51be96..dafb7152 100644 --- a/src/batch-doctrine-persistence/tests/ObjectRegistryTest.php +++ b/src/batch-doctrine-persistence/tests/ObjectRegistryTest.php @@ -28,14 +28,14 @@ protected function setUpConfigs(Configuration $authConfig, Configuration $shopCo $authConfig->setRepositoryFactory( new DecoratedRepositoryFactory( FindOneByCalledOnlyOnceWhenFoundRepositoryDecorator::class, - $authConfig->getRepositoryFactory() - ) + $authConfig->getRepositoryFactory(), + ), ); $shopConfig->setRepositoryFactory( new DecoratedRepositoryFactory( FindOneByCalledOnlyOnceWhenFoundRepositoryDecorator::class, - $shopConfig->getRepositoryFactory() - ) + $shopConfig->getRepositoryFactory(), + ), ); } @@ -61,7 +61,7 @@ public function testFindOneBy(): void self::assertSame( $this->galaxyExplorer, - $registry->findOneBy(Product::class, ['name' => 'Galaxy Explorer']) + $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'])); @@ -119,7 +119,7 @@ public function testReset(): void // 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' + '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); diff --git a/src/batch-league-flysystem/src/Job/CopyFilesJob.php b/src/batch-league-flysystem/src/Job/CopyFilesJob.php index ceedaab9..61bd3c77 100644 --- a/src/batch-league-flysystem/src/Job/CopyFilesJob.php +++ b/src/batch-league-flysystem/src/Job/CopyFilesJob.php @@ -24,7 +24,7 @@ public function __construct( private JobParameterAccessorInterface $location, private FilesystemReader $source, private FilesystemWriter $destination, - private ?Closure $transformLocation = null, + private null|Closure $transformLocation = null, ) { } @@ -49,34 +49,37 @@ final public function execute(JobExecution $jobExecution): void try { $this->destination->writeStream( $destinationLocation, - $this->source->readStream($sourceLocation) + $this->source->readStream($sourceLocation), ); } catch (UnableToReadFile $exception) { $jobExecution->addFailureException($exception, [], false); $jobExecution->getLogger()->error( 'Unable to read file from filesystem.', - ['file' => $sourceLocation] + ['file' => $sourceLocation], ); + continue; } catch (UnableToWriteFile $exception) { $jobExecution->addFailureException($exception, [], false); $jobExecution->getLogger()->error( 'Unable to write file to filesystem.', - ['file' => $destinationLocation] + ['file' => $destinationLocation], ); + continue; } catch (FilesystemException $exception) { $jobExecution->addFailureException($exception, [], false); $jobExecution->getLogger()->error( 'Unable to copy file.', - ['source' => $sourceLocation, 'destination' => $destinationLocation] + ['source' => $sourceLocation, 'destination' => $destinationLocation], ); + continue; } $jobExecution->getLogger()->notice( 'Copied file from filesystem to another.', - ['source' => $sourceLocation, 'destination' => $destinationLocation] + ['source' => $sourceLocation, 'destination' => $destinationLocation], ); } } diff --git a/src/batch-league-flysystem/src/Job/MoveFilesJob.php b/src/batch-league-flysystem/src/Job/MoveFilesJob.php index ebc8aba5..c63453d0 100644 --- a/src/batch-league-flysystem/src/Job/MoveFilesJob.php +++ b/src/batch-league-flysystem/src/Job/MoveFilesJob.php @@ -25,7 +25,7 @@ public function __construct( private JobParameterAccessorInterface $location, private FilesystemOperator $source, private FilesystemWriter $destination, - private ?Closure $transformLocation = null, + private null|Closure $transformLocation = null, ) { } @@ -50,42 +50,46 @@ final public function execute(JobExecution $jobExecution): void try { $this->destination->writeStream( $destinationLocation, - $this->source->readStream($sourceLocation) + $this->source->readStream($sourceLocation), ); $this->source->delete($sourceLocation); } catch (UnableToReadFile $exception) { $jobExecution->addFailureException($exception, [], false); $jobExecution->getLogger()->error( 'Unable to read file from filesystem.', - ['file' => $sourceLocation] + ['file' => $sourceLocation], ); + continue; } catch (UnableToWriteFile $exception) { $jobExecution->addFailureException($exception, [], false); $jobExecution->getLogger()->error( 'Unable to write file to filesystem.', - ['file' => $destinationLocation] + ['file' => $destinationLocation], ); + continue; } catch (UnableToDeleteFile $exception) { $jobExecution->addFailureException($exception, [], false); $jobExecution->getLogger()->error( 'Unable to delete file from filesystem.', - ['file' => $sourceLocation] + ['file' => $sourceLocation], ); + continue; } catch (FilesystemException $exception) { $jobExecution->addFailureException($exception, [], false); $jobExecution->getLogger()->error( 'Unable to move file.', - ['source' => $sourceLocation, 'destination' => $destinationLocation] + ['source' => $sourceLocation, 'destination' => $destinationLocation], ); + continue; } $jobExecution->getLogger()->notice( 'Moved file from filesystem to another.', - ['source' => $sourceLocation, 'destination' => $destinationLocation] + ['source' => $sourceLocation, 'destination' => $destinationLocation], ); } } diff --git a/src/batch-league-flysystem/src/Scheduler/FileFoundScheduler.php b/src/batch-league-flysystem/src/Scheduler/FileFoundScheduler.php index 1e0b7d14..74daa2c7 100644 --- a/src/batch-league-flysystem/src/Scheduler/FileFoundScheduler.php +++ b/src/batch-league-flysystem/src/Scheduler/FileFoundScheduler.php @@ -45,7 +45,7 @@ public function get(JobExecution $execution): iterable $execution->addFailureException($exception, [], false); $execution->getLogger()->error( 'Unable to assert that location exists on filesystem.', - ['file' => $location] + ['file' => $location], ); return []; diff --git a/src/batch-league-flysystem/tests/Job/CopyFilesJobTest.php b/src/batch-league-flysystem/tests/Job/CopyFilesJobTest.php index 3e018888..10605139 100644 --- a/src/batch-league-flysystem/tests/Job/CopyFilesJobTest.php +++ b/src/batch-league-flysystem/tests/Job/CopyFilesJobTest.php @@ -68,11 +68,11 @@ public function testWithPathTransformation(): void self::assertFalse( $destination->has('source-file.txt'), - 'file-1.txt does not exists yet on destination filesystem' + 'file-1.txt does not exists yet on destination filesystem', ); self::assertFalse( $destination->has('destination-file.txt'), - 'destination-file.txt does not exists yet on destination filesystem' + 'destination-file.txt does not exists yet on destination filesystem', ); $job = new CopyFilesJob($location, $source, $destination, $transformDestination); @@ -81,11 +81,11 @@ public function testWithPathTransformation(): void self::assertTrue($source->has('source-file.txt'), 'source-file.txt still exists on source filesystem'); self::assertFalse( $destination->has('source-file.txt'), - 'source-file.txt still not exists on destination filesystem' + 'source-file.txt still not exists on destination filesystem', ); self::assertTrue( $destination->has('destination-file.txt'), - 'destination-file.txt now exists on destination filesystem' + 'destination-file.txt now exists on destination filesystem', ); self::assertSame('SOURCE TO BE COPIED', $destination->read('destination-file.txt')); } diff --git a/src/batch-league-flysystem/tests/Job/MoveFilesJobTest.php b/src/batch-league-flysystem/tests/Job/MoveFilesJobTest.php index 7c678ef0..063ec70f 100644 --- a/src/batch-league-flysystem/tests/Job/MoveFilesJobTest.php +++ b/src/batch-league-flysystem/tests/Job/MoveFilesJobTest.php @@ -70,11 +70,11 @@ public function testWithPathTransformation(): void self::assertFalse( $destination->has('source-file.txt'), - 'file-1.txt does not exists yet on destination filesystem' + 'file-1.txt does not exists yet on destination filesystem', ); self::assertFalse( $destination->has('destination-file.txt'), - 'destination-file.txt does not exists yet on destination filesystem' + 'destination-file.txt does not exists yet on destination filesystem', ); $job = new MoveFilesJob($location, $source, $destination, $transformDestination); @@ -83,11 +83,11 @@ public function testWithPathTransformation(): void self::assertFalse($source->has('source-file.txt'), 'source-file.txt does exists anymore on source filesystem'); self::assertFalse( $destination->has('source-file.txt'), - 'source-file.txt still not exists on destination filesystem' + 'source-file.txt still not exists on destination filesystem', ); self::assertTrue( $destination->has('destination-file.txt'), - 'destination-file.txt now exists on destination filesystem' + 'destination-file.txt now exists on destination filesystem', ); self::assertSame('SOURCE TO BE MOVED', $destination->read('destination-file.txt')); } diff --git a/src/batch-league-flysystem/tests/Scheduler/FileFoundSchedulerTest.php b/src/batch-league-flysystem/tests/Scheduler/FileFoundSchedulerTest.php index 4b0e3434..c6bec875 100644 --- a/src/batch-league-flysystem/tests/Scheduler/FileFoundSchedulerTest.php +++ b/src/batch-league-flysystem/tests/Scheduler/FileFoundSchedulerTest.php @@ -33,7 +33,7 @@ public function testNoConfig(): void self::assertEquals( [new ScheduledJob('test.scheduled')], $scheduled, - 'file.txt exists on filesystem, job was scheduled' + 'file.txt exists on filesystem, job was scheduled', ); } @@ -48,7 +48,7 @@ public function testStaticConfig(): void $location, 'test.scheduled', ['parameter' => 'value', 'important' => true], - 'fake.job.id' + 'fake.job.id', ); $scheduled = $scheduler->get($execution); @@ -59,7 +59,7 @@ public function testStaticConfig(): void self::assertEquals( [new ScheduledJob('test.scheduled', ['parameter' => 'value', 'important' => true], 'fake.job.id')], $scheduled, - 'file.txt exists on filesystem, job was scheduled' + 'file.txt exists on filesystem, job was scheduled', ); } @@ -74,7 +74,7 @@ public function testClosureConfig(): void $location, 'test.scheduled', fn() => ['parameter' => 'value', 'important' => true], - fn() => 'fake.job.id' + fn() => 'fake.job.id', ); $scheduled = $scheduler->get($execution); @@ -85,7 +85,7 @@ public function testClosureConfig(): void self::assertEquals( [new ScheduledJob('test.scheduled', ['parameter' => 'value', 'important' => true], 'fake.job.id')], $scheduled, - 'file.txt exists on filesystem, job was scheduled' + 'file.txt exists on filesystem, job was scheduled', ); } @@ -116,12 +116,12 @@ public function testFilesystemException(): void self::assertSame( [], $scheduled, - 'file.txt exists on filesystem but got exception on checking existence, no job scheduled' + 'file.txt exists on filesystem but got exception on checking existence, no job scheduled', ); self::assertCount(1, $execution->getFailures()); self::assertStringContainsString( 'Unable to assert that location exists on filesystem.', - (string)$execution->getLogs() + (string)$execution->getLogs(), ); } } diff --git a/src/batch-openspout/src/Reader/FlatFileReader.php b/src/batch-openspout/src/Reader/FlatFileReader.php index 394f2cc4..3863871f 100644 --- a/src/batch-openspout/src/Reader/FlatFileReader.php +++ b/src/batch-openspout/src/Reader/FlatFileReader.php @@ -77,8 +77,8 @@ public function read(): iterable \count($exception->getRow()), ), [], - ['headers' => $exception->getHeaders(), 'row' => $exception->getRow()] - ) + ['headers' => $exception->getHeaders(), 'row' => $exception->getRow()], + ), ); } } diff --git a/src/batch-openspout/src/Reader/HeaderStrategy.php b/src/batch-openspout/src/Reader/HeaderStrategy.php index 380af48c..b8bd2b8c 100644 --- a/src/batch-openspout/src/Reader/HeaderStrategy.php +++ b/src/batch-openspout/src/Reader/HeaderStrategy.php @@ -23,7 +23,7 @@ private function __construct( /** * @var list|null */ - private ?array $headers + private null|array $headers, ) { } diff --git a/src/batch-openspout/src/Writer/FlatFileWriter.php b/src/batch-openspout/src/Writer/FlatFileWriter.php index b0df2031..33449814 100644 --- a/src/batch-openspout/src/Writer/FlatFileWriter.php +++ b/src/batch-openspout/src/Writer/FlatFileWriter.php @@ -36,7 +36,7 @@ final class FlatFileWriter implements { use JobExecutionAwareTrait; - private ?WriterInterface $writer = null; + private null|WriterInterface $writer = null; private bool $headersAdded = false; public function __construct( @@ -46,7 +46,7 @@ public function __construct( /** * @var list|null */ - private ?array $headers = null, + private null|array $headers = null, ) { } @@ -129,6 +129,7 @@ private function changeSheet(string $name): void foreach ($this->writer->getSheets() as $sheet) { if ($sheet->getName() === $name) { $this->writer->setCurrentSheet($sheet); + return; } } diff --git a/src/batch-openspout/tests/Reader/FlatFileReaderTest.php b/src/batch-openspout/tests/Reader/FlatFileReaderTest.php index 068d63d3..7f3f6621 100644 --- a/src/batch-openspout/tests/Reader/FlatFileReaderTest.php +++ b/src/batch-openspout/tests/Reader/FlatFileReaderTest.php @@ -22,9 +22,9 @@ class FlatFileReaderTest extends TestCase */ public function testRead( string $file, - ?object $options, - ?callable $sheetFilter, - ?callable $headers, + null|object $options, + null|callable $sheetFilter, + null|callable $headers, array $expected, ): void { $jobExecution = JobExecution::createRoot('123456789', 'parent'); @@ -32,7 +32,7 @@ public function testRead( new StaticValueParameterAccessor($file), $options, $sheetFilter ? $sheetFilter() : null, - $headers ? $headers() : null + $headers ? $headers() : null, ); $reader->setJobExecution($jobExecution); @@ -206,16 +206,16 @@ public function testReadWrongLineSize(): void ['firstName' => 'John', 'lastName' => 'Doe'], ['firstName' => 'Jack', 'lastName' => 'Doe'], ], - \iterator_to_array($result) + \iterator_to_array($result), ); self::assertSame( 'Expecting row 3 to have exactly 2 columns(s), but got 3.', - $jobExecution->getWarnings()[0]->getMessage() + $jobExecution->getWarnings()[0]->getMessage(), ); self::assertSame( ['headers' => ['firstName', 'lastName'], 'row' => ['Jane', 'Doe', 'too much data']], - $jobExecution->getWarnings()[0]->getContext() + $jobExecution->getWarnings()[0]->getContext(), ); } diff --git a/src/batch-openspout/tests/Writer/FlatFileWriterTest.php b/src/batch-openspout/tests/Writer/FlatFileWriterTest.php index c720b1b0..e3d63f8a 100644 --- a/src/batch-openspout/tests/Writer/FlatFileWriterTest.php +++ b/src/batch-openspout/tests/Writer/FlatFileWriterTest.php @@ -29,11 +29,11 @@ class FlatFileWriterTest extends TestCase */ public function testWrite( string $filename, - ?object $options, - ?string $defaultSheet, - ?array $headers, + null|object $options, + null|string $defaultSheet, + null|array $headers, iterable $itemsToWrite, - string $expectedContent + string $expectedContent, ): void { $file = self::WRITE_DIR . '/' . $filename; self::assertFileDoesNotExist($file); @@ -228,7 +228,7 @@ public function types(): \Generator /** * @dataProvider multipleSheets */ - public function testWriteMultipleSheets(string $type, ?string $defaultSheet): void + public function testWriteMultipleSheets(string $type, null|string $defaultSheet): void { $file = self::WRITE_DIR . '/multiple-sheets.' . $type; self::assertFileDoesNotExist($file); diff --git a/src/batch-symfony-console/src/CommandRunner.php b/src/batch-symfony-console/src/CommandRunner.php index 8ebb713c..b37d5336 100644 --- a/src/batch-symfony-console/src/CommandRunner.php +++ b/src/batch-symfony-console/src/CommandRunner.php @@ -13,7 +13,7 @@ class CommandRunner { private string $consolePath; - private ?PhpExecutableFinder $phpLocator; + private null|PhpExecutableFinder $phpLocator; public function __construct( string $binDir, @@ -38,8 +38,8 @@ public function runAsync(string $commandName, string $logFilename, array $argume \sprintf( '%s >> %s 2>&1 &', $this->buildCommand($commandName, $arguments), - \implode(DIRECTORY_SEPARATOR, [$this->logDir, $logFilename]) - ) + \implode(DIRECTORY_SEPARATOR, [$this->logDir, $logFilename]), + ), ); } @@ -61,7 +61,7 @@ private function buildCommand(string $commandName, array $arguments): string $this->phpLocator ? $this->phpLocator->find() : 'php', $this->consolePath, $commandName, - (string)(new ArrayInput($arguments)) + (string)(new ArrayInput($arguments)), ); } } diff --git a/src/batch-symfony-console/src/RunCommandJobLauncher.php b/src/batch-symfony-console/src/RunCommandJobLauncher.php index 4457314c..180f349b 100644 --- a/src/batch-symfony-console/src/RunCommandJobLauncher.php +++ b/src/batch-symfony-console/src/RunCommandJobLauncher.php @@ -41,7 +41,7 @@ public function launch(string $name, array $configuration = []): JobExecution [ 'job' => $name, 'configuration' => \json_encode($configuration, JSON_THROW_ON_ERROR), - ] + ], ); return $jobExecution; diff --git a/src/batch-symfony-console/src/RunJobCommand.php b/src/batch-symfony-console/src/RunJobCommand.php index 78f55fb1..9fd5f17f 100644 --- a/src/batch-symfony-console/src/RunJobCommand.php +++ b/src/batch-symfony-console/src/RunJobCommand.php @@ -82,7 +82,7 @@ private function outputExecution(JobExecution $jobExecution, OutputInterface $ou $output->writeln(\sprintf('%s', $warning), $output::VERBOSITY_VERBOSE); } $output->writeln( - \sprintf('%s has been executed with %d warnings.', $jobName, \count($warnings)) + \sprintf('%s has been executed with %d warnings.', $jobName, \count($warnings)), ); } else { $output->writeln(\sprintf('%s has been successfully executed.', $jobName)); @@ -95,8 +95,8 @@ private function outputExecution(JobExecution $jobExecution, OutputInterface $ou 'Error #%s of class %s: %s', $failure->getCode(), $failure->getClass(), - $failure - ) + $failure, + ), ); if ($failure->getTrace() !== null) { $output->writeln(\sprintf('%s', $failure->getTrace()), $output::VERBOSITY_VERBOSE); diff --git a/src/batch-symfony-console/src/SetupStorageCommand.php b/src/batch-symfony-console/src/SetupStorageCommand.php index 027c52a0..115fead0 100644 --- a/src/batch-symfony-console/src/SetupStorageCommand.php +++ b/src/batch-symfony-console/src/SetupStorageCommand.php @@ -32,7 +32,7 @@ protected function configure(): void The %command.name% command setups the job execution storage: php %command.full_name% -EOF +EOF, ) ; } diff --git a/src/batch-symfony-console/tests/CommandRunnerTest.php b/src/batch-symfony-console/tests/CommandRunnerTest.php index 4872426d..ffbc86f3 100644 --- a/src/batch-symfony-console/tests/CommandRunnerTest.php +++ b/src/batch-symfony-console/tests/CommandRunnerTest.php @@ -37,13 +37,13 @@ public function testRunAsync(): void ->method('exec') ->with( '/usr/bin/php /path/to/bin/console yokai:testing:test 1 ' . - '\'{"json":["value",2]}"\' --opt --option=foo >> /path/to/logs/test.log 2>&1 &' + '\'{"json":["value",2]}"\' --opt --option=foo >> /path/to/logs/test.log 2>&1 &', ); $runner->runAsync( 'yokai:testing:test', 'test.log', - ['arg1' => '1', 'arg2' => '{"json":["value",2]}"', '--opt', '--option' => 'foo'] + ['arg1' => '1', 'arg2' => '{"json":["value",2]}"', '--opt', '--option' => 'foo'], ); } } diff --git a/src/batch-symfony-console/tests/RunCommandJobLauncherTest.php b/src/batch-symfony-console/tests/RunCommandJobLauncherTest.php index 679e3b00..b1f47608 100644 --- a/src/batch-symfony-console/tests/RunCommandJobLauncherTest.php +++ b/src/batch-symfony-console/tests/RunCommandJobLauncherTest.php @@ -33,7 +33,7 @@ public function testLaunch(): void new JobExecutionFactory(new UniqidJobExecutionIdGenerator(), new NullJobExecutionParametersBuilder()), $commandRunner->reveal(), $storage = new InMemoryJobExecutionStorage(), - 'test.log' + 'test.log', ); $jobExecutionFromLauncher = $launcher->launch('testing', $config); diff --git a/src/batch-symfony-console/tests/RunJobCommandTest.php b/src/batch-symfony-console/tests/RunJobCommandTest.php index 7de49f4f..d5a98e5a 100644 --- a/src/batch-symfony-console/tests/RunJobCommandTest.php +++ b/src/batch-symfony-console/tests/RunJobCommandTest.php @@ -45,7 +45,7 @@ protected function setUp(): void $this->executor = new JobExecutor( JobRegistry::fromJobArray([self::JOBNAME => $this->job->reveal()]), new InMemoryJobExecutionStorage(), - null + null, ); } @@ -76,6 +76,7 @@ public function testRunWithErrors(int $verbosity): void $jobExecution = $args[0]; $jobExecution->addFailureException(new \RuntimeException('1st exception', 100)); $jobExecution->addFailureException(new \LogicException('2nd exception', 200)); + throw new \Exception('The exception that failed the job', 300); }); @@ -91,7 +92,7 @@ public function testRunWithErrors(int $verbosity): void self::assertStringContainsString('Error #200 of class LogicException: 2nd exception', $display); self::assertStringContainsString( 'Error #300 of class Exception: The exception that failed the job', - $display + $display, ); } } diff --git a/src/batch-symfony-console/tests/SetupStorageCommandTest.php b/src/batch-symfony-console/tests/SetupStorageCommandTest.php index d5e9e73e..86e63094 100644 --- a/src/batch-symfony-console/tests/SetupStorageCommandTest.php +++ b/src/batch-symfony-console/tests/SetupStorageCommandTest.php @@ -17,7 +17,7 @@ final class SetupStorageCommandTest extends TestCase public function testSetupRequired(): void { $this->execute( - $storage = new class() implements + $storage = new class implements JobExecutionStorageInterface, SetupableJobExecutionStorageInterface { public bool $wasSetup = false; @@ -48,7 +48,7 @@ public function retrieve(string $jobName, string $executionId): JobExecution public function testSetupNotRequired(): void { $this->execute( - new class() implements JobExecutionStorageInterface { + new class implements JobExecutionStorageInterface { public function store(JobExecution $execution): void { } diff --git a/src/batch-symfony-framework/src/ContainerParameterAccessor.php b/src/batch-symfony-framework/src/ContainerParameterAccessor.php index 30ef25f3..a9077146 100644 --- a/src/batch-symfony-framework/src/ContainerParameterAccessor.php +++ b/src/batch-symfony-framework/src/ContainerParameterAccessor.php @@ -28,7 +28,7 @@ public function get(JobExecution $execution): mixed } catch (InvalidArgumentException $exception) { throw new CannotAccessParameterException( \sprintf('Cannot access "%s" parameter from container parameters', $this->name), - $exception + $exception, ); } } diff --git a/src/batch-symfony-framework/src/DependencyInjection/YokaiBatchExtension.php b/src/batch-symfony-framework/src/DependencyInjection/YokaiBatchExtension.php index 75459e6f..ea0b3d03 100644 --- a/src/batch-symfony-framework/src/DependencyInjection/YokaiBatchExtension.php +++ b/src/batch-symfony-framework/src/DependencyInjection/YokaiBatchExtension.php @@ -88,7 +88,7 @@ private function getLoader(ContainerBuilder $container): LoaderInterface [ new DependencyInjectionLoader\XmlFileLoader($container, $locator), new DependencyInjectionLoader\DirectoryLoader($container, $locator), - ] + ], ); return new ConfigLoader\DelegatingLoader($resolver); @@ -111,7 +111,7 @@ private function configureStorage(ContainerBuilder $container, array $config): v 'connection' => $config['dbal']['connection'], 'table' => $config['dbal']['table'], ], - ] + ], ) ; diff --git a/src/batch-symfony-framework/src/UserInterface/Controller/JobController.php b/src/batch-symfony-framework/src/UserInterface/Controller/JobController.php index 7632ab15..d692c3f9 100644 --- a/src/batch-symfony-framework/src/UserInterface/Controller/JobController.php +++ b/src/batch-symfony-framework/src/UserInterface/Controller/JobController.php @@ -31,7 +31,7 @@ final class JobController public function __construct( private QueryableJobExecutionStorageInterface $jobExecutionStorage, - private ?FormFactoryInterface $formFactory, + private null|FormFactoryInterface $formFactory, private JobSecurity $security, private Environment $twig, private TemplatingInterface $templating, @@ -60,7 +60,7 @@ public function list(Request $request): Response [ 'method' => Request::METHOD_GET, 'csrf_protection' => false, - ] + ], ); $filter->handleRequest($request); @@ -136,7 +136,7 @@ public function list(Request $request): Response /** * View {@see JobExecution} details in a Twig template. */ - public function view(string $job, string $id, ?string $path = null): Response + public function view(string $job, string $id, null|string $path = null): Response { try { $execution = $this->jobExecutionStorage->retrieve($job, $id); @@ -192,7 +192,7 @@ public function logs(string $job, string $id): Response $response = new Response((string)$execution->getLogs()); $response->headers->set( 'Content-Disposition', - $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename) + $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename), ); $response->headers->set('Content-Type', 'application/log'); diff --git a/src/batch-symfony-framework/src/UserInterface/JobSecurity.php b/src/batch-symfony-framework/src/UserInterface/JobSecurity.php index 165c0ae0..14fc6b45 100644 --- a/src/batch-symfony-framework/src/UserInterface/JobSecurity.php +++ b/src/batch-symfony-framework/src/UserInterface/JobSecurity.php @@ -15,7 +15,7 @@ final class JobSecurity { public function __construct( - private ?AuthorizationCheckerInterface $authorizationChecker, + private null|AuthorizationCheckerInterface $authorizationChecker, private string $listAttribute, private string $viewAttribute, private string $tracesAttribute, diff --git a/src/batch-symfony-framework/tests/DependencyInjection/CompilerPass/ConfigureLauncherPassTest.php b/src/batch-symfony-framework/tests/DependencyInjection/CompilerPass/ConfigureLauncherPassTest.php index eb37d851..b2ad0efb 100644 --- a/src/batch-symfony-framework/tests/DependencyInjection/CompilerPass/ConfigureLauncherPassTest.php +++ b/src/batch-symfony-framework/tests/DependencyInjection/CompilerPass/ConfigureLauncherPassTest.php @@ -26,7 +26,7 @@ public function testNominal(): void public function testMissingService(): void { $this->expectExceptionObject( - new LogicException('Job launcher service "app.yokai_batch_job_launcher" does not exists.') + new LogicException('Job launcher service "app.yokai_batch_job_launcher" does not exists.'), ); $this->process(function (ContainerBuilder $container) { $container->setAlias(JobLauncherInterface::class, 'app.yokai_batch_job_launcher'); diff --git a/src/batch-symfony-framework/tests/DependencyInjection/CompilerPass/ConfigureTemplatingPassTest.php b/src/batch-symfony-framework/tests/DependencyInjection/CompilerPass/ConfigureTemplatingPassTest.php index 6c2cca1b..f100b798 100644 --- a/src/batch-symfony-framework/tests/DependencyInjection/CompilerPass/ConfigureTemplatingPassTest.php +++ b/src/batch-symfony-framework/tests/DependencyInjection/CompilerPass/ConfigureTemplatingPassTest.php @@ -26,7 +26,7 @@ public function testNominal(): void public function testMissingService(): void { $this->expectExceptionObject( - new LogicException('UI templating service "app.yokai_batch_templating" does not exists.') + new LogicException('UI templating service "app.yokai_batch_templating" does not exists.'), ); $this->process(function (ContainerBuilder $container) { $container->setAlias(TemplatingInterface::class, 'app.yokai_batch_templating'); diff --git a/src/batch-symfony-framework/tests/DependencyInjection/YokaiBatchExtensionTest.php b/src/batch-symfony-framework/tests/DependencyInjection/YokaiBatchExtensionTest.php index 53d3e22b..60466ad8 100644 --- a/src/batch-symfony-framework/tests/DependencyInjection/YokaiBatchExtensionTest.php +++ b/src/batch-symfony-framework/tests/DependencyInjection/YokaiBatchExtensionTest.php @@ -371,13 +371,13 @@ public function errors(): \Generator yield 'Per job parameters value must be an array' => [ ['parameters' => ['per_job' => ['job.foo' => 'string']]], new InvalidConfigurationException( - 'Invalid configuration for path "yokai_batch.parameters.per_job.job.foo": Should be an array.' + 'Invalid configuration for path "yokai_batch.parameters.per_job.job.foo": Should be an array.', ), ]; yield 'Per job parameters value must be a string indexed array' => [ ['parameters' => ['per_job' => ['job.foo' => [1, 2, 3]]]], new InvalidConfigurationException( - 'Invalid configuration for path "yokai_batch.parameters.per_job.job.foo": Should be an array.' + 'Invalid configuration for path "yokai_batch.parameters.per_job.job.foo": Should be an array.', ), ]; } diff --git a/src/batch-symfony-framework/tests/UserInterface/Controller/JobControllerTest.php b/src/batch-symfony-framework/tests/UserInterface/Controller/JobControllerTest.php index d0775f5e..0f32d1db 100644 --- a/src/batch-symfony-framework/tests/UserInterface/Controller/JobControllerTest.php +++ b/src/batch-symfony-framework/tests/UserInterface/Controller/JobControllerTest.php @@ -72,7 +72,7 @@ protected function setUp(): void public function testList( \Closure $fixtures, Request $request, - ?FormFactoryInterface $formFactory, + null|FormFactoryInterface $formFactory, JobSecurity $security, TemplatingInterface $templating, int $expectedStatus, @@ -197,7 +197,7 @@ public function testView( \Closure $fixtures, string $job, string $id, - ?string $path, + null|string $path, JobSecurity $security, TemplatingInterface $templating, int $expectedStatus, @@ -235,7 +235,7 @@ public static function view(): \Generator new Summary(['count' => 156]), ); $exportExecution->addWarning( - new Warning('Skipped suspicious record', [], ['suspicious_record' => 2]) + 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')); @@ -447,7 +447,7 @@ private static function templatings(): \Generator */ private function response( \Closure $closure, - ?FormFactoryInterface $formFactory, + null|FormFactoryInterface $formFactory, JobSecurity $security, TemplatingInterface $templating, ): Response { @@ -461,7 +461,7 @@ private function response( } private function controller( - ?FormFactoryInterface $formFactory, + null|FormFactoryInterface $formFactory, JobSecurity $security, TemplatingInterface $templating, ): JobController { @@ -519,7 +519,7 @@ private static function fixtures(int $count, array $attributes = []): void ])), 'startTime' => $start = (new \DateTimeImmutable())->setTimestamp(\random_int(0, \time() - 10)), 'endTime' => (new \DateTimeImmutable())->setTimestamp( - \random_int($start->getTimestamp(), \time() - 10) + \random_int($start->getTimestamp(), \time() - 10), ), ], $attributes, @@ -545,7 +545,7 @@ private static function assertSelectorTextContains(Crawler $crawler, string $sel { self::assertThat($crawler, LogicalAnd::fromConstraints( new DomCrawlerConstraint\CrawlerSelectorExists($selector), - new DomCrawlerConstraint\CrawlerSelectorTextContains($selector, $text) + new DomCrawlerConstraint\CrawlerSelectorTextContains($selector, $text), )); } diff --git a/src/batch-symfony-messenger/tests/DispatchMessageJobLauncherTest.php b/src/batch-symfony-messenger/tests/DispatchMessageJobLauncherTest.php index d6b9b2bd..91981789 100644 --- a/src/batch-symfony-messenger/tests/DispatchMessageJobLauncherTest.php +++ b/src/batch-symfony-messenger/tests/DispatchMessageJobLauncherTest.php @@ -24,7 +24,7 @@ public function testLaunch(): void $jobLauncher = new DispatchMessageJobLauncher( new JobExecutionFactory(new UniqidJobExecutionIdGenerator(), new NullJobExecutionParametersBuilder()), $storage = new InMemoryJobExecutionStorage(), - $messageBus = new BufferingMessageBus() + $messageBus = new BufferingMessageBus(), ); $jobExecutionFromLauncher = $jobLauncher->launch('testing', ['_id' => '123456789', 'foo' => ['bar']]); @@ -66,7 +66,7 @@ public function testLaunchAndMessengerFail(): void $jobLauncher = new DispatchMessageJobLauncher( new JobExecutionFactory(new UniqidJobExecutionIdGenerator(), new NullJobExecutionParametersBuilder()), $storage = new InMemoryJobExecutionStorage(), - new FailingMessageBus(new TransportException('This is a test')) + new FailingMessageBus(new TransportException('This is a test')), ); $jobExecutionFromLauncher = $jobLauncher->launch('testing'); diff --git a/src/batch-symfony-messenger/tests/LaunchJobMessageHandlerTest.php b/src/batch-symfony-messenger/tests/LaunchJobMessageHandlerTest.php index d9d591c4..bc401f97 100644 --- a/src/batch-symfony-messenger/tests/LaunchJobMessageHandlerTest.php +++ b/src/batch-symfony-messenger/tests/LaunchJobMessageHandlerTest.php @@ -24,7 +24,7 @@ final class LaunchJobMessageHandlerTest extends TestCase public function testInvoke(): void { - $job = new class() implements JobInterface { + $job = new class implements JobInterface { public JobExecution $execution; public function execute(JobExecution $jobExecution): void @@ -45,8 +45,8 @@ public function execute(JobExecution $jobExecution): void new JobExecutor( JobRegistry::fromJobArray(['foo' => $job]), $jobExecutionStorage, - null - ) + null, + ), ); $handler->__invoke(new LaunchJobMessage('foo', ['bar' => 'BAR'])); @@ -54,7 +54,7 @@ public function execute(JobExecution $jobExecution): void self::assertSame('123456', $job->execution->getId()); self::assertSame( ['bar' => 'BAR', '_id' => '123456'], - $job->execution->getParameters()->all() + $job->execution->getParameters()->all(), ); } } diff --git a/src/batch-symfony-serializer/src/DenormalizeItemProcessor.php b/src/batch-symfony-serializer/src/DenormalizeItemProcessor.php index 1a03a28a..ae21a352 100644 --- a/src/batch-symfony-serializer/src/DenormalizeItemProcessor.php +++ b/src/batch-symfony-serializer/src/DenormalizeItemProcessor.php @@ -18,7 +18,7 @@ final class DenormalizeItemProcessor implements ItemProcessorInterface public function __construct( private DenormalizerInterface $denormalizer, private string $type, - private ?string $format = null, + private null|string $format = null, /** * @var array */ @@ -38,7 +38,7 @@ public function process(mixed $item): mixed throw SkipItemException::onError( $item, $exception, - ['format' => $this->format, 'context' => $this->context] + ['format' => $this->format, 'context' => $this->context], ); } diff --git a/src/batch-symfony-serializer/src/NormalizeItemProcessor.php b/src/batch-symfony-serializer/src/NormalizeItemProcessor.php index 94dc2d1b..caae45c7 100644 --- a/src/batch-symfony-serializer/src/NormalizeItemProcessor.php +++ b/src/batch-symfony-serializer/src/NormalizeItemProcessor.php @@ -17,7 +17,7 @@ final class NormalizeItemProcessor implements ItemProcessorInterface { public function __construct( private NormalizerInterface $normalizer, - private ?string $format = null, + private null|string $format = null, /** * @var array */ @@ -37,7 +37,7 @@ public function process(mixed $item): mixed throw SkipItemException::onError( $item, $exception, - ['format' => $this->format, 'context' => $this->context] + ['format' => $this->format, 'context' => $this->context], ); } } diff --git a/src/batch-symfony-serializer/tests/DenormalizeItemProcessorTest.php b/src/batch-symfony-serializer/tests/DenormalizeItemProcessorTest.php index 82f4ee8a..cee0a5c6 100644 --- a/src/batch-symfony-serializer/tests/DenormalizeItemProcessorTest.php +++ b/src/batch-symfony-serializer/tests/DenormalizeItemProcessorTest.php @@ -20,7 +20,7 @@ final class DenormalizeItemProcessorTest extends TestCase /** * @dataProvider sets */ - public function testProcess(string $type, ?string $format, array $context, $item, $expected): void + public function testProcess(string $type, null|string $format, array $context, $item, $expected): void { $denormalizer = new DummyNormalizer(true, $expected); $processor = new DenormalizeItemProcessor($denormalizer, $type, $format, $context); @@ -31,12 +31,13 @@ public function testProcess(string $type, ?string $format, array $context, $item /** * @dataProvider sets */ - public function testUnsupported(string $type, ?string $format, array $context, $item): void + public function testUnsupported(string $type, null|string $format, array $context, $item): void { $denormalizer = new DummyNormalizer(false, null); $processor = new DenormalizeItemProcessor($denormalizer, $type, $format, $context); $exception = null; + try { $processor->process($item); } catch (SkipItemException $exception) { @@ -53,12 +54,13 @@ public function testUnsupported(string $type, ?string $format, array $context, $ /** * @dataProvider sets */ - public function testException(string $type, ?string $format, array $context, $item): void + public function testException(string $type, null|string $format, array $context, $item): void { $denormalizer = new FailingNormalizer($exceptionThrown = new UnsupportedException()); $processor = new DenormalizeItemProcessor($denormalizer, $type, $format, $context); $exception = null; + try { $processor->process($item); } catch (SkipItemException $exception) { diff --git a/src/batch-symfony-serializer/tests/Dummy/DummyNormalizer.php b/src/batch-symfony-serializer/tests/Dummy/DummyNormalizer.php index 6d91935f..df98f155 100644 --- a/src/batch-symfony-serializer/tests/Dummy/DummyNormalizer.php +++ b/src/batch-symfony-serializer/tests/Dummy/DummyNormalizer.php @@ -23,7 +23,7 @@ public function supportsNormalization(mixed $data, string $format = null, array public function normalize( mixed $object, string $format = null, - array $context = [] + array $context = [], ): array|string|int|float|bool|\ArrayObject|null { return $this->value; } @@ -38,7 +38,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar return $this->value; } - public function getSupportedTypes(?string $format): array + public function getSupportedTypes(null|string $format): array { return ['*' => true]; } diff --git a/src/batch-symfony-serializer/tests/Dummy/FailingNormalizer.php b/src/batch-symfony-serializer/tests/Dummy/FailingNormalizer.php index 231711a7..245ce5a8 100644 --- a/src/batch-symfony-serializer/tests/Dummy/FailingNormalizer.php +++ b/src/batch-symfony-serializer/tests/Dummy/FailingNormalizer.php @@ -23,7 +23,7 @@ public function supportsNormalization(mixed $data, string $format = null, array public function normalize( mixed $object, string $format = null, - array $context = [] + array $context = [], ): array|string|int|float|bool|\ArrayObject|null { throw $this->exception; } @@ -38,7 +38,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar throw $this->exception; } - public function getSupportedTypes(?string $format): array + public function getSupportedTypes(null|string $format): array { return ['*' => true]; } diff --git a/src/batch-symfony-serializer/tests/NormalizeItemProcessorTest.php b/src/batch-symfony-serializer/tests/NormalizeItemProcessorTest.php index 3050ed1e..dc29579e 100644 --- a/src/batch-symfony-serializer/tests/NormalizeItemProcessorTest.php +++ b/src/batch-symfony-serializer/tests/NormalizeItemProcessorTest.php @@ -20,7 +20,7 @@ final class NormalizeItemProcessorTest extends TestCase /** * @dataProvider sets */ - public function testProcess(?string $format, array $context, $item, $expected): void + public function testProcess(null|string $format, array $context, $item, $expected): void { $normalizer = new DummyNormalizer(true, $expected); $processor = new NormalizeItemProcessor($normalizer, $format, $context); @@ -31,12 +31,13 @@ public function testProcess(?string $format, array $context, $item, $expected): /** * @dataProvider sets */ - public function testUnsupported(?string $format, array $context, $item): void + public function testUnsupported(null|string $format, array $context, $item): void { $normalizer = new DummyNormalizer(false, null); $processor = new NormalizeItemProcessor($normalizer, $format, $context); $exception = null; + try { $processor->process($item); } catch (SkipItemException $exception) { @@ -53,12 +54,13 @@ public function testUnsupported(?string $format, array $context, $item): void /** * @dataProvider sets */ - public function testException(?string $format, array $context, $item): void + public function testException(null|string $format, array $context, $item): void { $normalizer = new FailingNormalizer($exceptionThrown = new BadMethodCallException()); $processor = new NormalizeItemProcessor($normalizer, $format, $context); $exception = null; + try { $processor->process($item); } catch (SkipItemException $exception) { diff --git a/src/batch-symfony-validator/src/SkipInvalidItemProcessor.php b/src/batch-symfony-validator/src/SkipInvalidItemProcessor.php index d6105380..6ed3b744 100644 --- a/src/batch-symfony-validator/src/SkipInvalidItemProcessor.php +++ b/src/batch-symfony-validator/src/SkipInvalidItemProcessor.php @@ -21,11 +21,11 @@ public function __construct( /** * @var Constraint[]|null */ - private ?array $contraints = null, + private null|array $contraints = null, /** * @var string[]|null */ - private ?array $groups = null, + private null|array $groups = null, ) { } @@ -47,7 +47,7 @@ public function process(mixed $item): mixed * * @return Iterator */ - private function normalizeConstraints(?array $constraints): Iterator + private function normalizeConstraints(null|array $constraints): Iterator { foreach ($constraints ?? [] as $constraint) { yield $constraint::class; diff --git a/src/batch-symfony-validator/src/SkipItemOnViolations.php b/src/batch-symfony-validator/src/SkipItemOnViolations.php index 6643a4cb..99e7f0a6 100644 --- a/src/batch-symfony-validator/src/SkipItemOnViolations.php +++ b/src/batch-symfony-validator/src/SkipItemOnViolations.php @@ -20,7 +20,7 @@ public function __construct( /** * @var ConstraintViolationListInterface */ - private ConstraintViolationListInterface $violations + private ConstraintViolationListInterface $violations, ) { } @@ -34,7 +34,7 @@ public function report(JobExecution $execution, int|string $index, mixed $item): '%s: %s (invalid value: %s)', $violation->getPropertyPath(), $violation->getMessage(), - $this->normalizeInvalidValue($violation->getInvalidValue()) + $this->normalizeInvalidValue($violation->getInvalidValue()), ); } @@ -42,8 +42,8 @@ public function report(JobExecution $execution, int|string $index, mixed $item): new Warning( 'Violations were detected by validator.', [], - ['itemIndex' => $index, 'item' => $item, 'violations' => $violations] - ) + ['itemIndex' => $index, 'item' => $item, 'violations' => $violations], + ), ); } diff --git a/src/batch-symfony-validator/tests/SkipInvalidItemProcessorTest.php b/src/batch-symfony-validator/tests/SkipInvalidItemProcessorTest.php index 850f6e68..462c030c 100644 --- a/src/batch-symfony-validator/tests/SkipInvalidItemProcessorTest.php +++ b/src/batch-symfony-validator/tests/SkipInvalidItemProcessorTest.php @@ -19,7 +19,7 @@ class SkipInvalidItemProcessorTest extends TestCase /** * @dataProvider groups */ - public function testProcessValid(?array $groups): void + public function testProcessValid(null|array $groups): void { $validator = Validation::createValidator(); $processor = new SkipInvalidItemProcessor($validator, [new NotBlank(['groups' => $groups])], $groups); @@ -29,12 +29,13 @@ public function testProcessValid(?array $groups): void /** * @dataProvider groups */ - public function testProcessInvalid(?array $groups): void + public function testProcessInvalid(null|array $groups): void { $validator = Validation::createValidator(); $processor = new SkipInvalidItemProcessor($validator, [new Blank(['groups' => ['Default', 'Full']])], $groups); $exception = null; + try { $processor->process('invalid item not blank'); } catch (SkipItemException $exception) { diff --git a/src/batch-symfony-validator/tests/SkipItemOnViolationsTest.php b/src/batch-symfony-validator/tests/SkipItemOnViolationsTest.php index 07a206f1..782c4067 100644 --- a/src/batch-symfony-validator/tests/SkipItemOnViolationsTest.php +++ b/src/batch-symfony-validator/tests/SkipItemOnViolationsTest.php @@ -30,7 +30,7 @@ public function test(array $violations, array $expectedViolations): void self::assertSame([], $execution->getWarnings()[0]->getParameters()); self::assertSame( ['itemIndex' => 'itemIndex', 'item' => 'item', 'violations' => $expectedViolations], - $execution->getWarnings()[0]->getContext() + $execution->getWarnings()[0]->getContext(), ); } diff --git a/src/batch/src/Exception/BadMethodCallException.php b/src/batch/src/Exception/BadMethodCallException.php index c28c6122..6caf54e5 100644 --- a/src/batch/src/Exception/BadMethodCallException.php +++ b/src/batch/src/Exception/BadMethodCallException.php @@ -20,8 +20,8 @@ public static function itemComponentNotInitialized(InitializableInterface $compo \sprintf( '%s component should have been initialized. Call %s::initialize().', $component::class, - $component::class - ) + $component::class, + ), ); } } diff --git a/src/batch/src/Exception/CannotRemoveJobExecutionException.php b/src/batch/src/Exception/CannotRemoveJobExecutionException.php index 36e8e860..90fdd501 100644 --- a/src/batch/src/Exception/CannotRemoveJobExecutionException.php +++ b/src/batch/src/Exception/CannotRemoveJobExecutionException.php @@ -12,7 +12,7 @@ public function __construct(string $jobName, string $executionId, Throwable $pre { parent::__construct( \sprintf('Cannot remove job execution "%s" of job "%s"', $executionId, $jobName), - $previous + $previous, ); } } diff --git a/src/batch/src/Exception/CannotStoreJobExecutionException.php b/src/batch/src/Exception/CannotStoreJobExecutionException.php index 434336ce..496101c4 100644 --- a/src/batch/src/Exception/CannotStoreJobExecutionException.php +++ b/src/batch/src/Exception/CannotStoreJobExecutionException.php @@ -12,7 +12,7 @@ public function __construct(string $jobName, string $executionId, Throwable $pre { parent::__construct( \sprintf('Cannot store job execution "%s" of job "%s"', $executionId, $jobName), - $previous + $previous, ); } } diff --git a/src/batch/src/Exception/ImmutablePropertyException.php b/src/batch/src/Exception/ImmutablePropertyException.php index a42d92c8..33998d30 100644 --- a/src/batch/src/Exception/ImmutablePropertyException.php +++ b/src/batch/src/Exception/ImmutablePropertyException.php @@ -9,7 +9,7 @@ class ImmutablePropertyException extends LogicException public function __construct(string $class, string $property) { parent::__construct( - \sprintf('%s:%s property is immutable and therefor cannot be modified.', $class, $property) + \sprintf('%s:%s property is immutable and therefor cannot be modified.', $class, $property), ); } } diff --git a/src/batch/src/Exception/JobExecutionNotFoundException.php b/src/batch/src/Exception/JobExecutionNotFoundException.php index 1282cdac..312fe07c 100644 --- a/src/batch/src/Exception/JobExecutionNotFoundException.php +++ b/src/batch/src/Exception/JobExecutionNotFoundException.php @@ -13,7 +13,7 @@ public function __construct(string $jobName, string $executionId, Throwable $pre parent::__construct( \sprintf('Job execution "%s" of job "%s" cannot be found', $executionId, $jobName), 0, - $previous + $previous, ); } } diff --git a/src/batch/src/Exception/UnexpectedValueException.php b/src/batch/src/Exception/UnexpectedValueException.php index 02306dd0..4803f8f8 100644 --- a/src/batch/src/Exception/UnexpectedValueException.php +++ b/src/batch/src/Exception/UnexpectedValueException.php @@ -17,7 +17,7 @@ public static function type(string $expected, mixed $argument, string $message = { return new self( $message, - \sprintf('Expecting argument to be %s, but got %s.', $expected, \get_debug_type($argument)) + \sprintf('Expecting argument to be %s, but got %s.', $expected, \get_debug_type($argument)), ); } @@ -31,8 +31,8 @@ public static function enum(array $expected, mixed $argument, string $message = \sprintf( 'Expecting argument to be one of "%s", but got %s.', \implode('", "', $expected), - \is_scalar($argument) ? $argument : \get_debug_type($argument) - ) + \is_scalar($argument) ? $argument : \get_debug_type($argument), + ), ); } @@ -48,8 +48,8 @@ public static function date(string $expected, mixed $argument, string $message = \sprintf( 'Expecting a date with format "%s". Got "%s"', $expected, - \is_scalar($argument) ? $argument : \get_debug_type($argument) - ) + \is_scalar($argument) ? $argument : \get_debug_type($argument), + ), ); } } diff --git a/src/batch/src/Failure.php b/src/batch/src/Failure.php index 2d74703a..fa450e41 100644 --- a/src/batch/src/Failure.php +++ b/src/batch/src/Failure.php @@ -33,7 +33,7 @@ public function __construct( /** * The exception trace {@see Throwable::getTraceAsString} */ - private ?string $trace = null, + private string|null $trace = null, ) { } @@ -49,7 +49,7 @@ public static function fromException(Throwable $exception, array $parameters = [ $exception->getMessage(), $exception->getCode(), $parameters, - self::buildTrace($exception) + self::buildTrace($exception), ); } @@ -81,7 +81,7 @@ public function getParameters(): array return $this->parameters; } - public function getTrace(): ?string + public function getTrace(): string|null { return $this->trace; } diff --git a/src/batch/src/Job/Item/Exception/SkipItemException.php b/src/batch/src/Job/Item/Exception/SkipItemException.php index 8fda8ed2..efa462a7 100644 --- a/src/batch/src/Job/Item/Exception/SkipItemException.php +++ b/src/batch/src/Job/Item/Exception/SkipItemException.php @@ -18,7 +18,7 @@ final class SkipItemException extends RuntimeException { public function __construct( private mixed $item, - private ?SkipItemCauseInterface $cause, + private SkipItemCauseInterface|null $cause, /** * @var array */ @@ -69,7 +69,7 @@ public function getItem(): mixed * The cause of the exception. * Will be used by {@see ItemJob} to leave a trace in {@see JobExecution}. */ - public function getCause(): ?SkipItemCauseInterface + public function getCause(): SkipItemCauseInterface|null { return $this->cause; } diff --git a/src/batch/src/Job/Item/Exception/SkipItemOnError.php b/src/batch/src/Job/Item/Exception/SkipItemOnError.php index ee642149..6dca9802 100644 --- a/src/batch/src/Job/Item/Exception/SkipItemOnError.php +++ b/src/batch/src/Job/Item/Exception/SkipItemOnError.php @@ -32,8 +32,8 @@ public function report(JobExecution $execution, int|string $index, mixed $item): 'message' => $this->error->getMessage(), 'code' => $this->error->getCode(), 'trace' => $this->error->getTraceAsString(), - ] - ) + ], + ), ); } diff --git a/src/batch/src/Job/Item/ItemJob.php b/src/batch/src/Job/Item/ItemJob.php index e7c61339..70991131 100644 --- a/src/batch/src/Job/Item/ItemJob.php +++ b/src/batch/src/Job/Item/ItemJob.php @@ -60,7 +60,7 @@ final public function execute(JobExecution $jobExecution): void $summary->increment('skipped'); $logger->debug( \sprintf('Skipping item %s.', $readIndex), - $exception->getContext() + ['item' => $exception->getItem()] + $exception->getContext() + ['item' => $exception->getItem()], ); $cause = $exception->getCause(); diff --git a/src/batch/src/Job/Item/Writer/LaunchJobForEachItemWriter.php b/src/batch/src/Job/Item/Writer/LaunchJobForEachItemWriter.php index 1b4cf076..dac8eb30 100644 --- a/src/batch/src/Job/Item/Writer/LaunchJobForEachItemWriter.php +++ b/src/batch/src/Job/Item/Writer/LaunchJobForEachItemWriter.php @@ -36,7 +36,7 @@ public function write(iterable $items): void $execution = $this->launcher->launch($this->jobName, $parameters); $this->jobExecution->getLogger()->notice( 'Triggered job for item.', - ['jobName' => $execution->getJobName(), 'executionId' => $execution->getId()] + ['jobName' => $execution->getJobName(), 'executionId' => $execution->getId()], ); } } diff --git a/src/batch/src/Job/Item/Writer/LaunchJobForItemsBatchWriter.php b/src/batch/src/Job/Item/Writer/LaunchJobForItemsBatchWriter.php index 7b8b296c..7e3c981f 100644 --- a/src/batch/src/Job/Item/Writer/LaunchJobForItemsBatchWriter.php +++ b/src/batch/src/Job/Item/Writer/LaunchJobForItemsBatchWriter.php @@ -35,7 +35,7 @@ public function write(iterable $items): void $execution = $this->launcher->launch($this->jobName, $parameters); $this->jobExecution->getLogger()->notice( 'Triggered job for items batch.', - ['jobName' => $execution->getJobName(), 'executionId' => $execution->getId()] + ['jobName' => $execution->getJobName(), 'executionId' => $execution->getId()], ); } } diff --git a/src/batch/src/Job/Item/Writer/TransformingWriter.php b/src/batch/src/Job/Item/Writer/TransformingWriter.php index 1b56c7a5..a11758f3 100644 --- a/src/batch/src/Job/Item/Writer/TransformingWriter.php +++ b/src/batch/src/Job/Item/Writer/TransformingWriter.php @@ -48,7 +48,7 @@ public function write(iterable $items): void } catch (SkipItemException $exception) { $this->jobExecution->getLogger()->debug( \sprintf('Skipping item in writer transformation %s.', $index), - $exception->getContext() + ['item' => $exception->getItem()] + $exception->getContext() + ['item' => $exception->getItem()], ); $cause = $exception->getCause(); diff --git a/src/batch/src/Job/JobExecutor.php b/src/batch/src/Job/JobExecutor.php index 5c67e82a..33639e28 100644 --- a/src/batch/src/Job/JobExecutor.php +++ b/src/batch/src/Job/JobExecutor.php @@ -29,7 +29,7 @@ final class JobExecutor public function __construct( private JobRegistry $jobRegistry, private JobExecutionStorageInterface $jobExecutionStorage, - private ?EventDispatcherInterface $eventDispatcher, + private EventDispatcherInterface|null $eventDispatcher, ) { } diff --git a/src/batch/src/Job/Parameters/ChainParameterAccessor.php b/src/batch/src/Job/Parameters/ChainParameterAccessor.php index ffff612d..e53f2550 100644 --- a/src/batch/src/Job/Parameters/ChainParameterAccessor.php +++ b/src/batch/src/Job/Parameters/ChainParameterAccessor.php @@ -37,8 +37,8 @@ public function get(JobExecution $execution): mixed \sprintf( 'Cannot access parameter, tried using %d accessor(s), all failed : "%s".', \count($tries), - \implode('". "', $tries) - ) + \implode('". "', $tries), + ), ); } } diff --git a/src/batch/src/Job/Parameters/ClosestJobExecutionAccessor.php b/src/batch/src/Job/Parameters/ClosestJobExecutionAccessor.php index ce051999..f31739d1 100644 --- a/src/batch/src/Job/Parameters/ClosestJobExecutionAccessor.php +++ b/src/batch/src/Job/Parameters/ClosestJobExecutionAccessor.php @@ -14,7 +14,7 @@ final class ClosestJobExecutionAccessor implements JobParameterAccessorInterface { public function __construct( - private JobParameterAccessorInterface $accessor + private JobParameterAccessorInterface $accessor, ) { } diff --git a/src/batch/src/Job/Parameters/JobExecutionParameterAccessor.php b/src/batch/src/Job/Parameters/JobExecutionParameterAccessor.php index 935d5cec..ccbc11da 100644 --- a/src/batch/src/Job/Parameters/JobExecutionParameterAccessor.php +++ b/src/batch/src/Job/Parameters/JobExecutionParameterAccessor.php @@ -26,7 +26,7 @@ public function get(JobExecution $execution): mixed } catch (UndefinedJobParameterException $exception) { throw new CannotAccessParameterException( \sprintf('Cannot access "%s" parameter from job execution.', $this->name), - $exception + $exception, ); } } diff --git a/src/batch/src/Job/Parameters/JobExecutionSummaryAccessor.php b/src/batch/src/Job/Parameters/JobExecutionSummaryAccessor.php index fc4d7661..63bf7e40 100644 --- a/src/batch/src/Job/Parameters/JobExecutionSummaryAccessor.php +++ b/src/batch/src/Job/Parameters/JobExecutionSummaryAccessor.php @@ -22,7 +22,7 @@ public function get(JobExecution $execution): mixed { if (!$execution->getSummary()->has($this->name)) { throw new CannotAccessParameterException( - \sprintf('Cannot access parameter, summary variable "%s" does not exists.', $this->name) + \sprintf('Cannot access parameter, summary variable "%s" does not exists.', $this->name), ); } diff --git a/src/batch/src/Job/Parameters/ReplaceWithVariablesParameterAccessor.php b/src/batch/src/Job/Parameters/ReplaceWithVariablesParameterAccessor.php index 9aaa368c..15d023c8 100644 --- a/src/batch/src/Job/Parameters/ReplaceWithVariablesParameterAccessor.php +++ b/src/batch/src/Job/Parameters/ReplaceWithVariablesParameterAccessor.php @@ -18,7 +18,7 @@ public function __construct( /** * @var array */ - private array $variables = [] + private array $variables = [], ) { } diff --git a/src/batch/src/Job/Parameters/SiblingJobExecutionAccessor.php b/src/batch/src/Job/Parameters/SiblingJobExecutionAccessor.php index a73552be..9da4fc28 100644 --- a/src/batch/src/Job/Parameters/SiblingJobExecutionAccessor.php +++ b/src/batch/src/Job/Parameters/SiblingJobExecutionAccessor.php @@ -28,7 +28,7 @@ public function get(JobExecution $execution): mixed $sibling = $parent->getChildExecution($this->sibling); if ($sibling === null) { throw new CannotAccessParameterException( - \sprintf('Cannot access parameter, job execution has no sibling named "%s".', $this->sibling) + \sprintf('Cannot access parameter, job execution has no sibling named "%s".', $this->sibling), ); } diff --git a/src/batch/src/JobExecution.php b/src/batch/src/JobExecution.php index 8c10890c..e21536d9 100644 --- a/src/batch/src/JobExecution.php +++ b/src/batch/src/JobExecution.php @@ -42,13 +42,13 @@ final class JobExecution * The date and time when the job started. * If null, the job is not started yet. */ - private ?DateTimeInterface $startTime = null; + private DateTimeInterface|null $startTime = null; /** * The date and time when the job finished. * If null, the job is not finished yet. */ - private ?DateTimeInterface $endTime = null; + private DateTimeInterface|null $endTime = null; /** * List of failures that occurred in the execution. @@ -77,7 +77,7 @@ final class JobExecution * Most of the time null, filled whenever using a {@see JobWithChildJobs}. * Inverse side of {@see JobExecution::$childExecutions} */ - private ?JobExecution $parentExecution; + private JobExecution|null $parentExecution; /** * The children executions. @@ -100,13 +100,13 @@ final class JobExecution private LoggerInterface $logger; private function __construct( - ?JobExecution $parentExecution, + JobExecution|null $parentExecution, string $id, string $jobName, - ?BatchStatus $status, - ?JobParameters $parameters, - ?Summary $summary, - ?JobExecutionLogs $logs + BatchStatus|null $status, + JobParameters|null $parameters, + Summary|null $summary, + JobExecutionLogs|null $logs, ) { $this->parentExecution = $parentExecution; $this->id = $id; @@ -127,7 +127,7 @@ public static function createRoot( BatchStatus $status = null, JobParameters $parameters = null, Summary $summary = null, - JobExecutionLogs $logs = null + JobExecutionLogs $logs = null, ): self { return new self(null, $id, $jobName, $status, $parameters, $summary, $logs); } @@ -140,7 +140,7 @@ public static function createChild( string $jobName, BatchStatus $status = null, JobParameters $parameters = null, - Summary $summary = null + Summary $summary = null, ): self { return new self($parent, $parent->getId(), $jobName, $status, $parameters, $summary, null); } @@ -167,12 +167,12 @@ public function setStatus(int $status): void } } - public function getStartTime(): ?DateTimeInterface + public function getStartTime(): DateTimeInterface|null { return $this->startTime; } - public function getEndTime(): ?DateTimeInterface + public function getEndTime(): DateTimeInterface|null { return $this->endTime; } @@ -193,7 +193,7 @@ public function getDuration(): DateInterval /** * @throws ImmutablePropertyException If {@see JobExecution::$startTime} is not null. */ - public function setStartTime(?DateTimeInterface $startTime): void + public function setStartTime(DateTimeInterface|null $startTime): void { if ($this->startTime !== null) { throw new ImmutablePropertyException(self::class, 'startTime'); @@ -205,7 +205,7 @@ public function setStartTime(?DateTimeInterface $startTime): void /** * @throws ImmutablePropertyException If {@see JobExecution::$endTime} is not null. */ - public function setEndTime(?DateTimeInterface $endTime): void + public function setEndTime(DateTimeInterface|null $endTime): void { if ($this->endTime !== null) { throw new ImmutablePropertyException(self::class, 'endTime'); @@ -227,7 +227,7 @@ public function createChildExecution(string $childName): JobExecution return self::createChild($this, $childName); } - public function getParentExecution(): ?JobExecution + public function getParentExecution(): JobExecution|null { return $this->parentExecution; } @@ -265,7 +265,7 @@ public function addChildExecution(JobExecution $execution): void * Get a child execution for which the job name is $childName. * Returns null if that execution does not exist. */ - public function getChildExecution(string $childName): ?JobExecution + public function getChildExecution(string $childName): JobExecution|null { return $this->childExecutions[$childName] ?? null; } diff --git a/src/batch/src/JobExecutionLogger.php b/src/batch/src/JobExecutionLogger.php index df8f3974..e2a48001 100644 --- a/src/batch/src/JobExecutionLogger.php +++ b/src/batch/src/JobExecutionLogger.php @@ -29,7 +29,7 @@ final class JobExecutionLogger extends AbstractLogger /** * Current timezone used for date formatting. */ - private static ?DateTimeZone $timezone = null; + private static DateTimeZone|null $timezone = null; public function __construct( /** @@ -52,8 +52,8 @@ public function log($level, $message, array $context = []): void $this->date(), self::LEVELS[$level] ?? '', $message, - \json_encode($context, JSON_THROW_ON_ERROR) - ) + \json_encode($context, JSON_THROW_ON_ERROR), + ), ); } diff --git a/src/batch/src/Logger/BatchLogger.php b/src/batch/src/Logger/BatchLogger.php index 474f0559..42275556 100644 --- a/src/batch/src/Logger/BatchLogger.php +++ b/src/batch/src/Logger/BatchLogger.php @@ -17,7 +17,7 @@ */ class BatchLogger extends AbstractLogger { - private ?LoggerInterface $batchLogger = null; + private LoggerInterface|null $batchLogger = null; /** * Access and remember the logger diff --git a/src/batch/src/Registry/JobContainer.php b/src/batch/src/Registry/JobContainer.php index 672f8838..c39a16fa 100644 --- a/src/batch/src/Registry/JobContainer.php +++ b/src/batch/src/Registry/JobContainer.php @@ -30,6 +30,7 @@ public function get(string $id): JobInterface { if (!isset($this->jobs[$id])) { $message = \sprintf('You have requested a non-existent job "%s".', $id); + throw new class($message) extends Exception implements NotFoundExceptionInterface { }; } diff --git a/src/batch/src/Serializer/JsonJobExecutionSerializer.php b/src/batch/src/Serializer/JsonJobExecutionSerializer.php index c568db51..80e2f2a9 100644 --- a/src/batch/src/Serializer/JsonJobExecutionSerializer.php +++ b/src/batch/src/Serializer/JsonJobExecutionSerializer.php @@ -101,7 +101,7 @@ private function fromArray(array $jobExecutionData, JobExecution $parentExecutio $status, $parameters, $summary, - new JobExecutionLogs($jobExecutionData['logs'] ?? '') + new JobExecutionLogs($jobExecutionData['logs'] ?? ''), ); } @@ -122,7 +122,7 @@ private function fromArray(array $jobExecutionData, JobExecution $parentExecutio return $jobExecution; } - private function dateToString(?DateTimeInterface $date): ?string + private function dateToString(DateTimeInterface|null $date): string|null { if ($date === null) { return null; @@ -131,7 +131,7 @@ private function dateToString(?DateTimeInterface $date): ?string return $date->format(DateTimeInterface::ISO8601); } - private function stringToDate(?string $date): ?DateTimeInterface + private function stringToDate(string|null $date): DateTimeInterface|null { if ($date === null) { return null; @@ -169,7 +169,7 @@ private function failureFromArray(array $array): Failure $array['message'], $array['code'], $array['parameters'], - $array['trace'] + $array['trace'], ); } diff --git a/src/batch/src/Storage/FilesystemJobExecutionStorage.php b/src/batch/src/Storage/FilesystemJobExecutionStorage.php index b16690ec..d14c6a63 100644 --- a/src/batch/src/Storage/FilesystemJobExecutionStorage.php +++ b/src/batch/src/Storage/FilesystemJobExecutionStorage.php @@ -87,7 +87,7 @@ public function query(Query $query): iterable { $candidates = []; $glob = new \GlobIterator( - \implode(DIRECTORY_SEPARATOR, [$this->directory, '**', '*']) . '.' . $this->serializer->extension() + \implode(DIRECTORY_SEPARATOR, [$this->directory, '**', '*']) . '.' . $this->serializer->extension(), ); /** @var \SplFileInfo $file */ foreach ($glob as $file) { diff --git a/src/batch/src/Storage/Query.php b/src/batch/src/Storage/Query.php index f022c3aa..a14dfd4d 100644 --- a/src/batch/src/Storage/Query.php +++ b/src/batch/src/Storage/Query.php @@ -33,9 +33,9 @@ public function __construct( * @var int[] */ private array $statuses, - private ?TimeFilter $startTime, - private ?TimeFilter $endTime, - private ?string $sort, + private TimeFilter|null $startTime, + private TimeFilter|null $endTime, + private string|null $sort, private int $limit, private int $offset, ) { @@ -65,17 +65,17 @@ public function statuses(): array return $this->statuses; } - public function startTime(): ?TimeFilter + public function startTime(): TimeFilter|null { return $this->startTime; } - public function endTime(): ?TimeFilter + public function endTime(): TimeFilter|null { return $this->endTime; } - public function sort(): ?string + public function sort(): string|null { return $this->sort; } diff --git a/src/batch/src/Storage/QueryBuilder.php b/src/batch/src/Storage/QueryBuilder.php index 35e70c75..146b54f9 100644 --- a/src/batch/src/Storage/QueryBuilder.php +++ b/src/batch/src/Storage/QueryBuilder.php @@ -68,11 +68,11 @@ final class QueryBuilder */ private array $statuses = []; - private ?TimeFilter $startTime = null; + private TimeFilter|null $startTime = null; - private ?TimeFilter $endTime = null; + private TimeFilter|null $endTime = null; - private ?string $sortBy = null; + private string|null $sortBy = null; private int $limit = 10; @@ -143,7 +143,7 @@ public function statuses(array $statuses): self * @param DateTimeInterface|null $from Beginning of the time frame * @param DateTimeInterface|null $to End of the time frame */ - public function startTime(?DateTimeInterface $from, ?DateTimeInterface $to): self + public function startTime(DateTimeInterface|null $from, DateTimeInterface|null $to): self { if ($from === null && $to === null) { $this->startTime = null; @@ -162,7 +162,7 @@ public function startTime(?DateTimeInterface $from, ?DateTimeInterface $to): sel * @param DateTimeInterface|null $from Beginning of the time frame * @param DateTimeInterface|null $to End of the time frame */ - public function endTime(?DateTimeInterface $from, ?DateTimeInterface $to): self + public function endTime(DateTimeInterface|null $from, DateTimeInterface|null $to): self { if ($from === null && $to === null) { $this->endTime = null; @@ -220,7 +220,7 @@ public function getQuery(): Query $this->endTime, $this->sortBy, $this->limit, - $this->offset + $this->offset, ); } } diff --git a/src/batch/src/Storage/TimeFilter.php b/src/batch/src/Storage/TimeFilter.php index ca617ea0..2b79de10 100644 --- a/src/batch/src/Storage/TimeFilter.php +++ b/src/batch/src/Storage/TimeFilter.php @@ -13,20 +13,20 @@ final class TimeFilter { public function __construct( - private ?DateTimeInterface $from, - private ?DateTimeInterface $to, + private DateTimeInterface|null $from, + private DateTimeInterface|null $to, ) { if ($from !== null && $to !== null && $from > $to) { throw new UnexpectedValueException('TimeFilter expect "from" boundary to be lower than "to" boundary.'); } } - public function getFrom(): ?DateTimeInterface + public function getFrom(): DateTimeInterface|null { return $this->from; } - public function getTo(): ?DateTimeInterface + public function getTo(): DateTimeInterface|null { return $this->to; } diff --git a/src/batch/src/Test/Job/Item/TestDebugComponent.php b/src/batch/src/Test/Job/Item/TestDebugComponent.php index 533b14b7..f878b094 100644 --- a/src/batch/src/Test/Job/Item/TestDebugComponent.php +++ b/src/batch/src/Test/Job/Item/TestDebugComponent.php @@ -126,7 +126,7 @@ public function assertWasNotUsed(bool $initialized = false, bool $flushed = fals Assert::assertSame( $initialized, $this->initialized, - 'Element was' . ($initialized ? ' not' : '') . ' initialized' + 'Element was' . ($initialized ? ' not' : '') . ' initialized', ); Assert::assertFalse($this->wasUsed(), 'Element was used'); Assert::assertSame($flushed, $this->flushed, 'Element was' . ($flushed ? ' not' : '') . ' flushed'); diff --git a/src/batch/src/Trigger/Scheduler/ScheduledJob.php b/src/batch/src/Trigger/Scheduler/ScheduledJob.php index 1902aee4..5de52948 100644 --- a/src/batch/src/Trigger/Scheduler/ScheduledJob.php +++ b/src/batch/src/Trigger/Scheduler/ScheduledJob.php @@ -15,7 +15,7 @@ public function __construct( * @var array */ private array $parameters = [], - private ?string $id = null, + private string|null $id = null, ) { } @@ -40,7 +40,7 @@ public function getParameters(): array /** * An optional job execution id for the job to trigger. */ - public function getId(): ?string + public function getId(): string|null { return $this->id; } diff --git a/src/batch/tests/Factory/JobExecutionFactoryTest.php b/src/batch/tests/Factory/JobExecutionFactoryTest.php index 75b2e9cd..3bb2616f 100644 --- a/src/batch/tests/Factory/JobExecutionFactoryTest.php +++ b/src/batch/tests/Factory/JobExecutionFactoryTest.php @@ -16,14 +16,14 @@ public function testCreate(): void { $executionFactory = new JobExecutionFactory( new UniqidJobExecutionIdGenerator(), - new NullJobExecutionParametersBuilder() + new NullJobExecutionParametersBuilder(), ); $executionWithoutConfig = $executionFactory->create('export'); self::assertSame('export', $executionWithoutConfig->getJobName()); self::assertSame( ['_id' => $executionWithoutConfig->getId()], - \iterator_to_array($executionWithoutConfig->getParameters()) + \iterator_to_array($executionWithoutConfig->getParameters()), ); $this->assertExecutionIsEmpty($executionWithoutConfig); @@ -32,7 +32,7 @@ public function testCreate(): void self::assertSame('idFromOutside', $executionWithId->getId()); self::assertSame( ['_id' => 'idFromOutside'], - \iterator_to_array($executionWithId->getParameters()) + \iterator_to_array($executionWithId->getParameters()), ); $this->assertExecutionIsEmpty($executionWithId); @@ -40,7 +40,7 @@ public function testCreate(): void self::assertSame('export', $executionWithConfig->getJobName()); self::assertSame( ['string' => 'foo', '_id' => $executionWithConfig->getId()], - \iterator_to_array($executionWithConfig->getParameters()) + \iterator_to_array($executionWithConfig->getParameters()), ); $this->assertExecutionIsEmpty($executionWithConfig); } diff --git a/src/batch/tests/FailureTest.php b/src/batch/tests/FailureTest.php index 54d166f1..de9609c6 100644 --- a/src/batch/tests/FailureTest.php +++ b/src/batch/tests/FailureTest.php @@ -22,7 +22,7 @@ public function test( string $message, array $trace, array $parameters, - string $string + string $string, ): void { /** @var Failure $failure */ $failure = $load(); @@ -41,7 +41,7 @@ public function failures(): Generator yield [ fn() => Failure::fromException( new LogicException('I will fail because of {var}'), - ['{var}' => 'test var'] + ['{var}' => 'test var'], ), 'LogicException', 0, @@ -54,7 +54,7 @@ public function failures(): Generator ]; yield [ fn() => Failure::fromException( - new RuntimeException('This is a test', 123, new LogicException('Previous exception')) + new RuntimeException('This is a test', 123, new LogicException('Previous exception')), ), 'RuntimeException', 123, diff --git a/src/batch/tests/Finder/CallbackFinderTest.php b/src/batch/tests/Finder/CallbackFinderTest.php index 4ae6a9f3..d0e76d4c 100644 --- a/src/batch/tests/Finder/CallbackFinderTest.php +++ b/src/batch/tests/Finder/CallbackFinderTest.php @@ -11,11 +11,11 @@ class CallbackFinderTest extends TestCase { public function test(): void { - $integers = new class() { + $integers = new class { }; - $numbers = new class() { + $numbers = new class { }; - $default = new class() { + $default = new class { }; $finder = new CallbackFinder([ [fn($subject) => \is_int($subject), $integers], diff --git a/src/batch/tests/Finder/ClassMapFinderTest.php b/src/batch/tests/Finder/ClassMapFinderTest.php index f4f0e52b..06fbffa3 100644 --- a/src/batch/tests/Finder/ClassMapFinderTest.php +++ b/src/batch/tests/Finder/ClassMapFinderTest.php @@ -17,11 +17,11 @@ class ClassMapFinderTest extends TestCase { public function test(): void { - $dates = new class() { + $dates = new class { }; - $exceptions = new class() { + $exceptions = new class { }; - $default = new class() { + $default = new class { }; $finder = new ClassMapFinder([DateTimeInterface::class => $dates, Throwable::class => $exceptions], $default); diff --git a/src/batch/tests/Job/Item/Exception/SkipItemOnErrorTest.php b/src/batch/tests/Job/Item/Exception/SkipItemOnErrorTest.php index 32376e3c..6b86fd86 100644 --- a/src/batch/tests/Job/Item/Exception/SkipItemOnErrorTest.php +++ b/src/batch/tests/Job/Item/Exception/SkipItemOnErrorTest.php @@ -36,7 +36,7 @@ public function test(Throwable $error): void 'code' => $error->getCode(), 'trace' => $error->getTraceAsString(), ], - $execution->getWarnings()[0]->getContext() + $execution->getWarnings()[0]->getContext(), ); } diff --git a/src/batch/tests/Job/Item/ItemJobTest.php b/src/batch/tests/Job/Item/ItemJobTest.php index 45066e4e..7154530b 100644 --- a/src/batch/tests/Job/Item/ItemJobTest.php +++ b/src/batch/tests/Job/Item/ItemJobTest.php @@ -24,7 +24,7 @@ class ItemJobTest extends TestCase public function testExecute(): void { $reader = new TestDebugReader( - new StaticIterableReader([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) + new StaticIterableReader([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]), ); $processor = new TestDebugProcessor( new CallbackProcessor(function ($item) { @@ -32,19 +32,19 @@ public function testExecute(): void throw SkipItemException::withWarning( $item, 'Item is greater than 9 got ' . $item, - ['context' => 'phpunit'] + ['context' => 'phpunit'], ); } return $item * 10; - }) + }), ); $debugWriter = new TestDebugWriter($writer = new InMemoryWriter()); $job = new ItemJob(4, $reader, $processor, $debugWriter, new NullJobExecutionStorage()); $job->execute( - $execution = JobExecution::createRoot('123456789', 'export') + $execution = JobExecution::createRoot('123456789', 'export'), ); self::assertSame([10, 20, 30, 40, 50, 60, 70, 80, 90], $writer->getItems()); @@ -87,7 +87,7 @@ public function testWithExpandItem(Closure $callback): void new StaticIterableReader(['eggplant', 'tomato', 'avocado']), new CallbackProcessor($callback), $writer = new InMemoryWriter(), - new NullJobExecutionStorage() + new NullJobExecutionStorage(), ); $job->execute($execution = JobExecution::createRoot('123456', 'testing')); @@ -101,7 +101,7 @@ public function testWithExpandItem(Closure $callback): void 'fruit:avocado', 'vegetable:avocado', ], - $writer->getItems() + $writer->getItems(), ); self::assertSame(3, $execution->getSummary()->get('read')); self::assertSame(3, $execution->getSummary()->get('processed')); diff --git a/src/batch/tests/Job/Item/Processor/ArrayMapProcessorTest.php b/src/batch/tests/Job/Item/Processor/ArrayMapProcessorTest.php index 64f64b9d..dfa0e7c6 100644 --- a/src/batch/tests/Job/Item/Processor/ArrayMapProcessorTest.php +++ b/src/batch/tests/Job/Item/Processor/ArrayMapProcessorTest.php @@ -15,11 +15,11 @@ public function test(): void $processor = new ArrayMapProcessor(fn($string) => \mb_strtoupper($string)); self::assertSame( ['firstName' => 'JOHN', 'lastName' => 'DOE'], - $processor->process(['firstName' => 'John', 'lastName' => 'Doe']) + $processor->process(['firstName' => 'John', 'lastName' => 'Doe']), ); self::assertSame( ['TOMATO', 'BANANA', 'EGGPLANT'], - $processor->process(['tomato', 'BaNaNa', 'Eggplant']) + $processor->process(['tomato', 'BaNaNa', 'Eggplant']), ); } diff --git a/src/batch/tests/Job/Item/Processor/ChainProcessorTest.php b/src/batch/tests/Job/Item/Processor/ChainProcessorTest.php index c29eb3dc..1abdacef 100644 --- a/src/batch/tests/Job/Item/Processor/ChainProcessorTest.php +++ b/src/batch/tests/Job/Item/Processor/ChainProcessorTest.php @@ -17,15 +17,15 @@ public function testProcess(): void $chain = [ // substract 1 new TestDebugProcessor( - new CallbackProcessor(fn(int $number) => $number - 1) + new CallbackProcessor(fn(int $number) => $number - 1), ), // multiply by 2 new TestDebugProcessor( - new CallbackProcessor(fn(int $number) => $number * 2) + new CallbackProcessor(fn(int $number) => $number * 2), ), // add 10 new TestDebugProcessor( - new CallbackProcessor(fn(int $number) => $number + 10) + new CallbackProcessor(fn(int $number) => $number + 10), ), ]; diff --git a/src/batch/tests/Job/Item/Reader/AddMetadataReaderTest.php b/src/batch/tests/Job/Item/Reader/AddMetadataReaderTest.php index 2d0cd67f..41e79e33 100644 --- a/src/batch/tests/Job/Item/Reader/AddMetadataReaderTest.php +++ b/src/batch/tests/Job/Item/Reader/AddMetadataReaderTest.php @@ -17,9 +17,9 @@ public function testRead(): void { $reader = new AddMetadataReader( $decorated = new TestDebugReader( - new StaticIterableReader([['name' => 'John'], ['name' => 'Jane']]) + new StaticIterableReader([['name' => 'John'], ['name' => 'Jane']]), ), - ['_type' => 'user'] + ['_type' => 'user'], ); $reader->setJobExecution(JobExecution::createRoot('123456', 'test')); @@ -29,7 +29,7 @@ public function testRead(): void self::assertSame( [['_type' => 'user', 'name' => 'John'], ['_type' => 'user', 'name' => 'Jane']], - $read + $read, ); $decorated->assertWasConfigured(); @@ -42,7 +42,7 @@ public function testReadDecoratedNotReturningAnArray(): void $reader = new AddMetadataReader( new StaticIterableReader(['string']), - ['_type' => 'user'] + ['_type' => 'user'], ); $reader->setJobExecution(JobExecution::createRoot('123456', 'test')); diff --git a/src/batch/tests/Job/Item/Reader/Filesystem/FixedColumnSizeFileReaderTest.php b/src/batch/tests/Job/Item/Reader/Filesystem/FixedColumnSizeFileReaderTest.php index e52c5541..ae6e6257 100644 --- a/src/batch/tests/Job/Item/Reader/Filesystem/FixedColumnSizeFileReaderTest.php +++ b/src/batch/tests/Job/Item/Reader/Filesystem/FixedColumnSizeFileReaderTest.php @@ -23,7 +23,7 @@ public function test(array $columns, string $headersMode, array $expected): void $reader = new FixedColumnSizeFileReader( $columns, new StaticValueParameterAccessor(__DIR__ . '/fixtures/fixed-column-size.txt'), - $headersMode + $headersMode, ); $reader->setJobExecution($execution); self::assertSame($expected, \iterator_to_array($reader->read())); @@ -41,7 +41,7 @@ public function testFileNotFound(): void $execution = JobExecution::createRoot('123456', 'testing'); $reader = new FixedColumnSizeFileReader( [10, 10], - new StaticValueParameterAccessor(__DIR__ . '/fixtures/unknown-file.ext') + new StaticValueParameterAccessor(__DIR__ . '/fixtures/unknown-file.ext'), ); $reader->setJobExecution($execution); \iterator_to_array($reader->read()); diff --git a/src/batch/tests/Job/Item/Reader/Filesystem/JsonLinesReaderTest.php b/src/batch/tests/Job/Item/Reader/Filesystem/JsonLinesReaderTest.php index 884ac139..20e9d6f0 100644 --- a/src/batch/tests/Job/Item/Reader/Filesystem/JsonLinesReaderTest.php +++ b/src/batch/tests/Job/Item/Reader/Filesystem/JsonLinesReaderTest.php @@ -26,7 +26,7 @@ public function testRead(): void null, 0, ], - \iterator_to_array($reader->read()) + \iterator_to_array($reader->read()), ); } diff --git a/src/batch/tests/Job/Item/Reader/IndexWithReaderTest.php b/src/batch/tests/Job/Item/Reader/IndexWithReaderTest.php index 99446008..52f69637 100644 --- a/src/batch/tests/Job/Item/Reader/IndexWithReaderTest.php +++ b/src/batch/tests/Job/Item/Reader/IndexWithReaderTest.php @@ -45,7 +45,7 @@ public function provider(): Generator yield 'Index with array key' => [ fn() => [IndexWithReader::withArrayKey( $decorated = new TestDebugReader(new StaticIterableReader([$john, $marie])), - 'name' + 'name', ), $decorated], ['John' => $john, 'Marie' => $marie], ]; @@ -55,7 +55,7 @@ public function provider(): Generator yield 'Index with object property' => [ fn() => [IndexWithReader::withProperty( $decorated = new TestDebugReader(new StaticIterableReader([$john, $marie])), - 'name' + 'name', ), $decorated], ['John' => $john, 'Marie' => $marie], ]; @@ -65,7 +65,7 @@ public function provider(): Generator yield 'Index with object method' => [ fn() => [IndexWithReader::withGetter( $decorated = new TestDebugReader(new StaticIterableReader([$three, $six])), - 'count' + 'count', ), $decorated], [3 => $three, 6 => $six], ]; @@ -73,7 +73,7 @@ public function provider(): Generator yield 'Index with arbitrary closure' => [ fn() => [new IndexWithReader( $decorated = new TestDebugReader(new StaticIterableReader([1, 2, 3])), - fn(int $value) => $value * $value + fn(int $value) => $value * $value, ), $decorated], [1 => 1, 4 => 2, 9 => 3], ]; diff --git a/src/batch/tests/Job/Item/Reader/SequenceReaderTest.php b/src/batch/tests/Job/Item/Reader/SequenceReaderTest.php index cba2ad20..5f77067e 100644 --- a/src/batch/tests/Job/Item/Reader/SequenceReaderTest.php +++ b/src/batch/tests/Job/Item/Reader/SequenceReaderTest.php @@ -16,13 +16,13 @@ public function testRead(): void { $sequence = [ new TestDebugReader( - new StaticIterableReader([1, 2, 3]) + new StaticIterableReader([1, 2, 3]), ), new TestDebugReader( - new StaticIterableReader([4, 5, 6]) + new StaticIterableReader([4, 5, 6]), ), new TestDebugReader( - new StaticIterableReader([7, 8, 9]) + new StaticIterableReader([7, 8, 9]), ), ]; diff --git a/src/batch/tests/Job/Item/Writer/ConditionalWriterTest.php b/src/batch/tests/Job/Item/Writer/ConditionalWriterTest.php index c101612e..79c134fe 100644 --- a/src/batch/tests/Job/Item/Writer/ConditionalWriterTest.php +++ b/src/batch/tests/Job/Item/Writer/ConditionalWriterTest.php @@ -16,7 +16,7 @@ public function testWriteSomething(): void { $writer = new ConditionalWriter( fn(int $number) => ($number % 2) === 0, - $debugWriter = new TestDebugWriter($memoryWriter = new InMemoryWriter()) + $debugWriter = new TestDebugWriter($memoryWriter = new InMemoryWriter()), ); $writer->setJobExecution(JobExecution::createRoot('123', 'test.conditional_writer')); @@ -34,7 +34,7 @@ public function testWriteNothing(): void { $writer = new ConditionalWriter( fn() => false, - $debugWriter = new TestDebugWriter($memoryWriter = new InMemoryWriter()) + $debugWriter = new TestDebugWriter($memoryWriter = new InMemoryWriter()), ); $writer->setJobExecution(JobExecution::createRoot('123', 'test.conditional_writer')); diff --git a/src/batch/tests/Job/Item/Writer/Filesystem/JsonLinesWriterTest.php b/src/batch/tests/Job/Item/Writer/Filesystem/JsonLinesWriterTest.php index 7f223e1a..c6de9367 100644 --- a/src/batch/tests/Job/Item/Writer/Filesystem/JsonLinesWriterTest.php +++ b/src/batch/tests/Job/Item/Writer/Filesystem/JsonLinesWriterTest.php @@ -52,7 +52,7 @@ public function testWrite(): void null 0 JSONL, - \trim(\file_get_contents($filename)) + \trim(\file_get_contents($filename)), ); } diff --git a/src/batch/tests/Job/Item/Writer/LaunchJobForEachItemWriterTest.php b/src/batch/tests/Job/Item/Writer/LaunchJobForEachItemWriterTest.php index 9dc8516f..dc3c5dc2 100644 --- a/src/batch/tests/Job/Item/Writer/LaunchJobForEachItemWriterTest.php +++ b/src/batch/tests/Job/Item/Writer/LaunchJobForEachItemWriterTest.php @@ -17,7 +17,7 @@ public function testStaticParameter(): void $writer = new LaunchJobForEachItemWriter( $launcher = new BufferingJobLauncher(new SequenceJobExecutionIdGenerator(['abc', 'def', 'hij', 'klm'])), 'test.launched_job', - 'itemInLaunchedJob' + 'itemInLaunchedJob', ); $writer->setJobExecution($execution = JobExecution::createRoot('123', 'test.launch_for_items_writer')); @@ -46,7 +46,7 @@ public function testClosureParameter(): void $writer = new LaunchJobForEachItemWriter( $launcher = new BufferingJobLauncher(new SequenceJobExecutionIdGenerator(['abc', 'def', 'hij', 'klm'])), 'test.launched_job', - fn($item) => ['itemInLaunchedJob' => $item, 'extraParameter' => 'foo'] + fn($item) => ['itemInLaunchedJob' => $item, 'extraParameter' => 'foo'], ); $writer->setJobExecution($execution = JobExecution::createRoot('123', 'test.launch_for_items_writer')); diff --git a/src/batch/tests/Job/Item/Writer/LaunchJobForItemsBatchWriterTest.php b/src/batch/tests/Job/Item/Writer/LaunchJobForItemsBatchWriterTest.php index 144142c6..efdf2bfc 100644 --- a/src/batch/tests/Job/Item/Writer/LaunchJobForItemsBatchWriterTest.php +++ b/src/batch/tests/Job/Item/Writer/LaunchJobForItemsBatchWriterTest.php @@ -17,7 +17,7 @@ public function testStaticParameter(): void $writer = new LaunchJobForItemsBatchWriter( $launcher = new BufferingJobLauncher(new SequenceJobExecutionIdGenerator(['456', '789'])), 'test.launched_job', - 'itemsInLaunchedJob' + 'itemsInLaunchedJob', ); $writer->setJobExecution($execution = JobExecution::createRoot('123', 'test.launch_for_items_writer')); @@ -40,7 +40,7 @@ public function testClosureParameter(): void $writer = new LaunchJobForItemsBatchWriter( $launcher = new BufferingJobLauncher(new SequenceJobExecutionIdGenerator(['456', '789'])), 'test.launched_job', - fn(iterable $items) => ['itemsInLaunchedJob' => $items, 'extraParameter' => 'foo'] + fn(iterable $items) => ['itemsInLaunchedJob' => $items, 'extraParameter' => 'foo'], ); $writer->setJobExecution($execution = JobExecution::createRoot('123', 'test.launch_for_items_writer')); diff --git a/src/batch/tests/Job/Item/Writer/TransformingWriterTest.php b/src/batch/tests/Job/Item/Writer/TransformingWriterTest.php index 5aab09e0..c69e1705 100644 --- a/src/batch/tests/Job/Item/Writer/TransformingWriterTest.php +++ b/src/batch/tests/Job/Item/Writer/TransformingWriterTest.php @@ -21,7 +21,7 @@ public function test(): void { $writer = new TransformingWriter( $debugProcessor = new TestDebugProcessor(new CallbackProcessor(fn($string) => \strtoupper($string))), - $debugWriter = new TestDebugWriter($innerWriter = new InMemoryWriter()) + $debugWriter = new TestDebugWriter($innerWriter = new InMemoryWriter()), ); $writer->setJobExecution(JobExecution::createRoot('123', 'test.transforming_writer')); @@ -41,10 +41,10 @@ public function testSkipItems(): void $writer = new TransformingWriter( $debugProcessor = new TestDebugProcessor( new CallbackProcessor( - fn($item) => throw SkipItemException::withWarning($item, 'Skipped for test purpose') - ) + fn($item) => throw SkipItemException::withWarning($item, 'Skipped for test purpose'), + ), ), - $debugWriter = new TestDebugWriter($innerWriter = new InMemoryWriter()) + $debugWriter = new TestDebugWriter($innerWriter = new InMemoryWriter()), ); $writer->setJobExecution($execution = JobExecution::createRoot('123', 'test.transforming_writer')); diff --git a/src/batch/tests/Job/JobExecutorTest.php b/src/batch/tests/Job/JobExecutorTest.php index 28ab63c8..f5562c5a 100644 --- a/src/batch/tests/Job/JobExecutorTest.php +++ b/src/batch/tests/Job/JobExecutorTest.php @@ -37,7 +37,7 @@ protected function setUp(): void $this->executor = new JobExecutor( JobRegistry::fromJobArray(['test.job_executor' => $this->job->reveal()]), new InMemoryJobExecutionStorage(), - $this->dispatcher + $this->dispatcher, ); } @@ -106,7 +106,7 @@ public function testLaunchErrorWithStatusListener(): void function (ExceptionEvent $event) use ($exception) { Assert::assertSame($exception, $event->getException()); $event->setStatus(BatchStatus::COMPLETED); - } + }, ); $this->executor->execute($execution); diff --git a/src/batch/tests/Job/JobWithChildJobsTest.php b/src/batch/tests/Job/JobWithChildJobsTest.php index 037f7404..e20f347e 100644 --- a/src/batch/tests/Job/JobWithChildJobsTest.php +++ b/src/batch/tests/Job/JobWithChildJobsTest.php @@ -25,13 +25,13 @@ protected function setUp(): void public function test(): void { $execution = $this->execute([ - 'import' => new class() implements JobInterface { + 'import' => new class implements JobInterface { public function execute(JobExecution $jobExecution): void { $jobExecution->getSummary()->set('executed', true); } }, - 'report' => new class() implements JobInterface { + 'report' => new class implements JobInterface { public function execute(JobExecution $jobExecution): void { $jobExecution->getSummary()->set('executed', true); @@ -67,13 +67,13 @@ public function testNoChildren(): void public function testFirstChildFailing(): void { $execution = $this->execute([ - 'import' => new class() implements JobInterface { + 'import' => new class implements JobInterface { public function execute(JobExecution $jobExecution): void { throw new \RuntimeException('Expected failure'); } }, - 'report' => new class() implements JobInterface { + 'report' => new class implements JobInterface { public function execute(JobExecution $jobExecution): void { throw new \LogicException('Should never be executed'); diff --git a/src/batch/tests/Job/Parameters/ReplaceWithVariablesParameterAccessorTest.php b/src/batch/tests/Job/Parameters/ReplaceWithVariablesParameterAccessorTest.php index d06c30ea..bd6693a9 100644 --- a/src/batch/tests/Job/Parameters/ReplaceWithVariablesParameterAccessorTest.php +++ b/src/batch/tests/Job/Parameters/ReplaceWithVariablesParameterAccessorTest.php @@ -15,21 +15,21 @@ class ReplaceWithVariablesParameterAccessorTest extends TestCase public function test(): void { $accessor = new ReplaceWithVariablesParameterAccessor( - new StaticValueParameterAccessor('{job}/{id}/{date}/{seed}') + new StaticValueParameterAccessor('{job}/{id}/{date}/{seed}'), ); $execution = JobExecution::createRoot('123', 'testing-1'); $execution->setStartTime(new DateTimeImmutable('2021-07-15 11:07:28')); self::assertMatchesRegularExpression( '~^testing-1/123/20210715110728/[a-z0-9]{13}$~', - $accessor->get($execution) + $accessor->get($execution), ); $execution = JobExecution::createRoot('456', 'testing-2'); $execution->setStartTime(new DateTimeImmutable('1986-11-17 22:30:58')); self::assertMatchesRegularExpression( '~^testing-2/456/19861117223058/[a-z0-9]{13}$~', - $accessor->get($execution) + $accessor->get($execution), ); } @@ -43,45 +43,45 @@ public function testConstructorOverride(): void '{date}' => 'date overridden', '{seed}' => 'seed overridden', '{extra}' => 'extra', - ] + ], ); $execution = JobExecution::createRoot('123', 'testing-1'); $execution->setStartTime(new DateTimeImmutable('2021-07-15 11:07:28')); self::assertSame( 'job overridden/id overridden/date overridden/seed overridden/extra', - $accessor->get($execution) + $accessor->get($execution), ); $execution = JobExecution::createRoot('456', 'testing-2'); $execution->setStartTime(new DateTimeImmutable('1986-11-17 22:30:58')); self::assertSame( 'job overridden/id overridden/date overridden/seed overridden/extra', - $accessor->get($execution) + $accessor->get($execution), ); } public function testNoPlaceholders(): void { $accessor = new ReplaceWithVariablesParameterAccessor( - new StaticValueParameterAccessor('string without placeholder') + new StaticValueParameterAccessor('string without placeholder'), ); self::assertSame( 'string without placeholder', - $accessor->get(JobExecution::createRoot('123', 'testing')) + $accessor->get(JobExecution::createRoot('123', 'testing')), ); } public function testNotString(): void { $accessor = new ReplaceWithVariablesParameterAccessor( - new StaticValueParameterAccessor(1042) + new StaticValueParameterAccessor(1042), ); self::assertSame( 1042, - $accessor->get(JobExecution::createRoot('123', 'testing')) + $accessor->get(JobExecution::createRoot('123', 'testing')), ); } } diff --git a/src/batch/tests/JobExecutionTest.php b/src/batch/tests/JobExecutionTest.php index a616bc53..749c6c7f 100644 --- a/src/batch/tests/JobExecutionTest.php +++ b/src/batch/tests/JobExecutionTest.php @@ -23,7 +23,7 @@ public function testConstruct(): void 'export', $status = new BatchStatus(BatchStatus::STOPPED), $parameters = new JobParameters(), - $summary = new Summary() + $summary = new Summary(), ); $fullJobExecution->setStartTime($startTime = new \DateTimeImmutable()); $fullJobExecution->setEndTime($endTime = new \DateTime()); @@ -62,8 +62,8 @@ public function testGetParameter() 'export', null, new JobParameters( - ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => false, 'int' => 0, 'float' => 0.000] - ) + ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => false, 'int' => 0, 'float' => 0.000], + ), ); self::assertSame(null, $jobExecution->getParameter('null')); @@ -83,8 +83,8 @@ public function testGetUndefinedParameter() 'export', null, new JobParameters( - ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => false, 'int' => 0, 'float' => 0.000] - ) + ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => false, 'int' => 0, 'float' => 0.000], + ), ); $jobExecution->getParameter('notset'); @@ -152,11 +152,11 @@ public function testManipulatesFailures() self::assertSame(['Job Failure'], \array_map($failureMessage, $jobExecution->getFailures())); self::assertSame( ['Job Failure', 'Prepare Job Failure', 'Export Job Failure'], - \array_map($failureMessage, $jobExecution->getAllFailures()) + \array_map($failureMessage, $jobExecution->getAllFailures()), ); self::assertSame( ['Job Failure', 'Prepare Job Failure', 'Export Job Failure'], - \array_map($failureToString, $jobExecution->getAllFailures()) + \array_map($failureToString, $jobExecution->getAllFailures()), ); $logs = (string)$jobExecution->getLogs(); @@ -185,11 +185,11 @@ public function testManipulatesWarnings() self::assertSame(['Job Warning'], \array_map($warningMessage, $jobExecution->getWarnings())); self::assertSame( ['Job Warning', 'Prepare Job Warning', 'Export Job Warning'], - \array_map($warningMessage, $jobExecution->getAllWarnings()) + \array_map($warningMessage, $jobExecution->getAllWarnings()), ); self::assertSame( ['Job Warning', 'Prepare Job Warning', 'Export Job Warning'], - \array_map($warningToString, $jobExecution->getAllWarnings()) + \array_map($warningToString, $jobExecution->getAllWarnings()), ); $logs = (string)$jobExecution->getLogs(); @@ -206,7 +206,7 @@ public function testComputesDuration() self::assertSame( '07h 30m 15s', - $jobExecution->getDuration()->format('%Hh %Im %Ss') + $jobExecution->getDuration()->format('%Hh %Im %Ss'), ); } } diff --git a/src/batch/tests/JobParametersTest.php b/src/batch/tests/JobParametersTest.php index f1cde5b9..24f3cc75 100644 --- a/src/batch/tests/JobParametersTest.php +++ b/src/batch/tests/JobParametersTest.php @@ -13,7 +13,7 @@ class JobParametersTest extends TestCase public function testHas(): void { $parameters = new JobParameters( - ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => false, 'int' => 0, 'float' => 0.000] + ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => false, 'int' => 0, 'float' => 0.000], ); self::assertTrue($parameters->has('null')); @@ -28,7 +28,7 @@ public function testHas(): void public function testGet(): void { $parameters = new JobParameters( - ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => false, 'int' => 0, 'float' => 0.000] + ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => false, 'int' => 0, 'float' => 0.000], ); self::assertSame(null, $parameters->get('null')); @@ -44,7 +44,7 @@ public function testGetUndefinedParameter(): void $this->expectException(UndefinedJobParameterException::class); $parameters = new JobParameters( - ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => false, 'int' => 0, 'float' => 0.000] + ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => false, 'int' => 0, 'float' => 0.000], ); $parameters->get('notset'); @@ -61,7 +61,7 @@ public function testAll(): void self::assertSame([], (new JobParameters())->all()); self::assertSame( ['null' => null, 'string' => 'foo'], - (new JobParameters(['null' => null, 'string' => 'foo']))->all() + (new JobParameters(['null' => null, 'string' => 'foo']))->all(), ); } @@ -70,7 +70,7 @@ public function testGetIterator(): void self::assertSame([], \iterator_to_array(new JobParameters())); self::assertSame( ['null' => null, 'string' => 'foo'], - \iterator_to_array(new JobParameters(['null' => null, 'string' => 'foo'])) + \iterator_to_array(new JobParameters(['null' => null, 'string' => 'foo'])), ); } } diff --git a/src/batch/tests/Serializer/JsonJobExecutionSerializerTest.php b/src/batch/tests/Serializer/JsonJobExecutionSerializerTest.php index 07c88cfe..7990956d 100644 --- a/src/batch/tests/Serializer/JsonJobExecutionSerializerTest.php +++ b/src/batch/tests/Serializer/JsonJobExecutionSerializerTest.php @@ -28,7 +28,7 @@ public function testDenormalize(JobExecution $expectedjobExecution, string $seri $serializer = new JsonJobExecutionSerializer(); self::assertEquals( $expectedjobExecution, - $serializer->unserialize($serializedJobExecution) + $serializer->unserialize($serializedJobExecution), ); } diff --git a/src/batch/tests/Serializer/fixtures/fulfilled.object.php b/src/batch/tests/Serializer/fixtures/fulfilled.object.php index b046e374..6fe05742 100644 --- a/src/batch/tests/Serializer/fixtures/fulfilled.object.php +++ b/src/batch/tests/Serializer/fixtures/fulfilled.object.php @@ -19,7 +19,7 @@ 'An error occurred', 666, $hash, - "A stack trace\nSomething that indicates\nWhere the error occurred\nIn application code" + "A stack trace\nSomething that indicates\nWhere the error occurred\nIn application code", ); $jobExecution = JobExecution::createRoot( @@ -34,8 +34,8 @@ 2020 [INFO]: Exported one row 2020 [WARNING]: Invalid row -LOG - ) +LOG, + ), ); $jobExecution->setStartTime(\DateTimeImmutable::createFromFormat(DATE_ISO8601, '2018-01-01T00:00:01+0200')); $jobExecution->setEndTime(\DateTimeImmutable::createFromFormat(DATE_ISO8601, '2018-01-01T01:59:59+0200')); @@ -47,8 +47,8 @@ 'prepare', new BatchStatus(BatchStatus::COMPLETED), null, - new Summary($hash) - ) + new Summary($hash), + ), ); $prepareChildExecution->setStartTime(\DateTimeImmutable::createFromFormat(DATE_ISO8601, '2018-01-01T00:00:01+0200')); $prepareChildExecution->setEndTime(\DateTimeImmutable::createFromFormat(DATE_ISO8601, '2018-01-01T00:59:59+0200')); @@ -59,8 +59,8 @@ 'export', new BatchStatus(BatchStatus::FAILED), null, - new Summary($hash) - ) + new Summary($hash), + ), ); $exportChildExecution->setStartTime(\DateTimeImmutable::createFromFormat(DATE_ISO8601, '2018-01-01T01:00:00+0200')); $exportChildExecution->setEndTime(\DateTimeImmutable::createFromFormat(DATE_ISO8601, '2018-01-01T01:59:59+0200')); diff --git a/src/batch/tests/Storage/FilesystemJobExecutionStorageTest.php b/src/batch/tests/Storage/FilesystemJobExecutionStorageTest.php index 0a6d271d..d6bb181a 100644 --- a/src/batch/tests/Storage/FilesystemJobExecutionStorageTest.php +++ b/src/batch/tests/Storage/FilesystemJobExecutionStorageTest.php @@ -50,11 +50,11 @@ protected function setUp(): void private function createStorage( string $dir = self::STORAGE_DIR, - JobExecutionSerializerInterface $serializer = null + JobExecutionSerializerInterface $serializer = null, ): FilesystemJobExecutionStorage { return new FilesystemJobExecutionStorage( $serializer ?? $this->serializer->reveal(), - $dir + $dir, ); } @@ -114,7 +114,7 @@ public function testList(string $jobName, array $expectedCouples): void { $storage = $this->createStorage( __DIR__ . '/fixtures/filesystem-job-execution', - new JsonJobExecutionSerializer() + new JsonJobExecutionSerializer(), ); self::assertExecutions($expectedCouples, $storage->list($jobName)); @@ -146,7 +146,7 @@ public function testQueryWithProvider(QueryBuilder $query, array $expectedCouple { $storage = $this->createStorage( __DIR__ . '/fixtures/filesystem-job-execution', - new JsonJobExecutionSerializer() + new JsonJobExecutionSerializer(), ); self::assertExecutions($expectedCouples, $storage->query($query->getQuery())); diff --git a/src/batch/tests/Storage/QueryBuilderTest.php b/src/batch/tests/Storage/QueryBuilderTest.php index daefe288..d13ff68a 100644 --- a/src/batch/tests/Storage/QueryBuilderTest.php +++ b/src/batch/tests/Storage/QueryBuilderTest.php @@ -64,7 +64,7 @@ public function valid(): \Generator endTime: $endTime, sort: $sortBy, limit: $limit, - offset: $offset + offset: $offset, ), ]; yield 'Query with sort' => [ @@ -77,7 +77,7 @@ public function valid(): \Generator endTime: $endTime, sort: Query::SORT_BY_START_DESC, limit: $limit, - offset: $offset + offset: $offset, ), ]; yield 'Query with limit' => [ @@ -90,7 +90,7 @@ public function valid(): \Generator endTime: $endTime, sort: $sortBy, limit: 30, - offset: 60 + offset: 60, ), ]; $startTimeFrom = new \DateTimeImmutable('2023-07-07 15:18'); @@ -105,7 +105,7 @@ public function valid(): \Generator endTime: null, sort: $sortBy, limit: $limit, - offset: $offset + offset: $offset, ), ]; yield 'Query with start time boundary reset' => [ @@ -118,7 +118,7 @@ public function valid(): \Generator endTime: null, sort: $sortBy, limit: $limit, - offset: $offset + offset: $offset, ), ]; $endTimeFrom = new \DateTimeImmutable('2023-07-07 15:18'); @@ -133,7 +133,7 @@ public function valid(): \Generator endTime: new TimeFilter($endTimeFrom, $endTimeTo), sort: $sortBy, limit: $limit, - offset: $offset + offset: $offset, ), ]; yield 'Query with end time boundary reset' => [ @@ -146,7 +146,7 @@ public function valid(): \Generator endTime: null, sort: $sortBy, limit: $limit, - offset: $offset + offset: $offset, ), ]; yield 'Query complex' => [ @@ -166,7 +166,7 @@ public function valid(): \Generator endTime: new TimeFilter($endTimeFrom, $endTimeTo), sort: Query::SORT_BY_END_DESC, limit: 6, - offset: 12 + offset: 12, ), ]; } @@ -201,7 +201,7 @@ public function invalid(): \Generator BatchStatus::ABANDONED, BatchStatus::FAILED, ], - 666 + 666, ), ]; yield 'QueryBuilder::sort expect any Query::SORT_*' => [ @@ -213,7 +213,7 @@ public function invalid(): \Generator Query::SORT_BY_END_ASC, Query::SORT_BY_END_DESC, ], - 'wrong' + 'wrong', ), ]; yield 'QueryBuilder::limit $limit argument expect positive int' => [ diff --git a/src/batch/tests/SummaryTest.php b/src/batch/tests/SummaryTest.php index 572e9e02..333244de 100644 --- a/src/batch/tests/SummaryTest.php +++ b/src/batch/tests/SummaryTest.php @@ -30,13 +30,13 @@ public function testSet(): void $summary->set('float', 0.999); self::assertSame( ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => true, 'int' => 1, 'float' => 0.999], - $summary->all() + $summary->all(), ); $summary->set('string', 'bar'); self::assertSame( ['null' => null, 'string' => 'bar', 'array' => [], 'bool' => true, 'int' => 1, 'float' => 0.999], - $summary->all() + $summary->all(), ); } @@ -51,14 +51,14 @@ public function testIncrement(): void self::assertSame( ['int' => 4, 'float' => 3.999, 'notset' => 1], - $summary->all() + $summary->all(), ); } public function testGet(): void { $summary = new Summary( - ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => true, 'int' => 1, 'float' => 0.999] + ['null' => null, 'string' => 'foo', 'array' => [], 'bool' => true, 'int' => 1, 'float' => 0.999], ); $summary->set('string', 'foo'); $summary->set('array', []); diff --git a/src/batch/tests/Test/Finder/DummyFinderTest.php b/src/batch/tests/Test/Finder/DummyFinderTest.php index a9ae41c4..0af5cb21 100644 --- a/src/batch/tests/Test/Finder/DummyFinderTest.php +++ b/src/batch/tests/Test/Finder/DummyFinderTest.php @@ -11,7 +11,7 @@ class DummyFinderTest extends TestCase { public function test(): void { - $dummy = new class() { + $dummy = new class { }; $finder = new DummyFinder($dummy); diff --git a/src/batch/tests/Test/Launcher/BufferingJobLauncherTest.php b/src/batch/tests/Test/Launcher/BufferingJobLauncherTest.php index 6c422260..4e28dadc 100644 --- a/src/batch/tests/Test/Launcher/BufferingJobLauncherTest.php +++ b/src/batch/tests/Test/Launcher/BufferingJobLauncherTest.php @@ -21,7 +21,7 @@ public function test(): void self::assertSame('123', $launcher->getExecutions()[0]->getId()); self::assertSame( ['_id' => '123'], - $launcher->getExecutions()[0]->getParameters()->all() + $launcher->getExecutions()[0]->getParameters()->all(), ); $launcher->launch('testing.foo'); @@ -31,13 +31,13 @@ public function test(): void self::assertSame('456', $launcher->getExecutions()[1]->getId()); self::assertSame( ['_id' => '456'], - $launcher->getExecutions()[1]->getParameters()->all() + $launcher->getExecutions()[1]->getParameters()->all(), ); self::assertSame('testing.bar', $launcher->getExecutions()[2]->getJobName()); self::assertSame('789', $launcher->getExecutions()[2]->getId()); self::assertSame( ['var' => 'value', '_id' => '789'], - $launcher->getExecutions()[2]->getParameters()->all() + $launcher->getExecutions()[2]->getParameters()->all(), ); } } diff --git a/src/batch/tests/Trigger/TriggerScheduledJobsJobTest.php b/src/batch/tests/Trigger/TriggerScheduledJobsJobTest.php index ffbda47b..2a7ac961 100644 --- a/src/batch/tests/Trigger/TriggerScheduledJobsJobTest.php +++ b/src/batch/tests/Trigger/TriggerScheduledJobsJobTest.php @@ -29,7 +29,7 @@ public function test(): void [new DateTimeImmutable('tomorrow'), 'not_triggered'], ]), ], - $launcher = new BufferingJobLauncher(new SequenceJobExecutionIdGenerator(['123'])) + $launcher = new BufferingJobLauncher(new SequenceJobExecutionIdGenerator(['123'])), ); $job->execute($jobExecution = JobExecution::createRoot('123456', 'testing')); @@ -39,13 +39,13 @@ public function test(): void self::assertSame('123', $launcher->getExecutions()[0]->getId()); self::assertSame( ['_id' => '123'], - $launcher->getExecutions()[0]->getParameters()->all() + $launcher->getExecutions()[0]->getParameters()->all(), ); self::assertSame('triggered', $launcher->getExecutions()[1]->getJobName()); self::assertSame('triggered_job_id', $launcher->getExecutions()[1]->getId()); self::assertSame( ['config' => 'value', '_id' => 'triggered_job_id'], - $launcher->getExecutions()[1]->getParameters()->all() + $launcher->getExecutions()[1]->getParameters()->all(), ); self::assertSame([ [ @@ -63,12 +63,12 @@ public function test(): void self::assertStringContainsString( 'INFO: Launched scheduled job. ' . '{"scheduler":"' . \preg_quote(CallbackScheduler::class) . '","job":"triggered_with_defaults","id":"123"}', - $logs + $logs, ); self::assertStringContainsString( 'INFO: Launched scheduled job. ' . '{"scheduler":"' . \preg_quote(TimeScheduler::class) . '","job":"triggered","id":"triggered_job_id"}', - $logs + $logs, ); } @@ -76,7 +76,7 @@ public function testWithNoScheduler(): void { $job = new TriggerScheduledJobsJob( [], - $launcher = new BufferingJobLauncher(new UniqidJobExecutionIdGenerator()) + $launcher = new BufferingJobLauncher(new UniqidJobExecutionIdGenerator()), ); $job->execute($jobExecution = JobExecution::createRoot('123456', 'testing')); diff --git a/tests/convention/Comment/ClassCommentsTest.php b/tests/convention/Comment/ClassCommentsTest.php index 6a97d820..5c51ca0f 100644 --- a/tests/convention/Comment/ClassCommentsTest.php +++ b/tests/convention/Comment/ClassCommentsTest.php @@ -18,7 +18,7 @@ public function testAllClassesHasComment(ReflectionClass $class): void { self::assertNotFalse( $class->getDocComment(), - "{$class->getName()} must have comment." + "{$class->getName()} must have comment.", ); } diff --git a/tests/convention/Comment/CommentsTestCase.php b/tests/convention/Comment/CommentsTestCase.php index 0724843d..49faf668 100644 --- a/tests/convention/Comment/CommentsTestCase.php +++ b/tests/convention/Comment/CommentsTestCase.php @@ -12,6 +12,7 @@ protected static function assertAllSeeDocAreSurroundedWithBrackets(string $comme { if (!\preg_match_all('/.@see [^ }]+./', $comment, $matches)) { self::assertTrue(true); + return; } diff --git a/tests/convention/Comment/MethodCommentsTest.php b/tests/convention/Comment/MethodCommentsTest.php index c34ae738..7b35194b 100644 --- a/tests/convention/Comment/MethodCommentsTest.php +++ b/tests/convention/Comment/MethodCommentsTest.php @@ -27,7 +27,7 @@ public function testAllPublicMethodsHasComment(ReflectionMethod $method): void self::assertNotEmpty( $comment, "{$this->methodFQCN($method)} is a public method and must have comment." . - " In {$this->fileAndLine($method)}." + " In {$this->fileAndLine($method)}.", ); } diff --git a/tests/convention/Dependency/PackagesTest.php b/tests/convention/Dependency/PackagesTest.php index 0f43d3dc..22b6e48f 100644 --- a/tests/convention/Dependency/PackagesTest.php +++ b/tests/convention/Dependency/PackagesTest.php @@ -58,6 +58,7 @@ public function testPackagesAreUsingRequiredClasses(Package $package): void foreach ($requirePrefixes as $prefix) { if (\str_starts_with($use, $prefix)) { self::assertTrue(true); + continue 2; } } @@ -85,7 +86,7 @@ public function testPackagesAreUsingSameDependencyVersions(): void self::assertCount( 1, $distinctVersions, - "{$dependency} is configured on the same version : " . \json_encode($distinctVersions) + "{$dependency} is configured on the same version : " . \json_encode($distinctVersions), ); } } diff --git a/tests/convention/Dependency/SourcesTest.php b/tests/convention/Dependency/SourcesTest.php index 0c461be3..c4ee3a72 100644 --- a/tests/convention/Dependency/SourcesTest.php +++ b/tests/convention/Dependency/SourcesTest.php @@ -45,7 +45,7 @@ public function test(): void self::assertSame( [], \array_diff($expectedProdDeps, $prodDeps), - 'Dependencies of all packages are required in root composer.json' + 'Dependencies of all packages are required in root composer.json', ); $expectedDevDeps = \array_unique($expectedDevDeps); @@ -59,7 +59,7 @@ public function test(): void self::assertSame( [], \array_diff($expectedDevDeps, $devDeps), - 'Dev dependencies of all packages are required in root composer.json' + 'Dev dependencies of all packages are required in root composer.json', ); $replace = $rootComposer->replace(); @@ -68,7 +68,7 @@ public function test(): void self::assertSame( $expectedReplace, $replace, - 'All packages are replaced in root composer.json' + 'All packages are replaced in root composer.json', ); $prodAutoload = $rootComposer->autoload(); @@ -77,7 +77,7 @@ public function test(): void self::assertSame( [], \array_diff($expectedProdAutoload, $prodAutoload), - 'All packages autoload rules are duplicated in root composer.json' + 'All packages autoload rules are duplicated in root composer.json', ); $devAutoload = $rootComposer->autoloadDev(); @@ -86,7 +86,7 @@ public function test(): void self::assertSame( [], \array_diff($expectedDevAutoload, $devAutoload), - 'All packages dev autoload rules are duplicated in root composer.json' + 'All packages dev autoload rules are duplicated in root composer.json', ); } } diff --git a/tests/convention/Documentation/DocumentationLinksTest.php b/tests/convention/Documentation/DocumentationLinksTest.php index ebe142df..324ad36d 100644 --- a/tests/convention/Documentation/DocumentationLinksTest.php +++ b/tests/convention/Documentation/DocumentationLinksTest.php @@ -35,7 +35,7 @@ public function testInternalLinksAreValid(DocFile $file): void self::assertNotFalse( $link->pointsToFile->getRealPath(), "Link \"{$link->label}\" in \"{$link->pointsToFile->getPathname()}\"," . - " is pointing to \"{$link->uri}\" which reference an internal file that do not exists." + " is pointing to \"{$link->uri}\" which reference an internal file that do not exists.", ); self::assertSame(self::DEFAULT_BRANCH, $link->branch, 'All links must be wired on default branch.'); @@ -94,7 +94,7 @@ public function testComponentsAreListed(string $filepath, string $interface): vo self::assertSame( $expectedClasses, $actualClasses, - "All classes implementing \"{$interface}\" should be linked in \"{$filepath}\"." + "All classes implementing \"{$interface}\" should be linked in \"{$filepath}\".", ); } diff --git a/tests/integration/DummyJobTest.php b/tests/integration/DummyJobTest.php index a8e3c6c7..38ae5eda 100644 --- a/tests/integration/DummyJobTest.php +++ b/tests/integration/DummyJobTest.php @@ -13,7 +13,7 @@ class DummyJobTest extends JobTestCase { protected function createJob(JobExecutionStorageInterface $executionStorage): JobInterface { - return new class() implements JobInterface { + return new class implements JobInterface { public function execute(JobExecution $jobExecution): void { $jobExecution->getSummary()->set('done', true); @@ -28,7 +28,7 @@ protected function getJobName(): string protected function assertAgainstExecution( JobExecutionStorageInterface $jobExecutionStorage, - JobExecution $jobExecution + JobExecution $jobExecution, ): void { parent::assertAgainstExecution($jobExecutionStorage, $jobExecution); diff --git a/tests/integration/FailingDummyJobTest.php b/tests/integration/FailingDummyJobTest.php index 0dde588b..ca8f6660 100644 --- a/tests/integration/FailingDummyJobTest.php +++ b/tests/integration/FailingDummyJobTest.php @@ -14,7 +14,7 @@ class FailingDummyJobTest extends JobTestCase { protected function createJob(JobExecutionStorageInterface $executionStorage): JobInterface { - return new class() implements JobInterface { + return new class implements JobInterface { public function execute(JobExecution $jobExecution): void { $jobExecution->addWarning(new Warning('WARNING! I am a dummy.')); @@ -32,7 +32,7 @@ protected function getJobName(): string protected function assertAgainstExecution( JobExecutionStorageInterface $jobExecutionStorage, - JobExecution $jobExecution + JobExecution $jobExecution, ): void { parent::assertAgainstExecution($jobExecutionStorage, $jobExecution); diff --git a/tests/integration/ImportDevelopersXlsxToORMTest.php b/tests/integration/ImportDevelopersXlsxToORMTest.php index 4167ef86..82bc996d 100644 --- a/tests/integration/ImportDevelopersXlsxToORMTest.php +++ b/tests/integration/ImportDevelopersXlsxToORMTest.php @@ -96,7 +96,7 @@ protected function createJob(JobExecutionStorageInterface $executionStorage): Jo $inputFile, $outputBadgeFile, $outputRepositoryFile, - $outputDeveloperFile + $outputDeveloperFile, ), 'import' => new JobWithChildJobs( $executionStorage, @@ -106,33 +106,33 @@ protected function createJob(JobExecutionStorageInterface $executionStorage): Jo $csvReader(self::OUTPUT_BADGE_FILE), new BadgeProcessor(), $objectWriter, - $executionStorage + $executionStorage, ), 'import-repository' => new ItemJob( PHP_INT_MAX, $csvReader(self::OUTPUT_REPOSITORY_FILE), new RepositoryProcessor(), $objectWriter, - $executionStorage + $executionStorage, ), 'import-developer' => new ItemJob( 5, $csvReader(self::OUTPUT_DEVELOPER_FILE), new DeveloperProcessor($entityManager), $objectWriter, - $executionStorage + $executionStorage, ), ]), - ['import-badge', 'import-repository', 'import-developer'] + ['import-badge', 'import-repository', 'import-developer'], ), ]), - ['split', 'import'] + ['split', 'import'], ); } protected function assertAgainstExecution( JobExecutionStorageInterface $jobExecutionStorage, - JobExecution $jobExecution + JobExecution $jobExecution, ): void { parent::assertAgainstExecution($jobExecutionStorage, $jobExecution); diff --git a/tests/integration/Job/SplitDeveloperXlsxJob.php b/tests/integration/Job/SplitDeveloperXlsxJob.php index 64a5657f..4b0248e8 100644 --- a/tests/integration/Job/SplitDeveloperXlsxJob.php +++ b/tests/integration/Job/SplitDeveloperXlsxJob.php @@ -18,7 +18,7 @@ public function __construct( private string $inputFile, private string $outputBadgeFile, private string $outputRepositoryFile, - private string $outputDeveloperFile + private string $outputDeveloperFile, ) { } @@ -73,7 +73,7 @@ public function execute(JobExecution $jobExecution): void unset( $badges, $repositories, - $developers + $developers, ); } @@ -96,7 +96,7 @@ function ($row): array { return $row; }, - \iterator_to_array(new \LimitIterator($sheet->getRowIterator(), 1), false) + \iterator_to_array(new \LimitIterator($sheet->getRowIterator(), 1), false), ); } } diff --git a/tests/integration/JobTestCase.php b/tests/integration/JobTestCase.php index d5a75412..b8ab6908 100644 --- a/tests/integration/JobTestCase.php +++ b/tests/integration/JobTestCase.php @@ -53,9 +53,9 @@ public function testExecuteJob(JobExecutionStorageInterface $jobExecutionStorage $launcher = new SimpleJobLauncher( new JobExecutionAccessor( new JobExecutionFactory(new UniqidJobExecutionIdGenerator(), new NullJobExecutionParametersBuilder()), - $jobExecutionStorage + $jobExecutionStorage, ), - self::createJobExecutor($jobExecutionStorage, [$jobName => $job]) + self::createJobExecutor($jobExecutionStorage, [$jobName => $job]), ); $jobExecution = $launcher->launch($jobName); @@ -81,11 +81,11 @@ abstract protected function getJobName(): string; protected function assertAgainstExecution( JobExecutionStorageInterface $jobExecutionStorage, - JobExecution $jobExecution + JobExecution $jobExecution, ): void { $this->compareExecutions( $jobExecution, - $jobExecutionStorage->retrieve($jobExecution->getJobName(), $jobExecution->getId()) + $jobExecutionStorage->retrieve($jobExecution->getJobName(), $jobExecution->getId()), ); } @@ -96,11 +96,11 @@ private function compareExecutions(JobExecution $jobExecution, JobExecution $sto self::compareStatuses($jobExecution->getStatus(), $storedJobExecution->getStatus()); self::assertSame( \iterator_to_array($jobExecution->getParameters()), - \iterator_to_array($storedJobExecution->getParameters()) + \iterator_to_array($storedJobExecution->getParameters()), ); self::assertSame( \iterator_to_array($jobExecution->getSummary()), - \iterator_to_array($storedJobExecution->getSummary()) + \iterator_to_array($storedJobExecution->getSummary()), ); self::compareDates($jobExecution->getStartTime(), $storedJobExecution->getStartTime()); self::compareDates($jobExecution->getEndTime(), $storedJobExecution->getEndTime()); @@ -111,7 +111,7 @@ private function compareExecutions(JobExecution $jobExecution, JobExecution $sto foreach ($jobExecution->getChildExecutions() as $childExecution) { $this->compareExecutions( $childExecution, - $storedJobExecution->getChildExecution($childExecution->getJobName()) + $storedJobExecution->getChildExecution($childExecution->getJobName()), ); } } @@ -120,7 +120,7 @@ private function storages(): \Iterator { yield new FilesystemJobExecutionStorage( new JsonJobExecutionSerializer(), - self::STORAGE_DIR + self::STORAGE_DIR, ); } @@ -129,11 +129,11 @@ private static function compareStatuses(BatchStatus $expected, BatchStatus $actu self::assertSame($expected->getValue(), $actual->getValue()); } - private static function compareDates(?\DateTimeInterface $expected, ?\DateTimeInterface $actual) + private static function compareDates(null|\DateTimeInterface $expected, null|\DateTimeInterface $actual) { self::assertSame( $expected ? $expected->format(\DateTime::ISO8601) : null, - $actual ? $actual->format(\DateTime::ISO8601) : null + $actual ? $actual->format(\DateTime::ISO8601) : null, ); } diff --git a/tests/integration/JobWithDummyChildrenTest.php b/tests/integration/JobWithDummyChildrenTest.php index 8ab22fb8..c6560420 100644 --- a/tests/integration/JobWithDummyChildrenTest.php +++ b/tests/integration/JobWithDummyChildrenTest.php @@ -17,20 +17,20 @@ protected function createJob(JobExecutionStorageInterface $executionStorage): Jo return new JobWithChildJobs( $executionStorage, self::createJobExecutor($executionStorage, [ - 'prepare' => new class() implements JobInterface { + 'prepare' => new class implements JobInterface { public function execute(JobExecution $jobExecution): void { $jobExecution->getSummary()->set('done', true); } }, - 'do' => new class() implements JobInterface { + 'do' => new class implements JobInterface { public function execute(JobExecution $jobExecution): void { $jobExecution->getSummary()->set('done', true); } }, ]), - ['prepare', 'do'] + ['prepare', 'do'], ); } @@ -41,7 +41,7 @@ protected function getJobName(): string protected function assertAgainstExecution( JobExecutionStorageInterface $jobExecutionStorage, - JobExecution $jobExecution + JobExecution $jobExecution, ): void { parent::assertAgainstExecution($jobExecutionStorage, $jobExecution); diff --git a/tests/integration/JobWithDummyItemChildrenTest.php b/tests/integration/JobWithDummyItemChildrenTest.php index 59508c37..b635000f 100644 --- a/tests/integration/JobWithDummyItemChildrenTest.php +++ b/tests/integration/JobWithDummyItemChildrenTest.php @@ -49,24 +49,24 @@ public function write(iterable $items): void new StaticIterableReader([1, 2, 3]), new NullProcessor(), $fileLineWriter, - $executionStorage + $executionStorage, ), 'four-five-six' => new ItemJob( 2, new StaticIterableReader([4, 5, 6]), new NullProcessor(), $fileLineWriter, - $executionStorage + $executionStorage, ), 'seven-height-nine' => new ItemJob( 3, new StaticIterableReader([7, 8, 9]), new NullProcessor(), $fileLineWriter, - $executionStorage + $executionStorage, ), ]), - ['one-two-three', 'four-five-six', 'seven-height-nine'] + ['one-two-three', 'four-five-six', 'seven-height-nine'], ); } @@ -77,7 +77,7 @@ protected function getJobName(): string protected function assertAgainstExecution( JobExecutionStorageInterface $jobExecutionStorage, - JobExecution $jobExecution + JobExecution $jobExecution, ): void { parent::assertAgainstExecution($jobExecutionStorage, $jobExecution); diff --git a/tests/integration/JobWithFailingDummyChidlrenTest.php b/tests/integration/JobWithFailingDummyChidlrenTest.php index 28df9529..b96780e8 100644 --- a/tests/integration/JobWithFailingDummyChidlrenTest.php +++ b/tests/integration/JobWithFailingDummyChidlrenTest.php @@ -17,13 +17,13 @@ protected function createJob(JobExecutionStorageInterface $executionStorage): Jo return new JobWithChildJobs( $executionStorage, self::createJobExecutor($executionStorage, [ - 'prepare' => new class() implements JobInterface { + 'prepare' => new class implements JobInterface { public function execute(JobExecution $jobExecution): void { throw new \Exception('Critical dummy exception'); } }, - 'do' => new class() implements JobInterface { + 'do' => new class implements JobInterface { public function execute(JobExecution $jobExecution): void { // this job should not be executed @@ -31,7 +31,7 @@ public function execute(JobExecution $jobExecution): void } }, ]), - ['prepare', 'do'] + ['prepare', 'do'], ); } @@ -42,7 +42,7 @@ protected function getJobName(): string protected function assertAgainstExecution( JobExecutionStorageInterface $jobExecutionStorage, - JobExecution $jobExecution + JobExecution $jobExecution, ): void { parent::assertAgainstExecution($jobExecutionStorage, $jobExecution); diff --git a/tests/symfony/src/Entity/StarWars/Character.php b/tests/symfony/src/Entity/StarWars/Character.php index bbe7f5de..ba7fd02a 100644 --- a/tests/symfony/src/Entity/StarWars/Character.php +++ b/tests/symfony/src/Entity/StarWars/Character.php @@ -25,18 +25,18 @@ class Character #[ORM\Column(type: 'string', unique: true)] #[Assert\NotNull] - public ?string $name; + public null|string $name; #[ORM\Column(type: 'integer', nullable: true)] - public ?int $birthYear; + public null|int $birthYear; #[ORM\Column(type: 'string')] #[Assert\NotNull] - public ?string $gender; + public null|string $gender; #[ORM\ManyToOne(targetEntity: Planet::class)] - public ?Planet $homeWorld; + public null|Planet $homeWorld; #[ORM\ManyToOne(targetEntity: Specie::class)] - public ?Specie $specie; + public null|Specie $specie; } diff --git a/tests/symfony/src/Entity/StarWars/Planet.php b/tests/symfony/src/Entity/StarWars/Planet.php index 609ed2b3..6db0ab8a 100644 --- a/tests/symfony/src/Entity/StarWars/Planet.php +++ b/tests/symfony/src/Entity/StarWars/Planet.php @@ -25,16 +25,16 @@ class Planet #[ORM\Column(type: 'string', unique: true)] #[Assert\NotNull] - public ?string $name; + public null|string $name; #[ORM\Column(type: 'integer', nullable: true)] - public ?int $rotationPeriod; + public null|int $rotationPeriod; #[ORM\Column(type: 'integer', nullable: true)] - public ?int $orbitalPeriod; + public null|int $orbitalPeriod; #[ORM\Column(type: 'integer', nullable: true)] - public ?int $population; + public null|int $population; #[ORM\Column(type: 'json')] #[Assert\NotNull] diff --git a/tests/symfony/src/Entity/StarWars/Specie.php b/tests/symfony/src/Entity/StarWars/Specie.php index b1858c95..50acada7 100644 --- a/tests/symfony/src/Entity/StarWars/Specie.php +++ b/tests/symfony/src/Entity/StarWars/Specie.php @@ -25,13 +25,13 @@ class Specie #[ORM\Column(type: 'string', unique: true)] #[Assert\NotNull] - public ?string $name; + public null|string $name; #[ORM\Column(type: 'string', nullable: true)] - public ?string $classification; + public null|string $classification; #[ORM\Column(type: 'string', nullable: true)] - public ?string $language; + public null|string $language; #[ORM\ManyToOne(targetEntity: Planet::class)] public Planet $homeWorld; diff --git a/tests/symfony/src/Job/Country/CountryJob.php b/tests/symfony/src/Job/Country/CountryJob.php index 2f349b85..d5ccdb7d 100644 --- a/tests/symfony/src/Job/Country/CountryJob.php +++ b/tests/symfony/src/Job/Country/CountryJob.php @@ -67,10 +67,10 @@ public static function getJobName(): string public function __construct( JobExecutionStorageInterface $executionStorage, KernelInterface $kernel, - LoggerInterface $yokaiBatchLogger + LoggerInterface $yokaiBatchLogger, ) { $writePath = fn(string $format) => new StaticValueParameterAccessor( - ARTIFACT_DIR . '/symfony/country/countries.' . $format + ARTIFACT_DIR . '/symfony/country/countries.' . $format, ); $reader = function (string $key) use ($kernel) { $path = new StaticValueParameterAccessor($kernel->getProjectDir() . '/data/country/' . $key . '.json'); @@ -94,7 +94,7 @@ public function __construct( new SequenceReader(\array_map($reader, $fragments)), $this, $this, - $executionStorage + $executionStorage, ), ); } @@ -111,7 +111,7 @@ public function write(iterable $items): void foreach ($items as $item) { $this->countries[$item['iso2']] = \array_merge( $this->countries[$item['iso2']] ?? [], - $item + $item, ); } } diff --git a/tests/symfony/src/Job/Country/CountryJsonFileReader.php b/tests/symfony/src/Job/Country/CountryJsonFileReader.php index b4594ee7..5b57014f 100644 --- a/tests/symfony/src/Job/Country/CountryJsonFileReader.php +++ b/tests/symfony/src/Job/Country/CountryJsonFileReader.php @@ -24,8 +24,8 @@ public function read(): iterable { $data = (array)\json_decode( (string)\file_get_contents( - (string)$this->filePath->get($this->jobExecution) - ) + (string)$this->filePath->get($this->jobExecution), + ), ); foreach ($data as $code => $value) { yield ['code' => $code, 'value' => $value]; diff --git a/tests/symfony/src/Job/StarWars/AbstractImportStartWarsEntityJob.php b/tests/symfony/src/Job/StarWars/AbstractImportStartWarsEntityJob.php index 105cb603..eb2372fd 100644 --- a/tests/symfony/src/Job/StarWars/AbstractImportStartWarsEntityJob.php +++ b/tests/symfony/src/Job/StarWars/AbstractImportStartWarsEntityJob.php @@ -42,7 +42,7 @@ public function __construct( Closure $process, ValidatorInterface $validator, ManagerRegistry $doctrine, - JobExecutionStorageInterface $executionStorage + JobExecutionStorageInterface $executionStorage, ) { parent::__construct( new ItemJob( @@ -51,18 +51,18 @@ public function __construct( new StaticValueParameterAccessor($file), null, null, - HeaderStrategy::combine() + HeaderStrategy::combine(), ), new ChainProcessor([ new ArrayMapProcessor( - fn(string $value) => $value === 'NA' ? null : $value + fn(string $value) => $value === 'NA' ? null : $value, ), new CallbackProcessor($process), new SkipInvalidItemProcessor($validator), ]), new ObjectWriter($doctrine), - $executionStorage - ) + $executionStorage, + ), ); } } diff --git a/tests/symfony/src/Job/StarWars/ImportStarWarsCharacterJob.php b/tests/symfony/src/Job/StarWars/ImportStarWarsCharacterJob.php index c993f531..ab41ce50 100644 --- a/tests/symfony/src/Job/StarWars/ImportStarWarsCharacterJob.php +++ b/tests/symfony/src/Job/StarWars/ImportStarWarsCharacterJob.php @@ -27,7 +27,7 @@ public function __construct( KernelInterface $kernel, ValidatorInterface $validator, ManagerRegistry $doctrine, - JobExecutionStorageInterface $executionStorage + JobExecutionStorageInterface $executionStorage, ) { parent::__construct( $kernel->getProjectDir() . '/data/star-wars/characters.csv', @@ -45,7 +45,7 @@ function (array $item) use ($doctrine) { }, $validator, $doctrine, - $executionStorage + $executionStorage, ); } } diff --git a/tests/symfony/src/Job/StarWars/ImportStarWarsJob.php b/tests/symfony/src/Job/StarWars/ImportStarWarsJob.php index 384b417f..7eec957f 100644 --- a/tests/symfony/src/Job/StarWars/ImportStarWarsJob.php +++ b/tests/symfony/src/Job/StarWars/ImportStarWarsJob.php @@ -31,7 +31,7 @@ public function __construct(JobExecutionStorageInterface $executionStorage, JobE ImportStarWarsPlanetJob::getJobName(), ImportStarWarsSpecieJob::getJobName(), ImportStarWarsCharacterJob::getJobName(), - ]) + ]), ); } } diff --git a/tests/symfony/src/Job/StarWars/ImportStarWarsPlanetJob.php b/tests/symfony/src/Job/StarWars/ImportStarWarsPlanetJob.php index 904cccec..60775fae 100644 --- a/tests/symfony/src/Job/StarWars/ImportStarWarsPlanetJob.php +++ b/tests/symfony/src/Job/StarWars/ImportStarWarsPlanetJob.php @@ -25,7 +25,7 @@ public function __construct( KernelInterface $kernel, ValidatorInterface $validator, ManagerRegistry $doctrine, - JobExecutionStorageInterface $executionStorage + JobExecutionStorageInterface $executionStorage, ) { parent::__construct( $kernel->getProjectDir() . '/data/star-wars/planets.csv', @@ -36,14 +36,14 @@ function (array $item) { $entity->orbitalPeriod = $item['orbital_period'] ? (int)$item['orbital_period'] : null; $entity->population = $item['population'] ? (int)$item['population'] : null; $entity->terrain = \array_filter( - \array_map('trim', \explode(',', (string)$item['terrain'])) + \array_map('trim', \explode(',', (string)$item['terrain'])), ); return $entity; }, $validator, $doctrine, - $executionStorage + $executionStorage, ); } } diff --git a/tests/symfony/src/Job/StarWars/ImportStarWarsSpecieJob.php b/tests/symfony/src/Job/StarWars/ImportStarWarsSpecieJob.php index a80cdb59..c4b13854 100644 --- a/tests/symfony/src/Job/StarWars/ImportStarWarsSpecieJob.php +++ b/tests/symfony/src/Job/StarWars/ImportStarWarsSpecieJob.php @@ -26,7 +26,7 @@ public function __construct( KernelInterface $kernel, ValidatorInterface $validator, ManagerRegistry $doctrine, - JobExecutionStorageInterface $executionStorage + JobExecutionStorageInterface $executionStorage, ) { parent::__construct( $kernel->getProjectDir() . '/data/star-wars/species.csv', @@ -44,7 +44,7 @@ function (array $item) use ($doctrine) { }, $validator, $doctrine, - $executionStorage + $executionStorage, ); } } diff --git a/tests/symfony/tests/CountryJobSet.php b/tests/symfony/tests/CountryJobSet.php index 3bfee185..1fbf530a 100644 --- a/tests/symfony/tests/CountryJobSet.php +++ b/tests/symfony/tests/CountryJobSet.php @@ -35,7 +35,7 @@ static function (JobExecution $execution) { 'currency' => 'EUR', 'phone' => '33', ], - $summary + $summary, ); Assert::assertContains( [ @@ -46,7 +46,7 @@ static function (JobExecution $execution) { 'currency' => 'GBP', 'phone' => '44', ], - $summary + $summary, ); // assert written CSV file @@ -55,11 +55,11 @@ static function (JobExecution $execution) { Assert::assertCount(self::COUNT_IN_CSV, $csv); Assert::assertContains( 'FR,FRA,France,EU,EUR,33', - $csv + $csv, ); Assert::assertContains( 'GB,GBR,"United Kingdom",EU,GBP,44', - $csv + $csv, ); // assert written JSONL file @@ -68,11 +68,11 @@ static function (JobExecution $execution) { Assert::assertCount(self::COUNT, $jsonl); Assert::assertContains( '{"iso2":"FR","iso3":"FRA","name":"France","continent":"EU","currency":"EUR","phone":"33"}', - $jsonl + $jsonl, ); Assert::assertContains( '{"iso2":"GB","iso3":"GBR","name":"United Kingdom","continent":"EU","currency":"GBP","phone":"44"}', - $jsonl + $jsonl, ); Assert::assertStringContainsString('log process', $execution->getLogs()->__toString()); }, diff --git a/tests/symfony/tests/JobAssert.php b/tests/symfony/tests/JobAssert.php index 9f5e865b..fe45a5f9 100644 --- a/tests/symfony/tests/JobAssert.php +++ b/tests/symfony/tests/JobAssert.php @@ -22,7 +22,7 @@ public static function assertItemJobStats( int $read, int $processed, int $write, - int $skipped = null + int $skipped = null, ): void { Assert::assertSame($read, $execution->getSummary()->get('read')); Assert::assertSame($processed, $execution->getSummary()->get('processed')); diff --git a/tests/symfony/tests/StarWarsJobSet.php b/tests/symfony/tests/StarWarsJobSet.php index 009bc6cc..08e2fa74 100644 --- a/tests/symfony/tests/StarWarsJobSet.php +++ b/tests/symfony/tests/StarWarsJobSet.php @@ -51,7 +51,7 @@ static function (JobExecution $execution, ContainerInterface $container) { FROM star_wars_character as character LEFT JOIN star_wars_planet homeworld on homeworld.id = character.home_world_id LEFT JOIN star_wars_specie specie on specie.id = character.specie_id - SQL + SQL, )->fetchAllAssociative(); Assert::assertContains( @@ -60,7 +60,7 @@ static function (JobExecution $execution, ContainerInterface $container) { 'homeworld' => 'Tatooine', 'species' => 'Human', ], - $results + $results, ); Assert::assertContains( [ @@ -68,7 +68,7 @@ static function (JobExecution $execution, ContainerInterface $container) { 'homeworld' => null, 'species' => null, ], - $results + $results, ); }, static function (ContainerInterface $container) { diff --git a/tests/symfony/tests/UserInterfaceTest.php b/tests/symfony/tests/UserInterfaceTest.php index 7f3f286e..11192ad3 100644 --- a/tests/symfony/tests/UserInterfaceTest.php +++ b/tests/symfony/tests/UserInterfaceTest.php @@ -147,31 +147,31 @@ static function (string $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 + $content, ); self::assertStringContainsString( 'Job executed successfully {"job":"star-wars.import:planet"', - $content + $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 + $content, ); self::assertStringContainsString( 'Job executed successfully {"job":"star-wars.import:specie"', - $content + $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 + $content, ); self::assertStringContainsString( 'Job executed successfully {"job":"star-wars.import:character"', - $content + $content, ); self::assertStringContainsString('Job executed successfully {"job":"star-wars.import"', $content);