From f6f6826036fa6e2166bc67576e9037e38714d909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Eugon=C3=A9?= Date: Mon, 8 Jan 2024 10:56:29 +0100 Subject: [PATCH] Enhanced code style (#113) * Forbid yoda style condition * Enforce maximum line length * Enforce trailing slash on native functions invocation --- ecs.php | 15 ++++++++++ .../src/DoctrineDBALJobExecutionStorage.php | 20 ++++++------- .../src/JobExecutionRowNormalizer.php | 26 ++++++++-------- .../DoctrineDBALJobExecutionStorageTest.php | 4 +-- .../tests/Dummy/SingleConnectionRegistry.php | 2 +- .../src/ObjectRegistry.php | 8 ++--- .../src/ObjectWriter.php | 6 ++-- .../Dummy/DecoratedRepositoryFactory.php | 4 ++- ...edOnlyOnceWhenFoundRepositoryDecorator.php | 4 +-- .../tests/ObjectRegistryTest.php | 9 ++++-- .../src/Reader/FlatFileReader.php | 8 ++--- .../src/Reader/HeaderStrategy.php | 2 +- .../src/Writer/FlatFileWriter.php | 2 +- .../tests/Reader/FlatFileReaderTest.php | 6 ++-- .../tests/Writer/FlatFileWriterTest.php | 24 +++++++-------- src/batch-openspout/tests/bootstrap.php | 2 +- .../src/CommandRunner.php | 12 ++++---- .../src/RunCommandJobLauncher.php | 2 +- .../src/RunJobCommand.php | 18 +++++------ .../src/DependencyInjection/Configuration.php | 2 +- .../YokaiBatchExtension.php | 8 ++--- .../src/UserInterface/Form/JobFilterType.php | 4 +-- .../YokaiBatchExtensionTest.php | 9 ++++-- .../Controller/JobControllerTest.php | 8 +++-- .../tests/UserInterface/JobSecurityTest.php | 2 +- .../tests/Dummy/DummyNormalizer.php | 7 +++-- .../tests/Dummy/FailingNormalizer.php | 7 +++-- src/batch/src/BatchStatus.php | 2 +- .../CannotRemoveJobExecutionException.php | 2 +- .../CannotStoreJobExecutionException.php | 2 +- .../src/Exception/FilesystemException.php | 10 +++---- .../Exception/ImmutablePropertyException.php | 2 +- .../JobExecutionNotFoundException.php | 2 +- .../src/Exception/UndefinedJobException.php | 2 +- .../UndefinedJobParameterException.php | 2 +- .../Exception/UnexpectedValueException.php | 2 +- src/batch/src/Job/Item/ItemJob.php | 2 +- .../Job/Item/Writer/TransformingWriter.php | 2 +- src/batch/src/Job/JobExecutionAccessor.php | 2 +- src/batch/src/JobExecution.php | 2 +- src/batch/src/JobExecutionLogger.php | 6 ++-- src/batch/src/JobParameters.php | 4 +-- .../Serializer/JsonJobExecutionSerializer.php | 8 ++--- .../Storage/FilesystemJobExecutionStorage.php | 26 ++++++++-------- src/batch/src/Storage/QueryBuilder.php | 14 ++++----- src/batch/src/Summary.php | 4 +-- src/batch/src/Warning.php | 2 +- .../tests/Factory/JobExecutionFactoryTest.php | 8 ++--- src/batch/tests/JobExecutionTest.php | 28 ++++++++--------- src/batch/tests/JobParametersTest.php | 4 +-- .../FilesystemJobExecutionStorageTest.php | 4 +-- src/batch/tests/SummaryTest.php | 2 +- src/batch/tests/bootstrap.php | 2 +- .../integration/Job/SplitDeveloperXlsxJob.php | 10 +++---- tests/integration/JobTestCase.php | 20 ++++++------- .../JobWithDummyItemChildrenTest.php | 4 +-- .../Processor/DeveloperProcessor.php | 4 +-- tests/symfony/tests/StarWarsJobSet.php | 4 +-- tests/symfony/tests/UserInterfaceTest.php | 30 +++++++++++++++---- 59 files changed, 247 insertions(+), 192 deletions(-) diff --git a/ecs.php b/ecs.php index 29e02613..955ba4f8 100644 --- a/ecs.php +++ b/ecs.php @@ -3,10 +3,13 @@ declare(strict_types=1); use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff; +use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer; use PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer; +use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer; 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; @@ -35,10 +38,22 @@ 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, [ 'forbiddenFunctions' => ['dump' => null, 'dd' => null, 'var_dump' => null, 'die' => null], ]); $ecsConfig->ruleWithConfiguration(FunctionDeclarationFixer::class, [ 'closure_fn_spacing' => 'none', ]); + $ecsConfig->ruleWithConfiguration(NativeFunctionInvocationFixer::class, [ + 'scope' => 'namespaced', + 'include' => ['@all'], + ]); }; diff --git a/src/batch-doctrine-dbal/src/DoctrineDBALJobExecutionStorage.php b/src/batch-doctrine-dbal/src/DoctrineDBALJobExecutionStorage.php index 15bfae20..21c8f278 100644 --- a/src/batch-doctrine-dbal/src/DoctrineDBALJobExecutionStorage.php +++ b/src/batch-doctrine-dbal/src/DoctrineDBALJobExecutionStorage.php @@ -44,7 +44,7 @@ final class DoctrineDBALJobExecutionStorage implements */ public function __construct(ConnectionRegistry $doctrine, array $options) { - $options = array_filter($options) + self::DEFAULT_OPTIONS; + $options = \array_filter($options) + self::DEFAULT_OPTIONS; $options['connection'] ??= $doctrine->getDefaultConnectionName(); $this->table = $options['table']; @@ -64,26 +64,26 @@ public function setup(): void fn(string $tableName) => $tableName === $this->table, ); - $schemaManager = method_exists($this->connection, 'createSchemaManager') + $schemaManager = \method_exists($this->connection, 'createSchemaManager') ? $this->connection->createSchemaManager() : $this->connection->getSchemaManager(); - $comparator = method_exists($schemaManager, 'createComparator') + $comparator = \method_exists($schemaManager, 'createComparator') ? $schemaManager->createComparator() : new Comparator(); - $fromSchema = method_exists($schemaManager, 'introspectSchema') + $fromSchema = \method_exists($schemaManager, 'introspectSchema') ? $schemaManager->introspectSchema() : $schemaManager->createSchema(); $toSchema = $this->getSchema(); - $schemaDiff = method_exists($comparator, 'compareSchemas') + $schemaDiff = \method_exists($comparator, 'compareSchemas') ? $comparator->compareSchemas($fromSchema, $toSchema) : $comparator->compare($fromSchema, $toSchema); $platform = $this->connection->getDatabasePlatform(); - $schemaDiffQueries = method_exists($platform, 'getAlterSchemaSQL') + $schemaDiffQueries = \method_exists($platform, 'getAlterSchemaSQL') ? $platform->getAlterSchemaSQL($schemaDiff) : $schemaDiff->toSaveSql($platform); foreach ($schemaDiffQueries as $sql) { - if (method_exists($this->connection, 'executeStatement')) { + if (\method_exists($this->connection, 'executeStatement')) { $this->connection->executeStatement($sql); } else { $this->connection->exec($sql); @@ -155,21 +155,21 @@ public function query(Query $query): iterable ->from($this->table); $names = $query->jobs(); - if (count($names) > 0) { + if (\count($names) > 0) { $qb->andWhere($qb->expr()->in('job_name', ':jobNames')); $queryParameters['jobNames'] = $names; $queryTypes['jobNames'] = Connection::PARAM_STR_ARRAY; } $ids = $query->ids(); - if (count($ids) > 0) { + if (\count($ids) > 0) { $qb->andWhere($qb->expr()->in('id', ':ids')); $queryParameters['ids'] = $ids; $queryTypes['ids'] = Connection::PARAM_STR_ARRAY; } $statuses = $query->statuses(); - if (count($statuses) > 0) { + if (\count($statuses) > 0) { $qb->andWhere($qb->expr()->in('status', ':statuses')); $queryParameters['statuses'] = $statuses; $queryTypes['statuses'] = Connection::PARAM_INT_ARRAY; diff --git a/src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php b/src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php index 23d437fa..7f803db9 100644 --- a/src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php +++ b/src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php @@ -37,13 +37,13 @@ public function toRow(JobExecution $jobExecution): array 'id' => $jobExecution->getId(), 'job_name' => $jobExecution->getJobName(), 'status' => $jobExecution->getStatus()->getValue(), - 'parameters' => iterator_to_array($jobExecution->getParameters()), + 'parameters' => \iterator_to_array($jobExecution->getParameters()), 'start_time' => $jobExecution->getStartTime(), 'end_time' => $jobExecution->getEndTime(), 'summary' => $jobExecution->getSummary()->all(), - 'failures' => array_map([$this, 'failureToArray'], $jobExecution->getFailures()), - 'warnings' => array_map([$this, 'warningToArray'], $jobExecution->getWarnings()), - 'child_executions' => array_map([$this, 'toChildRow'], $jobExecution->getChildExecutions()), + 'failures' => \array_map([$this, 'failureToArray'], $jobExecution->getFailures()), + 'warnings' => \array_map([$this, 'warningToArray'], $jobExecution->getWarnings()), + 'child_executions' => \array_map([$this, 'toChildRow'], $jobExecution->getChildExecutions()), 'logs' => $jobExecution->getParentExecution() === null ? (string)$jobExecution->getLogs() : null, ]; } @@ -55,7 +55,7 @@ public function toRow(JobExecution $jobExecution): array */ public function fromRow(array $data, JobExecution $parent = null): JobExecution { - $data['status'] = intval($data['status']); + $data['status'] = \intval($data['status']); $data['parameters'] = $this->jsonFromString($data['parameters']); $data['summary'] = $this->jsonFromString($data['summary']); $data['failures'] = $this->jsonFromString($data['failures']); @@ -63,7 +63,7 @@ public function fromRow(array $data, JobExecution $parent = null): JobExecution $data['child_executions'] = $this->jsonFromString($data['child_executions']); $name = $data['job_name']; - $status = new BatchStatus(intval($data['status'])); + $status = new BatchStatus(\intval($data['status'])); $parameters = new JobParameters($data['parameters']); $summary = new Summary($data['summary']); @@ -106,13 +106,13 @@ private function toChildRow(JobExecution $jobExecution): array return [ 'job_name' => $jobExecution->getJobName(), 'status' => $jobExecution->getStatus()->getValue(), - 'parameters' => iterator_to_array($jobExecution->getParameters()), + 'parameters' => \iterator_to_array($jobExecution->getParameters()), 'start_time' => $this->toDateString($jobExecution->getStartTime()), 'end_time' => $this->toDateString($jobExecution->getEndTime()), 'summary' => $jobExecution->getSummary()->all(), - 'failures' => array_map([$this, 'failureToArray'], $jobExecution->getFailures()), - 'warnings' => array_map([$this, 'warningToArray'], $jobExecution->getWarnings()), - 'child_executions' => array_map([$this, 'toChildRow'], $jobExecution->getChildExecutions()), + 'failures' => \array_map([$this, 'failureToArray'], $jobExecution->getFailures()), + 'warnings' => \array_map([$this, 'warningToArray'], $jobExecution->getWarnings()), + 'child_executions' => \array_map([$this, 'toChildRow'], $jobExecution->getChildExecutions()), ]; } @@ -123,11 +123,11 @@ private function toChildRow(JobExecution $jobExecution): array */ private function jsonFromString(array|string $value): array { - if (is_string($value)) { - $value = json_decode($value, true, 512, JSON_THROW_ON_ERROR); + if (\is_string($value)) { + $value = \json_decode($value, true, 512, JSON_THROW_ON_ERROR); } - if (!is_array($value)) { + if (!\is_array($value)) { throw UnexpectedValueException::type('array', $value); } diff --git a/src/batch-doctrine-dbal/tests/DoctrineDBALJobExecutionStorageTest.php b/src/batch-doctrine-dbal/tests/DoctrineDBALJobExecutionStorageTest.php index 5a2ecd26..027ad8db 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/Dummy/SingleConnectionRegistry.php b/src/batch-doctrine-dbal/tests/Dummy/SingleConnectionRegistry.php index 5598c0a1..7cf45679 100644 --- a/src/batch-doctrine-dbal/tests/Dummy/SingleConnectionRegistry.php +++ b/src/batch-doctrine-dbal/tests/Dummy/SingleConnectionRegistry.php @@ -27,7 +27,7 @@ public function getConnection($name = null) return $this->connection; } - throw new InvalidArgumentException(sprintf('Doctrine Connection named "%s" does not exist.', $name)); + throw new InvalidArgumentException(\sprintf('Doctrine Connection named "%s" does not exist.', $name)); } public function getConnections() diff --git a/src/batch-doctrine-persistence/src/ObjectRegistry.php b/src/batch-doctrine-persistence/src/ObjectRegistry.php index 8c453eac..b3d5c0fc 100644 --- a/src/batch-doctrine-persistence/src/ObjectRegistry.php +++ b/src/batch-doctrine-persistence/src/ObjectRegistry.php @@ -44,7 +44,7 @@ function ($repository) use ($criteria) { return $repository->findOneBy($criteria); }, - serialize($criteria) + \serialize($criteria) ); } @@ -62,11 +62,11 @@ public function findOneUsing(string $class, \Closure $closure, string $key = nul { $manager = $this->doctrine->getManagerForClass($class); if ($manager === null) { - throw new InvalidArgumentException(sprintf('Class "%s" is not a managed Doctrine entity.', $class)); + throw new InvalidArgumentException(\sprintf('Class "%s" is not a managed Doctrine entity.', $class)); } - $key ??= spl_object_hash($closure); - $key = md5($key); + $key ??= \spl_object_hash($closure); + $key = \md5($key); $identity = $this->identities[$class][$key] ?? null; if ($identity !== null) { diff --git a/src/batch-doctrine-persistence/src/ObjectWriter.php b/src/batch-doctrine-persistence/src/ObjectWriter.php index 697dadd8..a1766c6b 100644 --- a/src/batch-doctrine-persistence/src/ObjectWriter.php +++ b/src/batch-doctrine-persistence/src/ObjectWriter.php @@ -33,7 +33,7 @@ public function __construct( public function write(iterable $items): void { foreach ($items as $item) { - if (!is_object($item)) { + if (!\is_object($item)) { throw $this->createInvalidItemException($item); } @@ -62,7 +62,7 @@ private function getManagerForClass(object $item): ObjectManager $this->managerForClass[$class] = $manager; } - $this->encounteredManagers[spl_object_id($manager)] = $manager; + $this->encounteredManagers[\spl_object_id($manager)] = $manager; return $manager; } @@ -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 0998da20..2fac3b11 100644 --- a/src/batch-doctrine-persistence/tests/Dummy/DecoratedRepositoryFactory.php +++ b/src/batch-doctrine-persistence/tests/Dummy/DecoratedRepositoryFactory.php @@ -26,6 +26,8 @@ public function __construct( public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository { - return $this->repositories[$entityName] ??= new $this->class($this->decorated->getRepository($entityManager, $entityName)); + return $this->repositories[$entityName] ??= new $this->class( + $this->decorated->getRepository($entityManager, $entityName) + ); } } diff --git a/src/batch-doctrine-persistence/tests/Dummy/FindOneByCalledOnlyOnceWhenFoundRepositoryDecorator.php b/src/batch-doctrine-persistence/tests/Dummy/FindOneByCalledOnlyOnceWhenFoundRepositoryDecorator.php index 368a4980..a64c9b22 100644 --- a/src/batch-doctrine-persistence/tests/Dummy/FindOneByCalledOnlyOnceWhenFoundRepositoryDecorator.php +++ b/src/batch-doctrine-persistence/tests/Dummy/FindOneByCalledOnlyOnceWhenFoundRepositoryDecorator.php @@ -37,7 +37,7 @@ public function findOneBy(array $criteria) return null; } - $this->ensureNotCalledAlready(__FUNCTION__, func_get_args()); + $this->ensureNotCalledAlready(__FUNCTION__, \func_get_args()); return $result; } @@ -49,7 +49,7 @@ public function getClassName() private function ensureNotCalledAlready(string $method, array $args): void { - $key = md5($method . $serializedArgs = serialize($args)); + $key = \md5($method . $serializedArgs = \serialize($args)); if (isset($this->calls[$key])) { throw new \LogicException( 'Method ' . $method . ' with args ' . $serializedArgs . ' has already been called' diff --git a/src/batch-doctrine-persistence/tests/ObjectRegistryTest.php b/src/batch-doctrine-persistence/tests/ObjectRegistryTest.php index b74fa7ac..fe51be96 100644 --- a/src/batch-doctrine-persistence/tests/ObjectRegistryTest.php +++ b/src/batch-doctrine-persistence/tests/ObjectRegistryTest.php @@ -59,7 +59,10 @@ public function testFindOneBy(): void self::assertSame($this->lucy, $registry->findOneBy(User::class, ['name' => 'Lucy'])); self::assertNull($registry->findOneBy(User::class, ['name' => 'John'])); - self::assertSame($this->galaxyExplorer, $registry->findOneBy(Product::class, ['name' => 'Galaxy Explorer'])); + self::assertSame( + $this->galaxyExplorer, + $registry->findOneBy(Product::class, ['name' => 'Galaxy Explorer']) + ); self::assertSame($this->boutiqueHotel, $registry->findOneBy(Product::class, ['name' => 'Boutique Hotel'])); self::assertNull($registry->findOneBy(Product::class, ['name' => 'Haunted House'])); } @@ -115,7 +118,9 @@ public function testReset(): void // But here in the test, it is not possible to call the repository more than once // Hence, if we call reset after using the registry at least once, the repository will fail $this->expectException(\LogicException::class); - $this->expectExceptionMessage('Method findOneBy with args a:1:{i:0;a:1:{s:4:"name";s:5:"Emmet";}} has already been called'); + $this->expectExceptionMessage( + 'Method findOneBy with args a:1:{i:0;a:1:{s:4:"name";s:5:"Emmet";}} has already been called' + ); $registry = new ObjectRegistry($this->doctrine); diff --git a/src/batch-openspout/src/Reader/FlatFileReader.php b/src/batch-openspout/src/Reader/FlatFileReader.php index 8eb905db..394f2cc4 100644 --- a/src/batch-openspout/src/Reader/FlatFileReader.php +++ b/src/batch-openspout/src/Reader/FlatFileReader.php @@ -48,7 +48,7 @@ public function read(): iterable { /** @var string $path */ $path = $this->filePath->get($this->jobExecution); - $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); + $extension = \strtolower(\pathinfo($path, PATHINFO_EXTENSION)); $reader = match ($extension) { 'csv' => new CSVReader($this->options), 'xlsx' => new XLSXReader($this->options), @@ -70,11 +70,11 @@ public function read(): iterable } catch (InvalidRowSizeException $exception) { $this->jobExecution->addWarning( new Warning( - sprintf( + \sprintf( 'Expecting row %s to have exactly %d columns(s), but got %d.', $rowIndex, - count($exception->getHeaders()), - count($exception->getRow()), + \count($exception->getHeaders()), + \count($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 df164f6d..380af48c 100644 --- a/src/batch-openspout/src/Reader/HeaderStrategy.php +++ b/src/batch-openspout/src/Reader/HeaderStrategy.php @@ -89,7 +89,7 @@ public function getItem(array $row): array try { /** @var array $combined */ - $combined = @array_combine($this->headers, $row); + $combined = @\array_combine($this->headers, $row); } catch (\ValueError) { throw new InvalidRowSizeException($this->headers, $row); } diff --git a/src/batch-openspout/src/Writer/FlatFileWriter.php b/src/batch-openspout/src/Writer/FlatFileWriter.php index 1e84f9e1..b0df2031 100644 --- a/src/batch-openspout/src/Writer/FlatFileWriter.php +++ b/src/batch-openspout/src/Writer/FlatFileWriter.php @@ -59,7 +59,7 @@ public function initialize(): void throw new RuntimeException(\sprintf('Cannot create dir "%s".', $dir)); } - $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); + $extension = \strtolower(\pathinfo($path, PATHINFO_EXTENSION)); $this->writer = match ($extension) { 'csv' => new CSVWriter($this->options), 'xlsx' => new XLSXWriter($this->options), diff --git a/src/batch-openspout/tests/Reader/FlatFileReaderTest.php b/src/batch-openspout/tests/Reader/FlatFileReaderTest.php index 32626b4f..068d63d3 100644 --- a/src/batch-openspout/tests/Reader/FlatFileReaderTest.php +++ b/src/batch-openspout/tests/Reader/FlatFileReaderTest.php @@ -39,7 +39,7 @@ public function testRead( /** @var \Iterator $got */ $got = $reader->read(); self::assertInstanceOf(\Iterator::class, $got); - self::assertSame($expected, iterator_to_array($got)); + self::assertSame($expected, \iterator_to_array($got)); } public function sets(): Generator @@ -206,7 +206,7 @@ public function testReadWrongLineSize(): void ['firstName' => 'John', 'lastName' => 'Doe'], ['firstName' => 'Jack', 'lastName' => 'Doe'], ], - iterator_to_array($result) + \iterator_to_array($result) ); self::assertSame( @@ -230,7 +230,7 @@ public function testWrongOptions(string $file, object $options): void $reader = new FlatFileReader(new StaticValueParameterAccessor($file), $options); $reader->setJobExecution($jobExecution); - iterator_to_array($reader->read()); + \iterator_to_array($reader->read()); } public function wrongOptions(): \Generator diff --git a/src/batch-openspout/tests/Writer/FlatFileWriterTest.php b/src/batch-openspout/tests/Writer/FlatFileWriterTest.php index 0ff3aa15..c720b1b0 100644 --- a/src/batch-openspout/tests/Writer/FlatFileWriterTest.php +++ b/src/batch-openspout/tests/Writer/FlatFileWriterTest.php @@ -303,11 +303,11 @@ public function wrongOptions(): \Generator private static function assertFileContents(string $filePath, string $inlineData): void { $type = \strtolower(\pathinfo($filePath, PATHINFO_EXTENSION)); - $strings = array_merge(...array_map('str_getcsv', explode(PHP_EOL, $inlineData))); + $strings = \array_merge(...\array_map('str_getcsv', \explode(PHP_EOL, $inlineData))); switch ($type) { case 'csv': - $fileContents = file_get_contents($filePath); + $fileContents = \file_get_contents($filePath); foreach ($strings as $string) { self::assertStringContainsString($string, $fileContents); } @@ -315,15 +315,15 @@ private static function assertFileContents(string $filePath, string $inlineData) case 'xlsx': $pathToSheetFile = $filePath . '#xl/worksheets/sheet1.xml'; - $xmlContents = file_get_contents('zip://' . $pathToSheetFile); + $xmlContents = \file_get_contents('zip://' . $pathToSheetFile); foreach ($strings as $string) { self::assertStringContainsString("$string", $xmlContents); } break; case 'ods': - $sheetContent = file_get_contents('zip://' . $filePath . '#content.xml'); - if (!preg_match('#]+>[\s\S]*?<\/table:table>#', $sheetContent, $matches)) { + $sheetContent = \file_get_contents('zip://' . $filePath . '#content.xml'); + if (!\preg_match('#]+>[\s\S]*?<\/table:table>#', $sheetContent, $matches)) { self::fail('No sheet found in file "' . $filePath . '".'); } $sheetXmlAsString = $matches[0]; @@ -337,32 +337,32 @@ private static function assertFileContents(string $filePath, string $inlineData) private static function assertSheetContents(string $filePath, string $sheet, string $inlineData): void { $type = \strtolower(\pathinfo($filePath, PATHINFO_EXTENSION)); - $strings = array_merge(...array_map('str_getcsv', explode(PHP_EOL, $inlineData))); + $strings = \array_merge(...\array_map('str_getcsv', \explode(PHP_EOL, $inlineData))); switch ($type) { case 'csv': - $fileContents = file_get_contents($filePath); + $fileContents = \file_get_contents($filePath); foreach ($strings as $string) { self::assertStringContainsString($string, $fileContents); } break; case 'xlsx': - $workbookContent = file_get_contents('zip://' . $filePath . '#xl/workbook.xml'); - if (!preg_match('#$string", $sheetContent); } break; case 'ods': - $sheetContent = file_get_contents('zip://' . $filePath . '#content.xml'); + $sheetContent = \file_get_contents('zip://' . $filePath . '#content.xml'); $regex = '#[\s\S]*?<\/table:table>#'; - if (!preg_match($regex, $sheetContent, $matches)) { + if (!\preg_match($regex, $sheetContent, $matches)) { self::fail('Sheet ' . $sheet . ' was not found in file "' . $filePath . '".'); } $sheetXmlAsString = $matches[0]; diff --git a/src/batch-openspout/tests/bootstrap.php b/src/batch-openspout/tests/bootstrap.php index 6dc2ab0c..378319f4 100644 --- a/src/batch-openspout/tests/bootstrap.php +++ b/src/batch-openspout/tests/bootstrap.php @@ -9,7 +9,7 @@ require_once __DIR__ . '/../vendor/autoload.php'; $artifactDir = @getenv('ARTIFACT_DIR'); -if (false === $artifactDir) { +if ($artifactDir === false) { throw new \LogicException('Missing "ARTIFACT_DIR" env var.'); } diff --git a/src/batch-symfony-console/src/CommandRunner.php b/src/batch-symfony-console/src/CommandRunner.php index 029a0045..ecf1e0eb 100644 --- a/src/batch-symfony-console/src/CommandRunner.php +++ b/src/batch-symfony-console/src/CommandRunner.php @@ -20,8 +20,8 @@ public function __construct( private string $logDir, PhpExecutableFinder $phpLocator = null, ) { - $this->consolePath = implode(DIRECTORY_SEPARATOR, [$binDir, 'console']); - if (class_exists(PhpExecutableFinder::class)) { + $this->consolePath = \implode(DIRECTORY_SEPARATOR, [$binDir, 'console']); + if (\class_exists(PhpExecutableFinder::class)) { $phpLocator ??= new PhpExecutableFinder(); } $this->phpLocator = $phpLocator; @@ -35,10 +35,10 @@ public function __construct( public function runAsync(string $commandName, string $logFilename, array $arguments = []): void { $this->exec( - sprintf( + \sprintf( '%s >> %s 2>&1 &', $this->buildCommand($commandName, $arguments), - implode(DIRECTORY_SEPARATOR, [$this->logDir, $logFilename]) + \implode(DIRECTORY_SEPARATOR, [$this->logDir, $logFilename]) ) ); } @@ -48,7 +48,7 @@ public function runAsync(string $commandName, string $logFilename, array $argume */ protected function exec(string $command): void { - exec($command); + \exec($command); } /** @@ -56,7 +56,7 @@ protected function exec(string $command): void */ private function buildCommand(string $commandName, array $arguments): string { - return sprintf( + return \sprintf( '%s %s %s %s', $this->phpLocator ? $this->phpLocator->find() : 'php', $this->consolePath, diff --git a/src/batch-symfony-console/src/RunCommandJobLauncher.php b/src/batch-symfony-console/src/RunCommandJobLauncher.php index 59d6963c..4457314c 100644 --- a/src/batch-symfony-console/src/RunCommandJobLauncher.php +++ b/src/batch-symfony-console/src/RunCommandJobLauncher.php @@ -40,7 +40,7 @@ public function launch(string $name, array $configuration = []): JobExecution $this->logFilename, [ 'job' => $name, - 'configuration' => json_encode($configuration, JSON_THROW_ON_ERROR), + 'configuration' => \json_encode($configuration, JSON_THROW_ON_ERROR), ] ); diff --git a/src/batch-symfony-console/src/RunJobCommand.php b/src/batch-symfony-console/src/RunJobCommand.php index 69c5b3c0..8538ea44 100644 --- a/src/batch-symfony-console/src/RunJobCommand.php +++ b/src/batch-symfony-console/src/RunJobCommand.php @@ -62,7 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function guessExecutionExitCode(JobExecution $jobExecution): int { if ($jobExecution->getStatus()->is(BatchStatus::COMPLETED)) { - if (count($jobExecution->getAllWarnings()) === 0) { + if (\count($jobExecution->getAllWarnings()) === 0) { return self::EXIT_SUCCESS_CODE; } @@ -77,21 +77,21 @@ private function outputExecution(JobExecution $jobExecution, OutputInterface $ou $jobName = $jobExecution->getJobName(); if ($jobExecution->getStatus()->is(BatchStatus::COMPLETED)) { $warnings = $jobExecution->getAllWarnings(); - if (count($warnings)) { + if (\count($warnings)) { foreach ($warnings as $warning) { - $output->writeln(sprintf('%s', $warning), $output::VERBOSITY_VERBOSE); + $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)); + $output->writeln(\sprintf('%s has been successfully executed.', $jobName)); } } else { - $output->writeln(sprintf('An error occurred during the %s execution.', $jobName)); + $output->writeln(\sprintf('An error occurred during the %s execution.', $jobName)); foreach ($jobExecution->getAllFailures() as $failure) { $output->writeln( - sprintf( + \sprintf( 'Error #%s of class %s: %s', $failure->getCode(), $failure->getClass(), @@ -99,7 +99,7 @@ private function outputExecution(JobExecution $jobExecution, OutputInterface $ou ) ); if ($failure->getTrace() !== null) { - $output->writeln(sprintf('%s', $failure->getTrace()), $output::VERBOSITY_VERBOSE); + $output->writeln(\sprintf('%s', $failure->getTrace()), $output::VERBOSITY_VERBOSE); } } } @@ -112,7 +112,7 @@ private function outputExecution(JobExecution $jobExecution, OutputInterface $ou */ private function decodeConfiguration(string $data): array { - $config = json_decode($data, true, 512, \JSON_THROW_ON_ERROR); + $config = \json_decode($data, true, 512, \JSON_THROW_ON_ERROR); if (\is_array($config)) { return $config; } diff --git a/src/batch-symfony-framework/src/DependencyInjection/Configuration.php b/src/batch-symfony-framework/src/DependencyInjection/Configuration.php index 7b9a5191..92e1779b 100644 --- a/src/batch-symfony-framework/src/DependencyInjection/Configuration.php +++ b/src/batch-symfony-framework/src/DependencyInjection/Configuration.php @@ -110,7 +110,7 @@ private function ui(): ArrayNodeDefinition ->addDefaultsIfNotSet() ->beforeNormalization() ->always(function (string|array $value) { - if (is_string($value)) { + if (\is_string($value)) { $value = match ($value) { 'bootstrap4' => ['prefix' => '@YokaiBatch/bootstrap4', 'service' => null], 'sonata' => ['service' => 'yokai_batch.ui.sonata_templating', 'prefix' => null], diff --git a/src/batch-symfony-framework/src/DependencyInjection/YokaiBatchExtension.php b/src/batch-symfony-framework/src/DependencyInjection/YokaiBatchExtension.php index d5bd9af5..7f269e1b 100644 --- a/src/batch-symfony-framework/src/DependencyInjection/YokaiBatchExtension.php +++ b/src/batch-symfony-framework/src/DependencyInjection/YokaiBatchExtension.php @@ -56,7 +56,7 @@ public function load(array $configs, ContainerBuilder $container): void 'symfony/validator/' => $this->installed('symfony-validator'), ]; - foreach (array_keys(array_filter($bridges)) as $resource) { + foreach (\array_keys(\array_filter($bridges)) as $resource) { $loader->load($resource); } @@ -127,7 +127,7 @@ private function configureStorage(ContainerBuilder $container, array $config): v $defaultStorageDefinition = $container->getDefinition($defaultStorage); } catch (ServiceNotFoundException $exception) { throw new LogicException( - sprintf('Configured default job execution storage service "%s" does not exists.', $defaultStorage), + \sprintf('Configured default job execution storage service "%s" does not exists.', $defaultStorage), 0, $exception ); @@ -146,7 +146,7 @@ private function configureStorage(ContainerBuilder $container, array $config): v QueryableJobExecutionStorageInterface::class => false, ]; foreach ($interfaces as $interface => $required) { - if (!is_a($defaultStorageClass, $interface, true)) { + if (!\is_a($defaultStorageClass, $interface, true)) { if ($required) { throw new LogicException( \sprintf( @@ -207,7 +207,7 @@ private function configureUserInterface(ContainerBuilder $container, LoaderInter } } catch (ServiceNotFoundException $exception) { throw new LogicException( - sprintf('Configured UI templating service "%s" does not exists.', $templating['service']), + \sprintf('Configured UI templating service "%s" does not exists.', $templating['service']), 0, $exception ); diff --git a/src/batch-symfony-framework/src/UserInterface/Form/JobFilterType.php b/src/batch-symfony-framework/src/UserInterface/Form/JobFilterType.php index fb62fc77..2b8daccb 100644 --- a/src/batch-symfony-framework/src/UserInterface/Form/JobFilterType.php +++ b/src/batch-symfony-framework/src/UserInterface/Form/JobFilterType.php @@ -39,7 +39,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ChoiceType::class, [ 'label' => 'job.field.job_name', - 'choice_label' => fn($choice, string $key, $value) => sprintf('job.job_name.%s', $key), + 'choice_label' => fn($choice, string $key, $value) => \sprintf('job.job_name.%s', $key), 'choices' => \array_combine($this->jobs, $this->jobs), 'required' => false, 'multiple' => true, @@ -50,7 +50,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ChoiceType::class, [ 'label' => 'job.field.status', - 'choice_label' => fn($choice, string $key, $value) => sprintf('job.status.%s', $key), + 'choice_label' => fn($choice, string $key, $value) => \sprintf('job.status.%s', $key), 'choices' => self::STATUSES, 'required' => false, 'multiple' => true, diff --git a/src/batch-symfony-framework/tests/DependencyInjection/YokaiBatchExtensionTest.php b/src/batch-symfony-framework/tests/DependencyInjection/YokaiBatchExtensionTest.php index 602ea076..85ba6539 100644 --- a/src/batch-symfony-framework/tests/DependencyInjection/YokaiBatchExtensionTest.php +++ b/src/batch-symfony-framework/tests/DependencyInjection/YokaiBatchExtensionTest.php @@ -22,8 +22,13 @@ class YokaiBatchExtensionTest extends TestCase /** * @dataProvider configs */ - public function test(array $config, ?callable $configure, string $storage, ?callable $templating, ?array $security): void - { + public function test( + array $config, + ?callable $configure, + string $storage, + ?callable $templating, + ?array $security + ): void { $container = new ContainerBuilder(); if ($configure !== null) { $configure($container); diff --git a/src/batch-symfony-framework/tests/UserInterface/Controller/JobControllerTest.php b/src/batch-symfony-framework/tests/UserInterface/Controller/JobControllerTest.php index ca023e34..d0775f5e 100644 --- a/src/batch-symfony-framework/tests/UserInterface/Controller/JobControllerTest.php +++ b/src/batch-symfony-framework/tests/UserInterface/Controller/JobControllerTest.php @@ -234,7 +234,9 @@ public static function view(): \Generator new JobParameters(['type' => 'complete']), new Summary(['count' => 156]), ); - $exportExecution->addWarning(new Warning('Skipped suspicious record', [], ['suspicious_record' => 2])); + $exportExecution->addWarning( + new Warning('Skipped suspicious record', [], ['suspicious_record' => 2]) + ); $exportExecution->addFailure(new Failure('RuntimeException', 'Missing record #2', 0)); $exportExecution->setStartTime(new \DateTimeImmutable('2021-01-01 10:00')); $exportExecution->setEndTime(new \DateTimeImmutable('2021-01-01 11:00')); @@ -516,7 +518,9 @@ private static function fixtures(int $count, array $attributes = []): void BatchStatus::FAILED, ])), 'startTime' => $start = (new \DateTimeImmutable())->setTimestamp(\random_int(0, \time() - 10)), - 'endTime' => (new \DateTimeImmutable())->setTimestamp(\random_int($start->getTimestamp(), \time() - 10)), + 'endTime' => (new \DateTimeImmutable())->setTimestamp( + \random_int($start->getTimestamp(), \time() - 10) + ), ], $attributes, ); diff --git a/src/batch-symfony-framework/tests/UserInterface/JobSecurityTest.php b/src/batch-symfony-framework/tests/UserInterface/JobSecurityTest.php index d8c6aaa5..cc753cdb 100644 --- a/src/batch-symfony-framework/tests/UserInterface/JobSecurityTest.php +++ b/src/batch-symfony-framework/tests/UserInterface/JobSecurityTest.php @@ -41,7 +41,7 @@ public function __construct(private array $attributes) public function isGranted(mixed $attribute, mixed $subject = null): bool { - return in_array($attribute, $this->attributes, true) + return \in_array($attribute, $this->attributes, true) && ($subject === null || $subject instanceof JobExecution); } }; diff --git a/src/batch-symfony-serializer/tests/Dummy/DummyNormalizer.php b/src/batch-symfony-serializer/tests/Dummy/DummyNormalizer.php index 2594bb69..6d91935f 100644 --- a/src/batch-symfony-serializer/tests/Dummy/DummyNormalizer.php +++ b/src/batch-symfony-serializer/tests/Dummy/DummyNormalizer.php @@ -20,8 +20,11 @@ public function supportsNormalization(mixed $data, string $format = null, array return $this->supports; } - public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null - { + public function normalize( + mixed $object, + string $format = null, + array $context = [] + ): array|string|int|float|bool|\ArrayObject|null { return $this->value; } diff --git a/src/batch-symfony-serializer/tests/Dummy/FailingNormalizer.php b/src/batch-symfony-serializer/tests/Dummy/FailingNormalizer.php index a589f292..231711a7 100644 --- a/src/batch-symfony-serializer/tests/Dummy/FailingNormalizer.php +++ b/src/batch-symfony-serializer/tests/Dummy/FailingNormalizer.php @@ -20,8 +20,11 @@ public function supportsNormalization(mixed $data, string $format = null, array return true; } - public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null - { + public function normalize( + mixed $object, + string $format = null, + array $context = [] + ): array|string|int|float|bool|\ArrayObject|null { throw $this->exception; } diff --git a/src/batch/src/BatchStatus.php b/src/batch/src/BatchStatus.php index f1cbd7d2..a0145a18 100644 --- a/src/batch/src/BatchStatus.php +++ b/src/batch/src/BatchStatus.php @@ -89,7 +89,7 @@ public function is(int $value): bool */ public function isOneOf(array $values): bool { - return in_array($this->value, $values, true); + return \in_array($this->value, $values, true); } /** diff --git a/src/batch/src/Exception/CannotRemoveJobExecutionException.php b/src/batch/src/Exception/CannotRemoveJobExecutionException.php index 421316c5..36e8e860 100644 --- a/src/batch/src/Exception/CannotRemoveJobExecutionException.php +++ b/src/batch/src/Exception/CannotRemoveJobExecutionException.php @@ -11,7 +11,7 @@ class CannotRemoveJobExecutionException extends RuntimeException public function __construct(string $jobName, string $executionId, Throwable $previous = null) { parent::__construct( - sprintf('Cannot remove job execution "%s" of job "%s"', $executionId, $jobName), + \sprintf('Cannot remove job execution "%s" of job "%s"', $executionId, $jobName), $previous ); } diff --git a/src/batch/src/Exception/CannotStoreJobExecutionException.php b/src/batch/src/Exception/CannotStoreJobExecutionException.php index 584957f8..434336ce 100644 --- a/src/batch/src/Exception/CannotStoreJobExecutionException.php +++ b/src/batch/src/Exception/CannotStoreJobExecutionException.php @@ -11,7 +11,7 @@ class CannotStoreJobExecutionException extends RuntimeException public function __construct(string $jobName, string $executionId, Throwable $previous = null) { parent::__construct( - sprintf('Cannot store job execution "%s" of job "%s"', $executionId, $jobName), + \sprintf('Cannot store job execution "%s" of job "%s"', $executionId, $jobName), $previous ); } diff --git a/src/batch/src/Exception/FilesystemException.php b/src/batch/src/Exception/FilesystemException.php index 3c6be4f8..2bc9bab5 100644 --- a/src/batch/src/Exception/FilesystemException.php +++ b/src/batch/src/Exception/FilesystemException.php @@ -8,26 +8,26 @@ class FilesystemException extends RuntimeException { public static function cannotCreateDir(string $path): self { - return new self(sprintf('Cannot create dir "%s".', $path)); + return new self(\sprintf('Cannot create dir "%s".', $path)); } public static function cannotReadFile(string $path): self { - return new self(sprintf('Cannot read "%s" file content.', $path)); + return new self(\sprintf('Cannot read "%s" file content.', $path)); } public static function cannotWriteFile(string $path): self { - return new self(sprintf('Cannot write content to file "%s".', $path)); + return new self(\sprintf('Cannot write content to file "%s".', $path)); } public static function cannotRemoveFile(string $path): self { - return new self(sprintf('Unable to remove file "%s".', $path)); + return new self(\sprintf('Unable to remove file "%s".', $path)); } public static function fileNotFound(string $path): self { - return new self(sprintf('File "%s" does not exists.', $path)); + return new self(\sprintf('File "%s" does not exists.', $path)); } } diff --git a/src/batch/src/Exception/ImmutablePropertyException.php b/src/batch/src/Exception/ImmutablePropertyException.php index 63de39de..a42d92c8 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 c853c51c..1282cdac 100644 --- a/src/batch/src/Exception/JobExecutionNotFoundException.php +++ b/src/batch/src/Exception/JobExecutionNotFoundException.php @@ -11,7 +11,7 @@ class JobExecutionNotFoundException extends \InvalidArgumentException implements public function __construct(string $jobName, string $executionId, Throwable $previous = null) { parent::__construct( - sprintf('Job execution "%s" of job "%s" cannot be found', $executionId, $jobName), + \sprintf('Job execution "%s" of job "%s" cannot be found', $executionId, $jobName), 0, $previous ); diff --git a/src/batch/src/Exception/UndefinedJobException.php b/src/batch/src/Exception/UndefinedJobException.php index ba985c38..a868ec8e 100644 --- a/src/batch/src/Exception/UndefinedJobException.php +++ b/src/batch/src/Exception/UndefinedJobException.php @@ -10,6 +10,6 @@ class UndefinedJobException extends InvalidArgumentException { public function __construct(string $name, Throwable $previous = null) { - parent::__construct(sprintf('Job "%s" is undefined', $name), $previous); + parent::__construct(\sprintf('Job "%s" is undefined', $name), $previous); } } diff --git a/src/batch/src/Exception/UndefinedJobParameterException.php b/src/batch/src/Exception/UndefinedJobParameterException.php index 96c9af36..953fed2e 100644 --- a/src/batch/src/Exception/UndefinedJobParameterException.php +++ b/src/batch/src/Exception/UndefinedJobParameterException.php @@ -8,6 +8,6 @@ class UndefinedJobParameterException extends InvalidArgumentException { public function __construct(string $name) { - parent::__construct(sprintf('Parameter "%s" is undefined', $name)); + parent::__construct(\sprintf('Parameter "%s" is undefined', $name)); } } diff --git a/src/batch/src/Exception/UnexpectedValueException.php b/src/batch/src/Exception/UnexpectedValueException.php index b49dd582..02306dd0 100644 --- a/src/batch/src/Exception/UnexpectedValueException.php +++ b/src/batch/src/Exception/UnexpectedValueException.php @@ -45,7 +45,7 @@ public static function date(string $expected, mixed $argument, string $message = { return new self( $message, - sprintf( + \sprintf( 'Expecting a date with format "%s". Got "%s"', $expected, \is_scalar($argument) ? $argument : \get_debug_type($argument) diff --git a/src/batch/src/Job/Item/ItemJob.php b/src/batch/src/Job/Item/ItemJob.php index a23b0932..807feada 100644 --- a/src/batch/src/Job/Item/ItemJob.php +++ b/src/batch/src/Job/Item/ItemJob.php @@ -77,7 +77,7 @@ final public function execute(JobExecution $jobExecution): void $itemsToWrite[] = $item; $writeCount++; - if (0 === $writeCount % $this->batchSize) { + if ($writeCount % $this->batchSize === 0) { $this->writer->write($itemsToWrite); $summary->increment('write', $writeCount); $itemsToWrite = []; diff --git a/src/batch/src/Job/Item/Writer/TransformingWriter.php b/src/batch/src/Job/Item/Writer/TransformingWriter.php index 22fc5427..1b56c7a5 100644 --- a/src/batch/src/Job/Item/Writer/TransformingWriter.php +++ b/src/batch/src/Job/Item/Writer/TransformingWriter.php @@ -60,7 +60,7 @@ public function write(iterable $items): void } } - if (count($transformedItems) > 0) { + if (\count($transformedItems) > 0) { $this->writer->write($transformedItems); } } diff --git a/src/batch/src/Job/JobExecutionAccessor.php b/src/batch/src/Job/JobExecutionAccessor.php index 24d83c69..4e5737e3 100644 --- a/src/batch/src/Job/JobExecutionAccessor.php +++ b/src/batch/src/Job/JobExecutionAccessor.php @@ -30,7 +30,7 @@ public function __construct( public function get(string $name, array $configuration): JobExecution { $id = $configuration['_id'] ?? null; - if (is_string($id)) { + if (\is_string($id)) { try { return $this->jobExecutionStorage->retrieve($name, $id); } catch (JobExecutionNotFoundException) { diff --git a/src/batch/src/JobExecution.php b/src/batch/src/JobExecution.php index c8f65015..5160d107 100644 --- a/src/batch/src/JobExecution.php +++ b/src/batch/src/JobExecution.php @@ -249,7 +249,7 @@ public function getRootExecution(): JobExecution */ public function getChildExecutions(): array { - return array_values($this->childExecutions); + return \array_values($this->childExecutions); } /** diff --git a/src/batch/src/JobExecutionLogger.php b/src/batch/src/JobExecutionLogger.php index 0f428b39..f168bb43 100644 --- a/src/batch/src/JobExecutionLogger.php +++ b/src/batch/src/JobExecutionLogger.php @@ -45,19 +45,19 @@ public function __construct( public function log($level, $message, array $context = []): void { $this->logs->log( - sprintf( + \sprintf( '[%s] %s: %s %s', $this->date(), self::LEVELS[$level] ?? '', $message, - json_encode($context, JSON_THROW_ON_ERROR) + \json_encode($context, JSON_THROW_ON_ERROR) ) ); } private function date(): string { - self::$timezone ??= new DateTimeZone(date_default_timezone_get() ?: 'UTC'); + self::$timezone ??= new DateTimeZone(\date_default_timezone_get() ?: 'UTC'); $date = new DateTime('now', self::$timezone); $date->setTimezone(self::$timezone); diff --git a/src/batch/src/JobParameters.php b/src/batch/src/JobParameters.php index a1f5168b..8df3936e 100644 --- a/src/batch/src/JobParameters.php +++ b/src/batch/src/JobParameters.php @@ -44,7 +44,7 @@ public function all(): array */ public function has(string $name): bool { - return array_key_exists($name, $this->parameters); + return \array_key_exists($name, $this->parameters); } /** @@ -63,7 +63,7 @@ public function get(string $name): mixed public function count(): int { - return count($this->parameters); + return \count($this->parameters); } /** diff --git a/src/batch/src/Serializer/JsonJobExecutionSerializer.php b/src/batch/src/Serializer/JsonJobExecutionSerializer.php index 7ecee368..24078314 100644 --- a/src/batch/src/Serializer/JsonJobExecutionSerializer.php +++ b/src/batch/src/Serializer/JsonJobExecutionSerializer.php @@ -70,13 +70,13 @@ private function toArray(JobExecution $jobExecution): array 'id' => $jobExecution->getId(), 'jobName' => $jobExecution->getJobName(), 'status' => $jobExecution->getStatus()->getValue(), - 'parameters' => iterator_to_array($jobExecution->getParameters()), + 'parameters' => \iterator_to_array($jobExecution->getParameters()), 'startTime' => $this->dateToString($jobExecution->getStartTime()), 'endTime' => $this->dateToString($jobExecution->getEndTime()), 'summary' => $jobExecution->getSummary()->all(), - 'failures' => array_map([$this, 'failureToArray'], $jobExecution->getFailures()), - 'warnings' => array_map([$this, 'warningToArray'], $jobExecution->getWarnings()), - 'childExecutions' => array_map([$this, 'toArray'], $jobExecution->getChildExecutions()), + 'failures' => \array_map([$this, 'failureToArray'], $jobExecution->getFailures()), + 'warnings' => \array_map([$this, 'warningToArray'], $jobExecution->getWarnings()), + 'childExecutions' => \array_map([$this, 'toArray'], $jobExecution->getChildExecutions()), 'logs' => $jobExecution->getParentExecution() === null ? (string)$jobExecution->getLogs() : '', ]; } diff --git a/src/batch/src/Storage/FilesystemJobExecutionStorage.php b/src/batch/src/Storage/FilesystemJobExecutionStorage.php index 02505682..1a7646a7 100644 --- a/src/batch/src/Storage/FilesystemJobExecutionStorage.php +++ b/src/batch/src/Storage/FilesystemJobExecutionStorage.php @@ -48,10 +48,10 @@ public function remove(JobExecution $execution): void { try { $path = $this->buildFilePath($execution->getJobName(), $execution->getId()); - if (!file_exists($path)) { + if (!\file_exists($path)) { throw FilesystemException::fileNotFound($path); } - if (!@unlink($path)) { + if (!@\unlink($path)) { throw FilesystemException::cannotRemoveFile($path); } } catch (Throwable $exception) { @@ -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) { @@ -99,17 +99,17 @@ public function query(Query $query): iterable } $names = $query->jobs(); - if (count($names) > 0 && !in_array($execution->getJobName(), $names, true)) { + if (\count($names) > 0 && !\in_array($execution->getJobName(), $names, true)) { continue; } $ids = $query->ids(); - if (count($ids) > 0 && !in_array($execution->getId(), $ids, true)) { + if (\count($ids) > 0 && !\in_array($execution->getId(), $ids, true)) { continue; } $statuses = $query->statuses(); - if (count($statuses) > 0 && !$execution->getStatus()->isOneOf($statuses)) { + if (\count($statuses) > 0 && !$execution->getStatus()->isOneOf($statuses)) { continue; } @@ -133,36 +133,36 @@ public function query(Query $query): iterable }; if ($order) { - uasort($candidates, $order); + \uasort($candidates, $order); } - return array_slice($candidates, $query->offset(), $query->limit()); + return \array_slice($candidates, $query->offset(), $query->limit()); } private function buildFilePath(string $jobName, string $executionId): string { - return implode(DIRECTORY_SEPARATOR, [$this->directory, $jobName, $executionId]) . + return \implode(DIRECTORY_SEPARATOR, [$this->directory, $jobName, $executionId]) . '.' . $this->serializer->extension(); } private function executionToFile(JobExecution $execution): void { $path = $this->buildFilePath($execution->getJobName(), $execution->getId()); - $dir = dirname($path); - if (!is_dir($dir) && false === @mkdir($dir, 0777, true)) { + $dir = \dirname($path); + if (!\is_dir($dir) && @\mkdir($dir, 0777, true) === false) { throw FilesystemException::cannotCreateDir($path); } $content = $this->serializer->serialize($execution); - if (false === @file_put_contents($path, $content)) { + if (@\file_put_contents($path, $content) === false) { throw FilesystemException::cannotWriteFile($path); } } private function fileToExecution(string $file): JobExecution { - $content = @file_get_contents($file); + $content = @\file_get_contents($file); if ($content === false) { throw FilesystemException::cannotReadFile($file); } diff --git a/src/batch/src/Storage/QueryBuilder.php b/src/batch/src/Storage/QueryBuilder.php index 82bb6296..c2602b7a 100644 --- a/src/batch/src/Storage/QueryBuilder.php +++ b/src/batch/src/Storage/QueryBuilder.php @@ -76,9 +76,9 @@ final class QueryBuilder */ public function jobs(array $names): self { - $names = array_unique($names); + $names = \array_unique($names); foreach ($names as $name) { - if (!is_string($name)) { + if (!\is_string($name)) { throw UnexpectedValueException::type('string', $name); } } @@ -95,9 +95,9 @@ public function jobs(array $names): self */ public function ids(array $ids): self { - $ids = array_unique($ids); + $ids = \array_unique($ids); foreach ($ids as $id) { - if (!is_string($id)) { + if (!\is_string($id)) { throw UnexpectedValueException::type('string', $id); } } @@ -114,9 +114,9 @@ public function ids(array $ids): self */ public function statuses(array $statuses): self { - $statuses = array_unique($statuses); + $statuses = \array_unique($statuses); foreach ($statuses as $status) { - if (!in_array($status, self::STATUSES_ENUM, true)) { + if (!\in_array($status, self::STATUSES_ENUM, true)) { throw UnexpectedValueException::enum(self::STATUSES_ENUM, $status); } } @@ -133,7 +133,7 @@ public function statuses(array $statuses): self */ public function sort(string $by): self { - if (!in_array($by, self::SORTS_ENUM, true)) { + if (!\in_array($by, self::SORTS_ENUM, true)) { throw UnexpectedValueException::enum(self::SORTS_ENUM, $by); } diff --git a/src/batch/src/Summary.php b/src/batch/src/Summary.php index d881aaa4..c38d66aa 100644 --- a/src/batch/src/Summary.php +++ b/src/batch/src/Summary.php @@ -73,7 +73,7 @@ public function get(string $key): mixed */ public function has(string $key): bool { - return array_key_exists($key, $this->values); + return \array_key_exists($key, $this->values); } /** @@ -104,6 +104,6 @@ public function getIterator(): ArrayIterator public function count(): int { - return count($this->values); + return \count($this->values); } } diff --git a/src/batch/src/Warning.php b/src/batch/src/Warning.php index 9acd651c..ef462417 100644 --- a/src/batch/src/Warning.php +++ b/src/batch/src/Warning.php @@ -31,7 +31,7 @@ public function __construct( public function __toString(): string { - return strtr($this->message, $this->parameters); + return \strtr($this->message, $this->parameters); } public function getMessage(): string diff --git a/src/batch/tests/Factory/JobExecutionFactoryTest.php b/src/batch/tests/Factory/JobExecutionFactoryTest.php index fb94cbd7..894fd87a 100644 --- a/src/batch/tests/Factory/JobExecutionFactoryTest.php +++ b/src/batch/tests/Factory/JobExecutionFactoryTest.php @@ -19,7 +19,7 @@ public function testCreate(): void self::assertSame('export', $executionWithoutConfig->getJobName()); self::assertSame( ['_id' => $executionWithoutConfig->getId()], - iterator_to_array($executionWithoutConfig->getParameters()) + \iterator_to_array($executionWithoutConfig->getParameters()) ); $this->assertExecutionIsEmpty($executionWithoutConfig); @@ -28,7 +28,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); @@ -36,14 +36,14 @@ 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); } private function assertExecutionIsEmpty(JobExecution $jobExecution): void { - self::assertSame([], iterator_to_array($jobExecution->getSummary())); + self::assertSame([], \iterator_to_array($jobExecution->getSummary())); self::assertSame([], $jobExecution->getChildExecutions()); self::assertNull($jobExecution->getStartTime()); self::assertNull($jobExecution->getEndTime()); diff --git a/src/batch/tests/JobExecutionTest.php b/src/batch/tests/JobExecutionTest.php index 45c9fe29..a616bc53 100644 --- a/src/batch/tests/JobExecutionTest.php +++ b/src/batch/tests/JobExecutionTest.php @@ -138,25 +138,25 @@ public function testManipulatesFailures() $failureToString = fn(Failure $failure): string => (string)$failure; $jobExecution = JobExecution::createRoot('123456789', 'export'); - self::assertSame([], array_map($failureMessage, $jobExecution->getFailures())); - self::assertSame([], array_map($failureMessage, $jobExecution->getAllFailures())); + self::assertSame([], \array_map($failureMessage, $jobExecution->getFailures())); + self::assertSame([], \array_map($failureMessage, $jobExecution->getAllFailures())); $jobExecution->addFailureException(new \Exception('Job Failure')); - self::assertSame(['Job Failure'], array_map($failureMessage, $jobExecution->getFailures())); - self::assertSame(['Job Failure'], array_map($failureMessage, $jobExecution->getAllFailures())); + self::assertSame(['Job Failure'], \array_map($failureMessage, $jobExecution->getFailures())); + self::assertSame(['Job Failure'], \array_map($failureMessage, $jobExecution->getAllFailures())); $jobExecution->addChildExecution($prepareJobExecution = $jobExecution->createChildExecution('prepare')); $jobExecution->addChildExecution($exportJobExecution = $jobExecution->createChildExecution('export')); $prepareJobExecution->addFailureException(new \Exception('Prepare Job Failure')); $exportJobExecution->addFailureException(new \Exception('Export Job Failure')); - self::assertSame(['Job Failure'], array_map($failureMessage, $jobExecution->getFailures())); + 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(); @@ -171,25 +171,25 @@ public function testManipulatesWarnings() $warningToString = fn(Warning $warning): string => (string)$warning; $jobExecution = JobExecution::createRoot('123456789', 'export'); - self::assertSame([], array_map($warningMessage, $jobExecution->getWarnings())); - self::assertSame([], array_map($warningMessage, $jobExecution->getAllWarnings())); + self::assertSame([], \array_map($warningMessage, $jobExecution->getWarnings())); + self::assertSame([], \array_map($warningMessage, $jobExecution->getAllWarnings())); $jobExecution->addWarning(new Warning('Job Warning', [], ['foo' => 'FOO'])); - self::assertSame(['Job Warning'], array_map($warningMessage, $jobExecution->getWarnings())); - self::assertSame(['Job Warning'], array_map($warningMessage, $jobExecution->getAllWarnings())); + self::assertSame(['Job Warning'], \array_map($warningMessage, $jobExecution->getWarnings())); + self::assertSame(['Job Warning'], \array_map($warningMessage, $jobExecution->getAllWarnings())); $jobExecution->addChildExecution($prepareChildExecution = $jobExecution->createChildExecution('prepare')); $jobExecution->addChildExecution($exportChildExecution = $jobExecution->createChildExecution('export')); $prepareChildExecution->addWarning(new Warning('Prepare Job Warning')); $exportChildExecution->addWarning(new Warning('Export Job Warning', [], ['bar' => 'BAR'])); - self::assertSame(['Job Warning'], array_map($warningMessage, $jobExecution->getWarnings())); + 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(); diff --git a/src/batch/tests/JobParametersTest.php b/src/batch/tests/JobParametersTest.php index 3595e0e1..f1cde5b9 100644 --- a/src/batch/tests/JobParametersTest.php +++ b/src/batch/tests/JobParametersTest.php @@ -67,10 +67,10 @@ public function testAll(): void public function testGetIterator(): void { - self::assertSame([], iterator_to_array(new JobParameters())); + 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/Storage/FilesystemJobExecutionStorageTest.php b/src/batch/tests/Storage/FilesystemJobExecutionStorageTest.php index 7a1511b0..3d34c8a2 100644 --- a/src/batch/tests/Storage/FilesystemJobExecutionStorageTest.php +++ b/src/batch/tests/Storage/FilesystemJobExecutionStorageTest.php @@ -71,7 +71,7 @@ public function testStore(): void $file = self::STORAGE_DIR . '/export/123456789.txt'; self::assertFileExists($file); self::assertIsReadable($file); - self::assertEquals('serialized job execution', file_get_contents($file)); + self::assertEquals('serialized job execution', \file_get_contents($file)); } public function testStoreFileNotWritable(): void @@ -98,7 +98,7 @@ public function testStoreFilePathNotFound(): void public function testRetrieve(): void { $jobExecution = JobExecution::createRoot('123456789', 'export'); - file_put_contents(self::STORAGE_DIR . '/export/123456789.txt', 'serialized and stored job execution'); + \file_put_contents(self::STORAGE_DIR . '/export/123456789.txt', 'serialized and stored job execution'); $this->serializer->unserialize('serialized and stored job execution') ->shouldBeCalledTimes(1) diff --git a/src/batch/tests/SummaryTest.php b/src/batch/tests/SummaryTest.php index 06bceda0..572e9e02 100644 --- a/src/batch/tests/SummaryTest.php +++ b/src/batch/tests/SummaryTest.php @@ -85,7 +85,7 @@ public function testGetIterator(): void { $summary = new Summary(['null' => null, 'string' => 'foo']); - self::assertSame(['null' => null, 'string' => 'foo'], iterator_to_array($summary)); + self::assertSame(['null' => null, 'string' => 'foo'], \iterator_to_array($summary)); } public function testCount(): void diff --git a/src/batch/tests/bootstrap.php b/src/batch/tests/bootstrap.php index 03bf46f3..977a912a 100644 --- a/src/batch/tests/bootstrap.php +++ b/src/batch/tests/bootstrap.php @@ -9,7 +9,7 @@ require_once __DIR__ . '/../vendor/autoload.php'; $artifactDir = @getenv('ARTIFACT_DIR'); -if (false === $artifactDir) { +if ($artifactDir === false) { throw new \LogicException('Missing "ARTIFACT_DIR" env var.'); } diff --git a/tests/integration/Job/SplitDeveloperXlsxJob.php b/tests/integration/Job/SplitDeveloperXlsxJob.php index 4c8845c2..64a5657f 100644 --- a/tests/integration/Job/SplitDeveloperXlsxJob.php +++ b/tests/integration/Job/SplitDeveloperXlsxJob.php @@ -30,7 +30,7 @@ public function execute(JobExecution $jobExecution): void $reader = new Reader(); $reader->open($this->inputFile); - $sheets = iterator_to_array($reader->getSheetIterator(), false); + $sheets = \iterator_to_array($reader->getSheetIterator(), false); [$badgeSheet, $repositorySheet] = $sheets; foreach ($this->sheetToArray($badgeSheet) as $row) { @@ -60,8 +60,8 @@ public function execute(JobExecution $jobExecution): void } foreach ($developers as &$developer) { - $developer['badges'] = implode('|', $developer['badges']); - $developer['repositories'] = implode('|', $developer['repositories']); + $developer['badges'] = \implode('|', $developer['badges']); + $developer['repositories'] = \implode('|', $developer['repositories']); } $reader->close(); @@ -88,7 +88,7 @@ private function writeToCsv(string $filename, array $data, array $headers): void private function sheetToArray(SheetInterface $sheet): array { - return array_map( + return \array_map( function ($row): array { if ($row instanceof Row) { return $row->toArray(); @@ -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 16a572df..07f51253 100644 --- a/tests/integration/JobTestCase.php +++ b/tests/integration/JobTestCase.php @@ -33,10 +33,10 @@ public static function setUpBeforeClass(): void if (!self::$run) { self::$run = true; - if (is_dir(self::ARTIFACTS_DIR)) { - @rmdir(self::ARTIFACTS_DIR); - @mkdir(self::STORAGE_DIR, 0755, true); - @mkdir(self::OUTPUT_DIR, 0755, true); + if (\is_dir(self::ARTIFACTS_DIR)) { + @\rmdir(self::ARTIFACTS_DIR); + @\mkdir(self::STORAGE_DIR, 0755, true); + @\mkdir(self::OUTPUT_DIR, 0755, true); } } } @@ -94,12 +94,12 @@ private function compareExecutions(JobExecution $jobExecution, JobExecution $sto self::assertSame($jobExecution->getJobName(), $storedJobExecution->getJobName()); self::compareStatuses($jobExecution->getStatus(), $storedJobExecution->getStatus()); self::assertSame( - iterator_to_array($jobExecution->getParameters()), - iterator_to_array($storedJobExecution->getParameters()) + \iterator_to_array($jobExecution->getParameters()), + \iterator_to_array($storedJobExecution->getParameters()) ); self::assertSame( - iterator_to_array($jobExecution->getSummary()), - iterator_to_array($storedJobExecution->getSummary()) + \iterator_to_array($jobExecution->getSummary()), + \iterator_to_array($storedJobExecution->getSummary()) ); self::compareDates($jobExecution->getStartTime(), $storedJobExecution->getStartTime()); self::compareDates($jobExecution->getEndTime(), $storedJobExecution->getEndTime()); @@ -142,7 +142,7 @@ private static function compareDates(?\DateTimeInterface $expected, ?\DateTimeIn */ private static function compareFailures(array $expected, array $actual) { - self::assertCount(count($expected), $actual); + self::assertCount(\count($expected), $actual); foreach ($expected as $idx => $expectedFailure) { $actualFailure = $actual[$idx] ?? null; @@ -161,7 +161,7 @@ private static function compareFailures(array $expected, array $actual) */ private static function compareWarnings(array $expected, array $actual) { - self::assertCount(count($expected), $actual); + self::assertCount(\count($expected), $actual); foreach ($expected as $idx => $expectedWarning) { $actualWarning = $actual[$idx] ?? null; diff --git a/tests/integration/JobWithDummyItemChildrenTest.php b/tests/integration/JobWithDummyItemChildrenTest.php index 84897489..59508c37 100644 --- a/tests/integration/JobWithDummyItemChildrenTest.php +++ b/tests/integration/JobWithDummyItemChildrenTest.php @@ -36,7 +36,7 @@ public function __construct(string $file) public function write(iterable $items): void { foreach ($items as $item) { - file_put_contents($this->file, $item . PHP_EOL, FILE_APPEND); + \file_put_contents($this->file, $item . PHP_EOL, FILE_APPEND); } } }; @@ -101,6 +101,6 @@ protected function assertAgainstExecution( OUT; self::assertFileExists($output); - self::assertEquals($expected, file_get_contents($output)); + self::assertEquals($expected, \file_get_contents($output)); } } diff --git a/tests/integration/Processor/DeveloperProcessor.php b/tests/integration/Processor/DeveloperProcessor.php index bbc7d36c..ea77abf8 100644 --- a/tests/integration/Processor/DeveloperProcessor.php +++ b/tests/integration/Processor/DeveloperProcessor.php @@ -22,10 +22,10 @@ public function __construct(EntityManager $manager) public function process(mixed $item): Developer { $badges = $this->manager->getRepository(Badge::class) - ->findBy(['label' => str_getcsv($item['badges'], '|')]) + ->findBy(['label' => \str_getcsv($item['badges'], '|')]) ; $repositories = $this->manager->getRepository(Repository::class) - ->findBy(['label' => str_getcsv($item['repositories'], '|')]) + ->findBy(['label' => \str_getcsv($item['repositories'], '|')]) ; $developer = new Developer(); diff --git a/tests/symfony/tests/StarWarsJobSet.php b/tests/symfony/tests/StarWarsJobSet.php index 47cf68c9..009bc6cc 100644 --- a/tests/symfony/tests/StarWarsJobSet.php +++ b/tests/symfony/tests/StarWarsJobSet.php @@ -77,8 +77,8 @@ static function (ContainerInterface $container) { $connection = $entityManager->getConnection(); $database = $connection->getParams()['path']; - if (file_exists($database)) { - unlink($database); + if (\file_exists($database)) { + \unlink($database); } $schema = $connection->createSchemaManager(); $schema->createDatabase($database); diff --git a/tests/symfony/tests/UserInterfaceTest.php b/tests/symfony/tests/UserInterfaceTest.php index 5fde99a5..a3c912d6 100644 --- a/tests/symfony/tests/UserInterfaceTest.php +++ b/tests/symfony/tests/UserInterfaceTest.php @@ -145,16 +145,34 @@ static function (string $content) { self::assertStringContainsString('Starting job {"job":"star-wars.import"}', $content); self::assertStringContainsString('Starting child job {"job":"star-wars.import:planet"}', $content); - self::assertStringContainsString('Job produced summary {"job":"star-wars.import:planet","read":61,"processed":60,"skipped":1,"invalid":1,"write":60}', $content); - self::assertStringContainsString('Job executed successfully {"job":"star-wars.import:planet"', $content); + self::assertStringContainsString( + 'Job produced summary {"job":"star-wars.import:planet","read":61,"processed":60,"skipped":1,"invalid":1,"write":60}', + $content + ); + self::assertStringContainsString( + 'Job executed successfully {"job":"star-wars.import:planet"', + $content + ); self::assertStringContainsString('Starting child job {"job":"star-wars.import:specie"}', $content); - self::assertStringContainsString('Job produced summary {"job":"star-wars.import:specie","read":37,"processed":37,"write":37}', $content); - self::assertStringContainsString('Job executed successfully {"job":"star-wars.import:specie"', $content); + self::assertStringContainsString( + 'Job produced summary {"job":"star-wars.import:specie","read":37,"processed":37,"write":37}', + $content + ); + self::assertStringContainsString( + 'Job executed successfully {"job":"star-wars.import:specie"', + $content + ); self::assertStringContainsString('Starting child job {"job":"star-wars.import:character"}', $content); - self::assertStringContainsString('Job produced summary {"job":"star-wars.import:character","read":87,"processed":87,"write":87}', $content); - self::assertStringContainsString('Job executed successfully {"job":"star-wars.import:character"', $content); + self::assertStringContainsString( + 'Job produced summary {"job":"star-wars.import:character","read":87,"processed":87,"write":87}', + $content + ); + self::assertStringContainsString( + 'Job executed successfully {"job":"star-wars.import:character"', + $content + ); self::assertStringContainsString('Job executed successfully {"job":"star-wars.import"', $content); },