mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
apply rector rules: php up to php82
This commit is contained in:
@@ -34,9 +34,9 @@ use function count;
|
||||
*/
|
||||
class CreateFieldsOnGroupCommand extends Command
|
||||
{
|
||||
public const ARG_DELETE = 'delete';
|
||||
final public const ARG_DELETE = 'delete';
|
||||
|
||||
public const ARG_PATH = 'path';
|
||||
final public const ARG_PATH = 'path';
|
||||
|
||||
/**
|
||||
* CreateFieldsOnGroupCommand constructor.
|
||||
@@ -45,9 +45,9 @@ class CreateFieldsOnGroupCommand extends Command
|
||||
* @param $customizablesEntities
|
||||
*/
|
||||
public function __construct(
|
||||
private CustomFieldProvider $customFieldProvider,
|
||||
private EntityManager $entityManager,
|
||||
private ValidatorInterface $validator,
|
||||
private readonly CustomFieldProvider $customFieldProvider,
|
||||
private readonly EntityManager $entityManager,
|
||||
private readonly ValidatorInterface $validator,
|
||||
private $availableLanguages,
|
||||
private $customizablesEntities
|
||||
) {
|
||||
|
@@ -36,7 +36,7 @@ class CustomFieldsGroupController extends AbstractController
|
||||
/**
|
||||
* CustomFieldsGroupController constructor.
|
||||
*/
|
||||
public function __construct(private CustomFieldProvider $customFieldProvider, private TranslatorInterface $translator)
|
||||
public function __construct(private readonly CustomFieldProvider $customFieldProvider, private readonly TranslatorInterface $translator)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -32,15 +32,15 @@ use function LogicException;
|
||||
|
||||
class CustomFieldChoice extends AbstractCustomField
|
||||
{
|
||||
public const ALLOW_OTHER = 'other';
|
||||
final public const ALLOW_OTHER = 'other';
|
||||
|
||||
public const CHOICES = 'choices';
|
||||
final public const CHOICES = 'choices';
|
||||
|
||||
public const EXPANDED = 'expanded';
|
||||
final public const EXPANDED = 'expanded';
|
||||
|
||||
public const MULTIPLE = 'multiple';
|
||||
final public const MULTIPLE = 'multiple';
|
||||
|
||||
public const OTHER_VALUE_LABEL = 'otherValueLabel';
|
||||
final public const OTHER_VALUE_LABEL = 'otherValueLabel';
|
||||
|
||||
private $defaultLocales;
|
||||
|
||||
@@ -49,11 +49,11 @@ class CustomFieldChoice extends AbstractCustomField
|
||||
*/
|
||||
public function __construct(
|
||||
TranslatorInterface $translator,
|
||||
private TwigEngine $templating,
|
||||
private readonly TwigEngine $templating,
|
||||
/**
|
||||
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
|
||||
*/
|
||||
private TranslatableStringHelper $translatableStringHelper
|
||||
private readonly TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->defaultLocales = $translator->getFallbackLocales();
|
||||
}
|
||||
|
@@ -33,18 +33,18 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
*/
|
||||
class CustomFieldDate extends AbstractCustomField
|
||||
{
|
||||
public const DATE_FORMAT = DateTime::RFC3339;
|
||||
final public const DATE_FORMAT = DateTime::RFC3339;
|
||||
|
||||
public const FORMAT = 'format';
|
||||
final public const FORMAT = 'format';
|
||||
|
||||
public const MAX = 'max';
|
||||
final public const MAX = 'max';
|
||||
|
||||
/**
|
||||
* key for the minimal value of the field.
|
||||
*/
|
||||
public const MIN = 'min';
|
||||
final public const MIN = 'min';
|
||||
|
||||
public function __construct(private TwigEngine $templating, private TranslatableStringHelper $translatableStringHelper)
|
||||
public function __construct(private readonly TwigEngine $templating, private readonly TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -30,12 +30,12 @@ use function is_object;
|
||||
|
||||
class CustomFieldLongChoice extends AbstractCustomField
|
||||
{
|
||||
public const KEY = 'key';
|
||||
final public const KEY = 'key';
|
||||
|
||||
public function __construct(
|
||||
private OptionRepository $optionRepository,
|
||||
private TranslatableStringHelper $translatableStringHelper,
|
||||
private EngineInterface $templating,
|
||||
private readonly OptionRepository $optionRepository,
|
||||
private readonly TranslatableStringHelper $translatableStringHelper,
|
||||
private readonly EngineInterface $templating,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@@ -28,18 +28,18 @@ use Symfony\Component\Validator\Constraints\LessThanOrEqual;
|
||||
*/
|
||||
class CustomFieldNumber extends AbstractCustomField
|
||||
{
|
||||
public const MAX = 'max';
|
||||
final public const MAX = 'max';
|
||||
|
||||
/**
|
||||
* key for the minimal value of the field.
|
||||
*/
|
||||
public const MIN = 'min';
|
||||
final public const MIN = 'min';
|
||||
|
||||
public const POST_TEXT = 'post_text';
|
||||
final public const POST_TEXT = 'post_text';
|
||||
|
||||
public const SCALE = 'scale';
|
||||
final public const SCALE = 'scale';
|
||||
|
||||
public function __construct(private TwigEngine $templating, private TranslatableStringHelper $translatableStringHelper)
|
||||
public function __construct(private readonly TwigEngine $templating, private readonly TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -25,17 +25,17 @@ use function array_key_exists;
|
||||
|
||||
class CustomFieldText extends AbstractCustomField
|
||||
{
|
||||
public const MAX_LENGTH = 'maxLength';
|
||||
final public const MAX_LENGTH = 'maxLength';
|
||||
|
||||
public const MULTIPLE_CF_INLINE = 'multipleCFInline';
|
||||
final public const MULTIPLE_CF_INLINE = 'multipleCFInline';
|
||||
|
||||
public function __construct(
|
||||
private RequestStack $requestStack,
|
||||
private TwigEngine $templating,
|
||||
private readonly RequestStack $requestStack,
|
||||
private readonly TwigEngine $templating,
|
||||
/**
|
||||
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
|
||||
*/
|
||||
private TranslatableStringHelper $translatableStringHelper
|
||||
private readonly TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
}
|
||||
|
||||
|
@@ -21,19 +21,19 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
class CustomFieldTitle extends AbstractCustomField
|
||||
{
|
||||
public const TYPE = 'type';
|
||||
final public const TYPE = 'type';
|
||||
|
||||
public const TYPE_SUBTITLE = 'subtitle';
|
||||
final public const TYPE_SUBTITLE = 'subtitle';
|
||||
|
||||
public const TYPE_TITLE = 'title';
|
||||
final public const TYPE_TITLE = 'title';
|
||||
|
||||
public function __construct(
|
||||
private RequestStack $requestStack,
|
||||
private TwigEngine $templating,
|
||||
private readonly RequestStack $requestStack,
|
||||
private readonly TwigEngine $templating,
|
||||
/**
|
||||
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
|
||||
*/
|
||||
private TranslatableStringHelper $translatableStringHelper
|
||||
private readonly TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
}
|
||||
|
||||
|
@@ -22,9 +22,9 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
*/
|
||||
class CustomField
|
||||
{
|
||||
public const ONE_TO_MANY = 2;
|
||||
final public const ONE_TO_MANY = 2;
|
||||
|
||||
public const ONE_TO_ONE = 1;
|
||||
final public const ONE_TO_ONE = 1;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
|
@@ -30,7 +30,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class CustomFieldType extends AbstractType
|
||||
{
|
||||
public function __construct(private CustomFieldProvider $customFieldProvider, private ObjectManager $om, private TranslatableStringHelper $translatableStringHelper)
|
||||
public function __construct(private readonly CustomFieldProvider $customFieldProvider, private readonly ObjectManager $om, private readonly TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -26,9 +26,9 @@ use function count;
|
||||
class CustomFieldsGroupType extends AbstractType
|
||||
{
|
||||
public function __construct(
|
||||
private array $customizableEntities,
|
||||
private readonly array $customizableEntities,
|
||||
//TODO : add comment about this variable
|
||||
private TranslatorInterface $translator
|
||||
private readonly TranslatorInterface $translator
|
||||
) {
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ use Symfony\Component\Form\DataTransformerInterface;
|
||||
|
||||
class CustomFieldDataTransformer implements DataTransformerInterface
|
||||
{
|
||||
public function __construct(private CustomFieldInterface $customFieldDefinition, private CustomField $customField)
|
||||
public function __construct(private readonly CustomFieldInterface $customFieldDefinition, private readonly CustomField $customField)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@ use function gettype;
|
||||
|
||||
class CustomFieldsGroupToIdTransformer implements DataTransformerInterface
|
||||
{
|
||||
public function __construct(private ObjectManager $om)
|
||||
public function __construct(private readonly ObjectManager $om)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -24,9 +24,9 @@ use const JSON_THROW_ON_ERROR;
|
||||
*/
|
||||
class JsonCustomFieldToArrayTransformer implements DataTransformerInterface
|
||||
{
|
||||
private array $customField;
|
||||
private readonly array $customField;
|
||||
|
||||
public function __construct(private ObjectManager $om)
|
||||
public function __construct(private readonly ObjectManager $om)
|
||||
{
|
||||
$customFields = $this->om
|
||||
->getRepository(CustomField::class)
|
||||
@@ -68,13 +68,13 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface
|
||||
if (array_key_exists($key, $this->customField)) {
|
||||
$type = $this->customField[$key]->getType();
|
||||
|
||||
if (str_starts_with($type, 'ManyToOne')) {
|
||||
if (str_starts_with((string) $type, 'ManyToOne')) {
|
||||
// pour le manytoone() faire
|
||||
// un update du form en js ? : http://symfony.com/fr/doc/current/cookbook/form/form_collections.html
|
||||
//
|
||||
//$entityClass = substr($type, 10, -1);
|
||||
//echo $entityClasss;
|
||||
if (str_starts_with($type, 'ManyToOnePersist')) {
|
||||
if (str_starts_with((string) $type, 'ManyToOnePersist')) {
|
||||
// PEUT ETRE A FAIRE SI SEULEMENT $value->getId() ne renvoie rien...
|
||||
//
|
||||
//
|
||||
@@ -112,7 +112,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface
|
||||
if (null === $customFieldsJSON) {
|
||||
$customFieldsArray = [];
|
||||
} else {
|
||||
$customFieldsArray = json_decode($customFieldsJSON, true, 512, JSON_THROW_ON_ERROR);
|
||||
$customFieldsArray = json_decode((string) $customFieldsJSON, true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
$customFieldsArrayRet = [];
|
||||
@@ -123,11 +123,11 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface
|
||||
if (array_key_exists($key, $this->customField)) {
|
||||
$type = $this->customField[$key]->getType();
|
||||
|
||||
if (str_starts_with($type, 'ManyToOne')) {
|
||||
if (str_starts_with($type, 'ManyToOnePersist')) {
|
||||
$entityClass = substr($type, 17, -1);
|
||||
if (str_starts_with((string) $type, 'ManyToOne')) {
|
||||
if (str_starts_with((string) $type, 'ManyToOnePersist')) {
|
||||
$entityClass = substr((string) $type, 17, -1);
|
||||
} else {
|
||||
$entityClass = substr($type, 10, -1);
|
||||
$entityClass = substr((string) $type, 10, -1);
|
||||
}
|
||||
|
||||
$customFieldsArrayRet[$key] = $this->om
|
||||
|
@@ -24,7 +24,7 @@ class CustomFieldType extends AbstractType
|
||||
*/
|
||||
private $customFieldCompiler;
|
||||
|
||||
public function __construct(private ObjectManager $om, CustomFieldProvider $compiler)
|
||||
public function __construct(private readonly ObjectManager $om, CustomFieldProvider $compiler)
|
||||
{
|
||||
$this->customFieldCompiler = $compiler;
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ class LinkedCustomFieldsType extends AbstractType
|
||||
*/
|
||||
private $options = [];
|
||||
|
||||
public function __construct(private TranslatableStringHelper $translatableStringHelper)
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class LinkedCustomFieldsType extends AbstractType
|
||||
|
||||
$builder->addEventListener(
|
||||
FormEvents::POST_SET_DATA,
|
||||
[$this, 'appendChoice']
|
||||
$this->appendChoice(...)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,7 @@ class CustomFieldsHelper
|
||||
* @param CustomFieldProvider $provider The customfield provider that
|
||||
* contains all the declared custom fields
|
||||
*/
|
||||
public function __construct(private EntityManagerInterface $em, private CustomFieldProvider $provider)
|
||||
public function __construct(private readonly EntityManagerInterface $em, private readonly CustomFieldProvider $provider)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,7 @@ class CustomFieldRenderingTwig extends AbstractExtension implements ContainerAwa
|
||||
'label_layout' => 'ChillCustomFieldsBundle:CustomField:render_label.html.twig',
|
||||
];
|
||||
|
||||
public function __construct(private CustomFieldsHelper $customFieldsHelper)
|
||||
public function __construct(private readonly CustomFieldsHelper $customFieldsHelper)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -50,26 +50,17 @@ class CustomFieldRenderingTwig extends AbstractExtension implements ContainerAwa
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new TwigFunction('chill_custom_field_widget', [
|
||||
$this,
|
||||
'renderWidget',
|
||||
], [
|
||||
new TwigFunction('chill_custom_field_widget', $this->renderWidget(...), [
|
||||
'is_safe' => [
|
||||
'html',
|
||||
],
|
||||
]),
|
||||
new TwigFunction('chill_custom_field_label', [
|
||||
$this,
|
||||
'renderLabel',
|
||||
], [
|
||||
new TwigFunction('chill_custom_field_label', $this->renderLabel(...), [
|
||||
'is_safe' => [
|
||||
'html',
|
||||
],
|
||||
]),
|
||||
new TwigFunction('chill_custom_field_is_empty', [
|
||||
$this,
|
||||
'isEmptyValue',
|
||||
]),
|
||||
new TwigFunction('chill_custom_field_is_empty', $this->isEmptyValue(...)),
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -53,10 +53,7 @@ class CustomFieldsGroupRenderingTwig extends AbstractExtension implements Contai
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new TwigFunction('chill_custom_fields_group_widget', [
|
||||
$this,
|
||||
'renderWidget',
|
||||
], [
|
||||
new TwigFunction('chill_custom_fields_group_widget', $this->renderWidget(...), [
|
||||
'is_safe' => [
|
||||
'html',
|
||||
],
|
||||
|
Reference in New Issue
Block a user