Skip to content

Commit 8a2b584

Browse files
OskarStarkxabbuh
authored andcommitted
[Filesystem][Finder][Form] Use CPP
1 parent 2edb77e commit 8a2b584

File tree

67 files changed

+299
-454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+299
-454
lines changed

AbstractRendererEngine.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface, Re
2525
*/
2626
public const CACHE_KEY_VAR = 'cache_key';
2727

28-
protected array $defaultThemes;
29-
3028
/**
3129
* @var array[]
3230
*/
@@ -53,9 +51,9 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface, Re
5351
* @param array $defaultThemes The default themes. The type of these
5452
* themes is open to the implementation.
5553
*/
56-
public function __construct(array $defaultThemes = [])
57-
{
58-
$this->defaultThemes = $defaultThemes;
54+
public function __construct(
55+
protected array $defaultThemes = [],
56+
) {
5957
}
6058

6159
public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes = true): void

Button.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@
2626
class Button implements \IteratorAggregate, FormInterface
2727
{
2828
private ?FormInterface $parent = null;
29-
private FormConfigInterface $config;
3029
private bool $submitted = false;
3130

3231
/**
3332
* Creates a new button from a form configuration.
3433
*/
35-
public function __construct(FormConfigInterface $config)
36-
{
37-
$this->config = $config;
34+
public function __construct(
35+
private FormConfigInterface $config,
36+
) {
3837
}
3938

4039
/**

ButtonBuilder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
3131
private ResolvedFormTypeInterface $type;
3232
private string $name;
3333
private array $attributes = [];
34-
private array $options;
3534

3635
/**
3736
* @throws InvalidArgumentException if the name is empty
3837
*/
39-
public function __construct(?string $name, array $options = [])
40-
{
38+
public function __construct(
39+
?string $name,
40+
private array $options = [],
41+
) {
4142
if ('' === $name || null === $name) {
4243
throw new InvalidArgumentException('Buttons cannot have empty names.');
4344
}
4445

4546
$this->name = $name;
46-
$this->options = $options;
4747

4848
FormConfigBuilder::validateName($name);
4949
}

ChoiceList/LazyChoiceList.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
*/
2828
class LazyChoiceList implements ChoiceListInterface
2929
{
30-
private ChoiceLoaderInterface $loader;
31-
3230
/**
3331
* The callable creating string values for each choice.
3432
*
@@ -43,11 +41,13 @@ class LazyChoiceList implements ChoiceListInterface
4341
* The callable receives the choice as first and the array key as the second
4442
* argument.
4543
*
46-
* @param callable|null $value The callable generating the choice values
44+
* @param callable|null $value The callable creating string values for each choice.
45+
* If null, choices are cast to strings.
4746
*/
48-
public function __construct(ChoiceLoaderInterface $loader, callable $value = null)
49-
{
50-
$this->loader = $loader;
47+
public function __construct(
48+
private ChoiceLoaderInterface $loader,
49+
callable $value = null,
50+
) {
5151
$this->value = null === $value ? null : $value(...);
5252
}
5353

ChoiceList/View/ChoiceGroupView.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,15 @@
2020
*/
2121
class ChoiceGroupView implements \IteratorAggregate
2222
{
23-
public string $label;
24-
public array $choices;
25-
2623
/**
2724
* Creates a new choice group view.
2825
*
2926
* @param array<ChoiceGroupView|ChoiceView> $choices the choice views in the group
3027
*/
31-
public function __construct(string $label, array $choices = [])
32-
{
33-
$this->label = $label;
34-
$this->choices = $choices;
28+
public function __construct(
29+
public string $label,
30+
public array $choices = [],
31+
) {
3532
}
3633

3734
/**

ChoiceList/View/ChoiceListView.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,16 @@
2222
*/
2323
class ChoiceListView
2424
{
25-
public array $choices;
26-
public array $preferredChoices;
27-
2825
/**
2926
* Creates a new choice list view.
3027
*
3128
* @param array<ChoiceGroupView|ChoiceView> $choices The choice views
3229
* @param array<ChoiceGroupView|ChoiceView> $preferredChoices the preferred choice views
3330
*/
34-
public function __construct(array $choices = [], array $preferredChoices = [])
35-
{
36-
$this->choices = $choices;
37-
$this->preferredChoices = $preferredChoices;
31+
public function __construct(
32+
public array $choices = [],
33+
public array $preferredChoices = [],
34+
) {
3835
}
3936

4037
/**

ChoiceList/View/ChoiceView.php

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@
2020
*/
2121
class ChoiceView
2222
{
23-
public string|TranslatableInterface|false $label;
24-
public string $value;
25-
public mixed $data;
26-
27-
/**
28-
* Additional attributes for the HTML tag.
29-
*/
30-
public array $attr;
31-
32-
/**
33-
* Additional parameters used to translate the label.
34-
*/
35-
public array $labelTranslationParameters;
36-
3723
/**
3824
* Creates a new choice view.
3925
*
@@ -43,12 +29,12 @@ class ChoiceView
4329
* @param array $attr Additional attributes for the HTML tag
4430
* @param array $labelTranslationParameters Additional parameters used to translate the label
4531
*/
46-
public function __construct(mixed $data, string $value, string|TranslatableInterface|false $label, array $attr = [], array $labelTranslationParameters = [])
47-
{
48-
$this->data = $data;
49-
$this->value = $value;
50-
$this->label = $label;
51-
$this->attr = $attr;
52-
$this->labelTranslationParameters = $labelTranslationParameters;
32+
public function __construct(
33+
public mixed $data,
34+
public string $value,
35+
public string|TranslatableInterface|false $label,
36+
public array $attr = [],
37+
public array $labelTranslationParameters = [],
38+
) {
5339
}
5440
}

Command/DebugCommand.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,15 @@
3535
#[AsCommand(name: 'debug:form', description: 'Display form type information')]
3636
class DebugCommand extends Command
3737
{
38-
private FormRegistryInterface $formRegistry;
39-
private array $namespaces;
40-
private array $types;
41-
private array $extensions;
42-
private array $guessers;
43-
private ?FileLinkFormatter $fileLinkFormatter;
44-
45-
public function __construct(FormRegistryInterface $formRegistry, array $namespaces = ['Symfony\Component\Form\Extension\Core\Type'], array $types = [], array $extensions = [], array $guessers = [], FileLinkFormatter $fileLinkFormatter = null)
46-
{
38+
public function __construct(
39+
private FormRegistryInterface $formRegistry,
40+
private array $namespaces = ['Symfony\Component\Form\Extension\Core\Type'],
41+
private array $types = [],
42+
private array $extensions = [],
43+
private array $guessers = [],
44+
private ?FileLinkFormatter $fileLinkFormatter = null,
45+
) {
4746
parent::__construct();
48-
49-
$this->formRegistry = $formRegistry;
50-
$this->namespaces = $namespaces;
51-
$this->types = $types;
52-
$this->extensions = $extensions;
53-
$this->guessers = $guessers;
54-
$this->fileLinkFormatter = $fileLinkFormatter;
5547
}
5648

5749
protected function configure(): void

Extension/Core/CoreExtension.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ class CoreExtension extends AbstractExtension
3030
{
3131
private PropertyAccessorInterface $propertyAccessor;
3232
private ChoiceListFactoryInterface $choiceListFactory;
33-
private ?TranslatorInterface $translator;
3433

35-
public function __construct(PropertyAccessorInterface $propertyAccessor = null, ChoiceListFactoryInterface $choiceListFactory = null, TranslatorInterface $translator = null)
36-
{
34+
public function __construct(
35+
PropertyAccessorInterface $propertyAccessor = null,
36+
ChoiceListFactoryInterface $choiceListFactory = null,
37+
private ?TranslatorInterface $translator = null,
38+
) {
3739
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
3840
$this->choiceListFactory = $choiceListFactory ?? new CachingFactoryDecorator(new PropertyAccessDecorator(new DefaultChoiceListFactory(), $this->propertyAccessor));
39-
$this->translator = $translator;
4041
}
4142

4243
protected function loadTypes(): array

Extension/Core/DataAccessor/ChainAccessor.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020
*/
2121
class ChainAccessor implements DataAccessorInterface
2222
{
23-
private iterable $accessors;
24-
2523
/**
2624
* @param DataAccessorInterface[]|iterable $accessors
2725
*/
28-
public function __construct(iterable $accessors)
29-
{
30-
$this->accessors = $accessors;
26+
public function __construct(
27+
private iterable $accessors,
28+
) {
3129
}
3230

3331
public function getValue(object|array $data, FormInterface $form): mixed

0 commit comments

Comments
 (0)