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

@@ -29,7 +29,8 @@ final readonly class GenericDocForAccompanyingPeriodController
private PaginatorFactory $paginator,
private Security $security,
private \Twig\Environment $twig,
) {}
) {
}
/**
* @throws \Doctrine\DBAL\Exception

View File

@@ -29,7 +29,8 @@ final readonly class GenericDocForPerson
private PaginatorFactory $paginator,
private Security $security,
private \Twig\Environment $twig,
) {}
) {
}
/**
* @throws \Doctrine\DBAL\Exception

View File

@@ -20,7 +20,9 @@ use Symfony\Component\Security\Core\Security;
class StoredObjectApiController
{
public function __construct(private readonly Security $security) {}
public function __construct(private readonly Security $security)
{
}
/**
* @Route("/api/1.0/doc-store/stored-object/{uuid}/is-ready")

View File

@@ -37,7 +37,7 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
* @ORM\JoinColumn(name="category_id_inside_bundle", referencedColumnName="id_inside_bundle")
* })
*/
private ?\Chill\DocStoreBundle\Entity\DocumentCategory $category = null;
private ?DocumentCategory $category = null;
/**
* @ORM\Column(type="datetime")
@@ -61,12 +61,12 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
* message="Upload a document"
* )
*/
private ?\Chill\DocStoreBundle\Entity\StoredObject $object = null;
private ?StoredObject $object = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate")
*/
private ?\Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate $template = null;
private ?DocGeneratorTemplate $template = null;
/**
* @ORM\Column(type="text")
@@ -138,7 +138,7 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function setObject(StoredObject $object = null)
public function setObject(?StoredObject $object = null)
{
$this->object = $object;

View File

@@ -53,7 +53,8 @@ class DocumentCategory
* @var int The id which is unique inside the bundle
*/
private $idInsideBundle
) {}
) {
}
public function getBundleId() // ::class BundleClass (FQDN)
{

View File

@@ -43,7 +43,7 @@ class PersonDocument extends Document implements HasCenterInterface, HasScopeInt
*
* @var Scope The document's center
*/
private ?\Chill\MainBundle\Entity\Scope $scope = null;
private ?Scope $scope = null;
public function getCenter()
{

View File

@@ -30,7 +30,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PersonDocumentType extends AbstractType
{
public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly ScopeResolverDispatcher $scopeResolverDispatcher, private readonly ParameterBagInterface $parameterBag, private readonly CenterResolverDispatcher $centerResolverDispatcher) {}
public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly ScopeResolverDispatcher $scopeResolverDispatcher, private readonly ParameterBagInterface $parameterBag, private readonly CenterResolverDispatcher $centerResolverDispatcher)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{

View File

@@ -54,7 +54,8 @@ class FetchQuery implements FetchQueryInterface
private array $selectIdentifierTypes = [],
private array $selectDateParams = [],
private array $selectDateTypes = [],
) {}
) {
}
public function addJoinClause(string $sql, array $params = [], array $types = []): int
{

View File

@@ -21,7 +21,8 @@ final readonly class GenericDocDTO
public array $identifiers,
public \DateTimeImmutable $docDate,
public AccompanyingPeriod|Person $linked,
) {}
) {
}
public function getContext(): string
{

View File

@@ -17,10 +17,10 @@ interface GenericDocForAccompanyingPeriodProviderInterface
{
public function buildFetchQueryForAccompanyingPeriod(
AccompanyingPeriod $accompanyingPeriod,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
string $origin = null
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
?string $origin = null
): FetchQueryInterface;
/**

View File

@@ -17,10 +17,10 @@ interface GenericDocForPersonProviderInterface
{
public function buildFetchQueryForPerson(
Person $person,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
string $origin = null
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
?string $origin = null
): FetchQueryInterface;
/**

View File

@@ -43,9 +43,9 @@ final readonly class Manager
*/
public function countDocForAccompanyingPeriod(
AccompanyingPeriod $accompanyingPeriod,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
array $places = []
): int {
['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $places);
@@ -73,9 +73,9 @@ final readonly class Manager
public function countDocForPerson(
Person $person,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
array $places = []
): int {
['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($person, $startDate, $endDate, $content, $places);
@@ -94,9 +94,9 @@ final readonly class Manager
AccompanyingPeriod $accompanyingPeriod,
int $offset = 0,
int $limit = 20,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
array $places = []
): iterable {
['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $places);
@@ -137,9 +137,9 @@ final readonly class Manager
Person $person,
int $offset = 0,
int $limit = 20,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
array $places = []
): iterable {
['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($person, $startDate, $endDate, $content, $places);
@@ -183,9 +183,9 @@ final readonly class Manager
*/
private function buildUnionQuery(
AccompanyingPeriod|Person $linked,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
array $places = [],
): array {
$queries = [];

View File

@@ -31,9 +31,10 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen
public function __construct(
private Security $security,
private EntityManagerInterface $entityManager,
) {}
) {
}
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
{
$classMetadata = $this->entityManager->getClassMetadata(AccompanyingCourseDocument::class);
@@ -58,7 +59,7 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen
return $this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod);
}
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
public function buildFetchQueryForPerson(Person $person, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
{
$classMetadata = $this->entityManager->getClassMetadata(AccompanyingCourseDocument::class);
@@ -107,7 +108,7 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen
return $this->security->isGranted(AccompanyingPeriodVoter::SEE, $person);
}
private function addWhereClause(FetchQuery $query, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery
private function addWhereClause(FetchQuery $query, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
{
$classMetadata = $this->entityManager->getClassMetadata(AccompanyingCourseDocument::class);

View File

@@ -27,14 +27,15 @@ final readonly class PersonDocumentGenericDocProvider implements GenericDocForPe
public function __construct(
private Security $security,
private PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository,
) {}
) {
}
public function buildFetchQueryForPerson(
Person $person,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
string $origin = null
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
?string $origin = null
): FetchQueryInterface {
return $this->personDocumentACLAwareRepository->buildFetchQueryForPerson(
$person,
@@ -49,7 +50,7 @@ final readonly class PersonDocumentGenericDocProvider implements GenericDocForPe
return $this->security->isGranted(PersonDocumentVoter::SEE, $person);
}
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
{
return $this->personDocumentACLAwareRepository->buildFetchQueryForAccompanyingPeriod($accompanyingPeriod, $startDate, $endDate, $content);
}

View File

@@ -23,7 +23,8 @@ final readonly class AccompanyingCourseDocumentGenericDocRenderer implements Gen
public function __construct(
private AccompanyingCourseDocumentRepository $accompanyingCourseDocumentRepository,
private PersonDocumentRepository $personDocumentRepository,
) {}
) {
}
public function supports(GenericDocDTO $genericDocDTO, $options = []): bool
{

View File

@@ -25,7 +25,8 @@ final readonly class GenericDocExtensionRuntime implements RuntimeExtensionInter
* @var list<GenericDocRendererInterface>
*/
private iterable $renderers,
) {}
) {
}
/**
* @throws RuntimeError

View File

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

View File

@@ -55,7 +55,7 @@ class AccompanyingCourseDocumentRepository implements ObjectRepository
return $this->repository->findAll();
}
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}

View File

@@ -41,7 +41,7 @@ class DocumentCategoryRepository implements ObjectRepository
return $this->repository->findAll();
}
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}

View File

@@ -34,7 +34,8 @@ final readonly class PersonDocumentACLAwareRepository implements PersonDocumentA
private CenterResolverManagerInterface $centerResolverManager,
private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser,
private Security $security,
) {}
) {
}
public function buildQueryByPerson(Person $person): QueryBuilder
{
@@ -47,14 +48,14 @@ final readonly class PersonDocumentACLAwareRepository implements PersonDocumentA
return $qb;
}
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQueryInterface
public function buildFetchQueryForPerson(Person $person, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface
{
$query = $this->buildBaseFetchQueryForPerson($person, $startDate, $endDate, $content);
return $this->addFetchQueryByPersonACL($query, $person);
}
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $period, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQueryInterface
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface
{
$personDocMetadata = $this->em->getClassMetadata(PersonDocument::class);
$participationMetadata = $this->em->getClassMetadata(AccompanyingPeriodParticipation::class);
@@ -113,7 +114,7 @@ final readonly class PersonDocumentACLAwareRepository implements PersonDocumentA
return $this->addFilterClauses($query, $startDate, $endDate, $content);
}
public function buildBaseFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery
public function buildBaseFetchQueryForPerson(Person $person, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
{
$personDocMetadata = $this->em->getClassMetadata(PersonDocument::class);
@@ -133,7 +134,7 @@ final readonly class PersonDocumentACLAwareRepository implements PersonDocumentA
return $this->addFilterClauses($query, $startDate, $endDate, $content);
}
private function addFilterClauses(FetchQuery $query, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery
private function addFilterClauses(FetchQuery $query, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
{
$personDocMetadata = $this->em->getClassMetadata(PersonDocument::class);

View File

@@ -29,15 +29,15 @@ interface PersonDocumentACLAwareRepositoryInterface
public function buildFetchQueryForPerson(
Person $person,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null
): FetchQueryInterface;
public function buildFetchQueryForAccompanyingPeriod(
AccompanyingPeriod $period,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null
): FetchQueryInterface;
}

View File

@@ -39,7 +39,7 @@ readonly class PersonDocumentRepository implements ObjectRepository
return $this->repository->findAll();
}
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null)
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null)
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}

View File

@@ -44,7 +44,7 @@ final class StoredObjectRepository implements ObjectRepository
*
* @return array<int, StoredObject>
*/
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);
}

View File

@@ -20,7 +20,9 @@ class StoredObjectDenormalizer implements DenormalizerInterface
{
use ObjectToPopulateTrait;
public function __construct(private readonly StoredObjectRepository $storedObjectRepository) {}
public function __construct(private readonly StoredObjectRepository $storedObjectRepository)
{
}
public function denormalize($data, $type, $format = null, array $context = [])
{

View File

@@ -30,7 +30,9 @@ final class StoredObjectManager implements StoredObjectManagerInterface
public function __construct(
private readonly HttpClientInterface $client,
private readonly TempUrlGeneratorInterface $tempUrlGenerator
) {}
)
{
}
public function getLastModified(StoredObject $document): \DateTimeInterface
{

View File

@@ -120,7 +120,9 @@ final readonly class WopiEditTwigExtensionRuntime implements RuntimeExtensionInt
private const TEMPLATE_BUTTON_GROUP = '@ChillDocStore/Button/button_group.html.twig';
public function __construct(private DiscoveryInterface $discovery, private NormalizerInterface $normalizer) {}
public function __construct(private DiscoveryInterface $discovery, private NormalizerInterface $normalizer)
{
}
/**
* return true if the document is editable.
@@ -134,13 +136,13 @@ final readonly class WopiEditTwigExtensionRuntime implements RuntimeExtensionInt
}
/**
* @param array{small: boolean} $options
* @param array{small: bool} $options
*
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
*/
public function renderButtonGroup(Environment $environment, StoredObject $document, string $title = null, bool $canEdit = true, array $options = []): string
public function renderButtonGroup(Environment $environment, StoredObject $document, ?string $title = null, bool $canEdit = true, array $options = []): string
{
return $environment->render(self::TEMPLATE_BUTTON_GROUP, [
'document' => $document,
@@ -151,7 +153,7 @@ final readonly class WopiEditTwigExtensionRuntime implements RuntimeExtensionInt
]);
}
public function renderEditButton(Environment $environment, StoredObject $document, array $options = null): string
public function renderEditButton(Environment $environment, StoredObject $document, ?array $options = null): string
{
return $environment->render(self::TEMPLATE, [
'document' => $document,

View File

@@ -174,7 +174,7 @@ class ManagerTest extends KernelTestCase
final readonly class SimpleGenericDocAccompanyingPeriodProvider implements GenericDocForAccompanyingPeriodProviderInterface
{
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
{
$query = new FetchQuery(
'accompanying_course_document_dummy',
@@ -196,7 +196,7 @@ final readonly class SimpleGenericDocAccompanyingPeriodProvider implements Gener
final readonly class SimpleGenericDocPersonProvider implements GenericDocForPersonProviderInterface
{
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
public function buildFetchQueryForPerson(Person $person, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
{
$query = new FetchQuery(
'dummy_person_doc',

View File

@@ -40,7 +40,7 @@ class AccompanyingCourseDocumentGenericDocProviderTest extends KernelTestCase
/**
* @dataProvider provideSearchArguments
*/
public function testWithoutAnyArgument(?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, string $content = null): void
public function testWithoutAnyArgument(?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content = null): void
{
$period = $this->entityManager->createQuery('SELECT a FROM '.AccompanyingPeriod::class.' a')
->setMaxResults(1)

View File

@@ -53,7 +53,7 @@ class PersonDocumentACLAwareRepositoryTest extends KernelTestCase
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function testBuildFetchQueryForPerson(\DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): void
public function testBuildFetchQueryForPerson(?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): void
{
$centerManager = $this->prophesize(CenterResolverManagerInterface::class);
$centerManager->resolveCenters(Argument::type(Person::class))
@@ -92,9 +92,9 @@ class PersonDocumentACLAwareRepositoryTest extends KernelTestCase
*/
public function testBuildFetchQueryForAccompanyingPeriod(
AccompanyingPeriod $period,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null
): void {
$centerManager = $this->prophesize(CenterResolverManagerInterface::class);
$centerManager->resolveCenters(Argument::type(Person::class))

View File

@@ -91,7 +91,7 @@ final class StoredObjectManagerTest extends TestCase
/**
* @dataProvider getDataProvider
*/
public function testRead(StoredObject $storedObject, string $encodedContent, string $clearContent, string $exceptionClass = null)
public function testRead(StoredObject $storedObject, string $encodedContent, string $clearContent, ?string $exceptionClass = null)
{
if (null !== $exceptionClass) {
$this->expectException($exceptionClass);
@@ -105,7 +105,7 @@ final class StoredObjectManagerTest extends TestCase
/**
* @dataProvider getDataProvider
*/
public function testWrite(StoredObject $storedObject, string $encodedContent, string $clearContent, string $exceptionClass = null)
public function testWrite(StoredObject $storedObject, string $encodedContent, string $clearContent, ?string $exceptionClass = null)
{
if (null !== $exceptionClass) {
$this->expectException($exceptionClass);