Merge branch 'master' into upgrade-sf5

This commit is contained in:
2024-02-12 21:50:34 +01:00
920 changed files with 6430 additions and 1914 deletions

View File

@@ -19,7 +19,9 @@ final readonly class ContextManager implements ContextManagerInterface
/**
* @param \Chill\DocGeneratorBundle\Context\DocGeneratorContextInterface[] $contexts
*/
public function __construct(private iterable $contexts) {}
public function __construct(private iterable $contexts)
{
}
public function getContextByDocGeneratorTemplate(DocGeneratorTemplate $docGeneratorTemplate): DocGeneratorContextInterface
{

View File

@@ -22,7 +22,9 @@ use Symfony\Component\Routing\Annotation\Route;
class AdminDocGeneratorTemplateController extends CRUDController
{
public function __construct(private readonly ContextManager $contextManager) {}
public function __construct(private readonly ContextManager $contextManager)
{
}
public function generateTemplateParameter(string $action, $entity, Request $request, array $defaultTemplateParameters = [])
{

View File

@@ -24,7 +24,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class DocGeneratorTemplateType extends AbstractType
{
public function __construct(private readonly ContextManager $contextManager) {}
public function __construct(private readonly ContextManager $contextManager)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -13,5 +13,5 @@ namespace Chill\DocGeneratorBundle\GeneratorDriver;
interface DriverInterface
{
public function generateFromString(string $template, string $resourceType, array $data, string $templateName = null): string;
public function generateFromString(string $template, string $resourceType, array $data, ?string $templateName = null): string;
}

View File

@@ -17,7 +17,7 @@ namespace Chill\DocGeneratorBundle\GeneratorDriver\Exception;
*/
class TemplateException extends \RuntimeException
{
public function __construct(private readonly array $errors, $code = 0, \Throwable $previous = null)
public function __construct(private readonly array $errors, $code = 0, ?\Throwable $previous = null)
{
parent::__construct('Error while generating document from template', $code, $previous);
}

View File

@@ -33,7 +33,7 @@ final class RelatorioDriver implements DriverInterface
$this->url = $parameterBag->get('chill_doc_generator')['driver']['relatorio']['url'];
}
public function generateFromString(string $template, string $resourceType, array $data, string $templateName = null): string
public function generateFromString(string $template, string $resourceType, array $data, ?string $templateName = null): string
{
$form = new FormDataPart(
[

View File

@@ -18,7 +18,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class AdminMenuBuilder implements LocalMenuBuilderInterface
{
public function __construct(private readonly TranslatorInterface $translator, private readonly Security $security) {}
public function __construct(private readonly TranslatorInterface $translator, private readonly Security $security)
{
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{

View File

@@ -58,7 +58,7 @@ final class DocGeneratorTemplateRepository implements ObjectRepository
*
* @return DocGeneratorTemplate[]
*/
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
@@ -85,7 +85,7 @@ final class DocGeneratorTemplateRepository implements ObjectRepository
->getResult();
}
public function findOneBy(array $criteria, array $orderBy = null): ?DocGeneratorTemplate
public function findOneBy(array $criteria, ?array $orderBy = null): ?DocGeneratorTemplate
{
return $this->repository->findOneBy($criteria, $orderBy);
}

View File

@@ -16,9 +16,11 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class NormalizeNullValueHelper
{
public function __construct(private readonly NormalizerInterface $normalizer, private readonly ?string $discriminatorType = null, private readonly ?string $discriminatorValue = null) {}
public function __construct(private readonly NormalizerInterface $normalizer, private readonly ?string $discriminatorType = null, private readonly ?string $discriminatorValue = null)
{
}
public function normalize(array $attributes, string $format = 'docgen', ?array $context = [], ClassMetadataInterface $classMetadata = null)
public function normalize(array $attributes, string $format = 'docgen', ?array $context = [], ?ClassMetadataInterface $classMetadata = null)
{
$data = [];
$data['isNull'] = true;

View File

@@ -17,9 +17,11 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class BaseContextData
{
public function __construct(private readonly NormalizerInterface $normalizer) {}
public function __construct(private readonly NormalizerInterface $normalizer)
{
}
public function getData(User $user = null): array
public function getData(?User $user = null): array
{
$data = [];

View File

@@ -27,7 +27,9 @@ class Generator implements GeneratorInterface
{
private const LOG_PREFIX = '[docgen generator] ';
public function __construct(private readonly ContextManagerInterface $contextManager, private readonly DriverInterface $driver, private readonly EntityManagerInterface $entityManager, private readonly LoggerInterface $logger, private readonly StoredObjectManagerInterface $storedObjectManager) {}
public function __construct(private readonly ContextManagerInterface $contextManager, private readonly DriverInterface $driver, private readonly EntityManagerInterface $entityManager, private readonly LoggerInterface $logger, private readonly StoredObjectManagerInterface $storedObjectManager)
{
}
/**
* @template T of File|null
@@ -44,10 +46,10 @@ class Generator implements GeneratorInterface
DocGeneratorTemplate $template,
int $entityId,
array $contextGenerationDataNormalized,
StoredObject $destinationStoredObject = null,
?StoredObject $destinationStoredObject = null,
bool $isTest = false,
File $testFile = null,
User $creator = null
?File $testFile = null,
?User $creator = null
): ?string {
if ($destinationStoredObject instanceof StoredObject && StoredObject::STATUS_PENDING !== $destinationStoredObject->getStatus()) {
$this->logger->info(self::LOG_PREFIX.'Aborting generation of an already generated document');

View File

@@ -16,7 +16,7 @@ class GeneratorException extends \RuntimeException
/**
* @param string[] $errors
*/
public function __construct(private readonly array $errors = [], \Throwable $previous = null)
public function __construct(private readonly array $errors = [], ?\Throwable $previous = null)
{
parent::__construct(
'Could not generate the document',

View File

@@ -33,9 +33,9 @@ interface GeneratorInterface
DocGeneratorTemplate $template,
int $entityId,
array $contextGenerationDataNormalized,
StoredObject $destinationStoredObject = null,
?StoredObject $destinationStoredObject = null,
bool $isTest = false,
File $testFile = null,
User $creator = null
?File $testFile = null,
?User $creator = null
): ?string;
}

View File

@@ -13,7 +13,7 @@ namespace Chill\DocGeneratorBundle\Service\Generator;
class RelatedEntityNotFoundException extends \RuntimeException
{
public function __construct(string $relatedEntityClass, int $relatedEntityId, \Throwable $previous = null)
public function __construct(string $relatedEntityClass, int $relatedEntityId, ?\Throwable $previous = null)
{
parent::__construct(
sprintf('Related entity not found: %s, %s', $relatedEntityClass, $relatedEntityId),

View File

@@ -28,7 +28,9 @@ final readonly class OnGenerationFails implements EventSubscriberInterface
{
public const LOG_PREFIX = '[docgen failed] ';
public function __construct(private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private EntityManagerInterface $entityManager, private LoggerInterface $logger, private MailerInterface $mailer, private StoredObjectRepository $storedObjectRepository, private TranslatorInterface $translator, private UserRepositoryInterface $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)
{
}
public static function getSubscribedEvents()
{

View File

@@ -30,7 +30,9 @@ class RequestGenerationHandler implements MessageHandlerInterface
private const LOG_PREFIX = '[docgen message handler] ';
public function __construct(private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly EntityManagerInterface $entityManager, private readonly Generator $generator, private readonly LoggerInterface $logger, private readonly StoredObjectRepository $storedObjectRepository, private readonly UserRepositoryInterface $userRepository) {}
public function __construct(private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly EntityManagerInterface $entityManager, private readonly Generator $generator, private readonly LoggerInterface $logger, private readonly StoredObjectRepository $storedObjectRepository, private readonly UserRepositoryInterface $userRepository)
{
}
public function __invoke(RequestGenerationMessage $message)
{

View File

@@ -56,7 +56,7 @@ final class BaseContextDataTest extends KernelTestCase
}
private function buildBaseContext(
NormalizerInterface $normalizer = null
?NormalizerInterface $normalizer = null
): BaseContextData {
return new BaseContextData(
$normalizer ?? self::getContainer()->get(NormalizerInterface::class)