mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-11 22:58:26 +00:00
DX: apply rector rules up to php8.0
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
])
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user