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

@@ -33,31 +33,11 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/
class DocumentAccompanyingCourseController extends AbstractController
{
protected AuthorizationHelper $authorizationHelper;
protected EventDispatcherInterface $eventDispatcher;
protected TranslatorInterface $translator;
private AccompanyingCourseDocumentRepository $courseRepository;
private PaginatorFactory $paginatorFactory;
/**
* DocumentAccompanyingCourseController constructor.
*/
public function __construct(
TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher,
AuthorizationHelper $authorizationHelper,
PaginatorFactory $paginatorFactory,
AccompanyingCourseDocumentRepository $courseRepository
) {
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
$this->authorizationHelper = $authorizationHelper;
$this->paginatorFactory = $paginatorFactory;
$this->courseRepository = $courseRepository;
public function __construct(protected TranslatorInterface $translator, protected EventDispatcherInterface $eventDispatcher, protected AuthorizationHelper $authorizationHelper, private PaginatorFactory $paginatorFactory, private AccompanyingCourseDocumentRepository $courseRepository)
{
}
/**

View File

@@ -27,11 +27,8 @@ class DocumentCategoryController extends AbstractController
{
/**
* @Route("/{bundleId}/{idInsideBundle}", name="document_category_delete", methods="DELETE")
*
* @param mixed $bundleId
* @param mixed $idInsideBundle
*/
public function delete(Request $request, $bundleId, $idInsideBundle): Response
public function delete(Request $request, mixed $bundleId, mixed $idInsideBundle): Response
{
$em = $this->getDoctrine()->getManager();
$documentCategory = $em
@@ -50,11 +47,8 @@ class DocumentCategoryController extends AbstractController
/**
* @Route("/{bundleId}/{idInsideBundle}/edit", name="document_category_edit", methods="GET|POST")
*
* @param mixed $bundleId
* @param mixed $idInsideBundle
*/
public function edit(Request $request, $bundleId, $idInsideBundle): Response
public function edit(Request $request, mixed $bundleId, mixed $idInsideBundle): Response
{
$em = $this->getDoctrine()->getManager();
$documentCategory = $em
@@ -136,11 +130,8 @@ class DocumentCategoryController extends AbstractController
/**
* @Route("/{bundleId}/{idInsideBundle}", name="document_category_show", methods="GET")
*
* @param mixed $bundleId
* @param mixed $idInsideBundle
*/
public function show($bundleId, $idInsideBundle): Response
public function show(mixed $bundleId, mixed $idInsideBundle): Response
{
$em = $this->getDoctrine()->getManager();
$documentCategory = $em

View File

@@ -39,31 +39,11 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/
class DocumentPersonController extends AbstractController
{
protected AuthorizationHelper $authorizationHelper;
protected EventDispatcherInterface $eventDispatcher;
protected TranslatorInterface $translator;
private PaginatorFactory $paginatorFactory;
private PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository;
/**
* DocumentPersonController constructor.
*/
public function __construct(
TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher,
AuthorizationHelper $authorizationHelper,
PaginatorFactory $paginatorFactory,
PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository
) {
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
$this->authorizationHelper = $authorizationHelper;
$this->paginatorFactory = $paginatorFactory;
$this->personDocumentACLAwareRepository = $personDocumentACLAwareRepository;
public function __construct(protected TranslatorInterface $translator, protected EventDispatcherInterface $eventDispatcher, protected AuthorizationHelper $authorizationHelper, private PaginatorFactory $paginatorFactory, private PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository)
{
}
/**

View File

@@ -20,11 +20,8 @@ use Symfony\Component\Security\Core\Security;
class StoredObjectApiController
{
private Security $security;
public function __construct(Security $security)
public function __construct(private Security $security)
{
$this->security = $security;
}
/**

View File

@@ -19,14 +19,6 @@ use Doctrine\ORM\Mapping as ORM;
*/
class DocumentCategory
{
/**
* @ORM\Id
* @ORM\Column(type="string", name="bundle_id")
*
* @var string The id of the bundle that has create the category (i.e. 'person', 'activity', ....)
*/
private $bundleId;
/**
* @ORM\Column(type="string", name="document_class")
*
@@ -34,23 +26,31 @@ class DocumentCategory
*/
private $documentClass;
/**
* @ORM\Id
* @ORM\Column(type="integer", name="id_inside_bundle")
*
* @var int The id which is unique inside the bundle
*/
private $idInsideBundle;
/**
* @ORM\Column(type="json")
*/
private $name;
public function __construct($bundleId, $idInsideBundle)
{
$this->bundleId = $bundleId;
$this->idInsideBundle = $idInsideBundle;
/**
* @param string $bundleId
* @param int $idInsideBundle
*/
public function __construct(
/**
* @ORM\Id
* @ORM\Column(type="string", name="bundle_id")
*
* @var string The id of the bundle that has create the category (i.e. 'person', 'activity', ....)
*/
private $bundleId,
/**
* @ORM\Id
* @ORM\Column(type="integer", name="id_inside_bundle")
*
* @var int The id which is unique inside the bundle
*/
private $idInsideBundle
) {
}
public function getBundleId() // ::class BundleClass (FQDN)

View File

@@ -96,12 +96,6 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa
*/
private ?DocGeneratorTemplate $template = null;
/**
* @ORM\Column(type="text", options={"default": "ready"})
* @Serializer\Groups({"read"})
*/
private string $status;
/**
* Store the number of times a generation has been tryied for this StoredObject.
*
@@ -115,10 +109,13 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa
/**
* @param StoredObject::STATUS_* $status
*/
public function __construct(string $status = "ready")
{
public function __construct(/**
* @ORM\Column(type="text", options={"default": "ready"})
* @Serializer\Groups({"read"})
*/
private string $status = "ready"
) {
$this->uuid = Uuid::uuid4();
$this->status = $status;
}
public function addGenerationTrial(): self

View File

@@ -26,7 +26,7 @@ class DocumentCategoryType extends AbstractType
{
// TODO faire un service dans CHillMain
foreach ($kernelBundles as $key => $value) {
if (substr($key, 0, 5) === 'Chill') {
if (str_starts_with($key, 'Chill')) {
$this->chillBundlesFlipped[$value] = $key;
}
}

View File

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

View File

@@ -21,34 +21,17 @@ use Symfony\Contracts\Translation\TranslatorInterface;
final class MenuBuilder implements LocalMenuBuilderInterface
{
private Security $security;
private TranslatorInterface $translator;
public function __construct(
Security $security,
TranslatorInterface $translator
) {
$this->security = $security;
$this->translator = $translator;
public function __construct(private Security $security, private TranslatorInterface $translator)
{
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
switch ($menuId) {
case 'accompanyingCourse':
$this->buildMenuAccompanyingCourse($menu, $parameters);
break;
case 'person':
$this->buildMenuPerson($menu, $parameters);
break;
default:
throw new LogicException("this menuid {$menuId} is not implemented");
}
match ($menuId) {
'accompanyingCourse' => $this->buildMenuAccompanyingCourse($menu, $parameters),
'person' => $this->buildMenuPerson($menu, $parameters),
default => throw new LogicException("this menuid {$menuId} is not implemented"),
};
}
public static function getMenuIds(): array

View File

@@ -20,13 +20,10 @@ use Doctrine\Persistence\ObjectRepository;
class AccompanyingCourseDocumentRepository implements ObjectRepository
{
private EntityManagerInterface $em;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $em)
public function __construct(private EntityManagerInterface $em)
{
$this->em = $em;
$this->repository = $em->getRepository(AccompanyingCourseDocument::class);
}

View File

@@ -21,13 +21,10 @@ use Doctrine\Persistence\ObjectRepository;
*/
class DocumentCategoryRepository implements ObjectRepository
{
private EntityManagerInterface $em;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $em)
public function __construct(private EntityManagerInterface $em)
{
$this->em = $em;
$this->repository = $em->getRepository(DocumentCategory::class);
}

View File

@@ -22,20 +22,8 @@ use Symfony\Component\Security\Core\Security;
class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareRepositoryInterface
{
private AuthorizationHelperInterface $authorizationHelper;
private CenterResolverDispatcher $centerResolverDispatcher;
private EntityManagerInterface $em;
private Security $security;
public function __construct(EntityManagerInterface $em, AuthorizationHelperInterface $authorizationHelper, CenterResolverDispatcher $centerResolverDispatcher, Security $security)
public function __construct(private EntityManagerInterface $em, private AuthorizationHelperInterface $authorizationHelper, private CenterResolverDispatcher $centerResolverDispatcher, private Security $security)
{
$this->em = $em;
$this->authorizationHelper = $authorizationHelper;
$this->centerResolverDispatcher = $centerResolverDispatcher;
$this->security = $security;
}
public function buildQueryByPerson(Person $person): QueryBuilder

View File

@@ -37,19 +37,13 @@ class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements Prov
public const UPDATE = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE';
protected LoggerInterface $logger;
protected Security $security;
protected VoterHelperInterface $voterHelper;
public function __construct(
LoggerInterface $logger,
Security $security,
protected LoggerInterface $logger,
protected Security $security,
VoterHelperFactoryInterface $voterHelperFactory
) {
$this->logger = $logger;
$this->security = $security;
$this->voterHelper = $voterHelperFactory
->generate(self::class)
->addCheckFor(AccompanyingCourseDocument::class, $this->getRoles())

View File

@@ -35,19 +35,13 @@ class PersonDocumentVoter extends AbstractChillVoter implements ProvideRoleHiera
public const UPDATE = 'CHILL_PERSON_DOCUMENT_UPDATE';
protected LoggerInterface $logger;
protected Security $security;
protected VoterHelperInterface $voterHelper;
public function __construct(
LoggerInterface $logger,
Security $security,
protected LoggerInterface $logger,
protected Security $security,
VoterHelperFactoryInterface $voterHelperFactory
) {
$this->logger = $logger;
$this->security = $security;
$this->voterHelper = $voterHelperFactory
->generate(self::class)
->addCheckFor(PersonDocument::class, $this->getRoles())

View File

@@ -22,11 +22,8 @@ class StoredObjectDenormalizer implements DenormalizerInterface
{
use ObjectToPopulateTrait;
private StoredObjectRepository $storedObjectRepository;
public function __construct(StoredObjectRepository $storedObjectRepository)
public function __construct(private StoredObjectRepository $storedObjectRepository)
{
$this->storedObjectRepository = $storedObjectRepository;
}
public function denormalize($data, $type, $format = null, array $context = [])

View File

@@ -33,18 +33,10 @@ final class StoredObjectManager implements StoredObjectManagerInterface
{
private const ALGORITHM = 'AES-256-CBC';
private HttpClientInterface $client;
private array $inMemory = [];
private TempUrlGeneratorInterface $tempUrlGenerator;
public function __construct(
HttpClientInterface $client,
TempUrlGeneratorInterface $tempUrlGenerator
) {
$this->client = $client;
$this->tempUrlGenerator = $tempUrlGenerator;
public function __construct(private HttpClientInterface $client, private TempUrlGeneratorInterface $tempUrlGenerator)
{
}
public function getLastModified(StoredObject $document): DateTimeInterface

View File

@@ -122,14 +122,8 @@ final class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface
private const TEMPLATE_BUTTON_GROUP = '@ChillDocStore/Button/button_group.html.twig';
private DiscoveryInterface $discovery;
private NormalizerInterface $normalizer;
public function __construct(DiscoveryInterface $discovery, NormalizerInterface $normalizer)
public function __construct(private DiscoveryInterface $discovery, private NormalizerInterface $normalizer)
{
$this->discovery = $discovery;
$this->normalizer = $normalizer;
}
/**

View File

@@ -24,17 +24,14 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler
{
private EntityRepository $repository;
private TranslatorInterface $translator;
/**
* TODO: injecter le repository directement.
*/
public function __construct(
EntityManagerInterface $em,
TranslatorInterface $translator
private TranslatorInterface $translator
) {
$this->repository = $em->getRepository(AccompanyingCourseDocument::class);
$this->translator = $translator;
}
public function getDeletionRoles(): array