Apply rector rules: symfony up to 54

This commit is contained in:
2024-04-04 23:30:25 +02:00
parent 1ee3b9e2f0
commit 579bd829f8
204 changed files with 974 additions and 2346 deletions

View File

@@ -21,6 +21,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
class ConfigureOpenstackObjectStorageCommand extends Command
{
protected static $defaultDescription = 'Configure openstack container to store documents';
private readonly string $basePath;
private readonly string $tempUrlKey;
@@ -37,7 +38,7 @@ class ConfigureOpenstackObjectStorageCommand extends Command
protected function configure()
{
$this->setDescription('Configure openstack container to store documents')
$this
->setName('chill:doc-store:configure-openstack')
->addOption('os_token', 'o', InputOption::VALUE_REQUIRED, 'Openstack token')
->addOption('domain', 'd', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Domain name')
@@ -85,6 +86,6 @@ class ConfigureOpenstackObjectStorageCommand extends Command
}
}
return 0;
return Command::SUCCESS;
}
}

View File

@@ -16,21 +16,14 @@ use Symfony\Component\Serializer\Annotation as Serializer;
readonly class SignedUrl
{
public function __construct(
/**
* @Serializer\Groups({"read"})
*/
#[Serializer\Groups(['read'])]
public string $method,
/**
* @Serializer\Groups({"read"})
*/
#[Serializer\Groups(['read'])]
public string $url,
public \DateTimeImmutable $expires,
) {}
/**
* @Serializer\Groups({"read"})
*/
#[Serializer\Groups(['read'])]
public function getExpires(): int
{
return $this->expires->getTimestamp();

View File

@@ -18,35 +18,17 @@ readonly class SignedUrlPost extends SignedUrl
public function __construct(
string $url,
\DateTimeImmutable $expires,
/**
* @Serializer\Groups({"read"})
*/
#[Serializer\Groups(['read'])]
public int $max_file_size,
/**
* @Serializer\Groups({"read"})
*/
#[Serializer\Groups(['read'])]
public int $max_file_count,
/**
* @Serializer\Groups({"read"})
*/
#[Serializer\Groups(['read'])]
public int $submit_delay,
/**
* @Serializer\Groups({"read"})
*/
#[Serializer\Groups(['read'])]
public string $redirect,
/**
* @Serializer\Groups({"read"})
*/
#[Serializer\Groups(['read'])]
public string $prefix,
/**
* @Serializer\Groups({"read"})
*/
#[Serializer\Groups(['read'])]
public string $signature,
) {
parent::__construct('POST', $url, $expires);

View File

@@ -20,9 +20,8 @@ class AdminController extends AbstractController
{
/**
* @return \Symfony\Component\HttpFoundation\Response
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/document", name="chill_docstore_admin", options={null})
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/document', name: 'chill_docstore_admin', options: [null])]
public function indexAction()
{
return $this->render('@ChillDocStore/Admin/layout.html.twig');
@@ -30,9 +29,8 @@ class AdminController extends AbstractController
/**
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/document_redirect_to_main", name="chill_docstore_admin_redirect_to_admin_index", options={null})
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/document_redirect_to_main', name: 'chill_docstore_admin_redirect_to_admin_index', options: [null])]
public function redirectToAdminIndexAction()
{
return $this->redirectToRoute('chill_main_admin_central');

View File

@@ -33,10 +33,7 @@ final readonly class AsyncUploadController
private LoggerInterface $logger,
) {}
/**
* @Route("/asyncupload/temp_url/generate/{method}",
* name="async_upload.generate_url")
*/
#[Route(path: '/asyncupload/temp_url/generate/{method}', name: 'async_upload.generate_url')]
public function getSignedUrl(string $method, Request $request): JsonResponse
{
try {

View File

@@ -25,9 +25,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @Route("/{_locale}/parcours/{course}/document")
*/
#[Route(path: '/{_locale}/parcours/{course}/document')]
class DocumentAccompanyingCourseController extends AbstractController
{
/**
@@ -40,9 +38,7 @@ class DocumentAccompanyingCourseController extends AbstractController
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry
) {}
/**
* @Route("/{id}/delete", name="chill_docstore_accompanying_course_document_delete")
*/
#[Route(path: '/{id}/delete', name: 'chill_docstore_accompanying_course_document_delete')]
public function delete(Request $request, AccompanyingPeriod $course, AccompanyingCourseDocument $document): Response
{
$this->denyAccessUnlessGranted(AccompanyingCourseDocumentVoter::DELETE, $document);
@@ -75,9 +71,7 @@ class DocumentAccompanyingCourseController extends AbstractController
);
}
/**
* @Route("/{id}/edit", name="accompanying_course_document_edit", methods="GET|POST")
*/
#[Route(path: '/{id}/edit', name: 'accompanying_course_document_edit', methods: 'GET|POST')]
public function edit(Request $request, AccompanyingPeriod $course, AccompanyingCourseDocument $document): Response
{
$this->denyAccessUnlessGranted(AccompanyingCourseDocumentVoter::UPDATE, $document);
@@ -116,9 +110,7 @@ class DocumentAccompanyingCourseController extends AbstractController
);
}
/**
* @Route("/new", name="accompanying_course_document_new", methods="GET|POST")
*/
#[Route(path: '/new', name: 'accompanying_course_document_new', methods: 'GET|POST')]
public function new(Request $request, AccompanyingPeriod $course): Response
{
if (null === $course) {
@@ -162,9 +154,7 @@ class DocumentAccompanyingCourseController extends AbstractController
]);
}
/**
* @Route("/{id}", name="accompanying_course_document_show", methods="GET")
*/
#[Route(path: '/{id}', name: 'accompanying_course_document_show', methods: 'GET')]
public function show(AccompanyingPeriod $course, AccompanyingCourseDocument $document): Response
{
$this->denyAccessUnlessGranted(AccompanyingCourseDocumentVoter::SEE_DETAILS, $document);

View File

@@ -20,16 +20,12 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/{_locale}/admin/document/category")
*/
#[Route(path: '/{_locale}/admin/document/category')]
class DocumentCategoryController extends AbstractController
{
public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
/**
* @Route("/{bundleId}/{idInsideBundle}", name="document_category_delete", methods="DELETE")
*/
#[Route(path: '/{bundleId}/{idInsideBundle}', name: 'document_category_delete', methods: 'DELETE')]
public function delete(Request $request, mixed $bundleId, mixed $idInsideBundle): Response
{
$em = $this->managerRegistry->getManager();
@@ -47,9 +43,7 @@ class DocumentCategoryController extends AbstractController
return $this->redirectToRoute('document_category_index');
}
/**
* @Route("/{bundleId}/{idInsideBundle}/edit", name="document_category_edit", methods="GET|POST")
*/
#[Route(path: '/{bundleId}/{idInsideBundle}/edit', name: 'document_category_edit', methods: 'GET|POST')]
public function edit(Request $request, mixed $bundleId, mixed $idInsideBundle): Response
{
$em = $this->managerRegistry->getManager();
@@ -76,9 +70,8 @@ class DocumentCategoryController extends AbstractController
]);
}
/**
* @Route("/", name="document_category_index", methods="GET")
* @Route("/", name="chill_docstore_category_admin", methods="GET") */
#[Route(path: '/', name: 'document_category_index', methods: 'GET')]
#[Route(path: '/', name: 'chill_docstore_category_admin', methods: 'GET')]
public function index(): Response
{
$em = $this->managerRegistry->getManager();
@@ -92,9 +85,7 @@ class DocumentCategoryController extends AbstractController
);
}
/**
* @Route("/new", name="document_category_new", methods="GET|POST")
*/
#[Route(path: '/new', name: 'document_category_new', methods: 'GET|POST')]
public function new(Request $request): Response
{
$em = $this->managerRegistry->getManager();
@@ -130,9 +121,7 @@ class DocumentCategoryController extends AbstractController
]);
}
/**
* @Route("/{bundleId}/{idInsideBundle}", name="document_category_show", methods="GET")
*/
#[Route(path: '/{bundleId}/{idInsideBundle}', name: 'document_category_show', methods: 'GET')]
public function show(mixed $bundleId, mixed $idInsideBundle): Response
{
$em = $this->managerRegistry->getManager();

View File

@@ -29,11 +29,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Class DocumentPersonController.
*
* @Route("/{_locale}/person/{person}/document")
*
* TODO faire un controller abstrait ?
*/
#[Route(path: '/{_locale}/person/{person}/document')] // TODO faire un controller abstrait ?
class DocumentPersonController extends AbstractController
{
/**
@@ -46,9 +43,7 @@ class DocumentPersonController extends AbstractController
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry
) {}
/**
* @Route("/{id}/delete", name="chill_docstore_person_document_delete")
*/
#[Route(path: '/{id}/delete', name: 'chill_docstore_person_document_delete')]
public function delete(Request $request, Person $person, PersonDocument $document): Response
{
$this->denyAccessUnlessGranted(PersonDocumentVoter::DELETE, $document);
@@ -81,9 +76,7 @@ class DocumentPersonController extends AbstractController
);
}
/**
* @Route("/{id}/edit", name="person_document_edit", methods="GET|POST")
*/
#[Route(path: '/{id}/edit', name: 'person_document_edit', methods: 'GET|POST')]
public function edit(Request $request, Person $person, PersonDocument $document): Response
{
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
@@ -140,9 +133,7 @@ class DocumentPersonController extends AbstractController
);
}
/**
* @Route("/new", name="person_document_new", methods="GET|POST")
*/
#[Route(path: '/new', name: 'person_document_new', methods: 'GET|POST')]
public function new(Request $request, Person $person): Response
{
if (null === $person) {
@@ -188,9 +179,7 @@ class DocumentPersonController extends AbstractController
]);
}
/**
* @Route("/{id}", name="person_document_show", methods="GET")
*/
#[Route(path: '/{id}', name: 'person_document_show', methods: 'GET')]
public function show(Person $person, PersonDocument $document): Response
{
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);

