8000 minor #53493 [Filesystem][Finder][Form] Use CPP (OskarStark) · symfony/symfony@d4b1992 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit d4b1992

Browse files
committed
minor #53493 [Filesystem][Finder][Form] Use CPP (OskarStark)
This PR was squashed before being merged into the 7.1 branch. Discussion ---------- [Filesystem][Finder][Form] Use CPP | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | -- | License | MIT Commits ------- 7f15676 [Filesystem][Finder][Form] Use CPP
2 parents b40b65d + 7f15676 commit d4b1992

File tree

85 files changed

+400
-573
lines changed

Some content is hidden

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

85 files changed

+400
-573
lines changed

src/Symfony/Component/Filesystem/Exception/IOException.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
*/
2121
class IOException extends \RuntimeException implements IOExceptionInterface
2222
{
23-
private ?string $path;
24-
25-
public function __construct(string $message, int $code = 0, \Throwable $previous = null, string $path = null)
26-
{
27-
$this->path = $path;
28-
23+
public function __construct(
24+
string $message,
25+
int $code = 0,
26+
\Throwable $previous = null,
27+
private ?string $path = null,
28+
) {
2929
parent::__construct($message, $code, $previous);
3030
}
3131

src/Symfony/Component/Finder/Comparator/Comparator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
*/
1717
class Comparator
1818
{
19-
private string $target;
2019
private string $operator;
2120

22-
public function __construct(string $target, string $operator = '==')
23-
{
21+
public function __construct(
22+
private string $target,
23+
string $operator = '==',
24+
) {
2425
if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
2526
throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
2627
}
2728

28-
$this->target = $target;
2929
$this->operator = $operator;
3030
}
3131

src/Symfony/Component/Finder/SplFileInfo.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,17 @@
1818
*/
1919
class SplFileInfo extends \SplFileInfo
2020
{
21-
private string $relativePath;
22-
private string $relativePathname;
23-
2421
/**
2522
* @param string $file The file name
2623
* @param string $relativePath The relative path
2724
* @param string $relativePathname The relative path name
2825
*/
29-
public function __construct(string $file, string $relativePath, string $relativePathname)
30-
{
26+
public function __construct(
27+
string $file,
28+
private string $relativePath,
29+
private string $relativePathname,
30+
) {
3131
parent::__construct($file);
32-
$this->relativePath = $relativePath;
33-
$this->relativePathname = $relativePathname;
3432
}
3533

3634
/**

src/Symfony/Component/Form/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

src/Symfony/Component/Form/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
/**

src/Symfony/Component/Form/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
}

src/Symfony/Component/Form/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

src/Symfony/Component/Form/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
/**

src/Symfony/Component/Form/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
/**

src/Symfony/Component/Form/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
}

src/Symfony/Component/Form/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

src/Symfony/Component/Form/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

src/Symfony/Component/Form/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

src/Symfony/Component/Form/Extension/Core/DataTransformer/ArrayToPartsTransformer.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
*/
2222
class ArrayToPartsTransformer implements DataTransformerInterface
2323
{
24-
private array $partMapping;
25-
26-
public function __construct(array $partMapping)
27-
{
28-
$this->partMapping = $partMapping;
24+
public function __construct(
25+
private array $partMapping,
26+
) {
2927
}
3028

3129
public function transform(mixed $array): mixed

src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToValueTransformer.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222
*/
2323
class ChoiceToValueTransformer implements DataTransformerInterface
2424
{
25-
private ChoiceListInterface $choiceList;
26-
27-
public function __construct(ChoiceListInterface $choiceList)
28-
{
29-
$this->choiceList = $choiceList;
25+
public function __construct(
26+
private ChoiceListInterface $choiceList,
27+
) {
3028
}
3129

3230
public function transform(mixed $choice): mixed

src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToValuesTransformer.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222
*/
2323
class ChoicesToValuesTransformer implements DataTransformerInterface
2424
{
25-
private ChoiceListInterface $choiceList;
26-
27-
public function __construct(ChoiceListInterface $choiceList)
28-
{
29-
$this->choiceList = $choiceList;
25+
public function __construct(
26+
private ChoiceListInterface $choiceList,
27+
) {
3028
}
3129

3230
/**

src/Symfony/Component/Form/Extension/Core/DataTransformer/DataTransformerChain.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@
2121
*/
2222
class DataTransformerChain implements DataTransformerInterface
2323
{
24-
protected array $transformers;
25-
2624
/**
2725
* Uses the given value transformers to transform values.
2826
*
2927
* @param DataTransformerInterface[] $transformers
3028
*/
31-
public function __construct(array $transformers)
32-
{
33-
$this->transformers = $transformers;
29+
public function __construct(
30+
protected array $transformers,
31+
) {
3432
}
3533

3634
/**

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ class DateIntervalToArrayTransformer implements DataTransformerInterface
4242
self::INVERT => 'r',
4343
];
4444
private array $fields;
45-
private bool $pad;
4645

4746
/**
4847
* @param string[]|null $fields The date fields
4948
* @param bool $pad Whether to use padding
5049
*/
51-
public function __construct(array $fields = null, bool $pad = false)
52-
{
50+
public function __construct(
51+
array $fields = null,
52+
private bool $pad = false,
53+
) {
5354
$this->fields = $fields ?? ['years', 'months', 'days', 'hours', 'minutes', 'seconds', 'invert'];
54-
$this->pad = $pad;
5555
}
5656

5757
/**

0 commit comments

Comments
 (0)
0