Skip to content

Commit c57c2eb

Browse files
nicolas-grekasfabpot
authored andcommitted
Bump minimum version of PHP to 8.1
1 parent 78cba1f commit c57c2eb

17 files changed

+21
-46
lines changed

CallbackTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class CallbackTransformer implements DataTransformerInterface
1818

1919
public function __construct(callable $transform, callable $reverseTransform)
2020
{
21-
$this->transform = $transform instanceof \Closure ? $transform : \Closure::fromCallable($transform);
22-
$this->reverseTransform = $reverseTransform instanceof \Closure ? $reverseTransform : \Closure::fromCallable($reverseTransform);
21+
$this->transform = $transform(...);
22+
$this->reverseTransform = $reverseTransform(...);
2323
}
2424

2525
/**

ChoiceList/Factory/Cache/AbstractStaticOption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final public function __construct(FormTypeInterface|FormTypeExtensionInterface $
4040
{
4141
$hash = CachingFactoryDecorator::generateHash([static::class, $formType, $vary]);
4242

43-
$this->option = self::$options[$hash] ??= $option instanceof \Closure || !\is_callable($option) ? $option : \Closure::fromCallable($option);
43+
$this->option = self::$options[$hash] ??= $option instanceof \Closure || \is_string($option) || \is_bool($option) || $option instanceof ChoiceLoaderInterface || !\is_callable($option) ? $option : $option(...);
4444
}
4545

4646
final public function getOption(): mixed

ChoiceList/LazyChoiceList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class LazyChoiceList implements ChoiceListInterface
4848
public function __construct(ChoiceLoaderInterface $loader, callable $value = null)
4949
{
5050
$this->loader = $loader;
51-
$this->value = null === $value || $value instanceof \Closure ? $value : \Closure::fromCallable($value);
51+
$this->value = null === $value ? null : $value(...);
5252
}
5353

5454
/**

ChoiceList/Loader/CallbackChoiceLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CallbackChoiceLoader extends AbstractChoiceLoader
2525
*/
2626
public function __construct(callable $callback)
2727
{
28-
$this->callback = $callback instanceof \Closure ? $callback : \Closure::fromCallable($callback);
28+
$this->callback = $callback(...);
2929
}
3030

3131
protected function loadChoices(): iterable

ChoiceList/Loader/FilterChoiceLoaderDecorator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FilterChoiceLoaderDecorator extends AbstractChoiceLoader
2424
public function __construct(ChoiceLoaderInterface $loader, callable $filter)
2525
{
2626
$this->decoratedLoader = $loader;
27-
$this->filter = $filter instanceof \Closure ? $filter : \Closure::fromCallable($filter);
27+
$this->filter = $filter(...);
2828
}
2929

3030
protected function loadChoices(): iterable

Command/DebugCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ private function getCoreTypes(): array
209209
{
210210
$coreExtension = new CoreExtension();
211211
$loadTypesRefMethod = (new \ReflectionObject($coreExtension))->getMethod('loadTypes');
212-
$loadTypesRefMethod->setAccessible(true);
213212
$coreTypes = $loadTypesRefMethod->invoke($coreExtension);
214213
$coreTypes = array_map(function (FormTypeInterface $type) { return \get_class($type); }, $coreTypes);
215214
sort($coreTypes);

Console/Descriptor/TextDescriptor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ protected function describeDefaults(array $options)
4545

4646
if ($options['service_types']) {
4747
$this->output->section('Service form types');
48-
$this->output->listing(array_map([$this, 'formatClassLink'], $options['service_types']));
48+
$this->output->listing(array_map($this->formatClassLink(...), $options['service_types']));
4949
}
5050

5151
if (!$options['show_deprecated']) {
5252
if ($options['extensions']) {
5353
$this->output->section('Type extensions');
54-
$this->output->listing(array_map([$this, 'formatClassLink'], $options['extensions']));
54+
$this->output->listing(array_map($this->formatClassLink(...), $options['extensions']));
5555
}
5656

5757
if ($options['guessers']) {
5858
$this->output->section('Type guessers');
59-
$this->output->listing(array_map([$this, 'formatClassLink'], $options['guessers']));
59+
$this->output->listing(array_map($this->formatClassLink(...), $options['guessers']));
6060
}
6161
}
6262
}
@@ -92,12 +92,12 @@ protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedF
9292

9393
if ($this->parents) {
9494
$this->output->section('Parent types');
95-
$this->output->listing(array_map([$this, 'formatClassLink'], $this->parents));
95+
$this->output->listing(array_map($this->formatClassLink(...), $this->parents));
9696
}
9797

9898
if ($this->extensions) {
9999
$this->output->section('Type extensions');
100-
$this->output->listing(array_map([$this, 'formatClassLink'], $this->extensions));
100+
$this->output->listing(array_map($this->formatClassLink(...), $this->extensions));
101101
}
102102
}
103103

Extension/Core/EventListener/ResizeFormListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(string $type, array $options = [], bool $allowAdd =
3737
$this->allowAdd = $allowAdd;
3838
$this->allowDelete = $allowDelete;
3939
$this->options = $options;
40-
$this->deleteEmpty = $deleteEmpty instanceof \Closure || !\is_callable($deleteEmpty) ? $deleteEmpty : \Closure::fromCallable($deleteEmpty);
40+
$this->deleteEmpty = \is_bool($deleteEmpty) ? $deleteEmpty : $deleteEmpty(...);
4141
}
4242

4343
public static function getSubscribedEvents(): array

Extension/Core/Type/EnumType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function configureOptions(OptionsResolver $resolver): void
2727
$resolver
2828
->setRequired(['class'])
2929
->setAllowedTypes('class', 'string')
30-
->setAllowedValues('class', \Closure::fromCallable('enum_exists'))
30+
->setAllowedValues('class', enum_exists(...))
3131
->setDefault('choices', static function (Options $options): array {
3232
return $options['class']::cases();
3333
})

FormConfigBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ public function getFormConfig(): FormConfigInterface
729729
*/
730730
public function setIsEmptyCallback(?callable $isEmptyCallback): static
731731
{
732-
$this->isEmptyCallback = null === $isEmptyCallback || $isEmptyCallback instanceof \Closure ? $isEmptyCallback : \Closure::fromCallable($isEmptyCallback);
732+
$this->isEmptyCallback = null === $isEmptyCallback ? null : $isEmptyCallback(...);
733733

734734
return $this;
735735
}

0 commit comments

Comments
 (0)