apply rector rules: php up to php82

This commit is contained in:
2023-07-19 23:16:01 +02:00
parent 7b637d1287
commit 023a29cb78
744 changed files with 1369 additions and 1381 deletions

View File

@@ -25,17 +25,17 @@ class Resolver
/**
* The key to get the role necessary for the action.
*/
public const ROLE = 'role';
final public const ROLE = 'role';
/**
* @deprecated
*/
public const ROLE_EDIT = 'role.edit';
final public const ROLE_EDIT = 'role.edit';
/**
* @deprecated
*/
public const ROLE_VIEW = 'role.view';
final public const ROLE_VIEW = 'role.view';
/**
* @var array

View File

@@ -54,12 +54,12 @@ class TwigCRUDResolver extends AbstractExtension
return [
new TwigFunction(
'chill_crud_config',
[$this, 'getConfig'],
$this->getConfig(...),
['is_safe' => 'html']
),
new TwigFunction(
'chill_crud_action_exists',
[$this, 'hasAction'],
$this->hasAction(...),
[]
),
];

View File

@@ -138,8 +138,8 @@ class ChillImportUsersCommand extends Command
{
$user = new User();
$user
->setEmail(trim($data['email']))
->setUsername(trim($data['username']))
->setEmail(trim((string) $data['email']))
->setUsername(trim((string) $data['username']))
->setEnabled(true)
->setPassword($this->passwordEncoder->encodePassword(
$user,

View File

@@ -160,7 +160,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
try {
if (array_key_exists('email', $row)) {
return $userRepository->findOneByUsernameOrEmail(trim($row['email']));
return $userRepository->findOneByUsernameOrEmail(trim((string) $row['email']));
}
} catch (\Doctrine\ORM\NoResultException) {
// continue, we will try username
@@ -168,7 +168,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
try {
if (array_key_exists('username', $row)) {
return $userRepository->findOneByUsernameOrEmail(trim($row['username']));
return $userRepository->findOneByUsernameOrEmail(trim((string) $row['username']));
}
} catch (\Doctrine\ORM\NoResultException) {
return null;

View File

@@ -20,7 +20,7 @@ use Symfony\Component\Console\Output\OutputInterface;
class ExecuteCronJobCommand extends Command
{
public function __construct(
private CronManagerInterface $cronManager
private readonly CronManagerInterface $cronManager
) {
parent::__construct('chill:cron-job:execute');
}

View File

@@ -21,8 +21,8 @@ use Symfony\Component\Console\Output\OutputInterface;
class LoadAddressesBEFromBestAddressCommand extends Command
{
public function __construct(
private AddressReferenceBEFromBestAddress $addressImporter,
private PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter
private readonly AddressReferenceBEFromBestAddress $addressImporter,
private readonly PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter
) {
parent::__construct();
}

View File

@@ -19,7 +19,7 @@ use Symfony\Component\Console\Output\OutputInterface;
class LoadAddressesFRFromBANOCommand extends Command
{
public function __construct(private AddressReferenceFromBano $addressReferenceFromBano)
public function __construct(private readonly AddressReferenceFromBano $addressReferenceFromBano)
{
parent::__construct();
}

View File

@@ -26,9 +26,9 @@ use function in_array;
*/
class LoadAndUpdateLanguagesCommand extends Command
{
public const INCLUDE_ANCIENT = 'include_ancient';
final public const INCLUDE_ANCIENT = 'include_ancient';
public const INCLUDE_REGIONAL_VERSION = 'include_regional';
final public const INCLUDE_REGIONAL_VERSION = 'include_regional';
// Array of ancien languages (to exclude)
private $ancientToExclude = ['ang', 'egy', 'fro', 'goh', 'grc', 'la', 'non', 'peo', 'pro', 'sga',
@@ -43,7 +43,7 @@ class LoadAndUpdateLanguagesCommand extends Command
*
* @param $availableLanguages
*/
public function __construct(private EntityManager $entityManager, private $availableLanguages)
public function __construct(private readonly EntityManager $entityManager, private $availableLanguages)
{
parent::__construct();
}

View File

@@ -25,7 +25,7 @@ class LoadCountriesCommand extends Command
*
* @param $availableLanguages
*/
public function __construct(private EntityManager $entityManager, private $availableLanguages)
public function __construct(private readonly EntityManager $entityManager, private $availableLanguages)
{
parent::__construct();
}

View File

@@ -18,7 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface;
class LoadPostalCodeFR extends Command
{
public function __construct(private PostalCodeFRFromOpenData $loader)
public function __construct(private readonly PostalCodeFRFromOpenData $loader)
{
parent::__construct();
}

View File

@@ -30,7 +30,7 @@ use function strlen;
class LoadPostalCodesCommand extends Command
{
public function __construct(private EntityManagerInterface $entityManager, private ValidatorInterface $validator)
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly ValidatorInterface $validator)
{
parent::__construct();
}
@@ -90,7 +90,7 @@ class LoadPostalCodesCommand extends Command
0,
$input->getOption('delimiter'),
$input->getOption('enclosure'),
$input->getOption('escape')
(string) $input->getOption('escape')
))
) {
try {
@@ -109,7 +109,7 @@ class LoadPostalCodesCommand extends Command
private function addPostalCode($row, OutputInterface $output)
{
if ('FR' === $row[2] && strlen($row[0]) === 4) {
if ('FR' === $row[2] && strlen((string) $row[0]) === 4) {
// CP in FRANCE are on 5 digit
// For CP starting with a zero, the starting zero can be remove if stored as number in a csv
// add a zero if CP from FR and on 4 digit

View File

@@ -29,7 +29,7 @@ class SetPasswordCommand extends Command
/**
* SetPasswordCommand constructor.
*/
public function __construct(private EntityManager $entityManager)
public function __construct(private readonly EntityManager $entityManager)
{
parent::__construct();
}

View File

@@ -19,7 +19,7 @@ use Symfony\Component\Console\Output\OutputInterface;
class SynchronizeEntityInfoViewsCommand extends Command
{
public function __construct(
private ViewEntityInfoManager $viewEntityInfoManager,
private readonly ViewEntityInfoManager $viewEntityInfoManager,
) {
parent::__construct('chill:db:sync-views');
}

View File

@@ -28,7 +28,7 @@ use function trim;
final class AddressReferenceAPIController extends ApiController
{
public function __construct(private AddressReferenceRepository $addressReferenceRepository, private PaginatorFactory $paginatorFactory)
public function __construct(private readonly AddressReferenceRepository $addressReferenceRepository, private readonly PaginatorFactory $paginatorFactory)
{
}
@@ -45,7 +45,7 @@ final class AddressReferenceAPIController extends ApiController
$pattern = $request->query->get('q');
if ('' === trim($pattern)) {
if ('' === trim((string) $pattern)) {
throw new BadRequestHttpException('the search pattern is empty');
}

View File

@@ -23,7 +23,7 @@ use Symfony\Component\Serializer\SerializerInterface;
class AddressToReferenceMatcherController
{
public function __construct(private Security $security, private EntityManagerInterface $entityManager, private SerializerInterface $serializer)
public function __construct(private readonly Security $security, private readonly EntityManagerInterface $entityManager, private readonly SerializerInterface $serializer)
{
}

View File

@@ -53,13 +53,13 @@ use function unserialize;
class ExportController extends AbstractController
{
public function __construct(
private ChillRedis $redis,
private ExportManager $exportManager,
private FormFactoryInterface $formFactory,
private LoggerInterface $logger,
private SessionInterface $session,
private TranslatorInterface $translator,
private EntityManagerInterface $entityManager,
private readonly ChillRedis $redis,
private readonly ExportManager $exportManager,
private readonly FormFactoryInterface $formFactory,
private readonly LoggerInterface $logger,
private readonly SessionInterface $session,
private readonly TranslatorInterface $translator,
private readonly EntityManagerInterface $entityManager,
private readonly ExportFormHelper $exportFormHelper,
private readonly SavedExportRepositoryInterface $savedExportRepository,
private readonly Security $security

View File

@@ -24,7 +24,7 @@ use Symfony\Component\Serializer\SerializerInterface;
class GeographicalUnitByAddressApiController
{
public function __construct(private PaginatorFactory $paginatorFactory, private GeographicalUnitRepositoryInterface $geographicalUnitRepository, private Security $security, private SerializerInterface $serializer)
public function __construct(private readonly PaginatorFactory $paginatorFactory, private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository, private readonly Security $security, private readonly SerializerInterface $serializer)
{
}

View File

@@ -33,7 +33,7 @@ use UnexpectedValueException;
*/
class NotificationApiController
{
public function __construct(private EntityManagerInterface $entityManager, private NotificationRepository $notificationRepository, private PaginatorFactory $paginatorFactory, private Security $security, private SerializerInterface $serializer)
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly NotificationRepository $notificationRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer)
{
}

View File

@@ -41,7 +41,7 @@ use function in_array;
*/
class NotificationController extends AbstractController
{
public function __construct(private EntityManagerInterface $em, private LoggerInterface $chillLogger, private LoggerInterface $logger, private Security $security, private NotificationRepository $notificationRepository, private NotificationHandlerManager $notificationHandlerManager, private PaginatorFactory $paginatorFactory, private TranslatorInterface $translator, private UserRepository $userRepository)
public function __construct(private readonly EntityManagerInterface $em, private readonly LoggerInterface $chillLogger, private readonly LoggerInterface $logger, private readonly Security $security, private readonly NotificationRepository $notificationRepository, private readonly NotificationHandlerManager $notificationHandlerManager, private readonly PaginatorFactory $paginatorFactory, private readonly TranslatorInterface $translator, private readonly UserRepository $userRepository)
{
}

View File

@@ -24,7 +24,7 @@ use function json_decode;
class PermissionApiController extends AbstractController
{
public function __construct(private DenormalizerInterface $denormalizer, private Security $security)
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly Security $security)
{
}

View File

@@ -26,7 +26,7 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
final class PostalCodeAPIController extends ApiController
{
public function __construct(private CountryRepository $countryRepository, private PostalCodeRepositoryInterface $postalCodeRepository, private PaginatorFactory $paginatorFactory)
public function __construct(private readonly CountryRepository $countryRepository, private readonly PostalCodeRepositoryInterface $postalCodeRepository, private readonly PaginatorFactory $paginatorFactory)
{
}
@@ -43,7 +43,7 @@ final class PostalCodeAPIController extends ApiController
$pattern = $request->query->get('q');
if ('' === trim($pattern)) {
if ('' === trim((string) $pattern)) {
throw new BadRequestHttpException('the search pattern is empty');
}

View File

@@ -36,7 +36,7 @@ use function count;
class SavedExportController
{
public function __construct(private EngineInterface $templating, private EntityManagerInterface $entityManager, private ExportManager $exportManager, private FormFactoryInterface $formFactory, private SavedExportRepositoryInterface $savedExportRepository, private Security $security, private SessionInterface $session, private TranslatorInterface $translator, private UrlGeneratorInterface $urlGenerator)
public function __construct(private readonly EngineInterface $templating, private readonly EntityManagerInterface $entityManager, private readonly ExportManager $exportManager, private readonly FormFactoryInterface $formFactory, private readonly SavedExportRepositoryInterface $savedExportRepository, private readonly Security $security, private readonly SessionInterface $session, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator)
{
}

View File

@@ -103,7 +103,7 @@ class SearchController extends AbstractController
public function searchAction(Request $request, $_format)
{
$pattern = trim($request->query->get('q', ''));
$pattern = trim((string) $request->query->get('q', ''));
if ('' === $pattern) {
switch ($_format) {

View File

@@ -22,7 +22,7 @@ use function count;
class TimelineCenterController extends AbstractController
{
public function __construct(protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private Security $security)
public function __construct(protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private readonly Security $security)
{
}

View File

@@ -36,9 +36,9 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
class UserController extends CRUDController
{
public const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
final public const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
public function __construct(private LoggerInterface $logger, private ValidatorInterface $validator, private UserPasswordEncoderInterface $passwordEncoder, private UserRepository $userRepository, protected ParameterBagInterface $parameterBag)
public function __construct(private readonly LoggerInterface $logger, private readonly ValidatorInterface $validator, private readonly UserPasswordEncoderInterface $passwordEncoder, private readonly UserRepository $userRepository, protected ParameterBagInterface $parameterBag)
{
}

View File

@@ -30,7 +30,7 @@ use Symfony\Component\Serializer\SerializerInterface;
class WorkflowApiController
{
public function __construct(private EntityManagerInterface $entityManager, private EntityWorkflowRepository $entityWorkflowRepository, private PaginatorFactory $paginatorFactory, private Security $security, private SerializerInterface $serializer)
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer)
{
}

View File

@@ -39,7 +39,7 @@ use function count;
class WorkflowController extends AbstractController
{
public function __construct(private EntityWorkflowManager $entityWorkflowManager, private EntityWorkflowRepository $entityWorkflowRepository, private ValidatorInterface $validator, private PaginatorFactory $paginatorFactory, private Registry $registry, private EntityManagerInterface $entityManager, private TranslatorInterface $translator, private Security $security)
public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly ValidatorInterface $validator, private readonly PaginatorFactory $paginatorFactory, private readonly Registry $registry, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly Security $security)
{
}

View File

@@ -84,7 +84,7 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde
->getEncoder($user)
->encodePassword('password', $user->getSalt())
)
->setEmail(sprintf('%s@chill.social', str_replace(' ', '', $username)));
->setEmail(sprintf('%s@chill.social', str_replace(' ', '', (string) $username)));
foreach ($params['groupCenterRefs'] as $groupCenterRef) {
$user->addGroupCenter($this->getReference($groupCenterRef));

View File

@@ -36,7 +36,7 @@ class ShortMessageCompilerPass implements CompilerPassInterface
{
$config = $container->resolveEnvPlaceholders($container->getParameter('chill_main.short_messages'), true);
// weird fix for special characters
$config['dsn'] = str_replace(['%%'], ['%'], $config['dsn']);
$config['dsn'] = str_replace(['%%'], ['%'], (string) $config['dsn']);
$dsn = parse_url($config['dsn']);
parse_str($dsn['query'] ?? '', $dsn['queries']);

View File

@@ -26,7 +26,7 @@ class Configuration implements ConfigurationInterface
public function __construct(
array $widgetFactories,
private ContainerBuilder $containerBuilder
private readonly ContainerBuilder $containerBuilder
) {
$this->setWidgetFactories($widgetFactories);
}

View File

@@ -22,7 +22,7 @@ use Symfony\Component\Security\Core\Security;
class TrackCreateUpdateSubscriber implements EventSubscriber
{
public function __construct(private Security $security)
public function __construct(private readonly Security $security)
{
}

View File

@@ -20,7 +20,7 @@ class Point implements JsonSerializable
{
public static string $SRID = '4326';
private function __construct(private ?float $lon, private ?float $lat)
private function __construct(private readonly ?float $lon, private readonly ?float $lat)
{
}

View File

@@ -29,7 +29,7 @@ use function reset;
*/
class NativeDateIntervalType extends DateIntervalType
{
public const FORMAT = '%rP%YY%MM%DDT%HH%IM%SS';
final public const FORMAT = '%rP%YY%MM%DDT%HH%IM%SS';
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
@@ -51,7 +51,7 @@ class NativeDateIntervalType extends DateIntervalType
}
try {
$strings = explode(' ', $value);
$strings = explode(' ', (string) $value);
if (count($strings) === 0) {
return null;
@@ -101,8 +101,8 @@ class NativeDateIntervalType extends DateIntervalType
return $current . $unit;
}
if (preg_match('/([0-9]{2}\:[0-9]{2}:[0-9]{2})/', $current) === 1) {
$tExploded = explode(':', $current);
if (preg_match('/([0-9]{2}\:[0-9]{2}:[0-9]{2})/', (string) $current) === 1) {
$tExploded = explode(':', (string) $current);
$intervalSpec = 'T';
$intervalSpec .= $tExploded[0] . 'H';
$intervalSpec .= $tExploded[1] . 'M';

View File

@@ -21,7 +21,7 @@ use Doctrine\DBAL\Types\Type;
*/
class PointType extends Type
{
public const POINT = 'point';
final public const POINT = 'point';
public function canRequireSQLConversion()
{

View File

@@ -40,19 +40,19 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
/**
* When an Address does match with the AddressReference
*/
public const ADDR_REFERENCE_STATUS_MATCH = 'match';
final public const ADDR_REFERENCE_STATUS_MATCH = 'match';
/**
* When an Address does not match with the AddressReference, and
* is pending for a review
*/
public const ADDR_REFERENCE_STATUS_TO_REVIEW = 'to_review';
final public const ADDR_REFERENCE_STATUS_TO_REVIEW = 'to_review';
/**
* When an Address does not match with the AddressReference, but
* is reviewed
*/
public const ADDR_REFERENCE_STATUS_REVIEWED = 'reviewed';
final public const ADDR_REFERENCE_STATUS_REVIEWED = 'reviewed';
/**
* @ORM\ManyToOne(targetEntity=AddressReference::class)

View File

@@ -20,9 +20,9 @@ use Doctrine\ORM\Mapping as ORM;
*/
class CronJobExecution
{
public const FAILURE = 100;
final public const FAILURE = 100;
public const SUCCESS = 1;
final public const SUCCESS = 1;
/**
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})

View File

@@ -27,15 +27,15 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
*/
class LocationType
{
public const DEFAULT_FOR_3PARTY = 'thirdparty';
final public const DEFAULT_FOR_3PARTY = 'thirdparty';
public const DEFAULT_FOR_PERSON = 'person';
final public const DEFAULT_FOR_PERSON = 'person';
public const STATUS_NEVER = 'never';
final public const STATUS_NEVER = 'never';
public const STATUS_OPTIONAL = 'optional';
final public const STATUS_OPTIONAL = 'optional';
public const STATUS_REQUIRED = 'required';
final public const STATUS_REQUIRED = 'required';
/**
* @ORM\Column(type="boolean", nullable=true)

View File

@@ -78,7 +78,7 @@ interface AggregatorInterface extends ModifierInterface
*
* @return Closure where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }`
*/
public function getLabels($key, array $values, $data);
public function getLabels($key, array $values, mixed $data);
/**
* give the list of keys the current export added to the queryBuilder in

View File

@@ -33,5 +33,5 @@ interface ExportElementValidatedInterface
*
* @param mixed $data the data, as returned by the user
*/
public function validateForm($data, ExecutionContextInterface $context);
public function validateForm(mixed $data, ExecutionContextInterface $context);
}

View File

@@ -99,7 +99,7 @@ interface ExportInterface extends ExportElementInterface
*
* @return (callable(null|string|int|float|'_header' $value): string|int|\DateTimeInterface) where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }`
*/
public function getLabels($key, array $values, $data);
public function getLabels($key, array $values, mixed $data);
/**
* give the list of keys the current export added to the queryBuilder in

View File

@@ -70,9 +70,9 @@ class ExportManager
private $user;
public function __construct(
private LoggerInterface $logger,
private AuthorizationCheckerInterface $authorizationChecker,
private AuthorizationHelperInterface $authorizationHelper,
private readonly LoggerInterface $logger,
private readonly AuthorizationCheckerInterface $authorizationChecker,
private readonly AuthorizationHelperInterface $authorizationHelper,
TokenStorageInterface $tokenStorage,
iterable $exports,
iterable $aggregators,

View File

@@ -18,7 +18,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class DateTimeHelper
{
public function __construct(private TranslatorInterface $translator)
public function __construct(private readonly TranslatorInterface $translator)
{
}

View File

@@ -32,25 +32,25 @@ class ExportAddressHelper
/**
* Compute all the F_* constants.
*/
public const F_ALL =
final public const F_ALL =
self::F_ATTRIBUTES | self::F_BUILDING | self::F_COUNTRY |
self::F_GEOM | self::F_POSTAL_CODE | self::F_STREET | self::F_GEOGRAPHICAL_UNITS;
public const F_AS_STRING = 0b00010000;
final public const F_AS_STRING = 0b00010000;
public const F_ATTRIBUTES = 0b01000000;
final public const F_ATTRIBUTES = 0b01000000;
public const F_BUILDING = 0b00001000;
final public const F_BUILDING = 0b00001000;
public const F_COUNTRY = 0b00000001;
final public const F_COUNTRY = 0b00000001;
public const F_GEOGRAPHICAL_UNITS = 0b1000000000;
final public const F_GEOGRAPHICAL_UNITS = 0b1000000000;
public const F_GEOM = 0b00100000;
final public const F_GEOM = 0b00100000;
public const F_POSTAL_CODE = 0b00000010;
final public const F_POSTAL_CODE = 0b00000010;
public const F_STREET = 0b00000100;
final public const F_STREET = 0b00000100;
private const ALL = [
'country' => self::F_COUNTRY,
@@ -84,7 +84,7 @@ class ExportAddressHelper
*/
private ?array $unitRefsKeysCache = [];
public function __construct(private AddressRender $addressRender, private AddressRepository $addressRepository, private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper)
public function __construct(private readonly AddressRender $addressRender, private readonly AddressRepository $addressRepository, private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper)
{
}
@@ -253,7 +253,7 @@ class ExportAddressHelper
public function getLabel($key, array $values, $data, string $prefix = '', string $translationPrefix = 'export.address_helper.'): callable
{
$sanitizedKey = substr($key, strlen($prefix));
$sanitizedKey = substr((string) $key, strlen($prefix));
switch ($sanitizedKey) {
case 'id':
@@ -333,7 +333,7 @@ class ExportAddressHelper
};
default:
$layerNamesKeys = array_merge($this->generateKeysForUnitsNames($prefix), $this->generateKeysForUnitsRefs($prefix));
$layerNamesKeys = [...$this->generateKeysForUnitsNames($prefix), ...$this->generateKeysForUnitsRefs($prefix)];
if (array_key_exists($key, $layerNamesKeys)) {
return function ($value) use ($key, $layerNamesKeys) {

View File

@@ -21,7 +21,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
*/
class TranslatableStringExportLabelHelper
{
public function __construct(private TranslatableStringHelperInterface $translatableStringHelper)
public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper)
{
}

View File

@@ -18,7 +18,7 @@ use const SORT_NUMERIC;
class UserHelper
{
public function __construct(private UserRender $userRender, private UserRepositoryInterface $userRepository)
public function __construct(private readonly UserRender $userRender, private readonly UserRepositoryInterface $userRepository)
{
}

View File

@@ -19,7 +19,7 @@ use Symfony\Component\Security\Core\Security;
final class PrivateCommentDataMapper extends AbstractType implements DataMapperInterface
{
public function __construct(private Security $security)
public function __construct(private readonly Security $security)
{
}

View File

@@ -16,7 +16,7 @@ use Symfony\Component\Form\DataMapperInterface;
class ScopePickerDataMapper implements DataMapperInterface
{
public function __construct(private ?Scope $scope = null)
public function __construct(private readonly ?Scope $scope = null)
{
}

View File

@@ -29,12 +29,12 @@ use function call_user_func;
*/
class IdToEntityDataTransformer implements DataTransformerInterface
{
private Closure $getId;
private readonly Closure $getId;
/**
* @param Closure $getId
*/
public function __construct(private ObjectRepository $repository, private bool $multiple = false, ?callable $getId = null)
public function __construct(private readonly ObjectRepository $repository, private readonly bool $multiple = false, ?callable $getId = null)
{
$this->getId = $getId ?? static fn (object $o) => $o->getId();
}

View File

@@ -15,7 +15,7 @@ use Symfony\Component\Form\FormBuilderInterface;
class CustomizeFormEvent extends \Symfony\Component\EventDispatcher\Event
{
public const NAME = 'chill_main.customize_form';
final public const NAME = 'chill_main.customize_form';
public function __construct(protected string $type, protected FormBuilderInterface $builder)
{

View File

@@ -24,7 +24,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
final class LocationFormType extends AbstractType
{
public function __construct(private TranslatableStringHelper $translatableStringHelper)
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper)
{
}

View File

@@ -24,7 +24,7 @@ use function count;
class PermissionsGroupType extends AbstractType
{
public const FLAG_SCOPE = 'permissions_group';
final public const FLAG_SCOPE = 'permissions_group';
/**
* @var PermissionsGroupFlagProvider[]

View File

@@ -20,9 +20,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class ChillPhoneNumberType extends AbstractType
{
private string $defaultCarrierCode;
private readonly string $defaultCarrierCode;
private PhoneNumberUtil $phoneNumberUtil;
private readonly PhoneNumberUtil $phoneNumberUtil;
public function __construct(ParameterBagInterface $parameterBag)
{

View File

@@ -44,7 +44,7 @@ class ComposedRoleScopeType extends AbstractType
private $rolesWithoutScope = [];
public function __construct(
private TranslatableStringHelper $translatableStringHelper,
private readonly TranslatableStringHelper $translatableStringHelper,
RoleProvider $roleProvider
) {
$this->roles = $roleProvider->getRoles();

View File

@@ -15,7 +15,7 @@ use Chill\MainBundle\Repository\AddressRepository;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
final class AddressToIdDataTransformer implements DataTransformerInterface
final readonly class AddressToIdDataTransformer implements DataTransformerInterface
{
public function __construct(private AddressRepository $addressRepository)
{

View File

@@ -23,7 +23,7 @@ use function count;
class CenterTransformer implements DataTransformerInterface
{
public function __construct(private CenterRepository $centerRepository, private bool $multiple = false)
public function __construct(private readonly CenterRepository $centerRepository, private readonly bool $multiple = false)
{
}
@@ -40,7 +40,7 @@ class CenterTransformer implements DataTransformerInterface
$ids = [];
if ($this->multiple) {
$ids = explode(',', $id);
$ids = explode(',', (string) $id);
} else {
$ids[] = (int) $id;
}

View File

@@ -25,7 +25,7 @@ use function array_key_exists;
class EntityToJsonTransformer implements DataTransformerInterface
{
public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private bool $multiple, private string $type)
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly bool $multiple, private readonly string $type)
{
}
@@ -35,7 +35,7 @@ class EntityToJsonTransformer implements DataTransformerInterface
return null;
}
$denormalized = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
$denormalized = json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR);
if ($this->multiple) {
if (null === $denormalized) {

View File

@@ -17,7 +17,7 @@ use Symfony\Component\Form\DataTransformerInterface;
class MultipleObjectsToIdTransformer implements DataTransformerInterface
{
public function __construct(private EntityManagerInterface $em, private ?string $class = null)
public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null)
{
}

View File

@@ -17,7 +17,7 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
class ObjectToIdTransformer implements DataTransformerInterface
{
public function __construct(private EntityManagerInterface $em, private ?string $class = null)
public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null)
{
}

View File

@@ -20,7 +20,7 @@ use function is_int;
class PostalCodeToIdTransformer implements DataTransformerInterface
{
public function __construct(private PostalCodeRepositoryInterface $postalCodeRepository)
public function __construct(private readonly PostalCodeRepositoryInterface $postalCodeRepository)
{
}

View File

@@ -18,7 +18,7 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
class ScopeTransformer implements DataTransformerInterface
{
public function __construct(private EntityManagerInterface $em)
public function __construct(private readonly EntityManagerInterface $em)
{
}

View File

@@ -20,13 +20,13 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class ExportType extends AbstractType
{
public const AGGREGATOR_KEY = 'aggregators';
final public const AGGREGATOR_KEY = 'aggregators';
public const EXPORT_KEY = 'export';
final public const EXPORT_KEY = 'export';
public const FILTER_KEY = 'filters';
final public const FILTER_KEY = 'filters';
public const PICK_FORMATTER_KEY = 'pick_formatter';
final public const PICK_FORMATTER_KEY = 'pick_formatter';
/**
* @var ExportManager

View File

@@ -19,7 +19,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class FilterType extends AbstractType
{
public const ENABLED_FIELD = 'enabled';
final public const ENABLED_FIELD = 'enabled';
public function __construct()
{

View File

@@ -35,9 +35,9 @@ final class PickCenterType extends AbstractType
public const CENTERS_IDENTIFIERS = 'c';
public function __construct(
private ExportManager $exportManager,
private RegroupmentRepository $regroupmentRepository,
private AuthorizationHelperForCurrentUserInterface $authorizationHelper
private readonly ExportManager $exportManager,
private readonly RegroupmentRepository $regroupmentRepository,
private readonly AuthorizationHelperForCurrentUserInterface $authorizationHelper
) {
}

View File

@@ -43,7 +43,7 @@ use function uniqid;
*/
final class PickAddressType extends AbstractType
{
public function __construct(private AddressToIdDataTransformer $addressToIdDataTransformer, private TranslatorInterface $translator)
public function __construct(private readonly AddressToIdDataTransformer $addressToIdDataTransformer, private readonly TranslatorInterface $translator)
{
}

View File

@@ -21,7 +21,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickCivilityType extends AbstractType
{
public function __construct(private TranslatableStringHelper $translatableStringHelper)
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper)
{
}

View File

@@ -19,7 +19,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickLocationTypeType extends AbstractType
{
public function __construct(private TranslatableStringHelper $translatableStringHelper)
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper)
{
}

View File

@@ -21,7 +21,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickPostalCodeType extends AbstractType
{
public function __construct(private PostalCodeToIdTransformer $postalCodeToIdTransformer)
public function __construct(private readonly PostalCodeToIdTransformer $postalCodeToIdTransformer)
{
}

View File

@@ -55,7 +55,7 @@ class PickRollingDateType extends AbstractType
'class' => RollingDate::class,
'empty_data' => new RollingDate(RollingDate::T_TODAY),
'constraints' => [
new Callback([$this, 'validate']),
new Callback($this->validate(...)),
],
]);
}

View File

@@ -27,7 +27,7 @@ use Symfony\Component\Serializer\SerializerInterface;
*/
class PickUserDynamicType extends AbstractType
{
public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private NormalizerInterface $normalizer)
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly NormalizerInterface $normalizer)
{
}

View File

@@ -20,7 +20,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickUserLocationType extends AbstractType
{
public function __construct(private TranslatableStringHelper $translatableStringHelper, private LocationRepository $locationRepository)
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly LocationRepository $locationRepository)
{
}

View File

@@ -42,7 +42,7 @@ use function count;
*/
class ScopePickerType extends AbstractType
{
public function __construct(private AuthorizationHelperInterface $authorizationHelper, private Security $security, private TranslatableStringHelperInterface $translatableStringHelper)
public function __construct(private readonly AuthorizationHelperInterface $authorizationHelper, private readonly Security $security, private readonly TranslatableStringHelperInterface $translatableStringHelper)
{
}

View File

@@ -29,7 +29,7 @@ use const SORT_STRING;
*/
class Select2CountryType extends AbstractType
{
public function __construct(private RequestStack $requestStack, private ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
{
}

View File

@@ -29,7 +29,7 @@ use const SORT_STRING;
*/
class Select2LanguageType extends AbstractType
{
public function __construct(private RequestStack $requestStack, private ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
{
}

View File

@@ -28,7 +28,7 @@ class TranslatableStringFormType extends AbstractType
private $frameworkTranslatorFallback; // The langagues used for the translation
public function __construct(private array $availableLanguages, Translator $translator)
public function __construct(private readonly array $availableLanguages, Translator $translator)
{
$this->frameworkTranslatorFallback = $translator->getFallbackLocales();
}

View File

@@ -49,7 +49,7 @@ class UserPickerType extends AbstractType
TokenStorageInterface $tokenStorage,
protected UserRepository $userRepository,
protected UserACLAwareRepositoryInterface $userACLAwareRepository,
private UserRender $userRender
private readonly UserRender $userRender
) {
$this->authorizationHelper = $authorizationHelper;
$this->tokenStorage = $tokenStorage;

View File

@@ -35,7 +35,7 @@ use Symfony\Component\Validator\Constraints\Regex;
class UserType extends AbstractType
{
public function __construct(private TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
{
}

View File

@@ -36,7 +36,7 @@ use function array_key_exists;
class WorkflowStepType extends AbstractType
{
public function __construct(private EntityWorkflowManager $entityWorkflowManager, private Registry $registry, private TranslatableStringHelperInterface $translatableStringHelper)
public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly Registry $registry, private readonly TranslatableStringHelperInterface $translatableStringHelper)
{
}

View File

@@ -23,7 +23,7 @@ use Doctrine\ORM\Event\PreFlushEventArgs;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Security\Core\User\UserInterface;
final class NotificationByUserCounter implements NotificationCounterInterface
final readonly class NotificationByUserCounter implements NotificationCounterInterface
{
public function __construct(private CacheItemPoolInterface $cacheItemPool, private NotificationRepository $notificationRepository)
{

View File

@@ -25,7 +25,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class NotificationMailer
{
public function __construct(private MailerInterface $mailer, private LoggerInterface $logger, private TranslatorInterface $translator)
public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly TranslatorInterface $translator)
{
}

View File

@@ -19,7 +19,7 @@ use function count;
class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberInterface
{
public function __construct(private EntityManagerInterface $em, private NotificationPersisterInterface $persister)
public function __construct(private readonly EntityManagerInterface $em, private readonly NotificationPersisterInterface $persister)
{
}

View File

@@ -40,7 +40,7 @@ class Mailer
* @param $routeParameters
* @param mixed[] $routeParameters
*/
public function __construct(private MailerInterface $mailer, private LoggerInterface $logger, private EngineInterface $twig, private RouterInterface $router, private TranslatorInterface $translator, protected $routeParameters)
public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly EngineInterface $twig, private readonly RouterInterface $router, private readonly TranslatorInterface $translator, protected $routeParameters)
{
}

View File

@@ -15,7 +15,7 @@ use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound;
use Doctrine\ORM\EntityManagerInterface;
final class NotificationHandlerManager
final readonly class NotificationHandlerManager
{
public function __construct(private iterable $handlers, private EntityManagerInterface $em)
{

View File

@@ -24,7 +24,7 @@ class NotificationPresence
{
private array $cache = [];
public function __construct(private Security $security, private NotificationRepository $notificationRepository)
public function __construct(private readonly Security $security, private readonly NotificationRepository $notificationRepository)
{
}

View File

@@ -21,7 +21,7 @@ use Twig\Extension\RuntimeExtensionInterface;
class NotificationTwigExtensionRuntime implements RuntimeExtensionInterface
{
public function __construct(private FormFactoryInterface $formFactory, private NotificationPresence $notificationPresence, private UrlGeneratorInterface $urlGenerator)
public function __construct(private readonly FormFactoryInterface $formFactory, private readonly NotificationPresence $notificationPresence, private readonly UrlGeneratorInterface $urlGenerator)
{
}

View File

@@ -25,7 +25,7 @@ class ChillItemsPerPageTwig extends AbstractExtension
return [
new TwigFunction(
'chill_items_per_page',
[$this, 'paginationRender'],
$this->paginationRender(...),
[
'needs_environment' => true,
'is_safe' => ['html'],

View File

@@ -20,16 +20,16 @@ use Twig\TwigFunction;
*/
class ChillPaginationTwig extends AbstractExtension
{
public const LONG_TEMPLATE = '@ChillMain/Pagination/long.html.twig';
final public const LONG_TEMPLATE = '@ChillMain/Pagination/long.html.twig';
public const SHORT_TEMPLATE = '@ChillMain/Pagination/short.html.twig';
final public const SHORT_TEMPLATE = '@ChillMain/Pagination/short.html.twig';
public function getFunctions()
{
return [
new TwigFunction(
'chill_pagination',
[$this, 'paginationRender'],
$this->paginationRender(...),
[
'needs_environment' => true,
'is_safe' => ['html'],

View File

@@ -19,11 +19,11 @@ use Symfony\Component\Routing\RouterInterface;
*/
class PaginatorFactory
{
public const DEFAULT_CURRENT_PAGE_KEY = 'page';
final public const DEFAULT_CURRENT_PAGE_KEY = 'page';
public const DEFAULT_ITEM_PER_NUMBER_KEY = 'item_per_page';
final public const DEFAULT_ITEM_PER_NUMBER_KEY = 'item_per_page';
public const DEFAULT_PAGE_NUMBER = 1;
final public const DEFAULT_PAGE_NUMBER = 1;
/**
* @param int $itemPerPage
@@ -32,11 +32,11 @@ class PaginatorFactory
/**
* the request stack.
*/
private RequestStack $requestStack,
private readonly RequestStack $requestStack,
/**
* the router and generator for url.
*/
private RouterInterface $router,
private readonly RouterInterface $router,
/**
* the default item per page. This may be overriden by
* the request or inside the paginator.

View File

@@ -35,28 +35,28 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface
public const LOOKUP_URI = 'https://lookups.twilio.com/v1/PhoneNumbers/%s';
private array $config;
private readonly array $config;
private bool $isConfigured = false;
private PhonenumberUtil $phoneNumberUtil;
private readonly PhonenumberUtil $phoneNumberUtil;
private Client $twilioClient;
public function __construct(
private CacheItemPoolInterface $cachePool,
private readonly CacheItemPoolInterface $cachePool,
ParameterBagInterface $parameterBag,
private LoggerInterface $logger
private readonly LoggerInterface $logger
) {
$this->config = $config = $parameterBag->get('chill_main.phone_helper');
if (
array_key_exists('twilio_sid', $config)
&& !empty($config['twilio_sid'])
&& strlen($config['twilio_sid']) > 2
&& strlen((string) $config['twilio_sid']) > 2
&& array_key_exists('twilio_secret', $config)
&& !empty($config['twilio_secret'])
&& strlen($config['twilio_secret']) > 2
&& strlen((string) $config['twilio_secret']) > 2
) {
$this->twilioClient = new Client([
'auth' => [$config['twilio_sid'], $config['twilio_secret']],

View File

@@ -28,7 +28,7 @@ class Templating extends AbstractExtension
public function getFilters()
{
return [
new TwigFilter('chill_format_phonenumber', [$this, 'formatPhonenumber']),
new TwigFilter('chill_format_phonenumber', $this->formatPhonenumber(...)),
];
}
}

View File

@@ -16,13 +16,13 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
final class RedisConnectionFactory implements EventSubscriberInterface
{
private string $host;
private readonly string $host;
private int $port;
private readonly int $port;
private ChillRedis $redis;
private readonly ChillRedis $redis;
private int $timeout;
private readonly int $timeout;
public function __construct($parameters)
{

View File

@@ -28,9 +28,9 @@ use function trim;
final class AddressReferenceRepository implements ObjectRepository
{
private EntityManagerInterface $entityManager;
private readonly EntityManagerInterface $entityManager;
private EntityRepository $repository;
private readonly EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -19,7 +19,7 @@ use Doctrine\Persistence\ObjectRepository;
final class AddressRepository implements ObjectRepository
{
private EntityRepository $repository;
private readonly EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository;
final class CenterRepository implements CenterRepositoryInterface
{
private EntityRepository $repository;
private readonly EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository;
class CivilityRepository implements CivilityRepositoryInterface
{
private EntityRepository $repository;
private readonly EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -19,7 +19,7 @@ use Doctrine\Persistence\ObjectRepository;
final class CountryRepository implements ObjectRepository
{
private EntityRepository $repository;
private readonly EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository;
class CronJobExecutionRepository implements CronJobExecutionRepositoryInterface
{
private EntityRepository $repository;
private readonly EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository;
final class GeographicalUnitLayerLayerRepository implements GeographicalUnitLayerRepositoryInterface
{
private EntityRepository $repository;
private readonly EntityRepository $repository;
public function __construct(EntityManagerInterface $em)
{

View File

@@ -20,7 +20,7 @@ use Doctrine\ORM\QueryBuilder;
final class GeographicalUnitRepository implements GeographicalUnitRepositoryInterface
{
private EntityRepository $repository;
private readonly EntityRepository $repository;
public function __construct(EntityManagerInterface $em)
{

View File

@@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository;
final class GroupCenterRepository implements ObjectRepository
{
private EntityRepository $repository;
private readonly EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository;
final class LanguageRepository implements LanguageRepositoryInterface
{
private EntityRepository $repository;
private readonly EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

Some files were not shown because too many files have changed in this diff Show More