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
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"require-dev": {
"doctrine/doctrine-bundle": "^2.0|^3.0",
"league/flysystem-memory": "^3.0",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^11.0|^12.0",
"sonata-project/admin-bundle": "^4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/batch-doctrine-dbal/src/DoctrineDBALInsertWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* via a Doctrine {@see Connection}.
* All items must be arrays.
*/
final class DoctrineDBALInsertWriter implements ItemWriterInterface
final readonly class DoctrineDBALInsertWriter implements ItemWriterInterface
{
private Connection $connection;

Expand Down
22 changes: 11 additions & 11 deletions src/batch-doctrine-dbal/src/DoctrineDBALJobExecutionStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ final class DoctrineDBALJobExecutionStorage implements
'connection' => null,
];

private Connection $connection;
private string $table;
private readonly Connection $connection;
private readonly string $table;
private JobExecutionRowNormalizer $normalizer;

/**
Expand Down Expand Up @@ -334,53 +334,53 @@ private function addWheres(Query $query, QueryBuilder $qb): array
$queryTypes = [];

$names = $query->jobs();
if (\count($names) > 0) {
if ($names !== []) {
$qb->andWhere($qb->expr()->in('job_name', ':jobNames'));
$queryParameters['jobNames'] = $names;
$queryTypes['jobNames'] = ArrayParameterType::STRING;
}

$ids = $query->ids();
if (\count($ids) > 0) {
if ($ids !== []) {
$qb->andWhere($qb->expr()->in('id', ':ids'));
$queryParameters['ids'] = $ids;
$queryTypes['ids'] = ArrayParameterType::STRING;
}

$statuses = $query->statuses();
if (\count($statuses) > 0) {
if ($statuses !== []) {
$qb->andWhere($qb->expr()->in('status', ':statuses'));
$queryParameters['statuses'] = $statuses;
$queryTypes['statuses'] = ArrayParameterType::INTEGER;
}

if ($query->startTime()) {
if ($query->startTime() !== null) {
$qb->andWhere($qb->expr()->isNotNull('start_time'));
}
$startDateFrom = $query->startTime()?->getFrom();
if ($startDateFrom) {
if ($startDateFrom !== null) {
$qb->andWhere($qb->expr()->gte('start_time', ':startDateFrom'));
$queryParameters['startDateFrom'] = $startDateFrom;
$queryTypes['startDateFrom'] = Types::DATETIME_IMMUTABLE;
}
$startDateTo = $query->startTime()?->getTo();
if ($startDateTo) {
if ($startDateTo !== null) {
$qb->andWhere($qb->expr()->lte('start_time', ':startDateTo'));
$queryParameters['startDateTo'] = $startDateTo;
$queryTypes['startDateTo'] = Types::DATETIME_IMMUTABLE;
}

if ($query->endTime()) {
if ($query->endTime() !== null) {
$qb->andWhere($qb->expr()->isNotNull('start_time'));
}
$endDateFrom = $query->endTime()?->getFrom();
if ($endDateFrom) {
if ($endDateFrom !== null) {
$qb->andWhere($qb->expr()->gte('end_time', ':endDateFrom'));
$queryParameters['endDateFrom'] = $endDateFrom;
$queryTypes['endDateFrom'] = Types::DATETIME_IMMUTABLE;
}
$endDateTo = $query->endTime()?->getTo();
if ($endDateTo) {
if ($endDateTo !== null) {
$qb->andWhere($qb->expr()->lte('end_time', ':endDateTo'));
$queryParameters['endDateTo'] = $endDateTo;
$queryTypes['endDateTo'] = Types::DATETIME_IMMUTABLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* In that case, {@see DoctrineDBALQueryCursorReader::$column} argument should be "id",
* and if id is a numeric column {@see DoctrineDBALQueryCursorReader::$start} should be 0.
*/
final class DoctrineDBALQueryCursorReader implements ItemReaderInterface
final readonly class DoctrineDBALQueryCursorReader implements ItemReaderInterface
{
private Connection $connection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* This {@see ItemReaderInterface} executes an SQL query to a Doctrine connection,
* and iterate over each result as an item.
*/
final class DoctrineDBALQueryOffsetReader implements ItemReaderInterface
final readonly class DoctrineDBALQueryOffsetReader implements ItemReaderInterface
{
private Connection $connection;
private string $sql;
Expand Down
2 changes: 1 addition & 1 deletion src/batch-doctrine-dbal/src/DoctrineDBALUpsert.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* This model object is used by {@see DoctrineDBALUpsertWriter}.
* It holds table, data and identity to perform upsert operation.
*/
final class DoctrineDBALUpsert
final readonly class DoctrineDBALUpsert
{
public function __construct(
private string $table,
Expand Down
2 changes: 1 addition & 1 deletion src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* @internal
*/
final class JobExecutionRowNormalizer
final readonly class JobExecutionRowNormalizer
{
public function __construct(
private AbstractPlatform $platform,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testCreateStandardTable(): void
self::assertTrue($schemaManager->tablesExist(['yokai_batch_job_execution']));

$columns = $schemaManager->listTableColumns('yokai_batch_job_execution');
self::assertEquals(
self::assertSame(
[
'id',
'job_name',
Expand All @@ -68,7 +68,7 @@ public function testCreateCustomTable(): void
self::assertTrue($schemaManager->tablesExist(['acme_job_executions']));

$columns = $schemaManager->listTableColumns('acme_job_executions');
self::assertEquals(
self::assertSame(
[
'id',
'job_name',
Expand Down Expand Up @@ -279,7 +279,7 @@ public function testQuery(QueryBuilder $queryBuilder, array $expectedCouples): v
$this->loadFixtures($storage);

self::assertExecutions($expectedCouples, $storage->query($queryBuilder->getQuery()));
self::assertSame(\count($expectedCouples), $storage->count($queryBuilder->getQuery()));
self::assertCount($storage->count($queryBuilder->getQuery()), $expectedCouples);
}

public static function queries(): Generator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Doctrine\Persistence\ConnectionRegistry;
use InvalidArgumentException;

final class SingleConnectionRegistry implements ConnectionRegistry
final readonly class SingleConnectionRegistry implements ConnectionRegistry
{
public function __construct(
private Connection $connection,
Expand Down
2 changes: 1 addition & 1 deletion src/batch-doctrine-orm/src/EntityReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* This {@see ItemReaderInterface} executes an SQL query to a Doctrine connection,
*/
final class EntityReader implements ItemReaderInterface
final readonly class EntityReader implements ItemReaderInterface
{
public function __construct(
private ManagerRegistry $doctrine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
final class SingleManagerRegistry extends AbstractManagerRegistry
{
public function __construct(
private ObjectManager $manager,
private readonly ObjectManager $manager,
) {
parent::__construct('ORM', ['default'], ['default'], 'default', 'default', Proxy::class);
}
Expand Down
5 changes: 3 additions & 2 deletions src/batch-doctrine-orm/tests/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

namespace Yokai\Batch\Tests\Bridge\Doctrine\ORM\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'user')]
class User
{
#[ORM\Column(type: 'integer')]
#[ORM\Column(type: Types::INTEGER)]
#[ORM\Id]
#[ORM\GeneratedValue]
public int $id;

#[ORM\Column(type: 'string')]
#[ORM\Column(type: Types::STRING)]
public string $name;

public function __construct(string $name)
Expand Down
2 changes: 1 addition & 1 deletion src/batch-doctrine-persistence/src/ObjectRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class ObjectRegistry
private array $identities = [];

public function __construct(
private ManagerRegistry $doctrine,
private readonly ManagerRegistry $doctrine,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/batch-doctrine-persistence/src/ObjectWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class ObjectWriter implements ItemWriterInterface
private array $managerForClass = [];

public function __construct(
private ManagerRegistry $doctrine,
private readonly ManagerRegistry $doctrine,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public function __construct(
/**
* @var class-string<EntityRepository>
*/
private string $class,
private RepositoryFactory $decorated,
private readonly string $class,
private readonly RepositoryFactory $decorated,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class FindOneByCalledOnlyOnceWhenFoundRepositoryDecorator extends EntityReposito
private array $calls = [];

public function __construct(
private ObjectRepository $decorated,
private readonly ObjectRepository $decorated,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
$managers = [];
$defaultConnection = null;
$defaultEntityManager = null;
foreach ($this->services as $id => $service) {
foreach (\array_keys($this->services) as $id) {
$connections[] = $id;
$managers[] = $id;
$defaultConnection ??= $id;
Expand Down
5 changes: 3 additions & 2 deletions src/batch-doctrine-persistence/tests/Entity/Auth/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

namespace Yokai\Batch\Tests\Bridge\Doctrine\Persistence\Entity\Auth;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'auth_group')]
class Group
{
#[ORM\Column(type: 'integer')]
#[ORM\Column(type: Types::INTEGER)]
#[ORM\Id]
#[ORM\GeneratedValue]
public int $id;

#[ORM\Column(type: 'string')]
#[ORM\Column(type: Types::STRING)]
public string $name;

public function __construct(string $name)
Expand Down
5 changes: 3 additions & 2 deletions src/batch-doctrine-persistence/tests/Entity/Auth/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

namespace Yokai\Batch\Tests\Bridge\Doctrine\Persistence\Entity\Auth;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'auth_user')]
class User
{
#[ORM\Column(type: 'integer')]
#[ORM\Column(type: Types::INTEGER)]
#[ORM\Id]
#[ORM\GeneratedValue]
public int $id;

#[ORM\Column(type: 'string')]
#[ORM\Column(type: Types::STRING)]
public string $name;

public function __construct(string $name)
Expand Down
5 changes: 3 additions & 2 deletions src/batch-doctrine-persistence/tests/Entity/Shop/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

namespace Yokai\Batch\Tests\Bridge\Doctrine\Persistence\Entity\Shop;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'shop_product')]
class Product
{
#[ORM\Column(type: 'integer')]
#[ORM\Column(type: Types::INTEGER)]
#[ORM\Id]
#[ORM\GeneratedValue]
public int $id;

#[ORM\Column(type: 'string')]
#[ORM\Column(type: Types::STRING)]
public string $name;

public function __construct(string $name)
Expand Down
1 change: 0 additions & 1 deletion src/batch-league-flysystem/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"require-dev": {
"league/flysystem-memory": "^3.0",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5"
},
"autoload-dev": {
Expand Down
8 changes: 4 additions & 4 deletions src/batch-league-flysystem/src/Job/CopyFilesJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
class CopyFilesJob implements JobInterface
{
public function __construct(
private JobParameterAccessorInterface $location,
private FilesystemReader $source,
private FilesystemWriter $destination,
private Closure|null $transformLocation = null,
private readonly JobParameterAccessorInterface $location,
private readonly FilesystemReader $source,
private readonly FilesystemWriter $destination,
private readonly Closure|null $transformLocation = null,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/batch-league-flysystem/src/Job/MoveFilesJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
class MoveFilesJob implements JobInterface
{
public function __construct(
private JobParameterAccessorInterface $location,
private FilesystemOperator $source,
private FilesystemWriter $destination,
private Closure|null $transformLocation = null,
private readonly JobParameterAccessorInterface $location,
private readonly FilesystemOperator $source,
private readonly FilesystemWriter $destination,
private readonly Closure|null $transformLocation = null,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* Watch for the existence of a location on a filesystem to trigger a job.
*/
final class FileFoundScheduler implements SchedulerInterface
final readonly class FileFoundScheduler implements SchedulerInterface
{
public function __construct(
private FilesystemReader $filesystem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
final class CannotCheckMemoryAdapter extends InMemoryFilesystemAdapter
{
public function __construct(
private UnableToCheckExistence|FilesystemException $exception,
private readonly UnableToCheckExistence|FilesystemException $exception,
) {
parent::__construct();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
final class CannotDeleteMemoryAdapter extends InMemoryFilesystemAdapter
{
public function __construct(
private UnableToDeleteFile|FilesystemException $exception,
private readonly UnableToDeleteFile|FilesystemException $exception,
) {
parent::__construct();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
final class CannotReadMemoryAdapter extends InMemoryFilesystemAdapter
{
public function __construct(
private UnableToReadFile|FilesystemException $exception,
private readonly UnableToReadFile|FilesystemException $exception,
) {
parent::__construct();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
final class CannotWriteMemoryAdapter extends InMemoryFilesystemAdapter
{
public function __construct(
private UnableToWriteFile|FilesystemException $exception,
private readonly UnableToWriteFile|FilesystemException $exception,
) {
parent::__construct();
}
Expand Down
Loading
Loading