View File

@@ -33,9 +33,8 @@ final readonly class GenericDocForAccompanyingPeriodController
/**
* @throws \Doctrine\DBAL\Exception
*
* @Route("/{_locale}/doc-store/generic-doc/by-period/{id}/index", name="chill_docstore_generic-doc_by-period_index")
*/
#[Route(path: '/{_locale}/doc-store/generic-doc/by-period/{id}/index', name: 'chill_docstore_generic-doc_by-period_index')]
public function list(AccompanyingPeriod $accompanyingPeriod): Response
{
if (!$this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod)) {

View File

@@ -33,9 +33,8 @@ final readonly class GenericDocForPerson
/**
* @throws \Doctrine\DBAL\Exception
*
* @Route("/{_locale}/doc-store/generic-doc/by-person/{id}/index", name="chill_docstore_generic-doc_by-person_index")
*/
#[Route(path: '/{_locale}/doc-store/generic-doc/by-person/{id}/index', name: 'chill_docstore_generic-doc_by-person_index')]
public function list(Person $person): Response
{
if (!$this->security->isGranted(PersonDocumentVoter::SEE, $person)) {

View File

@@ -22,9 +22,7 @@ class StoredObjectApiController
{
public function __construct(private readonly Security $security) {}
/**
* @Route("/api/1.0/doc-store/stored-object/{uuid}/is-ready")
*/
#[Route(path: '/api/1.0/doc-store/stored-object/{uuid}/is-ready')]
public function isDocumentReady(StoredObject $storedObject): Response
{
if (!$this->security->isGranted('ROLE_USER')) {

View File

@@ -54,13 +54,9 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
* targetEntity="Chill\DocStoreBundle\Entity\StoredObject",
* cascade={"persist"}
* )
*
* @Assert\Valid
*
* @Assert\NotNull(
* message="Upload a document"
* )
*/
#[Assert\Valid]
#[Assert\NotNull(message: 'Upload a document')]
private ?StoredObject $object = null;
/**
@@ -70,11 +66,8 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(type="text")
*
* @Assert\Length(
* min=2, max=250
* )
*/
#[Assert\Length(min: 2, max: 250)]
private string $title = '';
/**

View File

@@ -46,16 +46,14 @@ class StoredObject implements Document, TrackCreationInterface
/**
* @ORM\Column(type="json", name="datas")
*
* @Serializer\Groups({"read", "write"})
*/
#[Serializer\Groups(['read', 'write'])]
private array $datas = [];
/**
* @ORM\Column(type="text")
*
* @Serializer\Groups({"read", "write"})
*/
#[Serializer\Groups(['read', 'write'])]
private string $filename = '';
/**
@@ -64,46 +62,40 @@ class StoredObject implements Document, TrackCreationInterface
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "write"})
*/
#[Serializer\Groups(['read', 'write'])]
private ?int $id = null;
/**
* @var int[]
*
* @ORM\Column(type="json", name="iv")
*
* @Serializer\Groups({"read", "write"})
*/
#[Serializer\Groups(['read', 'write'])]
private array $iv = [];
/**
* @ORM\Column(type="json", name="key")
*
* @Serializer\Groups({"read", "write"})
*/
#[Serializer\Groups(['read', 'write'])]
private array $keyInfos = [];
/**
* @ORM\Column(type="text", name="title")
*
* @Serializer\Groups({"read", "write"})
*/
#[Serializer\Groups(['read', 'write'])]
private string $title = '';
/**
* @ORM\Column(type="text", name="type", options={"default": ""})
*
* @Serializer\Groups({"read", "write"})
*/
#[Serializer\Groups(['read', 'write'])]
private string $type = '';
/**
* @ORM\Column(type="uuid", unique=true)
*
* @Serializer\Groups({"read", "write"})
*/
#[Serializer\Groups(['read', 'write'])]
private UuidInterface $uuid;
/**
@@ -135,10 +127,9 @@ class StoredObject implements Document, TrackCreationInterface
* @param StoredObject::STATUS_* $status
*/
public function __construct(/**
* @ORM\Column(type="text", options={"default": "ready"})
*
* @Serializer\Groups({"read"})
*/
* @ORM\Column(type="text", options={"default": "ready"})
*/
#[Serializer\Groups(['read'])]
private string $status = 'ready'
) {
$this->uuid = Uuid::uuid4();
@@ -152,10 +143,9 @@ class StoredObject implements Document, TrackCreationInterface
}
/**
* @Serializer\Groups({"read", "write"})
*
* @deprecated
*/
#[Serializer\Groups(['read', 'write'])]
public function getCreationDate(): \DateTime
{
if (null === $this->createdAt) {
@@ -233,10 +223,9 @@ class StoredObject implements Document, TrackCreationInterface
}
/**
* @Serializer\Groups({"write"})
*
* @deprecated
*/
#[Serializer\Groups(['write'])]
public function setCreationDate(\DateTime $creationDate): self
{
$this->createdAt = \DateTimeImmutable::createFromMutable($creationDate);