Skip to content

Commit 49d1783

Browse files
committed
Refactor anonymous functions to static
Signed-off-by: Tim Goudriaan <tim@codedmonkey.com>
1 parent 4ce28c0 commit 49d1783

11 files changed

Lines changed: 14 additions & 14 deletions

File tree

bin/console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if (!is_file(dirname(__DIR__) . '/vendor/autoload_runtime.php')) {
1414

1515
require_once dirname(__DIR__) . '/vendor/autoload_runtime.php';
1616

17-
return function (array $context) {
17+
return static function (array $context) {
1818
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
1919

2020
return new Application($kernel);

bin/dirigent

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if (!is_file(dirname(__DIR__) . '/vendor/autoload_runtime.php')) {
1414

1515
require_once dirname(__DIR__) . '/vendor/autoload_runtime.php';
1616

17-
return function (array $context) {
17+
return static function (array $context) {
1818
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
1919

2020
return new ConsoleApplication($kernel);

public/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
require_once dirname(__DIR__) . '/vendor/autoload_runtime.php';
66

7-
return function (array $context) {
7+
return static function (array $context) {
88
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
99
};

src/Controller/Dashboard/DashboardCredentialsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function configureFields(string $pageName): iterable
3636
->setTemplatePath('dashboard/fields/credentials_type.html.twig')
3737
->setRequired(true)
3838
->setChoices(CredentialsType::cases())
39-
->setFormTypeOption('choice_label', function (CredentialsType $choice): string {
39+
->setFormTypeOption('choice_label', static function (CredentialsType $choice): string {
4040
return "credentials.type.{$choice->value}";
4141
})
4242
->renderExpanded();

src/Controller/Dashboard/DashboardRegistryController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function configureFields(string $pageName): iterable
6969
->setTemplatePath('dashboard/fields/registry_package_mirroring.html.twig')
7070
->setRequired(true)
7171
->setChoices(RegistryPackageMirroring::cases())
72-
->setFormTypeOption('choice_label', function (RegistryPackageMirroring $choice): string {
72+
->setFormTypeOption('choice_label', static function (RegistryPackageMirroring $choice): string {
7373
return "registry.package-mirroring.{$choice->value}";
7474
})
7575
->renderExpanded();

src/Doctrine/Entity/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ public function toComposerArray(): array
718718
}
719719

720720
if (isset($data['php-ext']['configure-options'])) {
721-
usort($data['php-ext']['configure-options'], fn ($a, $b) => ($a['name'] ?? '') <=> ($b['name'] ?? ''));
721+
usort($data['php-ext']['configure-options'], static fn ($a, $b) => ($a['name'] ?? '') <=> ($b['name'] ?? ''));
722722
}
723723

724724
return $data;

src/Doctrine/Repository/PackageRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function updatePackageLinks(Package $package, Version $version): void
166166
public function deletePackageLinks(Package $package): void
167167
{
168168
$connection = $this->getEntityManager()->getConnection();
169-
$connection->transactional(function (Connection $connection) use ($package) {
169+
$connection->transactional(static function (Connection $connection) use ($package) {
170170
$queryParameters = ['id' => $package->getId()];
171171

172172
$connection->executeStatement('DELETE FROM package_provide_link WHERE package_id = :id', $queryParameters);

src/Encryption/Encryption.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ public static function create(
5858
$privateKey = $filesystem->readFile($privateKeyPath);
5959
$publicKey = $filesystem->readFile($publicKeyPath);
6060
$rotatedKeys = array_map(
61-
fn (string $rotatedKeyPath): string => $filesystem->readFile($rotatedKeyPath),
61+
static fn (string $rotatedKeyPath): string => $filesystem->readFile($rotatedKeyPath),
6262
$rotatedKeyPaths
6363
);
6464
}
6565

6666
$binaryPrivateKey = sodium_hex2bin($privateKey);
6767
$binaryPublicKey = sodium_hex2bin($publicKey);
6868
$binaryRotatedKeys = array_map(
69-
fn (string $rotatedKey): string => sodium_hex2bin($rotatedKey),
69+
static fn (string $rotatedKey): string => sodium_hex2bin($rotatedKey),
7070
$rotatedKeys,
7171
);
7272

src/Form/NewPasswordType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ public function configureOptions(OptionsResolver $resolver): void
2222
'options' => [
2323
'attr' => ['autocomplete' => 'new-password'],
2424
],
25-
'first_options' => function (Options $options): array {
25+
'first_options' => static function (Options $options): array {
2626
$label = $options['new_password'] ? 'New password' : 'Password';
2727

2828
return [
2929
'constraints' => self::constraints(false),
3030
'label' => $label,
3131
];
3232
},
33-
'second_options' => function (Options $options): array {
33+
'second_options' => static function (Options $options): array {
3434
$label = $options['new_password'] ? 'Repeat new password' : 'Repeat password';
3535

3636
return [

src/Form/PackageAddMirroringFormType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
1717
->add('packages', TextareaType::class)
1818
->add('registry', EntityType::class, [
1919
'class' => Registry::class,
20-
'query_builder' => function (RegistryRepository $repository) {
20+
'query_builder' => static function (RegistryRepository $repository) {
2121
return $repository->createPackageMirroringQueryBuilder('manual');
2222
},
2323
]);

0 commit comments

Comments
 (0)