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

@@ -44,27 +44,18 @@ class CustomFieldChoice extends AbstractCustomField
private $defaultLocales;
/**
* @var TwigEngine
*/
private $templating;
/**
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
*/
private $translatableStringHelper;
/**
* CustomFieldChoice constructor.
*/
public function __construct(
TranslatorInterface $translator,
TwigEngine $templating,
TranslatableStringHelper $translatableStringHelper
private TwigEngine $templating,
/**
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
*/
private TranslatableStringHelper $translatableStringHelper
) {
$this->defaultLocales = $translator->getFallbackLocales();
$this->templating = $templating;
$this->translatableStringHelper = $translatableStringHelper;
}
public function allowOtherChoice(CustomField $cf)
@@ -228,7 +219,7 @@ class CustomFieldChoice extends AbstractCustomField
*
* @return bool
*/
public function isChecked(CustomField $cf, $choiceSlug, $data)
public function isChecked(CustomField $cf, $choiceSlug, array|string $data)
{
if (null === $data) {
return false;
@@ -330,10 +321,9 @@ class CustomFieldChoice extends AbstractCustomField
* deserialized the data from the database to a multiple
* field.
*
* @param mixed $serialized
* @param bool $allowOther
*/
private function deserializeToMultiple($serialized, $allowOther)
private function deserializeToMultiple(mixed $serialized, $allowOther)
{
$value = $this->guessValue($serialized);
@@ -387,7 +377,7 @@ class CustomFieldChoice extends AbstractCustomField
*
* @return mixed
*/
private function guessValue($value)
private function guessValue(array|string $value)
{
if (null === $value) {
return null;

View File

@@ -44,20 +44,8 @@ class CustomFieldDate extends AbstractCustomField
*/
public const MIN = 'min';
/**
* @var TwigEngine
*/
private $templating;
/**
* @var TranslatableStringHelper
*/
private $translatableStringHelper;
public function __construct(TwigEngine $templating, TranslatableStringHelper $translatableStringHelper)
public function __construct(private TwigEngine $templating, private TranslatableStringHelper $translatableStringHelper)
{
$this->templating = $templating;
$this->translatableStringHelper = $translatableStringHelper;
}
public function buildForm(FormBuilderInterface $builder, CustomField $customField)
@@ -82,7 +70,7 @@ class CustomFieldDate extends AbstractCustomField
$validatorFunction = static function ($value, ExecutionContextInterface $context) {
try {
$date = new DateTime($value);
} catch (Exception $e) {
} catch (Exception) {
$context->buildViolation('The expression "%expression%" is invalid', [
'%expression%' => $value,
])

View File

@@ -30,20 +30,8 @@ class CustomFieldLongChoice extends AbstractCustomField
{
public const KEY = 'key';
private OptionRepository $optionRepository;
private TwigEngine $templating;
private TranslatableStringHelper $translatableStringHelper;
public function __construct(
OptionRepository $optionRepository,
TranslatableStringHelper $translatableStringHelper,
TwigEngine $twigEngine
) {
$this->optionRepository = $optionRepository;
$this->translatableStringHelper = $translatableStringHelper;
$this->templating = $twigEngine;
public function __construct(private OptionRepository $optionRepository, private TranslatableStringHelper $translatableStringHelper, private TwigEngine $templating)
{
}
public function buildForm(FormBuilderInterface $builder, CustomField $customField)
@@ -130,7 +118,7 @@ class CustomFieldLongChoice extends AbstractCustomField
if (!$value instanceof Option) {
throw new LogicException('the value should be an instance of '
. 'Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option, '
. is_object($value) ? get_class($value) : gettype($value) . ' given');
. is_object($value) ? $value::class : gettype($value) . ' given');
}
// we place the id in array, to allow in the future multiple select

View File

@@ -39,20 +39,8 @@ class CustomFieldNumber extends AbstractCustomField
public const SCALE = 'scale';
/**
* @var TwigEngine
*/
private $templating;
/**
* @var TranslatableStringHelper
*/
private $translatableStringHelper;
public function __construct(TwigEngine $templating, TranslatableStringHelper $translatableStringHelper)
public function __construct(private TwigEngine $templating, private TranslatableStringHelper $translatableStringHelper)
{
$this->templating = $templating;
$this->translatableStringHelper = $translatableStringHelper;
}
public function buildForm(FormBuilderInterface $builder, CustomField $customField)

View File

@@ -29,26 +29,14 @@ class CustomFieldText extends AbstractCustomField
public const MULTIPLE_CF_INLINE = 'multipleCFInline';
private $requestStack;
/**
* @var TwigEngine
*/
private $templating;
/**
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
*/
private $translatableStringHelper;
public function __construct(
RequestStack $requestStack,
TwigEngine $templating,
TranslatableStringHelper $translatableStringHelper
private RequestStack $requestStack,
private TwigEngine $templating,
/**
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
*/
private TranslatableStringHelper $translatableStringHelper
) {
$this->requestStack = $requestStack;
$this->templating = $templating;
$this->translatableStringHelper = $translatableStringHelper;
}
/**

View File

@@ -27,26 +27,14 @@ class CustomFieldTitle extends AbstractCustomField
public const TYPE_TITLE = 'title';
private $requestStack;
/**
* @var TwigEngine
*/
private $templating;
/**
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
*/
private $translatableStringHelper;
public function __construct(
RequestStack $requestStack,
TwigEngine $templating,
TranslatableStringHelper $translatableStringHelper
private RequestStack $requestStack,
private TwigEngine $templating,
/**
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
*/
private TranslatableStringHelper $translatableStringHelper
) {
$this->requestStack = $requestStack;
$this->templating = $templating;
$this->translatableStringHelper = $translatableStringHelper;
}
public function buildForm(FormBuilderInterface $builder, CustomField $customField)