rector fixes after rector's upgrade

This commit is contained in:
Julien Fastré 2024-08-28 15:32:57 +02:00
parent e477a49c92
commit 2d82c1e105
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
6 changed files with 31 additions and 43 deletions

View File

@ -364,7 +364,7 @@ class StoredObject implements Document, TrackCreationInterface
{
try {
return base_convert(bin2hex(random_bytes(32)), 16, 36);
} catch (RandomException $e) {
} catch (RandomException) {
return uniqid(more_entropy: true);
}
}

View File

@ -23,9 +23,9 @@ use Doctrine\Persistence\ObjectRepository;
*/
class StoredObjectVersionRepository implements ObjectRepository
{
private EntityRepository $repository;
private readonly EntityRepository $repository;
private Connection $connection;
private readonly Connection $connection;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@ -23,16 +23,16 @@ use Symfony\Component\Messenger\MessageBusInterface;
* This cronjob is executed every 7days, to remove expired stored object. For every
* expired stored object, every version is sent to message bus for async deletion.
*/
final class RemoveExpiredStoredObjectCronJob implements CronJobInterface
final readonly class RemoveExpiredStoredObjectCronJob implements CronJobInterface
{
public const string KEY = 'remove-expired-stored-object';
private const string LAST_DELETED_KEY = 'last-deleted-stored-object-id';
public function __construct(
private readonly ClockInterface $clock,
private readonly MessageBusInterface $messageBus,
private readonly StoredObjectRepositoryInterface $storedObjectRepository
private ClockInterface $clock,
private MessageBusInterface $messageBus,
private StoredObjectRepositoryInterface $storedObjectRepository
) {}
public function canRun(?CronJobExecution $cronJobExecution): bool

View File

@ -106,9 +106,7 @@ class RemoveExpiredStoredObjectCronJobTest extends TestCase
false => $messageBus->method('dispatch'),
};
$methodDispatch->willReturnCallback(function (RemoveOldVersionMessage $message) {
return new Envelope($message);
});
$methodDispatch->willReturnCallback(fn (RemoveOldVersionMessage $message) => new Envelope($message));
return $messageBus;
}

View File

@ -95,9 +95,7 @@ class RemoveOldVersionCronJobTest extends KernelTestCase
false => $messageBus->method('dispatch'),
};
$methodDispatch->willReturnCallback(function (RemoveOldVersionMessage $message) {
return new Envelope($message);
});
$methodDispatch->willReturnCallback(fn (RemoveOldVersionMessage $message) => new Envelope($message));
return $messageBus;
}

View File

@ -217,13 +217,11 @@ final class StoredObjectManagerTest extends TestCase
->expects($this->once())
->method('generate')
->with($this->identicalTo('DELETE'), $this->identicalTo('object_name'))
->willReturnCallback(function (string $method, string $objectName) {
return new SignedUrl(
$method,
'https://example.com/'.$objectName,
new \DateTimeImmutable('1 hours')
);
});
->willReturnCallback(fn (string $method, string $objectName) => new SignedUrl(
$method,
'https://example.com/'.$objectName,
new \DateTimeImmutable('1 hours')
));
$storedObjectManager = new StoredObjectManager($httpClient, $tempUrlGenerator);
$storedObjectManager->delete($version);
@ -276,14 +274,12 @@ final class StoredObjectManagerTest extends TestCase
->expects($this->never())
->method('generate')
->with($this->identicalTo('HEAD'), $this->isType('string'))
->willReturnCallback(function (string $method, string $objectName) {
return new SignedUrl(
$method,
'https://example.com/'.$objectName,
new \DateTimeImmutable('1 hours'),
$objectName
);
});
->willReturnCallback(fn (string $method, string $objectName) => new SignedUrl(
$method,
'https://example.com/'.$objectName,
new \DateTimeImmutable('1 hours'),
$objectName
));
$manager = new StoredObjectManager($client, $tempUrlGenerator);
@ -307,13 +303,11 @@ final class StoredObjectManagerTest extends TestCase
->expects($this->atLeastOnce())
->method('generate')
->with($this->identicalTo('HEAD'), $this->isType('string'))
->willReturnCallback(function (string $method, string $objectName) {
return new SignedUrl(
$method,
'https://example.com/'.$objectName,
new \DateTimeImmutable('1 hours')
);
});
->willReturnCallback(fn (string $method, string $objectName) => new SignedUrl(
$method,
'https://example.com/'.$objectName,
new \DateTimeImmutable('1 hours')
));
$manager = new StoredObjectManager($client, $tempUrlGenerator);
@ -368,14 +362,12 @@ final class StoredObjectManagerTest extends TestCase
->expects($this->atLeastOnce())
->method('generate')
->with($this->logicalOr($this->identicalTo('GET'), $this->identicalTo('PUT')), $this->isType('string'))
->willReturnCallback(function (string $method, string $objectName) {
return new SignedUrl(
$method,
'https://example.com/'.$objectName,
new \DateTimeImmutable('1 hours'),
$objectName
);
});
->willReturnCallback(fn (string $method, string $objectName) => new SignedUrl(
$method,
'https://example.com/'.$objectName,
new \DateTimeImmutable('1 hours'),
$objectName
));
return $tempUrlGenerator;
}