DX: apply rector rules up to php8.0

This commit is contained in:
2023-04-15 01:05:37 +02:00
parent d8870e906f
commit dde3002100
714 changed files with 2348 additions and 9263 deletions

View File

@@ -19,11 +19,8 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class BaseContextData
{
private NormalizerInterface $normalizer;
public function __construct(NormalizerInterface $normalizer)
public function __construct(private NormalizerInterface $normalizer)
{
$this->normalizer = $normalizer;
}
public function getData(?User $user = null): array

View File

@@ -25,30 +25,10 @@ use Symfony\Component\HttpFoundation\File\File;
class Generator implements GeneratorInterface
{
private ContextManagerInterface $contextManager;
private DriverInterface $driver;
private EntityManagerInterface $entityManager;
private LoggerInterface $logger;
private StoredObjectManagerInterface $storedObjectManager;
private const LOG_PREFIX = '[docgen generator] ';
public function __construct(
ContextManagerInterface $contextManager,
DriverInterface $driver,
EntityManagerInterface $entityManager,
LoggerInterface $logger,
StoredObjectManagerInterface $storedObjectManager
) {
$this->contextManager = $contextManager;
$this->driver = $driver;
$this->entityManager = $entityManager;
$this->logger = $logger;
$this->storedObjectManager = $storedObjectManager;
public function __construct(private ContextManagerInterface $contextManager, private DriverInterface $driver, private EntityManagerInterface $entityManager, private LoggerInterface $logger, private StoredObjectManagerInterface $storedObjectManager)
{
}
/**

View File

@@ -17,13 +17,10 @@ use Throwable;
class GeneratorException extends RuntimeException
{
/**
* @var list<string>
* @param string[] $errors
*/
private array $errors;
public function __construct(array $errors = [], ?Throwable $previous = null)
public function __construct(private array $errors = [], ?Throwable $previous = null)
{
$this->errors = $errors;
parent::__construct(
'Could not generate the document',
15252,
@@ -31,9 +28,6 @@ class GeneratorException extends RuntimeException
);
}
/**
* @return array
*/
public function getErrors(): array
{
return $this->errors;

View File

@@ -26,47 +26,10 @@ use Symfony\Contracts\Translation\TranslatorInterface;
final class OnGenerationFails implements EventSubscriberInterface
{
private DocGeneratorTemplateRepository $docGeneratorTemplateRepository;
private EntityManagerInterface $entityManager;
private LoggerInterface $logger;
private MailerInterface $mailer;
private StoredObjectRepository $storedObjectRepository;
private TranslatorInterface $translator;
private UserRepositoryInterface $userRepository;
public const LOG_PREFIX = '[docgen failed] ';
/**
* @param DocGeneratorTemplateRepository $docGeneratorTemplateRepository
* @param EntityManagerInterface $entityManager
* @param LoggerInterface $logger
* @param MailerInterface $mailer
* @param StoredObjectRepository $storedObjectRepository
* @param TranslatorInterface $translator
* @param UserRepositoryInterface $userRepository
*/
public function __construct(
DocGeneratorTemplateRepository $docGeneratorTemplateRepository,
EntityManagerInterface $entityManager,
LoggerInterface $logger,
MailerInterface $mailer,
StoredObjectRepository $storedObjectRepository,
TranslatorInterface $translator,
UserRepositoryInterface $userRepository
) {
$this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository;
$this->entityManager = $entityManager;
$this->logger = $logger;
$this->mailer = $mailer;
$this->storedObjectRepository = $storedObjectRepository;
$this->translator = $translator;
$this->userRepository = $userRepository;
public function __construct(private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private EntityManagerInterface $entityManager, private LoggerInterface $logger, private MailerInterface $mailer, private StoredObjectRepository $storedObjectRepository, private TranslatorInterface $translator, private UserRepositoryInterface $userRepository)
{
}
@@ -95,7 +58,7 @@ final class OnGenerationFails implements EventSubscriberInterface
'entity_id' => $message->getEntityId(),
'template_id' => $message->getTemplateId(),
'creator_id' => $message->getCreatorId(),
'throwable_class' => get_class($event->getThrowable()),
'throwable_class' => $event->getThrowable()::class,
]);
$this->markObjectAsFailed($message);

View File

@@ -26,36 +26,12 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
*/
class RequestGenerationHandler implements MessageHandlerInterface
{
private StoredObjectRepository $storedObjectRepository;
private DocGeneratorTemplateRepository $docGeneratorTemplateRepository;
private EntityManagerInterface $entityManager;
private Generator $generator;
private LoggerInterface $logger;
private UserRepositoryInterface $userRepository;
public const AUTHORIZED_TRIALS = 5;
private const LOG_PREFIX = '[docgen message handler] ';
public function __construct(
DocGeneratorTemplateRepository $docGeneratorTemplateRepository,
EntityManagerInterface $entityManager,
Generator $generator,
LoggerInterface $logger,
StoredObjectRepository $storedObjectRepository,
UserRepositoryInterface $userRepository
) {
$this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository;
$this->entityManager = $entityManager;
$this->generator = $generator;
$this->logger = $logger;
$this->storedObjectRepository = $storedObjectRepository;
$this->userRepository = $userRepository;
public function __construct(private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private EntityManagerInterface $entityManager, private Generator $generator, private LoggerInterface $logger, private StoredObjectRepository $storedObjectRepository, private UserRepositoryInterface $userRepository)
{
}
public function __invoke(RequestGenerationMessage $message)

View File

@@ -21,26 +21,20 @@ class RequestGenerationMessage
private int $templateId;
private int $entityId;
private int $destinationStoredObjectId;
private array $contextGenerationData;
private \DateTimeImmutable $createdAt;
public function __construct(
User $creator,
DocGeneratorTemplate $template,
int $entityId,
private int $entityId,
StoredObject $destinationStoredObject,
array $contextGenerationData
private array $contextGenerationData
) {
$this->creatorId = $creator->getId();
$this->templateId = $template->getId();
$this->entityId = $entityId;
$this->destinationStoredObjectId = $destinationStoredObject->getId();
$this->contextGenerationData = $contextGenerationData;
$this->createdAt = new \DateTimeImmutable('now');
}