Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 1 addition & 101 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ parameters:
path: src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php

-
message: "#^Parameter \\#1 \\$class of class Yokai\\\\Batch\\\\Failure constructor expects string, mixed given\\.$#"
message: "#^Parameter \\#1 \\$class of class Yokai\\\\Batch\\\\Failure constructor expects class\\-string\\<Throwable\\>, mixed given\\.$#"
count: 1
path: src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php

Expand Down Expand Up @@ -160,103 +160,3 @@ parameters:
count: 1
path: src/batch-openspout/src/Writer/FlatFileWriter.php

-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 3
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#1 \\$array of method Yokai\\\\Batch\\\\Serializer\\\\JsonJobExecutionSerializer\\:\\:failureFromArray\\(\\) expects array\\<string, mixed\\>, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#1 \\$array of method Yokai\\\\Batch\\\\Serializer\\\\JsonJobExecutionSerializer\\:\\:warningFromArray\\(\\) expects array\\<string, mixed\\>, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#1 \\$class of class Yokai\\\\Batch\\\\Failure constructor expects string, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#1 \\$date of method Yokai\\\\Batch\\\\Serializer\\\\JsonJobExecutionSerializer\\:\\:stringToDate\\(\\) expects string\\|null, mixed given\\.$#"
count: 2
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#1 \\$id of static method Yokai\\\\Batch\\\\JobExecution\\:\\:createRoot\\(\\) expects string, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#1 \\$jobExecutionData of method Yokai\\\\Batch\\\\Serializer\\\\JsonJobExecutionSerializer\\:\\:fromArray\\(\\) expects array\\<string, mixed\\>, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#1 \\$logs of class Yokai\\\\Batch\\\\JobExecutionLogs constructor expects string, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#1 \\$message of class Yokai\\\\Batch\\\\Warning constructor expects string, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#1 \\$parameters of class Yokai\\\\Batch\\\\JobParameters constructor expects array\\<string, mixed\\>, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#1 \\$value of class Yokai\\\\Batch\\\\BatchStatus constructor expects int, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#1 \\$values of class Yokai\\\\Batch\\\\Summary constructor expects array\\<string, mixed\\>, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#2 \\$jobName of static method Yokai\\\\Batch\\\\JobExecution\\:\\:createChild\\(\\) expects string, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#2 \\$jobName of static method Yokai\\\\Batch\\\\JobExecution\\:\\:createRoot\\(\\) expects string, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#2 \\$message of class Yokai\\\\Batch\\\\Failure constructor expects string, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#2 \\$parameters of class Yokai\\\\Batch\\\\Warning constructor expects array\\<string, string\\>, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#3 \\$code of class Yokai\\\\Batch\\\\Failure constructor expects int, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#3 \\$context of class Yokai\\\\Batch\\\\Warning constructor expects array\\<string, mixed\\>, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#4 \\$parameters of class Yokai\\\\Batch\\\\Failure constructor expects array\\<string, string\\>, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

-
message: "#^Parameter \\#5 \\$trace of class Yokai\\\\Batch\\\\Failure constructor expects string\\|null, mixed given\\.$#"
count: 1
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php

1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="memory_limit" value="256M"/>
<env name="ARTIFACT_DIR" value="tests/.artifacts"/>
<env name="DATABASE_URL" value="sqlite:///:memory:"/>
<env name="KERNEL_CLASS" value="Yokai\Batch\Sources\Tests\Symfony\App\Kernel"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* },
* filesystem: array{
* serializer: string,
* partial_serializer: string,
* dir: string,
* },
* }
Expand Down Expand Up @@ -96,6 +97,9 @@ private function storage(): ArrayNodeDefinition
->scalarNode('serializer')
->defaultValue('yokai_batch.job_execution_serializer.json')
->end()
->scalarNode('partial_serializer')
->defaultValue('yokai_batch.job_execution_partial_serializer.json')
->end()
->end()
->end()
->arrayNode('dbal')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ private function configureStorage(ContainerBuilder $container, array $config): v
} else {
$container
->register('yokai_batch.storage.filesystem', FilesystemJobExecutionStorage::class)
->setArguments([new Reference($config['filesystem']['serializer']), $config['filesystem']['dir']])
->setArguments([
new Reference($config['filesystem']['serializer']),
new Reference($config['filesystem']['partial_serializer']),
$config['filesystem']['dir'],
])
;

$defaultStorage = 'yokai_batch.storage.filesystem';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<defaults public="false"/>

<service id="yokai_batch.job_execution_partial_serializer.json"
class="Yokai\Batch\Serializer\JsonJobExecutionPartialSerializer"/>
</services>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
use Yokai\Batch\JobExecution;
use Yokai\Batch\JobExecutionLogs;
use Yokai\Batch\JobParameters;
use Yokai\Batch\Serializer\JsonJobExecutionPartialSerializer;
use Yokai\Batch\Serializer\JsonJobExecutionSerializer;
use Yokai\Batch\Storage\FilesystemJobExecutionStorage;
use Yokai\Batch\Summary;
Expand All @@ -59,7 +60,11 @@ final class JobControllerTest extends TestCase

public static function setUpBeforeClass(): void
{
self::$storage = new FilesystemJobExecutionStorage(new JsonJobExecutionSerializer(), self::STORAGE_DIR);
self::$storage = new FilesystemJobExecutionStorage(
new JsonJobExecutionSerializer(),
new JsonJobExecutionPartialSerializer(),
self::STORAGE_DIR,
);
}

protected function setUp(): void
Expand Down
4 changes: 4 additions & 0 deletions src/batch/src/Failure.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ final class Failure implements \Stringable
public function __construct(
/**
* The exception class
* @var class-string<\Throwable> $class
*/
private string $class,
/**
Expand Down Expand Up @@ -58,6 +59,9 @@ public function __toString(): string
return \strtr($this->message, $this->parameters);
}

/**
* @return class-string<\Throwable>
*/
public function getClass(): string
{
return $this->class;
Expand Down
21 changes: 21 additions & 0 deletions src/batch/src/JobExecutionResultFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Yokai\Batch;

use DateTimeInterface;

/**
* This value object represents a job execution result file with its path and optional start and end times.
* It is used to encapsulate minimal information about a job execution result to avoid memory leaks.
*/
final class JobExecutionResultFile
{
public function __construct(
public readonly string $path,
public readonly DateTimeInterface|null $jobStartTime,
public readonly DateTimeInterface|null $jobEndTime,
) {
}
}
Loading
Loading